10.07.2015 Views

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

PGI Fortran Reference manual - The Portland Group

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Fortran</strong> Data Types2.6.1. Array Declaration ElementAn array declaration has the following form:name([lb:]ub[,[lb:]ub]...)where name is the symbolic name of the array, lb is the specification of the lower bound of thedimension and ub is the specification of the upper bound. <strong>The</strong> upper bound, ub must be greaterthan or equal to the lower bound lb. <strong>The</strong> values lb and ub may be negative. <strong>The</strong> bound lb istaken to be 1 if it is not specified. <strong>The</strong> difference (ub-lb+1) specifies the number of elements inthat dimension. <strong>The</strong> number of lb,ub pairs specifies the rank of the array. Assuming the array isof a data type that requires N bytes per element, the total amount of storage of the array is:N*(ub-lb+1)*(ub-lb+1)*...<strong>The</strong> dimension specifiers of an array subroutine argument may themselves be subroutinearguments or members of COMMON.2.6.2. Deferred Shape ArraysDeferred-shape arrays are those arrays whose shape can be changed by an executable statement.Deferred-shape arrays are declared with a rank, but with no bounds information. <strong>The</strong>yassume their shape when either an ALLOCATE statement or a REDIMENSION statement isencountered.For example, the following statement declares a deferred shape REAL array A of rank two:REAL A(:, :)2.6.3. SubscriptsA subscript is used to specify an array element for access. An array name qualified by a subscriptlist has the following form:name(sub[,sub]...)where there must be one sub entry for each dimension in array name.Each sub must be an integer expression yielding a value which is within the range of the lowerand upper bounds. Arrays are stored as a linear sequence of values in memory and are held suchthat the first element is in the first store location and the last element is in the last store location.In a multi-dimensional array the first subscript varies more rapidly than the second, the secondmore rapidly than the third, and so on (column major order).2.6.4. Character SubstringA character substring is a contiguous portion of a character variable and is of type character.A character substring can be referenced, assigned values and named. It can take either of thefollowing forms:character_variable_name(x1:x2)character_array_name(subscripts)(x1:x2)where x1 and x2 are integers and x1 denotes the left-hand character position and x2 the righthandone. <strong>The</strong>se are known as substring expressions. In substring expressions x1 must be both<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!