In addition to the routines in the previous section, FIO provides a set of routines to do some simple I/O on files. FIO maintains a set of file descriptors for active files which are used by these routines. These descriptors contain such things as the access mode of a file (read only, update, etc.), which allow FIO to trap some errors rather than permitting a run time error to occur. For example, if an attempt is made to write to a file that has been opened with `read only' access, FIO will report the error, but the program will not crash, allowing the user to take corrective action. Use of these routines also makes user written code more portable. Issues such as requiring CARRIAGECONTROL='LIST' in DEC FORTRAN OPEN statements are handled internally. The routines that handle FIO file descriptors are:
Note that the same file descriptors are used by the FIO and RIO routines, so these can be freely mixed, where appropriate.
Here is an example of the use of some of these routines.
... * Open a file. CALL FIO_OPEN( FILNAM, 'WRITE', 'LIST', 0, FD, STATUS ) * Write the data. DO I = 1, N CALL FIO_WRITE( FD, BUF( I ), STATUS ) END DO * Close the file. CALL FIO_CLOSE( FD, STATUS ) ...
Note that there is no testing for errors in this piece of code since the FIO
routines follow the normal Starlink convention for error handling and will not
execute if STATUS is bad. However, if the loop is to be executed many times, it
would be worth testing that the call to FIO_OPEN was successful, otherwise you
could end up executing the loop many times to no effect.
FIO/RIO FORTRAN file I/O routines