The portability library contains routines that change file properties, read and write characters and buffers, and change the offset position in a file. These input and output routines can be used with standard Fortran input or output statements such as READ or WRITE on the same files, provided that you take into account the following:
I/O errors arising from the use of these routines result in a Visual Fortran run-time error.
Portability Routine | Description |
---|---|
ACCESS | Checks a file for accessibility according to mode |
CHMOD | Changes file attributes |
FGETC | Reads a character from an external unit |
FLUSH | Flushes the buffer for an external unit to its associated file |
FPUTC | Writes a character to an external unit |
FSEEK | Repositions a file on an external unit |
FTELL | Returns the offset, in bytes, from the beginning of the file |
GETC | Reads a character from unit 5 |
PUTC | Writes a character to unit 6 |
All path names can include drive specifications, forward slashes, or backslashes.
Some portability file I/O routines have equivalents in standard Fortran 95/90. For example, you could use the ACCESS function to check a file specified by name for accessibility according to mode. It tests a file for read, write, or execute permission, as well as checking to see if the file exists. It works on the file attributes as they exist on disk, not as a program's OPEN statement specifies them.
Instead of ACCESS, you can use the INQUIRE statement with the ACTION parameter to check for similar information. (The ACCESS function always returns 0 for read permission on FAT files, meaning that all files have read permission.)