how to enable vector intrinsic functions in fortran frontend
Tobias Burnus
burnus@net-b.de
Wed Oct 17 17:25:00 GMT 2007
Sa Liu wrote:
> Tobias Burnus <burnus@net-b.de> wrote on 15.10.2007 21:05:17:
>
>>> I think an intrinsic module would be the best place for these to go.
>>>
>> The advantage of an intrinsic module would be that it keeps the
>> namespace clean; the disadvantage is that it is not directly compatible
>> with the XL Fortran compiler.
>>
> Concretely why is it not compatible with XL Fortran compiler? Sorry I'm
> not quite familar with intrinsic module.
>
Well, a Fortran module looks like:
module myModule
type myType
integer :: i
real :: r
end type myType
integer :: a ! a module variable
contains
subroutine foo(a)
type(myType) :: a
print *, a%i
print *, a%r
end subroutine foo
end module myModule
If one compiles this, a Module file "mymodule.mod" is created, which
contains the name of the global variables and the interface of the
procedure "foo".
In another module or in the (main) program, one can then say:
use myModule, myTypeRenamed => myType
type(myTypeRenamed) :: t
t = myTypeRenamed(42, 0.0)
a = 19
call foo(t)
and both the module variable "a" and the procedure "foo" (including its
interface) is known and the type declaration is here accessible under a
different name.
The Fortran 2003 standard defines some modules as intrinsic, i.e. they
are not provided by the user but must be provided by the compiler.
These intrinsic modules can be either simply .mod files or they are
"virtual" in the sense that the front end recognizes certain variables
only after the user has loaded a module via, e.g.,
use ISO_C_BINDING
or to prevent module-name clashes:
use, intrinsic :: ISO_C_BINDING
Thus, in order to use this VECTOR, one would have to insert in each
program (Fortran is case insensitive):
USE AltiVec_Vector_module
This has two disadvantage, a small one and a large one. The small one
is: xlf does not require the user to insert "use ..." before (s)he can
use VECTOR/VEC_*. And there is a large disadvantage: VECTOR(...) is not
a user-defined TYPE (= struct, or approx. class), procedure or a module
variable. It is a new syntax and can therefore not be represented as
module. Thus you need in any case a flag for VECTOR(...).
For theVEC_* you can use an intrinsic module, but I actually do not see
any advantage of doing so as one needs the flag in any case.
Tobias
More information about the Fortran
mailing list