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

      subroutine stdout1(nz,z,ntop,nbot,iout,wl,dwl,wt, 1,4
     &           fdird,flxdn,flxup,ff,nphi,nzen,sazm,phi,uzen,uur,
     &           gasabs,trnsgas,tauraytot,tauaertot,taucldtot,kp,npass)
c
c performs these functions (depending on value of iout):
c  iout
c    1   print output at each wavelength (fluxes in w/m2/micron)
c    2   print gaseous absorption quantities
c    3   print radiance output at each user level summed over wavelength
c    5   print radiance output at top at each wavelength
c    6   print radiance output at bot at each wavelength
c   10   compute total inband flux (w/m2) by summing flux over wavelength 
c   11   flux at each level integrated over wavelength
c   20   compute total inband radiance (w/m2/str) at ZOUT(2)
c   21   compute total inband radiance (w/m2/str) at ZOUT(1)
c   22   compute inband radiance (w/m2/str) at each level
c   23   compute inband radiance (w/m2/str) at zout(1) and zout(2)
c        upper hemisphere radiance corresponds to conditions at zout(2)
c        lower hemisphere radiance corresponds to conditions at zout(1)

c
c common block OUT is used to pass information to STDOUT2

      parameter (nstrms=40)
      parameter (nrstrm=50)
      parameter (mxly=50)
      parameter (maxulv=mxly+1)
      parameter (nr=mxly*3)

      dimension fdird(*),flxdn(*),flxup(*),phi(*),uzen(*),z(*)
      dimension uur(nstrms,maxulv,nstrms)

      parameter (nta=9)
      dimension gasabs(nta,*),trnsgas(nta,*)

      common / out / phidw,topdn,topup,topdir,botdn,botup,botdir,
     &               fxup(maxulv),fxdn(maxulv),fxdir(maxulv),
     &               uurs(nrstrm,nrstrm),uurl(nrstrm,nrstrm,maxulv)

c      parameter (nu1=nstrms*nstrms)
c      parameter (nu2=nu1*maxulv)
c      data uurs/nu1*0.0/
c      data uurl/nu2*0.0/
c      data phidw,topdn,topup,topdir,botdn,botup,botdir/7*0./
c      data fxup,fxdn,fxdir/maxulv*0.,maxulv*0.,maxulv*0./

c

 1000 format(1p10e12.4)

      if(iout.eq.1 .or. iout.eq.5 .or. iout.eq.6) then
        if(kp.eq.1) then
          topdn=0.
          topup=0.
          topdir=0.
          botdn=0.
          botup=0.
          botdir=0.
        endif
        topdn  = topdn  + (flxdn(ntop)+fdird(ntop))*wt*ff
        topup  = topup  + flxup(ntop)*wt*ff
        topdir = topdir + fdird(ntop)*wt*ff
        botdn  = botdn  + (flxdn(nbot)+fdird(nbot))*wt*ff
        botup  = botup  + flxup(nbot)*wt*ff
        botdir = botdir + fdird(nbot)*wt*ff

        if(kp.eq.npass) write(*,'(f12.8,f9.5,1p6e12.4)')
     &                   wl,ff,topdn,topup,topdir,botdn,botup,botdir

        if(iout.eq.5 .or. iout.eq.6 ) then
          j=ntop
          if(iout.eq.6) j=nbot

          if(kp.eq.1) call zeroit(uurs,nstrms*nstrms)
          
          do 3 k=1,nphi
            do 2 i=1,nzen
              uurs(i,k)=uurs(i,k)+uur(i,j,k)*wt*ff
 2          continue
 3        continue

          if(kp.eq.npass) then
            write(*,'(3i4)')       nphi,nzen
            write(*,1000) (sazm+phi(j),j=1,nphi)
            write(*,1000) (uzen(j),j=1,nzen)
            do 4 i=nzen,1,-1
              write(*,1000) (uurs(i,k),k=1,nphi)
 4          continue
          endif
        endif
      endif

      if(iout.eq.2) write(*,'(f9.4,1p12e11.3)')
     &     wl,(gasabs(i,1),i=1,9),tauraytot,tauaertot,taucldtot

      dw=dwl*wt*ff

      if((iout.eq.3  .or.
     &    iout.eq.10 .or.
     &    iout.eq.11 .or.
     &    iout.eq.20 .or.
     &    iout.eq.21 .or.
     &    iout.eq.22 .or.
     &    iout.eq.23) .and. kp.eq.npass) phidw=phidw+dwl*ff

      if(iout.eq.3) then
        do j=1,nz
          do i=1,nta
            trnsgas(i,j)=trnsgas(i,j)+dwl*ff*exp(-gasabs(i,j))
          enddo
        enddo
      endif

      if(iout.eq.7 .or. iout.eq.11 .or. iout.eq.22) then
        if(iout.eq.7) then
          dwx=wt*ff
          if(kp.eq.1) then
            call zeroit(fxdn,nz)
            call zeroit(fxup,nz)
            call zeroit(fxdir,nz)
          endif
        else
          dwx=dw
        endif
        do 10 i=1,nz
          fxdn(i)=fxdn(i)+(flxdn(i+1)+fdird(i+1))*dwx
          fxup(i)=fxup(i)+flxup(i+1)*dwx
          fxdir(i)=fxdir(i)+fdird(i+1)*dwx
 10     continue
      endif

      if(iout.eq.7.and.kp.eq.npass) then
        write(*,'(//,f12.8)') wl
        write(*,'(/,1p,(10e11.3))') (        write(*,'(/,1p,(10e11.3))') (fxdir(i),i=1,nz)
        write(*,'(/,1p,(10e11.3))') (fxdn(i)-fxdir(i),i=1,nz)
        write(*,'(/,1p,(10e11.3))') (fxdn(i),i=1,nz)
        write(*,'(/,1p,(10e11.3))') (fxup(i),i=1,nz)
      endif

      if(iout.eq.10.or.iout.eq.20.or.iout.eq.21.or.iout.eq.23) then
        topdn  = topdn  + (flxdn(ntop)+fdird(ntop))*dw
        topup  = topup  + flxup(ntop)*dw
        topdir = topdir + fdird(ntop)*dw
        botdn  = botdn  + (flxdn(nbot)+fdird(nbot))*dw
        botup  = botup  + flxup(nbot)*dw
        botdir = botdir + fdird(nbot)*dw
      endif

      if(iout.eq.20 .or. iout.eq.21) then
        j=ntop
        if(iout.eq.21) j=nbot
        do 30 k=1,nphi
          do 20 i=1,nzen
            uurs(i,k)=uurs(i,k)+uur(i,j,k)*dw
 20       continue
 30     continue
      endif

      if(iout.eq.22) then
        do 60 j=1,nz
          do 50 k=1,nphi
            do 40 i=1,nzen
              uurl(k,i,j)=uurl(k,i,j)+uur(i,j+1,k)*dw
 40         continue
 50       continue
 60     continue
      endif
      
      if(iout.eq.23) then
        do 80 k=1,nphi
          do 70 i=1,nzen
            if(uzen(nzen-i+1).lt.90.) then           
              j=ntop
            else
              j=nbot
            endif
            uurs(i,k)=uurs(i,k)+uur(i,j,k)*dw
 70       continue
 80     continue
      endif

      return
      end