functionlocateprivate
character(len=:) function locate(search, directory, name) result(path)
The path of include file name, or '' if it is not found.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| search | type(string_t) | in | dimension(:) | other directories to look in |
| directory | character(len=*) | in | the directory of the including file | |
| name | character(len=*) | in | the file |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| path | character(len=:) | privateallocatable |
Source
Show the code
function locate(search, directory, name) result(path)
type(string_t), intent(in) :: search(:) !! other directories to look in
character(len=*), intent(in) :: directory !! the directory of the including file
character(len=*), intent(in) :: name !! the file
character(len=:), allocatable :: path
logical :: exists
integer :: k
path = join_path(directory, name)
inquire (file=path, exist=exists)
if (exists) return
do k = 1, size(search)
path = join_path(search(k)%s, name)
inquire (file=path, exist=exists)
if (exists) return
end do
path = ''
end function locate