Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

type aliasing

larson__michael
Beginner
857 Views

I can't seem to find an answer on the web for this..

Is there a way to alias a type like in c without creating a derived type?

In C

typedef float Vec4[4];

Now Vec4 is aliased to an array of 4 floats

 

What is it in Fortran? (without using a derived type)

 

As always thanks ahead of time.

 

 

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
857 Views

Fortran does not have type aliasing. There has been some discussion of it at the standards committee, but not everyone likes the idea. 

View solution in original post

0 Kudos
2 Replies
Steve_Lionel
Honored Contributor III
858 Views

Fortran does not have type aliasing. There has been some discussion of it at the standards committee, but not everyone likes the idea. 

0 Kudos
jimdempseyatthecove
Honored Contributor III
857 Views

Steve,

A suggestion you may bring up at the next standards committee that is but one way to provide for handling his is to suggest an anonymous user defined type.

************** for anyone reading this, the following is NOT part of the Fortran language **********

type Vec4
   real :: (4) ! note lack of member variable name
end type Vec4
...
type(Vec4) :: fido
...
fido = [1.0,2.0,3.0,4.0]
...
do I=1,4
    fido(I) = I
end do

Jim Dempsey

0 Kudos
Reply