Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Array declaration in Fortran

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?)

like image 541
Nordico Avatar asked May 21 '12 19:05

Nordico


People also ask

How do I store an array in Fortran?

Fortran stores higher dimensional arrays as a contiguous sequence of elements. It is important to know that 2-dimensional arrays are stored by column. So in the above example, array element (1,2) will follow element (3,1). Then follows the rest of the second column, thereafter the third column, and so on.

Do arrays start at 0 or 1 in Fortran?

C arrays always start at zero, but by default Fortran arrays start at 1. There are two usual ways of approaching indexing. You can use the Fortran default, as in the preceding example. Then the Fortran element B(2) is equivalent to the C element b[1] .


1 Answers

Yes, it is identical. Even for assumed, deferred and whatever possible shape.

like image 165
Vladimir F Героям слава Avatar answered Sep 21 '22 06:09

Vladimir F Героям слава