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

Array of structure of arrays in fortran

Amlesh_K_
Beginner
1,156 Views

I have something like this - 

type output
real(kind=8) :: array1(10,20,30)
real(kind=8) :: array2(10,20,4)
end type output

type (output),save, dimension(54) :: array_o

Also, I have something like this - 

type output_pointer
real(kind=8),pointer :: array1(:,:,:)
real(kind=8),pointer :: array2(:,:,:)
end type output_pointer

type (output),save, dimension(54) :: array_pointer

Are these permissible in fortran? I am getting no build error but I am getting runtime error.

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
1,156 Views

Both should be acceptable. Can you provide an example.

Note, if you intend to have pointer to array point to an array (members of element of output_pointer pointing to members of element output) then the attribute of the members of output need the TARGET attribute (I am not sure if array_o needs TARGET, but the compiler will inform you if it does.)

Jim Dempsey

0 Kudos
mecej4
Honored Contributor III
1,156 Views

Are these permissible in fortran? I am getting no build error but I am getting runtime error.

I don't see what your type output_pointer has got to do do with anything else.

If the code could be compiled into an EXE, the program may be syntactically correct, but, there could be other errors in the program, such as uninitialized variables, dangling/unallocated pointer variables, etc., that cause runtime errors.

0 Kudos
Reply