|
| 1 | +<code>ACCESS</code> — Checks file access modes |
| 2 | + |
| 3 | +<h3>Description</h3> |
| 4 | +<code>ACCESS(NAME, MODE)</code> checks whether the file <var>NAME</var> |
| 5 | +exists, is readable, writable or executable. Except for the |
| 6 | +executable check, <code>ACCESS</code> can be replaced by |
| 7 | +Fortran 95's <code>INQUIRE</code>. |
| 8 | + |
| 9 | + <br> |
| 10 | + |
| 11 | +<h3>Syntax</h3> |
| 12 | +<code>RESULT = ACCESS(NAME, MODE)</code> |
| 13 | + |
| 14 | + <br> |
| 15 | + |
| 16 | +<h3>Arguments</h3> |
| 17 | + |
| 18 | + <p><table summary=""><tbody><tr align="left"><td valign="top" width="15%"><var>NAME</var> </td><td valign="top" width="70%">Scalar <code>CHARACTER</code> of default kind with the |
| 19 | +file name. Tailing blank are ignored unless the character <code>achar(0)</code> |
| 20 | +is present, then all characters up to and excluding <code>achar(0)</code> are |
| 21 | +used as file name. |
| 22 | +<br></td></tr><tr align="left"><td valign="top" width="15%"><var>MODE</var> </td><td valign="top" width="70%">Scalar <code>CHARACTER</code> of default kind with the |
| 23 | +file access mode, may be any concatenation of <code>"r"</code> (readable), |
| 24 | +<code>"w"</code> (writable) and <code>"x"</code> (executable), or <code>" "</code> to check |
| 25 | +for existence. |
| 26 | + <br></td></tr></tbody></table> |
| 27 | + |
| 28 | + <br></p> |
| 29 | + |
| 30 | +<h3>Return value</h3> |
| 31 | +Returns a scalar <code>INTEGER</code>, which is <code>0</code> if the file is |
| 32 | +accessible in the given mode; otherwise or if an invalid argument |
| 33 | +has been given for <code>MODE</code> the value <code>1</code> is returned. |
| 34 | + |
| 35 | + <br> |
| 36 | + |
| 37 | +<h3>Example</h3> |
| 38 | + |
| 39 | + <code class="smallexample" syntax="Packages/Fortran/grammars/FortranModern.sublime-syntax"> |
| 40 | +<br>program access_test |
| 41 | +<br> implicit none |
| 42 | +<br> character(len=*), parameter :: file = 'test.dat' |
| 43 | +<br> character(len=*), parameter :: file2 = 'test.dat '//achar(0) |
| 44 | +<br> if(access(file,' ') == 0) print *, trim(file),' is exists' |
| 45 | +<br> if(access(file,'r') == 0) print *, trim(file),' is readable' |
| 46 | +<br> if(access(file,'w') == 0) print *, trim(file),' is writable' |
| 47 | +<br> if(access(file,'x') == 0) print *, trim(file),' is executable' |
| 48 | +<br> if(access(file2,'rwx') == 0) & |
| 49 | +<br> print *, trim(file2),' is readable, writable and executable' |
| 50 | +<br>end program access_test</code> |
| 51 | + <br> |
| 52 | + |
| 53 | +<h3>Specific names</h3> |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +<h3>Standard</h3> |
| 58 | +GNU extension |
| 59 | + |
| 60 | + <br> |
| 61 | + |
| 62 | +<h3>Class</h3> |
| 63 | +Inquiry function |
| 64 | + |
| 65 | + <br> |
| 66 | + |
| 67 | +<h3>See also</h3> |
| 68 | + |
0 commit comments