Get the HOME directory on Unix and the %USERPROFILE% directory on Windows.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=:), | intent(out), | allocatable | :: | home | ||
type(error_t), | intent(out), | allocatable | :: | error |
subroutine get_home(home, error)
character(len=:), allocatable, intent(out) :: home
type(error_t), allocatable, intent(out) :: error
if (os_is_unix()) then
home=get_env('HOME','')
if ( home == '' ) then
call fatal_error(error, "Couldn't retrieve 'HOME' variable")
return
end if
else
home=get_env('USERPROFILE','')
if ( home == '' ) then
call fatal_error(error, "Couldn't retrieve '%USERPROFILE%' variable")
return
end if
end if
end subroutine get_home