stem Function

public function stem(fname) result(res)

Determines the filename without the path and without the final extension given a path.

Syntax

 l = stem(fname)

Where:

  • fname: Name or path of the file the determine the filename without the final extension and the path.

It returns the filename of the file without the extension and without path.

Example

The following program gets the filenames of some files

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

Arguments

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

Filename or path to a file.

Return Value character(len=:), ALLOCATABLE

Filename without the final extension and without the path. If filename consists of an extension only, the extension is returned.


Contents