Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

allocate and deallocate versus call subroutine

$
0
0

Dear all,

I have a question about subroutine arguments:

If I have a subroutine like this one

CALL SUBROUTINE(nElem)

SUBROUTINE(nElem)
REAL, DIMENSION(nElem) :: VECT1
REAL, DIMENSION(nElem) :: VECT2

....

and another one:

SUBROUTINE(nElem)

REAL,ALLOCATABLE,DIMENSION(:) :: VECT1,VECT2


ALLOCATE(VECT1(nElem))
ALLOCATE(VECT2(nElem))

...
...
....

DEALLOCATE(VECT1,VECT2)

 

Are these two procedures equivalent, also from computational time?

I ask this question because I have a program where I call several time a subroutine. I stategy could be allocate VECT1 and VECT2 outside in a specific module, but this does not seems very elegant and could create confusion in future.

Thanks to everyone

 

Thread Topic: 

Question

Viewing all articles
Browse latest Browse all 2746

Trending Articles



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