is_empty Function

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

Checks if a file is empty.

Syntax

 l = is_empty(fname, ignoreErrors)

Where:

  • fname: Name of the file 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 an empty file and false otherwise.

Example

The following program checks the if a file is empty:

 PROGRAM is_emptyExample
    USE FU_Files, ONLY: is_empty
    IMPLICIT NONE
    CHARACTER(LEN=:), ALLOCATABLE :: path
    path='file1'
    IF (is_empty(path)) THEN
       WRITE(*,*) 'Empty'
    ELSE
       WRITE(*,*) 'Has data'
    END IF
 END PROGRAM is_emptyExample

Arguments

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

Name of the file 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 an empty file. False otherwise.


Contents