Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

type aliasing

Jump to solution

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

Accepted Solutions
Highlighted
Black Belt

Fortran does not have type

Jump to solution

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

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

View solution in original post

0 Kudos
2 Replies
Highlighted
Black Belt
1 View

Fortran does not have type

Jump to solution

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

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

View solution in original post

0 Kudos
Highlighted

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