From 569be5430520cdf16463ab7530d10d072b03baad Mon Sep 17 00:00:00 2001 From: scivision Date: Fri, 1 Sep 2023 13:55:07 -0400 Subject: [PATCH] homedir: verify --- src/ncarglow/fortran/fsutils.f90 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ncarglow/fortran/fsutils.f90 b/src/ncarglow/fortran/fsutils.f90 index ae7194f..94301ae 100644 --- a/src/ncarglow/fortran/fsutils.f90 +++ b/src/ncarglow/fortran/fsutils.f90 @@ -29,14 +29,17 @@ function homedir() character(:), allocatable :: homedir character(256) :: buf +integer :: i ! assume MacOS/Linux/BSD/Cygwin/WSL -call get_environment_variable("HOME", buf) +call get_environment_variable("HOME", buf, status=i) -if (len_trim(buf) == 0) then ! Windows - call get_environment_variable("USERPROFILE", buf) +if (i /= 0) then ! Windows + call get_environment_variable("USERPROFILE", buf, status=i) endif +if (i/=0) error stop 'could not determine home directory' + homedir = trim(buf) end function homedir