c    @(#)surflux.f	1.2
c
c
      subroutine surflux
c
c
c
c leonard walstad
c mod 2/26/90
c
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
                
      common /extpar/ rlat0, rlng0, t0, v0, dhor, ht, time0,
     +                r0,f0star

      common/sbldef/qsw0,qsurf0,wflux0,u10m,angu10m,hdpth0

      data rhoair/0.00123/
c
c-----------------------------------------------------------------------
c
c
      if (iftvf .gt. 0) call rdflux
c
c --- heat is the net surface heating due to long wave solar radiation,
c     back radiation sensible and latent heat flux in cal/cm/cm/s.
c
c --- sun is the short wave (penetrating) solar radiation.
c
c
c --- u10m is the ten meter wind velocity in m/s.
c

c
c --- now convert these quantities to the form needed for the model.
c
      degtorad=3.1415927/180.
      cosang=cos(degtorad*angu10m)
      sinang=sin(degtorad*angu10m)

      if (momflx .eq. 1) then
         wind1 = (u10m*.00125)**2.
        else if (momflx .eq. 2) then
         cd = .00122
         wind1 = rhoair * cd * u10m**2
        else if (momflx .eq. 3) then
         if (u10m .lt. 11.) then
            cd = 1.205e-3
           else
            cd = (.49 + 0.065 * u10m) * 1.e-3
          endif
         wind1 = rhoair * cd * u10m**2
        else
         write(*,*)'Invalid choice of momentum flux parameterization'
         stop
       endif

      xwind = wind1 * cosang
      ywind= wind1 *sinang
      twopi=2.0 * acos(-1.0)
      do 100 ip=1,msq
        wflux(ip)= wflux0
        qsw(ip)  = qsw0
        qsurf(ip)= qsurf0
        taux(ip)=xwind
        tauy(ip)=ywind
  100 continue

      end
