*IF DEF,A03_7A,OR,DEF,A03_6A                                               ACB1F405.4      
C *****************************COPYRIGHT******************************     EXFXUV5B.3      
C (c) CROWN COPYRIGHT 1997, METEOROLOGICAL OFFICE, All Rights Reserved.    EXFXUV5B.4      
C                                                                          EXFXUV5B.5      
C Use, duplication or disclosure of this code is subject to the            EXFXUV5B.6      
C restrictions as set forth in the contract.                               EXFXUV5B.7      
C                                                                          EXFXUV5B.8      
C                Meteorological Office                                     EXFXUV5B.9      
C                London Road                                               EXFXUV5B.10     
C                BRACKNELL                                                 EXFXUV5B.11     
C                Berkshire UK                                              EXFXUV5B.12     
C                RG12 2SZ                                                  EXFXUV5B.13     
C                                                                          EXFXUV5B.14     
C If no contract has been raised with this copy of the code, the use,      EXFXUV5B.15     
C duplication or disclosure of it is strictly prohibited.  Permission      EXFXUV5B.16     
C to do so must first be obtained in writing from the Head of Numerical    EXFXUV5B.17     
C Modelling at the above address.                                          EXFXUV5B.18     
C ******************************COPYRIGHT******************************    EXFXUV5B.19     
!!!  Purpose: Calculate explicit flux of momentum in u or v direction      EXFXUV5B.20     
!!!                                                                        EXFXUV5B.21     
!!!                                                                        EXFXUV5B.23     
!!!  Model           Modification history                                  EXFXUV5B.24     
!!! version  Date                                                          EXFXUV5B.25     
!!!  4.3    23/2/97   New deck                                             EXFXUV5B.26     
!!!  4.5    Jul. 98  Replace IBM with SCMA  (JCThil)                       AJC1F405.307    
!!!                                                                        EXFXUV5B.27     
!!!  JJ, SDJ <- Programmers of some or all of previous code or changes     EXFXUV5B.28     
!!!                                                                        EXFXUV5B.29     
!!!                                                                        EXFXUV5B.30     
!!!  Programming standard: UMDP3                                           EXFXUV5B.31     
!!!                                                                        EXFXUV5B.32     
!!!  System component covered: P244                                        EXFXUV5B.33     
!!!                                                                        EXFXUV5B.34     
!!!  Project task: P24                                                     EXFXUV5B.35     
!!!                                                                        EXFXUV5B.36     
!!!  Documentation: UM Documentation Paper No 24.                          EXFXUV5B.37     
!!!                                                                        EXFXUV5B.38     
!!!---------------------------------------------------------------------   EXFXUV5B.39     
                                                                           EXFXUV5B.40     
! SUBROUTINE EX_FLUX_UV                                                    EXFXUV5B.41     
                                                                           EXFXUV5B.42     

      SUBROUTINE EX_FLUX_UV (                                               4,2EXFXUV5B.43     
     &  U_V_POINTS                                                         EXFXUV5B.44     
     &, U_V_FIELD                                                          EXFXUV5B.45     
     &, ROW_LENGTH                                                         EXFXUV5B.46     
     &, BL_LEVELS                                                          EXFXUV5B.47     
     &, U1_V1                                                              EXFXUV5B.48     
     &, U_V, U_0_V_0                                                       EXFXUV5B.49     
     &, RDZ_U_V                                                            EXFXUV5B.50     
     &, RHOKM_U_V                                                          EXFXUV5B.51     
     &, TAU_X_Y                                                            EXFXUV5B.52     
     &, LTIMER                                                             EXFXUV5B.53     
     &  )                                                                  EXFXUV5B.54     
                                                                           EXFXUV5B.55     
      IMPLICIT NONE                                                        EXFXUV5B.56     
                                                                           EXFXUV5B.57     
! ARGUMENTS WITH INTENT IN. IE: INPUT VARIABLES.                           EXFXUV5B.58     
                                                                           EXFXUV5B.59     
      LOGICAL                                                              EXFXUV5B.60     
     &  LTIMER                 ! IN Flag for TIMER diagnostics             EXFXUV5B.61     
                                                                           EXFXUV5B.62     
      INTEGER                                                              EXFXUV5B.63     
     &  U_V_POINTS             ! IN Number of U_V-grid points.             EXFXUV5B.64     
     &, U_V_FIELD              ! IN No. of points in U_V-grid.             EXFXUV5B.68     
     &, ROW_LENGTH             ! IN No. of points in latitude row.         EXFXUV5B.69     
     &, BL_LEVELS              ! IN No. of atmospheric levels for          EXFXUV5B.70     
!                                  which boundary layer fluxes are         EXFXUV5B.71     
!                                  calculated.                             EXFXUV5B.72     
                                                                           EXFXUV5B.73     
     &, U1_V1                  ! IN First point to be processed in         EXFXUV5B.74     
!                                  U_V-grid.                               EXFXUV5B.75     
                                                                           EXFXUV5B.76     
                                                                           EXFXUV5B.77     
      REAL                                                                 EXFXUV5B.78     
     &  RDZ_U_V (U_V_FIELD, 2:BL_LEVELS)                                   EXFXUV5B.79     
!                                IN Reciprocal of the vertical             EXFXUV5B.80     
!                                   distance from level K-1 to             EXFXUV5B.81     
!                                   level K. (K > 1) on wind levels        EXFXUV5B.82     
     &, RHOKM_U_V (U_V_FIELD, BL_LEVELS)                                   EXFXUV5B.83     
