FORTRAN 77 Language Reference

Example

Example 1: Declare some items to be records of a specified structure:


       STRUCTURE /PRODUCT/ 
             INTEGER*4 ID 
             CHARACTER*16 NAME 
             CHARACTER*8 MODEL 
             REAL*4 COST 
             REAL*4 PRICE 
       END STRUCTURE 
       RECORD /PRODUCT/ CURRENT, PRIOR, NEXT, LINE(10)
       ...

Each of the three variables CURRENT, PRIOR, and NEXT is a record which has the PRODUCT structure, and LINE is an array of 10 such records.

Example 2: Define some fields of records, then use them:


       STRUCTURE /PRODUCT/
              INTEGER*4    ID
              CHARACTER*16 NAME
              CHARACTER*8  MODEL
              REAL*4       COST
              REAL*4       PRICE
       END STRUCTURE
       RECORD /PRODUCT/  CURRENT, PRIOR, NEXT, LINE(10)
       CURRENT.ID = 82
       PRIOR.NAME = "CacheBoard"
       NEXT.PRICE = 1000.00
       LINE(2).MODEL = "96K"
       PRINT 1, CURRENT.ID, PRIOR.NAME, NEXT.PRICE,LINE(2).MODEL
1      FORMAT(1X I5/1X A16/1X F8.2/1X A8)
       END

The above program produces the following output:


82
CacheBoard
1000.00
96K