oliveria@caen.engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA) (04/29/89)
c Please skip this if you don't use Fortran.
c Can someone tell me what is wrong with this program or
c better yet, how to use getenv in a Fortran program.
c Conditions of this run:
c sr9.7 or sr10.1
c bsd4.2 or bsd4.3
c ftn (Fortran 77 Compiler), revision 9.66
c or ftn (Fortran 77 Compiler), revision 10.00
c------------------------------------------------------------------
character*80 str
call libpth(str)
end
c------------------------------------------------------------------
c It only works for some environmental variables.
c I was told there was a problem with the c-shell but it had been
c fixed (it works fine for all env variables if you write this
c program in c language. We have 80 environmental variables)
c It doesn't work at all if you include integer*4 junkjunk
subroutine libpth(str)
character*(*) str
character*80 ncarg
integer*4 arg_pnt , getenv
c integer*4 junkjunk
pointer /arg_pnt/ ncarg
arg_pnt = getenv('SYSTYPE') {worked}
c arg_pnt = getenv('HOME') {didn't work}
c arg_pnt = getenv('NCARGLIB') {didn't work}
print *,'arg_pnt=',arg_pnt
print *,'ncarg=' ,ncarg
ncarg_len = nstr_len(ncarg)
str = ncarg(1:ncarg_len)
if (str(1:ncarg_len).eq.'') then
str = '/usr/local/lib/ncarg'
else
endif
print *,'str=',str
end
c------------------------------------------------------------------
integer function nstr_len(str)
character*(*) str
k =1
10 continue
if (str(k:k).eq.char(0)) go to 20
k=k+1
go to 10
20 nstr_len=k-1
return
end
c------------------------------------------------------------------
c Roque
c oliveria@caen.engin.umich.edu