FORTRAN 77 Language Reference

Examples

Example 1: Character string:


       CHARACTER *25 TEXT 
       TEXT = 'Some kind of text string' 
       CALL OOPS ( TEXT )
       END
       SUBROUTINE OOPS ( S )
              CHARACTER S*(*) 
              WRITE (*,*) S 
       END

Example 2: Alternate return:


       CALL RANK ( N, *8, *9 ) 
       WRITE (*,*) 'OK - Normal Return' 
       STOP 
8     WRITE (*,*) 'Minor - 1st alternate return' 
       STOP 
9     WRITE (*,*) 'Major - 2nd alternate return' 
       STOP 
       END 

       SUBROUTINE RANK ( N, *, * ) 
              IF ( N .EQ. 0 ) RETURN 
              IF ( N .EQ. 1 ) RETURN 1 
              RETURN 2 
       END 

Example 3: Another form of alternate return; the & is nonstandard:


       CALL RANK ( N, &8, &9 )

@

Example 4: Array, array element, and variable:


       REAL M(100,100), Q(2,2), Y 
       CALL SBRX ( M, Q(1,2), Y ) 
       ... 
       END 
       SUBROUTINE SBRX ( A, D, E ) 
       REAL A(100,100), D, E 
       ... 
       RETURN 
       END 

In this example, the real array M matches the real array, A, and the real array element Q(1,2) matches the real variable, D.

Example 5: A structured record and field; the record is nonstandard: @


       STRUCTURE /PRODUCT/ 
              INTEGER*4 ID 
              CHARACTER*16 NAME 
              CHARACTER*8 MODEL 
              REAL*4 COST 
              REAL*4 PRICE 
       END STRUCTURE 
       RECORD /PRODUCT/ CURRENT, PRIOR 
       CALL SBRX ( CURRENT, PRIOR.ID ) 
       ... 
       END 
       SUBROUTINE SBRX ( NEW, K ) 
       STRUCTURE /PRODUCT/ 
              INTEGER*4 ID 
              CHARACTER*16 NAME 
              CHARACTER*8 MODEL 
              REAL*4 COST 
              REAL*4 PRICE 
       END STRUCTURE 
       RECORD /PRODUCT/ NEW 
       ... 
       RETURN 
       END 

In the above example, the record NEW matches the record CURRENT, and the integer variable, K, matches the record field, PRIOR.OLD.