I have a subroutine that takes two different size arrays as input.
I have currently set this up as follows:
subroutine copacity(t, rho, realk, rkapparef, rhoref, tref, its, irhs)
implicit none
double precision :: realk, rho, t, rhoref(irhs), tref(its), rkapparef(irhs, its)
integer :: irhs, its
save
ALL CODE HERE
return
end subroutine
The two final parameters (its
and irhs
) are simply the dimensions of the arrays.
I cannot appear to define the arrays ‘on the fly’ as such; I have to have the parameters. I originally thought that passing the arrays would cause the system to define the local arrays accordingly, but this is not the case. I could define a single parameter, that defines which case to use (there are only two potential arrays that could be passed), but then I cannot use an if
statement to select the relevant integer values, prior to the arrays being defined.
Is there a method by which the local array could easily be set to the dimensions of the passed array?
Or is the passing of the two integer dimensions the best (only) approach?