Changeset 14798 for NEMO/branches/2021
- Timestamp:
- 2021-05-06T13:09:44+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2021/dev_r14122_HPC-08_Mueller_OSMOSIS_streamlining/src/OCE/ZDF/zdfosm.F90
r14785 r14798 56 56 !! zdf_osm_mle_parameters : timestep MLE depth and calculate MLE fluxes 57 57 !! zdf_osm_init : initialization, namelist read, and parameters control 58 !! zdf_osm_alloc : memory allocation 58 59 !! osm_rst : read (or initialize) and write osmosis restart fields 59 60 !! tra_osm : compute and add to the T & S trend the non-local flux … … 61 62 !! dyn_osm : compute and add to u & v trensd the non-local flux 62 63 !!---------------------------------------------------------------------- 63 USE oce ! ocean dynamics and active tracers 64 ! uses ww from previous time step (which is now wb) to calculate hbl 65 USE dom_oce ! ocean space and time domain 66 USE zdf_oce ! ocean vertical physics 67 USE sbc_oce ! surface boundary condition: ocean 68 USE sbcwave ! surface wave parameters 69 USE phycst ! physical constants 70 USE eosbn2 ! equation of state 71 USE traqsr ! details of solar radiation absorption 72 USE zdfdrg, ONLY : rCdU_bot ! bottom friction velocity 73 USE zdfddm ! double diffusion mixing (avs array) 74 USE iom ! I/O library 75 USE lib_mpp ! MPP library 76 USE trd_oce ! ocean trends definition 77 USE trdtra ! tracers trends 64 USE oce ! Ocean dynamics and active tracers 65 ! Uses ww from previous time step (which is now wb) to calculate hbl 66 USE dom_oce ! Ocean space and time domain 67 USE zdf_oce ! Ocean vertical physics 68 USE sbc_oce ! Surface boundary condition: ocean 69 USE sbcwave ! Surface wave parameters 70 USE phycst ! Physical constants 71 USE eosbn2 ! Equation of state 72 USE traqsr ! Details of solar radiation absorption 73 USE zdfdrg, ONLY : rCdU_bot ! Bottom friction velocity 74 USE zdfddm ! Double diffusion mixing (avs array) 75 USE iom ! I/O library 76 USE lib_mpp ! MPP library 77 USE trd_oce ! Ocean trends definition 78 USE trdtra ! Tracers trends 79 USE in_out_manager ! I/O manager 80 USE lbclnk ! Ocean lateral boundary conditions (or mpp link) 81 USE prtctl ! Print control 82 USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 83 USE timing, ONLY : timing_start, timing_stop ! Timer 78 84 ! 79 USE in_out_manager ! I/O manager80 USE lbclnk ! ocean lateral boundary conditions (or mpp link)81 USE prtctl ! Print control82 USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)83 USE timing, ONLY : timing_start, timing_stop ! Timer84 85 85 IMPLICIT NONE 86 86 PRIVATE 87 88 PUBLIC zdf_osm ! routine called by step.F9089 PUBLIC zdf_osm_init ! routine called by nemogcm.F9090 PUBLIC osm_rst ! routine called by step.F9091 PUBLIC tra_osm ! routine called by step.F9092 PUBLIC trc_osm ! routine called by trcstp.F9093 PUBLIC dyn_osm ! routine called by step.F9094 95 PUBLIC ln_osm_mle ! logical needed by tra_mle_init in tramle.F9096 97 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamu !: non-local u-momentum flux98 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamv !: non-local v-momentum flux99 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamt !: non-local temperature flux (gamma/<ws>o)100 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: gham s !: non-local salinity flux (gamma/<ws>o)101 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: etmean !: averaging operator for avt102 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,: ) :: hbl !: boundary layer depth103 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,: ) :: dh ! depth of pycnocline104 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: h ml ! MLdepth105 106 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hmle !Depth of layer affexted by mixed layer eddies in Fox-Kemper parametrization107 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdx_mle ! zonal buoyancy gradient in ML108 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdy_mle ! meridional buoyancy gradient in ML109 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: mld_prof ! level of base of MLE layer.110 87 ! 88 ! Public subroutines 89 PUBLIC zdf_osm ! Routine called by step.F90 90 PUBLIC zdf_osm_init ! Routine called by nemogcm.F90 91 PUBLIC osm_rst ! Routine called by step.F90 92 PUBLIC tra_osm ! Routine called by step.F90 93 PUBLIC trc_osm ! Routine called by trcstp.F90 94 PUBLIC dyn_osm ! Routine called by step.F90 95 ! 96 ! Public variables 97 LOGICAL, PUBLIC :: ln_osm_mle !: Flag to activate the Mixed Layer Eddy (MLE) 98 ! ! parameterisation, needed by tra_mle_init in 99 ! ! tramle.F90 100 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamu !: Non-local u-momentum flux 101 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamv !: Non-local v-momentum flux 102 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamt !: Non-local temperature flux (gamma/<ws>o) 103 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghams !: Non-local salinity flux (gamma/<ws>o) 104 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hbl !: Boundary layer depth 105 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hml !: ML depth 106 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hmle !: Depth of layer affexted by mixed layer eddies in Fox-Kemper parametrization 107 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdx_mle !: Zonal buoyancy gradient in ML 108 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdy_mle !: Meridional buoyancy gradient in ML 109 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: mld_prof !: Level of base of MLE layer 110 ! 111 111 INTERFACE zdf_osm_velocity_rotation 112 112 !!--------------------------------------------------------------------- … … 116 116 MODULE PROCEDURE zdf_osm_velocity_rotation_3d 117 117 END INTERFACE 118 119 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: r1_ft ! inverse of the modified Coriolis parameter at t-pts 120 118 ! 119 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: etmean ! Averaging operator for avt 120 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: dh ! Depth of pycnocline 121 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: r1_ft ! Inverse of the modified Coriolis parameter at t-pts 122 ! 123 ! Layer indices 124 INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nbld ! Level of boundary layer base 125 INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nmld ! Level of mixed-layer depth (pycnocline top) 126 ! 127 ! Layer type 128 INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) :: n_ddh ! Type of shear layer 129 ! ! n_ddh=0: active shear layer 130 ! ! n_ddh=1: shear layer not active 131 ! ! n_ddh=2: shear production low 132 ! 133 ! Layer flags 134 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_conv ! Unstable/stable bl 135 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_shear ! Shear layers 136 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_coup ! Coupling to bottom 137 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_pyc ! OSBL pycnocline present 138 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_flux ! Surface flux extends below OSBL into MLE layer 139 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_mle ! MLE layer increases in hickness. 140 ! 121 141 ! Scales 122 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swth0 ! Surface heat flux (Kinematic) 123 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sws0 ! Surface freshwater flux 124 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swb0 ! Surface buoyancy flux 125 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: suw0 ! Surface u-momentum flux 126 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sustar ! Friction velocity 127 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: scos_wind ! Cos angle of surface stress 128 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: ssin_wind ! Sin angle of surface stress 129 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swthav ! Heat flux - bl average 130 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swsav ! Freshwater flux - bl average 131 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swbav ! Buoyancy flux - bl average 132 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sustke ! Surface Stokes drift 133 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: dstokes ! Penetration depth of the Stokes drift 134 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swstrl ! Langmuir velocity scale 135 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swstrc ! Convective velocity scale 136 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sla ! Trubulent Langmuir number 137 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: svstr ! Velocity scale that tends to sustar for large Langmuir number 138 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: shol ! Stability parameter for boundary layer 139 140 ! !!** Namelist namzdf_osm ** 141 LOGICAL :: ln_use_osm_la ! Use namelist rn_osm_la 142 143 LOGICAL :: ln_osm_mle !: flag to activate the Mixed Layer Eddy (MLE) parameterisation 144 145 REAL(wp) :: rn_osm_la ! Turbulent Langmuir number 146 REAL(wp) :: rn_osm_dstokes ! Depth scale of Stokes drift 147 REAL(wp) :: rn_zdfosm_adjust_sd = 1.0 ! factor to reduce Stokes drift by 148 REAL(wp) :: rn_osm_hblfrac = 0.1! for nn_osm_wave = 3/4 specify fraction in top of hbl 149 LOGICAL :: ln_zdfosm_ice_shelter ! flag to activate ice sheltering 150 REAL(wp) :: rn_osm_hbl0 = 10._wp ! Initial value of hbl for 1D runs 151 INTEGER :: nn_ave ! = 0/1 flag for horizontal average on avt 152 INTEGER :: nn_osm_wave = 0 ! = 0/1/2 flag for getting stokes drift from La# / PM wind-waves/Inputs into sbcwave 153 INTEGER :: nn_osm_SD_reduce ! = 0/1/2 flag for getting effective stokes drift from surface value 154 LOGICAL :: ln_dia_osm ! Use namelist rn_osm_la 155 LOGICAL :: ln_dia_pyc_scl = .FALSE. ! Output of pycnocline scalar-gradient profiles 156 LOGICAL :: ln_dia_pyc_shr = .FALSE. ! Output of pycnocline velocity-shear profiles 157 158 159 LOGICAL :: ln_kpprimix = .true. ! Shear instability mixing 160 REAL(wp) :: rn_riinfty = 0.7 ! local Richardson Number limit for shear instability 161 REAL(wp) :: rn_difri = 0.005 ! maximum shear mixing at Rig = 0 (m2/s) 162 LOGICAL :: ln_convmix = .true. ! Convective instability mixing 163 REAL(wp) :: rn_difconv = 1._wp ! diffusivity when unstable below BL (m2/s) 164 142 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swth0 ! Surface heat flux (Kinematic) 143 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sws0 ! Surface freshwater flux 144 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swb0 ! Surface buoyancy flux 145 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: suw0 ! Surface u-momentum flux 146 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sustar ! Friction velocity 147 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: scos_wind ! Cos angle of surface stress 148 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: ssin_wind ! Sin angle of surface stress 149 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swthav ! Heat flux - bl average 150 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swsav ! Freshwater flux - bl average 151 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swbav ! Buoyancy flux - bl average 152 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sustke ! Surface Stokes drift 153 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: dstokes ! Penetration depth of the Stokes drift 154 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swstrl ! Langmuir velocity scale 155 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swstrc ! Convective velocity scale 156 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sla ! Trubulent Langmuir number 157 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: svstr ! Velocity scale that tends to sustar for large Langmuir number 158 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: shol ! Stability parameter for boundary layer 159 ! 160 ! ** Namelist namzdf_osm ** 161 LOGICAL :: ln_use_osm_la ! Use namelist rn_osm_la 162 REAL(wp) :: rn_osm_la ! Turbulent Langmuir number 163 REAL(wp) :: rn_osm_dstokes ! Depth scale of Stokes drift 164 REAL(wp) :: rn_zdfosm_adjust_sd = 1.0_wp ! Factor to reduce Stokes drift by 165 REAL(wp) :: rn_osm_hblfrac = 0.1_wp ! For nn_osm_wave = 3/4 specify fraction in top of hbl 166 LOGICAL :: ln_zdfosm_ice_shelter ! Flag to activate ice sheltering 167 REAL(wp) :: rn_osm_hbl0 = 10.0_wp ! Initial value of hbl for 1D runs 168 INTEGER :: nn_ave ! = 0/1 flag for horizontal average on avt 169 INTEGER :: nn_osm_wave = 0 ! = 0/1/2 flag for getting stokes drift from La# / PM wind-waves/Inputs into 170 ! ! sbcwave 171 INTEGER :: nn_osm_SD_reduce ! = 0/1/2 flag for getting effective stokes drift from surface value 172 LOGICAL :: ln_dia_osm ! Use namelist rn_osm_la 173 LOGICAL :: ln_dia_pyc_scl = .FALSE. ! Output of pycnocline scalar-gradient profiles 174 LOGICAL :: ln_dia_pyc_shr = .FALSE. ! Output of pycnocline velocity-shear profiles 175 LOGICAL :: ln_kpprimix = .TRUE. ! Shear instability mixing 176 REAL(wp) :: rn_riinfty = 0.7_wp ! Local Richardson Number limit for shear instability 177 REAL(wp) :: rn_difri = 0.005_wp ! Maximum shear mixing at Rig = 0 (m2/s) 178 LOGICAL :: ln_convmix = .TRUE. ! Convective instability mixing 179 REAL(wp) :: rn_difconv = 1.0_wp ! Diffusivity when unstable below BL (m2/s) 180 ! 165 181 #ifdef key_osm_debug 166 182 INTEGER :: nn_idb = 297, nn_jdb = 193, nn_kdb = 35, nn_narea_db = 109 167 183 INTEGER :: iloc_db, jloc_db 168 184 #endif 169 185 ! 170 186 ! OSMOSIS mixed layer eddy parametrization constants 171 INTEGER :: nn_osm_mle ! = 0/1 flag for horizontal average on avt 172 REAL(wp) :: rn_osm_mle_ce ! MLE coefficient 173 ! ! parameters used in nn_osm_mle = 0 case 174 REAL(wp) :: rn_osm_mle_lf ! typical scale of mixed layer front 175 REAL(wp) :: rn_osm_mle_time ! time scale for mixing momentum across the mixed layer 176 ! ! parameters used in nn_osm_mle = 1 case 177 REAL(wp) :: rn_osm_mle_lat ! reference latitude for a 5 km scale of ML front 178 LOGICAL :: ln_osm_hmle_limit ! If true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 179 REAL(wp) :: rn_osm_hmle_limit ! If ln_osm_hmle_limit true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 180 REAL(wp) :: rn_osm_mle_rho_c ! Density criterion for definition of MLD used by FK 181 REAL(wp) :: r5_21 = 5.e0 / 21.e0 ! factor used in mle streamfunction computation 182 REAL(wp) :: rb_c ! ML buoyancy criteria = g rho_c /rho0 where rho_c is defined in zdfmld 183 REAL(wp) :: rc_f ! MLE coefficient (= rn_ce / (5 km * fo) ) in nn_osm_mle=1 case 184 REAL(wp) :: rn_osm_mle_thresh ! Threshold buoyancy for deepening of MLE layer below OSBL base. 185 REAL(wp) :: rn_osm_bl_thresh ! Threshold buoyancy for deepening of OSBL base. 186 REAL(wp) :: rn_osm_mle_tau ! Adjustment timescale for MLE. 187 188 189 ! !!! ** General constants ** 190 REAL(wp) :: epsln = 1.0e-20_wp ! a small positive number to ensure no div by zero 191 REAL(wp) :: depth_tol = 1.0e-6_wp ! a small-ish positive number to give a hbl slightly shallower than gdepw 192 REAL(wp) :: pthird = 1._wp/3._wp ! 1/3 193 REAL(wp) :: p2third = 2._wp/3._wp ! 2/3 194 195 INTEGER :: idebug = 236 196 INTEGER :: jdebug = 228 197 187 INTEGER :: nn_osm_mle ! = 0/1 flag for horizontal average on avt 188 REAL(wp) :: rn_osm_mle_ce ! MLE coefficient 189 ! ! Parameters used in nn_osm_mle = 0 case 190 REAL(wp) :: rn_osm_mle_lf ! Typical scale of mixed layer front 191 REAL(wp) :: rn_osm_mle_time ! Time scale for mixing momentum across the mixed layer 192 ! ! Parameters used in nn_osm_mle = 1 case 193 REAL(wp) :: rn_osm_mle_lat ! Reference latitude for a 5 km scale of ML front 194 LOGICAL :: ln_osm_hmle_limit ! If true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 195 REAL(wp) :: rn_osm_hmle_limit ! If ln_osm_hmle_limit true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 196 REAL(wp) :: rn_osm_mle_rho_c ! Density criterion for definition of MLD used by FK 197 REAL(wp) :: rb_c ! ML buoyancy criteria = g rho_c /rho0 where rho_c is defined in zdfmld 198 REAL(wp) :: rc_f ! MLE coefficient (= rn_ce / (5 km * fo) ) in nn_osm_mle=1 case 199 REAL(wp) :: rn_osm_mle_thresh ! Threshold buoyancy for deepening of MLE layer below OSBL base 200 REAL(wp) :: rn_osm_bl_thresh ! Threshold buoyancy for deepening of OSBL base 201 REAL(wp) :: rn_osm_mle_tau ! Adjustment timescale for MLE 202 ! 203 ! ** General constants ** 204 REAL(wp) :: epsln = 1.0e-20_wp ! A small positive number to ensure no div by zero 205 REAL(wp) :: depth_tol = 1.0e-6_wp ! A small-ish positive number to give a hbl slightly shallower than gdepw 206 REAL(wp) :: pthird = 1.0_wp/3.0_wp ! 1/3 207 REAL(wp) :: p2third = 2.0_wp/3.0_wp ! 2/3 208 ! 198 209 !! * Substitutions 199 210 # include "do_loop_substitute.h90" … … 205 216 !!---------------------------------------------------------------------- 206 217 CONTAINS 207 218 ! 208 219 INTEGER FUNCTION zdf_osm_alloc() 209 220 !!---------------------------------------------------------------------- 210 221 !! *** FUNCTION zdf_osm_alloc *** 211 222 !!---------------------------------------------------------------------- 212 !213 223 INTEGER :: ierr 214 224 ! 215 ALLOCATE( swth0(jpi,jpj), sws0(jpi,jpj), swb0(jpi,jpj), suw0(jpi,jpj), & 216 & sustar(jpi,jpj), scos_wind(jpi,jpj), ssin_wind(jpi,jpj), swthav(jpi,jpj), & 217 & swsav(jpi,jpj), swbav(jpi,jpj), sustke(jpi,jpj), swstrl(jpi,jpj), & 218 & swstrc(jpi,jpj), sla(jpi,jpj), svstr(jpi,jpj), shol(jpi,jpj), & 219 & STAT=ierr ) 220 zdf_osm_alloc = ierr 221 ! 222 ALLOCATE( ghamu(jpi,jpj,jpk), ghamv(jpi,jpj,jpk), ghamt(jpi,jpj,jpk),ghams(jpi,jpj,jpk), & 223 & hbl(jpi,jpj), dh(jpi,jpj), hml(jpi,jpj), dstokes(jpi, jpj), & 224 & etmean(jpi,jpj,jpk), STAT=ierr ) 225 zdf_osm_alloc = 0 226 ! 227 ALLOCATE( ghamu(jpi,jpj,jpk), ghamv(jpi,jpj,jpk), ghamt(jpi,jpj,jpk), ghams(jpi,jpj,jpk), hbl(jpi,jpj), hml(jpi,jpj), & 228 & hmle(jpi,jpj), dbdx_mle(jpi,jpj), dbdy_mle(jpi,jpj), mld_prof(jpi,jpj), STAT=ierr ) 225 229 zdf_osm_alloc = zdf_osm_alloc + ierr 226 230 ! 227 ALLOCATE( hmle(jpi,jpj), r1_ft(jpi,jpj), dbdx_mle(jpi,jpj), dbdy_mle(jpi,jpj), & 228 & mld_prof(jpi,jpj), STAT=ierr ) 231 ALLOCATE( etmean(jpi,jpj,jpk), dh(jpi,jpj), r1_ft(jpi,jpj), STAT=ierr ) 229 232 zdf_osm_alloc = zdf_osm_alloc + ierr 230 233 ! 234 ALLOCATE( nbld(jpi,jpj), nmld(jpi,jpj), STAT=ierr ) 235 zdf_osm_alloc = zdf_osm_alloc + ierr 236 ! 237 ALLOCATE( n_ddh(jpi,jpj), STAT=ierr ) 238 zdf_osm_alloc = zdf_osm_alloc + ierr 239 ! 240 ALLOCATE( l_conv(jpi,jpj), l_shear(jpi,jpj), l_coup(jpi,jpj), l_pyc(jpi,jpj), l_flux(jpi,jpj), l_mle(jpi,jpj), STAT=ierr ) 241 zdf_osm_alloc = zdf_osm_alloc + ierr 242 ! 243 ALLOCATE( swth0(jpi,jpj), sws0(jpi,jpj), swb0(jpi,jpj), suw0(jpi,jpj), sustar(jpi,jpj), scos_wind(jpi,jpj), & 244 & ssin_wind(jpi,jpj), swthav(jpi,jpj), swsav(jpi,jpj), swbav(jpi,jpj), sustke(jpi,jpj), dstokes(jpi,jpj), & 245 & swstrl(jpi,jpj), swstrc(jpi,jpj), sla(jpi,jpj), svstr(jpi,jpj), shol(jpi,jpj), STAT=ierr ) 246 zdf_osm_alloc = zdf_osm_alloc + ierr 247 ! 231 248 CALL mpp_sum ( 'zdfosm', zdf_osm_alloc ) 232 IF( zdf_osm_alloc /= 0 ) CALL ctl_warn('zdf_osm_alloc: failed to allocate zdf_osm arrays')249 IF( zdf_osm_alloc /= 0 ) CALL ctl_warn( 'zdf_osm_alloc: failed to allocate zdf_osm arrays' ) 233 250 ! 234 251 END FUNCTION zdf_osm_alloc 235 236 237 SUBROUTINE zdf_osm( kt, Kbb, Kmm, Krhs, p_avm,p_avt )252 ! 253 SUBROUTINE zdf_osm( kt, Kbb, Kmm, Krhs, p_avm, & 254 & p_avt ) 238 255 !!---------------------------------------------------------------------- 239 256 !! *** ROUTINE zdf_osm *** … … 305 322 REAL(wp), DIMENSION(jpi,jpj) :: zvel_mle ! velocity scale for dhdt with stable ML and FK 306 323 307 LOGICAL, DIMENSION(jpi,jpj) :: lconv ! unstable/stable bl308 LOGICAL, DIMENSION(jpi,jpj) :: lshear ! Shear layers309 LOGICAL, DIMENSION(jpi,jpj) :: lcoup ! Coupling to bottom310 LOGICAL, DIMENSION(jpi,jpj) :: lpyc ! OSBL pycnocline present311 LOGICAL, DIMENSION(jpi,jpj) :: lflux ! surface flux extends below OSBL into MLE layer.312 LOGICAL, DIMENSION(jpi,jpj) :: lmle ! MLE layer increases in hickness.313 314 324 ! mixed-layer variables 315 325 316 INTEGER, DIMENSION(jpi,jpj) :: ibld ! level of boundary layer base317 INTEGER, DIMENSION(jpi,jpj) :: imld ! level of mixed-layer depth (pycnocline top)318 326 INTEGER, DIMENSION(jpi,jpj) :: jp_ext ! offset for external level 319 INTEGER, DIMENSION(jpi, jpj) :: j_ddh ! Type of shear layer320 327 321 328 REAL(wp), DIMENSION(jpi,jpj) :: zhbl ! bl depth - grid … … 373 380 ! 374 381 IF( ln_timing ) CALL timing_start('zdf_osm') 375 ibld(:,:) = 0 ; imld(:,:) = 0382 nbld(:,:) = 0 ; nmld(:,:) = 0 376 383 sustar(:,:) = zlarge 377 384 swstrl(:,:) = zlarge ; svstr(:,:) = zlarge ; swstrc(:,:) = zlarge ; suw0(:,:) = zlarge … … 380 387 sustke(:,:) = zlarge ; sla(:,:) = zlarge ; scos_wind(:,:) = zlarge ; ssin_wind(:,:) = zlarge 381 388 shol(:,:) = zlarge ; zalpha_pyc(:,:) = zlarge 382 l pyc(:,:) = .FALSE. ; lflux(:,:) = .FALSE. ; lmle(:,:) = .FALSE.389 l_pyc(:,:) = .FALSE. ; l_flux(:,:) = .FALSE. ; l_mle(:,:) = .FALSE. 383 390 ! mixed layer 384 391 ! no initialization of zhbl or zhml (or zdh?) … … 607 614 ! Note sustke and swstrl are not amended. 608 615 ! 609 ! get convective velocity (swstrc), stabilty scale (shol) and logical conection flag l conv616 ! get convective velocity (swstrc), stabilty scale (shol) and logical conection flag l_conv 610 617 IF ( swbav(ji,jj) > 0.0) THEN 611 618 swstrc(ji,jj) = ( 2.0 * swbav(ji,jj) * 0.9 * hbl(ji,jj) )**pthird … … 631 638 ! BL must be always 4 levels deep. 632 639 ! For calculation of lateral buoyancy gradients for FK in 633 ! zdf_osm_zmld_horizontal_gradients need halo values for ibld, so must640 ! zdf_osm_zmld_horizontal_gradients need halo values for nbld, so must 634 641 ! previously exist for hbl also. 635 642 … … 637 644 ! ########################################################################## 638 645 hbl(:,:) = MAX(hbl(:,:), gdepw(:,:,4,Kmm) ) 639 ibld(:,:) = 4646 nbld(:,:) = 4 640 647 DO_3D( 1, 1, 1, 1, 5, jpkm1 ) 641 648 IF ( hbl(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) THEN 642 ibld(ji,jj) = MIN(mbkt(ji,jj)-2, jk)649 nbld(ji,jj) = MIN(mbkt(ji,jj)-2, jk) 643 650 ENDIF 644 651 END_3D … … 646 653 647 654 DO_2D( 0, 0, 0, 0 ) 648 zhbl(ji,jj) = gdepw(ji,jj, ibld(ji,jj),Kmm)649 imld(ji,jj) = MAX(3,ibld(ji,jj) - MAX( INT( dh(ji,jj) / e3t(ji, jj, ibld(ji,jj) - 1, Kmm )) , 1 ))650 zhml(ji,jj) = gdepw(ji,jj, imld(ji,jj),Kmm)655 zhbl(ji,jj) = gdepw(ji,jj,nbld(ji,jj),Kmm) 656 nmld(ji,jj) = MAX( 3, nbld(ji,jj) - MAX( INT( dh(ji,jj) / e3t(ji,jj,nbld(ji,jj)-1,Kmm) ), 1 ) ) 657 zhml(ji,jj) = gdepw(ji,jj,nmld(ji,jj),Kmm) 651 658 zdh(ji,jj) = zhbl(ji,jj) - zhml(ji,jj) 652 659 END_2D … … 657 664 & 'Before updating hbl: hbl=', hbl(ji,jj), ' dh=', dh(ji,jj), & 658 665 &' zhbl =',zhbl(ji,jj) , ' zhml=', zhml(ji,jj), ' zdh=', zdh(ji,jj),& 659 &' imld=', imld(ji,jj), ' ibld=', ibld(ji,jj)666 &' imld=', nmld(ji,jj), ' ibld=', nbld(ji,jj) 660 667 661 668 WRITE(narea+100,'(a,g11.3,a,2g11.3)') 'Physics: ssh ',ssh(ji,jj,Kmm),' T S surface=',ts(ji,jj,1,jp_tem,Kmm),ts(ji,jj,1,jp_sal,Kmm) 662 jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )669 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 663 670 WRITE(narea+100,'(a,*(g11.3))') ' T[imld-1..ibld+2] =', ( ts(ji,jj,jk,jp_tem,Kmm), jk=jl,jm ) 664 671 WRITE(narea+100,'(a,*(g11.3))') ' S[imld-1..ibld+2] =', ( ts(ji,jj,jk,jp_sal,Kmm), jk=jl,jm ) … … 675 682 ! Averages over well-mixed and boundary layer, note BL averages use jp_ext=2 everywhere 676 683 jp_ext(:,:) = 1 ! ag 19/03 677 CALL zdf_osm_vertical_average( Kbb, Kmm,&678 & ibld, zt_bl, zs_bl, zb_bl, zu_bl, zv_bl,&679 & jp_ext, zdt_bl,zds_bl, zdb_bl, zdu_bl, zdv_bl )680 jp_ext(:,:) = ibld(:,:) - imld(:,:) + jp_ext(:,:) + 1 ! ag 19/03681 CALL zdf_osm_vertical_average( Kbb, Kmm,&682 & imld-1, zt_ml, zs_ml, zb_ml, zu_ml, zv_ml, jp_ext, &683 & zd t_ml, zds_ml, zdb_ml, zdu_ml,zdv_ml )684 CALL zdf_osm_vertical_average( Kbb, Kmm, nbld, zt_bl, zs_bl, & 685 & zb_bl, zu_bl, zv_bl, jp_ext, zdt_bl, & 686 & zds_bl, zdb_bl, zdu_bl, zdv_bl ) 687 jp_ext(:,:) = nbld(:,:) - nmld(:,:) + jp_ext(:,:) + 1 ! ag 19/03 688 CALL zdf_osm_vertical_average( Kbb, Kmm, nmld - 1, zt_ml, zs_ml, & 689 & zb_ml, zu_ml, zv_ml, jp_ext, zdt_ml, & 690 & zds_ml, zdb_ml, zdu_ml, zdv_ml ) 684 691 #ifdef key_osm_debug 685 692 IF(narea==nn_narea_db) THEN … … 713 720 714 721 ! Determine the state of the OSBL, stable/unstable, shear/no shear 715 CALL zdf_osm_osbl_state( Kmm, lconv, lshear, j_ddh, zwb_ent, zwb_min, zshear, & 716 & zhbl, zhml, zdh, zdb_bl, zdu_bl, zdv_bl, zdb_ml, zdu_ml, zdv_ml ) 722 CALL zdf_osm_osbl_state( Kmm, zwb_ent, zwb_min, zshear, zhbl, & 723 & zhml, zdh, zdb_bl, zdu_bl, zdv_bl, & 724 & zdb_ml, zdu_ml, zdv_ml ) 717 725 718 726 #ifdef key_osm_debug … … 720 728 ji=iloc_db; jj=jloc_db 721 729 WRITE(narea+100,'(2(a,l7),a, i7,/,3(a,g11.3),/)') & 722 & 'After zdf_osm_osbl_state: lconv=', l conv(ji,jj), ' lshear=', lshear(ji,jj), ' j_ddh=', j_ddh(ji,jj),&730 & 'After zdf_osm_osbl_state: lconv=', l_conv(ji,jj), ' lshear=', l_shear(ji,jj), ' j_ddh=', n_ddh(ji,jj),& 723 731 & 'zwb_ent=', zwb_ent(ji,jj), ' zwb_min=', zwb_min(ji,jj), ' zshear=', zshear(ji,jj) 724 732 FLUSH(narea+100) … … 731 739 IF ( hmle(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) mld_prof(ji,jj) = MIN(mbkt(ji,jj), jk) 732 740 END_3D 733 CALL zdf_osm_vertical_average( Kbb, Kmm,&734 & mld_prof, zt_mle, zs_mle,zb_mle, zu_mle, zv_mle )741 CALL zdf_osm_vertical_average( Kbb, Kmm, mld_prof, zt_mle, zs_mle, & 742 & zb_mle, zu_mle, zv_mle ) 735 743 736 744 DO_2D( 0, 0, 0, 0 ) … … 749 757 750 758 !! Calculate fairly-well-mixed depth zmld & its index mld_prof + lateral zmld-averaged gradients 751 CALL zdf_osm_zmld_horizontal_gradients( Kmm, ibld, zmld, zdtdx, zdtdy, zdsdx, zdsdy, dbdx_mle, dbdy_mle, zdbds_mle ) 759 CALL zdf_osm_zmld_horizontal_gradients( Kmm, zmld, zdtdx, zdtdy, zdsdx, & 760 & zdsdy, dbdx_mle, dbdy_mle, zdbds_mle ) 752 761 !! Calculate max vertical FK flux zwb_fk & set logical descriptors 753 CALL zdf_osm_osbl_state_fk( Kmm, ibld, lconv, lpyc, lflux, lmle, zwb_fk, zt_mle, zs_mle, zb_mle, zhbl, & 754 & zhmle, zwb_ent, zt_bl, zs_bl, zb_bl, zdb_bl, zdbds_mle ) 762 CALL zdf_osm_osbl_state_fk( Kmm, zwb_fk, zt_mle, zs_mle, zb_mle, & 763 & zhbl, zhmle, zwb_ent, zt_bl, zs_bl, & 764 & zb_bl, zdb_bl, zdbds_mle ) 755 765 !! recalculate hmle, zmle, zvel_mle, zdiff_mle & redefine mld_proc to be index for new hmle 756 CALL zdf_osm_mle_parameters( Kmm, lconv, lmle, mld_prof, zmld, zhmle, &757 & z vel_mle, zdiff_mle, zdbds_mle, zhbl, zb_bl, zwb0tot )766 CALL zdf_osm_mle_parameters( Kmm, mld_prof, zmld, zhmle, zvel_mle, & 767 & zdiff_mle, zdbds_mle, zhbl, zb_bl, zwb0tot ) 758 768 #ifdef key_osm_debug 759 769 IF(narea==nn_narea_db) THEN … … 772 782 ELSE ! ln_osm_mle 773 783 ! FK not selected, Boundary Layer only. 774 l pyc(:,:) = .TRUE.775 l flux(:,:) = .FALSE.776 l mle(:,:) = .FALSE.784 l_pyc(:,:) = .TRUE. 785 l_flux(:,:) = .FALSE. 786 l_mle(:,:) = .FALSE. 777 787 DO_2D( 0, 0, 0, 0 ) 778 IF ( l conv(ji,jj) .AND. zdb_bl(ji,jj) < rn_osm_bl_thresh ) lpyc(ji,jj) = .FALSE.788 IF ( l_conv(ji,jj) .AND. zdb_bl(ji,jj) < rn_osm_bl_thresh ) l_pyc(ji,jj) = .FALSE. 779 789 END_2D 780 790 ENDIF ! ln_osm_mle 781 791 782 792 !! External gradient below BL needed both with and w/o FK 783 CALL zdf_osm_external_gradients( Kmm, ibld+1, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) ! ag 19/03793 CALL zdf_osm_external_gradients( Kmm, nbld + 1, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) ! ag 19/03 784 794 785 795 ! Test if pycnocline well resolved 786 796 ! DO_2D( 0, 0, 0, 0 ) Removed with ag 19/03 changes. A change in eddy diffusivity/viscosity 787 ! IF (l conv(ji,jj) ) THEN should account for this.788 ! ztmp = 0.2 * zhbl(ji,jj) / e3w(ji,jj, ibld(ji,jj),Kmm)797 ! IF (l_conv(ji,jj) ) THEN should account for this. 798 ! ztmp = 0.2 * zhbl(ji,jj) / e3w(ji,jj,nbld(ji,jj),Kmm) 789 799 ! IF ( ztmp > 6 ) THEN 790 800 ! ! pycnocline well resolved … … 803 813 ji=iloc_db; jj=jloc_db 804 814 WRITE(narea+100,'(4(a,l7),a,i7,/, 3(a,g11.3),/)') & 805 & 'BL logical descriptors: lconv =',l conv(ji,jj),' lpyc=', lpyc(ji,jj),' lflux=', lflux(ji,jj),' lmle=', lmle(ji,jj),&815 & 'BL logical descriptors: lconv =',l_conv(ji,jj),' lpyc=', l_pyc(ji,jj),' lflux=', l_flux(ji,jj),' lmle=', l_mle(ji,jj),& 806 816 & ' jp_ext=', jp_ext(ji,jj), & 807 817 & 'sub-BL strat: zdtdz_bl_ext=', zdtdz_bl_ext(ji,jj),' zdsdz_bl_ext=', zdsdz_bl_ext(ji,jj),' zdbdz_bl_ext=', zdbdz_bl_ext(ji,jj) … … 812 822 ! Recalculate bl averages using jp_ext & ml averages .... note no rotation of u & v here.. 813 823 jp_ext(:,:) = 1 ! ag 19/03 814 CALL zdf_osm_vertical_average( Kbb, Kmm,&815 & ibld, zt_bl, zs_bl, zb_bl, zu_bl, zv_bl,&816 & jp_ext, zdt_bl,zds_bl, zdb_bl, zdu_bl, zdv_bl )817 jp_ext(:,:) = ibld(:,:) - imld(:,:) + jp_ext(:,:) + 1 ! ag 19/03818 CALL zdf_osm_vertical_average( Kbb, Kmm,&819 & imld-1, zt_ml, zs_ml, zb_ml, zu_ml, zv_ml,&820 & jp_ext, zdt_ml, zds_ml, zdb_ml, zdu_ml,zdv_ml ) ! ag 19/03824 CALL zdf_osm_vertical_average( Kbb, Kmm, nbld, zt_bl, zs_bl, & 825 & zb_bl, zu_bl, zv_bl, jp_ext, zdt_bl, & 826 & zds_bl, zdb_bl, zdu_bl, zdv_bl ) 827 jp_ext(:,:) = nbld(:,:) - nmld(:,:) + jp_ext(:,:) + 1 ! ag 19/03 828 CALL zdf_osm_vertical_average( Kbb, Kmm, nmld - 1, zt_ml, zs_ml, & 829 & zb_ml, zu_ml, zv_ml, jp_ext, zdt_ml, & 830 & zds_ml, zdb_ml, zdu_ml, zdv_ml ) ! ag 19/03 821 831 #ifdef key_osm_debug 822 832 IF(narea==nn_narea_db) THEN … … 836 846 837 847 ! Rate of change of hbl 838 CALL zdf_osm_calculate_dhdt( lconv, lshear, j_ddh, zdhdt, zhbl, zdh, zwb_ent, zwb_min, & 839 & zdb_bl, zdbdz_bl_ext, zdb_ml, zwb_fk_b, zwb_fk, zvel_mle ) 848 CALL zdf_osm_calculate_dhdt( zdhdt, zhbl, zdh, zwb_ent, zwb_min, & 849 & zdb_bl, zdbdz_bl_ext, zdb_ml, zwb_fk_b, zwb_fk, & 850 & zvel_mle ) 840 851 ! Test if surface boundary layer coupled to bottom 841 l coup(:,:) = .FALSE. ! ag 19/03852 l_coup(:,:) = .FALSE. ! ag 19/03 842 853 DO_2D( 0, 0, 0, 0 ) 843 zhbl_t(ji,jj) = hbl(ji,jj) + ( zdhdt(ji,jj) - ww(ji,jj,ibld(ji,jj)))* rn_Dt ! certainly need ww here, so subtract it854 zhbl_t(ji,jj) = hbl(ji,jj) + ( zdhdt(ji,jj) - ww(ji,jj,nbld(ji,jj)) ) * rn_Dt ! Certainly need ww here, so subtract it 844 855 ! adjustment to represent limiting by ocean bottom 845 856 IF ( mbkt(ji,jj) > 2 ) THEN ! to ensure mbkt(ji,jj) - 2 > 0 so no incorrect array access 846 857 IF ( zhbl_t(ji,jj) > gdepw(ji, jj,mbkt(ji,jj)-2,Kmm) ) THEN 847 858 zhbl_t(ji,jj) = MIN( zhbl_t(ji,jj), gdepw(ji,jj,mbkt(ji,jj)-2,Kmm) ) ! ht(:,:)) 848 l pyc(ji,jj) = .FALSE.849 l coup(ji,jj) = .TRUE. ! ag 19/03859 l_pyc(ji,jj) = .FALSE. 860 l_coup(ji,jj) = .TRUE. ! ag 19/03 850 861 END IF 851 862 END IF … … 853 864 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 854 865 WRITE(narea+100,'(2(a,g11.3),/,2(a,g11.3)),2(a,l7)')'after zdf_osm_calculate_dhdt: zhbl_t=',zhbl_t(ji,jj), 'hbl=', hbl(ji,jj),& 855 & 'delta hbl from dzdhdt', zdhdt(ji,jj)*rn_Dt,' delta hbl from w ', ww(ji,jj, ibld(ji,jj))*rn_Dt, &856 & ' lcoup= ', l coup(ji,jj), ' lpyc= ', lpyc(ji,jj)866 & 'delta hbl from dzdhdt', zdhdt(ji,jj)*rn_Dt,' delta hbl from w ', ww(ji,jj,nbld(ji,jj))*rn_Dt, & 867 & ' lcoup= ', l_coup(ji,jj), ' lpyc= ', l_pyc(ji,jj) 857 868 FLUSH(narea+100) 858 869 END IF … … 860 871 END_2D 861 872 862 imld(:,:) = ibld(:,:) ! use imld to hold previous blayer index863 ibld(:,:) = 4873 nmld(:,:) = nbld(:,:) ! use nmld to hold previous blayer index 874 nbld(:,:) = 4 864 875 865 876 DO_3D( 0, 0, 0, 0, 4, jpkm1 ) 866 877 IF ( zhbl_t(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) THEN 867 ibld(ji,jj) = jk878 nbld(ji,jj) = jk 868 879 ENDIF 869 880 END_3D … … 872 883 ! Step through model levels taking account of buoyancy change to determine the effect on dhdt 873 884 ! 874 CALL zdf_osm_timestep_hbl( Kmm, ibld, imld, lconv, lpyc, zdhdt, zhbl, zhbl_t, zt_bl, zs_bl, zwb_ent, zwb_fk_b ) 885 CALL zdf_osm_timestep_hbl( Kmm, zdhdt, zhbl, zhbl_t, zt_bl, & 886 & zs_bl, zwb_ent, zwb_fk_b ) 875 887 ! is external level in bounds? 876 888 877 889 ! Recalculate BL averages and differences using new BL depth 878 890 jp_ext(:,:) = 1 ! ag 19/03 879 CALL zdf_osm_vertical_average( Kbb, Kmm,&880 & ibld, zt_bl, zs_bl, zb_bl, zu_bl, zv_bl,&881 & jp_ext, zdt_bl,zds_bl, zdb_bl, zdu_bl, zdv_bl )882 883 CALL zdf_osm_pycnocline_thickness( Kmm, ibld, imld, lshear, lconv, j_ddh, zdh, zhml,zdhdt, zdb_bl, &891 CALL zdf_osm_vertical_average( Kbb, Kmm, nbld, zt_bl, zs_bl, & 892 & zb_bl, zu_bl, zv_bl, jp_ext, zdt_bl, & 893 & zds_bl, zdb_bl, zdu_bl, zdv_bl ) 894 895 CALL zdf_osm_pycnocline_thickness( Kmm, zdh, zhml, zdhdt, zdb_bl, & 884 896 & zhbl, zwb_ent, zdbdz_bl_ext, zwb_fk_b ) 885 897 … … 887 899 888 900 DO_2D( 0, 0, 0, 0 ) 889 IF ( zdb_bl(ji,jj) < rn_osm_bl_thresh .or. ibld(ji,jj) >= mbkt(ji,jj) - 2 .or. &890 & ibld(ji,jj)-imld(ji,jj) == 1 .or. zdhdt(ji,jj) < 0.0_wp ) THEN ! ag 19/03891 l pyc(ji,jj) = .FALSE. ! ag 19/03892 IF ( ibld(ji,jj) >= mbkt(ji,jj) -2 ) THEN893 imld(ji,jj) = ibld(ji,jj) - 1 ! ag 19/03894 zdh(ji,jj) = gdepw(ji,jj, ibld(ji,jj),Kmm) - gdepw(ji,jj,imld(ji,jj),Kmm) ! ag 19/03895 zhml(ji,jj) = gdepw(ji,jj, imld(ji,jj),Kmm) ! ag 19/03901 IF ( zdb_bl(ji,jj) < rn_osm_bl_thresh .or. nbld(ji,jj) >= mbkt(ji,jj) - 2 .or. & 902 & nbld(ji,jj) - nmld(ji,jj) == 1 .or. zdhdt(ji,jj) < 0.0_wp ) THEN ! ag 19/03 903 l_pyc(ji,jj) = .FALSE. ! ag 19/03 904 IF ( nbld(ji,jj) >= mbkt(ji,jj) -2 ) THEN 905 nmld(ji,jj) = nbld(ji,jj) - 1 ! ag 19/03 906 zdh(ji,jj) = gdepw(ji,jj,nbld(ji,jj),Kmm) - gdepw(ji,jj,nmld(ji,jj),Kmm) ! ag 19/03 907 zhml(ji,jj) = gdepw(ji,jj,nmld(ji,jj),Kmm) ! ag 19/03 896 908 dh(ji,jj) = zdh(ji,jj) ! ag 19/03 897 909 hml(ji,jj) = hbl(ji,jj) - dh(ji,jj) ! ag 19/03 … … 899 911 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 900 912 WRITE(narea+100,'(a)')'After setting pycnocline thickness BL running aground: lpyc= F5: ibld(ji,jj) >= mbkt(ji,jj) -2' 901 WRITE(narea+100,'(2(a,i7),2(a,g11.3))')' ibld=', ibld(ji,jj),' imld=',imld(ji,jj), ' zdh=',zdh(ji,jj), ' zhml=',zhml(ji,jj)913 WRITE(narea+100,'(2(a,i7),2(a,g11.3))')' ibld=',nbld(ji,jj),' imld=',nmld(ji,jj), ' zdh=',zdh(ji,jj), ' zhml=',zhml(ji,jj) 902 914 WRITE(narea+100,'(2(a,g11.3))')'dh=',dh(ji,jj),' hml=',hml(ji,jj) 903 915 FLUSH(narea+100) … … 911 923 ! 912 924 ! Average over the depth of the mixed layer in the convective boundary layer 913 ! jp_ext = ibld - imld +1925 ! jp_ext = nbld - nmld +1 914 926 ! Recalculate ML averages and differences using new ML depth 915 jp_ext(:,:) = ibld(:,:) - imld(:,:) + jp_ext(:,:) + 1 ! ag 19/03916 CALL zdf_osm_vertical_average( Kbb, Kmm,&917 & imld-1, zt_ml, zs_ml, zb_ml, zu_ml, zv_ml,&918 & jp_ext, zdt_ml, zds_ml, zdb_ml, zdu_ml,zdv_ml )919 920 CALL zdf_osm_external_gradients( Kmm, ibld+1, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext )927 jp_ext(:,:) = nbld(:,:) - nmld(:,:) + jp_ext(:,:) + 1 ! ag 19/03 928 CALL zdf_osm_vertical_average( Kbb, Kmm, nmld - 1, zt_ml, zs_ml, & 929 & zb_ml, zu_ml, zv_ml, jp_ext, zdt_ml, & 930 & zds_ml, zdb_ml, zdu_ml, zdv_ml ) 931 932 CALL zdf_osm_external_gradients( Kmm, nbld + 1, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) 921 933 #ifdef key_osm_debug 922 934 IF(narea==nn_narea_db) THEN … … 953 965 954 966 jp_ext(:,:) = 1 ! ag 19/03 955 CALL zdf_osm_pycnocline_buoyancy_profiles( Kmm, ibld, jp_ext, lconv, lpyc, zdbdz_pyc, zalpha_pyc, zdh, & 956 & zdb_bl, zhbl, zdbdz_bl_ext, zhml, zdb_ml, zdhdt ) 967 CALL zdf_osm_pycnocline_buoyancy_profiles( Kmm, jp_ext, zdbdz_pyc, zalpha_pyc, zdh, & 968 & zdb_bl, zhbl, zdbdz_bl_ext, zhml, zdb_ml, & 969 & zdhdt ) 957 970 #ifdef key_osm_debug 958 971 IF(narea==nn_narea_db) THEN 959 972 ji=iloc_db; jj=jloc_db 960 jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )973 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 961 974 WRITE(narea+100,'(a,l7,/,3(a,g11.3),/)') & 962 & 'After pycnocline profiles BL lpyc=', l pyc(ji,jj),&975 & 'After pycnocline profiles BL lpyc=', l_pyc(ji,jj),& 963 976 & 'sub-BL strat: zdtdz_bl_ext=', zdtdz_bl_ext(ji,jj),' zdsdz_bl_ext=', zdsdz_bl_ext(ji,jj),' zdbdz_bl_ext=', zdbdz_bl_ext(ji,jj), & 964 977 & 'Pycnocline: zalpha_pyc=', zalpha_pyc(ji,jj) … … 975 988 ! Eddy viscosity/diffusivity and non-gradient terms in the flux-gradient relationship 976 989 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 977 CALL zdf_osm_diffusivity_viscosity( Kbb, Kmm, ibld, imld, lconv, lshear, lpyc, lcoup, j_ddh, zdiffut, zviscos, & 978 & zhbl, zhml, zdh, zdhdt, zshear, zb_bl, zu_bl, zv_bl, zb_ml, zu_ml, zv_ml, zwb_ent, & 979 & zwb_min ) 990 CALL zdf_osm_diffusivity_viscosity( Kbb, Kmm, zdiffut, zviscos, zhbl, & 991 & zhml, zdh, zdhdt, zshear, zb_bl, & 992 & zu_bl, zv_bl, zb_ml, zu_ml, zv_ml, & 993 & zwb_ent, zwb_min ) 980 994 #ifdef key_osm_debug 981 995 IF(narea==nn_narea_db) THEN 982 996 ji=iloc_db; jj=jloc_db 983 jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )997 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 984 998 WRITE(narea+100,'(a,*(g11.3))') ' zdiffut[imld-1..ibld+2] =', ( zdiffut(ji,jj,jk), jk=jl,jm ) 985 999 WRITE(narea+100,'(a,*(g11.3))') ' zviscos[imld-1..ibld+2] =', ( zviscos(ji,jj,jk), jk=jl,jm ) … … 992 1006 ! Calculate non-gradient components of the flux-gradient relationships 993 1007 ! -------------------------------------------------------------------- 994 CALL zdf_osm_fgr_terms( Kmm, ibld, imld, jp_ext, lconv, lpyc, j_ddh, zhbl, zhml, zdh, zdhdt, zshear, & 995 & zdt_bl, zds_bl, zdb_bl, zdu_bl, zdv_bl, zdt_ml, zds_ml, zdb_ml, zdu_ml, zdv_ml, & 996 & zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_pyc, zalpha_pyc, zdiffut, zviscos ) 1008 CALL zdf_osm_fgr_terms( Kmm, jp_ext, zhbl, zhml, zdh, & 1009 & zdhdt, zshear, zdt_bl, zds_bl, zdb_bl, & 1010 & zdu_bl, zdv_bl, zdt_ml, zds_ml, zdb_ml, & 1011 & zdu_ml, zdv_ml, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_pyc, & 1012 & zalpha_pyc, zdiffut, zviscos ) 997 1013 998 1014 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> … … 1004 1020 1005 1021 ! Rotate non-gradient velocity terms back to model reference frame 1006 CALL zdf_osm_velocity_rotation( ghamu, ghamv, .FALSE., 2, ibld )1022 CALL zdf_osm_velocity_rotation( ghamu, ghamv, .FALSE., 2, nbld ) 1007 1023 1008 1024 ! KPP-style Ri# mixing … … 1010 1026 jkflt = jpk 1011 1027 DO_2D( 0, 0, 0, 0 ) 1012 IF ( ibld(ji,jj) < jkflt ) jkflt = ibld(ji,jj)1028 IF ( nbld(ji,jj) < jkflt ) jkflt = nbld(ji,jj) 1013 1029 END_2D 1014 1030 DO jk = jkflt+1, jpkm1 … … 1023 1039 END_2D 1024 1040 DO_2D( 0, 0, 0, 0 ) 1025 IF ( jk > ibld(ji,jj) ) THEN1041 IF ( jk > nbld(ji,jj) ) THEN 1026 1042 ! Shear prod. at w-point weightened by mask 1027 1043 zesh2 = ( z2du(ji-1,jj) + z2du(ji,jj) ) / MAX( 1.0_wp , umask(ji-1,jj,jk) + umask(ji,jj,jk) ) & … … 1042 1058 IF( ln_convmix) THEN 1043 1059 DO_2D( 0, 0, 0, 0 ) 1044 DO jk = ibld(ji,jj) + 1, jpkm11060 DO jk = nbld(ji,jj) + 1, jpkm1 1045 1061 IF( MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) zdiffut(ji,jj,jk) = MAX( rn_difconv, zdiffut(ji,jj,jk) ) 1046 1062 END DO … … 1050 1066 IF(narea==nn_narea_db) THEN 1051 1067 ji=iloc_db; jj=jloc_db 1052 jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )1068 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 1053 1069 WRITE(narea+100,'(a)') ' After including KPP Ri# diffusivity & viscosity' 1054 1070 WRITE(narea+100,'(a,*(g11.3))') ' zdiffut[imld-1..ibld+2] =', ( zdiffut(ji,jj,jk), jk=jl,jm ) … … 1063 1079 IF ( ln_osm_mle ) THEN ! set up diffusivity and non-gradient mixing 1064 1080 DO_2D( 0, 0, 0, 0 ) 1065 IF ( l flux(ji,jj) ) THEN ! MLE mixing extends below boundary layer1081 IF ( l_flux(ji,jj) ) THEN ! MLE mixing extends below boundary layer 1066 1082 ! Calculate MLE flux contribution from surface fluxes 1067 DO jk = 1, ibld(ji,jj)1083 DO jk = 1, nbld(ji,jj) 1068 1084 znd = gdepw(ji,jj,jk,Kmm) / MAX(zhbl(ji,jj),epsln) 1069 1085 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) - ( swth0(ji,jj) - zrad0(ji,jj) + zradh(ji,jj) ) * ( 1.0 - znd ) … … 1092 1108 IF(narea==nn_narea_db) THEN 1093 1109 ji=iloc_db; jj=jloc_db 1094 jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )1110 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 1095 1111 WRITE(narea+100,'(a)') ' After including FK diffusivity & non-local terms' 1096 1112 WRITE(narea+100,'(a,*(g11.3))') ' zdiffut[imld-1..ibld+2] =', ( zdiffut(ji,jj,jk), jk=jl,jm ) … … 1134 1150 IF(narea==nn_narea_db) THEN 1135 1151 ji=iloc_db; jj=jloc_db 1136 jl = imld(ji,jj) - 1; jm = MIN(ibld(ji,jj) + 2, mbkt(ji,jj) )1152 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 1137 1153 WRITE(narea+100,'(a)') ' Final diffusivity & viscosity, & non-local terms' 1138 1154 WRITE(narea+100,'(a,*(g11.3))') ' p_avt[imld-1..ibld+2] =', ( p_avt(ji,jj,jk), jk=jl,jm ) … … 1175 1191 IF ( iom_use("zwbav") ) CALL iom_put( "zwbav", tmask(:,:,1)*swth0 ) ! upward BL-avged turb buoyancy flux 1176 1192 IF ( iom_use("hbl") ) CALL iom_put( "hbl", tmask(:,:,1)*hbl ) ! boundary-layer depth 1177 IF ( iom_use("ibld") ) CALL iom_put( "ibld", tmask(:,:,1)* ibld ) ! boundary-layer max k1193 IF ( iom_use("ibld") ) CALL iom_put( "ibld", tmask(:,:,1)*nbld ) ! boundary-layer max k 1178 1194 IF ( iom_use("zdt_bl") ) CALL iom_put( "zdt_bl", tmask(:,:,1)*zdt_bl ) ! dt at ml base 1179 1195 IF ( iom_use("zds_bl") ) CALL iom_put( "zds_bl", tmask(:,:,1)*zds_bl ) ! ds at ml base … … 1197 1213 IF ( iom_use("zhbl") ) CALL iom_put( "zhbl", tmask(:,:,1)*zhbl ) ! BL depth internal to zdf_osm routine 1198 1214 IF ( iom_use("zhml") ) CALL iom_put( "zhml", tmask(:,:,1)*zhml ) ! ML depth internal to zdf_osm routine 1199 IF ( iom_use("imld") ) CALL iom_put( "imld", tmask(:,:,1)* imld ) ! index for ML depth internal to zdf_osm routine1215 IF ( iom_use("imld") ) CALL iom_put( "imld", tmask(:,:,1)*nmld ) ! index for ML depth internal to zdf_osm routine 1200 1216 IF ( iom_use("jp_ext") ) CALL iom_put( "jp_ext", tmask(:,:,1)*jp_ext ) ! =1 if pycnocline resolved internal to zdf_osm routine 1201 IF ( iom_use("j_ddh") ) CALL iom_put( "j_ddh", tmask(:,:,1)* j_ddh ) ! index forpyc thicknessh internal to zdf_osm routine1217 IF ( iom_use("j_ddh") ) CALL iom_put( "j_ddh", tmask(:,:,1)*n_ddh ) ! index forpyc thicknessh internal to zdf_osm routine 1202 1218 IF ( iom_use("zshear") ) CALL iom_put( "zshear", tmask(:,:,1)*zshear ) ! shear production of TKE internal to zdf_osm routine 1203 1219 IF ( iom_use("zdh") ) CALL iom_put( "zdh", tmask(:,:,1)*zdh ) ! pyc thicknessh internal to zdf_osm routine … … 1225 1241 END SUBROUTINE zdf_osm 1226 1242 1227 SUBROUTINE zdf_osm_vertical_average( Kbb, Kmm, 1228 & knlev, pt, ps, pb, pu, pv,&1229 & kp_ext, pdt, pds, pdb, pdu,pdv )1243 SUBROUTINE zdf_osm_vertical_average( Kbb, Kmm, knlev, pt, ps, & 1244 & pb, pu, pv, kp_ext, pdt, & 1245 & pds, pdb, pdu, pdv ) 1230 1246 !!--------------------------------------------------------------------- 1231 1247 !! *** ROUTINE zdf_vertical_average *** … … 1298 1314 pu(ji,jj) = pu(ji,jj) / zthick(ji,jj) 1299 1315 pv(ji,jj) = pv(ji,jj) / zthick(ji,jj) 1300 zthermal = rab_n(ji,jj,1,jp_tem) ! ideally use ibld not 1??1316 zthermal = rab_n(ji,jj,1,jp_tem) ! ideally use nbld not 1?? 1301 1317 zbeta = rab_n(ji,jj,1,jp_sal) 1302 1318 pb(ji,jj) = grav * zthermal * pt(ji,jj) - grav * zbeta * ps(ji,jj) … … 1315 1331 pdv(ji,jj) = pv(ji,jj) - ( vv(ji,jj,ibld_ext,Kbb) + vv(ji,jj-1,ibld_ext,Kbb ) ) / & 1316 1332 & MAX(1.0_wp , vmask(ji,jj,ibld_ext ) + vmask(ji,jj-1,ibld_ext ) ) 1317 zthermal = rab_n(ji,jj,1,jp_tem) ! ideally use ibld not 1??1333 zthermal = rab_n(ji,jj,1,jp_tem) ! ideally use nbld not 1?? 1318 1334 zbeta = rab_n(ji,jj,1,jp_sal) 1319 1335 pdb(ji,jj) = grav * zthermal * pdt(ji,jj) - grav * zbeta * pds(ji,jj) … … 1415 1431 END SUBROUTINE zdf_osm_velocity_rotation_3d 1416 1432 1417 SUBROUTINE zdf_osm_osbl_state( Kmm, ldconv, ldshear, k_ddh, pwb_ent, pwb_min, pshear, & 1418 & phbl, phml, pdh, pdb_bl, pdu_bl, pdv_bl, pdb_ml, pdu_ml, pdv_ml ) 1433 SUBROUTINE zdf_osm_osbl_state( Kmm, pwb_ent, pwb_min, pshear, phbl, & 1434 & phml, pdh, pdb_bl, pdu_bl, pdv_bl, & 1435 & pdb_ml, pdu_ml, pdv_ml ) 1419 1436 !!--------------------------------------------------------------------- 1420 1437 !! *** ROUTINE zdf_osm_osbl_state *** … … 1429 1446 !!---------------------------------------------------------------------- 1430 1447 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1431 LOGICAL, DIMENSION(:,:), INTENT( out) :: ldconv ! BL stability flags1432 LOGICAL, DIMENSION(:,:), INTENT( out) :: ldshear ! Shear layers1433 INTEGER, DIMENSION(:,:), INTENT( out) :: k_ddh ! k_ddh=0: active shear layer1434 ! ! k_ddh=1: shear layer not active1435 ! ! k_ddh=2: shear production low1436 1448 REAL(wp), DIMENSION(:,:), INTENT( out) :: pwb_ent ! Buoyancy fluxes at base 1437 1449 REAL(wp), DIMENSION(:,:), INTENT( out) :: pwb_min ! of well-mixed layer … … 1467 1479 ! 1468 1480 ! Initialise INTENT( out) arrays 1469 l dconv(:,:) = .FALSE.1470 l dshear(:,:) = .FALSE.1471 k_ddh(:,:) = 11481 l_conv(:,:) = .FALSE. 1482 l_shear(:,:) = .FALSE. 1483 n_ddh(:,:) = 1 1472 1484 pwb_ent(:,:) = zlarge 1473 1485 pwb_min(:,:) = zlarge 1474 1486 pshear(:,:) = zlarge 1475 1487 ! 1476 ! Determins stability and set flag l dconv1488 ! Determins stability and set flag l_conv 1477 1489 DO_2D( 0, 0, 0, 0 ) 1478 1490 IF ( shol(ji,jj) < 0._wp ) THEN 1479 l dconv(ji,jj) = .TRUE.1491 l_conv(ji,jj) = .TRUE. 1480 1492 ELSE 1481 l dconv(ji,jj) = .FALSE.1493 l_conv(ji,jj) = .FALSE. 1482 1494 ENDIF 1483 1495 END_2D … … 1496 1508 ! 1497 1509 DO_2D( 0, 0, 0, 0 ) 1498 IF ( l dconv(ji,jj) ) THEN1510 IF ( l_conv(ji,jj) ) THEN 1499 1511 IF ( pdb_bl(ji,jj) > 0.0_wp ) THEN 1500 1512 zri_p(ji,jj) = MAX ( SQRT( pdb_bl(ji,jj) * pdh(ji,jj) / MAX( pdu_bl(ji,jj)**2 + pdv_bl(ji,jj)**2, 1e-8_wp ) ) * & … … 1528 1540 #endif 1529 1541 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1530 ! Test ensures k_ddh=0 is not selected. Change to zri_p<27 when !1542 ! Test ensures n_ddh=0 is not selected. Change to zri_p<27 when ! 1531 1543 ! full code available ! 1532 1544 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! … … 1534 1546 IF ( zri_p(ji,jj) < rn_ri_p_thresh .AND. MIN( hu(ji,jj,Kmm), hu(ji-1,jj,Kmm), hv(ji,jj,Kmm), hv(ji,jj-1,Kmm) ) > 100.0_wp ) THEN 1535 1547 ! Growing shear layer 1536 k_ddh(ji,jj) = 01537 l dshear(ji,jj) = .TRUE.1548 n_ddh(ji,jj) = 0 1549 l_shear(ji,jj) = .TRUE. 1538 1550 ELSE 1539 k_ddh(ji,jj) = 11551 n_ddh(ji,jj) = 1 1540 1552 ! IF ( zri_b <= 1.5 .and. pshear(ji,jj) > 0._wp ) THEN 1541 1553 ! Shear production large enough to determine layer charcteristics, but can't maintain a shear layer 1542 l dshear(ji,jj) = .TRUE.1554 l_shear(ji,jj) = .TRUE. 1543 1555 ! ELSE 1544 1556 END IF 1545 1557 ELSE 1546 k_ddh(ji,jj) = 21547 l dshear(ji,jj) = .FALSE.1558 n_ddh(ji,jj) = 2 1559 l_shear(ji,jj) = .FALSE. 1548 1560 END IF 1549 1561 ! Shear production may not be zero, but is small and doesn't determine characteristics of pycnocline 1550 1562 ! pshear(ji,jj) = 0.5 * pshear(ji,jj) 1551 ! l dshear(ji,jj) = .FALSE.1563 ! l_shear(ji,jj) = .FALSE. 1552 1564 ! ENDIF 1553 1565 ELSE ! pdb_bl test, note pshear set to zero 1554 k_ddh(ji,jj) = 21555 l dshear(ji,jj) = .FALSE.1566 n_ddh(ji,jj) = 2 1567 l_shear(ji,jj) = .FALSE. 1556 1568 ENDIF 1557 1569 ENDIF … … 1560 1572 ! Calculate entrainment buoyancy flux due to surface fluxes. 1561 1573 DO_2D( 0, 0, 0, 0 ) 1562 IF ( l dconv(ji,jj) ) THEN1574 IF ( l_conv(ji,jj) ) THEN 1563 1575 zwcor = ABS( ff_t(ji,jj) ) * phbl(ji,jj) + epsln 1564 1576 zrf_conv = TANH( ( swstrc(ji,jj) / zwcor )**0.69_wp ) … … 1587 1599 ! 1588 1600 DO_2D( 0, 0, 0, 0 ) 1589 IF ( l dshear(ji,jj) ) THEN1590 IF ( l dconv(ji,jj) ) THEN1601 IF ( l_shear(ji,jj) ) THEN 1602 IF ( l_conv(ji,jj) ) THEN 1591 1603 ! Unstable OSBL 1592 1604 zwb_shr = -1.0_wp * za_wb_s * zri_b(ji,jj) * pshear(ji,jj) … … 1597 1609 END IF 1598 1610 #endif 1599 IF ( k_ddh(ji,jj) == 0 ) THEN1611 IF ( n_ddh(ji,jj) == 0 ) THEN 1600 1612 ! Developing shear layer, additional shear production possible. 1601 1613 … … 1608 1620 #ifdef key_osm_debug 1609 1621 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 1610 WRITE(narea+100,'(3(a,g11.3))')'zdf_osm_osbl_state k_ddh(ji,jj) == 0:zwb_shr=',zwb_shr, &1622 WRITE(narea+100,'(3(a,g11.3))')'zdf_osm_osbl_state j_ddh(ji,jj) == 0:zwb_shr=',zwb_shr, & 1611 1623 & ' zshear=',pshear(ji,jj),' zshear_u=', pshear_u 1612 1624 FLUSH(narea+100) … … 1616 1628 pwb_ent(ji,jj) = pwb_ent(ji,jj) + zwb_shr 1617 1629 ! pwb_min(ji,jj) = pwb_ent(ji,jj) + pdh(ji,jj) / phbl(ji,jj) * zwb0(ji,jj) 1618 ELSE ! IF ( l dconv ) THEN - ENDIF1630 ELSE ! IF ( l_conv ) THEN - ENDIF 1619 1631 ! Stable OSBL - shear production not coded for first attempt. 1620 ENDIF ! l dconv1621 END IF ! l dshear1622 IF ( l dconv(ji,jj) ) THEN1632 ENDIF ! l_conv 1633 END IF ! l_shear 1634 IF ( l_conv(ji,jj) ) THEN 1623 1635 ! Unstable OSBL 1624 1636 pwb_min(ji,jj) = pwb_ent(ji,jj) + pdh(ji,jj) / phbl(ji,jj) * 2.0_wp * swbav(ji,jj) 1625 END IF ! l dconv1637 END IF ! l_conv 1626 1638 #ifdef key_osm_debug 1627 1639 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN … … 1643 1655 !! ** Purpose : Calculates the gradients below the OSBL 1644 1656 !! 1645 !! ** Method : Uses ibld and ibld_ext to determine levels to calculate the gradient.1657 !! ** Method : Uses nbld and ibld_ext to determine levels to calculate the gradient. 1646 1658 !! 1647 1659 !!---------------------------------------------------------------------- … … 1664 1676 DO_2D( 0, 0, 0, 0 ) 1665 1677 IF ( kbase(ji,jj)+1 < mbkt(ji,jj) ) THEN 1666 zthermal = rab_n(ji,jj,1,jp_tem) ! Ideally use ibld not 1??1678 zthermal = rab_n(ji,jj,1,jp_tem) ! Ideally use nbld not 1?? 1667 1679 zbeta = rab_n(ji,jj,1,jp_sal) 1668 1680 jkb = kbase(ji,jj) … … 1682 1694 END SUBROUTINE zdf_osm_external_gradients 1683 1695 1684 SUBROUTINE zdf_osm_calculate_dhdt( ldconv, ldshear, k_ddh, pdhdt, phbl, pdh, pwb_ent, pwb_min, & 1685 & pdb_bl, pdbdz_bl_ext, pdb_ml, pwb_fk_b, pwb_fk, pvel_mle ) 1696 SUBROUTINE zdf_osm_calculate_dhdt( pdhdt, phbl, pdh, pwb_ent, pwb_min, & 1697 & pdb_bl, pdbdz_bl_ext, pdb_ml, pwb_fk_b, pwb_fk, & 1698 & pvel_mle ) 1686 1699 !!--------------------------------------------------------------------- 1687 1700 !! *** ROUTINE zdf_osm_calculate_dhdt *** … … 1692 1705 !! 1693 1706 !!---------------------------------------------------------------------- 1694 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags1695 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldshear ! Shear layers1696 INTEGER, DIMENSION(:,:), INTENT(in ) :: k_ddh ! k_ddh=0: active shear layer1697 ! ! k_ddh=1: shear layer not active1698 ! ! k_ddh=2: shear production low1699 1707 REAL(wp), DIMENSION(A2D(0)), INTENT( out) :: pdhdt ! Rate of change of hbl 1700 1708 REAL(wp), DIMENSION(:,:), INTENT(in ) :: phbl ! BL depth … … 1728 1736 DO_2D( 0, 0, 0, 0 ) 1729 1737 ! 1730 IF ( l dshear(ji,jj) ) THEN1738 IF ( l_shear(ji,jj) ) THEN 1731 1739 ! 1732 IF ( l dconv(ji,jj) ) THEN ! Convective1740 IF ( l_conv(ji,jj) ) THEN ! Convective 1733 1741 ! 1734 1742 IF ( ln_osm_mle ) THEN … … 1759 1767 END IF 1760 1768 #endif 1761 IF ( k_ddh(ji,jj) == 1 ) THEN1769 IF ( n_ddh(ji,jj) == 1 ) THEN 1762 1770 IF ( ( swstrc(ji,jj) / svstr(ji,jj) )**3 <= 0.5_wp ) THEN 1763 1771 zari = MIN( 1.5_wp * pdb_bl(ji,jj) / & … … 1780 1788 END IF 1781 1789 #endif 1782 ELSE IF ( k_ddh(ji,jj) == 0 ) THEN ! Growing shear layer1790 ELSE IF ( n_ddh(ji,jj) == 0 ) THEN ! Growing shear layer 1783 1791 zddhdt = -1.0_wp * a_ddh * ( 1.0_wp - 1.6_wp * pdh(ji,jj) / phbl(ji,jj) ) * pwb_ent(ji,jj) / & 1784 1792 & ( zvel_max + MAX( pdb_bl(ji,jj), 1e-15_wp ) ) … … 1786 1794 ELSE 1787 1795 zddhdt = 0.0_wp 1788 ENDIF ! k_ddh1796 ENDIF ! n_ddh 1789 1797 pdhdt(ji,jj) = pdhdt(ji,jj) + zalpha_b * ( 1.0_wp - 0.5_wp * pdh(ji,jj) / phbl(ji,jj) ) * & 1790 1798 & pdb_ml(ji,jj) * MAX( zddhdt, 0.0_wp ) / & … … 1805 1813 ENDIF ! ln_osm_mle 1806 1814 ! 1807 ELSE ! l dconv - Stable1815 ELSE ! l_conv - Stable 1808 1816 ! 1809 1817 pdhdt(ji,jj) = ( 0.06_wp + 0.52_wp * shol(ji,jj) / 2.0_wp ) * svstr(ji,jj)**3 / hbl(ji,jj) + swbav(ji,jj) … … 1816 1824 pdhdt(ji,jj) = MAX( pdhdt(ji,jj), -1.0_wp * hbl(ji,jj) / 5400.0_wp ) 1817 1825 ! 1818 ENDIF ! l dconv1826 ENDIF ! l_conv 1819 1827 ! 1820 ELSE ! l dshear1828 ELSE ! l_shear 1821 1829 ! 1822 IF ( l dconv(ji,jj) ) THEN ! Convective1830 IF ( l_conv(ji,jj) ) THEN ! Convective 1823 1831 ! 1824 1832 IF ( ln_osm_mle ) THEN … … 1860 1868 pdhdt(ji,jj) = MAX( pdhdt(ji,jj), -1.0_wp * hbl(ji,jj) / 5400.0_wp ) 1861 1869 ! 1862 ENDIF ! l dconv1870 ENDIF ! l_conv 1863 1871 ! 1864 ENDIF ! l dshear1872 ENDIF ! l_shear 1865 1873 #ifdef key_osm_debug 1866 1874 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN … … 1881 1889 END SUBROUTINE zdf_osm_calculate_dhdt 1882 1890 1883 SUBROUTINE zdf_osm_timestep_hbl( Kmm, kbld, kmld, ldconv, ldpyc, pdhdt, phbl, phbl_t, pt_bl, ps_bl, pwb_ent, pwb_fk_b ) 1891 SUBROUTINE zdf_osm_timestep_hbl( Kmm, pdhdt, phbl, phbl_t, pt_bl, & 1892 & ps_bl, pwb_ent, pwb_fk_b ) 1884 1893 !!--------------------------------------------------------------------- 1885 1894 !! *** ROUTINE zdf_osm_timestep_hbl *** … … 1894 1903 !!---------------------------------------------------------------------- 1895 1904 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1896 INTEGER, DIMENSION(:,:), INTENT(inout) :: kbld ! BL base layer1897 INTEGER, DIMENSION(:,:), INTENT(in ) :: kmld ! ML base layer1898 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags1899 LOGICAL, DIMENSION(:,:), INTENT(inout) :: ldpyc ! Pycnocline flags1900 1905 REAL(wp), DIMENSION(A2D(0)), INTENT(inout) :: pdhdt ! Rates of change of hbl 1901 1906 REAL(wp), DIMENSION(:,:), INTENT(inout) :: phbl ! BL depth … … 1916 1921 #ifdef key_osm_debug 1917 1922 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 1918 WRITE(narea+100,'(2(a,i7))')'start of zdf_osm_timestep_hbl: old ibld=', kmld(ji,jj),' trial ibld=', kbld(ji,jj)1923 WRITE(narea+100,'(2(a,i7))')'start of zdf_osm_timestep_hbl: old ibld=',nmld(ji,jj),' trial ibld=', nbld(ji,jj) 1919 1924 FLUSH(narea+100) 1920 1925 END IF 1921 1926 #endif 1922 IF ( kbld(ji,jj) - kmld(ji,jj) > 1 ) THEN1927 IF ( nbld(ji,jj) - nmld(ji,jj) > 1 ) THEN 1923 1928 ! 1924 1929 ! If boundary layer changes by more than one level, need to check for stable layers between initial and final depths. 1925 1930 ! 1926 1931 zhbl_s = hbl(ji,jj) 1927 jm = kmld(ji,jj)1932 jm = nmld(ji,jj) 1928 1933 zthermal = rab_n(ji,jj,1,jp_tem) 1929 1934 zbeta = rab_n(ji,jj,1,jp_sal) 1930 1935 ! 1931 IF ( l dconv(ji,jj) ) THEN ! Unstable1936 IF ( l_conv(ji,jj) ) THEN ! Unstable 1932 1937 ! 1933 1938 IF( ln_osm_mle ) THEN … … 1944 1949 END IF 1945 1950 #endif 1946 DO jk = kmld(ji,jj), kbld(ji,jj)1951 DO jk = nmld(ji,jj), nbld(ji,jj) 1947 1952 zdb = MAX( grav * ( zthermal * ( pt_bl(ji,jj) - ts(ji,jj,jm,jp_tem,Kmm) ) - & 1948 1953 & zbeta * ( ps_bl(ji,jj) - ts(ji,jj,jm,jp_sal,Kmm) ) ), 0.0_wp ) + zvel_max … … 1950 1955 IF ( ln_osm_mle ) THEN 1951 1956 zhbl_s = zhbl_s + MIN( rn_Dt * ( ( -1.0_wp * pwb_ent(ji,jj) - 2.0_wp * pwb_fk_b(ji,jj) ) / zdb ) / & 1952 & REAL( kbld(ji,jj) - kmld(ji,jj), KIND=wp ), e3w(ji,jj,jm,Kmm) )1957 & REAL( nbld(ji,jj) - nmld(ji,jj), KIND=wp ), e3w(ji,jj,jm,Kmm) ) 1953 1958 ELSE 1954 1959 zhbl_s = zhbl_s + MIN( rn_Dt * ( -1.0_wp * pwb_ent(ji,jj) / zdb ) / & 1955 & REAL( kbld(ji,jj) - kmld(ji,jj), KIND=wp ), e3w(ji,jj,jm,Kmm) )1960 & REAL( nbld(ji,jj) - nmld(ji,jj), KIND=wp ), e3w(ji,jj,jm,Kmm) ) 1956 1961 ENDIF 1957 1962 ! zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 1958 1963 IF ( zhbl_s >= gdepw(ji,jj,mbkt(ji,jj) + 1,Kmm) ) THEN 1959 1964 zhbl_s = MIN( zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1, Kmm ) - depth_tol ) 1960 l dpyc(ji,jj) = .FALSE.1965 l_pyc(ji,jj) = .FALSE. 1961 1966 ENDIF 1962 1967 IF ( zhbl_s >= gdepw(ji,jj,jm+1,Kmm) ) jm = jm + 1 … … 1964 1969 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 1965 1970 WRITE(narea+100,'(2(a,i7))')' jk=',jk,' jm=', jm 1966 WRITE(narea+100,'(2(a,g11.3),a,l7)')'zdb=',zdb,' zhbl_s=', zhbl_s,' lpyc=',l dpyc(ji,jj)1971 WRITE(narea+100,'(2(a,g11.3),a,l7)')'zdb=',zdb,' zhbl_s=', zhbl_s,' lpyc=',l_pyc(ji,jj) 1967 1972 FLUSH(narea+100) 1968 1973 END IF … … 1970 1975 END DO 1971 1976 hbl(ji,jj) = zhbl_s 1972 kbld(ji,jj) = jm1977 nbld(ji,jj) = jm 1973 1978 ELSE ! Stable 1974 1979 #ifdef key_osm_debug … … 1978 1983 END IF 1979 1984 #endif 1980 DO jk = kmld(ji,jj), kbld(ji,jj)1985 DO jk = nmld(ji,jj), nbld(ji,jj) 1981 1986 zdb = MAX( grav * ( zthermal * ( pt_bl(ji,jj) - ts(ji,jj,jm,jp_tem,Kmm) ) - & 1982 1987 & zbeta * ( ps_bl(ji,jj) - ts(ji,jj,jm,jp_sal,Kmm) ) ), 0.0_wp ) + & … … 1990 1995 & ( 0.725_wp + 0.225_wp * EXP( -7.5_wp * shol(ji,jj) ) ) 1991 1996 pdhdt(ji,jj) = pdhdt(ji,jj) + swbav(ji,jj) 1992 zhbl_s = zhbl_s + MIN( pdhdt(ji,jj) / zdb * rn_Dt / REAL( kbld(ji,jj) - kmld(ji,jj), KIND=wp ), &1997 zhbl_s = zhbl_s + MIN( pdhdt(ji,jj) / zdb * rn_Dt / REAL( nbld(ji,jj) - nmld(ji,jj), KIND=wp ), & 1993 1998 & e3w(ji,jj,jm,Kmm) ) 1994 1999 … … 1996 2001 IF ( zhbl_s >= mbkt(ji,jj) + 1 ) THEN 1997 2002 zhbl_s = MIN( zhbl_s, gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) - depth_tol ) 1998 l dpyc(ji,jj) = .FALSE.2003 l_pyc(ji,jj) = .FALSE. 1999 2004 ENDIF 2000 2005 IF ( zhbl_s >= gdepw(ji,jj,jm,Kmm) ) jm = jm + 1 … … 2002 2007 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 2003 2008 WRITE(narea+100,'(2(a,i7))')' jk=',jk,' jm=', jm 2004 WRITE(narea+100,'(4(a,g11.3),a,l7)')'zdb=',zdb,' shol',shol(ji,jj),' zdhdt',pdhdt(ji,jj),' zhbl_s=', zhbl_s,' lpyc=',l dpyc(ji,jj)2009 WRITE(narea+100,'(4(a,g11.3),a,l7)')'zdb=',zdb,' shol',shol(ji,jj),' zdhdt',pdhdt(ji,jj),' zhbl_s=', zhbl_s,' lpyc=',l_pyc(ji,jj) 2005 2010 FLUSH(narea+100) 2006 2011 END IF 2007 2012 #endif 2008 2013 END DO 2009 ENDIF ! IF ( l dconv )2014 ENDIF ! IF ( l_conv ) 2010 2015 hbl(ji,jj) = MAX( zhbl_s, gdepw(ji,jj,4,Kmm) ) 2011 kbld(ji,jj) = MAX( jm, 4 )2016 nbld(ji,jj) = MAX( jm, 4 ) 2012 2017 ELSE 2013 2018 ! change zero or one model level. 2014 2019 hbl(ji,jj) = MAX( phbl_t(ji,jj), gdepw(ji,jj,4,Kmm) ) 2015 2020 ENDIF 2016 phbl(ji,jj) = gdepw(ji,jj, kbld(ji,jj),Kmm)2021 phbl(ji,jj) = gdepw(ji,jj,nbld(ji,jj),Kmm) 2017 2022 #ifdef key_osm_debug 2018 2023 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 2019 WRITE(narea+100,'(2(a,g11.3),a,i7,/)')'end of zdf_osm_timestep_hbl: hbl=', hbl(ji,jj),' zhbl=', phbl(ji,jj),' ibld=', kbld(ji,jj)2024 WRITE(narea+100,'(2(a,g11.3),a,i7,/)')'end of zdf_osm_timestep_hbl: hbl=', hbl(ji,jj),' zhbl=', phbl(ji,jj),' ibld=', nbld(ji,jj) 2020 2025 FLUSH(narea+100) 2021 2026 END IF … … 2027 2032 END SUBROUTINE zdf_osm_timestep_hbl 2028 2033 2029 SUBROUTINE zdf_osm_pycnocline_thickness( Kmm, kbld, kmld, ldshear, ldconv, k_ddh, pdh, phml, pdhdt, pdb_bl, phbl, pwb_ent, pdbdz_bl_ext, pwb_fk_b ) 2034 SUBROUTINE zdf_osm_pycnocline_thickness( Kmm, pdh, phml, pdhdt, pdb_bl, & 2035 & phbl, pwb_ent, pdbdz_bl_ext, pwb_fk_b ) 2030 2036 !!--------------------------------------------------------------------- 2031 2037 !! *** ROUTINE zdf_osm_pycnocline_thickness *** … … 2041 2047 !!---------------------------------------------------------------------- 2042 2048 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 2043 INTEGER, DIMENSION(:,:), INTENT(in ) :: kbld ! BL base layer2044 INTEGER, DIMENSION(:,:), INTENT(inout) :: kmld ! ML base layer2045 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldshear ! Shear layers2046 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags2047 INTEGER, DIMENSION(:,:), INTENT(in ) :: k_ddh ! k_ddh=0: active shear layer2048 ! ! k_ddh=1: shear layer not active2049 ! ! k_ddh=2: shear production low2050 2049 REAL(wp), DIMENSION(:,:), INTENT(inout) :: pdh ! Pycnocline thickness 2051 2050 REAL(wp), DIMENSION(:,:), INTENT(inout) :: phml ! ML depth … … 2070 2069 DO_2D( 0, 0, 0, 0 ) 2071 2070 ! 2072 IF ( l dshear(ji,jj) ) THEN2071 IF ( l_shear(ji,jj) ) THEN 2073 2072 ! 2074 IF ( l dconv(ji,jj) ) THEN2073 IF ( l_conv(ji,jj) ) THEN 2075 2074 ! 2076 2075 IF ( pdb_bl(ji,jj) > 1e-15_wp ) THEN 2077 IF ( k_ddh(ji,jj) == 0 ) THEN2076 IF ( n_ddh(ji,jj) == 0 ) THEN 2078 2077 zvel_max = ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 2079 2078 ! ddhdt for pycnocline determined in osm_calculate_dhdt … … 2105 2104 END IF 2106 2105 ! 2107 ELSE ! l dconv2106 ELSE ! l_conv 2108 2107 ! Initially shear only for entraining OSBL. Stable code will be needed if extended to stable OSBL 2109 2108 ztau = hbl(ji,jj) / MAX(svstr(ji,jj), epsln) … … 2125 2124 ENDIF 2126 2125 ! 2127 ELSE ! l dshear = .FALSE., calculate ddhdt here2126 ELSE ! l_shear = .FALSE., calculate ddhdt here 2128 2127 ! 2129 IF ( l dconv(ji,jj) ) THEN2128 IF ( l_conv(ji,jj) ) THEN 2130 2129 ! 2131 2130 IF( ln_osm_mle ) THEN … … 2169 2168 IF ( dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref 2170 2169 ! Alan: this hml is never defined or used 2171 ELSE ! IF (l dconv)2170 ELSE ! IF (l_conv) 2172 2171 ! 2173 2172 ztau = hbl(ji,jj) / MAX( svstr(ji,jj), epsln ) … … 2187 2186 IF ( pdhdt(ji,jj) < 0.0_wp .AND. dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref ! Can be a problem with dh>hbl for 2188 2187 ! ! rapid collapse 2189 END IF ! IF (l dconv)2188 END IF ! IF (l_conv) 2190 2189 ! 2191 END IF ! l dshear2190 END IF ! l_shear 2192 2191 ! 2193 2192 hml(ji,jj) = hbl(ji,jj) - dh(ji,jj) 2194 inhml = MAX( INT( dh(ji,jj) / MAX( e3t(ji,jj, kbld(ji,jj)-1,Kmm), 1e-3_wp ) ), 1 )2195 kmld(ji,jj) = MAX( kbld(ji,jj) - inhml, 3 )2196 phml(ji,jj) = gdepw(ji,jj, kmld(ji,jj),Kmm)2193 inhml = MAX( INT( dh(ji,jj) / MAX( e3t(ji,jj,nbld(ji,jj)-1,Kmm), 1e-3_wp ) ), 1 ) 2194 nmld(ji,jj) = MAX( nbld(ji,jj) - inhml, 3 ) 2195 phml(ji,jj) = gdepw(ji,jj,nmld(ji,jj),Kmm) 2197 2196 pdh(ji,jj) = phbl(ji,jj) - phml(ji,jj) 2198 2197 #ifdef key_osm_debug 2199 2198 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 2200 2199 WRITE(narea+100,'(4(a,g11.3),2(a,i7),/,5(a,g11.3),/)') 'end of zdf_osm_pycnocline_thickness:hml=',hml(ji,jj), & 2201 & ' zhml=',phml(ji,jj),' zdh=', pdh(ji,jj), ' dh=', dh(ji,jj), ' imld=', kmld(ji,jj), ' inhml=', inhml, &2200 & ' zhml=',phml(ji,jj),' zdh=', pdh(ji,jj), ' dh=', dh(ji,jj), ' imld=', nmld(ji,jj), ' inhml=', inhml, & 2202 2201 & 'zvel_max=', zvel_max, ' ztau=', ztau,' zdh_ref=', zdh_ref, ' zar=', zari, ' zddhdt=', zddhdt 2203 2202 FLUSH(narea+100) … … 2211 2210 END SUBROUTINE zdf_osm_pycnocline_thickness 2212 2211 2213 SUBROUTINE zdf_osm_pycnocline_buoyancy_profiles( Kmm, kbld, kp_ext, ldconv, ldpyc, pdbdz, palpha, pdh, pdb_bl, phbl, pdbdz_bl_ext, phml, pdb_ml, pdhdt ) 2212 SUBROUTINE zdf_osm_pycnocline_buoyancy_profiles( Kmm, kp_ext, pdbdz, palpha, pdh, & 2213 & pdb_bl, phbl, pdbdz_bl_ext, phml, pdb_ml, & 2214 & pdhdt ) 2214 2215 !!--------------------------------------------------------------------- 2215 2216 !! *** ROUTINE zdf_osm_pycnocline_buoyancy_profiles *** … … 2221 2222 !!---------------------------------------------------------------------- 2222 2223 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 2223 INTEGER, DIMENSION(:,:), INTENT(in ) :: kbld ! BL base layer2224 2224 INTEGER, DIMENSION(:,:), INTENT(in ) :: kp_ext ! External-level offsets 2225 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags2226 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldpyc ! Pycnocline flags2227 2225 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pdbdz ! Gradients in the pycnocline 2228 2226 REAL(wp), DIMENSION(:,:), INTENT(inout) :: palpha … … 2248 2246 DO_2D( 0, 0, 0, 0 ) 2249 2247 ! 2250 IF ( kbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN2248 IF ( nbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN 2251 2249 ! 2252 IF ( l dconv(ji,jj) ) THEN ! Convective conditions2250 IF ( l_conv(ji,jj) ) THEN ! Convective conditions 2253 2251 ! 2254 IF ( l dpyc(ji,jj) ) THEN2252 IF ( l_pyc(ji,jj) ) THEN 2255 2253 ! 2256 2254 zzeta_m = 0.1_wp + 0.3_wp / ( 1.0_wp + EXP( -3.5_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) ) … … 2268 2266 zbgrad = palpha(ji,jj) * pdb_ml(ji,jj) * ztmp + pdbdz_bl_ext(ji,jj) 2269 2267 zgamma_b_nd = pdbdz_bl_ext(ji,jj) * pdh(ji,jj) / MAX( pdb_ml(ji,jj), epsln ) 2270 DO jk = 2, kbld(ji,jj)2268 DO jk = 2, nbld(ji,jj) 2271 2269 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) * ztmp 2272 2270 IF ( znd <= zzeta_m ) THEN … … 2300 2298 ztmp = 1.0_wp / MAX( phbl(ji,jj), epsln ) 2301 2299 zbgrad = pdb_bl(ji,jj) * ztmp 2302 DO jk = 2, kbld(ji,jj)2300 DO jk = 2, nbld(ji,jj) 2303 2301 znd = gdepw(ji,jj,jk,Kmm) * ztmp 2304 2302 pdbdz(ji,jj,jk) = zbgrad * EXP( -15.0_wp * ( znd - 0.9_wp )**2 ) … … 2307 2305 ztmp = 1.0_wp / MAX( pdh(ji,jj), epsln ) 2308 2306 zbgrad = pdb_bl(ji,jj) * ztmp 2309 DO jk = 2, kbld(ji,jj)2307 DO jk = 2, nbld(ji,jj) 2310 2308 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phml(ji,jj) ) * ztmp 2311 2309 pdbdz(ji,jj,jk) = zbgrad * EXP( -1.75_wp * ( znd + 0.75_wp )**2 ) … … 2323 2321 END IF ! IF (pdhdt >= 0) pdhdt < 0 not considered since pycnocline profile is zero and profile arrays are intialized to zero 2324 2322 ! 2325 END IF ! IF (l dconv)2323 END IF ! IF (l_conv) 2326 2324 ! 2327 END IF ! IF ( kbld(ji,jj) < mbkt(ji,jj) )2325 END IF ! IF ( nbld(ji,jj) < mbkt(ji,jj) ) 2328 2326 ! 2329 2327 END_2D … … 2337 2335 END SUBROUTINE zdf_osm_pycnocline_buoyancy_profiles 2338 2336 2339 SUBROUTINE zdf_osm_diffusivity_viscosity( Kbb, Kmm, kbld, kmld, ldconv, ldshear, ldpyc, ldcoup, k_ddh, pdiffut, pviscos, & 2340 & phbl, phml, pdh, pdhdt, pshear, pb_bl, pu_bl, pv_bl, pb_ml, pu_ml, pv_ml, pwb_ent, & 2341 & pwb_min ) 2337 SUBROUTINE zdf_osm_diffusivity_viscosity( Kbb, Kmm, pdiffut, pviscos, phbl, & 2338 & phml, pdh, pdhdt, pshear, pb_bl, & 2339 & pu_bl, pv_bl, pb_ml, pu_ml, pv_ml, & 2340 & pwb_ent, pwb_min ) 2342 2341 !!--------------------------------------------------------------------- 2343 2342 !! *** ROUTINE zdf_osm_diffusivity_viscosity *** … … 2350 2349 !!---------------------------------------------------------------------- 2351 2350 INTEGER, INTENT(in ) :: Kbb, Kmm ! Ocean time-level indices 2352 INTEGER, DIMENSION(:,:), INTENT(in ) :: kbld ! BL base layer2353 INTEGER, DIMENSION(:,:), INTENT(in ) :: kmld ! ML base layer2354 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags2355 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldshear ! Shear layers2356 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldpyc ! Pycnocline flags2357 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldcoup ! Coupling to bottom2358 INTEGER, DIMENSION(:,:), INTENT(in ) :: k_ddh ! Type of shear layer2359 2351 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pdiffut ! t-diffusivity 2360 2352 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pviscos ! Viscosity … … 2398 2390 ! 2399 2391 DO_2D( 0, 0, 0, 0 ) 2400 IF ( l dconv(ji,jj) ) THEN2392 IF ( l_conv(ji,jj) ) THEN 2401 2393 ! 2402 2394 zvel_sc_pyc = ( 0.15_wp * svstr(ji,jj)**3 + swstrc(ji,jj)**3 + 4.25_wp * pshear(ji,jj) * phbl(ji,jj) )**pthird … … 2415 2407 #endif 2416 2408 ! 2417 IF ( l dpyc(ji,jj) ) THEN2409 IF ( l_pyc(ji,jj) ) THEN 2418 2410 zdifpyc_n_sc(ji,jj) = rn_dif_pyc * zvel_sc_ml * pdh(ji,jj) 2419 2411 zvispyc_n_sc(ji,jj) = 0.09_wp * zvel_sc_pyc * ( 1.0_wp - phbl(ji,jj) / pdh(ji,jj) )**2 * & … … 2428 2420 #endif 2429 2421 ! 2430 IF ( l dshear(ji,jj) .AND. k_ddh(ji,jj) /= 2 ) THEN2422 IF ( l_shear(ji,jj) .AND. n_ddh(ji,jj) /= 2 ) THEN 2431 2423 ztmp = rn_vispyc_shr * ( pshear(ji,jj) * phbl(ji,jj) )**pthird * phbl(ji,jj) 2432 2424 zdifpyc_n_sc(ji,jj) = zdifpyc_n_sc(ji,jj) + ztmp … … 2471 2463 zvispyc_n_sc(ji,jj) = rn_vis_pyc * zvel_sc_ml * pdh(ji,jj) ! ag 19/03 2472 2464 zvispyc_s_sc(ji,jj) = 0.0_wp ! ag 19/03 2473 IF(l dcoup(ji,jj) ) THEN ! ag 19/032465 IF(l_coup(ji,jj) ) THEN ! ag 19/03 2474 2466 ! code from SUBROUTINE tke_tke zdftke.F90; uses bottom drag velocity rCdU_bot(ji,jj) = -Cd|ub| 2475 2467 ! already calculated at T-points in SUBROUTINE zdf_drg from zdfdrg.F90 … … 2535 2527 ! 2536 2528 DO_2D( 0, 0, 0, 0 ) 2537 IF ( l dconv(ji,jj) ) THEN2538 DO jk = 2, kmld(ji,jj) ! Mixed layer diffusivity2529 IF ( l_conv(ji,jj) ) THEN 2530 DO jk = 2, nmld(ji,jj) ! Mixed layer diffusivity 2539 2531 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2540 2532 pdiffut(ji,jj,jk) = zdifml_sc(ji,jj) * zznd_ml * ( 1.0_wp - zbeta_d_sc(ji,jj) * zznd_ml )**1.5 … … 2545 2537 ! Coupling to bottom 2546 2538 ! 2547 IF ( l dcoup(ji,jj) ) THEN ! ag 19/032548 DO jk = mbkt(ji,jj), kmld(ji,jj), -1 ! ag 19/032539 IF ( l_coup(ji,jj) ) THEN ! ag 19/03 2540 DO jk = mbkt(ji,jj), nmld(ji,jj), -1 ! ag 19/03 2549 2541 zz_b = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) ) ! ag 19/03 2550 2542 pviscos(ji,jj,jk) = zb_coup(ji,jj) * zz_b + zc_coup_vis(ji,jj) * zz_b**2 ! ag 19/03 … … 2553 2545 ENDIF ! ag 19/03 2554 2546 ! Pycnocline 2555 IF ( l dpyc(ji,jj) ) THEN2547 IF ( l_pyc(ji,jj) ) THEN 2556 2548 ! Diffusivity and viscosity profiles in the pycnocline given by 2557 ! cubic polynomial. Note, if l dpyc TRUE can't be coupled to seabed.2549 ! cubic polynomial. Note, if l_pyc TRUE can't be coupled to seabed. 2558 2550 za_cubic = 0.5_wp 2559 2551 zb_d_cubic = -1.75_wp * zdifpyc_s_sc(ji,jj) / zdifpyc_n_sc(ji,jj) … … 2568 2560 zd_v_cubic = zd_v_cubic - zb_v_cubic - 2.0_wp * ( 1.0_wp - za_cubic - zb_v_cubic ) 2569 2561 zc_v_cubic = 1.0_wp - za_cubic - zb_v_cubic - zd_v_cubic 2570 DO jk = kmld(ji,jj) , kbld(ji,jj)2562 DO jk = nmld(ji,jj) , nbld(ji,jj) 2571 2563 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / MAX(pdh(ji,jj), 1.0e-6_wp ) 2572 2564 ztmp = ( 1.75_wp * zznd_pyc - 0.15_wp * zznd_pyc**2 - 0.2_wp * zznd_pyc**3 ) … … 2581 2573 END DO 2582 2574 ! IF ( pdhdt(ji,jj) > 0._wp ) THEN 2583 ! zdiffut(ji,jj, ibld(ji,jj)+1) = MAX( 0.5 * pdhdt(ji,jj) * e3w(ji,jj,ibld(ji,jj)+1,Kmm), 1.0e-6 )2584 ! zviscos(ji,jj, ibld(ji,jj)+1) = MAX( 0.5 * pdhdt(ji,jj) * e3w(ji,jj,ibld(ji,jj)+1,Kmm), 1.0e-6 )2575 ! zdiffut(ji,jj,nbld(ji,jj)+1) = MAX( 0.5 * pdhdt(ji,jj) * e3w(ji,jj,nbld(ji,jj)+1,Kmm), 1.0e-6 ) 2576 ! zviscos(ji,jj,nbld(ji,jj)+1) = MAX( 0.5 * pdhdt(ji,jj) * e3w(ji,jj,nbld(ji,jj)+1,Kmm), 1.0e-6 ) 2585 2577 ! ELSE 2586 ! zdiffut(ji,jj, ibld(ji,jj)) = 0._wp2587 ! zviscos(ji,jj, ibld(ji,jj)) = 0._wp2578 ! zdiffut(ji,jj,nbld(ji,jj)) = 0._wp 2579 ! zviscos(ji,jj,nbld(ji,jj)) = 0._wp 2588 2580 ! ENDIF 2589 2581 ENDIF 2590 2582 ELSE 2591 2583 ! Stable conditions 2592 DO jk = 2, kbld(ji,jj)2584 DO jk = 2, nbld(ji,jj) 2593 2585 zznd_ml = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 2594 2586 pdiffut(ji,jj,jk) = 0.75_wp * zdifml_sc(ji,jj) * zznd_ml * ( 1.0_wp - zznd_ml )**1.5_wp … … 2597 2589 ! 2598 2590 IF ( pdhdt(ji,jj) > 0.0_wp ) THEN 2599 pdiffut(ji,jj, kbld(ji,jj)) = MAX( pdhdt(ji,jj), 1.0e-6_wp) * e3w(ji, jj, kbld(ji,jj), Kmm)2600 pviscos(ji,jj, kbld(ji,jj)) = pdiffut(ji,jj,kbld(ji,jj))2591 pdiffut(ji,jj,nbld(ji,jj)) = MAX( pdhdt(ji,jj), 1.0e-6_wp) * e3w(ji, jj, nbld(ji,jj), Kmm) 2592 pviscos(ji,jj,nbld(ji,jj)) = pdiffut(ji,jj,nbld(ji,jj)) 2601 2593 ENDIF 2602 ENDIF ! End if ( l dconv )2594 ENDIF ! End if ( l_conv ) 2603 2595 ! 2604 2596 END_2D … … 2608 2600 END SUBROUTINE zdf_osm_diffusivity_viscosity 2609 2601 2610 SUBROUTINE zdf_osm_fgr_terms( Kmm, kbld, kmld, kp_ext, ldconv, ldpyc, k_ddh, phbl, phml, pdh, pdhdt, pshear, & 2611 & pdt_bl, pds_bl, pdb_bl, pdu_bl, pdv_bl, pdt_ml, pds_ml, pdb_ml, pdu_ml, pdv_ml, & 2612 & pdtdz_bl_ext, pdsdz_bl_ext, pdbdz_pyc, palpha_pyc, pdiffut, pviscos ) 2602 SUBROUTINE zdf_osm_fgr_terms( Kmm, kp_ext, phbl, phml, pdh, & 2603 & pdhdt, pshear, pdt_bl, pds_bl, pdb_bl, & 2604 & pdu_bl, pdv_bl, pdt_ml, pds_ml, pdb_ml, & 2605 & pdu_ml, pdv_ml, pdtdz_bl_ext, pdsdz_bl_ext, pdbdz_pyc, & 2606 & palpha_pyc, pdiffut, pviscos ) 2613 2607 !!--------------------------------------------------------------------- 2614 2608 !! *** ROUTINE zdf_osm_fgr_terms *** … … 2620 2614 !!---------------------------------------------------------------------- 2621 2615 INTEGER, INTENT(in ) :: Kmm ! Time-level index 2622 INTEGER, DIMENSION(:,:), INTENT(in ) :: kbld ! BL base layer2623 INTEGER, DIMENSION(:,:), INTENT(in ) :: kmld ! ML base layer2624 2616 INTEGER, DIMENSION(:,:), INTENT(in ) :: kp_ext ! Offset for external level 2625 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags2626 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldpyc ! Pycnocline flags2627 INTEGER, DIMENSION(:,:), INTENT(in ) :: k_ddh ! Type of shear layer2628 2617 REAL(wp), DIMENSION(:,:), INTENT(in ) :: phbl ! BL depth 2629 2618 REAL(wp), DIMENSION(:,:), INTENT(in ) :: phml ! ML depth … … 2687 2676 jkm_mld = 0 2688 2677 DO_2D( 0, 0, 0, 0 ) 2689 IF ( kbld(ji,jj) > jkm_bld ) jkm_bld = kbld(ji,jj)2690 IF ( kmld(ji,jj) < jkf_mld ) jkf_mld = kmld(ji,jj)2691 IF ( kmld(ji,jj) > jkm_mld ) jkm_mld = kmld(ji,jj)2678 IF ( nbld(ji,jj) > jkm_bld ) jkm_bld = nbld(ji,jj) 2679 IF ( nmld(ji,jj) < jkf_mld ) jkf_mld = nmld(ji,jj) 2680 IF ( nmld(ji,jj) > jkm_mld ) jkm_mld = nmld(ji,jj) 2692 2681 END_2D 2693 2682 ! 2694 2683 ! Stokes term in scalar flux, flux-gradient relationship 2695 2684 ! ------------------------------------------------------ 2696 WHERE ( l dconv(A2D(0)) )2685 WHERE ( l_conv(A2D(0)) ) 2697 2686 zsc_wth_1(:,:) = swstrl(A2D(0))**3 * swth0(A2D(0)) / ( svstr(A2D(0))**3 + 0.5_wp * swstrc(A2D(0))**3 + epsln ) 2698 2687 zsc_ws_1(:,:) = swstrl(A2D(0))**3 * sws0(A2D(0)) / ( svstr(A2D(0))**3 + 0.5_wp * swstrc(A2D(0))**3 + epsln ) … … 2702 2691 ENDWHERE 2703 2692 DO_3D( 0, 0, 0, 0, 2, MAX( jkm_mld, jkm_bld ) ) 2704 IF ( l dconv(ji,jj) ) THEN2705 IF ( jk <= kmld(ji,jj) ) THEN2693 IF ( l_conv(ji,jj) ) THEN 2694 IF ( jk <= nmld(ji,jj) ) THEN 2706 2695 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2707 2696 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 1.35_wp * EXP( -1.0_wp * zznd_d ) * & … … 2711 2700 END IF 2712 2701 ELSE ! Stable conditions 2713 IF ( jk <= kbld(ji,jj) ) THEN2702 IF ( jk <= nbld(ji,jj) ) THEN 2714 2703 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2715 2704 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 2.15_wp * EXP( -0.85_wp * zznd_d ) * & … … 2718 2707 & ( 1.0_wp - EXP( -4.0_wp * zznd_d ) ) * zsc_ws_1(ji,jj) 2719 2708 END IF 2720 END IF ! Check on l dconv2709 END IF ! Check on l_conv 2721 2710 END_3D 2722 2711 ! … … 2729 2718 ! svstr since term needs to go to zero as swstrl goes to zero) 2730 2719 ! --------------------------------------------------------------------- 2731 WHERE ( l dconv(A2D(0)) )2720 WHERE ( l_conv(A2D(0)) ) 2732 2721 zsc_uw_1(:,:) = ( swstrl(A2D(0))**3 + 0.5_wp * swstrc(A2D(0))**3 )**pthird * sustke(A2D(0)) / & 2733 2722 & MAX( ( 1.0_wp - 1.0_wp * 6.5_wp * sla(A2D(0))**( 8.0_wp / 3.0_wp ) ), 0.2_wp ) … … 2742 2731 ENDWHERE 2743 2732 DO_3D( 0, 0, 0, 0, 2, MAX( jkm_mld, jkm_bld ) ) 2744 IF ( l dconv(ji,jj) ) THEN2745 IF ( jk <= kmld(ji,jj) ) THEN2733 IF ( l_conv(ji,jj) ) THEN 2734 IF ( jk <= nmld(ji,jj) ) THEN 2746 2735 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2747 2736 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + ( -0.05_wp * EXP( -0.4_wp * zznd_d ) * zsc_uw_1(ji,jj) + & … … 2752 2741 END IF 2753 2742 ELSE ! Stable conditions 2754 IF ( jk <= kbld(ji,jj) ) THEN ! Corrected to ibld2743 IF ( jk <= nbld(ji,jj) ) THEN ! Corrected to nbld 2755 2744 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2756 2745 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) - 0.75_wp * 1.3_wp * EXP( -0.5_wp * zznd_d ) * & … … 2762 2751 IF(narea==nn_narea_db) THEN 2763 2752 ji=iloc_db; jj=jloc_db 2764 jl = kmld(ji,jj) - 1; jm = MIN(kbld(ji,jj) + 2, mbkt(ji,jj) )2753 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 2765 2754 WRITE(narea+100,'(a,g11.3)')'Stokes contrib to ghamt/s: zsc_wth_1=',zsc_wth_1(ji,jj), ' zsc_ws_1=',zsc_ws_1(ji,jj) 2766 2755 WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm ) 2767 2756 WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm ) 2768 IF( l dconv(ji,jj) ) THEN2757 IF( l_conv(ji,jj) ) THEN 2769 2758 WRITE(narea+100,'(3(a,g11.3))')'Stokes contrib to ghamu/v: zsc_uw_1=',zsc_uw_1(ji,jj), ' zsc_vw_1=',zsc_vw_1(ji,jj), & 2770 2759 &' zsc_uw_2=',zsc_uw_2(ji,jj) … … 2782 2771 ! (X0.3) and pressure (X0.5)] 2783 2772 ! ---------------------------------------------------------------------- 2784 WHERE ( l dconv(A2D(0)) )2773 WHERE ( l_conv(A2D(0)) ) 2785 2774 zsc_wth_1(:,:) = swbav(A2D(0)) * swth0(A2D(0)) * ( 1.0_wp + EXP( 0.2_wp * shol(A2D(0)) ) ) * phml(A2D(0)) / & 2786 2775 & ( svstr(A2D(0))**3 + 0.5_wp * swstrc(A2D(0))**3 + epsln ) … … 2792 2781 ENDWHERE 2793 2782 DO_3D( 0, 0, 0, 0, 2, MAX( jkm_mld, jkm_bld ) ) 2794 IF ( l dconv(ji,jj) ) THEN2795 IF ( jk <= kmld(ji,jj) ) THEN2783 IF ( l_conv(ji,jj) ) THEN 2784 IF ( jk <= nmld(ji,jj) ) THEN 2796 2785 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2797 2786 ! Calculate turbulent time scale … … 2806 2795 END IF 2807 2796 ELSE ! Stable conditions 2808 IF ( jk <= kbld(ji,jj) ) THEN2797 IF ( jk <= nbld(ji,jj) ) THEN 2809 2798 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + zsc_wth_1(ji,jj) 2810 2799 ghams(ji,jj,jk) = ghams(ji,jj,jk) + zsc_ws_1(ji,jj) … … 2813 2802 END_3D 2814 2803 DO_2D( 0, 0, 0, 0 ) 2815 IF ( l dconv(ji,jj) .AND. ldpyc(ji,jj) ) THEN2804 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) ) THEN 2816 2805 ztau_sc_u(ji,jj) = phml(ji,jj) / ( svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird * & 2817 2806 & ( 1.4_wp - 0.4_wp / ( 1.0_wp + EXP( -3.5_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) )**1.5_wp ) … … 2841 2830 END_2D 2842 2831 DO_3D( 0, 0, 0, 0, 2, jkm_bld ) 2843 IF ( l dconv(ji,jj) .AND. ldpyc(ji,jj) .AND. ( jk <= kbld(ji,jj) ) ) THEN2832 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2844 2833 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2845 2834 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) - & … … 2852 2841 END IF 2853 2842 END_3D 2854 jl = kmld(ji,jj) - 1; jm = MIN(kbld(ji,jj) + 2, mbkt(ji,jj) )2843 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 2855 2844 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 2856 2845 WRITE(narea+100,'(3(a,g11.3))')'lpyc= lconv=T: ztau_sc_u=',ztau_sc_u(ji,jj),' zwth_ent=',zwth_ent(ji,jj), & … … 2862 2851 END IF 2863 2852 DO_3D( 0, 0, 0, 0, 2, jkm_bld ) 2864 IF ( l dconv(ji,jj) .AND. ldpyc(ji,jj) .AND. ( jk <= kbld(ji,jj) ) ) THEN2853 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2865 2854 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2866 2855 #endif 2867 IF ( dh(ji,jj) < 0.2_wp * hbl(ji,jj) .AND. kbld(ji,jj) - kmld(ji,jj) > 3 ) THEN2856 IF ( dh(ji,jj) < 0.2_wp * hbl(ji,jj) .AND. nbld(ji,jj) - nmld(ji,jj) > 3 ) THEN 2868 2857 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.05_wp * zwt_pyc_sc_1(ji,jj) * & 2869 2858 & EXP( -0.25_wp * ( zznd_pyc / zzeta_pyc(ji,jj) )**2 ) * & … … 2882 2871 ! 2883 2872 zsc_vw_1(:,:) = 0.0_wp 2884 WHERE ( l dconv(A2D(0)) )2873 WHERE ( l_conv(A2D(0)) ) 2885 2874 zsc_uw_1(:,:) = -1.0_wp * swb0(A2D(0)) * sustar(A2D(0))**2 * phml(A2D(0)) / & 2886 2875 & ( svstr(A2D(0))**3 + 0.5_wp * swstrc(A2D(0))**3 + epsln ) … … 2891 2880 ENDWHERE 2892 2881 DO_3D( 0, 0, 0, 0, 2, MAX( jkm_mld, jkm_bld ) ) 2893 IF ( l dconv(ji,jj) ) THEN2894 IF ( jk <= kmld(ji,jj) ) THEN2882 IF ( l_conv(ji,jj) ) THEN 2883 IF ( jk <= nmld(ji,jj) ) THEN 2895 2884 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2896 2885 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + 0.3_wp * 0.5_wp * & … … 2900 2889 END IF 2901 2890 ELSE ! Stable conditions 2902 IF ( jk <= kbld(ji,jj) ) THEN2891 IF ( jk <= nbld(ji,jj) ) THEN 2903 2892 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + zsc_uw_1(ji,jj) 2904 2893 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + zsc_vw_1(ji,jj) … … 2908 2897 ! 2909 2898 DO_2D( 0, 0, 0, 0 ) 2910 IF ( l dconv(ji,jj) .AND. ldpyc(ji,jj) ) THEN2911 IF ( k_ddh(ji,jj) == 0 ) THEN2899 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) ) THEN 2900 IF ( n_ddh(ji,jj) == 0 ) THEN 2912 2901 ! Place holding code. Parametrization needs checking for these conditions. 2913 2902 zomega = ( 0.15_wp * swstrl(ji,jj)**3 + swstrc(ji,jj)**3 + 4.75_wp * ( pshear(ji,jj) * phbl(ji,jj) ) )**pthird … … 2927 2916 END_2D 2928 2917 DO_3D( 0, 0, 0, 0, jkf_mld, jkm_bld ) ! Need ztau_sc_u to be available. Change to array. 2929 IF ( l dconv(ji,jj) .AND. ldpyc(ji,jj) .AND. ( jk >= kmld(ji,jj) ) .AND. ( jk <= kbld(ji,jj) ) ) THEN2918 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) .AND. ( jk >= nmld(ji,jj) ) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2930 2919 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2931 2920 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) - 0.045_wp * ( ztau_sc_u(ji,jj)**2 ) * zuw_bse(ji,jj) * & … … 2935 2924 & ( zc_cubic(ji,jj) * zznd_pyc**2 + zd_cubic(ji,jj) * zznd_pyc**3 ) * & 2936 2925 & ( 0.75_wp + 0.25_wp * zznd_pyc )**2 * pdbdz_pyc(ji,jj,jk) 2937 END IF ! l dconv .AND. ldpyc2926 END IF ! l_conv .AND. l_pyc 2938 2927 END_3D 2939 2928 ! … … 2941 2930 IF(narea==nn_narea_db) THEN 2942 2931 ji=iloc_db; jj=jloc_db 2943 jl = kmld(ji,jj) - 1; jm = MIN(kbld(ji,jj) + 2, mbkt(ji,jj) )2932 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 2944 2933 WRITE(narea+100,'(2(a,g11.3))')'Stokes + buoy + pyc contribs to ghamt/s: zsc_wth_1=',zsc_wth_1(ji,jj), ' zsc_ws_1=',zsc_ws_1(ji,jj) 2945 2934 WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm ) 2946 2935 WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm ) 2947 IF( l dconv(ji,jj) ) THEN2936 IF( l_conv(ji,jj) ) THEN 2948 2937 WRITE(narea+100,'(3(a,g11.3))')'Stokes + buoy + pyc contribs to ghamu/v: zsc_uw_1=',zsc_uw_1(ji,jj), ' zsc_vw_1=',zsc_vw_1(ji,jj), & 2949 2938 &' zsc_uw_2=',zsc_uw_2(ji,jj) … … 2966 2955 ! (X0.3) ] 2967 2956 ! ----------------------------------------------------------------------- 2968 WHERE ( l dconv(A2D(0)) )2957 WHERE ( l_conv(A2D(0)) ) 2969 2958 zsc_wth_1(:,:) = swth0(A2D(0)) / ( 1.0_wp - 0.56_wp * EXP( shol(A2D(0)) ) ) 2970 2959 zsc_ws_1(:,:) = sws0(A2D(0)) / ( 1.0_wp - 0.56_wp * EXP( shol(A2D(0)) ) ) 2971 WHERE ( l dpyc(A2D(0)) ) ! Pycnocline scales2960 WHERE ( l_pyc(A2D(0)) ) ! Pycnocline scales 2972 2961 zsc_wth_pyc(:,:) = -0.003_wp * swstrc(A2D(0)) * ( 1.0_wp - pdh(A2D(0)) / phbl(A2D(0)) ) * pdt_ml(A2D(0)) 2973 2962 zsc_ws_pyc(:,:) = -0.003_wp * swstrc(A2D(0)) * ( 1.0_wp - pdh(A2D(0)) / phbl(A2D(0)) ) * pds_ml(A2D(0)) … … 2978 2967 END WHERE 2979 2968 DO_3D( 0, 0, 0, 0, 1, MAX( jkm_mld, jkm_bld ) ) 2980 IF ( l dconv(ji,jj) ) THEN2981 IF ( ( jk > 1 ) .AND. ( jk <= kmld(ji,jj) ) ) THEN2969 IF ( l_conv(ji,jj) ) THEN 2970 IF ( ( jk > 1 ) .AND. ( jk <= nmld(ji,jj) ) ) THEN 2982 2971 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2983 2972 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3_wp * zsc_wth_1(ji,jj) * ( -2.0_wp + 2.75_wp * ( ( 1.0_wp + 0.6_wp * zznd_ml**4 ) - EXP( -6.0_wp * zznd_ml ) ) ) * & … … 2988 2977 ! 2989 2978 ! may need to comment out lpyc block 2990 IF ( l dpyc(ji,jj) .AND. ( jk >= kmld(ji,jj) ) .AND. ( jk <= kbld(ji,jj) ) ) THEN ! Pycnocline2979 IF ( l_pyc(ji,jj) .AND. ( jk >= nmld(ji,jj) ) .AND. ( jk <= nbld(ji,jj) ) ) THEN ! Pycnocline 2991 2980 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2992 2981 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 4.0_wp * zsc_wth_pyc(ji,jj) * ( 0.48_wp - EXP( -1.5_wp * ( zznd_pyc - 0.3_wp )**2 ) ) … … 2995 2984 ELSE 2996 2985 IF( pdhdt(ji,jj) > 0. ) THEN 2997 IF ( ( jk > 1 ) .AND. ( jk <= kbld(ji,jj) ) ) THEN2986 IF ( ( jk > 1 ) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2998 2987 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2999 2988 znd = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) … … 3007 2996 END_3D 3008 2997 ! 3009 WHERE ( l dconv(A2D(0)) )2998 WHERE ( l_conv(A2D(0)) ) 3010 2999 zsc_uw_1(:,:) = sustar(A2D(0))**2 3011 3000 zsc_vw_1(:,:) = ff_t(A2D(0)) * sustke(A2D(0)) * phml(A2D(0)) … … 3019 3008 ENDWHERE 3020 3009 DO_3D( 0, 0, 0, 0, 2, MAX( jkm_mld, jkm_bld ) ) 3021 IF ( l dconv(ji,jj) ) THEN3022 IF ( jk <= kmld(ji,jj) ) THEN3010 IF ( l_conv(ji,jj) ) THEN 3011 IF ( jk <= nmld(ji,jj) ) THEN 3023 3012 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 3024 3013 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) … … 3031 3020 END IF 3032 3021 ELSE 3033 IF ( jk <= kbld(ji,jj) ) THEN3022 IF ( jk <= nbld(ji,jj) ) THEN 3034 3023 znd = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 3035 3024 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) … … 3051 3040 IF(narea==nn_narea_db) THEN 3052 3041 ji=iloc_db; jj=jloc_db 3053 jl = kmld(ji,jj) - 1; jm = MIN(kbld(ji,jj) + 2, mbkt(ji,jj) )3042 jl = nmld(ji,jj) - 1; jm = MIN( nbld(ji,jj) + 2, mbkt(ji,jj) ) 3054 3043 WRITE(narea+100,'(2(a,g11.3))')'Stokes + buoy + pyc + transport contribs to ghamt/s: zsc_wth_1=',zsc_wth_1(ji,jj), ' zsc_ws_1=',zsc_ws_1(ji,jj) 3055 IF (l dpyc(ji,jj)) WRITE(narea+100,'(2(a,g11.3))') 'zsc_wth_pyc=', zsc_wth_pyc(ji,jj), ' zsc_wth_pyc=',zsc_wth_pyc(ji,jj)3044 IF (l_pyc(ji,jj)) WRITE(narea+100,'(2(a,g11.3))') 'zsc_wth_pyc=', zsc_wth_pyc(ji,jj), ' zsc_wth_pyc=',zsc_wth_pyc(ji,jj) 3056 3045 WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm ) 3057 3046 WRITE(narea+100,'(a,*(g11.3))') ' ghams[imld-1..ibld+2] =', ( ghams(ji,jj,jk), jk=jl,jm ) 3058 IF( l dconv(ji,jj) ) THEN3047 IF( l_conv(ji,jj) ) THEN 3059 3048 WRITE(narea+100,'(2(a,g11.3))')'Unstable; transport contrib to ghamu/v: zsc_uw_1=',zsc_uw_1(ji,jj), ' zsc_vw_1=',zsc_vw_1(ji,jj) 3060 3049 ELSE … … 3083 3072 ! of the boundary layer. 3084 3073 DO_3D( 0, 0, 0, 0, 2, jkm_bld ) 3085 IF ( ( .NOT. l dconv(ji,jj) ) .AND. ( jk <= kbld(ji,jj) ) ) THEN3074 IF ( ( .NOT. l_conv(ji,jj) ) .AND. ( jk <= nbld(ji,jj) ) ) THEN 3086 3075 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / phbl(ji,jj) ! ALMG to think about 3087 3076 IF ( znd >= 0.0_wp ) THEN … … 3104 3093 END IF 3105 3094 DO_3D( 0, 0, 0, 0, 2, jkm_bld ) 3106 IF ( l dconv (ji,jj) ) THEN3095 IF ( l_conv (ji,jj) ) THEN 3107 3096 ! Unstable conditions. Shouldn;t be needed with no pycnocline code. 3108 3097 ! zugrad = 0.7 * zdu_ml(ji,jj) / zdh(ji,jj) + 0.3 * zustar(ji,jj)*zustar(ji,jj) / & … … 3114 3103 ! & ( ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird + epsln ) & 3115 3104 ! & )/ (zdh(ji,jj) + epsln ) 3116 ! DO jk = 2, ibld(ji,jj) - 1 + ibld_ext3105 ! DO jk = 2, nbld(ji,jj) - 1 + ibld_ext 3117 3106 ! znd = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / (zdh(ji,jj) + epsln ) - zzeta_v 3118 3107 ! IF ( znd <= 0.0 ) THEN … … 3125 3114 ! END DO 3126 3115 ELSE ! Stable conditions 3127 IF ( kbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN3116 IF ( nbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN 3128 3117 ! Pycnocline profile only defined when depth steady of increasing. 3129 3118 IF ( pdhdt(ji,jj) > 0.0_wp ) THEN ! Depth increasing, or steady. … … 3134 3123 zsgrad = pds_bl(ji,jj) * ztmp 3135 3124 zbgrad = pdb_bl(ji,jj) * ztmp 3136 IF ( jk <= kbld(ji,jj) ) THEN3125 IF ( jk <= nbld(ji,jj) ) THEN 3137 3126 znd = gdepw(ji,jj,jk,Kmm) * ztmp 3138 3127 zdtdz_pyc = ztgrad * EXP( -15.0_wp * ( znd - 0.9_wp )**2 ) … … 3150 3139 zsgrad = pds_bl(ji,jj) * ztmp 3151 3140 zbgrad = pdb_bl(ji,jj) * ztmp 3152 IF ( jk <= kbld(ji,jj) ) THEN3141 IF ( jk <= nbld(ji,jj) ) THEN 3153 3142 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phml(ji,jj) ) * ztmp 3154 3143 zdtdz_pyc = ztgrad * EXP( -1.75_wp * ( znd + 0.75_wp )**2 ) … … 3172 3161 END IF 3173 3162 DO_3D( 0, 0, 0, 0, 2, jkm_bld ) 3174 IF ( .NOT. l dconv (ji,jj) ) THEN3175 IF ( kbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN3163 IF ( .NOT. l_conv (ji,jj) ) THEN 3164 IF ( nbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN 3176 3165 zugrad = 3.25_wp * pdu_bl(ji,jj) / phbl(ji,jj) 3177 3166 zvgrad = 2.75_wp * pdv_bl(ji,jj) / phbl(ji,jj) 3178 IF ( jk <= kbld(ji,jj) ) THEN3167 IF ( jk <= nbld(ji,jj) ) THEN 3179 3168 znd = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 3180 3169 IF ( znd < 1.0 ) THEN … … 3207 3196 ! 3208 3197 DO_2D( 0, 0, 0, 0 ) 3209 ghamt(ji,jj, kbld(ji,jj)) = 0.0_wp3210 ghams(ji,jj, kbld(ji,jj)) = 0.0_wp3211 ghamu(ji,jj, kbld(ji,jj)) = 0.0_wp3212 ghamv(ji,jj, kbld(ji,jj)) = 0.0_wp3198 ghamt(ji,jj,nbld(ji,jj)) = 0.0_wp 3199 ghams(ji,jj,nbld(ji,jj)) = 0.0_wp 3200 ghamu(ji,jj,nbld(ji,jj)) = 0.0_wp 3201 ghamv(ji,jj,nbld(ji,jj)) = 0.0_wp 3213 3202 END_2D 3214 3203 #ifdef key_osm_debug 3215 3204 IF(narea==nn_narea_db) THEN 3216 3205 ji=iloc_db; jj=jloc_db 3217 jl = kmld(ji,jj) - 1; jm = MIN(kbld(ji,jj) + 2, mbkt(ji,jj) )3206 jl = nmld(ji,jj) - 1; jm = MIN(nbld(ji,jj) + 2, mbkt(ji,jj) ) 3218 3207 WRITE(narea+100,'(a)')'Tweak gham[uv] to go to zero near surface, add pycnocline viscosity/diffusivity & set=0 at ibld' 3219 3208 WRITE(narea+100,'(a,*(g11.3))') ' ghamt[imld-1..ibld+2] =', ( ghamt(ji,jj,jk), jk=jl,jm ) … … 3236 3225 END SUBROUTINE zdf_osm_fgr_terms 3237 3226 3238 SUBROUTINE zdf_osm_zmld_horizontal_gradients( Kmm, kbld, pmld, pdtdx, pdtdy, pdsdx, pdsdy, pdbdx_mle, pdbdy_mle, pdbds_mle ) 3227 SUBROUTINE zdf_osm_zmld_horizontal_gradients( Kmm, pmld, pdtdx, pdtdy, pdsdx, & 3228 & pdsdy, pdbdx_mle, pdbdy_mle, pdbds_mle ) 3239 3229 !!---------------------------------------------------------------------- 3240 3230 !! *** ROUTINE zdf_osm_zmld_horizontal_gradients *** … … 3250 3240 !!---------------------------------------------------------------------- 3251 3241 INTEGER, INTENT(in ) :: Kmm ! Time-level index 3252 INTEGER, DIMENSION(:,:), INTENT(in ) :: kbld ! BL base layer3253 3242 REAL(wp), DIMENSION(:,:), INTENT( out) :: pmld ! == Estimated FK BLD used for MLE horizontal gradients == ! 3254 3243 REAL(wp), DIMENSION(:,:), INTENT(inout) :: pdtdx ! Horizontal gradient for Fox-Kemper parametrization … … 3286 3275 END_3D 3287 3276 DO_2D( 1, 1, 1, 1 ) 3288 mld_prof(ji,jj) = MAX( mld_prof(ji,jj), kbld(ji,jj) ) ! Ensure mld_prof .ge. kbld3277 mld_prof(ji,jj) = MAX( mld_prof(ji,jj), nbld(ji,jj) ) ! Ensure mld_prof .ge. nbld 3289 3278 pmld(ji,jj) = gdepw(ji,jj,mld_prof(ji,jj),Kmm) 3290 3279 END_2D … … 3337 3326 END SUBROUTINE zdf_osm_zmld_horizontal_gradients 3338 3327 3339 SUBROUTINE zdf_osm_osbl_state_fk( Kmm, kbld, ldconv, ldpyc, ldflux, ldmle, pwb_fk, pt_mle, ps_mle, pb_mle, phbl, & 3340 & phmle, pwb_ent, pt_bl, ps_bl, pb_bl, pdb_bl, pdbds_mle ) 3328 SUBROUTINE zdf_osm_osbl_state_fk( Kmm, pwb_fk, pt_mle, ps_mle, pb_mle, & 3329 & phbl, phmle, pwb_ent, pt_bl, ps_bl, & 3330 & pb_bl, pdb_bl, pdbds_mle ) 3341 3331 !!--------------------------------------------------------------------- 3342 3332 !! *** ROUTINE zdf_osm_osbl_state_fk *** 3343 3333 !! 3344 3334 !! ** Purpose : Determines the state of the OSBL and MLE layer. Info is 3345 !! returned in the logicals l dpyc, ldflux and ldmle. Used3335 !! returned in the logicals l_pyc, l_flux and ldmle. Used 3346 3336 !! with Fox-Kemper scheme. 3347 !! l dpyc :: determines whether pycnocline flux-grad3337 !! l_pyc :: determines whether pycnocline flux-grad 3348 3338 !! relationship needs to be determined 3349 !! l dflux :: determines whether effects of surface flux3339 !! l_flux :: determines whether effects of surface flux 3350 3340 !! extend below the base of the OSBL 3351 3341 !! ldmle :: determines whether the layer with MLE is … … 3358 3348 ! Outputs 3359 3349 INTEGER, INTENT(in ) :: Kmm ! Time-level index 3360 INTEGER, DIMENSION(:,:), INTENT(in ) :: kbld ! BL base layer3361 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags3362 LOGICAL, DIMENSION(:,:), INTENT(inout) :: ldpyc3363 LOGICAL, DIMENSION(:,:), INTENT(inout) :: ldflux ! Surface flux extends below OSBL into MLE layer3364 LOGICAL, DIMENSION(:,:), INTENT(inout) :: ldmle ! MLE layer increases in thickness3365 3350 REAL(wp), DIMENSION(:,:), INTENT(inout) :: pwb_fk 3366 3351 REAL(wp), DIMENSION(:,:), INTENT(inout) :: pt_mle ! Temperature average over the depth of the MLE layer … … 3397 3382 DO_2D( 0, 0, 0, 0 ) 3398 3383 ! 3399 IF ( l dconv(ji,jj) ) THEN3384 IF ( l_conv(ji,jj) ) THEN 3400 3385 IF ( phmle(ji,jj) > 1.2_wp * phbl(ji,jj) ) THEN 3401 3386 pt_mle(ji,jj) = ( pt_mle(ji,jj) * phmle(ji,jj) - pt_bl(ji,jj) * phbl(ji,jj) ) / ( phmle(ji,jj) - phbl(ji,jj) ) … … 3408 3393 zthermal = rab_n(ji,jj,1,jp_tem) 3409 3394 zbeta = rab_n(ji,jj,1,jp_sal) 3410 DO jk = kbld(ji,jj), mld_prof(ji,jj)3395 DO jk = nbld(ji,jj), mld_prof(ji,jj) 3411 3396 zbuoy = grav * ( zthermal * ts(ji,jj,jk,jp_tem,Kmm) - zbeta * ts(ji,jj,jk,jp_sal,Kmm) ) 3412 3397 zpe_mle_layer = zpe_mle_layer + zbuoy * gdepw(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) … … 3432 3417 DO_2D( 0, 0, 0, 0 ) 3433 3418 ! 3434 IF ( l dconv(ji,jj) ) THEN3419 IF ( l_conv(ji,jj) ) THEN 3435 3420 IF ( -2.0_wp * pwb_fk(ji,jj) / pwb_ent(ji,jj) > 0.5_wp ) THEN 3436 3421 IF ( phmle(ji,jj) > 1.2_wp * phbl(ji,jj) ) THEN ! MLE layer growing 3437 3422 IF ( znd_param (ji,jj) > 100.0_wp ) THEN ! Thermocline present 3438 l dflux(ji,jj) = .FALSE.3439 l dmle(ji,jj) = .FALSE.3423 l_flux(ji,jj) = .FALSE. 3424 l_mle(ji,jj) = .FALSE. 3440 3425 ELSE ! Thermocline not present 3441 l dflux(ji,jj) = .TRUE.3442 l dmle(ji,jj) = .TRUE.3426 l_flux(ji,jj) = .TRUE. 3427 l_mle(ji,jj) = .TRUE. 3443 3428 ENDIF ! znd_param > 100 3444 3429 ! 3445 3430 IF ( pdb_bl(ji,jj) < rn_osm_bl_thresh ) THEN 3446 l dpyc(ji,jj) = .FALSE.3431 l_pyc(ji,jj) = .FALSE. 3447 3432 ELSE 3448 l dpyc(ji,jj) = .TRUE.3433 l_pyc(ji,jj) = .TRUE. 3449 3434 ENDIF 3450 3435 ELSE ! MLE layer restricted to OSBL or just below 3451 3436 IF ( pdb_bl(ji,jj) < rn_osm_bl_thresh ) THEN ! Weak stratification MLE layer can grow 3452 l dpyc(ji,jj) = .FALSE.3453 l dflux(ji,jj) = .TRUE.3454 l dmle(ji,jj) = .TRUE.3437 l_pyc(ji,jj) = .FALSE. 3438 l_flux(ji,jj) = .TRUE. 3439 l_mle(ji,jj) = .TRUE. 3455 3440 ELSE ! Strong stratification 3456 l dpyc(ji,jj) = .TRUE.3457 l dflux(ji,jj) = .FALSE.3458 l dmle(ji,jj) = .FALSE.3441 l_pyc(ji,jj) = .TRUE. 3442 l_flux(ji,jj) = .FALSE. 3443 l_mle(ji,jj) = .FALSE. 3459 3444 END IF ! pdb_bl < rn_mle_thresh_bl and 3460 3445 END IF ! phmle > 1.2 phbl 3461 3446 ELSE 3462 l dpyc(ji,jj) = .TRUE.3463 l dflux(ji,jj) = .FALSE.3464 l dmle(ji,jj) = .FALSE.3465 IF ( pdb_bl(ji,jj) < rn_osm_bl_thresh ) l dpyc(ji,jj) = .FALSE.3447 l_pyc(ji,jj) = .TRUE. 3448 l_flux(ji,jj) = .FALSE. 3449 l_mle(ji,jj) = .FALSE. 3450 IF ( pdb_bl(ji,jj) < rn_osm_bl_thresh ) l_pyc(ji,jj) = .FALSE. 3466 3451 END IF ! -2.0 * pwb_fk(ji,jj) / pwb_ent > 0.5 3467 3452 ELSE ! Stable Boundary Layer 3468 l dpyc(ji,jj) = .FALSE.3469 l dflux(ji,jj) = .FALSE.3470 l dmle(ji,jj) = .FALSE.3471 END IF ! l dconv3453 l_pyc(ji,jj) = .FALSE. 3454 l_flux(ji,jj) = .FALSE. 3455 l_mle(ji,jj) = .FALSE. 3456 END IF ! l_conv 3472 3457 #ifdef key_osm_debug 3473 3458 IF(narea==nn_narea_db.and.ji==iloc_db.and.jj==jloc_db)THEN 3474 3459 WRITE(narea+100,'(3(a,g11.3),/,4(a,l2))')'end of zdf_osm_osbl_state_fk:zwb_ent=',pwb_ent(ji,jj), & 3475 3460 & ' zhmle=',phmle(ji,jj), ' zhbl=', phbl(ji,jj), & 3476 & ' lpyc= ', l dpyc(ji,jj), ' lflux= ', ldflux(ji,jj), ' lmle= ', ldmle(ji,jj), ' lconv= ', ldconv(ji,jj)3461 & ' lpyc= ', l_pyc(ji,jj), ' lflux= ', l_flux(ji,jj), ' lmle= ', l_mle(ji,jj), ' lconv= ', l_conv(ji,jj) 3477 3462 FLUSH(narea+100) 3478 3463 END IF … … 3485 3470 END SUBROUTINE zdf_osm_osbl_state_fk 3486 3471 3487 SUBROUTINE zdf_osm_mle_parameters( Kmm, ldconv, ldmle, kmld_prof, pmld, phmle, pvel_mle, pdiff_mle, pdbds_mle, phbl, pb_bl, pwb0tot ) 3472 SUBROUTINE zdf_osm_mle_parameters( Kmm, kmld_prof, pmld, phmle, pvel_mle, & 3473 & pdiff_mle, pdbds_mle, phbl, pb_bl, pwb0tot ) 3488 3474 !!---------------------------------------------------------------------- 3489 3475 !! *** ROUTINE zdf_osm_mle_parameters *** … … 3500 3486 !!---------------------------------------------------------------------- 3501 3487 INTEGER, INTENT(in ) :: Kmm ! Time-level index 3502 LOGICAL, DIMENSION(:,:), INTENT(in ) :: ldconv ! BL stability flags3503 LOGICAL, DIMENSION(:,:), INTENT(inout) :: ldmle ! MLE layer increases in thickness3504 3488 INTEGER, DIMENSION(:,:), INTENT(inout) :: kmld_prof 3505 3489 REAL(wp), DIMENSION(:,:), INTENT(in ) :: pmld ! == Estimated FK BLD used for MLE horiz gradients == ! … … 3527 3511 ! Calculate vertical buoyancy, heat and salinity fluxes due to MLE 3528 3512 DO_2D( 0, 0, 0, 0 ) 3529 IF ( l dconv(ji,jj) ) THEN3513 IF ( l_conv(ji,jj) ) THEN 3530 3514 ztmp = r1_ft(ji,jj) * MIN( 111e3_wp, e1u(ji,jj) ) / rn_osm_mle_lf 3531 3515 ! This velocity scale, defined in Fox-Kemper et al (2008), is needed for calculating dhdt … … 3536 3520 ! Timestep mixed layer eddy depth 3537 3521 DO_2D( 0, 0, 0, 0 ) 3538 IF ( l dmle(ji,jj) ) THEN ! MLE layer growing3522 IF ( l_mle(ji,jj) ) THEN ! MLE layer growing 3539 3523 ! Buoyancy gradient at base of MLE layer 3540 3524 zthermal = rab_n(ji,jj,1,jp_tem)
Note: See TracChangeset
for help on using the changeset viewer.