*IF DEF,OCEAN                                                              @DYALLOC.4654   
C ******************************COPYRIGHT******************************    GTS2F400.5959   
C (c) CROWN COPYRIGHT 1995, METEOROLOGICAL OFFICE, All Rights Reserved.    GTS2F400.5960   
C                                                                          GTS2F400.5961   
C Use, duplication or disclosure of this code is subject to the            GTS2F400.5962   
C restrictions as set forth in the contract.                               GTS2F400.5963   
C                                                                          GTS2F400.5964   
C                Meteorological Office                                     GTS2F400.5965   
C                London Road                                               GTS2F400.5966   
C                BRACKNELL                                                 GTS2F400.5967   
C                Berkshire UK                                              GTS2F400.5968   
C                RG12 2SZ                                                  GTS2F400.5969   
C                                                                          GTS2F400.5970   
C If no contract has been raised with this copy of the code, the use,      GTS2F400.5971   
C duplication or disclosure of it is strictly prohibited.  Permission      GTS2F400.5972   
C to do so must first be obtained in writing from the Head of Numerical    GTS2F400.5973   
C Modelling at the above address.                                          GTS2F400.5974   
C ******************************COPYRIGHT******************************    GTS2F400.5975   
C                                                                          GTS2F400.5976   
C*LL                                                                       MIXSET.3      
CLL   Subroutine MIXSET.                                                   MIXSET.4      
CLL   Can run on any compiler accepting long lower case variables.         MIXSET.5      
CLL                                                                        MIXSET.6      
CLL   The code must be pre-compiled by the UPDOC system.                   MIXSET.7      
CLL   Option X selects the mixed layer code.                               MIXSET.8      
CLL   Option A indicates that the Unified Model version is to be used,     MIXSET.9      
CLL   otherwise the default is for the COX standard code.                  MIXSET.10     
CLL                                                                        MIXSET.11     
CLL   Author: S J Foreman                                                  MIXSET.12     
CLL   Date 31 January 1990                                                 MIXSET.13     
CLL   Reviewer: xxxxxxxxxxx                                                MIXSET.14     
CLL   Review date: xxxxxxxxxxxx                                            MIXSET.15     
CLL   Version 2.01 date 08 October 1990                                    MIXSET.16     
CLL                                                                        MIXSET.17     
CLL   Programming standards use Cox naming convention for Cox variables    MIXSET.18     
CLL      with the addition that lower case variables are local to the      MIXSET.19     
CLL      routine.                                                          MIXSET.20     
CLL      Otherwise follows UM doc paper 4 version 1.                       MIXSET.21     
CLL                                                                        MIXSET.22     
CLL   This forms part of UM brick P4.                                      MIXSET.23     
CLL                                                                        MIXSET.24     
CLL   THIS ROUTINE DEFINES CONSTANTS USED BY OCEAN MIXED LAYER SCHEME      MIXSET.25     
CLL                                                                        MIXSET.26     
CLL   External documentation:                                              MIXSET.27     
CLL      scientific Heathershaw and Martin, ARE TM (UJO) 87129             MIXSET.28     
CLL      programming: Brick P4, paper 1, version number 1.                 MIXSET.29     
CLL                                                                        MIXSET.30     
CLL   Subroutine dependencies.  The following subroutine must be           MIXSET.31     
CLL   called before MIXSET to initialise the necessary variables:          MIXSET.32     
CLL                                                                        MIXSET.33     
CLL      SOLSET: routine to set solar penetration depth                    MIXSET.34     
CLL                                                                        MIXSET.35     
CLLEND------------------------------------------------------------------   MIXSET.36     
C*                                                                         MIXSET.37     
C*L   -------------Arguments--------------------------------------------   MIXSET.38     
C                                                                          MIXSET.39     

      SUBROUTINE MIXSET (DELPSF, DELPSL, DECAY,                             2MIXSET.40     
     +                  GRAV_SI, DZ, ZDZ, ZDZZ, RZ,                        MIXSET.41     
     +                  KM,                                                MIXSET.42     
     +                  KFIX, RSOL, ETA1_SI, ETA2_SI, DELTA_SI             MIXSET.43     
     +                  )                                                  MIXSET.44     
C                                                                          MIXSET.45     
      IMPLICIT NONE                                                        MIXSET.46     
C                                                                          MIXSET.47     
      INTEGER                                                              MIXSET.48     
     +   KM       ! IN  Number of points in vertical                       MIXSET.49     
C                                                                          MIXSET.50     
      INTEGER                                                              MIXSET.51     
     +   KFIX     ! IN  Number of levels with solar heating                MIXSET.52     
C                                                                          MIXSET.53     
C     Physical arguments                                                   MIXSET.54     
C                                                                          MIXSET.55     
      REAL                                                                 MIXSET.56     
     +   GRAV_SI        ! IN  Acceleration due to gravity (m/s2)           MIXSET.57     
     +,  DZ (KM)        ! IN  Layer thicknesses                            MIXSET.58     
     +,  ZDZ (KM)       ! IN  Layer bottoms                                MIXSET.59     
     +,  ZDZZ (KM)      ! IN  Layer centres *NB* Dim is KMP1 in /ONEDIM/   MIXSET.60     
     +,  RZ (KM)        ! IN  Layer thickness scaled by 1/timestep ratio   MIXSET.61     
