Checks if a file or directory exists.
l = exists(fname)
Where:
fname
: Name of the file to be checked for existence.It returns True if the file exists and False otherwhise.
The following program check if file1 exists:
PROGRAM existsExample
USE FU_Files, ONLY: exists
IMPLICIT NONE
CHARACTER(LEN=:), ALLOCATABLE :: path
path='file1'
IF (exists(path)) THEN
WRITE(*,*) 'File exists'
ELSE
WRITE(*,*) 'File does not exist'
END IF
END PROGRAM existsExample
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | fname |
Name of the file to be check for existence. |
True if the file exists. False otherwise.