
      subroutine getinp
      include 'tigcmdif.h'
      dimension htsc(3)
c
      call lexcon(pertvol ,8HPERTVOL ,npvols)
      call lexcon(mtpert  ,8HPERTTIME,nptimes)
      call lexcon(cntrvol ,8HCNTRVOL ,ncvols)
      call lexcon(mtcntr  ,8HCNTRTIME,nctimes)
      call lexcon(iden    ,8HIDEN    ,niden)
      call lexcon(idif    ,8HIDIF    ,nidif)
      call lexcon(icolor  ,8HCOLOR   ,ncolor)
      call lexcon(cenglb  ,8HCENGLB  ,nglb)
      call lexcon(cenmolw ,8HCENMOLW ,nmolw)
      call lexcon(censatv ,8HCENSATV ,nsatv)
      call lexcon(perimlat,8HPOLLAT  ,npollat)
      call lexcon(icont   ,8HICONT   ,ncont)
      call lexcon(ituv    ,8HTUV     ,ntuv)
      call lexcon(ipuv    ,8HPUV     ,npuv)
      call lexcon(uvmax   ,8HUVMAX   ,nuvmax)
      call lexcon(log10map,8HLOG10   ,nlog10)
      call lexcon(spls    ,8HZP      ,npls)
      call lexcon(shts    ,8HHTS     ,nhts)
      call lexcon(slon    ,8HLON     ,nlon)
      call lexcon(sslt    ,8HSLT     ,nslt)
      call lexcon(slat    ,8HLAT     ,nlat)
      call lexcon(zprange ,8HZP_RANGE,nzpr)
      call lexcon(htsc    ,8HHT_SCALE,nhtscale)
      call lexcon(gloc    ,8HLOC     ,nloc)
      call lexcon(locname ,8HLOCNAME ,nlocname)
      call lexcon(ibilin  ,8HBILIN   ,nbilin)
      call lexcon(lineloc ,8HLINELOC ,nlineloc)
      call lexcon(iutloc  ,8HUTLOC   ,nutloc)
      call lexcon(iutline ,8HUTLINE  ,nutline)
      call lexcon(iutlat  ,8HUTLAT   ,nutlat)
      call lexcon(zphtlon ,8HZPHT_LON,nzphtlon)
      call lexcon(ifplt   ,8HFIELDS  ,npltact)
      call lexcon(iwrascii,8HWRASCII ,nwrascii)
      call lexcon(mssascii,8HMSSASCII,nmsascii)
      call lexcon(dirascii,8HDIRASCII,ndirdat)
      call lexcon(dircgm  ,8HDIRCGM  ,ndircgm)
      call lexcon(cmin    ,8HCMIN    ,ncmin)
      call lexcon(cmax    ,8HCMAX    ,ncmax)
      call lexcon(cint    ,8HCINT    ,ncint)
      call readlx(5,ierr)
      if (ierr.ne.1) then
        write(6,"(' ')")
        write(6,"('>>> getinp readlx ierr=',i10)") ierr
        write(6,"(' ')")
        stop 'readlx'
      endif
c
c Iden = 0,1,2 for mass mixing ratios, number densities, mass densities
c
      if (niden.lt.0.or.iden.gt.2) then
        write(6,"(' >>> getinp: no iden -- will default to cm-3')")
        iden = 1
      endif
c
      if (nidif.lt.0) idif = 1
      if (idif.gt.1) then
        write(6,"('>>> getinp: bad idif=',i3,
     +    ' will default to idif=1')") idif
        idif = 1
      endif
      if (nbilin.le.0) ibilin = 0
c
c Color option:
c
      if (ncolor.le.0) icolor = 0
c
c Perturbed histvol(s)
c
      if (mod(npvols,3).ne.0) then
        write(6,"('>>> getinp: perturbed history volumes must be ',
     +    '24-chars each',/,' npvols=',i3)") npvols
        stop 'npvols'
      endif
      npvols = npvols/3
      if (npvols.gt.mxvols) then
        write(6,"(' >>> getinp: npvols.gt.mxvols: npvols=',I3,
     +    ' mxvols=',i3)") npvols,mxvols
        stop 'npvols'
      endif
