Skip to content

Commit

Permalink
homedir: verify
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Sep 1, 2023
1 parent 08e1b2c commit 569be54
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/ncarglow/fortran/fsutils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 569be54

Please sign in to comment.