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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 4.FORTRAN ARRAYS<strong>Fortran</strong> arrays are any object with the dimension attribute. In <strong>Fortran</strong> 90/95, arrays may be verydifferent from arrays in older versions of <strong>Fortran</strong>. Arrays can have values assigned as a wholewithout specifying operations on individual array elements, and array sections can be accessed.Also, allocatable arrays that are created dynamically are available as part of the <strong>Fortran</strong> 90/95standard. This section describes some of the features of <strong>Fortran</strong> 90/95 arrays.<strong>The</strong> following example illustrates valid array operations.REAL(10,10) A,B,CA = 12 !Assign 12 to all elements of AB = 3 !Assign 3 to all elements of BC = A + B !Add each element of A to each of B4.1. Array Types<strong>Fortran</strong> supports four types of arrays: explicit-shape arrays, assumed-shape arrays, deferred-shapearrays and assumed-size arrays. Both explicit-shape arrays and deferred shape arrays are validin a main program. Assumed shape arrays and assumed size arrays are only valid for arrays usedas dummy arguments. Deferred shape arrays, where the storage for the array is allocated duringexecution, must be declared with either the ALLOCATABLE or POINTER attributes.Every array has properties of type rank, shape and size. <strong>The</strong> extent of an array’s dimension is thenumber of elements in the dimension. <strong>The</strong> array rank is the number of dimensions in the array, upto a maximum of seven. <strong>The</strong> shape is the vector representing the extents for all dimensions. <strong>The</strong>size is the product of the extents. For some types of arrays, all of these properties are determinedwhen the array is declared. For other types of arrays, some of these properties are determinedwhen the array is allocated or when a procedure using the array is entered. For arrays that aredummy arguments, there are several special cases.Allocatable arrays are arrays that are declared but for which no storage is allocated until anallocate statement is executed when the program is running. Allocatable arrays provide <strong>Fortran</strong>90/95 programs with dynamic storage. Allocatable arrays are declared with a rank specifiedwith the ":" character rather than with explicit extents, and they are given the ALLOCATABLEattribute.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 64

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

Saved successfully!

Ooh no, something went wrong!