src/gray_params.f90: improve handling of absolute paths
This commit is contained in:
parent
d3a87e1044
commit
efd4fc51e5
@ -344,13 +344,16 @@ contains
|
|||||||
close(u)
|
close(u)
|
||||||
|
|
||||||
! Convert all filenames to absolute paths
|
! Convert all filenames to absolute paths
|
||||||
! Note: `filenm` is assumed to be a path relative to the
|
|
||||||
! gray_params.data file.
|
|
||||||
block
|
block
|
||||||
use utils, only : dirname
|
use utils, only : dirname, isrelative
|
||||||
params%antenna%filenm = dirname(filename) // params%antenna%filenm
|
if (isrelative(params%antenna%filenm)) &
|
||||||
params%equilibrium%filenm = dirname(filename) // params%equilibrium%filenm
|
params%antenna%filenm = dirname(filename) // params%antenna%filenm
|
||||||
params%profiles%filenm = dirname(filename) // params%profiles%filenm
|
|
||||||
|
if (isrelative(params%equilibrium%filenm)) &
|
||||||
|
params%equilibrium%filenm = dirname(filename) // params%equilibrium%filenm
|
||||||
|
|
||||||
|
if (isrelative(params%profiles%filenm)) &
|
||||||
|
params%profiles%filenm = dirname(filename) // params%profiles%filenm
|
||||||
end block
|
end block
|
||||||
end subroutine read_parameters
|
end subroutine read_parameters
|
||||||
|
|
||||||
|
@ -293,10 +293,20 @@ contains
|
|||||||
directory = filepath(1:last_sep)
|
directory = filepath(1:last_sep)
|
||||||
|
|
||||||
! append the cwd to relative paths
|
! append the cwd to relative paths
|
||||||
if (filepath(1:1) /= '/') then
|
if (isrelative(filepath)) then
|
||||||
call getcwd(cwd)
|
call getcwd(cwd)
|
||||||
directory = trim(cwd) // '/' // directory
|
directory = trim(cwd) // '/' // directory
|
||||||
end if
|
end if
|
||||||
end function dirname
|
end function dirname
|
||||||
|
|
||||||
|
function isrelative(filepath)
|
||||||
|
! Check if `filepath` is a relative or an absolute path
|
||||||
|
|
||||||
|
! function arguments
|
||||||
|
character(*), intent(in) :: filepath
|
||||||
|
logical :: isrelative
|
||||||
|
|
||||||
|
isrelative = (filepath(1:1) /= '/')
|
||||||
|
end function isrelative
|
||||||
|
|
||||||
end module utils
|
end module utils
|
||||||
|
Loading…
Reference in New Issue
Block a user