Subroutine that keeps only the directory from a file path
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | file_path |
function dirname(file_path) !! Subroutine that keeps only the directory from a file path implicit none character(len = * ), intent(in) :: file_path character(len = :), allocatable :: dirname character(len = 1) :: sep integer(kind = I4) :: ind sep = dir_separator() ind = index( file_path, sep, back = .true. ) dirname = trim( file_path( :ind - 1 ) ) return endfunction dirname