Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

type aliasing

larson__michael
Beginner
229 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
Black Belt Retired Employee
229 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

2 Replies
Steve_Lionel
Black Belt Retired Employee
230 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

jimdempseyatthecove
Black Belt
229 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

Reply