Sun Studio 12: Fortran Programming Guide

7.2 Working With Files

Early Fortran systems did not use named files, but did provide a command line mechanism to equate actual file names with internal unit numbers. This facility can be emulated in a number of ways, including standard UNIX redirection.

Example: Redirecting stdin to redir.data (using csh(1)):


demo% cat redir.data           The data file
 9 9.9

demo% cat redir.f             The source file
      read(*,*) i, z          The program reads standard input
      print *, i, z
      stop
      end

demo% f95 -o redir redir.f   The compilation step
demo% redir < redir.data            Run with redirection reads data file
  9 9.90000
demo%