!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
*** S/P MOMCOEF
*
#include "phy_macros_f.h"

      SUBROUTINE MOMCOEF (RI,Z0TOT,Z0H,ZREF,CD,N),4
*
*
#include "impnone.cdk"
*
      INTEGER N
      REAL RI(N), Z0TOT(N), Z0H(N), ZREF(N), CD(N)
*
*Author
*          S. Belair (April 1998)
*Revisions
* 001      B. Bilodeau (January 2001) - Automatic arrays
*
*Object
*
*     Calculates the surface transfer coefficient for
*     momentum.
*
*
*Arguments
*
*          - Input -
* RI        Richardson's number
* Z0TOT     roughness length including the effect of snow
* Z0H       roughness length for heat
* ZREF      reference height
*
*
*           - Output -
* CD        drag coefficient for momentum
*
**
*
#include "consphy.cdk"
*
*
      INTEGER I
*
*
************************************************************************
*     AUTOMATIC ARRAYS
************************************************************************
*
      AUTOMATIC ( MU     , REAL , (N) )
      AUTOMATIC ( CDN    , REAL , (N) )
      AUTOMATIC ( CMSTAR , REAL , (N) )
      AUTOMATIC ( PM     , REAL , (N) )
      AUTOMATIC ( CM     , REAL , (N) )
      AUTOMATIC ( FM     , REAL , (N) )
*
************************************************************************
*
*
*
*------------------------------------------------------------------------
*
*
*
* 
*         1.     DRAG COEFFICIENT FOR MOMENTUM TRANSFERS
*                ---------------------------------------
*
*                           In this particular case, we now use
*                           the roughness length due to the coupled
*                           effect of vegetation and snow
*                           (i.e., Z0TOT)
*
*                           Thus, we must first recalculate ZMU,
*                           ZZ0T, and ZCDN
*
*
      DO I=1,N
        MU(I) = MAX( LOG( Z0TOT(I)/Z0H(I) ), 0.0 )
*
*
        CDN(I) = (KARMAN/LOG(1.+ZREF(I)/Z0TOT(I)))**2.
*
        CMSTAR(I) = 6.8741 + 2.6933*MU(I) - 0.3601*MU(I)*MU(I)
     1            + 0.0154*MU(I)*MU(I)*MU(I)
        PM(I)     = 0.5233 - 0.0815*MU(I) + 0.0135*MU(I)*MU(I)
     1            - 0.0010*MU(I)*MU(I)*MU(I)
*
        CM(I) = 10.*CMSTAR(I)*CDN(I)*(1.+ZREF(I)/Z0TOT(I))**PM(I)
      END DO
*
*
      DO I=1,N
        IF (RI(I).GT.0.0) THEN
          FM(I) = 1. + 10.*RI(I) / SQRT( 1.+5.*RI(I) )
          FM(I) = 1. / FM(I)
        ELSE
          FM(I) = 1. - 10.*RI(I) / ( 1.+CM(I)*SQRT(-RI(I)) )
        END IF
*
        CD(I) = CDN(I)*FM(I)
      END DO
*
*
      RETURN
      END