c    @(#)setup.f	1.3
c
c
      subroutine setup
c
c_______________________________________________________________________
c
      include'mladv.inc'
c
c_______________________________________________________________________
c
c
      common/parm/kz,m,mm1,mm2,mp1,msq,tim,tmax,tstart,hy,rea,dt,
     +   xbasin,yy(mx0),icalc,kzp1,kzm1,iftop,ifbot,iftvv,ifrel,theta,
     +   ifsbl,ifeva

c
c
      common /vert/ rho0,tsurf,xc(k01),salsur,eta(k01)
c
      common /threed/hz(k0),scisg,sigz(k01),eigval(k0),ainv(k0,k0),
     .               amat(k0,k0)
c
      common /extpar/ rlat0,rlng0,t0,v0,dhor,ht,time0,r0,f0star
c
      common /cnn/n,nm1,nm2,np1
c
      common /unit/iin,iout,idff,idif,iorr,iowr,iplt,ifndd

c
c
c
c---------------------------------------------------------------------
c
c -- set qg related parameters and check parameter ranges
c
      if(m*n.gt.mnmax)stop 'setup1'
c
c --- time step is same as qgmodel; convert to seconds.
c
      qgts=t0*dt
      dxyml=hy*dhor
c
c
c --- now set up the constants needed for boundary conditions
c
      mbnd=m+m+n+n-4
      if(mbnd.gt.maxbnd)stop 'setup3'
      do 20 ibnd=1,mbnd
        ip=ibnd
        if(ibnd.gt.m)ip=(ibnd-m+1)*m
        if(ibnd.ge.m+n-1)ip=msq-(ibnd-(m+n-1))
        if(ibnd.gt.m+n-1+m-1)ip=(mbnd-ibnd)*m+m+1
        ipofb(ibnd)=ip
   20 continue

c
c --- read sbl parameters
c
      call readsbl
c
c --- set max depth array
c
      do 15 ip=1,msq
        hmax(ip)=maxh
   15 continue
c
c --- compute the surface buoyancy
c
      sva=svan(salsur,tsurf,0.,denanom)
      buoysur=9.8*(rho0-(1.+denanom/1000.))/rho0
      sursigt = denanom
      write(iout,*)'sursigt = ',sursigt
c
c --- describe tracers....
c
      if(ntrace .gt.0) then
         write(iout,'('' Tracers: '',i1)')ntrace
      else
         write(iout,'(" there are no tracers ")')
      endif

c
c
c --- describe the field output
c
c
      if (nout.gt.0) then
        write(iout,'(//,''  mixed layer field output'',//,
     .                  ''  type  depth  interval'')'           )
        write(iout,'(3x,i2,3x,f5.2,3x,f6.3)')
     .               (nint(dout(1,ii)),dout(2,ii),dout(3,ii),ii=1,nout)
      else
        write(iout,'(//''  no mixed layer field output'')')
      endif
c

c
      end
