Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=:), | intent(out), | allocatable | :: | config | Name of the configuration file |
subroutine get_config_file(config)
!> Name of the configuration file
character(len=:), allocatable, intent(out) :: config
character(len=*), parameter :: rc = 'mctc.toml'
character(len=:), allocatable :: tmp, prefix
character :: sep
logical :: exist
if (is_windows()) then
sep = '\'
call get_variable('HOMEDRIVE', prefix)
call get_variable('HOMEDIR', tmp)
prefix = prefix // tmp
else
sep = '/'
call get_variable('HOME', prefix)
end if
if (allocated(prefix)) then
tmp = prefix // sep // rc
inquire(file=tmp, exist=exist)
if (exist) then
config = tmp
return
end if
tmp = prefix // sep // '.' // rc
inquire(file=tmp, exist=exist)
if (exist) then
config = tmp
return
end if
end if
inquire(file=rc, exist=exist)
if (exist) then
config = rc
return
end if
end subroutine get_config_file