Skip to content

Commit

Permalink
fs: use generic filesep
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Sep 1, 2023
1 parent f1ed959 commit 08e1b2c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/ncarglow/fortran/fsutils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function expanduser(indir)
if (indir(1:1) /= '~') then
expanduser = trim(adjustl(indir))
elseif (len_trim(indir) < 3) then
expanduser = homedir()
expanduser = homedir() // "/"
else
expanduser = homedir() // trim(adjustl(indir(3:)))
expanduser = homedir() // "/" // trim(adjustl(indir(3:)))
endif

end function expanduser
Expand All @@ -28,19 +28,16 @@ end function expanduser
function homedir()

character(:), allocatable :: homedir
character :: filesep
character(256) :: buf

! assume MacOS/Linux/BSD/Cygwin/WSL
filesep = '/'
call get_environment_variable("HOME", buf)

if (len_trim(buf) == 0) then ! Windows
call get_environment_variable("USERPROFILE", buf)
filesep = char(92)
endif

homedir = trim(buf) // filesep
homedir = trim(buf)

end function homedir

Expand Down

0 comments on commit 08e1b2c

Please sign in to comment.