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.

<strong>Fortran</strong> Statements(for example, .EQ., .XOR.), logical constants (.TRUE. or .FALSE.), or logical expressions(.AND., .NOT., .OR.) as field names in structure declarations.Fields in a structure are aligned as required by hardware and a structure's storage requirements aretherefore machine-dependent. Note that VAX/VMS <strong>Fortran</strong> does no padding. Because explicitpadding of records is not necessary, the compiler recognizes the %FILL intrinsic, but performs noaction in response to it.Data initialization can occur for the individual fields.<strong>The</strong> UNION and MAP statements are supported.<strong>The</strong> following is an example of record and structure usage.STRUCTURE /account/INTEGER typetag ! Tag to determine defined mapUNIONMAP! Structure for an employeeCHARACTER*12 ssn ! Social Security NumberREAL*4 salaryCHARACTER*8 empdate ! Employment dateEND MAPMAP! Structure for a customerINTEGER*4 acct_custREAL*4 credit_amtCHARACTER*8 due_dateEND MAPMAP! Structure for a supplierINTEGER*4 acct_suppREAL*4 debit_amtBYTE num_itemsBYTE items(12) ! Items suppliedEND MAPEND UNIONEND STRUCTURERECORD /account/ recarr(1000)3.21. UNIONA UNION declaration, a DEC extension to FORTRAN 77, is a multi-statement declarationdefining a data area that can be shared intermittently during program execution by one or morefields or groups of fields. It declares groups of fields that share a common location within astructure. Each group of fields within a union declaration is declared by a map declaration, withone or more fields per map declaration.Union declarations are used when one wants to use the same area of memory to alternatelycontain two or more groups of fields. Whenever one of the fields declared by a union declarationis referenced in a program, that field and any other fields in its map declaration become defined.<strong>The</strong>n, when a field in one of the other map declarations in the union declaration is referenced,the fields in that map declaration become defined, superseding the fields that were previouslydefined.A union declaration is initiated by a UNION statement and terminated by an END UNIONstatement. Enclosed within these statements are one or more map declarations, initiated and<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 59

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

Saved successfully!

Ooh no, something went wrong!