I am using Intel(R) Fortran Compiler XE on a Linux cluster. I would like to know how to efficiently
pass slices of an array to subroutines.
Here are relevant portions of the code:
in the main program
REAL,ALLOCATABLE,DIMENSION(:,:,:) :: DTC
ALLOCATE(DTC(0:MTLOC,KBM1,NCP)); DTC = 0.0
CALL CARBON(DTC(0:MTLOC,1:KBM1,9), DTC(0:MTLOC,1:KBM1,10), DTC(0:MTLOC,1:KBM1,11),DTC(0:MTLOC,1:KBM1,12),FLUXS(0:MTLOC,1:KBM1,5))
in the subroutine
REAL,DIMENSION(0:MTLOC,KBM1) :: DTLDOC, DTRDOC, DTLPOC, DTRPOC, FLXSPOC
calculate values for DTLDOC, etc
END SUBROUTINE CARBON
integers MTLOC = 5760, KBM1 = 20, and NCP = 27 are declared in module WQM
when I received the code, the call sytax was
CALL CARBON(DTC(0,1,9), DTC(0,1,10), DTC(0,1,11), DTC(0,1,12), FLUXS(0,1,5))
This was a bug because it only passed one element of the array. Would this syntax work on some systems
to pass all elements of the first two dimensions, and only the specified element of the third dimension?
I changed the array indices in the call as indicated above to specify the range of indices. This caused the subroutine to act on the correct
portions of the array, but array temporaries were created, which may slow down performance.
What would be the most efficient way to pass portions of the array to the subroutines? Or, would it be as efficient to
declare the array in a module and make it available within the subroutine to act on it directly?