c===============================================================


      subroutine chkin(isat,nf,wlinf,wlsup,solfac,isalb,albcon, 1,27
     &     sc,idatm,zpres,pbar,zcloud,tcloud,nre,jaer,zaer,
     &     taerst,iaer,zout,iout,prnt,lwp,nphi,nzen)


c PURPOSE     check input for invalid values.
c             if input is bad, issue error messages and stop
c
c input:  all arguments
c output: none
c
      parameter (nstrms=40)
      parameter (ncldz=5,naerz=5)
      real zcloud(ncldz),tcloud(ncldz)
      real lwp(ncldz),nre(ncldz)
      dimension zaer(naerz),taerst(naerz),jaer(naerz),sc(4),zout(2)
      logical prnt(7)
c
      kill=0

      call ckint('idatm',idatm,1,-6,6,kill)
      call ckreal('wlinf',wlinf,1,.20,100.,kill)
      if(isat.le.-2) then
        call ckreal('wlsup',wlsup,1,0.,wlinf,kill)
      else
        call ckreal('wlsup',wlsup,1,wlinf,100.,kill)
      endif
c      if(wlsup.ne.wlinf)
c     &     call ckreal('wlinc',wlinc,1,-wlsup/wlinf,wlsup-wlinf,kill)
      call ckint('isat',isat,1,-4,25,kill)
      call ckreal('solfac',solfac,1,0.,1.e30,kill)
      call ckreal('zcloud',zcloud,ncldz,-100.,100.,kill)
      call ckreal('nre',nre,ncldz,-1.e30,1.e30,kill)
      call ckreal('lwp',lwp,ncldz,0.,1.e30,kill)
      call ckreal('zaer',zaer,naerz,0.,100.,kill)
      call ckreal('taerst',taerst,naerz,0.,1.e30,kill)

      call ckint('jaer',jaer,naerz,0,4,kill)
      call ckint('nf',nf,1,-1,3,kill)
      call ckint('iaer',iaer,1,0,5,kill)
      call ckint('isalb',isalb,-1,-999999,-2,kill)
      call ckreal('albcon',albcon,1,0.,1.e30,kill)
      call ckreal('sc',sc,4,0.,1.e30,kill)
      call ckreal('zout',zout,2,0.,100.,kill)

      call ckint('isalb',isalb,-1,7,9,kill)
      call ckint('isalb',isalb,-1,11,999999,kill)
      call ckint('iout',iout,-1,-999999,-1,kill)
      call ckint('iout',iout,-1,8,9,kill)
      call ckint('iout',iout,-1,12,19,kill)
      call ckint('iout',iout,-1,24,999999,kill)
      call ckint('nphi',nphi,1,0,nstrms,kill)

      if((prnt(5).or.
     &   iout.eq.20.or.
     &   iout.eq.21.or.
     &   iout.eq.22.or.
     &   iout.eq.23).and.nzen.eq.0) then
        write(*,'(x,a,i2,a,a)') 'iout =',iout,
     &       ' implies radiance calculation, ',
     &       'but nzen=0 produces no radiance output'
        kill=1
      endif

      if(zpres.gt.0.and.pbar.gt.0.) then
        write(*,'(x,a)') 'set zpres or pbar but not both'
        write(*,*) 'zpres,pbar ',zpres,pbar
        kill=1
      endif
      if((numset(0.,tcloud,ncldz).ne.0).and.
     &   (numset(0.,lwp,ncldz).ne.0)) then
        write (*,*) 'set TCLOUD or LWP, but not both'
        kill=1
      endif

      if(kill.eq.1) stop
      return
      end