c
c Control histvol(s)
c
      if (mod(ncvols,3).ne.0) then
        write(6,"('>>> getinp: control history volumes must be ',
     +    '24-chars each',/,' ncvols=',i3)") ncvols
        stop 'ncvols'
      endif
      ncvols = ncvols/3
      if (ncvols.gt.mxvols) then
        write(6,"(' >>> getinp: ncvols.gt.mxvols: ncvols=',I3,
     +    ' mxvols=',i3)") ncvols,mxvols
        stop 'ncvols'
      endif
c        
c Number of desired times:
c        
      if (nptimes.le.0.or.nctimes.le.0) then
        write(6,"('>>> getinp: need model times (CNTRTIME and ',
     +    'PERTTIME)')")
        stop 'mtimes'
      endif
      if (nptimes.ne.nctimes) then
        write(6,"('>>> getinp: need same number of perturbed and ',
     +    'control times: nptimes=',i3,' nctimes=',i3)") nptimes,nctimes
        stop 'ntimes'
      endif
      ntimes = nptimes
      if (mod(ntimes,3).ne.0) then
        write(6,"('>> getinp: model times should come in triplets ',
     +    '(dd,hh,mm): ntimes=',i3)") ntimes
        stop 'ntimes'
      endif
      ntms = ntimes/3
      if (ntms.gt.mxtms) then
        write(6,"('>>> getinp: too many model times (DDHHMM);',
     +    ' ntms=',i3,' mxtms=',i3)") ntms,mxtms
        stop 'mxtms'
      endif
c
c Ut loop:
c (mh,mm=99 means search only)
c
      do it=1,ntms
c
c Perturbed times:
        if (mtpert(2,it).ne.99.and.
     +     (mtpert(2,it).lt.0.or.mtpert(2,it).gt.23)) then
          write(6,"('>>> getinp: bad perturbed model hour: ',i3,
     +      ' it=',i3)") mtpert(2,it),it
          stop 'mhour'
        endif
        if (mtpert(3,it).ne.99.and.
     +     (mtpert(3,it).lt.0.or.mtpert(3,it).gt.59)) then
          write(6,"('>>> getinp: bad perturbed model minute: ',i3,
     +      ' it=',i3)") mtpert(3,it),it
          stop 'mm'
        endif
        utpert = float(mtpert(2,it))+float(mtpert(3,it))/60.
c
c Control times:
        if (mtcntr(2,it).ne.99.and.
     +     (mtcntr(2,it).lt.0.or.mtcntr(2,it).gt.23)) then
          write(6,"('>>> getinp: bad perturbed model hour: ',i3,
     +      ' it=',i3)") mtcntr(2,it),it
          stop 'mhour'
        endif
        if (mtcntr(3,it).ne.99.and.
     +     (mtcntr(3,it).lt.0.or.mtcntr(3,it).gt.59)) then
          write(6,"('>>> getinp: bad perturbed model minute: ',i3,
     +      ' it=',i3)") mtcntr(3,it),it
          stop 'mm'
        endif
        utcntr = float(mtcntr(2,it))+float(mtcntr(3,it))/60.
        if (utpert.ne.utcntr) then
          write(6,"('>>> getinp: pert and cntr ut must be the same:',
     +      ' utpert=',f6.2,' utcntr=',f6.2)") utpert,utcntr
          stop 'ut'
        endif
        ut(it) = float(mtcntr(2,it))+float(mtcntr(3,it))/60.
        utinc(it) = float(mtcntr(1,it))*24.+float(mtcntr(2,it))+
     +    float(mtcntr(3,it))/60.
      enddo
