I would like to ask a question about allocatable arrays. What I currently have in my application is that 3D arrays are allocated in the main program and they are passed to subroutines as arguments. A simplified example would be:
! contents of dimensions.inc'
integer(4) :: nx, ny, nz
COMMON /dimensionsCommon/ nx, ny, nz
! main program
real(8), dimension(:,:,:), allocatable :: Array
allocate( Array(ny,ny,nz), STAT=allocationStatus )
call initializeArray( Array )
! another file
subroutine initializeArray( Array )
real(8) :: Array(nx,ny,nz)
My application is far more complicated - tens of 3D arrays are passed this way to subroutines that pass them to other subroutines and functions. I am considering having the allocatable arrays in modules and using the command use instead of passing the arrays as arguments, but I would like to ask first of all whether such a change (in a huge code) makes any sense. Does any of the approaches have a significant impact on the performance and the application speed? It is possible to say which approach is the best from the performance point of view?