HP 3000 Manuals

Alternative Methods of Specifying Input/Output [ HP FORTRAN 77/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Programmer's Guide

Alternative Methods of Specifying Input/Output 

There are alternative methods of specifying an I/O statement.  They are:

   *   Using the PARAMETER statement to assign input and output unit
       numbers

   *   Using character variables to represent formats

   *   Using the ASSIGN statement to assign a FORMAT label to an
       INTEGER*4 variable

These methods are shown in the following program:

           PROGRAM formatting

           CHARACTER*16  format_string
           INTEGER*4     format_label

     C  Using the PARAMETER statement:
           INTEGER*4 in, out
           PARAMETER (in=5, out=6)
           READ(in,*) a, b, c
           WRITE(out,*) a, b, c

     C  Using CHARACTER variables to represent formats:
           format_string = '(1X, I9)'
           READ(5, format_string) i
           format_string = '(1X, "i=", I9)'
           WRITE(6, format_string) i

     C  Using the ASSIGN statement:
           ASSIGN 100 TO format_label    ! Note: format_label must be a
           READ(5, format_label) i       ! 4-byte integer
           ASSIGN 200 TO format_label
           WRITE(6, format_label) i
      100  FORMAT(I9)
      200  FORMAT('1X, i=', I9)

           END



MPE/iX 5.0 Documentation