c
c ifplt(nftot) = desired fields to plot
c ifget(nftot) = fields needed (ifplt plus others as needed below):
c Thus, hpalloc for fields and call to getgcmf use ifget, whereas plot
c   routines use ifplt.
c If fewer than nftot flags are received, fill in with zeroes and list
c   available fields
c If no field flags are set, stop.
c
      if (npltact.lt.nftot) then
        write(6,"(/'WARNING: received ',i3,' FIELDS flags but ',
     +    'expected ',i3,' flags')") npltact,nftot
        write(6,"('  Field flags ',i3,' to ',i3,' will be set ',
     +    'to zero')") npltact+1,nftot
        do i=npltact+1,nftot
          ifplt(i) = 0
        enddo
        write(6,"('  Following is a list of fields and flags:')")
        write(6,"('index  name      flag')")
        nf = 0
        do i=1,nftot
          write(6,"(i5,2x,a8,2x,i4)") i,labshort(i),ifplt(i)
          if (ifplt(i).gt.0) nf = nf+1
        enddo
        if (nf.eq.0) then
          write(6,"(/'>>> NO FIELDS FLAGGED -- stop')")
          stop 'nofields'
        endif
      endif
      do i=1,nfhist
        ifget(i) = ifplt(i)
      enddo 
      ifget(ixz) = 1 ! always get heights
c
c Need potential and heights for ion drifts:
      if (ifplt(ixui).gt.0.or.ifplt(ixvi).gt.0.or.ifplt(ixwi).gt.0.or.
     +    ifplt(ixuivi).gt.0) then
        ifget(ixpot) = 1
      endif
c
c Need uv and vn to calculate vapr and wpar:
c (dip and dec are found in tigcmdif.f using igrf)
c
      if (ifplt(ixvpar).gt.0.or.ifplt(ixwpar).gt.0) then
        ifget(ixu) = 1
        ifget(ixv) = 1
      endif
c
c Need ne and hts to get fof2 and/or hmf2:
      if (ifplt(ixfof2).gt.0.or.ifplt(ixhmf2).gt.0) then
        ifget(ixne) = 1
      endif
c
c Need o2,o,n2 for total density (rho):
      if (ifplt(ixrho).gt.0) then
        ifget(ixo1) = 1
        ifget(ixo2) = 1
        ifget(ixn2) = 1
      endif
c
c Need o2,n2 for O/N2:
      if (ifplt(ixon2).gt.0.or.ifplt(ixn2o).gt.0) then
        ifget(ixo1) = 1
        ifget(ixn2) = 1
      endif
c
c------------------ begin mapped projection inputs ------------------
c
      imap = 0
      if (nglb.le.0.and.nmolw.le.0.and.nsatv.le.0.and.npollat.le.0) 
     +  goto 100
      imap = 1
c
c Continental outlines flag (default is to draw continental outlines):
      if (ncont.le.0) icont = 1
c
c Plot un+vn vectors over tn if ituv > 0, or unvn vectors alone
c if ixunvn > 0:
      if (ntuv.le.0) ituv = 1
      if (ifplt(ixunvn).gt.0.or.(ituv.gt.0.and.ifplt(ixt).gt.0)) then
        ifget(ixu) = 1
        ifget(ixv) = 1
      endif
c
c Plot ui+vi vectors over potential if ipuv > 0, or uivi vectors
c alone if ixuivi > 0:
      if (npuv.le.0) ipuv = 1
      if (ifplt(ixuivi).gt.0.or.(ipuv.gt.0.and.ifplt(ixpot).gt.0)) then
        ifget(ixui) = 1
        ifget(ixvi) = 1
      endif
c
c Max magnitude for vector scaling:
      if (nuvmax.le.0) uvmax = 0.
c
c Plot log10 on mapped projections if log10map > 0:
      if (nlog10.le.0) log10map = 0
c
c CE projection(s) (nglb may be = 0):
c (cenglb(2,i) = r12flag means use local noon longitude)
c
      if (nglb.gt.0)
     +  call checkcen(nglb,mxmap,cenglb,gcmlon,imx,r12flag,'CENGLB')
