Is it possible with fortran to have a subroutine that accepts shape-varying input parameters ? I could not find a way...However I found a workaround which is to reshape the input array such as
SUBROUTINE func(R1_TBV,...)
DOUBLE PRECISION, dimension(:), allocatable :: R1_TBV ! type of boundary value
DOUBLE PRECISION R2_TBV(3,2), R3_TBV(3,2,3)
SELECT CASE(trim(name))
CASE('flux')
allocate(r1_tbv(18))
r3_tbv = reshape(r1_tbv,(/3,2,3/))
CASE('volumic')
allocate(r1_tbv(6))
r2_tbv = reshape(r1_tbv,(/3,2/))
END SELECT
but:
- I find strange not to have other choice to define all possible arrays because reshape can't do the work (i.e. tbv = reshape(tbv,(/3,2,3/) does not work...)
- when calling this function, my input parameter R1_TBV actually has either the size (3,2,3) or (3,2) so I also need beforehand to reshape it to call the function...