is_directory Function

public function is_directory(fname, ignoreErrors) result(res)

Checks if a directory exists.

Syntax

 l = is_directory(fname, ignoreErrors)

Where:

  • fname: Name of the direcory to be checked.
  • ignoreErrors: False to print a detailed description of the error message. Optional parameter. Default is False.

It returns True if fname is a directory and false otherwise.

Example

The following program checks the existance of a folder:

 PROGRAM is_directoryExample
    USE FU_Files, ONLY: is_directory
    IMPLICIT NONE
    CHARACTER(LEN=:), ALLOCATABLE :: path
    path='/tmp'
    IF (is_directory(path)) THEN
       WRITE(*,*) 'It is a directory'
    ELSE
       WRITE(*,*) 'It is not a directory'
    END IF
 END PROGRAM is_directoryExample

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: fname

Name of the directory to be checked.

logical, intent(in), optional :: ignoreErrors

False to print a detailed description of the error message. Optional parameter. Default is False.

Return Value logical

True if fname is a directory. False otherwise.


Contents