c
c MO projection(s) (nmolw may be = 0):
c (cenmolw(2,i) = r12flag means use local noon longitude)
c
      if (nmolw.gt.0)
     +  call checkcen(nmolw,mxmap,cenmolw,gcmlon,imx,r12flag,'CENMOLW')
c
c Sat view projection(s) (nsatv may be = 0):
c (censatv(2,i) = r12flag means use local noon longitude)
c
      if (nsatv.gt.0)
     +  call checkcen(nsatv,mxmap,censatv,gcmlon,imx,r12flag,'CENSATV')
c
c Perimeter latitudes (for polars)
c
      if (npollat.gt.mxmap) then
        write(6,"('>>> getinp: too many perim lats (POLLAT)=',i3
     +    ' will default to ',i3)") npollat,mxmap
        npollat = mxmap
      endif
      if (npollat.gt.0) then
        do i=1,npollat
          ixlat = ixfind(gcmlat,jmx,perimlat(i),dlat)
          if (ixlat.le.0) then
            write(6,"('>>> getinp: bad perimlat (POLLAT)=',f10.3,
     +        ' i=',i3)") perimlat(i),i
            stop 'perimlat'
          endif
          perimlat(i) = gcmlat(ixlat)
        enddo
      endif
c
c Selected pressures for mapped projections:
      if (npls.gt.kmx) then
        write(6,"('>>> getinp: too many spls: npls=',i3,
     +    ' will default to ',i3)") npls,kmx
        npls = kmx
      endif
c
c Selected heights for mapped projections:
      if (nhts.gt.kmx) then
        write(6,"('>>> getinp: too many hts: nhts=',i3,
     +    ' will default to ',i3)") nhts,kmx
        nhts = kmx
      endif
 100  continue
c
c-------------------- end mapped projection inputs ------------------
c
c-------------- begin vertical slice and loc plots inputs -----------
c
      islice = 0
      if (nloc.le.0.and.iutloc.gt.0) then
        write(6,"('>>> need LOC locations to make UTLOC plots -- ',
     +    'turning iutloc off')")
        iutloc = 0
      endif
      if (nloc.le.0.and.iutline.gt.0) then
        write(6,"('>>> need LOC locations to make UTLINE plots -- ',
     +    'turning iutline off')")
        iutline = 0
      endif
      if (nloc.le.0.and.lineloc.gt.0) then
        write(6,"('>>> need LOC locations to make LINELOC plots -- ',
     +    'turning lineloc off')")
        lineloc = 0
      endif
      if (ntms.le.1.and.(iutloc.gt.0.or.iutline.gt.0.or.iutlat.gt.0))
     +  then
        write(6,"('>>> need more than 1 time to make plots with ',
     +    'ut on x-axis -- turning off multi-ut plots')")
        iutloc = 0
        iutline = 0
        iutlat = 0
      endif
      if (nlon.le.0.and.nslt.le.0.and.nlat.le.0.and.nloc.le.0) goto 200
      islice = 1
c
c Locations for line plots:
c
      if (nloc.gt.0) then
        if (mod(nloc,2).ne.0) then
          write(6,"('>>> getinp: need even number of locs (lat,lon)',
     +      ' nloc=',i3)") nloc
          stop 'nloc'
        else
          nloc = nloc/2
        endif
        if (nloc.gt.mxloc) then
          write(6,"('>>> getinp: too many locs: nloc=',i3,
     +      ' will default to ',i3)") nloc,mxloc
          stop 'nloc'
        endif
        write(6,"('getinp: nloc=',i2)") nloc
        if (nlocname.gt.0) then
          if (nlocname.ne.nloc*2) then
            write(6,"('>>> getinp: must have one 16-char loc name ',
     +        'for each location: nloc=',i2,' but nlocname=',i2)")
     +        nloc,nlocname/2
            stop 'locname'
          endif
        else
          locname(1) = 'xxxxxxxxxxxxxxxx'
        endif
        do i=1,nloc
