12.07.2015 Views

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

PGI Fortran - Servidor WWW del Cluster Ladon-Hidra

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.

4 Fortran ArraysFortran arrays are any object with the dimension attribute. In Fortran 90/95, and in HPF, arraysmay be very different from arrays in older versions of Fortran. Arrays can have values assigned asa whole without specifying operations on individual array elements, and array sections can beaccessed. Also, allocatable arrays that are created dynamically are available as part of the Fortran90/95 and HPF standards. Arrays in HPF play a central role in data distribution and data alignment(refer to this chapter and The High Performance Fortran Handbook for details on working witharrays in HPF). This chapter describes some of the features of Fortran 90/95 and HPF arrays.The 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 TypesFortran 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 valid in amain program. Assumed shape arrays and assumed size arrays are only valid for arrays used asdummy 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. The extent of an array’s dimension is thenumber of elements in the dimension. The array rank is the number of dimensions in the array, upto a maximum of seven. The shape is the vector representing the extents for all dimensions. Thesize 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 Fortran90/95 and HPF programs with dynamic storage. Allocatable arrays are declared with a rankFortran Arrays 145

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

Saved successfully!

Ooh no, something went wrong!