1

In my programme, I require a mulitidimensional array, in which the length of second and third dimension depend on the index of the first dimension. This is not directly possible with normal array in Fortran 90. Is there a equivalent of Class (in this sense) in Fortran that I can use here ?

Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
user35952
  • 93
  • 8

1 Answers1

0

Yes, this is possible by using derived types:

type myType
  integer :: index
  integer,allocatable :: arr(:,:)
end type

You can assign the scalar by

type(myType) :: var
var%index = 10

and similarly allocate the array:

allocate( var%arr( var%index, var%index ) )
Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68