9.4 ACCESS — Checks file access modes
- Description:
-
ACCESS(NAME, MODE)checks whether the file NAME exists, is readable, writable or executable. Except for the executable check,ACCESScan be replaced by Fortran 95’sINQUIRE. - Standard:
-
GNU extension
- Class:
-
Inquiry function
- Syntax:
-
RESULT = ACCESS(NAME, MODE) - Arguments:
-
NAME Scalar CHARACTERof default kind with the file name. Tailing blank are ignored unless the characterachar(0)is present, then all characters up to and excludingachar(0)are used as file name.MODE Scalar CHARACTERof default kind with the file access mode, may be any concatenation of"r"(readable),"w"(writable) and"x"(executable), or" "to check for existence. - Return value:
-
Returns a scalar
INTEGER, which is0if the file is accessible in the given mode; otherwise or if an invalid argument has been given forMODEthe value1is returned. - Example:
-
program access_test implicit none character(len=*), parameter :: file = 'test.dat' character(len=*), parameter :: file2 = 'test.dat '//achar(0) if(access(file,' ') == 0) print *, trim(file),' is exists' if(access(file,'r') == 0) print *, trim(file),' is readable' if(access(file,'w') == 0) print *, trim(file),' is writable' if(access(file,'x') == 0) print *, trim(file),' is executable' if(access(file2,'rwx') == 0) & print *, trim(file2),' is readable, writable and executable' end program access_test - Specific names:
- See also:
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gfortran/ACCESS.html