syntax - Different syntaxes to declare arrays: with and without the dimension statement -


i'm using gfortran version 7.2.0. i'm quite new fortran. know there different versions of fortran. in code below, i'm declaring arrays (or tensors) using different syntaxes

program arrays     implicit none      integer :: m(3, 4)     integer, dimension(3, 4) :: n      print *, "m = ", m     print *, "n = ", n  end program arrays 

in 1 case, i'm using dimension statement, in other not. program compiles (without errors). i'm using gfortran's flags -g , -fbounds-check. file extension of file program above f.90.

why there different syntaxes apparently declare arrays in fortran? versions of fortran support syntaxes, or possibility declare rank, shapes , extents of arrays m extension of compiler?

the statements

integer :: m(3, 4) integer, dimension(3, 4) :: n 

are both standard fortran since fortran 90. without use of :: first line like

integer m(3,4) 

would valid before fortran 90.

before coming else, ,dimension isn't dimension statement attribute specification. dimension statement be

dimension n(3,4)  ! n implicitly or explicitly typed elsewhere 

the important thing here attributes specified type declaration apply (almost) all objects declared. so

integer :: m1(3,4), m2, m3 integer, dimension(3,4) :: n1, n2, n3 

sees m1 rank-2 array, m2 , m3 scalars (unless given array properties elsewhere or functions) whereas n1, n2 , n3 rank-2 arrays of shape [3,4]

the 2 declarations of question simply

integer, dimension(3,4) :: m, n 

the "almost" comes fact can have

integer, dimension(3,4) :: n, p(5) 

where shape of p [5], overriding [3,4] specified earlier.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -