Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Allocatable arrays in MODULE vs. passing them as arguments ?

$
0
0

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
program Test
include 'dimensions.inc'
real(8), dimension(:,:,:), allocatable :: Array
allocate( Array(ny,ny,nz), STAT=allocationStatus )
call initializeArray( Array )
! ...
end

! another file
subroutine initializeArray( Array )
include 'dimensions.inc'
real(8) :: Array(nx,ny,nz)
! ...
return
end

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?


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>