c
c Accept lon in range 0->360, but convert to -180->+180:
c (If not doing interpolation to location, change glat,glon to reflect 
c   actual grid point used)
c
          if (gloc(2,i).ne.gmflag.and.gloc(2,i).gt.180.)
     +      gloc(2,i) = gloc(2,i)-360.
          if (gloc(1,i).ne.gmflag.and.gloc(2,i).ne.gmflag) then
            ilat = ixfind(gcmlat,jmx,gloc(1,i),dlat)
            ilon = ixfind(gcmlon,imx,gloc(2,i),dlon)
            if (ilat.le.0.or.ilon.le.0.) then
              write(6,"('>>> getinp: bad LOC=',2f10.2,' i=',i2)")
     +          (gloc(ii,i),ii=1,2),i
              stop 'LOC'
            endif
            if (ibilin.le.0) then
              gloc(1,i) = gcmlat(ilat)
              gloc(2,i) = gcmlon(ilon)
            endif
          elseif (gloc(1,i).ne.gmflag.or.gloc(2,i).ne.gmflag) then
            write(6,"('>>> getinp: bad LOC=',2f10.2,' i=',i2,/,
     +        ' (both lat,lon must be = ',f4.0,' for global means)')")
     +          (gloc(ii,i),ii=1,2),i,gmflag
            stop 'LOC'
          endif
          if (locname(1).eq.'xxxxxxxxxxxxxxxx') then
            write(6,"('LOC ',i2,' = ',2f9.2)") i,(gloc(ii,i),ii=1,2)
          else
            write(6,"('LOC ',i2,' = ',2f9.2,' (',a,')')") 
     +        i,(gloc(ii,i),ii=1,2),locname(i)(1:lenstr(locname(i)))
          endif
        enddo
      endif
c
c Selected longitudes (for lon slices made in pltlon):
      if (nlon.gt.imx) then
        write(6,"('>>> getinp: too many lons: nlon=',i3,
     +    ' will default to ',i3)") nlon,imx
        nlon = imx
      endif
c
c Selected local times (for lon slices made in pltlon):
      if (nslt.gt.imx) then
        write(6,"('>>> getinp: too many slt: nslt=',i3,
     +    ' will default to ',i3)") nslt,imx
        nslt = imx
      endif
      if (nslt.gt.0) then
        do i=1,nslt
          if (sslt(i).lt.0..or.sslt(i).gt.23.99999) then
            write(6,"('>>> getinp: bad SLT=',f10.2)") sslt(i)
            stop 'SLT'
          endif
        enddo
      endif
c
c Selected latitudes (for lat slices made in pltlat):
      if (nlat.gt.jmx) then
        write(6,"('>>> getinp: too many lats: nlat=',i3,
     +    ' will default to ',i3)") nlat,jmx
        nlat = jmx
      endif
c
c Range of zp for y-axis for vertical slices:
      if (nzpr.gt.0) then
        if (zprange(1).lt.gcmzp(1).or.zprange(2).gt.gcmzp(kmx).or.
     +      zprange(1).ge.zprange(2)) then
          write(6,"('>>> BAD ZP_RANGE = ',2f10.2,' gcmzp=',/(6e12.4))")
     +      zprange,gcmzp
          stop 'zprange'
        endif
        izprange(1) = ixfind(gcmzp,kmx,zprange(1),dzp)
        if (izprange(1).lt.0) then
          write(6,"('>>> error from ixfind for zprange(1): zprange(1)=',
     +      f10.2,' kmx=',i3,' gcmzp=',/(6e12.4))") zprange(1),kmx,gcmzp
          stop 'izprange'
        endif
        izprange(2) = ixfind(gcmzp,kmx,zprange(2),dzp)
        if (izprange(2).lt.0) then
          write(6,"('>>> error from ixfind for zprange(2): zprange(2)=',
     +      f10.2,' kmx=',i3,' gcmzp=',/(6e12.4))") zprange(2),kmx,gcmzp
          stop 'izprange'
        endif
        write(6,"('getinp: zprange=',2f8.2,' izprange=',2i3)") zprange,
     +    izprange
      else 
        izprange(1) = 0
        izprange(2) = 0
      endif
      nzprange = izprange(2)-izprange(1)
