Reputation: 1307
Consider
INTEGER,DIMENSION(3) :: NumberVector
and
INTEGER :: NumberVector(3)
Is there any difference whatsoever between these two declarations or are they exactly the same? (I mean in ANY possible context and variation: for example, in the case that those two were identical, what if I am declaring an array with an implicit size as one of the input parameter of a subroutine? Would it still be irrelevant which one I used?)
Upvotes: 6
Views: 1754
Reputation: 74495
The DIMENSION
attribute was added to Fortran 90 in order to improve code clarity and to enable code savings when declaring multiple arrays of the same type (not uncommon in scientific computing), e.g. instead of
REAL :: mat1(10,20), mat2(10,20), mat3(10,20), mat4(10,20), mat5(10,20)
one could write
REAL, DIMENSION(10,20) :: mat1, mat2, mat3, mat4, mat5
Besides reducing source code size and compilation time (less parsing; not that relevant nowadays), this reduces the possibility of making a mistake in any of the declarations. Otherwise both forms are equal and the variables declared behave exactly the same way everywhere in the program.
Upvotes: 3
Reputation: 60123
Yes, it is identical. Even for assumed, deferred and whatever possible shape.
Upvotes: 8