!                                IN Exchange coefficients for              EXFXUV5B.84     
!                                   momentum, on UV-grid with              EXFXUV5B.85     
!                                   first and last rows ignored.           EXFXUV5B.86     
!                                   for K>=2 (from KMKH).                  EXFXUV5B.87     
     &, U_V (U_V_FIELD, BL_LEVELS)                                         EXFXUV5B.88     
!                                IN Westerly_Southerly component of        EXFXUV5B.89     
!                                   wind.                                  EXFXUV5B.90     
                                                                           EXFXUV5B.91     
     &, U_0_V_0 (U_V_FIELD)    ! IN Westerly_Southerly component of        EXFXUV5B.92     
!                                   surface current                        EXFXUV5B.93     
!                                   (m/s; 0 over land) UVG.                EXFXUV5B.94     
                                                                           EXFXUV5B.95     
                                                                           EXFXUV5B.96     
! ARGUMENTS WITH INTENT OUT. IE: INPUT VARIABLES CHANGED ON OUTPUT.        EXFXUV5B.97     
                                                                           EXFXUV5B.98     
      REAL                                                                 EXFXUV5B.99     
     &  TAU_X_Y (U_V_FIELD, BL_LEVELS)                                     EXFXUV5B.100    
!                                OUT explicit x_y-component of             EXFXUV5B.101    
!                                    turbulent stress at levels            EXFXUV5B.102    
!                                    k-1/2; eg. TAUX(,1) is surface        EXFXUV5B.103    
!                                    stress. UV-grid, 1st and last rows    EXFXUV5B.104    
!                                    set to "missing data". (N/sq m)       EXFXUV5B.105    
                                                                           EXFXUV5B.106    
! LOCAL VARIABLES.                                                         EXFXUV5B.107    
                                                                           EXFXUV5B.108    
      INTEGER                                                              EXFXUV5B.109    
     &  I                                                                  EXFXUV5B.110    
     &, J                                                                  EXFXUV5B.111    
     &, K                                                                  EXFXUV5B.112    
     &, ERROR                                                              EXFXUV5B.113    
                                                                           EXFXUV5B.114    
! External routines                                                        EXFXUV5B.115    
      EXTERNAL TIMER                                                       EXFXUV5B.116    
                                                                           EXFXUV5B.117    
                                                                           EXFXUV5B.118    
      IF (LTIMER) THEN                                                     EXFXUV5B.119    
        CALL TIMER('EXFLUXUV',3)                                           EXFXUV5B.120    
      ENDIF                                                                EXFXUV5B.121    
                                                                           EXFXUV5B.122    
!-----------------------------------------------------------------------   EXFXUV5B.123    
!!  0.  Check that the scalars input to define the grid are consistent.    EXFXUV5B.124    
!-----------------------------------------------------------------------   EXFXUV5B.125    
                                                                           EXFXUV5B.126    
      ERROR = 0                                                            EXFXUV5B.127    
                                                                           EXFXUV5B.134    
!-----------------------------------------------------------------------   EXFXUV5B.135    
!!  1.  Calculate "explicit" surface fluxes of momentum                    EXFXUV5B.136    
!-----------------------------------------------------------------------   EXFXUV5B.137    
                                                                           EXFXUV5B.138    
! Level 1. Formerly calculated at end of SFEXCH                            EXFXUV5B.139    
                                                                           EXFXUV5B.140    
*IF -DEF,SCMA                                                              AJC1F405.308    
        DO I=U1_V1+ROW_LENGTH,U1_V1+U_V_POINTS-ROW_LENGTH-1                EXFXUV5B.142    
*ELSE                                                                      EXFXUV5B.143    
        DO I=1,U_V_POINTS                                                  EXFXUV5B.144    
*ENDIF                                                                     EXFXUV5B.145    
                                                                           EXFXUV5B.146    
           TAU_X_Y(I,1) = RHOKM_U_V(I,1) * ( U_V(I,1) - U_0_V_0(I) )       EXFXUV5B.147    
                                                                           EXFXUV5B.148    
        ENDDO                                                              EXFXUV5B.149    
                                                                           EXFXUV5B.150    
! Other Levels. Formerly calculated at end of KMKH                         EXFXUV5B.151    
      DO K = 2,BL_LEVELS                                                   EXFXUV5B.152    
*IF -DEF,SCMA                                                              AJC1F405.309    
        DO I=U1_V1+ROW_LENGTH,U1_V1+U_V_POINTS-ROW_LENGTH-1                EXFXUV5B.154    
*ELSE                                                                      EXFXUV5B.155    
        DO I=1,U_V_POINTS                                                  EXFXUV5B.156    
*ENDIF                                                                     EXFXUV5B.157    
          TAU_X_Y(I,K) = RHOKM_U_V(I,K) * ( U_V(I,K) - U_V(I,K-1) )        EXFXUV5B.158    
     &    *RDZ_U_V(I,K)                                                    EXFXUV5B.159    
                                                                           EXFXUV5B.160    
        END DO                                                             EXFXUV5B.161    
      END DO                                                               EXFXUV5B.162    
                                                                           EXFXUV5B.163    
    6 CONTINUE ! exit error point                                          EXFXUV5B.164    
                                                                           EXFXUV5B.165    
      IF (LTIMER) THEN                                                     EXFXUV5B.166    
        CALL TIMER('EXFLUXUV',4)                                           EXFXUV5B.167    
      ENDIF                                                                EXFXUV5B.168    
      RETURN                                                               EXFXUV5B.169    
                                                                           EXFXUV5B.170    
      END                                                                  EXFXUV5B.171    
*ENDIF                                                                     EXFXUV5B.172