C                             Note that if varaible timestep with depth    MIXSET.62     
C                             not included, then this is specified as      MIXSET.63     
C                             DZ in the call.                              MIXSET.64     
     +,  RSOL           ! IN  Ratio of solar components                    MIXSET.65     
     +,  ETA1_SI        ! IN  Decay scale of one solar component (1/m)     MIXSET.66     
     +,  ETA2_SI        ! IN  Decay scale of other solar component (1/m)   MIXSET.67     
     +,  DELTA_SI       ! IN  Vertical decay length for WME (m)            MIXSET.68     
     +,  DECAY (KM)     ! OUT Decay scale for WME (dimensionless)          MIXSET.69     
     +,  DELPSF         ! OUT 'Energy change' due to non-solar (cm3/s2)    MIXSET.70     
     +,  DELPSL (0:KM)  ! OUT 'Energy change' from solar (cm3/s2)          MIXSET.71     
C*                                                                         MIXSET.72     
C*L  --------------- Externals -----------------------------------------   MIXSET.73     
C                                                                          MIXSET.74     
      INTRINSIC                                                            MIXSET.75     
     +   EXP            !  Exponential function                            MIXSET.76     
C*                                                                         MIXSET.77     
C                                                                          MIXSET.78     
CL    Define working variables                                             MIXSET.79     
C                                                                          MIXSET.80     
      INTEGER                                                              MIXSET.81     
     +   k           !  Vertical index                                     MIXSET.82     
C                                                                          MIXSET.83     
      REAL                                                                 MIXSET.84     
     +   pe             !  PE change this layer                            MIXSET.85     
     +,  rdeta1         !  RSOL/eta1                                       MIXSET.86     
     +,  rdeta2         !  (1-RSOL)/eta2                                   MIXSET.87     
     +,  solup          !  Solar flux at top of layer                      MIXSET.88     
     +,  soldown        !  Solar flux at base of layer                     MIXSET.89     
     +,  total          !  Full solar contribution                         MIXSET.90     
     +,  exp1           !  Value of first exponential                      MIXSET.91     
     +,  exp2           !  Value of second exponential                     MIXSET.92     
     +,  sclfct         !  Scaling factor                                  MIXSET.93     
     +,  penup          !  temporary store of solar heating                MIXSET.94     
     +,  grav           !  CGS version of GRAV_SI                          MIXSET.95     
     +,  eta1           !  CGS version of ETA1_SI                          MIXSET.96     
     +,  eta2           !  CGS version of ETA2_SI                          MIXSET.97     
C                                                                          MIXSET.98     
C           Create cgs versions of constants                               MIXSET.99     
C                                                                          MIXSET.100    
      grav=GRAV_SI*100.                                                    MIXSET.101    
      eta1=ETA1_SI*0.01                                                    MIXSET.102    
      eta2=ETA2_SI*0.01                                                    MIXSET.103    
C                                                                          MIXSET.104    
CL    1.0   Surface component of heating                                   MIXSET.105    
C                                                                          MIXSET.106    
      DELPSF = -0.5*grav*DZ(1)*DZ(1)                                       MIXSET.107    
C                                                                          MIXSET.108    
CL    2.0   Solar component                                                MIXSET.109    
C                                                                          MIXSET.110    
CL    2.1   Initial values                                                 MIXSET.111    
C                                                                          MIXSET.112    
      DELPSL(0) = 0.0                                                      MIXSET.113    
      pe = 0.0                                                             MIXSET.114    
      penup=0.0                                                            MIXSET.115    
      sclfct = - grav * DZ(1)/(1.0 - RSOL*EXP(-eta1*DZ(1))                 MIXSET.116    
     +                        - (1.0-RSOL)*EXP(-eta2*DZ(1)))               MIXSET.117    
      rdeta1 = RSOL / eta1                                                 MIXSET.118    
      rdeta2 = (1.0 - RSOL) / eta2                                         MIXSET.119    
      solup = 1.0                                                          MIXSET.120    
C                                                                          MIXSET.121    
CL    2.2   Values where heating penetrates                                MIXSET.122    
C                                                                          MIXSET.123    
      DO 2200, k = 1, KFIX                                                 MIXSET.124    
         exp1 = EXP (-eta1*ZDZ(k) )                                        MIXSET.125    
         exp2 = EXP (-eta2*ZDZ(k) )                                        MIXSET.126    
         total = zdz(k) * (RSOL*exp1 + (1.0-RSOL)*exp2) -                  MIXSET.127    
     -            rdeta1*(1.0-exp1) - rdeta2*(1.0-exp2)                    MIXSET.128    
         soldown = RSOL*exp1 + (1.0-RSOL)*exp2                             MIXSET.129    
         penup = penup - (soldown - solup) * ZDZZ(k)*(DZ(k)/RZ(k))         MIXSET.130    
         DELPSL (k) = (penup + total)*sclfct                               MIXSET.131    
         solup = soldown                                                   MIXSET.132    
 2200 CONTINUE                                                             MIXSET.133    
C                                                                          MIXSET.134    
CL    2.3   Values below heated region                                     MIXSET.135    
C                                                                          MIXSET.136    
      DO 2300, k = (KFIX+1), KM                                            MIXSET.137    
         DELPSL(k) = DELPSL(KFIX)                                          MIXSET.138    
 2300 CONTINUE                                                             MIXSET.139    
C                                                                          MIXSET.140    
CL    3.0   Decay scale for wind mixing energy                             MIXSET.141    
C                                                                          MIXSET.142    
      DO 3000, k = 1, KM                                                   MIXSET.143    
         DECAY (k) = EXP(-DZ(k)/(DELTA_SI*100.))                           MIXSET.144    
 3000 CONTINUE                                                             MIXSET.145    
C                                                                          MIXSET.146    
CL    RETURN from MIXSET                                                   MIXSET.147    
C                                                                          MIXSET.148    
      RETURN                                                               MIXSET.149    
      END                                                                  MIXSET.150    
*ENDIF                                                                     @DYALLOC.4655