I need to turn a specific Fortran procedure into a generic one to be used many times without changes.
It takes a couple of derived types as dummy arguments, containing several arrays, whose dimension are unknown at compiling time (I need to add it to a static lib).
Can I declare member arrays as assumed shape arrays inside the subroutine? I.e.
subroutine(TF_Model_V)
type TF_Model_V
sequence
real*8 , dimension (:) ::A
real*8 , dimension (:) ::ACONE
real*8 , dimension (:) ::ADM
...
End type
...
It seems that is not possible since the compilation fails. Is there any way of doing this?
Array components of a derived type cannot have assumed shape.
The shape specification of a derived type component must be either explicit or deferred, this latter being for pointer or allocatable components.
For dummy arguments, explicit shape specifications do not need to be constant expressions. This gives us a way to have the shape of a component vary at run-time.
We do this using length type parameters for the type, which can be assumed:
Additional length type parameters can be included and assumed, to handle further components of different shapes.
Sequence types cannot have type parameters, so the definition of the derived type must be unique.
Alternatively, using deferred shape for components:
Your choice really comes down to how you want to set/process the dynamic shape of the components.