      subroutine namel(icmd)
c
c     namelist simulator for pc's with no namelist statement
c     this subroutine is program independent but it
c     calls subroutine check which is program dependent
c     The program does not handle the repeat indicator *
c     nor does it handle subscripted array variables or
c     substrings of character variables.
c     It also does not handle complex or logical variables.
c     nn = number of characters in value name(tvar)
c     chv = character variable indicator(logical)
c     inum = an array index number
c     nvar = a number returned by subroutine check to
c     determine whether a variable is an array
c     numa = a number returned by subroutine check
c     which is compared against nvar
c     r.godson,usgs,denver,co., 11/87
c
      parameter(ivar=80)
      character var(ivar),comma,apos,blank,equal,amp,dollar
      character*6 pvar
      character*56 tvar
      logical chv,vset
      data comma/','/,apos/#27/,blank/' '/,equal/'='/
      data amp/'&'/,dollar/'$'/,pvar/' '/,tvar/' '/
c
c     get namelist start name(e.g.&parms)
c
    5 read(icmd,1000,end=910) var
      do 7 i=1,ivar
      if(var(i).ne.amp.and.var(i).ne.dollar) go to 7
      do 6 m=i+1,ivar
      if(var(m).eq.blank) go to 15
    6 continue
    7 continue
      go to 5
c
c     start processing variables
c
   10 read(icmd,1000,end=900) var
 1000 format(80a1)
      m=1
   15 do 20 i=m,ivar
      if(var(i).eq.amp.or.var(i).eq.dollar) go to 900
      if(var(i).ne.blank.and.var(i).ne.comma) go to 30
   20 continue
      go to 10
   30 mm=0
c
c     check for continuation of array values on succeding lines
c
      item=ichar(var(i))
      if(item.eq.43.or.item.eq.45.or.item
     & .eq.46.or.(item.gt.47.and.item.lt.58).or.var(i).eq.apos) then
      k=i
      go to 95
      endif
c
c     get program variable name
c
   35 inum=1
      pvar=blank
      vset=.false.
      do 40 j=i,ivar
      if(var(j).eq.blank.or.var(j).eq.equal) go to 50
      mm=mm+1
      pvar(mm:mm)=var(j)
   40 continue
c
c     get variable value
c
     

   50 do 80 k=j+1,ivar
      if(var(k).eq.blank.or.var(k).eq.equal) go to 80
      if(var(k).eq.apos) then
c
c     character variable
      chv=.true.
      vset=.true.
      nn=0
      do 60 l=k+1,ivar
      if(var(l).eq.apos) go to 90
      nn=nn+1
      tvar(nn:nn)=var(l)
   60 continue
      write(*,*) 'error in namelist variable ',pvar,
     & ' no ending apostrophy'
      stop
      else
c
c     not a character variable
      chv=.false.
      nn=0
      do 70 l=k,ivar
      if(var(l).eq.blank.or.var(l).eq.comma
     & .or.var(l).eq.amp.or.var(l).eq.dollar) go to 90
c
c     check for non numeric character
c
      item=ichar(var(l))
      if((item.lt.48.and.(item.ne.46
     & .and.item.ne.45.and.item.ne.43)) .or. (item .gt. 57 .and.
     & (item .ne. 69 .and. item .ne. 101 .and. item.ne.68
     &  .and. item.ne.100))) then
      write(*,*) 'missing first apostropy or a non numeric',
     & ' character in namelist variable ',pvar
      stop
      endif
      nn=nn+1
      tvar(nn:nn)=var(l)
   70 continue
      write(*,*) 'error in namelist variable ',pvar,
     & ' no delimiter'
      stop
      endif
   80 continue
      write(*,*) 'error in namelist variable ',pvar,' no  value'
      stop
c
c     call program dependent subroutine to assign values
c
   90 call check(pvar,tvar,nn,chv,nvar,numa,inum)
      tvar=blank
      k=l+1
c
c     check to see if variable is an array
c     the variable numa used is program dependent
c
      if(nvar.lt.numa) go to 110
   95 if(.not.chv) then
c
c     array variable
c
      nn=0
      do 100 l=k,ivar
      if(var(l).eq.blank.and.nn.eq.0) go to 100
      if(var(l-1).eq.blank.and.var(l).eq.comma.and.nn.eq.0) go to 100
      if((var(l).eq.amp.or.var(l).eq.dollar).and.nn.eq.0) go to 900
c
c     check for consecutive commas
c
      if(var(l).eq.comma.and.vset) then
      vset=.false.
      inum=inum+1
      go to 90
      else if(var(l).eq.comma) then
      inum=inum + 1
      go to 100
      endif
c
      if(var(l).eq.blank
     & .or.var(l).eq.amp.or.var(l).eq.dollar) then
      inum=inum+1
      go to 90
      endif
      if(ichar(var(l)).gt.57.and.nn.eq.0) go to 120
      nn=nn+1
      tvar(nn:nn)=var(l)
      vset=.true.
  100 continue
      else
c
c     character array variable
c
      do 105 j=k,ivar
      if(var(j).eq.blank) go to 105
      if(var(j).eq.amp.or.var(j).eq.dollar) go to 900
      if(ichar(var(j)).gt.57) then
      l=j
      go to 120
      endif
