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 Types<strong>The</strong> following example shows RECORD, STRUCTURE, MAP and UNION usage. <strong>The</strong> size ofeach element of the recarr array would be the size of typetag (4 bytes) plus the size of the largestMAP, in this case, the employee map (24 bytes).STRUCTURE /account/INTEGER typetagUNIONMAPCHARACTER*12 ssnREAL*4 salaryCHARACTER*8 empdateEND MAP! Tag to determine defined map.! Structure for an employee! Social Security Number! Salary! Employment dateMAPINTEGER*4 acct_custREAL*4 credit_amtCHARACTER*8 due_dateEND MAPMAPINTEGER*4 acct_suppREAL*4 debit_amtBYTE num_itemsBYTE items(12)END MAP! Structure for a customer! 4-digit account! credit amount! due date! Structure for a supplier! supply account! debit amount! number of items! items suppliedEND UNIONEND STRUCTURERECORD /account/ recarr(1000)2.10.3. Data InitializationData initialization is allowed within data type declaration statements. This is an extension to the<strong>Fortran</strong> language. Data is initialized by placing values bounded by slashes immediately followingthe symbolic name (variable or array) to be initialized. Initialization of fields within structuredeclarations is allowed, but initialization of unnamed fields and records is not.Hollerith, octal and hexadecimal constants can be used to initialize data in both data typedeclarations and in DATA statements. Truncation and padding occur for constants that differ insize from the declared data item (as specified in the discussion of constants).2.11. Pointer Variables<strong>The</strong> POINTER statement, a CRAY extension to FORTRAN 77 which is distinct from the <strong>Fortran</strong>90/95 POINTER specification statement or attribute, declares a scalar variable to be a pointervariable of data type INTEGER, and another variable to be its pointer-based variable.<strong>The</strong> syntax of the POINTER statement is:POINTER (p1, v1) [, (p2, v2) ...]v1 and v2are pointer-based variables. A pointer-based variable can be of any type, includingSTRUCTURE. A pointer-based variable can be dimensioned in a separate type, in aDIMENSION statement, or in the POINTER statement. <strong>The</strong> dimension expression may beadjustable, where the rules for adjustable dummy arrays regarding any variables which appearin the dimension declarators apply.<strong>PGI</strong> <strong>Fortran</strong> <strong>Reference</strong> Guide 34

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

Saved successfully!

Ooh no, something went wrong!