c
c Linear height scale (for pltlat,pltlon):
c User specifies bottom, top, and delta in that order:
c
      if (nhtscale.gt.0.and.nhtscale.ne.3) then
        write(6,"('>>> getinp: HTSCALE should be = htbot,httop,delht ',
     +    'e.g., 50.,500.,25.')")
        stop 'htscale'
      endif
      if (nhtscale.gt.0) then
        if (htsc(1).ge.htsc(2)) then
          write(6,"('>>> getinp: HTSCALE: top must be > bot: bot=',
     +      f10.2,' top=',f10.2)") htsc(1),htsc(2)
          stop 'htscale'
        endif
        if (htsc(3).le.0.) then
          write(6,"('>>> getinp: HTSCALE: bad delta ht=',f10.2)")htsc(3)
          stop 'htscale'
        endif
        htbot = htsc(1)
        httop = htsc(2)
        delht = htsc(3)
      else
        delht = 0.
      endif
c
c Set up linear height scale, if needed:
c
      nhtscale = 0
      if (delht.gt.0.) then
        nhtscale = ifix((httop-htbot) / delht + 1.0000001)
        call hpalloc(phtscale,nhtscale,ier,1)
        if (ier.ne.0) then
          write(6,"('hpalloc error = ',i6,' for phtscale')") ier
          stop 'phtscale'
        endif
        do i=1,nhtscale
          htscale(i) = htbot + (i-1)*delht
        enddo
        if (nlon.gt.0.or.nslt.gt.0.or.nloc.gt.0)
     +    write(6,"('getinp: nhtscale=',i2,' linear height scale = ',
     +      /(6e10.3))") nhtscale,(htscale(i),i=1,nhtscale)
      endif
c
c If utline plots are requested (ut on x-axis, field on y-axis) at
c selected heights, then ht_scale must also be set, and all hts must
c lie within the range of htscale. Check here to make sure htscale
c is set, but check for hts within range will be done in pltutlin:
c
      if (iutline.gt.0.and.nhts.gt.0.and.nhtscale.le.0) then
        write(6,"('>>> getinp: need linear height scale for UTLINE ',
     +    ' with HTS -- turning UTLINE off')")
        iutline = 0
      endif
      if (iutline.gt.0.and.ntms.le.1) then
        write(6,"('>>> getinp: need more than one time to make ',
     +    'utline plots -- turning UTLINE off')")
        iutline = 0
      endif
c
c iutloc = contours with ut on x-axis, zp (not ht) on y-axis:
c
      if (iutloc.gt.0) then
        if (ntms.le.1) then
          write(6,"('>>> Need more than one time to make utloc plots',
     +      ' -- turning UTLOC off')")
          iutloc = 0  
        endif
        write(6,"('getinp: will make utloc plots')")
      endif
 200  continue
c
c iutlat = 1 -> contour ut on x-axis, latitude on y-axis at zphtlon pairs: 
c
      if (nutlat.le.0) iutlat = 0
      if (iutlat.gt.0.and.nzphtlon.le.0) then
        write(6,"('>>> getinp: need ZPHT_LON (zp/ht,lon pairs) for ',
     +    'UTLAT (contour ut x-axis, latitude y-axis)')")
        stop 'ZPHT_LON'
      endif
