Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Record Structures

The record structure was defined in earlier versions of Intel® Fortran as a language extension. It is still supported, although its functionality has been replaced by Standard Fortran derived data types.

Record structures in existing code can be easily converted to Standard Fortran derived type structures for portability, but can also be left in their old form. In most cases, an Intel Fortran record and a Standard Fortran derived type can be used interchangeably.

Intel Fortran record structures are similar to Standard Fortran derived types.

A record structure is an aggregate entity containing one or more elements. (Record elements are also called fields or components.) You can use records when you need to declare and operate on multi-field data structures in your programs.

Creating a record is a two-step process:

  1. You must define the form of the record with a multistatement structure declaration.

  2. You must use a RECORD statement to declare the record as an entity with a name. (More than one RECORD statement can refer to a given structure.)

Examples

Intel Fortran record structures, using only intrinsic types, easily convert to Standard Fortran derived types. The conversion can be as simple as replacing the keyword STRUCTURE with TYPE and removing slash ( / ) marks. The following shows an example conversion:

Record Structure

Standard Fortran Derived-Type


STRUCTURE /employee_name/
  CHARACTER*25  last_name
  CHARACTER*15  first_name
END STRUCTURE
STRUCTURE /employee_addr/
  CHARACTER*20  street_name
  INTEGER(2)    street_number
  INTEGER(2)    apt_number
  CHARACTER*20  city
  CHARACTER*2   state
  INTEGER(4)    zip
END STRUCTURE

TYPE employee_name
  CHARACTER*25  last_name
  CHARACTER*15  first_name
END TYPE
TYPE employee_addr
  CHARACTER*20  street_name
  INTEGER(2)    street_number
  INTEGER(2)    apt_number
  CHARACTER*20  city
  CHARACTER*2   state
  INTEGER(4)    zip
END TYPE

The record structures can be used as subordinate record variables within another record, such as the employee_data record. The equivalent Standard Fortran derived type would use the derived-type objects as components in a similar manner, as shown below:

Record Structure

Standard Fortran Derived-Type

STRUCTURE /employee_data/
  RECORD  /employee_name/ name
  RECORD  /employee_addr/ addr
  INTEGER(4) telephone
  INTEGER(2) date_of_birth
  INTEGER(2) date_of_hire
  INTEGER(2) social_security(3)
  LOGICAL(2) married
  INTEGER(2) dependents
END STRUCTURE
TYPE employee_data
  TYPE (employee_name) name
  TYPE (employee_addr) addr
  INTEGER(4) telephone
  INTEGER(2) date_of_birth
  INTEGER(2) date_of_hire
  INTEGER(2) social_security(3)
  LOGICAL(2) married
  INTEGER(2) dependents
END TYPE