FUNCTION USTAR_2D(PWIND,PZ,PZ0,PLMO)
USE MODD_CSTS
USE MODD_SURF_PAR, ONLY : XUNDEF
IMPLICIT NONE
REAL, DIMENSION(:,:), INTENT(IN) :: PWIND
REAL, DIMENSION(:,:), INTENT(IN) :: PZ
REAL, DIMENSION(:,:), INTENT(IN) :: PZ0
REAL, DIMENSION(:,:), INTENT(IN) :: PLMO
REAL, DIMENSION(SIZE(PZ,1),SIZE(PZ,2)) :: USTAR_2D
REAL, DIMENSION(SIZE(PZ,1),SIZE(PZ,2)) :: ZZ_O_LMO
REAL, DIMENSION(SIZE(PZ,1),SIZE(PZ,2)) :: ZZ0_O_LMO
REAL(KIND=JPRB) :: ZHOOK_HANDLE
!
!* purely unstable case
IF (LHOOK) CALL DR_HOOK('MODE_SBLS:USTAR_2D',0,ZHOOK_HANDLE)
USTAR_2D (:,:) = 0.
ZZ_O_LMO (:,:) = XUNDEF
ZZ0_O_LMO(:,:) = XUNDEF
!
!* general case
WHERE(ABS(PLMO) > 1.E-20 .AND. PLMO/=XUNDEF)
ZZ_O_LMO = PZ(:,:) / PLMO(:,:)
ZZ0_O_LMO = PZ0(:,:) / PLMO(:,:)
USTAR_2D(:,:) = PWIND(:,:) &
* XKARMAN / ( LOG(PZ(:,:)/PZ0(:,:)) &
- PAULSON_PSIM(ZZ_O_LMO(:,:)) &
+ PAULSON_PSIM(ZZ0_O_LMO(:,:)) )
END WHERE
!
!* purely neutral case
WHERE(PLMO==XUNDEF)
ZZ_O_LMO = 0.
USTAR_2D(:,:) = PWIND(:,:) &
* XKARMAN / LOG(PZ(:,:)/PZ0(:,:))
END WHERE
IF (LHOOK) CALL DR_HOOK('MODE_SBLS:USTAR_2D',1,ZHOOK_HANDLE)
!
END FUNCTION USTAR_2D