c
c zpht_lon (zpht,lon pairs) for contours with ut on x-axis, lat on y-axis
c
      if (iutlat.gt.0) then
        if (mod(nzphtlon,2).ne.0) then
          write(6,"('>>> getinp: need even number of ZPHT_LON ',
     +      ' (lat,lon)  nzphtlon=',i3)") nzphtlon
          stop 'nzphtlon'
        else
          nzphtlon = nzphtlon/2
        endif
        if (nzphtlon.gt.mxloc) then
          write(6,"('>>> getinp: too many ZPHT_LON: nzphtlon=',i3,
     +      ' will default to ',i3)") nzphtlon,mxloc
          nzphtlon = mxloc
        endif
        write(6,"('getinp: nzphtlon=',i2)") nzphtlon
        do i=1,nzphtlon
          if (zphtlon(1,i).lt.gcmzp(1)) then 
            write(6,"('>>> getinp: bad zp (ZPHT_LON)=',f8.2,' i=',i3)")
     +        zphtlon(1,i),i
            stop 'zphtlon'
          endif
          if (zphtlon(2,i).ne.zmflag.and.
     +       (zphtlon(2,i).lt.gcmlon(1).or.zphtlon(2,i).gt.gcmlon(imx))) 
     +      then
            write(6,"('>>> getinp: bad lon (ZPHT_LON)=',f8.2,' i=',
     +        i3)") zphtlon(2,i),i
            stop 'zphtlon'
          endif
c
c At selected zp (put index to zp in zphtlon(1,i)):
          if (zphtlon(1,i).le.gcmzp(kmx)) then
            izphtlon(1,i) = ixfind(gcmzp,kmx,zphtlon(1,i),dzp)
            if (izphtlon(1,i).le.0) then
              write(6,"('>>> getinp: error from ixfind for ',
     +          'zphtlon(1,i)=',f8.2)") zphtlon(1,i)
              stop 'zphtlon'
            endif
c
c At selected height (flag izphtlon(1,i)):
          else
            izphtlon(1,i) = 0
          endif
c
c At selected longitude:
          if (zphtlon(2,i).ne.zmflag) then
            izphtlon(2,i) = ixfind(gcmlon,imx,zphtlon(2,i),dlon)
            if (izphtlon(2,i).le.0) then
              write(6,"('>>> getinp: error from ixfind for ',
     +          'zphtlon(2,i)=',f8.2)") zphtlon(2,i)
              stop 'zphtlon'
            endif
            write(6,"('ZPHT_LON(',i2,')=',2f8.2)") i,
     +        (zphtlon(ii,i),ii=1,2)
