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

Array of arrays

t_j_m
Beginner
454 Views
I need to make an array of arrays, is this possible in Fortran?. Let me explain, I have Xnumbers of networks(the networks are rank 2 arrays), each network contains X aounts data.
For example say I read a file that has 4 networks and each network has 4 coulmns and 4 rows. How can I write a code that will read the number of networks from a file, allocate that many arrays which will contain X amount of rank 2 arrays?
Thnaks
Again
0 Kudos
1 Reply
Steven_L_Intel1
Employee
454 Views
Not directly, but you can have an array of derived type where that derived type has array components. Something like this:


type t_network
integer, dimension(:,:), allocatable :: data
end type t_network

type(t_network), dimension(:), allocatable :: networks

... read number of networks

allocate (networks(n_networks))

do i=1,n_networks
allocate (networks(i)%data(n_networks,n_networks))
end do
...
0 Kudos
Reply