Annotation of 43BSDTahoe/new/help/src/f77/io_intro, revision 1.1

1.1     ! root        1: .TI F77/IO_INTRO "Sep. 4, 1985"
        !             2: F77 I/O - Introduction
        !             3: 
        !             4: By default, Fortran units 5, and 6 are connected to standard input and
        !             5: standard output and unit 0 is connected to standard error.
        !             6: 
        !             7: A 'read' with no unit number reads from unit 5; a 'print' writes
        !             8: to unit 6.  Thus, the default is that
        !             9: 
        !            10: .nf
        !            11:        read 8010, ...
        !            12:        read (5,8010) ...
        !            13:        read (*,8010) ...
        !            14: .fi
        !            15: 
        !            16: read from standard input (the terminal),
        !            17: 
        !            18: .nf
        !            19:        print 8020, ...
        !            20:        write (6,8020) ...
        !            21:        write (*,8020) ...
        !            22: .fi
        !            23: 
        !            24: write to standard output (the terminal) and
        !            25: 
        !            26:        write (0,8020) ...
        !            27: 
        !            28: writes to standard error (the terminal).
        !            29: 
        !            30: To enter an end-of-file from a terminal, type control-D (type the letter "d"
        !            31: while holding down the key labeled "control").
        !            32: 
        !            33: You can avoid the use of format statements by using list directed I/O.
        !            34: For example, the statements
        !            35: 
        !            36: .nf
        !            37:        read *,  i,j,x,y
        !            38:        print *, i,j,x,y
        !            39: .fi
        !            40: 
        !            41: read i, j, x, and y from the terminal and write them back to it.
        !            42: 
        !            43: To read and write from disk files, it is simplest to write your program
        !            44: as if you are reading and writing on the terminal.  Then use shell
        !            45: I/O redirection:
        !            46: 
        !            47:        a.out < infile
        !            48: 
        !            49: reads from the file 'infile' instead of the terminal and
        !            50: 
        !            51:        a.out > outfile
        !            52: 
        !            53: writes to the file 'outfile' instead of the terminal.  These may be
        !            54: combined as in:
        !            55: 
        !            56:        a.out < infile > outfile
        !            57: 
        !            58: F77 allows unit numbers to be between 0 and 99.  If you use a unit number
        !            59: N other than 0, 5, or 6, then the default is for it to reference a file
        !            60: named 'fort.N'.
        !            61: 
        !            62: Disk files may be explicitly opened for reading and writing with the 'open'
        !            63: statement:
        !            64: 
        !            65:        open( N, file='filename')
        !            66: 
        !            67: where N is any of 0 ... 99 .
        !            68: 
        !            69: Appropriately named environment variables override default file names
        !            70: or file names in 'open' statements.
        !            71: The corresponding environment variable name is the same
        !            72: as the file name with periods deleted.
        !            73: For example, a program containing:
        !            74: .nf
        !            75: 
        !            76:       open(32,file="data.d")
        !            77:       read(32,100) vec
        !            78:       write(44) vec
        !            79: 
        !            80: .fi
        !            81: normally will read from file 'data.d' and write to
        !            82: file 'fort.44' in the current directory.
        !            83: If the environment variables 'datad' and 'fort44' are set:
        !            84: .nf
        !            85: 
        !            86: % setenv datad mydata
        !            87: % setenv fort44 myout
        !            88: 
        !            89: .nf
        !            90: in the C shell or:
        !            91: .nf
        !            92: 
        !            93: $ datad=mydata
        !            94: $ fort44=myout
        !            95: $ export datad fort44
        !            96: 
        !            97: .fi
        !            98: in the Bourne shell, then the program will read from 'mydata' and
        !            99: write to 'myout'.
        !           100: If the file name in the open statement is a path name including
        !           101: slashes, then only the tail (the part after the last slash) is used
        !           102: in looking for an environment variable.
        !           103: 
        !           104: Carriage control is not normally recognized by the f77 I/O library,
        !           105: see "help f77 carriage_cc" to see how to use carriage control.
        !           106: 
        !           107: To find out if a logical unit is connected to a terminal, use the 
        !           108: logical function 'isatty()',  see "man 3f ttynam" for details.
        !           109: 
        !           110: For an example of random access I/O, see "help f77 io_random".
        !           111: For a list of errors from the f77 I/O library, see "help f77 io_err_msgs".

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.