1

Is there any performance advantage to declare multiple variables by one single statement compared to using separate statements for the declaration?

This question could be interesting for choosing between a lazy

REAL(kind=8), ALLOCATABLE :: x(:,:,:) , &
                     &       y(:,:,:) , &
                     &       z(:,:,:)

and a more explicit programming style

REAL(kind=8), ALLOCATABLE :: x(:,:,:)
REAL(kind=8), ALLOCATABLE :: y(:,:,:)
REAL(kind=8), ALLOCATABLE :: z(:,:,:)

Is the answer the same for global variables shared via modules and for local variables declared in subroutines?

BHF
  • 748
  • 7
  • 19

1 Answers1

3

There cannot be any difference in speed. These declarations of the variables are 100% equivalent.

Also please do not use kind=8, it does not do, what you probably think it does. In particular it is not equivalent with real*8 nor with double precision (Fortran: integer*4 vs integer(4) vs integer(kind=4)).

Community
  • 1
  • 1