If I have the following code (thanks to M. Chinoune) in a subroutine
type :: vector
integer, dimension(:), allocatable :: elements
end type vector
type :: ragged_array
type(vector), dimension(:), allocatable :: vectors
end type ragged_array
type(ragged_array) :: raggar
allocate( raggar%vectors(2) )
allocate( raggar%vectors(1)%elements(3) )
allocate( raggar%vectors(2)%elements(4) )
raggar%vectors(1)%elements=0
raggar%vectors(2)%elements=0
if I want to pass raggar
in an other subroutine to modify size of raggar
. should I do something like :
CALL MySubroutine(raggar)
or
CALL MySubroutine(raggar%vectors%elements)
And then, in my subroutine how can I declare it ?
SUBROUTINE MySubroutine(raggar)
type :: vector
integer, dimension(:), allocatable :: elements
end type vector
type :: ragged_array
type(vector), dimension(:), allocatable :: vectors
end type ragged_array
type(ragged_array), INTENT(INOUT):: raggar
I did many tried but I always get error such as :
The type of the actual argument differs from the types of the dummy argument.
or
the shape matching rules of actual arguments and dummy argument have been violated