1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
c This reads a string value. If it isn't in the namelist,
c it defaults to the value passed in.
c
c Variables which have default values may safely be passed in both
c as the default value and as the value read in.
subroutine nl_str(key,def,var)
implicit none
character*(*) key,def,var
#include "namelist.com"
#include "callstack.com"
character*(nllinelen) str1,str2
logical nl_key,present
integer strlen
callstack_prev=callstack_curr
callstack_curr='NL_STR'
present=nl_key(key,var)
if (.not.present) var=def
if (prt_nl) then
if (strlen(var).le.20) then
str1=var
else
str1=var(1:18)//' $'
end if
if (strlen(def).le.20) then
str2=def
else
str2=def(1:18)//' $'
end if
if (var(1:strlen(var)).eq.def(1:strlen(def))) then
write(*,900) key,'string',str1
900 format(a20,2x,a10,2x,a20)
else
write(*,910) key,'string',str1,str2
910 format(a20,2x,a10,2x,a20,2x,a20)
end if
end if
callstack_curr=callstack_prev
return
c end subroutine nl_str
end
|