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?

4

1 に答える 1

3

速度に違いはありません。これらの変数の宣言は 100% 同等です。

また、使用kind=8しないでください、しないと思います。real*8特に、double precision( Fortran: integer*4 vs integer(4) vs integer(kind=4) )とは等価ではありません。

于 2013-05-27T12:11:14.260 に答える