filename Function

public function filename(fname) result(res)

Determines the full filename given a path.

Syntax

 l = filename(fname)

Where:

  • fname: Name or path of the file the determine the filename.

It returns the filename of the given path.

Example

The following program gets the filenames of some files

 PROGRAM filenameExample
    USE FU_Files, ONLY: filename
    IMPLICIT NONE
    CHARACTER(LEN=:), ALLOCATABLE :: path
    path='file1.txt'
    WRITE(*,*) path, ' ', filename(path)
    path='./file1.txt'
    WRITE(*,*) path, ' ', filename(path)
    path='/tmp/file1.txt'
    WRITE(*,*) path, ' ', filename(path)
    path='/tmp/file1'
    WRITE(*,*) path, ' ', filename(path)
 END PROGRAM filenameExample

Arguments

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

Filename or path to a file.

Return Value character(len=:), ALLOCATABLE

Full filename given in the path.


Contents