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)
|
||||
|
||||
! Convert all filenames to absolute paths
|
||||
! Note: `filenm` is assumed to be a path relative to the
|
||||
! gray_params.data file.
|
||||
block
|
||||
use utils, only : dirname
|
||||
params%antenna%filenm = dirname(filename) // params%antenna%filenm
|
||||
params%equilibrium%filenm = dirname(filename) // params%equilibrium%filenm
|
||||
params%profiles%filenm = dirname(filename) // params%profiles%filenm
|
||||
use utils, only : dirname, isrelative
|
||||
if (isrelative(params%antenna%filenm)) &
|
||||
params%antenna%filenm = dirname(filename) // params%antenna%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 subroutine read_parameters
|
||||
|
||||
|
@ -293,10 +293,20 @@ contains
|
||||
directory = filepath(1:last_sep)
|
||||
|
||||
! append the cwd to relative paths
|
||||
if (filepath(1:1) /= '/') then
|
||||
if (isrelative(filepath)) then
|
||||
call getcwd(cwd)
|
||||
directory = trim(cwd) // '/' // directory
|
||||
end if
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user