c
c     check for consecutive commas
c
      if(var(j).eq.comma.and.vset) then
      vset=.false.
      go to 105
      else if(var(j).eq.comma) then
      inum=inum + 1
      go to 105
      endif
      if(var(j).eq.apos) then
      nn=0
      inum=inum+1
      vset=.true.
      do 103 l=j+1,ivar
      if(var(l).eq.apos) go to 90
      nn=nn+1
      tvar(nn:nn)=var(l)
  103 continue
      write(*,*) 'error in namelist variable ',pvar,
     & ' no ending apostrophy'
      stop
      endif
  105 continue
c
c     end of array values
c
      endif
  110 m=l+1
      if(var(l).eq.amp.or.var(l).eq.dollar) go to 900
      go to 130
  120 m=l
  130 if(m.lt.81) then
      go to 15
      else
      go to 10
      endif
  900 return
  910 write(*,*) ' error in namelist;no beginning & or $'
      stop
      end
c*********
      subroutine check(pvar,tvar,nn,chv,nvar,numa,inum)
c
c     assigns values to proper variable
c     variables are passed to program pccontur through common blocks
c     numr=position in the array var where real variables start
c     numa=position in the array var where arrays start
c     nnvar=number of variables in program pccontur
c
      parameter(nnvar=89,numr=26)
      common /titls/ title1,title2,title3,fmtx,fmty
      common /setxy/ xx(2),yy(2),xp1(4),yp1(4),iplotr,sizel,
     1 ncharx,nchary,sizex,sizey,adelx,adely,pllx,plly,
     1 lintx,linty,xscale,yscale,xxscal,yyscal,mscale,delx,dely
      common/chksiz/conlim
      common /concom/ ncol,nrow,bmin,bmax,
     1 grad,gflg,ijs,ije,ijsi,ijei,prime,ij4,cont,
     1 fltmax,lmult(0:3),idashs,linet,sigma,nsig
      common /llp/ latm(3),latx(3),longm(3),longx(3),cm(3),baslat(3),
     1 iproj,xxx(2),yyy(2),sizep,unit,ip,neat,tint,itpost,ibound,
     1 sizet,phi1,phi2
      common /vect/ ispost,lowhi,nid,ncharv,szpost,vmin,vmax,
     & lifmtv(14),lfmtv(4),ich(20),lchid(20),dgrad,sizehi,szlab
      common/labcom/lchars(6),fmtc,nchar,size,idum(3),delb
      common /contrc/ cmin,cmax,dcval,ncval,nsec,gradi,
     & acdel(200),acgrad(200),jcdash(200),ncval2,
     & acsize(200),acmin(200),acmax(200)
      common/txcb/txfile,iverb
      common /contur/ acval(200)
      common/hacom/hachln,hachsp,hachgp,hachmx,hachlm,hachvb
      common/lxcb/lxfile,lxfmt,lxproj,lxunit,lxtype
      common/files/ifile,ifile2,acfile,mxhach
      common/captur/icapt
c
      character*56 title1,title2,title3,ifile,ifile2,ifmtv,
     & acfile,lxfile,txfile
      character*16 fmtc,fmtx,fmty,fmtv,lxfmt,cfmt
      character*4 chid(20)
      real latm,latx,longm,longx
      character*6 pvar,var(nnvar)
      character*56 kvar,tvar
      equivalence(lchid,chid),(lifmtv,ifmtv),(lfmtv,fmtv)
      logical chv
      data var/'nsec','mscale','iplotr','nchar','idashs',
     1 'ncval','ncharx','nchary','lintx','linty','nsig','iproj',
     2 'neat','itpost','ibound','ispost','ncharv','lowhi','nid',
     3 'lxproj','lxunit','lxtype','mxhach','icapt','iverb','dcval',
     4 'cmin','cmax','xscale','yscale','gradi','size','phi1',
     5 'phi2','sizel','sizex','sizey','adelx','adely','pllx',
     6 'plly','sigma','sizep','unit','tint','vmax',
     7 'vmin','szpost','sizehi','szlab','sizet','conlim','dgrad','delb',
     8 'hachsp','hachln','hachlm','hachgp','hachvb',
     9 'title2','title3','fmtc','fmtx',
     a 'fmty','fmtv','ifmtv','ifile','ifile2',
     b 'acfile','lxfile','lxfmt','txfile','acval','latm',
     c 'latx','longm','longx','cm','baslat','xxx','yyy','ich','chid',
     d 'jcdash','acdel','acgrad','acsize','acmin','acmax'/
      numa=73
      do 190 i=1,100
      if(pvar.ne.var(i)) go to 190
      if(.not.chv) then
c
c     noncharacter value
c     right justify then number in variable kvar
c
      m=57-nn
      im=m-1
      kvar(m:56)=tvar(1:nn)
      if(i.lt.numr.or.i.eq.82.or.i.eq.84) then
c
c     integer value
c
      write(cfmt,50) im,nn
   50 format('(',i2,'x,i',i2,')')
      read(kvar,cfmt) jvar
      else
