C=======================================================================

      subroutine atms(iatm,amix,nz,z,p,t,wh,wo) 1,8
c
c     input: 
c       iatm         atmospheric model index
c       amix         mixing fraction of user specified atmosphere
c       nz           number of layers
c     output:
c       z            layer altitude
c       p            pressure
c       t            temperature
c       wh           water vapor
c       wo           ozone
c
      parameter (mxly=50)
      dimension zz(mxly),pp(mxly),tt(mxly),hh(mxly),oo(mxly)
      dimension z(*),p(*),t(*),wh(*),wo(*)

      ia=abs(iatm)

      if(ia.eq.0) call useratm(nz,z,p,t,wh,wo)
      if(ia.eq.1) call tropic(nz,z,p,t,wh,wo)
      if(ia.eq.2) call midsum(nz,z,p,t,wh,wo)
      if(ia.eq.3) call midwin(nz,z,p,t,wh,wo)
      if(ia.eq.4) call subsum(nz,z,p,t,wh,wo)
      if(ia.eq.5) call subwin(nz,z,p,t,wh,wo)
      if(ia.eq.6) call us62(nz,z,p,t,wh,wo)

      if(iatm .lt. 0) then
        call useratm(nz,zz,pp,tt,hh,oo)
        ierr=0
        do 10 i=1,nz
          if(abs(zz(i)-z(i)).gt.0.01) ierr=1
          p(i)=p(i)*(1.-amix)+pp(i)*amix
          t(i)=t(i)*(1.-amix)+tt(i)*amix
          wh(i)=wh(i)*(1.-amix)+hh(i)*amix
          wo(i)=wo(i)*(1.-amix)+oo(i)*amix
          write(17,'(1p5e14.3)') z(i),p(i),t(i),wh(i),wo(i)
 10     continue
        if(ierr.eq.1) stop 'atms -- vertical grids do not match'
      endif

      return
      end