
      subroutine getinp
      include 'mkncdf.h'
      parameter(mxt=3*mxtms,kmxtimes=45)
      character*8 flabs(nftot)
      namelist/input/ histvol,mtimes,iden,ifields,unixdir,mssdir,ionvel,
     +  modelhts
      data histvol/mxvols*'                        '/
      data mtimes /mxt*ispval/
      data iden/1/, ionvel/ispval/, modelhts/0/
      data ifields/nftot*ispval/
      data unixdir
     + /'                                                        '/
      data mssdir 
     + /'                                                        '/
c
c Read input namelist:
c
      read(5,input)
c
c History volumes (nhvols = number of volumes):
c
      nhvols = 0
      do i=1,mxvols
        if (lenstr(histvol(i)).gt.0) nhvols = nhvols+1
      enddo
      if (nhvols.le.0) then
        write(6,"('>>> Need at least one mss history volume (histvol)',
     +    ' <<<')")
        stop 'histvol'
      endif
c
c Model times (ntms = number of model times):
c
      ntms = 0
      do i=1,mxtms
        if (mtimes(1,i).ne.ispval) ntms = ntms+1
      enddo
      if (ntms.le.0) then
        write(6,"('>>> Need at least one model time (mtimes) <<<')")
        stop 'mtimes'
      endif
c
c Density conversion flag:
c
      if (iden.lt.0.or.iden.gt.3) then
        write(6,"('>>> getinp: bad iden=',i3)") iden
        stop 'iden'
      endif
c
c Field flags:
c (ifields(nftot) > 0 -> field desired by original user input)
c
      nf = 0
      do i=1,nftot
        if (ifields(i).ne.ispval) nf = nf+1
      enddo
      if (nf.ne.nftot) then
        write(6,"('>>> Need ',i2,' values for ifields (0 or 1) ',
     +    '(got ',i2,') <<<')") nftot,nf
        stop 'ifields'
      endif
      ifields(ixz) = 1 ! always save heights
      if (modelhts.gt.0) then
        ifields(ixz) = 2 ! flag gettgcm.a to get model hts
        write(6,"('Heights will be returned directly from model ',
     +    'history')")
      else
        write(6,"('Heights will be calculated from tn and mean mass')")
      endif
      do i=1,nfhist
        ifget(i) = ifields(i)
      enddo
c
c Ion drifts flag (ionvel=1 -> ExB drifts, ionvel=2 -> "total" ion drifts,
c i.e., ExB + effect of neutral winds (see mkdrifts.f and mkuivi.f)
c
      if (ifields(ixui).gt.0.or.ifields(ixvi).gt.0.or.
     +    ifields(ixwi).gt.0) then
        if (ionvel.eq.ispval) then
          write(6,"('Did not get value for ionvel -- will default to ',
     +      'ionvel=1 (ExB drifts)')") 
          ionvel = 1
        endif
        ifget(ixpot) = 1
        if (ionvel.eq.2) then
          ifget(ixu) = 1
          ifget(ixv) = 1
          ifget(ixw) = 1
        endif
      else
        ionvel = 0
      endif
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
c
c Report inputs to stdout:
c
      write(6,"(' ')")
      write(6,"('--------------------------------------------------',
     +  '----------------------')")
      write(6,"('MAKE NETCDF INPUTS:')")
      write(6,"(' ')")
      write(6,"('nhvols =',i3,' histvol=',$)") nhvols
      do iv=1,nhvols
        write(6,"(a)") histvol(iv)(1:lenstr(histvol(iv))) 
      enddo
      write(6,"('ntms =',i3,' mtimes = ',$)") ntms
      write(6,"(6(2x,i2,':',i2,':',i2))") 
     +  ((mtimes(ii,i),ii=1,3),i=1,ntms)
      if (iden.eq.0) write(6,"('iden =',i2,' (leave species as on ',
     +  'history)')") iden
      if (iden.eq.1) write(6,"('iden =',i2,' (convert appropriate ',
     +  'species to number densities (cm3))')") iden
      if (iden.eq.2) write(6,"('iden =',i2,' (convert appropriate ',
     +  'species to number density mixing ratios)')") iden
      if (iden.eq.3) write(6,"('iden =',i2,' (convert appropriate ',
     +  'species to mass density (gm/cm3))')") iden
      if (modelhts.gt.0) then
        write(6,"('modelhts=',i2,
     +    ' (heights are obtained from the history)')") modelhts
      else
        write(6,"('modelhts=',i2,
     +    ' (heights are calculated from tn and mean mass)')") modelhts
      endif
      nf = 0
      do ip=1,nftot
        if (ifields(ip).gt.0) then
          nf = nf+1
          flabs(nf) = flab(ip)
        endif
      enddo 
      write(6,"('nflds=',i2,' requested fields = ')") nf
      write(6,"(8a8)") (flabs(ip),ip=1,nf)
      if (ifields(ixui).gt.0.or.ifields(ixvi).gt.0.or.
     +    ifields(ixwi).gt.0)
     +  write(6,"('ionvel = ',i2)") ionvel
      if (lenstr(unixdir).gt.0) write(6,"('unixdir=',a)") 
     +  unixdir(1:lenstr(unixdir))
      if (lenstr(mssdir).gt.0) write(6,"('mssdir=',a)") 
     +  mssdir(1:lenstr(mssdir))
      write(6,"('--------------------------------------------------',
     +  '----------------------')")
      write(6,"(' ')")
c
      return
      end