c
c At zonal means (flag izphtlon(2,i):
          else
            izphtlon(2,i) = ifix(zmflag)
            write(6,"('ZPHT_LON(',i2,')=',2f8.2,' (ZONAL MEANS)')")
     +        i,(zphtlon(ii,i),ii=1,2)
          endif
        enddo
      endif
c
c---------------- end vertical slice and loc plots inputs -----------
c
c Fields to get (nfget = number of fields to get (sum of ifget > 0)
c (max nfget = nfhist)
c
      nfget = 0
      do ip=1,nfhist
        if (ifget(ip).gt.0) nfget = nfget+1
      enddo 
      if (nfget.le.0) then
        write(6,"('>>> No fields to get?? nfget=',i3,' ifplt=',
     +    /(10i5))") nfget,ifplt
        stop 'nfget'
      endif
      ixfld(:) = 0
      ii = 0
      do i=1,nfhist
        if (ifget(i).gt.0) then
          ii = ii+1
          ixfld(i) = ii
        endif
      enddo
c
c nfplt = number of fields to plot (used for utloc plots):
c
      nfplt = 0
      do ip=1,nftot
        if (ifplt(ip).gt.0) nfplt = nfplt+1
      enddo
c
c Contour intervals:
c
      if (ncint.le.0) then
        do ip=1,nftot
          cint(ip) = 0.
        enddo
      elseif (ncint.lt.nftot) then
c       write(6,"('>>> Need ',i3,' contour intervals (CINT),'
c    +    ' or none: got ',i3,' -- stop ')")
c    +    nftot,ncint
c       stop 'CINT'
        write(6,"('>>> NOTE: Received ',i3,' CINT values, but ',
     +    'expected ',i3,' -- remaining fields CINT will be 0.')")
     +    ncint
      endif
c
c Contour minimums:
c
      if (ncmin.le.0) then
        do ip=1,nftot
          cmin(ip) = 1.
        enddo
      elseif (ncmin.lt.nftot) then
c       write(6,"('>>> Need ',i3,' contour minimums (CMIN),'
c    +    ' or none: got ',i3,' -- stop ')")
c    +    nftot,ncmin
c       stop 'CMIN'
        write(6,"('>>> NOTE: Received ',i3,' CMIN values, but ',
     +    'expected ',i3,' -- remaining fields CMIN will be 1.')")
     +    ncmin
      endif
c
c Contour maximums:
c
      if (ncmax.le.0) then
        do ip=1,nftot
          cmax(ip) = 0.
        enddo
      elseif (ncmax.lt.nftot) then
c       write(6,"('>>> Need ',i3,' contour maximums (CMAX),'
c    +    ' or none: got ',i3,' -- stop ')")
c    +    nftot,ncmax
c       stop 'CMAX'
        write(6,"('>>> NOTE: Received ',i3,' CMAX values, but ',
     +    'expected ',i3,' -- remaining fields CMAX will be 0.')")
      endif
c
c iwrascii = 0 -> do not write ascii data file
c iwrascii = 1 -> write ascii data file per frame
c iwrascii = 2 -> write single ascii data file (append each frame)
c dirascii = remote dir for rcp of ascii files
c
      if (nwrascii.le.0) iwrascii = 0
      if (ndirdat.gt.0) then
        if (ndirdat.ne.7) then
          write(6,"('>>> DIRASCII must be 56 characters: ',
     +      'ndirdat=',i3)") ndirdat
          stop 'DIRASCII'
        endif
      else
        call clearstr(dirascii)
      endif
c
c mssascii = mass store dir to put ascii files:
c
      if (nmsascii.gt.0) then
        if (nmsascii.ne.7) then
          write(6,"('>>> MSSASCII must be 56 characters: ',
     +      'nmsascii=',i3)") nmsascii
          stop 'MSSASCII'
        endif
      else
        call clearstr(nmsascii)
      endif
c
c dircgm = remote dir for rcp of gmeta
c
      if (ndircgm.gt.0) then
        if (ndircgm.ne.7) then
          write(6,"('>>> DIRCGM must be 56 characters: ',
     +      'ndircgm=',i3)") ndircgm
          stop 'DIRCGM'
        endif
      else
        call clearstr(dircgm)
      endif
c
      return
      end
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
      subroutine checkcen(ncen,mxmap,cen,gcmlon,imx,glonflag,lab)
      dimension cen(2,mxmap), gcmlon(imx)
      character*(*) lab
c
      if (mod(ncen,2).ne.0) then
        write(6,"('>>> checkcen ',a,': projection center must be in ',
     +    'pairs (lat,lon) of center of projection: ncen=',i3)") 
     +  lab,ncen
        stop 'ncen'
      endif
      ncen = ncen/2
      if (ncen.gt.mxmap) then
        write(6,"('>>> checkcen warning ',a,': too many proj=',i3,
     +    ' will default to ',i3)") lab,ncen,mxmap
        ncen = mxmap
      endif
      do i=1,ncen
        if (cen(1,i).lt.-90..or.cen(1,i).gt.90.) then
          write(6,"('>>> checkcen ',a,': bad lat in cen=',f10.2,' i=',
     +      i2)") lab,cen(1,i),i
          stop 'cen'
        endif
        if (cen(2,i).ne.glonflag.and.(cen(2,i).lt.gcmlon(1).or.
     +      cen(2,i).gt.gcmlon(imx))) then
          write(6,"('>>> checkcen ',a,': bad lon in cen=',f10.2,
     +      ' i=',i2)") lab,cen(2,i),i
          stop 'cen'
        endif
      enddo
      return
      end