c
c     real value
c
      write(cfmt,60) im,nn
   60 format('(',i2,'x,g',i2,'.0)')
      read(kvar,cfmt) xvar
      endif
      endif
      go to (101,102,103,104,105,106,107,108,109,110,111,112,
     & 113,114,115,116,117,118,119,120,121,1121,1221,1321,1322,122,123,
     & 124,
     & 125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,
     & 142,143,144,145,1451,1452,1453,146,147,148,149,150,
     & 1150,1250,1350,151,152,153,154,
     & 155,156,157,158,159,160,161,162,163,164,165,166,167,168,
     & 169,170,171,172,173,174,175,176,177,178,179,180),i
  101 nsec=jvar
      go to 200
  102 mscale=jvar
      go to 200
  103 iplotr=jvar
      go to 200
  104 nchar=jvar
      go to 200
  105 idashs=jvar
      go to 200
  106 ncval=jvar
      go to 200
  107 ncharx=jvar
      go to 200
  108 nchary=jvar
      go to 200
  109 lintx=jvar
      go to 200
  110 linty=jvar
      go to 200
  111 nsig=jvar
      go to 200
  112 iproj=jvar
      go to 200
  113 neat=jvar
      go to 200
  114 itpost=jvar
      go to 200
  115 ibound=jvar
      go to 200
  116 ispost=jvar
      go to 200
  117 ncharv=jvar
      go to 200
  118 lowhi=jvar
      go to 200
  119 nid=jvar
      go to 200
  120 lxproj=jvar
      go to 200
  121 lxunit=jvar
      go to 200
 1121 lxtype=jvar
      go to 200
 1221 hachmx=float(jvar)
      mxhach=jvar
      go to 200
 1321 icapt=jvar
      go to 200
 1322 iverb=jvar
      go to 200
  122 dcval=xvar 
      go to 200
  123 cmin=xvar
      go to 200
  124 cmax=xvar
      go to 200
  125 xscale=xvar
      go to 200
  126 yscale=xvar
      go to 200
  127 gradi=xvar
      go to 200
  128 size=xvar
      go to 200
  129 phi1=xvar
      go to 200
  130 phi2=xvar
      go to 200
  131 sizel=xvar
      go to 200
  132 sizex=xvar
      go to 200
  133 sizey=xvar
      go to 200
  134 adelx=xvar
      go to 200
  135 adely=xvar
      go to 200
  136 pllx=xvar
      go to 200
  137 plly=xvar
      go to 200
  138 sigma=xvar
      go to 200
  139 sizep=xvar
      go to 200
  140 unit=xvar
      go to 200
  142 tint=xvar
      go to 200
  143 vmax=xvar
      go to 200
  144 vmin=xvar
      go to 200
  145 szpost=xvar
      go to 200
 1451 sizehi=xvar
      go to 200
 1452 szlab=xvar
      go to 200
 1453 sizet=xvar
      go to 200
  146 conlim=xvar
      go to 200
  147 dgrad=xvar
      go to 200
  148 delb=xvar
      go to 200
  149 hachsp=xvar
      go to 200
  150 hachln=xvar
      go to 200
 1150 hachlm=xvar
      go to 200
 1250 hachgp=xvar
      go to 200
 1350 hachvb=xvar
      go to 200
  151 title2=tvar(1:nn)
      go to 200
  152 title3=tvar(1:nn)
      go to 200
  153 fmtc=tvar(1:nn)
      go to 200
  154 fmtx=tvar(1:nn)
      go to 200
  155 fmty=tvar(1:nn)
      go to 200
  156 fmtv=tvar(1:nn)
      go to 200
  157 ifmtv=tvar(1:nn)
      go to 200
  158 ifile=tvar(1:nn)
      go to 200
  159 ifile2=tvar(1:nn)
      go to 200
  160 acfile=tvar(1:nn)
      go to 200
  161 lxfile=tvar(1:nn)
      go to 200
  162 lxfmt=tvar(1:nn)
      go to 200
  163 txfile=tvar(1:nn)
      go to 200
  164 acval(inum)=xvar
      go to 200
  165 latm(inum)=xvar
      go to 200
  166 latx(inum)=xvar
      go to 200
  167 longm(inum)=xvar
      go to 200
  168 longx(inum)=xvar
      go to 200
  169 cm(inum)=xvar
      go to 200
  170 baslat(inum)=xvar
      go to 200
  171 xxx(inum)=xvar
      go to 200
  172 yyy(inum)=xvar
      go to 200
  173 ich(inum)=jvar
c      print *, inum, jvar
      go to 200
  174 chid(inum)=tvar(1:nn)
      go to 200
  175 jcdash(inum)=jvar
      go to 200
  176 acdel(inum)=xvar
      go to 200
  177 acgrad(inum)=xvar
      go to 200
  178 acsize(inum)=xvar
      go to 200
  179 acmin(inum)=xvar
      go to 200
  180 acmax(inum)=xvar
      go to 200
  190 continue
      write(*,*) ' error in namelist - ',pvar,' variable not included'
      stop
  200 nvar=i
      return
      end
