Changeset 14958
- Timestamp:
- 2021-06-07T16:31:38+02:00 (3 years ago)
- Location:
- NEMO/branches/2021/dev_r14608_AGRIF_domcfg
- Files:
-
- 3 deleted
- 161 edited
- 15 copied
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
r14229 r14958 40 40 ln_closea = .false. ! F => suppress closed seas (defined by closea_mask field) 41 41 ! ! from the bathymetry at runtime. 42 / 43 !----------------------------------------------------------------------- 44 &namtile ! parameters of the tiling 45 !----------------------------------------------------------------------- 42 46 / 43 47 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg
r14229 r14958 38 38 ln_read_cfg = .true. ! (=T) read the domain configuration file 39 39 cn_domcfg = "ORCA_R05_zps_domcfg_agrif" ! domain configuration filename 40 / 41 !----------------------------------------------------------------------- 42 &namtile ! parameters of the tiling 43 !----------------------------------------------------------------------- 40 44 / 41 45 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg
r14229 r14958 38 38 ln_read_cfg = .true. ! (=T) read the domain configuration file 39 39 cn_domcfg = "ORCA_R017_zps_domcfg_agrif" ! domain configuration filename 40 / 41 !----------------------------------------------------------------------- 42 &namtile ! parameters of the tiling 43 !----------------------------------------------------------------------- 40 44 / 41 45 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg
r14229 r14958 40 40 ln_closea = .false. ! F => suppress closed seas (defined by closea_mask field) 41 41 ! ! from the bathymetry at runtime. 42 / 43 !----------------------------------------------------------------------- 44 &namtile ! parameters of the tiling 45 !----------------------------------------------------------------------- 42 46 / 43 47 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/AMM12/EXPREF/namelist_cfg
r14229 r14958 40 40 ln_read_cfg = .true. ! (=T) read the domain configuration file 41 41 cn_domcfg = "AMM_R12_sco_domcfg" ! domain configuration filename 42 / 43 !----------------------------------------------------------------------- 44 &namtile ! parameters of the tiling 45 !----------------------------------------------------------------------- 42 46 / 43 47 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/C1D_PAPA/EXPREF/namelist_cfg
r14229 r14958 58 58 / 59 59 !----------------------------------------------------------------------- 60 &namtile ! parameters of the tiling 61 !----------------------------------------------------------------------- 62 / 63 !----------------------------------------------------------------------- 60 64 &namtsd ! Temperature & Salinity Data (init/dmp) (default: OFF) 61 65 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/GYRE_BFM/EXPREF/namelist_cfg
r14229 r14958 32 32 !----------------------------------------------------------------------- 33 33 ln_read_cfg = .false. ! (=F) user defined configuration (F => create/check namusr_def) 34 / 35 !----------------------------------------------------------------------- 36 &namtile ! parameters of the tiling 37 !----------------------------------------------------------------------- 34 38 / 35 39 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/GYRE_PISCES/EXPREF/namelist_cfg
r14229 r14958 32 32 !----------------------------------------------------------------------- 33 33 ln_read_cfg = .false. ! (=F) user defined configuration (F => create/check namusr_def) 34 / 35 !----------------------------------------------------------------------- 36 &namtile ! parameters of the tiling 37 !----------------------------------------------------------------------- 34 38 / 35 39 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg
r14229 r14958 41 41 ln_closea = .false. ! F => suppress closed seas (defined by closea_mask field) 42 42 ! ! from the bathymetry at runtime. 43 / 44 !----------------------------------------------------------------------- 45 &namtile ! parameters of the tiling 46 !----------------------------------------------------------------------- 43 47 / 44 48 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
r14229 r14958 38 38 ln_closea = .false. ! F => suppress closed seas (defined by closea_mask field) 39 39 ! ! from the bathymetry at runtime. 40 / 41 !----------------------------------------------------------------------- 42 &namtile ! parameters of the tiling 43 !----------------------------------------------------------------------- 40 44 / 41 45 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg
r14255 r14958 43 43 cn_domcfg = "ORCA_R2_zps_domcfg" ! domain configuration filename 44 44 ! 45 / 46 !----------------------------------------------------------------------- 47 &namtile ! parameters of the tiling 48 !----------------------------------------------------------------------- 45 49 / 46 50 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg
r14256 r14958 42 42 cn_domcfg = "ORCA_R2_zps_domcfg" ! domain configuration filename 43 43 ! 44 / 45 !----------------------------------------------------------------------- 46 &namtile ! parameters of the tiling 47 !----------------------------------------------------------------------- 44 48 / 45 49 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg
r14229 r14958 35 35 ln_read_cfg = .true. ! (=T) read the domain configuration file 36 36 cn_domcfg = "ORCA_R2_zps_domcfg" ! domain configuration filename 37 / 38 !----------------------------------------------------------------------- 39 &namtile ! parameters of the tiling 40 !----------------------------------------------------------------------- 37 41 / 38 42 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/SHARED/field_def_nemo-ice.xml
r14581 r14958 178 178 <field id="hfxcndtop" long_name="Net conductive heat flux at the ice surface (neg = ice cooling)" standard_name="conductive_heat_flux_at_sea_ice_surface" unit="W/m2" /> 179 179 <field id="hfxcndbot" long_name="Net conductive heat flux at the ice bottom (neg = ice cooling)" standard_name="conductive_heat_flux_at_sea_ice_bottom" unit="W/m2" /> 180 <!-- clem: uncomment when uncommented in iceupdate.F90 -->181 <!--182 180 <field id="hfxmelt" long_name="Melt heat flux at the ice surface" unit="W/m2" /> 183 181 <field id="hfxldmelt" long_name="Heat flux in the lead for ice melting" unit="W/m2" /> 184 182 <field id="hfxldgrow" long_name="Heat flux in the lead for ice growth" unit="W/m2" /> 185 -->186 183 187 184 <!-- diags --> … … 351 348 <field id="SH_icearea" long_name="Sea ice area South" standard_name="sea_ice_area_s" unit="1e6_km2" /> 352 349 353 <!-- available with ln_icediaout --> 350 <!-- available with ln_icediahsb --> 351 <!-- global forcings --> 354 352 <field id="ibgfrcvoltop" long_name="global mean ice/snow forcing at interface ice/snow-atm (volume equivalent ocean volume)" unit="km3" /> 355 353 <field id="ibgfrcvolbot" long_name="global mean ice/snow forcing at interface ice/snow-ocean (volume equivalent ocean volume)" unit="km3" /> … … 360 358 <field id="ibgfrchfxbot" long_name="global mean heat flux below ice (on top of ocean) " unit="W/m2" /> 361 359 360 <!-- global drifts (conservation checks) --> 362 361 <field id="ibgvolume" long_name="drift in ice/snow volume (equivalent ocean volume)" unit="km3" /> 363 362 <field id="ibgsaltco" long_name="drift in ice salt content (equivalent ocean volume)" unit="pss*km3" /> … … 365 364 <field id="ibgheatfx" long_name="drift in ice/snow heat flux" unit="W/m2" /> 366 365 366 <!-- global contents --> 367 367 <field id="ibgvol_tot" long_name="global mean ice volume" unit="km3" /> 368 368 <field id="sbgvol_tot" long_name="global mean snow volume" unit="km3" /> 369 369 <field id="ibgarea_tot" long_name="global mean ice area" unit="km2" /> 370 <field id="ibgsalt_tot" long_name="global mean ice salt content" unit=" 1e-3*km3"/>370 <field id="ibgsalt_tot" long_name="global mean ice salt content" unit="pss*km3" /> 371 371 <field id="ibgheat_tot" long_name="global mean ice heat content" unit="1e20J" /> 372 372 <field id="sbgheat_tot" long_name="global mean snow heat content" unit="1e20J" /> 373 <field id="ipbgvol_tot" long_name="global mean ice pond volume" unit="km3" /> 374 <field id="ilbgvol_tot" long_name="global mean ice pond lid volume" unit="km3" /> 373 375 374 376 </field_group> … … 502 504 </field_group> 503 505 506 <!--============================--> 507 <!-- CONSERVATION diagnostics --> 508 <!--============================--> 509 504 510 <field_group id="ICE_globalbudget" grid_ref="grid_scalar" > 505 <!-- global contents -->506 511 <field field_ref="ibgvol_tot" name="ibgvol_tot" /> 507 512 <field field_ref="sbgvol_tot" name="sbgvol_tot" /> … … 510 515 <field field_ref="ibgheat_tot" name="ibgheat_tot" /> 511 516 <field field_ref="sbgheat_tot" name="sbgheat_tot" /> 512 513 <!-- global drifts (conservation checks) --> 514 <field field_ref="ibgvolume" name="ibgvolume" /> 515 <field field_ref="ibgsaltco" name="ibgsaltco" /> 516 <field field_ref="ibgheatco" name="ibgheatco" /> 517 <field field_ref="ibgheatfx" name="ibgheatfx" /> 518 519 <!-- global forcings --> 520 <field field_ref="ibgfrcvoltop" name="ibgfrcvoltop" /> 521 <field field_ref="ibgfrcvolbot" name="ibgfrcvolbot" /> 522 <field field_ref="ibgfrctemtop" name="ibgfrctemtop" /> 523 <field field_ref="ibgfrctembot" name="ibgfrctembot" /> 524 <field field_ref="ibgfrcsal" name="ibgfrcsal" /> 525 <field field_ref="ibgfrchfxtop" name="ibgfrchfxtop" /> 526 <field field_ref="ibgfrchfxbot" name="ibgfrchfxbot" /> 527 </field_group> 528 529 517 <field field_ref="ipbgvol_tot" name="ipbgvol_tot" /> 518 <field field_ref="ilbgvol_tot" name="ilbgvol_tot" /> 519 </field_group> 520 521 <field_group id="ICE_budget" grid_ref="grid_T_2D" > 522 <!-- general --> 523 <field field_ref="icemask" name="simsk" /> 524 <field field_ref="iceconc" name="siconc" /> 525 <field field_ref="icetemp" name="sitemp" /> 526 <field field_ref="snwtemp" name="sntemp" /> 527 <field field_ref="icettop" name="sittop" /> 528 <field field_ref="icetbot" name="sitbot" /> 529 <!-- heat fluxes --> 530 <field field_ref="qt_oce_ai" name="qt_oce_ai" /> 531 <field field_ref="qt_atm_oi" name="qt_atm_oi" /> 532 <field field_ref="qtr_ice_top" name="qtr_ice_top"/> 533 <field field_ref="qtr_ice_bot" name="qtr_ice_bot"/> 534 <field field_ref="qt_ice" name="qt_ice" /> 535 <field field_ref="qsr_ice" name="qsr_ice" /> 536 <field field_ref="qns_ice" name="qns_ice" /> 537 <field field_ref="qemp_ice" name="qemp_ice" /> 538 <field field_ref="hfxsub" name="hfxsub" /> 539 <field field_ref="hfxspr" name="hfxspr" /> 540 <field field_ref="hfxcndtop" name="hfxcndtop" /> 541 <field field_ref="hfxcndbot" name="hfxcndbot" /> 542 <field field_ref="hfxsensib" name="hfxsensib" /> 543 <field field_ref="hfxmelt" name="hfxmelt" /> 544 <field field_ref="hfxldmelt" name="hfxldmelt" /> 545 <field field_ref="hfxldgrow" name="hfxldgrow" /> 546 <!-- salt fluxes --> 547 <field field_ref="sfxice" name="sfxice" /> 548 <!-- mass fluxes --> 549 <field field_ref="vfxice" name="vfxice" /> 550 <field field_ref="vfxsnw" name="vfxsnw" /> 551 <field field_ref="vfxpnd" name="vfxpnd" /> 552 <field field_ref="vfxsub" name="vfxsub" /> 553 <field field_ref="vfxsub_err" name="vfxsub_err" /> 554 <field field_ref="vfxsnw_sub" name="vfxsnw_sub" /> 555 <field field_ref="vfxsnw_pre" name="vfxsnw_pre" /> 556 </field_group> 557 558 530 559 <!--============================--> 531 560 <!-- SIMIP sea ice field groups --> -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/SHARED/field_def_nemo-oce.xml
r14224 r14958 241 241 <field id="mf_mf" long_name="mass flux" standard_name="mf_mass_flux" unit="m" grid_ref="grid_T_3D" /> 242 242 243 <!-- fluxes from damping --> 244 <field id="sflx_dmp_cea" long_name="salt flux due to damping" standard_name="salt_flux_due_to_damping" unit="g/m2/s" /> 245 <field id="hflx_dmp_cea" long_name="heat flux due to damping" standard_name="heat_flux_due_to_damping" unit="W/m2" /> 246 243 247 </field_group> <!-- grid_T --> 244 248 … … 276 280 <field id="dh" long_name="Pycnocline thickness" unit=" m" /> 277 281 <field id="ibld" long_name="index of boundary layer depth" unit="#" /> 278 <field id="imld" long_name="index of mixed layer depth" unit="#" /> 279 <field id="zhbl" long_name="boundary layer depth -grid" unit="m" /> 280 <field id="zhml" long_name="mixed layer depth - grid" unit="m" /> 282 <field id="imld" long_name="index of mixed layer depth" unit="#" /> 283 <field id="jp_ext" long_name="flag =1 if pycnocline well resolved" unit="#" /> 284 <field id="j_ddh" long_name="index of mixed layer depth" unit="#" /> 285 <field id="zshear" long_name="shear production of TKE " unit="m^3/s^3" /> 286 <field id="zhbl" long_name="boundary layer depth -grid" unit="m" /> 287 <field id="zhml" long_name="mixed layer depth - grid" unit="m" /> 281 288 <field id="zdh" long_name="Pycnocline depth - grid" unit=" m" /> 282 289 <field id="zustke" long_name="magnitude of stokes drift at T-points" unit="m/s" /> 283 <field id="us_x" long_name="i component of active Stokes drift"unit="m/s" />284 <field id="us_y" long_name="j component of active Stokes drift"unit="m/s" />290 <field id="us_x" long_name="i component of active Stokes drift" unit="m/s" /> 291 <field id="us_y" long_name="j component of active Stokes drift" unit="m/s" /> 285 292 <field id="dstokes" long_name="stokes drift depth scale" unit="m" /> 286 293 <field id="zwth0" long_name="surface non-local temperature flux" unit="deg m/s" /> 287 294 <field id="zws0" long_name="surface non-local salinity flux" unit="psu m/s" /> 295 <field id="zwb0" long_name="surface non-local buoyancy flux" unit="m^2/s^3" /> 288 296 <field id="zwstrc" long_name="convective velocity scale" unit="m/s" /> 289 297 <field id="zustar" long_name="friction velocity" unit="m/s" /> … … 296 304 297 305 <!-- interior BL OSMOSIS diagnostics --> 298 <field id="zw thav" long_name="av turb flux of T in ml" unit="deg m/s" />306 <field id="zwbav" long_name="av turb flux of buoyancy in ml" unit="m^2/s^3" /> 299 307 <field id="zt_ml" long_name="av T in ml" unit="deg" /> 300 308 <field id="zhol" long_name="Hoenekker number" unit="#" /> … … 303 311 <field id="zwb_ent" long_name="entrainment turb flux of buoyancy" unit="m^2/s^-3" /> 304 312 305 <field id="zdt_bl" long_name="temperature jump at base of BL" unit="deg" /> 306 <field id="zds_bl" long_name="salinity jump at base of BL" unit="10^-3" /> 307 <field id="zdb_bl" long_name="buoyancy jump at base of BL" unit="m/s^2" /> 308 <field id="zdu_bl" long_name="u jump at base of BL" unit="m/s" /> 309 <field id="zdv_bl" long_name="v jump at base of BL" unit="m/s" /> 310 313 <field id="zdt_bl" long_name="temperature jump at base of BL" unit="deg" /> 314 <field id="zds_bl" long_name="salinity jump at base of BL" unit="10^-3" /> 315 <field id="zdb_bl" long_name="buoyancy jump at base of BL" unit="m/s^2" /> 316 <field id="zdu_bl" long_name="u jump at base of BL" unit="m/s" /> 317 <field id="zdv_bl" long_name="v jump at base of BL" unit="m/s" /> 318 <field id="zdt_ml" long_name="temperature jump at base of ML" unit="deg" /> 319 <field id="zds_ml" long_name="salinity jump at base of ML" unit="10^-3" /> 320 <field id="zdb_ml" long_name="buoyancy jump at base of ML" unit="m/s^2" /> 321 <field id="pb_coup" long_name="bottom coupling velocity" unit="m/s" /> 311 322 <!-- extra OSMOSIS diagnostics for debugging --> 312 323 <field id="zsc_uw_1_0" long_name="zsc u-momentum flux on T after Stokes" unit="m^2/s^2" /> … … 315 326 <field id="zsc_uw_2_f" long_name="2nd zsc u-momentum flux on T after Coriolis" unit="m^2/s^2" /> 316 327 <field id="zsc_vw_2_f" long_name="2nd zsc v-momentum flux on T after Coriolis" unit="m^2/s^2" /> 317 <field id="zuw_bse" long_name="base u-flux T-points" unit="m^2/s^2" />318 <field id="zvw_bse" long_name="base v-flux T-points" unit="m^2/s^2" />319 328 320 329 <!-- FK_OSM OSMOSIS diagnostics (require also ln_osm_mle=.true.--> … … 375 384 <field id="emp_oce" long_name="Evap minus Precip over ocean" standard_name="evap_minus_precip_over_sea_water" unit="kg/m2/s" /> 376 385 <field id="emp_ice" long_name="Evap minus Precip over ice" standard_name="evap_minus_precip_over_sea_ice" unit="kg/m2/s" /> 377 <field id="saltflx" long_name="Downward salt flux" unit=" 1e-3/m2/s"/>386 <field id="saltflx" long_name="Downward salt flux" unit="g/m2/s" /> 378 387 <field id="fmmflx" long_name="Water flux due to freezing/melting" unit="kg/m2/s" /> 379 388 <field id="snowpre" long_name="Snow precipitation" standard_name="snowfall_flux" unit="kg/m2/s" /> … … 475 484 <field id="hflx_rain_cea" long_name="heat flux due to rainfall" standard_name="temperature_flux_due_to_rainfall_expressed_as_heat_flux_into_sea_water" unit="W/m2" /> 476 485 <field id="hflx_evap_cea" long_name="heat flux due to evaporation" standard_name="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water" unit="W/m2" /> 486 <field id="hflx_subl_cea" long_name="heat flux due to sublimation (from atm. forcings)" standard_name="temperature_flux_due_to_sublimation_expressed_as_heat_flux_out_of_sea_ice" unit="W/m2" /> 477 487 <field id="hflx_prec_cea" long_name="heat flux due to all precip" standard_name="temperature_flux_due_to_all_precip_expressed_as_heat_flux_into_sea_water" unit="W/m2" /> 478 488 <field id="hflx_snow_cea" long_name="heat flux due to snow falling" standard_name="heat_flux_onto_ocean_and_ice_due_to_snow_thermodynamics" unit="W/m2" /> … … 481 491 <field id="hflx_ice_cea" long_name="heat flux due to ice thermodynamics" standard_name="heat_flux_into_sea_water_due_to_sea_ice_thermodynamics" unit="W/m2" /> 482 492 <field id="hflx_rnf_cea" long_name="heat flux due to runoffs" standard_name="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water" unit="W/m2" /> 493 <field id="sflx_rnf_cea" long_name="salt flux due to runoffs" standard_name="salt_flux_due_to_runoffs" unit="g/m2/s" /> 483 494 <field id="hflx_cal_cea" long_name="heat flux due to calving" standard_name="heat_flux_into_sea_water_due_to_calving" unit="W/m2" /> 484 495 <field id="hflx_icb_cea" long_name="heat flux due to iceberg" standard_name="heat_flux_into_sea_water_due_to_icebergs" unit="W/m2" /> … … 490 501 <field id="ticemel_cea" long_name="Rate of Melt at Upper Surface of Sea Ice (cell average)" standard_name="tendency_of_sea_ice_amount_due_to_surface_melting" unit="kg/m2/s" /> 491 502 503 <!-- fluxes from relaxation and freshwater budget --> 504 <field id="sflx_ssr_cea" long_name="salt flux due to restoring" standard_name="salt_flux_due_to_restoring" unit="g/m2/s" /> 505 <field id="hflx_ssr_cea" long_name="heat flux due to restoring" standard_name="heat_flux_due_to_restoring" unit="W/m2" /> 506 <field id="vflx_ssr_cea" long_name="volume flux due to restoring" standard_name="volume_flux_due_to_restoring" unit="kg/m2/s" /> 507 <field id="hflx_fwb_cea" long_name="heat flux due to fwb" standard_name="heat_flux_due_to_fwb" unit="W/m2" /> 508 <field id="vflx_fwb_cea" long_name="volume flux due to fwb" standard_name="volume_flux_due_to_fwb" unit="kg/m2/s" /> 509 492 510 <!-- ice field (nn_ice=1) --> 493 511 <field id="ice_cover" long_name="Ice fraction" standard_name="sea_ice_area_fraction" unit="1" /> … … 1253 1271 </field_group> 1254 1272 1273 <!--============================--> 1274 <!-- CONSERVATION diagnostics --> 1275 <!--============================--> 1276 <!-- BE CAREFUL: this group (OCE_budget) cannot be called in file_def.xml as such (unless nn_fsbc=1) 1277 If doing so, the last output (in time) of the netcdf file 1278 would be corrupted (NaN values). However calling each of these 1279 variables directly in the file_def.xml works. It is probably 1280 because there is a mix up of sbc variables with other variables 1281 --> 1282 <field_group id="OCE_budget" grid_ref="grid_T_2D" > 1283 <field field_ref="sst" name="tos" /> 1284 <field field_ref="sss" name="sos" /> 1285 <field field_ref="ssh" name="zos" /> 1286 <!-- mass flux --> 1287 <field field_ref="empmr" name="empmr" /> 1288 <field field_ref="runoffs" name="runoffs" /> 1289 <field field_ref="emp_ice" name="emp_ice" /> 1290 <field field_ref="emp_oce" name="emp_oce" /> 1291 <field field_ref="iceshelf_cea" name="iceshelf" /> 1292 <field field_ref="iceberg_cea" name="iceberg" /> 1293 <field field_ref="calving_cea" name="calving" /> 1294 <!-- <field field_ref="berg_floating_melt" name="calving" /> --> 1295 <field field_ref="precip" name="precip" /> 1296 <field field_ref="snowpre" name="snowpre" /> 1297 <field field_ref="rain" name="rain" /> 1298 <field field_ref="evap_ao_cea" name="evap_ao" /> 1299 <field field_ref="subl_ai_cea" name="subl_ai" /> 1300 <field field_ref="snow_ai_cea" name="snow_ai" /> 1301 <field field_ref="snow_ao_cea" name="snow_ao" /> 1302 <!-- heat flux --> 1303 <field field_ref="qsr" name="qsr" /> 1304 <field field_ref="qns" name="qns" /> 1305 <field field_ref="qt_oce" name="qt_oce" /> 1306 <field field_ref="qemp_oce" name="qemp_oce" /> 1307 <field field_ref="hflx_rain_cea" name="hflx_rain" /> 1308 <field field_ref="hflx_evap_cea" name="hflx_evap" /> 1309 <field field_ref="hflx_snow_cea" name="hflx_snow" /> 1310 <field field_ref="hflx_snow_ao_cea" name="hflx_snow_ao" /> 1311 <field field_ref="hflx_snow_ai_cea" name="hflx_snow_ai" /> 1312 <field field_ref="hflx_rnf_cea" name="hflx_rnf" /> 1313 <field field_ref="hflx_icb_cea" name="hflx_icb" /> 1314 <field field_ref="hflx_isf_cea" name="hflx_isf" /> 1315 <!-- salt flux (includes ssr) --> 1316 <field field_ref="saltflx" name="saltflx" /> 1317 <field field_ref="sflx_rnf_cea" name="sflx_rnf" /> 1318 <!-- relaxation and damping --> 1319 <field field_ref="hflx_ssr_cea" name="hflx_ssr" /> 1320 <field field_ref="vflx_ssr_cea" name="vflx_ssr" /> 1321 <field field_ref="sflx_ssr_cea" name="sflx_ssr" /> 1322 <field field_ref="hflx_dmp_cea" name="hflx_dmp" /> 1323 <field field_ref="sflx_dmp_cea" name="sflx_dmp" /> 1324 <field field_ref="hflx_fwb_cea" name="hflx_fwb" /> 1325 <field field_ref="vflx_fwb_cea" name="vflx_fwb" /> 1326 </field_group> 1327 1328 <field_group id="OCE_globalbudget" grid_ref="grid_scalar" > 1329 <field field_ref="voltot" name="scvoltot" /> 1330 <field field_ref="saltot" name="scsaltot" /> 1331 <field field_ref="temptot" name="sctemtot" /> 1332 </field_group> 1333 1334 1255 1335 </field_definition> -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/SHARED/namelist_ref
r14433 r14958 99 99 !----------------------------------------------------------------------- 100 100 ln_tile = .false. ! Use tiling (T) or not (F) 101 nn_ltile_i = 10! Length of tiles in i101 nn_ltile_i = 99999 ! Length of tiles in i 102 102 nn_ltile_j = 10 ! Length of tiles in j 103 103 / … … 1265 1265 ! = 2:use surface value of SD fit to slope at rn_osm_hblfrac*hbl below surface 1266 1266 ln_zdfosm_ice_shelter = .true. ! reduce surface SD and depth scale under ice 1267 ln_osm_mle = . false.! Use integrated FK-OSM model1267 ln_osm_mle = .true. ! Use integrated FK-OSM model 1268 1268 / 1269 1269 !----------------------------------------------------------------------- … … 1273 1273 nn_osm_mle = 0 ! MLE type: =0 standard Fox-Kemper ; =1 new formulation 1274 1274 rn_osm_mle_lf = 5.e+3 ! typical scale of mixed layer front (meters) (case rn_osm_mle=0) 1275 rn_osm_mle_time = 172800.! time scale for mixing momentum across the mixed layer (seconds) (case rn_osm_mle=0)1275 rn_osm_mle_time = 43200. ! time scale for mixing momentum across the mixed layer (seconds) (case rn_osm_mle=0) 1276 1276 rn_osm_mle_lat = 20. ! reference latitude (degrees) of MLE coef. (case rn_mle=1) 1277 rn_osm_mle_rho_c = 0.01! delta rho criterion used to calculate MLD for FK1278 rn_osm_mle_thresh = 0.0005! delta b criterion used for FK MLE criterion1279 rn_osm_mle_tau = 172800.! time scale for FK-OSM (seconds) (case rn_osm_mle=0)1280 ln_osm_hmle_limit = . false. !limit hmle to rn_osm_hmle_limit*hbl1281 rn_osm_hmle_limit = 1. 21277 rn_osm_mle_rho_c = 0.03 ! delta rho criterion used to calculate MLD for FK 1278 rn_osm_mle_thresh = 0.0001 ! delta b criterion used for FK MLE criterion 1279 rn_osm_mle_tau = 172800. ! time scale for FK-OSM (seconds) (case rn_osm_mle=0) 1280 ln_osm_hmle_limit = .true. ! If true, limit hmle to rn_osm_hmle_limit*hbl 1281 rn_osm_hmle_limit = 1.5 1282 1282 / 1283 1283 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/SPITZ12/EXPREF/namelist_cfg
r14229 r14958 36 36 ! ! (=F) user defined configuration (F => create/check namusr_def) 37 37 cn_domcfg = "domain_cfg" ! domain configuration filename 38 / 39 !----------------------------------------------------------------------- 40 &namtile ! parameters of the tiling 41 !----------------------------------------------------------------------- 38 42 / 39 43 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/cfgs/WED025/EXPREF/namelist_cfg
r14229 r14958 54 54 ! ! (=F) user defined configuration (F => create/check namusr_def) 55 55 cn_domcfg = "domain_cfg" ! domain configuration filename 56 / 57 !----------------------------------------------------------------------- 58 &namtile ! parameters of the tiling 59 !----------------------------------------------------------------------- 56 60 / 57 61 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/main/abstract.tex
r11591 r14958 24 24 it includes different sub-modules: ocean water age, inorganic carbon (CFCs) \& radiocarbon (C14b), 25 25 built-in biogeochemical model (PISCES), and prototype for user-defined cases or 26 coupling with alternative biogeochemical models (\eg \href{http://www.bfm-community.eu}{BFM}).26 coupling with alternative biogeochemical models (\eg, \href{http://www.bfm-community.eu}{BFM}). -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/main/authors.tex
r11591 r14958 5 5 Georges Nurser \\ 6 6 Julien Palmi\'{e}ri \\ 7 Renaud Person \\ 7 8 Andrew Yool -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/main/bibliography.bib
r14374 r14958 187 187 } 188 188 189 @article{ getzlaff_2013, 190 author = {Getzlaff, Julia and Dietze, Heiner}, 191 title = {Effects of increased isopycnal diffusivity 192 mimicking the unresolved equatorial intermediate 193 current system in an earth system climate model}, 194 year = {2013}, 195 volume = {40}, 196 number = {10}, 197 pages = {2166--2170}, 198 doi = {10.1002/grl.50419}, 199 url = {https://dx.doi.org/10.1002/grl.50419}, 200 journal = {Geophysical Research Letters}, 201 publisher = {Wiley Online Library} 202 } 203 189 204 @techreport{ gibson_trpt86, 190 205 title = "Standards for software development and maintenance", … … 271 286 journal = {Limnology and Oceanography}, 272 287 publisher = {Wiley} 288 } 289 290 @Article{ mathiot_explicit_2017, 291 author = {Mathiot, Pierre and Jenkins, Adrian and Harris, Christopher 292 and Madec, Gurvan}, 293 title = {Explicit representation and parametrised impacts of under 294 ice shelf seas in the z∗ coordinate ocean model {NEMO} 3.6}, 295 year = {2017}, 296 volume = {10}, 297 number = {7}, 298 month = jul, 299 pages = {2849--2874}, 300 issn = {1991-9603}, 301 doi = {10.5194/gmd-10-2849-2017}, 302 url = {https://www.geosci-model-dev.net/10/2849/2017/}, 303 journal = {Geoscientific Model Development}, 304 publisher = {Copernicus GmbH} 273 305 } 274 306 … … 448 480 } 449 481 482 @Article{ person_sensitivity_2019, 483 author = {Person, Renaud and Aumont, Olivier and Madec, Gurvan and 484 Vancoppenolle, Martin and Bopp, Laurent and Merino, Nacho}, 485 title = {Sensitivity of ocean biogeochemistry to the iron supply from the 486 {Antarctic} {Ice} {Sheet} explored with a biogeochemical model}, 487 year = {2019}, 488 volume = {16}, 489 number = {18}, 490 month = sep, 491 pages = {3583--3603}, 492 issn = {1726-4189}, 493 doi = {10.5194/bg-16-3583-2019}, 494 url = {https://www.biogeosciences.net/16/3583/2019/}, 495 journal = {Biogeosciences}, 496 publisher = {Copernicus GmbH} 497 } 498 450 499 @Article{ reimer_2013, 451 500 author = {Reimer, Paula J and Bard, Edouard and Bayliss, Alex and … … 630 679 publisher = {Elsevier BV} 631 680 } 681 682 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/main/introduction.tex
r11591 r14958 11 11 \begin{itemize} 12 12 \item a transport code TRP sharing the same advection/diffusion routines with the dynamics, with specific treatment of some features like the surface boundary 13 conditions ,or the positivity of passive tracers concentrations13 conditions or the positivity of passive tracers concentrations 14 14 \item sources and sinks - SMS - models that can be typically biogeochemical, biological or radioactive 15 \item an offline option which is a simplified OPA 9 model using fields of physic s variables that are previously stored todisk15 \item an offline option which is a simplified OPA 9 model using fields of physical variables that were previously stored on disk 16 16 \end{itemize} 17 17 18 There istwo ways of coupling TOP to the dynamics :18 There are two ways of coupling TOP to the dynamics : 19 19 20 20 \begin{itemize} 21 21 \item \textit{online coupling} : the evolution of passive tracers is computed along with the dynamics 22 \item \textit{offline coupling} : the fields of physics variables are read from files and interpolated at each model time step, with no constraints on the timesampling in the input files22 \item \textit{offline coupling} : the physical variable fields are read from files and interpolated at each model time step, with no constraints on the temporal sampling in the input files 23 23 \end{itemize} 24 24 25 TOP is designed to handle multiple oceanic tracers through a modular approach and i t includes different sub-modules :25 TOP is designed to handle multiple oceanic tracers through a modular approach and includes different sub-modules : 26 26 27 27 \begin{itemize} 28 28 \item the ocean water age module (AGE) tracks down the time-dependent spread of surface waters into the ocean interior 29 \item inorganic carbon (e.g.CFCs, SF6) and radiocarbon (C14) passive tracers can be modeled to assess ocean absorption timescales of anthropogenic emissions and further address water masses ventilation29 \item inorganic (\eg, CFCs, SF6) and radiocarbon (C14) passive tracers can be modeled to assess ocean absorption timescales of anthropogenic emissions and further address water masses ventilation 30 30 \item a built-in biogeochemical model (PISCES) to simulate lower trophic levels ecosystem dynamics in the global ocean 31 \item a prototype tracer module (MY\_TRC) to enable user-defined cases or the coupling with alternative biogeochemical models ( e.g.BFM, MEDUSA, ERSEM, BFM, ECO3M)31 \item a prototype tracer module (MY\_TRC) to enable user-defined cases or the coupling with alternative biogeochemical models (\eg, BFM, MEDUSA, ERSEM, BFM, ECO3M) 32 32 \end{itemize} 33 33 … … 36 36 \vspace{0cm} 37 37 \includegraphics[width=0.80\textwidth]{Fig_TOP_design} 38 %\includegraphics[height=6cm,angle=-00]{Fig_TOP_design} 39 \caption{A schematic view of NEMO-TOP component} 38 \caption{Schematic view of the NEMO-TOP component} 40 39 \label{topdesign} 41 40 \end{center} -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/subfiles/miscellaneous.tex
r14239 r14958 7 7 \section{TOP synthetic Workflow} 8 8 9 \subsection{Model initialization} 9 A synthetic description of the TOP interface workflow is given below to summarize the steps involved in the computation of biogeochemical and physical trends and their time integration and outputs, by reporting also the principal Fortran subroutine herein involved. 10 10 11 \subsection{Time marching procedure} 11 %\begin{figure}[!h] 12 % \centering 13 % \includegraphics[width=0.80\textwidth]{Top_FlowChart} 14 % \caption{Schematic view of NEMO-TOP flowchart} 15 % \label{img_cfcatm} 16 %\end{figure} 17 18 \begin{minted}{bash} 19 nemogcm 20 ! 21 nemo_init ! NEMO General Initialisations 22 ! 23 trc_init ! TOP Initialisations 24 ! 25 stp() ! NEMO Time-stepping 26 ! 27 trc_stp() ! TOP time-stepping 28 ! 29 trc_wri() ! I/O manager : Output of passive tracers 30 trc_sms() ! Sinks and sources program manager 31 trc_trp() ! Transport of passive tracers 32 trc_rst_wri() ! Write tracer restart file 33 trd_mxl_trc() ! trends: Mixed-layer 34 \end{minted} 35 36 \subsection{Model initialization (./src/TOP/trcini.F90)} 37 38 This module consists on inital set up of passive tracers variables and parameters : read the namelist, set initial tracer fields (either read restart or read data or analytical formulation and specific initailisation in each SMS module ( analytical initialisation of tracers or constant values ) 39 40 \begin{minted}{bash} 41 trc_init ! TOP Initialisations 42 ! 43 IF( PISCES ) trc_ini_pisces() ! PISCES bio model 44 IF( MY_TRC) trc_ini_my_trc() ! MY_TRC model 45 IF( CFCs ) trc_ini_cfc () ! CFCs 46 IF( C14 ) trc_ini_c14 () ! C14 model 47 IF( AGE ) trc_ini_age () ! AGE tracer 48 ! 49 IF( REST ) trc_rst_read() ! Restart from a file 50 ELSE trc_dta() ! Initialisation from data 51 \end{minted} 52 53 \subsection{BGC trends computation (./src/TOP/trcsms.F90)} 54 55 This is the main module where the passive tracers source minus sinks of each TOP sub-module is managed. 56 57 \begin{minted}{bash} 58 trc_sms() ! Sinks and sources prooram manager 59 ! 60 IF( PISCES ) trc_sms_pisces() ! main program of PISCES 61 IF( CFCs ) trc_sms_cfc() ! surface fluxes of CFC 62 IF( C14 ) trc_sms_c14() ! surface fluxes of C14 63 IF( AGE ) trc_sms_age() ! Age tracer 64 IF( MY_TRC) trc_sms_my_trc() ! MY_TRC tracers 65 \end{minted} 66 67 \subsection{Physical trends computation (./src/TOP/TRP/trctrp.F90)} 68 69 This is the main module where the passive tracers transport is managed. All the physical trends is calculated ( advective \& diffusive trends, surface BC from freshwater or external inputs ) 70 71 \begin{minted}{bash} 72 trc_trp() ! Transport of passive tracers 73 ! 74 trc_sbc() ! Surface boundary condition of freshwater flux 75 trc_bc() ! Surface and lateral Boundary Conditions 76 trc_ais() ! Tracers from Antarctic Ice Sheet (icb, isf) 77 trc_bbl() ! Advective (and/or diffusive) bottom boundary layer scheme 78 trc_dmp() ! Internal damping trends 79 trc_bdy() ! BDY damping trends 80 trc_adv() ! Horizontal & Vertical advection 81 trc_ldf() ! Lateral mixing 82 trc_zdf() ! Vert. mixing & after tracer 83 trc_atf() ! Time filtering of "now" tracer fields 84 trc_rad() ! Correct artificial negative concentrations 85 \end{minted} 86 87 \subsection{Outputs (./src/TOP/TRP/trcwri.F90)} 88 89 This is the main module where the passive tracer outputs of each TOP sub-module is managed using the I/O library XIOS. 90 91 \begin{minted}{bash} 92 trc_wri() ! I/O manager : Output of passive tracers 93 ! 94 IF( PISCES ) trc_wri_pisces() ! Output of PISCES diagnostics 95 IF( CFCs ) trc_wri_cfc() ! Output of Cfcs diagnostics 96 IF( C14 ) trc_wri_c14() ! surface fluxes of C14 97 IF( AGE ) trc_wri_age() ! Age tracer 98 IF( MY_TRC ) trc_wri_my_trc() ! MY_TRC tracers 99 \end{minted} 12 100 13 101 \section{Coupling an external BGC model using NEMO framework} … … 27 115 \end{minted} 28 116 29 the compilation with \textit{makenemo} will be executed through the following syntax117 The compilation with \textit{makenemo} will be executed through the following syntax 30 118 31 119 \begin{minted}{bash} 32 120 makenemo -n NEMO_MYBGC -m <arch_my_machine> -j 8 -e <MYBGCPATH> 33 121 \end{minted} 34 %The makenemo feature ?-e? was introduced to readdress at compilation time the standard MY_SRC folder (usually found in NEMO configurations) with a user defined external one. 35 % 36 % 37 %The compilation of more articulated BGC model code & infrastructure, like in the case of BFM (?BFM-NEMO coupling manual), requires some additional features. 38 % 39 %As before, let?s assume a coupled configuration name NEMO_MYBGC, but in this case MYBGC model root becomes <MYBGCPATH> that contains 4 different subfolders for biogeochemistry, named initialization, pelagic, and benthic, and a separate one named nemo_coupling including the modified MY_SRC routines. The latter folder containing the modified NEMO coupling interface will be still linked using the makenemo ?-e? option. 40 % 41 %In order to include the BGC model subfolders in the compilation of NEMO code, it will be necessary to extend the configuration cpp_NEMO_MYBGC.fcmfile to include the specific paths of MYBGC folders, as in the following example42 % 122 123 The makenemo feature \textit{-e} was introduced to readdress at compilation time the standard MY\_SRC folder (usually found in NEMO configurations) with a user defined external one. \\ \\ 124 125 The compilation of more articulated BGC model code \& infrastructure, like in the case of BFM (BFM-NEMO coupling manual), requires some additional features. \\ \\ 126 127 As before, let's assume a coupled configuration name NEMO\_MYBGC, but in this case MYBGC model root becomes <MYBGCPATH> that contains 4 different subfolders for biogeochemistry, named initialization, pelagic, and benthic, and a separate one named nemo\_coupling including the modified MY\_SRC routines. The latter folder containing the modified NEMO coupling interface will be still linked using the makenemo \textit{-e} option. \\ \\ 128 129 In order to include the BGC model subfolders in the compilation of NEMO code, it will be necessary to extend the configuration \textit{cpp\_NEMO\_MYBGC.fcm} file to include the specific paths of MYBGC folders, as in the following example 130 43 131 \begin{minted}{bash} 44 132 bld::tool::fppkeys key_xios key_top … … 49 137 50 138 bld::pp::MYBGC 1 51 bld::tool::fppflags::MYBGC %FPPFLAGS52 bld::tool::fppkeys %bld::tool::fppkeys MYBGC_MACROS139 bld::tool::fppflags::MYBGC \%FPPFLAGS 140 bld::tool::fppkeys \%bld::tool::fppkeys MYBGC_MACROS 53 141 \end{minted} 54 142 55 %where MYBGC_MACROS is the space delimited list of macros used in MYBGC model for selecting/excluding specific parts of the code. The BGC model code will be preprocessed in the configuration BLD folder as for NEMO, but with an independent path, like NEMO_MYBGC/BLD/MYBGC/<subforlders>. 56 % 57 %The compilation will be performed similarly to in the previous case with the following 58 % 59 %makenemo -n NEMO_MYBGC -m <arch_my_machine> -j 8 -e <MYBGCPATH>/nemo_coupling 60 %Note that, the additional lines specific for the BGC model source and build paths, can be written into a separate file, e.g. named MYBGC.fcm, and then simply included in the cpp_NEMO_MYBGC.fcm as follow 61 % 62 %bld::tool::fppkeys key_zdftke key_dynspg_ts key_xios key_top 63 %inc <MYBGCPATH>/MYBGC.fcm 64 %This will enable a more portable compilation structure for all MYBGC related configurations. 65 % 66 %Important: the coupling interface contained in nemo_coupling cannot be added using the FCM syntax, as the same files already exists in NEMO and they are overridden only with the readdressing of MY_SRC contents to avoid compilation conflicts due to duplicate routines. 67 % 68 %All modifications illustrated above, can be easily implemented using shell or python scripting to edit the NEMO configuration cpp.fcm file and to create the BGC model specific FCM compilation file with code paths. 143 where MYBGC\_MACROS is the space delimited list of macros used in MYBGC model for selecting/excluding specific parts of the code. The BGC model code will be preprocessed in the configuration BLD folder as for NEMO, but with an independent path, like NEMO\_MYBGC/BLD/MYBGC/<subfolders>.\\ 144 145 The compilation will be performed similarly to in the previous case with the following 146 147 \begin{minted}{bash} 148 makenemo -n NEMO_MYBGC -m <arch_my_machine> -j 8 -e <MYBGCPATH>/nemo_coupling 149 \end{minted} 150 151 Note that, the additional lines specific for the BGC model source and build paths, can be written into a separate file, e.g. named MYBGC.fcm, and then simply included in the cpp\_NEMO\_MYBGC.fcm as follow: 152 153 \begin{minted}{bash} 154 bld::tool::fppkeys key_zdftke key_dynspg_ts key_xios key_top 155 inc <MYBGCPATH>/MYBGC.fcm 156 \end{minted} 157 158 This will enable a more portable compilation structure for all MYBGC related configurations. \\ \\ 159 160 Important: the coupling interface contained in nemo\_coupling cannot be added using the FCM syntax, as the same files already exists in NEMO and they are overridden only with the readdressing of MY\_SRC contents to avoid compilation conflicts due to duplicate routines. \\ \\ 161 162 All modifications illustrated above, can be easily implemented using shell or python scripting to edit the NEMO configuration cpp.fcm file and to create the BGC model specific FCM compilation file with code paths. 69 163 70 164 \end{document} -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/subfiles/model_description.tex
r14375 r14958 17 17 \label{sec:Bas} 18 18 19 The time evolution of any passive tracer $C$ followsthe transport equation, which is similar to that of active tracer - temperature or salinity :19 The time evolution of any passive tracer $C$ is given by the transport equation, which is similar to that of active tracer - temperature or salinity : 20 20 21 21 \begin{equation} … … 24 24 \end{equation} 25 25 26 where expressions of $D^{lC}$ and $D^{vC}$ depend on the choice for the lateral and vertical subgrid scale parameterizations , see equations 5.10 and 5.11 in \citep{nemo_manual}27 28 {S(C)} , the first term on the right hand side of \autoref{Eq_tracer}; is the SMS - Source Minus Sink- inherent to the tracer.29 In the case of biological tracer such as phytoplankton, {S(C)} is the balance between phytoplankton growth and its decaythrough mortality and grazing.30 In the case of a tracer comprising carbon, {S(C)} accounts for gas exchange, river discharge, flux to the sediments, gravitational sinking and other bio logical processes.31 In the case of a radioactive tracer, {S(C)} is simply loss due to radioactive decay.26 where expressions of $D^{lC}$ and $D^{vC}$ depend on the choice for the lateral and vertical subgrid scale parameterizations (see Equations 5.10 and 5.11 in \cite{nemo_manual}). 27 28 {S(C)}, the first term on the right hand side of \autoref{Eq_tracer}, is the SMS - Sources Minus Sinks - inherent to the tracer. 29 In the case of a biological tracer such as phytoplankton, {S(C)} is the balance between phytoplankton growth and its loss through mortality and grazing. 30 In the case of a tracer comprising carbon, {S(C)} accounts for gas exchange, river discharge, flux to the sediments, gravitational sinking and other biogeochemical processes. 31 In the case of a radioactive tracer, {S(C)} is simply the loss due to radioactive decay. 32 32 33 33 The second term (within brackets) represents the advection of the tracer in the three directions. … … 36 36 The third term represents the change due to lateral diffusion. 37 37 38 The fourth term ischange due to vertical diffusion, parameterized as eddy diffusion to represent vertical turbulent fluxes :38 The fourth term denotes the change due to vertical diffusion, parameterized as eddy diffusion to represent vertical turbulent fluxes : 39 39 40 40 \begin{equation} … … 43 43 \end{equation} 44 44 45 where $A^{vT}$ is the vertical eddy diffusivity coefficient of active tracers 45 where $A^{vT}$ is the vertical eddy diffusivity coefficient of active tracers. 46 46 47 47 \section{The NEMO-TOP interface} 48 48 \label{sec:TopInt} 49 49 50 TOP is the NEMO hardwired interface toward biogeochemical models and providethe physical constraints/boundaries for oceanic tracers.50 TOP is the NEMO hardwired interface toward biogeochemical models, which provides the physical constraints/boundaries for oceanic tracers. 51 51 It consists of a modular framework to handle multiple ocean tracers, including also a variety of built-in modules. 52 52 53 This component of the NEMO framework allows one to exploit available modules and further develop a range of applications, spanning from the implementation of a dye passive tracer to evaluate dispersion processes (by means of MY\_TRC), track water masses age (AGE module), assess the ocean interior penetration of persistent chemical compounds (e.g., gases like CFC or even PCBs), up to the full set of equations involvingmarine biogeochemical cycles.53 This component of the NEMO framework allows one to exploit available modules and further develop a range of applications, spanning from the implementation of a dye passive tracer to evaluate dispersion processes (by means of MY\_TRC), track water masses age (AGE module), assess the ocean interior penetration of persistent chemical compounds (e.g., gases like CFC or even PCBs), up to the full set of equations to simulate marine biogeochemical cycles. 54 54 55 55 TOP interface has the following location in the code repository : \path{<repository>/src/TOP/} … … 60 60 \begin{itemize} 61 61 \item \textbf{TRP} : Interface to NEMO physical core for computing tracers transport 62 \item \textbf{CFC} : Inert carbontracers (CFC11,CFC12, SF6)62 \item \textbf{CFC} : Inert tracers (CFC11,CFC12, SF6) 63 63 \item \textbf{C14} : Radiocarbon passive tracer 64 64 \item \textbf{AGE} : Water age tracking 65 65 \item \textbf{MY\_TRC} : Template for creation of new modules and external BGC models coupling 66 \item \textbf{PISCES} : Built in BGC model. 67 See \citep{aumont_2015} for a throughout description. 66 \item \textbf{PISCES} : Built in BGC model. See \cite{aumont_2015} for a complete description 68 67 \end{itemize} 69 68 % ---------------------------------------------------------- … … 71 70 \section{The transport component : TRP} 72 71 73 The passive tracer transport component 72 The passive tracer transport component shares the same advection/diffusion routines with the dynamics, with specific treatment of some features like the surface boundary conditions, or the positivity of passive tracers concentrations. 74 73 75 74 \subsection{Advection} 75 76 The advection schemes used for the passive tracers are the same as those used for $T$ and $S$. They are described in section 5.1 of \cite{nemo_manual}. 77 The choice of an advection scheme can be selected independently and can differ from the ones used for active tracers. 78 This choice is made in \textit{namelist\_to}p (ref or cfg) in the namelist block \textit{namtrc\_adv}, by setting to \textit{true} one and only one of the logicals \textit{ln\_trcadv\_xxx}, the same way of what is done for dynamics. 79 cen2, MUSCL2, and UBS are not \textit{positive} schemes meaning that negative values can appear in an initially strictly positive tracer field which is advected, implying that artificial extrema are permitted. Their use is not recommended for passive tracers. 80 76 81 %------------------------------------------namtrc_adv---------------------------------------------------- 77 82 \nlst{namtrc_adv} 78 %------------------------------------------------------------------------------------------------------------- 79 The advection schemes used for the passive tracers are the same than the ones for $T$ and $S$ and described in section 5.1 of \citep{nemo_manual}. 80 The choice of an advection scheme can be selected independently and can differ from the ones used for active tracers. 81 This choice is made in the \textit{namtrc\_adv} namelist, by setting to \textit{true} one and only one of the logicals \textit{ln\_trcadv\_xxx}, the same way of what is done for dynamics. 82 cen2, MUSCL2, and UBS are not \textit{positive} schemes meaning that negative values can appear in an initially strictly positive tracer field which is advected, implying that false extrema are permitted. 83 Their use is not recommended on passive tracers 83 %---------------------------------------------------------------------------------------------------------- 84 84 85 85 \subsection{Lateral diffusion} 86 87 In NEMO v4.0, diffusion of passive tracers has necessarily the same form as the active tracer diffusion, meaning that the numerical scheme must be the same. 88 However the passive tracer mixing coefficient can be chosen as a multiple of the active ones by changing the value of \textit{rn\_ldf\_multi} in namelist \textit{namtrc\_ldf}. 89 The choice of the numerical scheme is then set in the \forcode{&namtra_ldf} namelist section for the dynamic described in section 5.2 of \cite{nemo_manual}. 90 91 rn\_fact\_lap is a factor used to increase zonal equatorial diffusion for depths beyond 200 m. It can be useful to achieve a better representation of Oxygen Minimum Zone (OMZ) in some biogeochemical models, especially at coarse resolution \citep{getzlaff_2013}. 92 86 93 %------------------------------------------namtrc_ldf---------------------------------------------------- 87 94 \nlst{namtrc_ldf} 88 %------------------------------------------------------------------------------------------------------------- 89 In NEMO v4.0, the passive tracer diffusion has necessarily the same form as the active tracer diffusion, meaning that the numerical scheme must be the same. 90 However the passive tracer mixing coefficient can be chosen as a multiple of the active ones by changing the value of \textit{rn\_ldf\_multi} in namelist \textit{namtrc\_ldf}. 91 The choice of numerical scheme is then set in the \forcode{&namtra_ldf} namelist for the dynamic described in section 5.2 of \citep{nemo_manual}. 95 %--------------------------------------------------------------------------------------------------------- 92 96 93 97 %-----------------We also offers the possibility to increase zonal equatorial diffusion for passive tracers by introducing an enhanced zonal diffusivity coefficent in the equatorial domain which can be defined by the equation below : … … 98 102 \subsection{Tracer damping} 99 103 104 The use of newtonian damping to climatological fields or observations is also coded, sharing the same routine as that of active tracers. 105 Boolean variables are defined in the namelist\_top\_ref to select the tracers on which restoring is applied. 106 Options are defined through the \textit{\&namtrc\_dmp} namelist variables. 107 The restoring term is added when the namelist parameter \textit{ln\_trcdmp} is set to \textit{true}. 108 The restoring coefficient is a three-dimensional array read in a file, whose name is specified by the namelist variable \textit{cn\_resto\_tr}. 109 This netcdf file can be generated using the DMP\_TOOLS tool. 110 100 111 %------------------------------------------namtrc_dmp---------------------------------------------------- 101 112 \nlst{namtrc_dmp} 102 %------------------------------------------------------------------------------------------------------------- 103 104 The use of newtonian damping to climatological fields or observations is also coded, sharing the same routine dans active tracers. 105 Boolean variables are defined in the namelist\_top\_ref to select the tracers on which restoring is applied 106 Options are defined through the \nam{trc_dmp}{trc\_dmp} namelist variables. 107 The restoring term is added when the namelist parameter \np{ln\_trcdmp} is set to true. 108 The restoring coefficient is a three-dimensional array read in a file, which name is specified by the namelist variable \np{cn\_resto\_tr}. 109 This netcdf file can be generated using the DMP\_TOOLS tool. 113 %----------------------------------------------------------------------------------------------------------- 110 114 111 115 \subsection{Tracer positivity} 116 117 Some numerical schemes can generate negative values of passive tracers concentration, which is obviously unrealistic. 118 For example, isopycnal diffusion can created local extrema, meaning that negative concentrations can be generated. 119 The trcrad routine artificially corrects negative concentrations with a very crude solution that either sets negative concentrations to zero without adjusting the tracer budget (CFCs or C14 chemical coumpounds), or by removing negative concentrations while computing the corresponding tracer content that is added and then, adjusting the tracer concentration using a multiplicative factor so that the total tracer concentration is preserved (PISCES model). 120 The treatment of negative concentrations is an option and can be selected in the namelist \textit{\&namtrc\_rad} by setting the parameter \textit{ln\_trcrad} to true. 112 121 113 122 %------------------------------------------namtrc_rad---------------------------------------------------- 114 123 \nlst{namtrc_rad} 115 %------------------------------------------------------------------------------------------------------------- 116 117 Sometimes, numerical scheme can generates negative values of passive tracers concentration that must be positive. 118 For exemple, isopycnal diffusion can created extrema. 119 The trcrad routine artificially corrects negative concentrations with a very crude solution that either sets negative concentration to zero without adjusting the tracer budget, or by removing negative concentration and keeping mass conservation. 120 The treatment of negative concentrations is an option and can be selected in the namelist \nam{trc_rad}{trc\_rad} by setting the parameter \np{ln\_trcrad} to true. 124 %---------------------------------------------------------------------------------------------------------- 125 126 \subsection{Tracer boundary conditions} 127 128 In NEMO, different types of boundary conditions can be specified for biogeochemical tracers. For every single variable, it is possible to define a field of surface boundary conditions, such as deposition of dust or nitrogen, which is then interpolated to the grid and timestep using the fld\_read function. The same facility is available to include river inputs or coastal erosion (coastal boundary conditions) and the treatment of open boundary conditions. For lateral boundary conditions, spatial interpolation should not be activated. 129 130 %------------------------------------------namtrc_bc---------------------------------------------------- 131 \nlst{namtrc_cfg} 132 %--------------------------------------------------------------------------------------------------------- 133 134 \subsubsection{Surface and lateral boundaries} 135 136 The namelist \textit{\&namtrc\_bc} is in file \textit{namelist\_top\_cfg} and allows to specify the name of the files, the frequency of the input and the time and space interpolation as done for any other field using the fld\_read interface. 137 138 %------------------------------------------namtrc_bc---------------------------------------------------- 139 \nlst{namtrc_bc} 140 %--------------------------------------------------------------------------------------------------------- 141 \subsubsection{Open boundaries} 142 143 The BDY for passive tracer are set together with the physical oceanic variables (lnbdy =.true.). Boundary conditions are set in the structure used to define the passive tracer properties in the « cbc » column. These boundary conditions are applied on the segments defined for the physical core of NEMO (see BDY description in the User Manual). 144 \begin{itemize} 145 \item cn\_trc\_dflt : the type of OBC applied to all the tracers 146 \item cn\_trc : the boundary condition used for tracers with data file 147 \end{itemize} 148 149 %------------------------------------------namtrc_bdy---------------------------------------------------- 150 \nlst{namtrc_bdy} 151 %---------------------------------------------------------------------------------------------------------- 152 153 \subsubsection{Sedimentation of particles} 154 155 This module computes the vertical flux of particulate matter due to gravitational sinking. It also offers a temporary solution for the problem that may arise in specific situation where the CFL criterion is broken for vertical sedimentation of particles. To avoid this, a time splitting algorithm has been coded. The number of iterations niter necessary to respect the CFL criterion is dynamically computed. A specific maximum number of iterations nitermax may be specified in the namelist. This is to avoid a very large number of iterations when explicit free surface is used, for instance. If niter is larger than the prescribed nitermax, sinking speeds are clipped so that the CFL criterion is respected. The numerical scheme used to compute sedimentation is based on the MUSCL advection scheme. 156 157 %------------------------------------------namtrc_bdy---------------------------------------------------- 158 \nlst{namtrc_snk} 159 %---------------------------------------------------------------------------------------------------------- 160 161 \subsubsection{Sea-ice growth and melt effect} 162 163 NEMO provides three options for the specification of tracer concentrations in sea ice: (-1) identical tracer concentrations in sea ice and ocean, which corresponds to no concentration/dilution effect upon ice growth and melt; (0) zero concentrations in sea ice, which gives the largest concentration-dilution effect upon ice growth and melt; (1) specified concentrations in sea ice, which gives a possibly more realistic effect of sea ice on tracers. Option (-1) and (0) work for all tracers, but (1) is currently only available for PISCES. 164 165 %------------------------------------------namtrc_ice---------------------------------------------------- 166 \nlst{namtrc_ice} 167 %--------------------------------------------------------------------------------------------------------- 168 169 \subsubsection{Antartic Ice Sheet tracer supply} 170 171 The external input of biogeochemical tracers from the Antarctic Ice Sheet (AIS) is represented by associating a tracer content with the freshwater flux from icebergs and ice shelves \citep{person_sensitivity_2019}. This supply is currently implemented only for dissolved Fe (\autoref{img_icbisf}) and is effective in model configurations with south-extended grids (eORCA1 and eORCA025). As the ORCA2 grid does not extend south into Antarctica, the external source of tracers from the AIS cannot be enabled in this configuration. 172 173 For icebergs, a homogeneous distribution of biogeochemical tracers is applied from the surface to a depth that can be defined in \textit{\&namtrc\_ais}, currently set at 120 m. It should be noted that the freshwater flux from icebergs affects only the ocean properties at the surface. For ice shelves, biogeochemical tracers follow the explicit or parameterized representation of freshwater flux distribution modeled in NEMO. The AIS tracer supply is activated by setting \textit{ln\_trcais} to \textit{true} in the \textit{\&namtrc} section. 174 175 \begin{figure}[!h] 176 \centering 177 \includegraphics[width=0.80\textwidth]{ICB-ISF-Feflx} 178 \caption{Annual Fe fluxes from icebergs and ice shelves in the Southern Ocean.} 179 \label{img_icbisf} 180 \end{figure} 181 182 %------------------------------------------namtrc_ais---------------------------------------------------- 183 \nlst{namtrc_ais} 184 %--------------------------------------------------------------------------------------------------------- 121 185 122 186 \section{The SMS modules} … … 129 193 \subsection{Ideal Age} 130 194 %------------------------------------------namage---------------------------------------------------- 131 %132 195 \nlst{namage} 133 196 %---------------------------------------------------------------------------------------------------------- 134 197 135 198 An `ideal age' tracer is integrated online in TOP when \textit{ln\_age} = \texttt{.true.} in namelist \textit{namtrc}. 136 This tracer marks the length of time in units of years that fluid has spent in the interior of the ocean, insulated from exposure to the atmosphere. 199 This tracer marks the duration in units of years that fluid has spent in the interior of the ocean, insulated from exposure to the atmosphere (\autoref{img_ageatl} and \autoref{img_age200}). 200 201 \begin{figure}[!h] 202 \centering 203 \includegraphics[width=0.80\textwidth]{Age_Atl} 204 \caption{Vertical distribution of the Age tracer in the Atlantic Ocean at 35°W from a 62-year simulation.} 205 \label{img_ageatl} 206 \end{figure} 207 208 \begin{figure}[!h] 209 \centering 210 \includegraphics[width=0.80\textwidth]{Age_200m} 211 \caption{Age tracer at 200 m depth from a 62-year simulation.} 212 \label{img_age200} 213 \end{figure} 214 137 215 Thus, away from the surface for $z<-H_{\mathrm{Age}}$ where $H_{\mathrm{Age}}$ is specified by the \textit{namage} namelist variable \textit{rn\_age\_depth}, whose default value is 10~m, there is a source $\mathrm{SMS_{\mathrm{Age}}}$ of the age tracer $A$: 138 216 … … 151 229 152 230 where the relaxation rate $\lambda_{\mathrm{Age}}$ (units $\mathrm{s}\;^{-1}$) is specified by the \textit{namage} namelist variable \textit{rn\_age\_kill\_rate} and has a default value of 1/7200~s. 153 Since this relaxation is applied explicitly, th is relaxation rate in principle shouldnot exceed $1/\Delta t$, where $\Delta t$ is the time step used to step forward passive tracers (2 * \textit{nn\_dttrc * rn\_rdt} when the default leapfrog time-stepping scheme is employed).231 Since this relaxation is applied explicitly, the relaxation rate should in principle not exceed $1/\Delta t$, where $\Delta t$ is the time step used to step forward passive tracers (2 * \textit{nn\_dttrc * rn\_rdt} when the default leapfrog time-stepping scheme is employed). 154 232 155 233 Currently the 1-dimensional reference depth of the grid boxes is used rather than the dynamically evolving depth to determine whether the age tracer is incremented or relaxed to zero. 156 This means that the traceronly works correctly in z-coordinates.157 To ensure that the forcing is independent of the level thicknesses, where the tracer cell at level $k$ has its upper face $z=-depw(k)$ above the depth $-H_{\mathrm{Age}}$, but its lower face $z=-depw(k+1)$ below that depth, then the age source 234 This means that the age tracer module only works correctly in z-coordinates. 235 To ensure that the forcing is independent of the level thicknesses, where the tracer cell at level $k$ has its upper face $z=-depw(k)$ above the depth $-H_{\mathrm{Age}}$, but its lower face $z=-depw(k+1)$ below that depth, then the age source is computed as: 158 236 159 237 \begin{equation} … … 169 247 \end{align} 170 248 171 172 This implementation was first used in the CORE-II intercomparison runs described e.g.\ in \citet{danabasoglu_2014}. 249 This implementation was first used in the CORE-II intercomparison runs described in \citet{danabasoglu_2014}. 173 250 174 251 \subsection{Inert carbons tracer} … … 184 261 and additionally as an aerosol propellant. 185 262 SF6 (SF$_{6}$) is also a gas at room temperature, with a range of applications based around its property as an excellent electrical insulator (often replacing more toxic alternatives). 186 All three are relatively inert chemicals that are both non-toxic and non-flammable, and their wide use has led to their accumulation within the Earth'satmosphere.187 Large-scale production of CFC-11 and CFC-12 began in the 1930s, while production of SF6 began in the 1950s, and the ir atmospheric concentration time-histories are shown in Figure \autoref{img_cfcatm}.188 As can be seen in the figure, while the concentration of SF6 continues to rise to the present day, theconcentrations of both CFC-11 and CFC-12 have levelled off and declined since around the 1990s.263 All three gases are relatively inert chemicals that are both non-toxic and non-flammable, and their wide use has led to their accumulation in the atmosphere. 264 Large-scale production of CFC-11 and CFC-12 began in the 1930s, while production of SF6 began in the 1950s, and the time-histories of their atmospheric concentrations are shown in Figure \autoref{img_cfcatm}. 265 As can be seen in the figure, while the concentration of SF6 continues to rise to the present day, concentrations of both CFC-11 and CFC-12 have levelled off and declined since around the 1990s. 189 266 These declines have been driven by the Montreal Protocol (effective since August 1989), which has banned the production of CFC-11 and CFC-12 (as well as other CFCs) because of their role in the depletion of 190 stratospheric ozone (O$_{3}$), critical in decreasing the flux of ultraviolet radiation to the Earth's surface. 191 Separate to this role in ozone-depletion, all three chemicals are significantly more potent greenhouse gases 267 stratospheric ozone (O$_{3}$), critical in decreasing the flux of ultraviolet radiation to the Earth's surface. All three chemicals are also significantly more potent greenhouse gases 192 268 than CO$_{2}$ (especially SF6), although their relatively low atmospheric concentrations limit their role in climate change. \\ 193 269 … … 204 280 The ocean is a notable sink for all three gases, and their relatively recent occurrence in the atmosphere, coupled to the ease of making high precision measurements of their dissolved concentrations, has made them 205 281 valuable in oceanography. % for tracking interior ventilation and mixing. 206 Because they only enter the ocean via surface air-sea exchange, and are almost completely chemically and biologically inert, their distribution within the ocean interior reveals its ventilationvia transport and mixing.207 Measuring the dissolved concentrations of the gases -- as well as the mixing ratios between them -- shows circulation pathways within the ocean as well as water mass ages (i.e. the time since lastcontact with the282 Because they only enter the ocean via surface air-sea exchange, and are almost completely chemically and biologically inert, their distribution within the ocean interior reveals ventilation of the latter via transport and mixing. 283 Measuring the dissolved concentrations of these gases -- as well as the mixing ratios between them -- shows circulation pathways within the ocean as well as water mass ages (i.e. the time since has been last in contact with the 208 284 atmosphere). 209 This feature of the gaseshas made them valuable across a wide range of oceanographic problems.210 One use lies in ocean modelling, where they can be used to evaluate the realism of thecirculation and211 ventilation of models, key for understanding the behaviour of widermodelled marine biogeochemistry (e.g. \citep{dutay_2002,palmieri_2015}). \\285 This feature has made them valuable across a wide range of oceanographic problems. 286 In ocean modelling, they can be used to evaluate the realism of the simulated circulation and 287 ventilation patterns, which is key for understanding the behaviour of modelled marine biogeochemistry (e.g. \citep{dutay_2002,palmieri_2015}). \\ 212 288 213 289 Modelling these gases (henceforth CFCs) in NEMO is done within the passive tracer transport module, TOP, using the conservation state equation \autoref{Eq_tracer} 214 290 215 Advection and diffusion of the CFCs in NEMO are calculated by the physical module, OPA,291 Advection and diffusion of the CFCs in NEMO are calculated by the physical module, TRP, 216 292 whereas sources and sinks are done by the CFC module within TOP. 217 The only source for CFCs inthe ocean is via air-sea gas exchange at its surface, and since CFCs are generally293 The only source of CFCs to the ocean is via air-sea gas exchange at its surface, and since CFCs are generally 218 294 stable within the ocean, we assume that there are no sinks (i.e. no loss processes) within the ocean interior. 219 295 Consequently, the sinks-minus-sources term for CFCs consists only of their air-sea fluxes, $F_{cfc}$, as … … 233 309 $C_{surf}$ is the local surface concentration of the CFC tracer within the model (in mol~m$^{-3}$); 234 310 and $f_{i}$ is the fractional sea-ice cover of the local ocean (ranging between 0.0 for ice-free ocean, 235 throughto 1.0 for completely ice-covered ocean with no air-sea exchange).311 to 1.0 for completely ice-covered ocean with no air-sea exchange). 236 312 237 313 The saturation concentration of the CFC, $C_{sat}$, is calculated as follows: … … 312 388 % AXY: consider an itemized list here if you've got a list of differences 313 389 314 For instance, C$_{sat}$ is calculated for a fixed surface pressure of 1atm , what could be corrected in a furtherversion of the module.390 For instance, C$_{sat}$ is calculated for a fixed surface pressure of 1atm. This may be corrected in a future version of the module. 315 391 316 392 … … 333 409 334 410 \begin{table}[!t] 335 \caption{Coefficients for fit of the CFCs Schmidt number (Eq. \autoref{equ_Sc}). 411 \caption{Coefficients for fit of the CFCs Schmidt number (Eq. \autoref{equ_Sc}).} 336 412 \vskip4mm 337 413 \centering … … 384 460 %---------------------------------------------------------------------------------------------------------- 385 461 386 The C14 package implemented in NEMO by Anne Mouchet models ocean$\Dcq$.462 The C14 package has been implemented in NEMO by Anne Mouchet $\Dcq$. 387 463 It offers several possibilities: $\Dcq$ as a physical tracer of the ocean ventilation (natural $\cq$), assessment of bomb radiocarbon uptake, as well as transient studies of paleo-historical ocean radiocarbon distributions. 388 464 … … 390 466 391 467 Let $\Rq$ represent the ratio of $\cq$ atoms to the total number of carbon atoms in the sample, i.e. $\cq/\mathrm{C}$. 392 Then, radiocarbon anomalies are reported as 468 Then, radiocarbon anomalies are reported as: 393 469 394 470 \begin{equation} … … 397 473 398 474 where $\Rq_{\textrm{ref}}$ is a reference ratio. 399 For the purpose of ocean ventilation studies $\Rq_{\textrm{ref}}$ is set to one.475 For the purpose of ocean ventilation studies, $\Rq_{\textrm{ref}}$ is set to one. 400 476 401 477 Here we adopt the approach of \cite{fiadeiro_1982} and \cite{toggweiler_1989a,toggweiler_1989b} in which the ratio $\Rq$ is transported rather than the individual concentrations C and $\cq$. … … 464 540 The radiocarbon decay rate (\forcode{rlam14}; in \texttt{trcnam\_c14} module) is set to $\lambda=(1/8267)$ yr$^{-1}$ \citep{stuiver_1977}, which corresponds to a half-life of 5730 yr.\\[1pt] 465 541 % 466 The Schmidt number $Sc$, Eq. \autoref{eq:wanc14}, is calculated with the help ofthe formulation of \cite{wanninkhof_2014}.542 The Schmidt number $Sc$, Eq. \autoref{eq:wanc14}, is calculated using the formulation of \cite{wanninkhof_2014}. 467 543 The $\cd$ solubility $K_0$ in \autoref{eq:Rspeed} is taken from \cite{weiss_1974}. $K_0$ and $Sc$ are computed with the OGCM temperature and salinity fields (\texttt{trcsms\_c14} module).\\[1pt] 468 544 % … … 522 598 \end{figure} 523 599 524 Performing this type of experiment requires that a pre-industrial equilibrium run beperformed beforehand (\forcode{ln\_rsttr} should be set to \texttt{.TRUE.}).525 526 An exception to this rule is when wishing to performa perturbation bomb experiment as was possible with the package \texttt{C14b}.600 Performing this type of experiment requires that a pre-industrial equilibrium run has been performed beforehand (\forcode{ln\_rsttr} should be set to \texttt{.TRUE.}). 601 602 An exception to this rule is when performing a perturbation bomb experiment as was possible with the package \texttt{C14b}. 527 603 It is still possible to easily set-up that type of transient experiment for which no previous run is needed. 528 In addition to the instructions as given in this sectionit is however necessary to adapt the \texttt{atmc14.dat} file so that it does no longer contain any negative $\Dcq$ values (Suess effect in the pre-bomb period).604 In addition to the instructions given in this section, it is however necessary to adapt the \texttt{atmc14.dat} file so that it does no longer contain any negative $\Dcq$ values (Suess effect in the pre-bomb period). 529 605 530 606 The model is integrated from a given initial date following the observed records provided from 1765 AD on ( Fig. \autoref{fig:bomb}). … … 535 611 Dates in these forcing files are expressed as yr AD. 536 612 537 To ensure that the atmospheric forcing is applied properly as well as that output files contain consistent dates and inventories the experiment should be set up carefully:613 To ensure that the atmospheric forcing is applied properly as well as that output files contain consistent dates and inventories, the experiment should be set up carefully: 538 614 539 615 \begin{itemize} … … 543 619 \end{itemize} 544 620 545 If the experiment date is outside the data time span then the first or last atmospheric concentrations areprescribed depending on whether the date is earlier or later.546 Note that \forcode{tyrc14\_beg} (\texttt{namelist\_c14}) is not used in this context.621 If the experiment date is outside the data time span, the first or last atmospheric concentrations are then prescribed depending on whether the date is earlier or later. 622 Note that \forcode{tyrc14\_beg} (\texttt{namelist\_c14}) is not used in this context. 547 623 548 624 % … … 582 658 583 659 All output fields in Table \autoref{tab:out} are routinely computed. 584 It depends on the actual settings in \texttt{iodef.xml} whether they are s tored or not.660 It depends on the actual settings in \texttt{iodef.xml} whether they are saved or not. 585 661 % 586 662 \begin{table}[!h] … … 645 721 \subsection{PISCES biogeochemical model} 646 722 647 PISCES is a biogeochemical model which simulates the lower trophic levels of marine ecosystem (phytoplankton, microzooplankton and mesozooplankton) and the biogeochemical cycles of carbonand of the main nutrients (P, N, Fe, and Si). 648 The model is intended to be used for both regional and global configurations at high or low spatial resolutions as well as for short-term (seasonal, interannual) and long-term (climate change, paleoceanography) analyses. 723 PISCES is a biogeochemical model that simulates the lower trophic levels of marine ecosystem (phytoplankton, microzooplankton, and mesozooplankton) and the biogeochemical cycles of carbon and of the main nutrients (P, N, Si, and Fe) (\autoref{img_piscesdesign} and \autoref{img_pisces}). 724 725 \begin{figure}[ht] 726 \begin{center} 727 \vspace{0cm} 728 \includegraphics[width=0.80\textwidth]{Fig_PISCES_model} 729 \caption{Schematic view of the PISCES-v2 model (figure by Jorge Martinez-Rey).} 730 \label{img_piscesdesign} 731 \end{center} 732 \end{figure} 733 734 \begin{figure}[!h] 735 \centering 736 \includegraphics[width=0.80\textwidth]{PISCES_tracers} 737 \caption{Surface concentrations of NO$_{3}$, PO$_{4}$, total chlorophyll, and air-sea CO$_{2}$ flux from the last year of a 62-year simulation.} 738 \label{img_pisces} 739 \end{figure} 740 741 The model is intended to be used for both regional and global configurations at high or low spatial resolutions as well as for short-term (seasonal, interannual) and long-term (climate change, paleoceanography) analyses. 742 649 743 Two versions of PISCES are available in NEMO v4.0 : 650 744 651 PISCES-v2, by setting in namelist\_pisces\_ref \np{ln\_p4z} to true, can be seen as one of the many Monod models \citep{monod_1958}. 652 It assumes a constant Redfield ratio and phytoplankton growth depends on the external concentration in nutrients. 653 There are twenty-four prognostic variables (tracers) including two phytoplankton compartments (diatoms and nanophytoplankton), two zooplankton size-classes (microzooplankton and mesozooplankton) and a description of the carbonate chemistry. 654 Formulations in PISCES-v2 are based on a mixed Monod/Quota formalism: On one hand, stoichiometry of C/N/P is fixed and growth rate of phytoplankton is limited by the external availability in N, P and Si. 655 On the other hand, the iron and silicium quotas are variable and growth rate of phytoplankton is limited by the internal availability in Fe. 656 Various parameterizations can be activated in PISCES-v2, setting for instance the complexity of iron chemistry or the description of particulate organic materials. 657 658 PISCES-QUOTA has been built on the PISCES-v2 model described in \citet{aumont_2015}. 659 PISCES-QUOTA has thirty-nine prognostic compartments. 660 Phytoplankton growth can be controlled by five modeled limiting nutrients: Nitrate and Ammonium, Phosphate, Silicate and Iron. 661 Five living compartments are represented: Three phytoplankton size classes/groups corresponding to picophytoplankton, nanophytoplankton and diatoms, and two zooplankton size classes which are microzooplankton and mesozooplankton. 662 For phytoplankton, the prognostic variables are the carbon, nitrogen, phosphorus, iron, chlorophyll and silicon biomasses (the latter only for diatoms). 663 This means that the N/C, P/C, Fe/C and Chl/C ratios of both phytoplankton groups as well as the Si/C ratio of diatoms are prognostically predicted by the model. 664 Zooplankton are assumed to be strictly homeostatic \citep[e.g.,][]{sterner_2003,woods_2013,meunier_2014}. 665 As a consequence, the C/N/P/Fe ratios of these groups are maintained constant and are not allowed to vary. 666 In PISCES, the Redfield ratios C/N/P are set to 122/16/1 \citep{takahashi_1985} and the -O/C ratio is set to 1.34 \citep{kortzinger_2001}. 667 No silicified zooplankton is assumed. 668 The bacterial pool is not yet explicitly modeled. 745 \begin{itemize} 746 \item PISCES-v2, by setting \textit{ln\_p4z} = \texttt{.true.} in \textit{namelist\_pisces\_ref}. This version can be seen as one of the many Monod models \citep{monod_1958}. It assumes a constant Redfield ratio and phytoplankton growth depends on the external concentration in nutrients. There are twenty-four prognostic variables (tracers) including two phytoplankton compartments (diatoms and nanophytoplankton), two zooplankton size-classes (microzooplankton and mesozooplankton) and a description of the carbonate chemistry. Formulations in PISCES-v2 are based on a mixed Monod/Quota formalism: On one hand, stoichiometry of C/N/P is fixed and growth rate of phytoplankton is limited by the external availability in N, P, and Si. On the other hand, the iron and silicium quotas are variable and growth rate of phytoplankton is limited by the internal availability in Fe. Various parameterizations can be activated in PISCES-v2, setting for instance the complexity of iron chemistry or the description of particulate organic materials. 747 748 \item PISCES-QUOTA, by setting \textit{ln\_p5z} = \texttt{.true.} in \textit{namelist\_pisces\_ref}. This version has been built on the PISCES-v2 model described in \citet{aumont_2015}. PISCES-QUOTA has thirty-nine prognostic compartments. Phytoplankton growth is controlled by five modeled limiting nutrients: Nitrate and Ammonium, Phosphate, Silicate, and Iron. Five living compartments are represented: Three phytoplankton size classes/groups corresponding to picophytoplankton, nanophytoplankton, and diatoms, and two zooplankton size classes, which are microzooplankton and mesozooplankton. For phytoplankton, the prognostic variables are the carbon, nitrogen, phosphorus, iron, chlorophyll and silicon biomasses (the latter only for diatoms). This means that the N/C, P/C, Fe/C, and Chl/C ratios of the three phytoplankton groups as well as the Si/C ratio of diatoms are prognostically predicted by the model. Zooplankton are assumed to be strictly homeostatic \citep[e.g.,][]{sterner_2003,woods_2013,meunier_2014}. As a consequence, the C/N/P/Fe ratios of these groups are maintained constant and are not allowed to vary. In PISCES, the Redfield ratios C/N/P are set to 122/16/1 \citep{takahashi_1985} and the -O/C ratio is set to 1.34 \citep{kortzinger_2001}. No silicified zooplankton is assumed. The bacterial pool is not yet explicitly modeled. 749 \end{itemize} 669 750 670 751 There are three non-living compartments: Semi-labile dissolved organic matter, small sinking particles, and large sinking particles. 671 752 As a consequence of the variable stoichiometric ratios of phytoplankton and of the stoichiometric regulation of zooplankton, elemental ratios in organic matter cannot be supposed constant anymore as that was the case in PISCES-v2. 672 Indeed, the nitrogen, phosphorus, iron, silicon and calcite pools of the particles are now all explicitly modeled.753 Indeed, the nitrogen, phosphorus, iron, silicon, and calcite pools of the particles are now all explicitly modeled. 673 754 The sinking speed of the particles is not altered by their content in calcite and biogenic silicate (''The ballast effect'', \citep{honjo_1996,armstrong_2001}). 674 755 The latter particles are assumed to sink at the same speed as the large organic matter particles. … … 678 759 \label{Mytrc} 679 760 680 The NEMO-TOP has only one built-in biogeochemical model - PISCES - but there are several BGC models - MEDUSA, ERSEM, BFM or ECO3M - which are meant to be coupled with the NEMO dynamics.681 Therefore it was necessary to provide to the users a framework for easily add their own BGCM model, that can be a single passive tracer.761 NEMO-TOP has one built-in biogeochemical model - PISCES - but there are several BGC models - MEDUSA, ERSEM, BFM or ECO3M - which are meant to be used within the NEMO plateform. 762 Therefore it was necessary to provide to the users a framework to easily add their own BGCM model. 682 763 The generalized interface is pivoted on MY\_TRC module that contains template files to build the coupling between NEMO and any external BGC model. 683 The call to MY\_TRC is activated by setting \textit{ln\_my\_trc} = \texttt{.true.} in namelist \textit{namtrc} 764 Call to MY\_TRC is activated by setting \textit{ln\_my\_trc} = \texttt{.true.} in namelist \textit{namtrc}.\\ 684 765 685 766 The following 6 fortran files are available in MY\_TRC with the specific purposes here described. … … 692 773 \item \textit{trcsms\_my\_trc.F90} : The routine performs the call to Boundary Conditions and its main purpose is to contain the Source-Minus-Sinks terms due to the biogeochemical processes of the external model. 693 774 Be aware that lateral boundary conditions are applied in trcnxt routine. 694 IMPORTANT: the routines to compute thelight penetration along the water column and the tracer vertical sinking should be defined/called in here, as generalized modules are still missing in the code.695 \item \textit{trcice\_my\_trc.F90} : Here it is possible to prescribe the tracers concentrations in the seaice that will be used as boundary conditions when icemelting occurs (nn\_ice\_tr =1 in namtrc\_ice).775 IMPORTANT: the routines to compute light penetration along the water column and the tracer vertical sinking should be defined/called in here, as generalized modules are still missing in the code. 776 \item \textit{trcice\_my\_trc.F90} : Here it is possible to prescribe the tracers concentrations in sea ice that will be used as boundary conditions when ice formation and melting occurs (nn\_ice\_tr =1 in namtrc\_ice). 696 777 See e.g. the correspondent PISCES subroutine. 697 778 \item \textit{trcwri\_my\_trc.F90} : This routine performs the output of the model tracers using IOM module (see Manual Chapter Output and Diagnostics). … … 702 783 \label{Offline} 703 784 704 %------------------------------------------namtrc_sms---------------------------------------------------- 705 \nlst{namdta_dyn} 706 %------------------------------------------------------------------------------------------------------------- 707 708 Coupling passive tracers offline with NEMO requires precomputed physical fields from OGCM. 709 Those fields are read from files and interpolated on-the-fly at each model time step 710 At least the following dynamical parameters should be absolutely passed to the transport : ocean velocities, temperature, salinity, mixed layer depth and for ecosystem models like PISCES, sea ice concentration, short wave radiation at the ocean surface, wind speed (or at least, wind stress). 711 The so-called offline mode is useful since it has lower computational costs for example to perform very longer simulations - about 3000 years - to reach equilibrium of CO2 sinks for climate-carbon studies. 712 713 The offline interface is located in the code repository : \path{<repository>/src/OFF/}. 714 It is activated by adding the CPP key \textit{key\_offline} to the CPP keys list. 715 There are two specifics routines for the Offline code : 785 Coupling passive tracers offline with NEMO requires precomputed physical fields 786 from OGCM. Those fields are read in files and interpolated on-the-fly at each model 787 time step. There are two sets of fields to perform offline simulations : 716 788 717 789 \begin{itemize} 718 \item \textit{dtadyn.F90} : this module allows to read and compute the dynamical fields at each model time-step 719 \item \textit{nemogcm.F90} : a degraded version of the main nemogcm.F90 code of NEMO to manage the time-stepping 790 \item linear free surface ( ln\_linssh = .true. ) where the vertical scale factor is constant with time. At least, the following dynamical parameters should be absolutely passed 791 to transport : the effective ocean transport velocities (eulerian plus the eddy induced plus all others parameterizations), vertical diffusion coefficient and the freshwater flux 792 . 793 %------------------------------------------namtrc_sms---------------------------------------------------- 794 \nlst{namdta_dyn_linssh} 795 %----------------------------------------------------------------------------------------------------------- 796 \item non linear free surface ( ln\_linssh = .false. or key\_qco ) : the same fields than the ones in the linear free surface case. In addition, the horizontal divergence transport is needed to recompute the time evolution of the sea surface heigth and the vertical scale factor and depth, and thus the time evolution of the vertical transport velocity. 797 %------------------------------------------namtrc_sms---------------------------------------------------- 798 \nlst{namdta_dyn_nolinssh} 799 %----------------------------------------------------------------------------------------------------------- 720 800 \end{itemize} 721 801 722 %- 723 %- 724 %- 725 %- Describes here the specifities of oflline : At least the dynamical variables needed - u/v/w transport T/S for isopycnal MLD for biogeo models etc ... 726 %- the specfities of vvl - ssh + runoffs and how to 727 %- 802 Additionally, temperature, salinity, and mixed layer depth are needed to compute slopes for isopycnal diffusion. Some ecosystem models like PISCES need sea ice concentration, short-wave radiation at the ocean surface, and wind speed (or at least, wind stress). 803 804 The so-called offline mode is useful since it has lower computational costs for example to perform very longer simulations – about 3000 years - to reach equilibrium of CO$_{2}$ sinks for climate-carbon studies. 805 806 The offline interface is located in the code repository : <repository>/src/OFF/. It is activated by adding the\textit{ key\_offline} CPP key to the CPP keys list. 807 There are 808 two specifics routines for the offline code : 809 \begin{itemize} 810 \item dtadyn.F90 : this module reads and computes the dynamical fields at 811 each model time-step 812 \item nemogcm.F90 : a degraded version of the main nemogcm.F90 code of NEMO to 813 manage the time-stepping 814 \end{itemize} 815 816 728 817 \end{document} -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/doc/latex/TOP/subfiles/model_setup.tex
r11591 r14958 5 5 \chapter{ Model Setup} 6 6 7 The usage of TOP is activated i) by including in the configuration definition the component TOP and ii) by adding the macro key\_top in the configuration CPP file (see for more details “Learn more about the model”). 8 As an example, the user can refer to already available configurations in the code, ORCA2\_ICE\_PISCES being the NEMO biogeochemical demonstrator and GYRE\_BFM to see the required configuration elements to couple with an external biogeochemical model (see also Section 4).\\ 9 Note that, since version 4.0, TOP interface core functionalities are activated by means of logical keys and all submodules preprocessing macros from previous versions were removed.\\ 10 11 Below is the list of preprocessing keys that apply to the TOP interface (beside key\_top): 12 \begin{itemize} 13 \item key\_xios use XIOS I/O 14 \item key\_agrif enables AGRIF coupling 15 \item key\_trdtrc and key\_trdmxl\_trc trend computation for tracers 16 \end{itemize} 17 18 There are only two entry points in the NEMOGCM model for passive tracers : 19 \begin{itemize} 20 \item initialization (trcini) : general initialization of global variables and parameters of BGCM 21 \item time-stepping (trcstp) : time-evolution of SMS first, then time evolution of tracers by transport 22 \end{itemize} 23 7 24 \section{ Setting up a passive tracer configuration} 8 25 %------------------------------------------namtrc_int---------------------------------------------------- … … 10 27 %------------------------------------------------------------------------------------------------------------- 11 28 12 The usage of TOP is activated 13 14 \begin{itemize} 15 \item by including in the configuration definition the component TOP\_SRC 16 \item by adding the macro \textit{key\_top} in the configuration cpp file 17 \end{itemize} 18 19 As an example, the user can refer to already available configurations in the code, GYRE\_PISCES being the NEMO biogeochemical demonstrator and GYRE\_BFM to see the required configuration elements to couple with an external biogeochemical model (see also section \S\ref{SMS_models}) . 20 21 Note that, since version 4.0, TOP interface core functionalities are activated by means of logical keys and all submodules preprocessing macros from previous versions were removed. 22 23 There are only three specific keys remaining in TOP 24 25 \begin{itemize} 26 \item \textit{key\_top} : to enables passive tracer module 27 \item \textit{key\_trdtrc} and \textit{key\_trdmxl\_trc} : trend computation for tracers 28 \end{itemize} 29 30 For a remind, the revisited structure of TOP interface now counts for five different modules handled in namelist\_top : 29 As a reminder, the revisited structure of TOP interface now counts for five different modules handled in namelist\_top : 31 30 32 31 \begin{itemize} 33 32 \item \textbf{PISCES}, default BGC model 34 33 \item \textbf{MY\_TRC}, template for creation of new modules couplings (maybe run a single passive tracer) 35 \item \textbf{CFC}, inert carbon tracers dynamics (CFC11,CFC12,SF6) Updated withOMIP-BGC guidelines (Orr et al, 2016)34 \item \textbf{CFC}, inert tracers dynamics (CFC$_{11}$,CFC$_{12}$,SF$_{6}$) updated based on OMIP-BGC guidelines (Orr et al, 2016) 36 35 \item \textbf{C14}, radiocarbon passive tracer 37 \item \textbf{AGE}, water age tracking revised implementation36 \item \textbf{AGE}, water age tracking 38 37 \end{itemize} 39 38 40 The modular approach was implemented also in the definition of the total number of passive tracers (jptra). This results from to user setting from the namelist \textit{namtrc} 39 For inert, C14, and Age tracers, all variables settings (\textit{sn\_tracer} definitions) are hard-coded in \textit{trc\_nam\_*} routines. For instance, for Age tracer: 40 %------------------------------------------namtrc_int---------------------------------------------------- 41 \nlst{nam_trc_age} 42 %--------------------------------------------------------------------------------------------------------- 41 43 42 \section{ TOP Tracer Initialisation} 44 The modular approach was also implemented in the definition of the total number of passive tracers (jptra) which is specified by the user in \textit{namtrc} 45 46 \section{ TOP Tracer Initialization} 47 48 Two main types of data structure are used within TOP interface to initialize tracer properties and to provide related initial and boundary conditions. 49 In addition to providing name and metadata for tracers, the use of initial and boundary conditions is also defined here (sn\_tracer). 50 The data structure is internally initialized by the code with dummy names and all initialization/forcing logical fields are set to \textit{false} . 51 Below are listed some features/options of the TOP interface accessible through the \textit{namelist\_top\_ref} and modifiable by means of \textit{namelist\_top\_cfg} (as for NEMO physical ones). 52 53 There are three options to initialize TOP tracers in the \textit{namelist\_top } file: (1) initialization to hard-coded constant values when \textit{ln\_trcdta} at \textit{false}, (2) initialization from files when \textit{ln\_trcdta} at \textit{true}, and (3) initialisation from restart files by setting \textit{ln\_rsttr} to \textit{true} in \textit{namelist}. 54 55 In the following, an example of the full structure definition is given for four tracers (DIC, Fe, NO$_{3}$, PHY) with initial conditions and different surface boundary and coastal forcings for DIC, Fe, and NO$_{3}$: 56 57 %------------------------------------------namtrc_int---------------------------------------------------- 58 \nlst{namtrc_cfg} 59 %--------------------------------------------------------------------------------------------------------- 60 61 You have to activate which tracers (\textit{sn\_tracer}) you want to initialize by setting them to \texttt{true} in the column. 62 63 \nlst{namtrc_dta_cfg} 64 65 In \textit{namtrc\_dta}, you prescribe from which files the tracer are initialized (\textit{sn\_trcdta}). 66 A multiplicative factor can also be set for each tracer (\textit{rn\_trfac}). 67 43 68 44 69 \section{ TOP Boundaries Conditions} 45 70 71 \subsection{Surface and lateral boundaries} 72 73 Lateral and surface boundary conditions for passive tracers are prescribed in \textit{namtrc\_bc} as well as whether temporal interpolation of these files is enabled. Here we show the cases of Fe and NO$_{3}$ from dust and rivers with different output frequencies. 74 75 %------------------------------------------namtrc_bc---------------------------------------------------- 76 \nlst{namtrc_bc_cfg} 77 %--------------------------------------------------------------------------------------------------------- 78 79 \subsection{Antartic Ice Sheet tracer supply} 80 81 As a reminder, the supply of passive tracers from the AIS is currently implemented only for dissolved Fe. The activation of this Fe source is done by setting \textit{ln\_trcais} to \textit{true} and by adding the Fe tracer (\textit{sn\_tracer(2) = .true.}) in the 'ais' column in \textit{\&namtrc} (see section 2.2). \\ 82 83 As the external source of Fe from the AIS is represented by associating a sedimentary Fe content (with a solubility fraction) to the freshwater fluxes of icebergs and ice shelves, these fluxes have to be activated in \textit{namelist\_cfg}. The reading of the freshwater flux file from ice shelves is activated in \textit{namisf} with the namelist parameter \textit{ln\_isf} set to \textit{true}. 84 85 You have to choose between two options depending whether the cavities under ice shelves are open or not in your grid configuration: 86 \begin{itemize} 87 \item ln\_isfcav\_mlt = .false. (resolved cavities) 88 \item ln\_isfpar\_mlt = .true. (parameterized distribution for unopened cavities) 89 \end{itemize} 90 91 %------------------------------------------namisf---------------------------------------------------- 92 \nlst{namisf_cfg_eORCA1} 93 %----------------------------------------------------------------------------------------------------- 94 95 Runoff from icebergs is activated by setting \textit{ln\_rnf\_icb} to \textit{true} in the \textit{\&namsbc\_rnf} section of \textit{namelist\_cfg}. 96 97 %------------------------------------------namsbc_rnf-------------------------------------------------- 98 \nlst{namsbc_rnf_cfg_eORCA1} 99 %--------------------------------------------------------------------------------------------------------- 100 101 The freshwater flux from ice shelves and icebergs is based on observations and modeled climatologies and is available for eORCA1 and eORCA025 grids : 102 \begin{itemize} 103 \item runoff-icb\_DaiTrenberth\_Depoorter\_eORCA1\_JD.nc 104 \item runoff-icb\_DaiTrenberth\_Depoorter\_eORCA025\_JD.nc 105 \end{itemize} 106 107 %------------------------------------------namtrc_ais---------------------------------------------------- 108 \nlst{namtrc_ais_cfg} 109 %--------------------------------------------------------------------------------------------------------- 110 111 Two options for tracer concentrations in iceberg and ice shelf can be set with the namelist parameter \textit{nn\_ais\_tr}: 112 \begin{itemize} 113 \item 0 : null concentrations corresponding to dilution of BGC tracers due to freshwater fluxes from icebergs and ice shelves 114 \item 1 : prescribed concentrations set with the \textit{rn\_trafac} factor 115 \end{itemize} 116 117 The depth until which Fe from melting iceberg is delivered can be set with the namelist parameter \textit{rn\_icbdep}. The value of 120 m is the average underwater depth of the different iceberg size classes modeled by the NEMO iceberg module, which was used to produce the freshwater flux climatology of icebergs. 118 119 46 120 \end{document} -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/ICE/icedia.F90
r14072 r14958 67 67 REAL(wp) :: zbg_ivol, zbg_item, zbg_area, zbg_isal 68 68 REAL(wp) :: zbg_svol, zbg_stem 69 REAL(wp) :: zbg_ipvol, zbg_ilvol 69 70 REAL(wp) :: z_frc_voltop, z_frc_temtop, z_frc_sal 70 71 REAL(wp) :: z_frc_volbot, z_frc_tembot … … 87 88 ! ----------------------- ! 88 89 IF( iom_use('ibgvol_tot' ) .OR. iom_use('sbgvol_tot' ) .OR. iom_use('ibgarea_tot') .OR. & 89 & iom_use('ibgsalt_tot') .OR. iom_use('ibgheat_tot') .OR. iom_use('sbgheat_tot') ) THEN 90 & iom_use('ibgsalt_tot') .OR. iom_use('ibgheat_tot') .OR. iom_use('sbgheat_tot') .OR. & 91 & iom_use('ipbgvol_tot' ) .OR. iom_use('ilbgvol_tot' ) ) THEN 90 92 91 93 zbg_ivol = glob_sum( 'icedia', vt_i(:,:) * e1e2t(:,:) ) * 1.e-9 ! ice volume (km3) … … 95 97 zbg_item = glob_sum( 'icedia', et_i(:,:) * e1e2t(:,:) ) * 1.e-20 ! heat content (1.e20 J) 96 98 zbg_stem = glob_sum( 'icedia', et_s(:,:) * e1e2t(:,:) ) * 1.e-20 ! heat content (1.e20 J) 99 ! ponds 100 zbg_ipvol = glob_sum( 'icedia', vt_ip(:,:) * e1e2t(:,:) ) * 1.e-9 ! ice pond volume (km3) 101 zbg_ilvol = glob_sum( 'icedia', vt_il(:,:) * e1e2t(:,:) ) * 1.e-9 ! ice pond lid volume (km3) 97 102 98 103 CALL iom_put( 'ibgvol_tot' , zbg_ivol ) … … 102 107 CALL iom_put( 'ibgheat_tot' , zbg_item ) 103 108 CALL iom_put( 'sbgheat_tot' , zbg_stem ) 109 ! ponds 110 CALL iom_put( 'ipbgvol_tot' , zbg_ipvol ) 111 CALL iom_put( 'ilbgvol_tot' , zbg_ilvol ) 104 112 105 113 ENDIF -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/ICE/icestp.F90
r14072 r14958 460 460 qcn_ice (ji,jj,jl) = 0._wp ! conductive flux (ln_cndflx=T & ln_cndemule=T) 461 461 qtr_ice_bot(ji,jj,jl) = 0._wp ! part of solar radiation transmitted through the ice needed at least for outputs 462 qml_ice (ji,jj,jl) = 0._wp ! surface melt heat flux 462 463 ! Melt pond surface melt diagnostics (mv - more efficient: grouped into one water volume flux) 463 464 dh_i_sum_2d(ji,jj,jl) = 0._wp -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/ICE/icethd.F90
r14433 r14958 536 536 CALL tab_1d_2d( npti, nptidx(1:npti), qcn_ice_bot_1d(1:npti), qcn_ice_bot(:,:,kl) ) 537 537 CALL tab_1d_2d( npti, nptidx(1:npti), qcn_ice_top_1d(1:npti), qcn_ice_top(:,:,kl) ) 538 CALL tab_1d_2d( npti, nptidx(1:npti), qml_ice_1d (1:npti), qml_ice (:,:,kl) ) 538 539 ! extensive variables 539 540 CALL tab_1d_2d( npti, nptidx(1:npti), v_i_1d (1:npti), v_i (:,:,kl) ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/ICE/icethd_dh.F90
r14072 r14958 224 224 zevap_rema(1:npti) = 0._wp 225 225 DO ji = 1, npti 226 IF( evap_ice_1d(ji) > 0._wp ) THEN 227 zdeltah (ji) = MAX( - evap_ice_1d(ji) * r1_rhos * rDt_ice, - h_s_1d(ji) ) ! amount of snw that sublimates, < 0 228 zevap_rema(ji) = MAX( 0._wp, evap_ice_1d(ji) * rDt_ice + zdeltah(ji) * rhos ) ! remaining evap in kg.m-2 (used for ice sublimation later on) 229 ENDIF 226 zdeltah (ji) = MAX( - evap_ice_1d(ji) * r1_rhos * rDt_ice, - h_s_1d(ji) ) ! amount of snw that sublimates, < 0 227 zevap_rema(ji) = evap_ice_1d(ji) * rDt_ice + zdeltah(ji) * rhos ! remaining evap in kg.m-2 (used for ice sublimation later on) 230 228 END DO 231 229 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/ICE/icethd_ent.F90
r13547 r14958 121 121 DO ji = 1, npti 122 122 rswitch = MAX( 0._wp , SIGN( 1._wp , zhnew(ji) - epsi20 ) ) 123 qnew(ji,jk1) = rswitch * ( zeh_cum1(ji,jk1) - zeh_cum1(ji,jk1-1) ) / MAX( zhnew(ji), epsi20 )123 qnew(ji,jk1) = rswitch * MAX( 0._wp, zeh_cum1(ji,jk1) - zeh_cum1(ji,jk1-1) ) / MAX( zhnew(ji), epsi20 ) ! max for roundoff error 124 124 END DO 125 125 END DO -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/ICE/iceupdate.F90
r14595 r14958 289 289 IF( iom_use('hfxcndbot' ) ) CALL iom_put( 'hfxcndbot' , SUM( qcn_ice_bot * a_i_b, dim=3 ) ) ! Bottom conduction flux 290 290 IF( iom_use('hfxcndtop' ) ) CALL iom_put( 'hfxcndtop' , SUM( qcn_ice_top * a_i_b, dim=3 ) ) ! Surface conduction flux 291 !!IF( iom_use('hfxmelt' ) ) CALL iom_put( 'hfxmelt' , SUM( qml_ice * a_i_b, dim=3 ) ) ! Surface melt flux292 !!IF( iom_use('hfxldmelt' ) ) CALL iom_put( 'hfxldmelt' , fhld * at_i_b ) ! Heat in lead for ice melting293 !!IF( iom_use('hfxldgrow' ) ) CALL iom_put( 'hfxldgrow' , qlead * r1_Dt_ice ) ! Heat in lead for ice growth291 IF( iom_use('hfxmelt' ) ) CALL iom_put( 'hfxmelt' , SUM( qml_ice * a_i_b, dim=3 ) ) ! Surface melt flux 292 IF( iom_use('hfxldmelt' ) ) CALL iom_put( 'hfxldmelt' , fhld * at_i_b ) ! Heat in lead for ice melting 293 IF( iom_use('hfxldgrow' ) ) CALL iom_put( 'hfxldgrow' , qlead * r1_Dt_ice ) ! Heat in lead for ice growth 294 294 295 295 ! controls -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ASM/asminc.F90
r14090 r14958 26 26 USE par_oce ! Ocean space and time domain variables 27 27 USE dom_oce ! Ocean space and time domain 28 USE domtile29 28 USE domvvl ! domain: variable volume level 30 29 USE ldfdyn ! lateral diffusion: eddy viscosity coefficients … … 519 518 ! 520 519 INTEGER :: ji, jj, jk 521 INTEGER :: it , itile520 INTEGER :: it 522 521 REAL(wp) :: zincwgt ! IAU weight for current time step 523 522 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: fzptnz ! 3d freezing point values … … 541 540 zincwgt = wgtiau(it) / rn_Dt ! IAU weight for the current time step 542 541 ! 543 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile542 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 544 543 IF(lwp) THEN 545 544 WRITE(numout,*) … … 578 577 ENDIF 579 578 ! 580 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only on the last tile579 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 581 580 IF ( kt == nitiaufin_r + 1 ) THEN ! For bias crcn to work 582 581 DEALLOCATE( t_bkginc ) … … 595 594 IF (ln_temnofreeze) THEN 596 595 ! Do not apply negative increments if the temperature will fall below freezing 597 WHERE( t_bkginc( A2D(0),:) > 0.0_wp .OR. pts(A2D(0),:,jp_tem,Kmm) + t_bkginc(A2D(0),:) > fzptnz(:,:,:) )598 pts( A2D(0),:,jp_tem,Kmm) = t_bkg(A2D(0),:) + t_bkginc(A2D(0),:)596 WHERE( t_bkginc(:,:,:) > 0.0_wp .OR. pts(:,:,:,jp_tem,Kmm) + t_bkginc(:,:,:) > fzptnz(:,:,:) ) 597 pts(:,:,:,jp_tem,Kmm) = t_bkg(:,:,:) + t_bkginc(:,:,:) 599 598 END WHERE 600 599 ELSE 601 DO_3D( 0, 0, 0, 0, 1, jpk ) 602 pts(ji,jj,jk,jp_tem,Kmm) = t_bkg(ji,jj,jk) + t_bkginc(ji,jj,jk) 603 END_3D 600 pts(:,:,:,jp_tem,Kmm) = t_bkg(:,:,:) + t_bkginc(:,:,:) 604 601 ENDIF 605 602 IF (ln_salfix) THEN 606 603 ! Do not apply negative increments if the salinity will fall below a specified 607 604 ! minimum value salfixmin 608 WHERE( s_bkginc( A2D(0),:) > 0.0_wp .OR. pts(A2D(0),:,jp_sal,Kmm) + s_bkginc(A2D(0),:) > salfixmin )609 pts( A2D(0),:,jp_sal,Kmm) = s_bkg(A2D(0),:) + s_bkginc(A2D(0),:)605 WHERE( s_bkginc(:,:,:) > 0.0_wp .OR. pts(:,:,:,jp_sal,Kmm) + s_bkginc(:,:,:) > salfixmin ) 606 pts(:,:,:,jp_sal,Kmm) = s_bkg(:,:,:) + s_bkginc(:,:,:) 610 607 END WHERE 611 608 ELSE 612 DO_3D( 0, 0, 0, 0, 1, jpk ) 613 pts(ji,jj,jk,jp_sal,Kmm) = s_bkg(ji,jj,jk) + s_bkginc(ji,jj,jk) 614 END_3D 615 ENDIF 616 617 DO_3D( 0, 0, 0, 0, 1, jpk ) 618 pts(ji,jj,jk,:,Kbb) = pts(ji,jj,jk,:,Kmm) ! Update before fields 619 END_3D 609 pts(:,:,:,jp_sal,Kmm) = s_bkg(:,:,:) + s_bkginc(:,:,:) 610 ENDIF 611 612 pts(:,:,:,:,Kbb) = pts(:,:,:,:,Kmm) ! Update before fields 620 613 621 614 CALL eos( pts(:,:,:,:,Kbb), rhd, rhop, gdept_0(:,:,:) ) ! Before potential and in situ densities … … 624 617 !!gm 625 618 626 ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed from zps_hde*) 627 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only for the full domain 628 itile = ntile 629 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Use full domain 630 631 IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav) & 632 & CALL zps_hde ( kt, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv, & ! Partial steps: before horizontal gradient 633 & rhd, gru , grv ) ! of t, s, rd at the last ocean level 634 IF( ln_zps .AND. .NOT. lk_c1d .AND. ln_isfcav) & 635 & CALL zps_hde_isf( nit000, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv, gtui, gtvi, & ! Partial steps for top cell (ISF) 636 & rhd, gru , grv , grui, grvi ) ! of t, s, rd at the last ocean level 637 638 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = itile ) ! Revert to tile domain 639 ENDIF 640 641 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 642 DEALLOCATE( t_bkginc ) 643 DEALLOCATE( s_bkginc ) 644 DEALLOCATE( t_bkg ) 645 DEALLOCATE( s_bkg ) 646 ENDIF 647 ! 619 IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav) & 620 & CALL zps_hde ( kt, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv, & ! Partial steps: before horizontal gradient 621 & rhd, gru , grv ) ! of t, s, rd at the last ocean level 622 IF( ln_zps .AND. .NOT. lk_c1d .AND. ln_isfcav) & 623 & CALL zps_hde_isf( nit000, Kmm, jpts, pts(:,:,:,:,Kbb), gtsu, gtsv, gtui, gtvi, & ! Partial steps for top cell (ISF) 624 & rhd, gru , grv , grui, grvi ) ! of t, s, rd at the last ocean level 625 626 DEALLOCATE( t_bkginc ) 627 DEALLOCATE( s_bkginc ) 628 DEALLOCATE( t_bkg ) 629 DEALLOCATE( s_bkg ) 648 630 ENDIF 649 631 ! … … 669 651 REAL(wp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) :: puu, pvv ! ocean velocities and RHS of momentum equation 670 652 ! 671 INTEGER :: j k653 INTEGER :: ji, jj, jk 672 654 INTEGER :: it 673 655 REAL(wp) :: zincwgt ! IAU weight for current time step … … 683 665 zincwgt = wgtiau(it) / rn_Dt ! IAU weight for the current time step 684 666 ! 685 IF(lwp) THEN 686 WRITE(numout,*) 687 WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 688 WRITE(numout,*) '~~~~~~~~~~~~' 667 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 668 IF(lwp) THEN 669 WRITE(numout,*) 670 WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it) 671 WRITE(numout,*) '~~~~~~~~~~~~' 672 ENDIF 689 673 ENDIF 690 674 ! 691 675 ! Update the dynamic tendencies 692 DO jk = 1, jpkm1 693 puu(:,:,jk,Krhs) = puu(:,:,jk,Krhs) + u_bkginc(:,:,jk) * zincwgt 694 pvv(:,:,jk,Krhs) = pvv(:,:,jk,Krhs) + v_bkginc(:,:,jk) * zincwgt 695 END DO 696 ! 697 IF ( kt == nitiaufin_r ) THEN 698 DEALLOCATE( u_bkginc ) 699 DEALLOCATE( v_bkginc ) 676 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 677 puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + u_bkginc(ji,jj,jk) * zincwgt 678 pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) + v_bkginc(ji,jj,jk) * zincwgt 679 END_3D 680 ! 681 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 682 IF ( kt == nitiaufin_r ) THEN 683 DEALLOCATE( u_bkginc ) 684 DEALLOCATE( v_bkginc ) 685 ENDIF 700 686 ENDIF 701 687 ! … … 741 727 ! 742 728 INTEGER :: it 743 INTEGER :: j k729 INTEGER :: ji, jj, jk 744 730 REAL(wp) :: zincwgt ! IAU weight for current time step 745 731 !!---------------------------------------------------------------------- … … 754 740 zincwgt = wgtiau(it) / rn_Dt ! IAU weight for the current time step 755 741 ! 756 IF(lwp) THEN 757 WRITE(numout,*) 758 WRITE(numout,*) 'ssh_asm_inc : SSH IAU at time step = ', & 759 & kt,' with IAU weight = ', wgtiau(it) 760 WRITE(numout,*) '~~~~~~~~~~~~' 742 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 743 IF(lwp) THEN 744 WRITE(numout,*) 745 WRITE(numout,*) 'ssh_asm_inc : SSH IAU at time step = ', & 746 & kt,' with IAU weight = ', wgtiau(it) 747 WRITE(numout,*) '~~~~~~~~~~~~' 748 ENDIF 761 749 ENDIF 762 750 ! … … 764 752 ! (applied in dynspg.*) 765 753 #if defined key_asminc 766 ssh_iau(:,:) = ssh_bkginc(:,:) * zincwgt 754 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 755 ssh_iau(ji,jj) = ssh_bkginc(ji,jj) * zincwgt 756 END_2D 767 757 #endif 768 758 ! … … 770 760 ! 771 761 ! test on ssh_bkginc needed as ssh_asm_inc is called twice by time step 772 IF (ALLOCATED(ssh_bkginc)) DEALLOCATE( ssh_bkginc ) 762 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 763 IF (ALLOCATED(ssh_bkginc)) DEALLOCATE( ssh_bkginc ) 764 ENDIF 773 765 ! 774 766 #if defined key_asminc 775 ssh_iau(:,:) = 0._wp 767 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 768 ssh_iau(ji,jj) = 0._wp 769 END_2D 776 770 #endif 777 771 ! … … 820 814 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: phdivn ! horizontal divergence 821 815 !! 822 INTEGER :: j k! dummy loop index816 INTEGER :: ji, jj, jk ! dummy loop index 823 817 REAL(wp), DIMENSION(:,:) , POINTER :: ztim ! local array 824 818 !!---------------------------------------------------------------------- … … 828 822 ! 829 823 IF( ln_linssh ) THEN 830 phdivn(:,:,1) = phdivn(:,:,1) - ssh_iau(:,:) / e3t(:,:,1,Kmm) * tmask(:,:,1) 824 DO_2D_OVR( nn_hls-1, nn_hls, nn_hls-1, nn_hls ) 825 phdivn(ji,jj,1) = phdivn(ji,jj,1) - ssh_iau(ji,jj) / e3t(ji,jj,1,Kmm) * tmask(ji,jj,1) 826 END_2D 831 827 ELSE 832 ALLOCATE( ztim(jpi,jpj) ) 833 ztim(:,:) = ssh_iau(:,:) / ( ht(:,:) + 1.0 - ssmask(:,:) ) 834 DO jk = 1, jpkm1 835 phdivn(:,:,jk) = phdivn(:,:,jk) - ztim(:,:) * tmask(:,:,jk) 836 END DO 828 ALLOCATE( ztim(A2D(nn_hls)) ) 829 DO_2D_OVR( nn_hls-1, nn_hls, nn_hls-1, nn_hls ) 830 ztim(ji,jj) = ssh_iau(ji,jj) / ( ht(ji,jj) + 1.0 - ssmask(ji,jj) ) 831 DO jk = 1, jpkm1 832 phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - ztim(ji,jj) * tmask(ji,jj,jk) 833 END DO 834 END_2D 837 835 ! 838 836 DEALLOCATE(ztim) … … 876 874 ! note this is not a tendency so should not be divided by rn_Dt (as with the tracer and other increments) 877 875 ! 878 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile876 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 879 877 IF(lwp) THEN 880 878 WRITE(numout,*) … … 920 918 #endif 921 919 ! 922 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only on the last tile920 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 923 921 IF ( kt == nitiaufin_r ) THEN 924 922 DEALLOCATE( seaice_bkginc ) … … 979 977 END_2D 980 978 #endif 981 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only on the last tile979 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 982 980 IF ( .NOT. PRESENT(kindic) ) THEN 983 981 DEALLOCATE( seaice_bkginc ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/BDY/bdydyn3d.F90
r14433 r14958 349 349 REAL(wp) :: zwgt ! boundary weight 350 350 !!---------------------------------------------------------------------- 351 IF( l_istiled .AND. ntile /= 1 ) RETURN ! Do only for the full domain 351 352 ! 352 353 IF( ln_timing ) CALL timing_start('bdy_dyn3d_dmp') -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/BDY/bdyice.F90
r14433 r14958 153 153 h_i (ji,jj, jl) = ( h_i (ji,jj, jl) * zwgt1 + dta%h_i(i_bdy,jl) * zwgt ) * tmask(ji,jj,1) ! Ice depth 154 154 h_s (ji,jj, jl) = ( h_s (ji,jj, jl) * zwgt1 + dta%h_s(i_bdy,jl) * zwgt ) * tmask(ji,jj,1) ! Snow depth 155 t_i (ji,jj,:,jl) = ( t_i (ji,jj,:,jl) * zwgt1 + dta%t_i(i_bdy,jl) * zwgt )* tmask(ji,jj,1) ! Ice temperature156 t_s (ji,jj,:,jl) = ( t_s (ji,jj,:,jl) * zwgt1 + dta%t_s(i_bdy,jl) * zwgt )* tmask(ji,jj,1) ! Snow temperature157 t_su(ji,jj, jl) = ( t_su(ji,jj, jl) * zwgt1 + dta%tsu(i_bdy,jl) * zwgt )* tmask(ji,jj,1) ! Surf temperature158 s_i (ji,jj, jl) = ( s_i (ji,jj, jl) * zwgt1 + dta%s_i(i_bdy,jl) * zwgt )* tmask(ji,jj,1) ! Ice salinity155 t_i (ji,jj,:,jl) = dta%t_i(i_bdy,jl) * tmask(ji,jj,1) ! Ice temperature 156 t_s (ji,jj,:,jl) = dta%t_s(i_bdy,jl) * tmask(ji,jj,1) ! Snow temperature 157 t_su(ji,jj, jl) = dta%tsu(i_bdy,jl) * tmask(ji,jj,1) ! Surf temperature 158 s_i (ji,jj, jl) = dta%s_i(i_bdy,jl) * tmask(ji,jj,1) ! Ice salinity 159 159 a_ip(ji,jj, jl) = ( a_ip(ji,jj, jl) * zwgt1 + dta%aip(i_bdy,jl) * zwgt ) * tmask(ji,jj,1) ! Ice pond concentration 160 160 h_ip(ji,jj, jl) = ( h_ip(ji,jj, jl) * zwgt1 + dta%hip(i_bdy,jl) * zwgt ) * tmask(ji,jj,1) ! Ice pond depth … … 254 254 sv_i(ji,jj,jl) = MIN( s_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl) ! salt content 255 255 DO jk = 1, nlay_s 256 t_s(ji,jj,jk,jl) = MIN( t_s(ji,jj,jk,jl), -0.15_wp + rt0 ) ! Force t_s to be lower than -0.15deg (arbitrary) => likely conservation issue 257 ! ! otherwise instant melting can occur 256 258 e_s(ji,jj,jk,jl) = rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus ) ! enthalpy in J/m3 257 259 e_s(ji,jj,jk,jl) = e_s(ji,jj,jk,jl) * v_s(ji,jj,jl) * r1_nlay_s ! enthalpy in J/m2 258 260 END DO 261 t_su(ji,jj,jl) = MIN( t_su(ji,jj,jl), -0.15_wp + rt0 ) ! Force t_su to be lower than -0.15deg (arbitrary) 259 262 DO jk = 1, nlay_i 260 263 ztmelts = - rTmlt * sz_i(ji,jj,jk,jl) ! Melting temperature in C 261 t_i(ji,jj,jk,jl) = MIN( t_i(ji,jj,jk,jl), ztmelts + rt0 ) ! Force t_i to be lower than melting point=> likely conservation issue264 t_i(ji,jj,jk,jl) = MIN( t_i(ji,jj,jk,jl), (ztmelts-0.15_wp) + rt0 ) ! Force t_i to be lower than melting point (-0.15) => likely conservation issue 262 265 ! 263 266 e_i(ji,jj,jk,jl) = rhoi * ( rcpi * ( ztmelts - ( t_i(ji,jj,jk,jl) - rt0 ) ) & ! enthalpy in J/m3 … … 363 366 IF( zflag == -1. .AND. ji > 1 .AND. ji < jpi ) THEN 364 367 IF ( vt_i(ji ,jj) > 0. ) THEN ; u_ice(ji,jj) = u_ice(ji-1,jj) 365 ELSEIF( vt_i(ji+1,jj) > 0. ) THEN ; u_ice(ji,jj) = 0._wp368 ELSEIF( vt_i(ji+1,jj) > 0. ) THEN ; u_ice(ji,jj) = u_oce(ji,jj) 366 369 END IF 367 370 END IF … … 371 374 IF( zflag == 1. .AND. ji+1 < jpi+1 ) THEN 372 375 IF ( vt_i(ji+1,jj) > 0. ) THEN ; u_ice(ji,jj) = u_ice(ji+1,jj) 373 ELSEIF( vt_i(ji ,jj) > 0. ) THEN ; u_ice(ji,jj) = 0._wp376 ELSEIF( vt_i(ji ,jj) > 0. ) THEN ; u_ice(ji,jj) = u_oce(ji,jj) 374 377 END IF 375 378 END IF … … 395 398 IF( zflag == -1. .AND. jj > 1 .AND. jj < jpj ) THEN 396 399 IF ( vt_i(ji,jj ) > 0. ) THEN ; v_ice(ji,jj) = v_ice(ji,jj-1) 397 ELSEIF( vt_i(ji,jj+1) > 0. ) THEN ; v_ice(ji,jj) = 0._wp400 ELSEIF( vt_i(ji,jj+1) > 0. ) THEN ; v_ice(ji,jj) = v_oce(ji,jj) 398 401 END IF 399 402 END IF … … 405 408 IF( zflag == 1. .AND. jj < jpj ) THEN 406 409 IF ( vt_i(ji,jj+1) > 0. ) THEN ; v_ice(ji,jj) = v_ice(ji,jj+1) 407 ELSEIF( vt_i(ji,jj ) > 0. ) THEN ; v_ice(ji,jj) = 0._wp410 ELSEIF( vt_i(ji,jj ) > 0. ) THEN ; v_ice(ji,jj) = v_oce(ji,jj) 408 411 END IF 409 412 END IF -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/BDY/bdytra.F90
r14433 r14958 158 158 INTEGER :: ib_bdy ! Loop index 159 159 !!---------------------------------------------------------------------- 160 IF( ntile /= 0.AND. ntile /= 1 ) RETURN ! Do only for the full domain160 IF( l_istiled .AND. ntile /= 1 ) RETURN ! Do only for the full domain 161 161 ! 162 162 IF( ln_timing ) CALL timing_start('bdy_tra_dmp') -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DIA/diaar5.F90
r14072 r14958 34 34 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,: ) :: thick0 ! ocean thickness (interior domain) 35 35 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: sn0 ! initial salinity 36 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) :: hstr_adv, hstr_ldf37 36 38 37 LOGICAL :: l_ar5 … … 55 54 !!---------------------------------------------------------------------- 56 55 ! 57 ALLOCATE( thick0(jpi,jpj) , sn0(jpi,jpj,jpk) , & 58 & hstr_adv(jpi,jpj,jpts,2), hstr_ldf(jpi,jpj,jpts,2), STAT=dia_ar5_alloc ) 56 ALLOCATE( thick0(jpi,jpj) , sn0(jpi,jpj,jpk), STAT=dia_ar5_alloc ) 59 57 ! 60 58 CALL mpp_sum ( 'diaar5', dia_ar5_alloc ) … … 306 304 END SUBROUTINE dia_ar5 307 305 308 ! TEMP: [tiling] These changes not necessary if using XIOS (subdomain support, will not output haloes) 306 309 307 SUBROUTINE dia_ar5_hst( ktra, cptr, puflx, pvflx ) 310 308 !!---------------------------------------------------------------------- … … 320 318 ! 321 319 INTEGER :: ji, jj, jk 322 323 IF( cptr /= 'adv' .AND. cptr /= 'ldf' ) RETURN 324 IF( ktra /= jp_tem .AND. ktra /= jp_sal ) RETURN 320 REAL(wp), DIMENSION(A2D(nn_hls)) :: z2d 321 322 z2d(:,:) = puflx(:,:,1) 323 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 324 z2d(ji,jj) = z2d(ji,jj) + puflx(ji,jj,jk) 325 END_3D 325 326 326 327 IF( cptr == 'adv' ) THEN 327 DO_2D( 0, 0, 0, 0 ) 328 hstr_adv(ji,jj,ktra,1) = puflx(ji,jj,1) 329 hstr_adv(ji,jj,ktra,2) = pvflx(ji,jj,1) 330 END_2D 331 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 332 hstr_adv(ji,jj,ktra,1) = hstr_adv(ji,jj,ktra,1) + puflx(ji,jj,jk) 333 hstr_adv(ji,jj,ktra,2) = hstr_adv(ji,jj,ktra,2) + pvflx(ji,jj,jk) 334 END_3D 328 IF( ktra == jp_tem ) CALL iom_put( 'uadv_heattr' , rho0_rcp * z2d(:,:) ) ! advective heat transport in i-direction 329 IF( ktra == jp_sal ) CALL iom_put( 'uadv_salttr' , rho0 * z2d(:,:) ) ! advective salt transport in i-direction 335 330 ELSE IF( cptr == 'ldf' ) THEN 336 DO_2D( 0, 0, 0, 0 ) 337 hstr_ldf(ji,jj,ktra,1) = puflx(ji,jj,1) 338 hstr_ldf(ji,jj,ktra,2) = pvflx(ji,jj,1) 339 END_2D 340 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 341 hstr_ldf(ji,jj,ktra,1) = hstr_ldf(ji,jj,ktra,1) + puflx(ji,jj,jk) 342 hstr_ldf(ji,jj,ktra,2) = hstr_ldf(ji,jj,ktra,2) + pvflx(ji,jj,jk) 343 END_3D 344 ENDIF 345 346 IF( ntile == 0 .OR. ntile == nijtile ) THEN 347 IF( cptr == 'adv' ) THEN 348 IF( ktra == jp_tem ) CALL iom_put( 'uadv_heattr' , rho0_rcp * hstr_adv(:,:,ktra,1) ) ! advective heat transport in i-direction 349 IF( ktra == jp_sal ) CALL iom_put( 'uadv_salttr' , rho0 * hstr_adv(:,:,ktra,1) ) ! advective salt transport in i-direction 350 IF( ktra == jp_tem ) CALL iom_put( 'vadv_heattr' , rho0_rcp * hstr_adv(:,:,ktra,2) ) ! advective heat transport in j-direction 351 IF( ktra == jp_sal ) CALL iom_put( 'vadv_salttr' , rho0 * hstr_adv(:,:,ktra,2) ) ! advective salt transport in j-direction 352 ENDIF 353 IF( cptr == 'ldf' ) THEN 354 IF( ktra == jp_tem ) CALL iom_put( 'udiff_heattr' , rho0_rcp * hstr_ldf(:,:,ktra,1) ) ! diffusive heat transport in i-direction 355 IF( ktra == jp_sal ) CALL iom_put( 'udiff_salttr' , rho0 * hstr_ldf(:,:,ktra,1) ) ! diffusive salt transport in i-direction 356 IF( ktra == jp_tem ) CALL iom_put( 'vdiff_heattr' , rho0_rcp * hstr_ldf(:,:,ktra,2) ) ! diffusive heat transport in j-direction 357 IF( ktra == jp_sal ) CALL iom_put( 'vdiff_salttr' , rho0 * hstr_ldf(:,:,ktra,2) ) ! diffusive salt transport in j-direction 358 ENDIF 331 IF( ktra == jp_tem ) CALL iom_put( 'udiff_heattr' , rho0_rcp * z2d(:,:) ) ! diffusive heat transport in i-direction 332 IF( ktra == jp_sal ) CALL iom_put( 'udiff_salttr' , rho0 * z2d(:,:) ) ! diffusive salt transport in i-direction 333 ENDIF 334 ! 335 z2d(:,:) = pvflx(:,:,1) 336 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 337 z2d(ji,jj) = z2d(ji,jj) + pvflx(ji,jj,jk) 338 END_3D 339 340 IF( cptr == 'adv' ) THEN 341 IF( ktra == jp_tem ) CALL iom_put( 'vadv_heattr' , rho0_rcp * z2d(:,:) ) ! advective heat transport in j-direction 342 IF( ktra == jp_sal ) CALL iom_put( 'vadv_salttr' , rho0 * z2d(:,:) ) ! advective salt transport in j-direction 343 ELSE IF( cptr == 'ldf' ) THEN 344 IF( ktra == jp_tem ) CALL iom_put( 'vdiff_heattr' , rho0_rcp * z2d(:,:) ) ! diffusive heat transport in j-direction 345 IF( ktra == jp_sal ) CALL iom_put( 'vdiff_salttr' , rho0 * z2d(:,:) ) ! diffusive salt transport in j-direction 359 346 ENDIF 360 347 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DIA/diaptr.F90
r14229 r14958 71 71 CONTAINS 72 72 73 ! NOTE: [tiling] tiling sometimes changes the diagnostics very slightly, usually where there are few zonal points e.g. the northern Indian Ocean basin. The difference is usually very small, for one point in one diagnostic. Presumably this is because of the additional zonal integration step over tiles. 73 74 SUBROUTINE dia_ptr( kt, Kmm, pvtr ) 74 75 !!---------------------------------------------------------------------- … … 93 94 94 95 ! Calculate diagnostics only when zonal integrals have finished 95 IF( ntile == 0.OR. ntile == nijtile ) CALL dia_ptr_iom(kt, Kmm, pvtr)96 IF( .NOT. l_istiled .OR. ntile == nijtile ) CALL dia_ptr_iom(kt, Kmm, pvtr) 96 97 ENDIF 97 98 … … 317 318 ! 318 319 IF( iom_use( 'uocetr_vsum_cumul' ) ) THEN 319 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Use full domain320 320 CALL iom_get_var( 'uocetr_vsum_op', z2d ) ! get uocetr_vsum_op from xml 321 321 z2d(:,:) = ptr_ci_2d( z2d(:,:) ) 322 322 CALL iom_put( 'uocetr_vsum_cumul', z2d ) 323 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = nijtile ) ! Revert to tile domain324 323 ENDIF 325 324 ! … … 589 588 590 589 #if ! defined key_mpi_off 591 IF( ntile == 0.OR. ntile == nijtile ) THEN590 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 592 591 ish1d(1) = jpj*nbasin 593 592 ish2d(1) = jpj ; ish2d(2) = nbasin … … 627 626 628 627 #if ! defined key_mpi_off 629 IF( ntile == 0.OR. ntile == nijtile ) THEN628 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 630 629 ish1d(1) = jpj*jpk*nbasin 631 630 ish3d(1) = jpj ; ish3d(2) = jpk ; ish3d(3) = nbasin -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/dom_oce.F90
r14433 r14958 73 73 INTEGER :: nn_ltile_i, nn_ltile_j 74 74 75 ! Domain tiling (all tiles)75 ! Domain tiling 76 76 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) :: ntsi_a !: start of internal part of tile domain 77 77 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) :: ntsj_a ! 78 78 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) :: ntei_a !: end of internal part of tile domain 79 79 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) :: ntej_a ! 80 LOGICAL, PUBLIC :: l_istiled ! whether tiling is currently active or not 80 81 81 82 ! !: domain MPP decomposition parameters -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/domain.F90
r14433 r14958 125 125 ! !== Reference coordinate system ==! 126 126 ! 127 CALL dom_glo 128 CALL dom_nam 129 CALL dom_tile ( ntsi, ntsj, ntei, ntej )! Tile domain127 CALL dom_glo ! global domain versus local domain 128 CALL dom_nam ! read namelist ( namrun, namdom ) 129 CALL dom_tile_init ! Tile domain 130 130 131 131 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/domqco.F90
r14433 r14958 123 123 CALL dom_qco_r3c( ssh(:,:,Kmm), r3t(:,:,Kmm), r3u(:,:,Kmm), r3v(:,:,Kmm), r3f(:,:) ) 124 124 #endif 125 ! dom_qco_r3c defines over [nn_hls, nn_hls-1, nn_hls, nn_hls-1] 126 IF( nn_hls == 2 ) CALL lbc_lnk( 'dom_qco_zgr', r3u(:,:,Kbb), 'U', 1._wp, r3v(:,:,Kbb), 'V', 1._wp, & 127 & r3u(:,:,Kmm), 'U', 1._wp, r3v(:,:,Kmm), 'V', 1._wp ) 125 128 ! 126 129 END SUBROUTINE dom_qco_zgr … … 146 149 ! 147 150 ! 148 pr3t(:,:) = pssh(:,:) * r1_ht_0(:,:) !== ratio at t-point ==! 151 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 152 pr3t(ji,jj) = pssh(ji,jj) * r1_ht_0(ji,jj) !== ratio at t-point ==! 153 END_2D 149 154 ! 150 155 ! … … 154 159 #if ! defined key_qcoTest_FluxForm 155 160 ! ! no 'key_qcoTest_FluxForm' : surface weighted ssh average 156 DO_2D( 0, 0, 0, 0)157 158 159 160 161 161 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 162 pr3u(ji,jj) = 0.5_wp * ( e1e2t(ji ,jj) * pssh(ji ,jj) & 163 & + e1e2t(ji+1,jj) * pssh(ji+1,jj) ) * r1_hu_0(ji,jj) * r1_e1e2u(ji,jj) 164 pr3v(ji,jj) = 0.5_wp * ( e1e2t(ji,jj ) * pssh(ji,jj ) & 165 & + e1e2t(ji,jj+1) * pssh(ji,jj+1) ) * r1_hv_0(ji,jj) * r1_e1e2v(ji,jj) 166 END_2D 162 167 !!st ELSE !- Flux Form (simple averaging) 163 168 #else 164 DO_2D( 0, 0, 0, 0)165 166 167 169 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 170 pr3u(ji,jj) = 0.5_wp * ( pssh(ji,jj) + pssh(ji+1,jj ) ) * r1_hu_0(ji,jj) 171 pr3v(ji,jj) = 0.5_wp * ( pssh(ji,jj) + pssh(ji ,jj+1) ) * r1_hv_0(ji,jj) 172 END_2D 168 173 !!st ENDIF 169 174 #endif 170 175 ! 171 176 IF( .NOT.PRESENT( pr3f ) ) THEN !- lbc on ratio at u-, v-points only 172 CALL lbc_lnk( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )177 IF (nn_hls==1) CALL lbc_lnk( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp ) 173 178 ! 174 179 ! … … 179 184 ! ! no 'key_qcoTest_FluxForm' : surface weighted ssh average 180 185 181 DO_2D( 0, 0, 0, 0 ) ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line 182 pr3f(ji,jj) = 0.25_wp * ( e1e2t(ji ,jj ) * pssh(ji ,jj ) & 183 & + e1e2t(ji+1,jj ) * pssh(ji+1,jj ) & 184 & + e1e2t(ji ,jj+1) * pssh(ji ,jj+1) & 185 & + e1e2t(ji+1,jj+1) * pssh(ji+1,jj+1) ) * r1_hf_0(ji,jj) * r1_e1e2f(ji,jj) 186 END_2D 186 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line 187 ! round brackets added to fix the order of floating point operations 188 ! needed to ensure halo 1 - halo 2 compatibility 189 pr3f(ji,jj) = 0.25_wp * ( ( e1e2t(ji ,jj ) * pssh(ji ,jj ) & 190 & + e1e2t(ji+1,jj ) * pssh(ji+1,jj ) & 191 & ) & ! bracket for halo 1 - halo 2 compatibility 192 & + ( e1e2t(ji ,jj+1) * pssh(ji ,jj+1) & 193 & + e1e2t(ji+1,jj+1) * pssh(ji+1,jj+1) & 194 & ) & ! bracket for halo 1 - halo 2 compatibility 195 & ) * r1_hf_0(ji,jj) * r1_e1e2f(ji,jj) 196 END_2D 187 197 !!st ELSE !- Flux Form (simple averaging) 188 198 #else 189 DO_2D( 0, 0, 0, 0 ) ! start from 1 since lbc_lnk('F') doesn't update the 1st row/line 190 pr3f(ji,jj) = 0.25_wp * ( pssh(ji,jj ) + pssh(ji+1,jj ) & 191 & + pssh(ji,jj+1) + pssh(ji+1,jj+1) ) * r1_hf_0(ji,jj) 192 END_2D 199 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 200 ! round brackets added to fix the order of floating point operations 201 ! needed to ensure halo 1 - halo 2 compatibility 202 pr3f(ji,jj) = 0.25_wp * ( ( pssh(ji,jj ) + pssh(ji+1,jj ) ) & 203 & + ( pssh(ji,jj+1) + pssh(ji+1,jj+1) & 204 & ) & ! bracket for halo 1 - halo 2 compatibility 205 & ) * r1_hf_0(ji,jj) 206 END_2D 193 207 !!st ENDIF 194 208 #endif 195 209 ! ! lbc on ratio at u-,v-,f-points 196 CALL lbc_lnk( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )210 IF (nn_hls==1) CALL lbc_lnk( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp ) 197 211 ! 198 212 ENDIF -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/domtile.F90
r14090 r14958 13 13 ! 14 14 USE prtctl ! Print control (prt_ctl_info routine) 15 USE lib_mpp , ONLY : ctl_stop, ctl_warn 15 16 USE in_out_manager ! I/O manager 16 17 … … 18 19 PRIVATE 19 20 20 PUBLIC dom_tile ! called by step.F90 21 PUBLIC dom_tile ! called by step.F90 22 PUBLIC dom_tile_start ! called by various 23 PUBLIC dom_tile_stop ! " " 24 PUBLIC dom_tile_init ! called by domain.F90 25 26 LOGICAL, ALLOCATABLE, DIMENSION(:) :: l_tilefin ! whether a tile is finished or not 21 27 22 28 !!---------------------------------------------------------------------- … … 27 33 CONTAINS 28 34 29 SUBROUTINE dom_tile( ktsi, ktsj, ktei, ktej, ktile ) 35 SUBROUTINE dom_tile_init 36 !!---------------------------------------------------------------------- 37 !! *** ROUTINE dom_tile_init *** 38 !! 39 !! ** Purpose : Initialise tile domain variables 40 !! 41 !! ** Action : - ntsi, ntsj : start of internal part of domain 42 !! - ntei, ntej : end of internal part of domain 43 !! - ntile : current tile number 44 !! - nijtile : total number of tiles 45 !! - nthl, nthr : modifier on DO loop macro bound offset (left, right) 46 !! - nthb, ntht : " " (bottom, top) 47 !! - l_istiled : whether tiling is currently active or not 48 !! - l_tilefin : whether a tile is finished or not 49 !!---------------------------------------------------------------------- 50 INTEGER :: jt ! dummy loop argument 51 INTEGER :: iitile, ijtile ! Local integers 52 !!---------------------------------------------------------------------- 53 IF( ln_tile .AND. nn_hls /= 2 ) CALL ctl_stop('dom_tile_init: Tiling is only supported for nn_hls = 2') 54 55 ntile = 0 ! Initialise to full domain 56 nijtile = 1 57 ntsi = Nis0 58 ntsj = Njs0 59 ntei = Nie0 60 ntej = Nje0 61 nthl = 0 62 nthr = 0 63 nthb = 0 64 ntht = 0 65 l_istiled = .FALSE. 66 67 IF( ln_tile ) THEN ! Calculate tile domain indices 68 iitile = Ni_0 / nn_ltile_i ! Number of tiles 69 ijtile = Nj_0 / nn_ltile_j 70 IF( MOD( Ni_0, nn_ltile_i ) /= 0 ) iitile = iitile + 1 71 IF( MOD( Nj_0, nn_ltile_j ) /= 0 ) ijtile = ijtile + 1 72 73 nijtile = iitile * ijtile 74 ALLOCATE( ntsi_a(0:nijtile), ntsj_a(0:nijtile), ntei_a(0:nijtile), ntej_a(0:nijtile), l_tilefin(nijtile) ) 75 76 l_tilefin(:) = .FALSE. 77 78 ntsi_a(0) = Nis0 ! Full domain 79 ntsj_a(0) = Njs0 80 ntei_a(0) = Nie0 81 ntej_a(0) = Nje0 82 83 DO jt = 1, nijtile ! Tile domains 84 ntsi_a(jt) = Nis0 + nn_ltile_i * MOD(jt - 1, iitile) 85 ntsj_a(jt) = Njs0 + nn_ltile_j * ((jt - 1) / iitile) 86 ntei_a(jt) = MIN(ntsi_a(jt) + nn_ltile_i - 1, Nie0) 87 ntej_a(jt) = MIN(ntsj_a(jt) + nn_ltile_j - 1, Nje0) 88 ENDDO 89 ENDIF 90 91 IF(lwp) THEN ! control print 92 WRITE(numout,*) 93 WRITE(numout,*) 'dom_tile : Domain tiling decomposition' 94 WRITE(numout,*) '~~~~~~~~' 95 IF( ln_tile ) THEN 96 WRITE(numout,*) iitile, 'tiles in i' 97 WRITE(numout,*) ' Starting indices' 98 WRITE(numout,*) ' ', (ntsi_a(jt), jt=1, iitile) 99 WRITE(numout,*) ' Ending indices' 100 WRITE(numout,*) ' ', (ntei_a(jt), jt=1, iitile) 101 WRITE(numout,*) ijtile, 'tiles in j' 102 WRITE(numout,*) ' Starting indices' 103 WRITE(numout,*) ' ', (ntsj_a(jt), jt=1, nijtile, iitile) 104 WRITE(numout,*) ' Ending indices' 105 WRITE(numout,*) ' ', (ntej_a(jt), jt=1, nijtile, iitile) 106 ELSE 107 WRITE(numout,*) 'No domain tiling' 108 WRITE(numout,*) ' i indices =', ntsi, ':', ntei 109 WRITE(numout,*) ' j indices =', ntsj, ':', ntej 110 ENDIF 111 ENDIF 112 END SUBROUTINE dom_tile_init 113 114 115 SUBROUTINE dom_tile( ktsi, ktsj, ktei, ktej, ktile, ldhold, cstr ) 30 116 !!---------------------------------------------------------------------- 31 117 !! *** ROUTINE dom_tile *** 32 118 !! 33 !! ** Purpose : Set t ile domain variables119 !! ** Purpose : Set the current tile and its domain indices 34 120 !! 35 121 !! ** Action : - ktsi, ktsj : start of internal part of domain 36 122 !! - ktei, ktej : end of internal part of domain 37 !! - ntile : current tile number 38 !! - nijtile : total number of tiles 123 !! - nthl, nthr : modifier on DO loop macro bound offset (left, right) 124 !! - nthb, ntht : " " (bottom, top) 125 !! - ktile : set the current tile number (ntile) 39 126 !!---------------------------------------------------------------------- 40 127 INTEGER, INTENT(out) :: ktsi, ktsj, ktei, ktej ! Tile domain indices 41 INTEGER, INTENT(in), OPTIONAL :: ktile ! Tile number 42 INTEGER :: jt ! dummy loop argument 43 INTEGER :: iitile, ijtile ! Local integers 44 CHARACTER (len=11) :: charout 45 !!---------------------------------------------------------------------- 46 IF( PRESENT(ktile) .AND. ln_tile ) THEN 47 ntile = ktile ! Set domain indices for tile 48 ktsi = ntsi_a(ktile) 49 ktsj = ntsj_a(ktile) 50 ktei = ntei_a(ktile) 51 ktej = ntej_a(ktile) 52 128 INTEGER, INTENT(in) :: ktile ! Tile number 129 LOGICAL, INTENT(in), OPTIONAL :: ldhold ! Pause/resume (.true.) or set (.false.) current tile 130 CHARACTER(len=*), INTENT(in), OPTIONAL :: cstr ! Debug information (added to warnings) 131 CHARACTER(len=23) :: clstr 132 LOGICAL :: llhold 133 CHARACTER(len=11) :: charout 134 INTEGER :: iitile 135 !!---------------------------------------------------------------------- 136 llhold = .FALSE. 137 IF( PRESENT(ldhold) ) llhold = ldhold 138 clstr = '' 139 IF( PRESENT(cstr) ) clstr = TRIM(' ('//TRIM(cstr)//')') 140 141 IF( .NOT. ln_tile ) CALL ctl_stop('Cannot use dom_tile with ln_tile = .false.') 142 IF( .NOT. llhold ) THEN 143 IF( .NOT. l_istiled ) THEN 144 CALL ctl_warn('Cannot call dom_tile when tiling is inactive'//clstr) 145 RETURN 146 ENDIF 147 148 IF( ntile /= 0 ) l_tilefin(ntile) = .TRUE. ! If setting a new tile, the current tile is complete 149 150 ntile = ktile ! Set the new tile 53 151 IF(sn_cfctl%l_prtctl) THEN 54 WRITE(charout, FMT="('ntile =', I4)") ktile152 WRITE(charout, FMT="('ntile =', I4)") ntile 55 153 CALL prt_ctl_info( charout ) 56 154 ENDIF 57 ELSE 58 ntile = 0 ! Initialise to full domain 59 nijtile = 1 60 ktsi = Nis0 61 ktsj = Njs0 62 ktei = Nie0 63 ktej = Nje0 64 65 IF( ln_tile ) THEN ! Calculate tile domain indices 66 iitile = Ni_0 / nn_ltile_i ! Number of tiles 67 ijtile = Nj_0 / nn_ltile_j 68 IF( MOD( Ni_0, nn_ltile_i ) /= 0 ) iitile = iitile + 1 69 IF( MOD( Nj_0, nn_ltile_j ) /= 0 ) ijtile = ijtile + 1 70 71 nijtile = iitile * ijtile 72 ALLOCATE( ntsi_a(0:nijtile), ntsj_a(0:nijtile), ntei_a(0:nijtile), ntej_a(0:nijtile) ) 73 74 ntsi_a(0) = ktsi ! Full domain 75 ntsj_a(0) = ktsj 76 ntei_a(0) = ktei 77 ntej_a(0) = ktej 78 79 DO jt = 1, nijtile ! Tile domains 80 ntsi_a(jt) = Nis0 + nn_ltile_i * MOD(jt - 1, iitile) 81 ntsj_a(jt) = Njs0 + nn_ltile_j * ((jt - 1) / iitile) 82 ntei_a(jt) = MIN(ntsi_a(jt) + nn_ltile_i - 1, Nie0) 83 ntej_a(jt) = MIN(ntsj_a(jt) + nn_ltile_j - 1, Nje0) 84 ENDDO 85 ENDIF 86 87 IF(lwp) THEN ! control print 88 WRITE(numout,*) 89 WRITE(numout,*) 'dom_tile : Domain tiling decomposition' 90 WRITE(numout,*) '~~~~~~~~' 91 IF( ln_tile ) THEN 92 WRITE(numout,*) iitile, 'tiles in i' 93 WRITE(numout,*) ' Starting indices' 94 WRITE(numout,*) ' ', (ntsi_a(jt), jt=1, iitile) 95 WRITE(numout,*) ' Ending indices' 96 WRITE(numout,*) ' ', (ntei_a(jt), jt=1, iitile) 97 WRITE(numout,*) ijtile, 'tiles in j' 98 WRITE(numout,*) ' Starting indices' 99 WRITE(numout,*) ' ', (ntsj_a(jt), jt=1, nijtile, iitile) 100 WRITE(numout,*) ' Ending indices' 101 WRITE(numout,*) ' ', (ntej_a(jt), jt=1, nijtile, iitile) 102 ELSE 103 WRITE(numout,*) 'No domain tiling' 104 WRITE(numout,*) ' i indices =', ktsi, ':', ktei 105 WRITE(numout,*) ' j indices =', ktsj, ':', ktej 106 ENDIF 107 ENDIF 108 ENDIF 155 ENDIF 156 157 ktsi = ntsi_a(ktile) ! Set the domain indices 158 ktsj = ntsj_a(ktile) 159 ktei = ntei_a(ktile) 160 ktej = ntej_a(ktile) 161 162 ! Calculate the modifying factor on DO loop bounds (1 = do not work on points that have already been processed by a neighbouring tile) 163 nthl = 0 ; nthr = 0 ; nthb = 0 ; ntht = 0 164 iitile = Ni_0 / nn_ltile_i 165 IF( MOD( Ni_0, nn_ltile_i ) /= 0 ) iitile = iitile + 1 166 IF( ktsi > Nis0 ) THEN ; IF( l_tilefin(ktile - 1 ) ) nthl = 1 ; ENDIF ! Left adjacent tile 167 IF( ktei < Nie0 ) THEN ; IF( l_tilefin(ktile + 1 ) ) nthr = 1 ; ENDIF ! Right " " 168 IF( ktsj > Njs0 ) THEN ; IF( l_tilefin(ktile - iitile) ) nthb = 1 ; ENDIF ! Bottom " " 169 IF( ktej < Nje0 ) THEN ; IF( l_tilefin(ktile + iitile) ) ntht = 1 ; ENDIF ! Top " " 109 170 END SUBROUTINE dom_tile 110 171 172 173 SUBROUTINE dom_tile_start( ldhold, cstr ) 174 !!---------------------------------------------------------------------- 175 !! *** ROUTINE dom_tile_start *** 176 !! 177 !! ** Purpose : Start or resume the use of tiling 178 !! 179 !! ** Method : dom_tile_start & dom_tile_stop are used to declare a tiled region of code. 180 !! 181 !! Tiling is active/inactive (l_istiled = .true./.false.) within/outside of this code region. 182 !! After enabling tiling, no tile will initially be set (the full domain will be used) and dom_tile must 183 !! be called to set a specific tile to work on. Furthermore, all tiles will be marked as incomplete 184 !! (ln_tilefin(:) = .false.). 185 !! 186 !! Tiling can be paused/resumed within the tiled code region by calling dom_tile_stop/dom_tile_start 187 !! with ldhold = .true.. This can be used to temporarily revert back to using the full domain. 188 !! 189 !! CALL dom_tile_start ! Enable tiling 190 !! CALL dom_tile(ntsi, ntei, ntsj, ntej, ktile=n) ! Set current tile "n" 191 !! ... 192 !! CALL dom_tile_stop(.TRUE.) ! Pause tiling (temporarily disable) 193 !! ... 194 !! CALL dom_tile_start(.TRUE.) ! Resume tiling 195 !! CALL dom_tile_stop ! Disable tiling 196 !!---------------------------------------------------------------------- 197 LOGICAL, INTENT(in), OPTIONAL :: ldhold ! Resume (.true.) or start (.false.) 198 LOGICAL :: llhold 199 CHARACTER(len=*), INTENT(in), OPTIONAL :: cstr ! Debug information (added to warnings) 200 CHARACTER(len=23) :: clstr 201 !!---------------------------------------------------------------------- 202 llhold = .FALSE. 203 IF( PRESENT(ldhold) ) llhold = ldhold 204 clstr = '' 205 IF( PRESENT(cstr) ) clstr = TRIM(' ('//TRIM(cstr)//')') 206 207 IF( .NOT. ln_tile ) CALL ctl_stop('Cannot resume/start tiling as ln_tile = .false.') 208 IF( l_istiled ) THEN 209 CALL ctl_warn('Cannot resume/start tiling as it is already active'//clstr) 210 RETURN 211 ! TODO: [tiling] this warning will always be raised outside a tiling loop (cannot check for pause rather than stop) 212 ELSE IF( llhold .AND. ntile == 0 ) THEN 213 CALL ctl_warn('Cannot resume tiling as it is not paused'//clstr) 214 RETURN 215 ENDIF 216 217 ! Whether resumed or started, the tiling is made active. If resumed, the domain indices for the current tile are used. 218 IF( llhold ) CALL dom_tile(ntsi, ntsj, ntei, ntej, ktile=ntile, ldhold=.TRUE., cstr='dom_tile_start'//clstr) 219 l_istiled = .TRUE. 220 END SUBROUTINE dom_tile_start 221 222 223 SUBROUTINE dom_tile_stop( ldhold, cstr ) 224 !!---------------------------------------------------------------------- 225 !! *** ROUTINE dom_tile_stop *** 226 !! 227 !! ** Purpose : End or pause the use of tiling 228 !! 229 !! ** Method : See dom_tile_start 230 !!---------------------------------------------------------------------- 231 LOGICAL, INTENT(in), OPTIONAL :: ldhold ! Pause (.true.) or stop (.false.) 232 LOGICAL :: llhold 233 CHARACTER(len=*), INTENT(in), OPTIONAL :: cstr ! Debug information (added to warnings) 234 CHARACTER(len=23) :: clstr 235 !!---------------------------------------------------------------------- 236 llhold = .FALSE. 237 IF( PRESENT(ldhold) ) llhold = ldhold 238 clstr = '' 239 IF( PRESENT(cstr) ) clstr = TRIM(' ('//TRIM(cstr)//')') 240 241 IF( .NOT. ln_tile ) CALL ctl_stop('Cannot pause/stop tiling as ln_tile = .false.') 242 IF( .NOT. l_istiled ) THEN 243 CALL ctl_warn('Cannot pause/stop tiling as it is inactive'//clstr) 244 RETURN 245 ENDIF 246 247 ! Whether paused or stopped, the tiling is made inactive and the full domain indices are used. 248 ! If stopped, there is no active tile (ntile = 0) and the finished tile indicators are reset 249 CALL dom_tile(ntsi, ntsj, ntei, ntej, ktile=0, ldhold=llhold, cstr='dom_tile_stop'//clstr) 250 IF( .NOT. llhold ) l_tilefin(:) = .FALSE. 251 l_istiled = .FALSE. 252 END SUBROUTINE dom_tile_stop 111 253 !!====================================================================== 112 254 END MODULE domtile -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/domutl.F90
r14072 r14958 22 22 23 23 INTERFACE is_tile 24 MODULE PROCEDURE is_tile_2d , is_tile_3d, is_tile_4d24 MODULE PROCEDURE is_tile_2d_sp, is_tile_3d_sp, is_tile_4d_sp, is_tile_2d_dp, is_tile_3d_dp, is_tile_4d_dp 25 25 END INTERFACE is_tile 26 26 … … 116 116 117 117 118 FUNCTION is_tile_2d( pt ) 119 !! 120 REAL(wp), DIMENSION(:,:), INTENT(in) :: pt 121 INTEGER :: is_tile_2d 122 !! 123 IF( ln_tile .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 124 is_tile_2d = 1 118 INTEGER FUNCTION is_tile_2d_sp( pt ) 119 REAL(sp), DIMENSION(:,:), INTENT(in) :: pt 120 121 IF( l_istiled .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 122 is_tile_2d_sp = 1 125 123 ELSE 126 is_tile_2d = 0124 is_tile_2d_sp = 0 127 125 ENDIF 128 END FUNCTION is_tile_2d 126 END FUNCTION is_tile_2d_sp 129 127 130 128 131 FUNCTION is_tile_3d( pt ) 132 !! 133 REAL(wp), DIMENSION(:,:,:), INTENT(in) :: pt 134 INTEGER :: is_tile_3d 135 !! 136 IF( ln_tile .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 137 is_tile_3d = 1 129 INTEGER FUNCTION is_tile_2d_dp( pt ) 130 REAL(dp), DIMENSION(:,:), INTENT(in) :: pt 131 132 IF( l_istiled .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 133 is_tile_2d_dp = 1 138 134 ELSE 139 is_tile_ 3d= 0135 is_tile_2d_dp = 0 140 136 ENDIF 141 END FUNCTION is_tile_ 3d137 END FUNCTION is_tile_2d_dp 142 138 143 139 144 FUNCTION is_tile_4d( pt ) 145 !! 146 REAL(wp), DIMENSION(:,:,:,:), INTENT(in) :: pt 147 INTEGER :: is_tile_4d 148 !! 149 IF( ln_tile .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 150 is_tile_4d = 1 140 INTEGER FUNCTION is_tile_3d_sp( pt ) 141 REAL(sp), DIMENSION(:,:,:), INTENT(in) :: pt 142 143 IF( l_istiled .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 144 is_tile_3d_sp = 1 151 145 ELSE 152 is_tile_ 4d= 0146 is_tile_3d_sp = 0 153 147 ENDIF 154 END FUNCTION is_tile_ 4d148 END FUNCTION is_tile_3d_sp 155 149 150 151 INTEGER FUNCTION is_tile_3d_dp( pt ) 152 REAL(dp), DIMENSION(:,:,:), INTENT(in) :: pt 153 154 IF( l_istiled .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 155 is_tile_3d_dp = 1 156 ELSE 157 is_tile_3d_dp = 0 158 ENDIF 159 END FUNCTION is_tile_3d_dp 160 161 162 INTEGER FUNCTION is_tile_4d_sp( pt ) 163 REAL(sp), DIMENSION(:,:,:,:), INTENT(in) :: pt 164 165 IF( l_istiled .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 166 is_tile_4d_sp = 1 167 ELSE 168 is_tile_4d_sp = 0 169 ENDIF 170 END FUNCTION is_tile_4d_sp 171 172 173 INTEGER FUNCTION is_tile_4d_dp( pt ) 174 REAL(dp), DIMENSION(:,:,:,:), INTENT(in) :: pt 175 176 IF( l_istiled .AND. (SIZE(pt, 1) < jpi .OR. SIZE(pt, 2) < jpj) ) THEN 177 is_tile_4d_dp = 1 178 ELSE 179 is_tile_4d_dp = 0 180 ENDIF 181 END FUNCTION is_tile_4d_dp 156 182 !!====================================================================== 157 183 END MODULE domutl -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/domvvl.F90
r14433 r14958 204 204 gdept(:,:,1,Kbb) = 0.5_wp * e3w(:,:,1,Kbb) 205 205 gdepw(:,:,1,Kbb) = 0.0_wp 206 DO_3D( 1, 1, 1, 1, 2, jpk ) ! vertical sum206 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 2, jpk ) ! vertical sum 207 207 ! zcoef = tmask - wmask ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt 208 208 ! ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf) … … 404 404 zwu(:,:) = 0._wp 405 405 zwv(:,:) = 0._wp 406 DO_3D( 1, 0, 1, 0, 1, jpkm1 )! a - first derivative: diffusive fluxes406 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) ! a - first derivative: diffusive fluxes 407 407 un_td(ji,jj,jk) = rn_ahe3 * umask(ji,jj,jk) * e2_e1u(ji,jj) & 408 408 & * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji+1,jj ,jk) ) … … 412 412 zwv(ji,jj) = zwv(ji,jj) + vn_td(ji,jj,jk) 413 413 END_3D 414 DO_2D( 1, 1, 1, 1 )! b - correction for last oceanic u-v points414 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) ! b - correction for last oceanic u-v points 415 415 un_td(ji,jj,mbku(ji,jj)) = un_td(ji,jj,mbku(ji,jj)) - zwu(ji,jj) 416 416 vn_td(ji,jj,mbkv(ji,jj)) = vn_td(ji,jj,mbkv(ji,jj)) - zwv(ji,jj) … … 423 423 ! ! d - thickness diffusion transport: boundary conditions 424 424 ! (stored for tracer advction and continuity equation) 425 CALL lbc_lnk( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)425 IF( nn_hls == 1 ) CALL lbc_lnk( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp) 426 426 ! 4 - Time stepping of baroclinic scale factors 427 427 ! --------------------------------------------- … … 640 640 gdepw(:,:,1,Kmm) = 0.0_wp 641 641 gde3w(:,:,1) = gdept(:,:,1,Kmm) - ssh(:,:,Kmm) 642 DO_3D( 1, 1, 1, 1, 2, jpk )642 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 2, jpk ) 643 643 ! zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk)) ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt 644 644 ! 1 for jk = mikt -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/dtatsd.F90
r14189 r14958 141 141 INTEGER :: ji, jj, jk, jl, jkk ! dummy loop indicies 142 142 INTEGER :: ik, il0, il1, ii0, ii1, ij0, ij1 ! local integers 143 INTEGER :: itile144 143 INTEGER, DIMENSION(jpts), SAVE :: irec_b, irec_n 145 144 REAL(wp):: zl, zi ! local scalars … … 147 146 !!---------------------------------------------------------------------- 148 147 ! 149 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only for the full domain 150 itile = ntile 151 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Use full domain 148 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only for the full domain 149 IF( ln_tile ) CALL dom_tile_stop( ldhold=.TRUE. ) ! Use full domain 152 150 CALL fld_read( kt, 1, sf_tsd ) !== read T & S data at kt time step ==! 153 151 ! … … 195 193 ENDIF 196 194 !!gm end 197 IF( ln_tile ) CALL dom_tile ( ntsi, ntsj, ntei, ntej, ktile = itile) ! Revert to tile domain195 IF( ln_tile ) CALL dom_tile_start( ldhold=.TRUE. ) ! Revert to tile domain 198 196 ENDIF 199 197 ! … … 205 203 IF( ln_sco ) THEN !== s- or mixed s-zps-coordinate ==! 206 204 ! 207 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile205 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 208 206 IF( kt == nit000 .AND. lwp )THEN 209 207 WRITE(numout,*) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DOM/istate.F90
r14139 r14958 152 152 ! 153 153 !!gm the use of umsak & vmask is not necessary below as uu(:,:,:,Kmm), vv(:,:,:,Kmm), uu(:,:,:,Kbb), vv(:,:,:,Kbb) are always masked 154 DO_3D( 1, 1, 1, 1, 1, jpkm1 )154 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 155 155 uu_b(ji,jj,Kmm) = uu_b(ji,jj,Kmm) + e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) * umask(ji,jj,jk) 156 156 vv_b(ji,jj,Kmm) = vv_b(ji,jj,Kmm) + e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) * vmask(ji,jj,jk) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/divhor.F90
r13558 r14958 64 64 ! 65 65 INTEGER :: ji, jj, jk ! dummy loop indices 66 REAL(wp) :: zraur, zdep ! local scalars67 REAL(wp), DIMENSION(jpi,jpj) :: ztmp68 66 !!---------------------------------------------------------------------- 69 67 ! … … 71 69 ! 72 70 IF( kt == nit000 ) THEN 73 IF(lwp) WRITE(numout,*) 74 IF(lwp) WRITE(numout,*) 'div_hor : horizontal velocity divergence ' 75 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 76 hdiv(:,:,:) = 0._wp ! initialize hdiv for the halos at the first time step 71 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 72 IF(lwp) WRITE(numout,*) 73 IF(lwp) WRITE(numout,*) 'div_hor : horizontal velocity divergence ' 74 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 75 ENDIF 76 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 77 hdiv(ji,jj,jk) = 0._wp ! initialize hdiv for the halos at the first time step 78 END_3D 77 79 ENDIF 78 80 ! 79 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) !== Horizontal divergence ==! 80 hdiv(ji,jj,jk) = ( e2u(ji ,jj) * e3u(ji ,jj,jk,Kmm) * uu(ji ,jj,jk,Kmm) & 81 & - e2u(ji-1,jj) * e3u(ji-1,jj,jk,Kmm) * uu(ji-1,jj,jk,Kmm) & 82 & + e1v(ji,jj ) * e3v(ji,jj ,jk,Kmm) * vv(ji,jj ,jk,Kmm) & 83 & - e1v(ji,jj-1) * e3v(ji,jj-1,jk,Kmm) * vv(ji,jj-1,jk,Kmm) ) & 84 & * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) 81 DO_3D_OVR( nn_hls-1, nn_hls, nn_hls-1, nn_hls, 1, jpkm1 ) !== Horizontal divergence ==! 82 ! round brackets added to fix the order of floating point operations 83 ! needed to ensure halo 1 - halo 2 compatibility 84 hdiv(ji,jj,jk) = ( ( e2u(ji ,jj) * e3u(ji ,jj,jk,Kmm) * uu(ji ,jj,jk,Kmm) & 85 & - e2u(ji-1,jj) * e3u(ji-1,jj,jk,Kmm) * uu(ji-1,jj,jk,Kmm) & 86 & ) & ! bracket for halo 1 - halo 2 compatibility 87 & + ( e1v(ji,jj ) * e3v(ji,jj ,jk,Kmm) * vv(ji,jj ,jk,Kmm) & 88 & - e1v(ji,jj-1) * e3v(ji,jj-1,jk,Kmm) * vv(ji,jj-1,jk,Kmm) & 89 & ) & ! bracket for halo 1 - halo 2 compatibility 90 & ) * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) 85 91 END_3D 86 92 ! … … 91 97 ! 92 98 #endif 93 !94 99 IF( ln_isf ) CALL isf_hdiv( kt, Kmm, hdiv ) !== ice shelf ==! (update hdiv field) 95 100 ! 96 CALL lbc_lnk( 'divhor', hdiv, 'T', 1.0_wp ) ! (no sign change)101 IF (nn_hls==1) CALL lbc_lnk( 'divhor', hdiv, 'T', 1.0_wp ) ! (no sign change) 97 102 ! 98 103 IF( ln_timing ) CALL timing_stop('div_hor') -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynadv_cen2.F90
r13497 r14958 52 52 ! 53 53 INTEGER :: ji, jj, jk ! dummy loop indices 54 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zfu_t, zfu_f, zfu_uw, zfu55 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zfv_t, zfv_f, zfv_vw, zfv, zfw54 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zfu_t, zfu_f, zfu_uw, zfu 55 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zfv_t, zfv_f, zfv_vw, zfv, zfw 56 56 !!---------------------------------------------------------------------- 57 57 ! 58 IF( kt == nit000 .AND. lwp ) THEN 59 WRITE(numout,*) 60 WRITE(numout,*) 'dyn_adv_cen2 : 2nd order flux form momentum advection' 61 WRITE(numout,*) '~~~~~~~~~~~~' 58 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 59 IF( kt == nit000 .AND. lwp ) THEN 60 WRITE(numout,*) 61 WRITE(numout,*) 'dyn_adv_cen2 : 2nd order flux form momentum advection' 62 WRITE(numout,*) '~~~~~~~~~~~~' 63 ENDIF 62 64 ENDIF 63 65 ! … … 70 72 ! 71 73 DO jk = 1, jpkm1 ! horizontal transport 72 zfu(:,:,jk) = 0.25_wp * e2u(:,:) * e3u(:,:,jk,Kmm) * puu(:,:,jk,Kmm) 73 zfv(:,:,jk) = 0.25_wp * e1v(:,:) * e3v(:,:,jk,Kmm) * pvv(:,:,jk,Kmm) 74 DO_2D( 1, 1, 1, 1 ) 75 zfu(ji,jj,jk) = 0.25_wp * e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * puu(ji,jj,jk,Kmm) 76 zfv(ji,jj,jk) = 0.25_wp * e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pvv(ji,jj,jk,Kmm) 77 END_2D 74 78 DO_2D( 1, 0, 1, 0 ) ! horizontal momentum fluxes (at T- and F-point) 75 79 zfu_t(ji+1,jj ,jk) = ( zfu(ji,jj,jk) + zfu(ji+1,jj,jk) ) * ( puu(ji,jj,jk,Kmm) + puu(ji+1,jj ,jk,Kmm) ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynadv_ubs.F90
r14433 r14958 75 75 INTEGER :: ji, jj, jk ! dummy loop indices 76 76 REAL(wp) :: zui, zvj, zfuj, zfvi, zl_u, zl_v ! local scalars 77 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zfu_t, zfu_f, zfu_uw, zfu78 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zfv_t, zfv_f, zfv_vw, zfv, zfw79 REAL(wp), DIMENSION( jpi,jpj,jpk,2) :: zlu_uu, zlu_uv80 REAL(wp), DIMENSION( jpi,jpj,jpk,2) :: zlv_vv, zlv_vu77 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zfu_t, zfu_f, zfu_uw, zfu 78 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zfv_t, zfv_f, zfv_vw, zfv, zfw 79 REAL(wp), DIMENSION(A2D(nn_hls),jpk,2) :: zlu_uu, zlu_uv 80 REAL(wp), DIMENSION(A2D(nn_hls),jpk,2) :: zlv_vv, zlv_vu 81 81 !!---------------------------------------------------------------------- 82 82 ! 83 IF( kt == nit000 ) THEN 84 IF(lwp) WRITE(numout,*) 85 IF(lwp) WRITE(numout,*) 'dyn_adv_ubs : UBS flux form momentum advection' 86 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 83 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 84 IF( kt == nit000 ) THEN 85 IF(lwp) WRITE(numout,*) 86 IF(lwp) WRITE(numout,*) 'dyn_adv_ubs : UBS flux form momentum advection' 87 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 88 ENDIF 87 89 ENDIF 88 90 ! … … 105 107 ! ! =========================== ! 106 108 ! ! horizontal volume fluxes 107 zfu(:,:,jk) = e2u(:,:) * e3u(:,:,jk,Kmm) * puu(:,:,jk,Kmm) 108 zfv(:,:,jk) = e1v(:,:) * e3v(:,:,jk,Kmm) * pvv(:,:,jk,Kmm) 109 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 110 zfu(ji,jj,jk) = e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * puu(ji,jj,jk,Kmm) 111 zfv(ji,jj,jk) = e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pvv(ji,jj,jk,Kmm) 112 END_2D 109 113 ! 110 DO_2D( 0, 0, 0, 0 ) ! laplacian 111 zlu_uu(ji,jj,jk,1) = ( puu (ji+1,jj ,jk,Kbb) - 2.*puu (ji,jj,jk,Kbb) + puu (ji-1,jj ,jk,Kbb) ) * umask(ji,jj,jk) 112 zlv_vv(ji,jj,jk,1) = ( pvv (ji ,jj+1,jk,Kbb) - 2.*pvv (ji,jj,jk,Kbb) + pvv (ji ,jj-1,jk,Kbb) ) * vmask(ji,jj,jk) 113 zlu_uv(ji,jj,jk,1) = ( puu (ji ,jj+1,jk,Kbb) - puu (ji ,jj ,jk,Kbb) ) * fmask(ji ,jj ,jk) & 114 & - ( puu (ji ,jj ,jk,Kbb) - puu (ji ,jj-1,jk,Kbb) ) * fmask(ji ,jj-1,jk) 115 zlv_vu(ji,jj,jk,1) = ( pvv (ji+1,jj ,jk,Kbb) - pvv (ji ,jj ,jk,Kbb) ) * fmask(ji ,jj ,jk) & 116 & - ( pvv (ji ,jj ,jk,Kbb) - pvv (ji-1,jj ,jk,Kbb) ) * fmask(ji-1,jj ,jk) 117 ! 118 zlu_uu(ji,jj,jk,2) = ( zfu(ji+1,jj ,jk) - 2.*zfu(ji,jj,jk) + zfu(ji-1,jj ,jk) ) * umask(ji,jj,jk) 119 zlv_vv(ji,jj,jk,2) = ( zfv(ji ,jj+1,jk) - 2.*zfv(ji,jj,jk) + zfv(ji ,jj-1,jk) ) * vmask(ji,jj,jk) 120 zlu_uv(ji,jj,jk,2) = ( zfu(ji ,jj+1,jk) - zfu(ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & 121 & - ( zfu(ji ,jj ,jk) - zfu(ji ,jj-1,jk) ) * fmask(ji ,jj-1,jk) 122 zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj ,jk) - zfv(ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & 123 & - ( zfv(ji ,jj ,jk) - zfv(ji-1,jj ,jk) ) * fmask(ji-1,jj ,jk) 114 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! laplacian 115 ! round brackets added to fix the order of floating point operations 116 ! needed to ensure halo 1 - halo 2 compatibility 117 zlu_uu(ji,jj,jk,1) = ( ( puu (ji+1,jj ,jk,Kbb) - puu (ji ,jj ,jk,Kbb) & 118 & ) & ! bracket for halo 1 - halo 2 compatibility 119 & + ( puu (ji-1,jj ,jk,Kbb) - puu (ji ,jj ,jk,Kbb) & 120 & ) & ! bracket for halo 1 - halo 2 compatibility 121 & ) * umask(ji ,jj ,jk) 122 zlv_vv(ji,jj,jk,1) = ( ( pvv (ji ,jj+1,jk,Kbb) - pvv (ji ,jj ,jk,Kbb) & 123 & ) & ! bracket for halo 1 - halo 2 compatibility 124 & + ( pvv (ji ,jj-1,jk,Kbb) - pvv (ji ,jj ,jk,Kbb) & 125 & ) & ! bracket for halo 1 - halo 2 compatibility 126 & ) * vmask(ji ,jj ,jk) 127 zlu_uv(ji,jj,jk,1) = ( puu (ji ,jj+1,jk,Kbb) - puu (ji ,jj ,jk,Kbb) ) * fmask(ji ,jj ,jk) & 128 & - ( puu (ji ,jj ,jk,Kbb) - puu (ji ,jj-1,jk,Kbb) ) * fmask(ji ,jj-1,jk) 129 zlv_vu(ji,jj,jk,1) = ( pvv (ji+1,jj ,jk,Kbb) - pvv (ji ,jj ,jk,Kbb) ) * fmask(ji ,jj ,jk) & 130 & - ( pvv (ji ,jj ,jk,Kbb) - pvv (ji-1,jj ,jk,Kbb) ) * fmask(ji-1,jj ,jk) 131 ! 132 ! round brackets added to fix the order of floating point operations 133 ! needed to ensure halo 1 - halo 2 compatibility 134 zlu_uu(ji,jj,jk,2) = ( ( zfu(ji+1,jj ,jk) - zfu(ji ,jj ,jk) & 135 & ) & ! bracket for halo 1 - halo 2 compatibility 136 & + ( zfu(ji-1,jj ,jk) - zfu(ji ,jj ,jk) & 137 & ) & ! bracket for halo 1 - halo 2 compatibility 138 & ) * umask(ji ,jj ,jk) 139 zlv_vv(ji,jj,jk,2) = ( ( zfv(ji ,jj+1,jk) - zfv(ji ,jj ,jk) & 140 & ) & ! bracket for halo 1 - halo 2 compatibility 141 & + ( zfv(ji ,jj-1,jk) - zfv(ji ,jj ,jk) & 142 & ) & ! bracket for halo 1 - halo 2 compatibility 143 & ) * vmask(ji ,jj ,jk) 144 zlu_uv(ji,jj,jk,2) = ( zfu(ji ,jj+1,jk) - zfu(ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & 145 & - ( zfu(ji ,jj ,jk) - zfu(ji ,jj-1,jk) ) * fmask(ji ,jj-1,jk) 146 zlv_vu(ji,jj,jk,2) = ( zfv(ji+1,jj ,jk) - zfv(ji ,jj ,jk) ) * fmask(ji ,jj ,jk) & 147 & - ( zfv(ji ,jj ,jk) - zfv(ji-1,jj ,jk) ) * fmask(ji-1,jj ,jk) 124 148 END_2D 125 149 END DO 126 CALL lbc_lnk( 'dynadv_ubs', zlu_uu(:,:,:,1), 'U', 1.0_wp , zlu_uv(:,:,:,1), 'U',1.0_wp, &127 & zlu_uu(:,:,:,2), 'U', 1.0_wp , zlu_uv(:,:,:,2), 'U', 1.0_wp, &128 & zlv_vv(:,:,:,1), 'V', 1.0_wp , zlv_vu(:,:,:,1), 'V',1.0_wp, &129 & zlv_vv(:,:,:,2), 'V', 1.0_wp , zlv_vu(:,:,:,2), 'V',1.0_wp )150 IF( nn_hls == 1 ) CALL lbc_lnk( 'dynadv_ubs', zlu_uu(:,:,:,1), 'U', -1.0_wp , zlu_uv(:,:,:,1), 'U', -1.0_wp, & 151 & zlu_uu(:,:,:,2), 'U', -1.0_wp , zlu_uv(:,:,:,2), 'U', -1.0_wp, & 152 & zlv_vv(:,:,:,1), 'V', -1.0_wp , zlv_vu(:,:,:,1), 'V', -1.0_wp, & 153 & zlv_vv(:,:,:,2), 'V', -1.0_wp , zlv_vu(:,:,:,2), 'V', -1.0_wp ) 130 154 ! 131 155 ! ! ====================== ! … … 133 157 DO jk = 1, jpkm1 ! ====================== ! 134 158 ! ! horizontal volume fluxes 135 zfu(:,:,jk) = 0.25_wp * e2u(:,:) * e3u(:,:,jk,Kmm) * puu(:,:,jk,Kmm) 136 zfv(:,:,jk) = 0.25_wp * e1v(:,:) * e3v(:,:,jk,Kmm) * pvv(:,:,jk,Kmm) 159 DO_2D( 1, 1, 1, 1 ) 160 zfu(ji,jj,jk) = 0.25_wp * e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * puu(ji,jj,jk,Kmm) 161 zfv(ji,jj,jk) = 0.25_wp * e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pvv(ji,jj,jk,Kmm) 162 END_2D 137 163 ! 138 164 DO_2D( 1, 0, 1, 0 ) ! horizontal momentum fluxes at T- and F-point -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynatf.F90
r14433 r14958 201 201 IF( ln_linssh ) THEN ! Fixed volume ! 202 202 ! ! =============! 203 DO_3D( 1, 1, 1, 1, 1, jpkm1 )203 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 204 204 puu(ji,jj,jk,Kmm) = puu(ji,jj,jk,Kmm) + rn_atfp * ( puu(ji,jj,jk,Kbb) - 2._wp * puu(ji,jj,jk,Kmm) + puu(ji,jj,jk,Kaa) ) 205 205 pvv(ji,jj,jk,Kmm) = pvv(ji,jj,jk,Kmm) + rn_atfp * ( pvv(ji,jj,jk,Kbb) - 2._wp * pvv(ji,jj,jk,Kmm) + pvv(ji,jj,jk,Kaa) ) … … 237 237 CALL dom_vvl_interpol( pe3t(:,:,:,Kmm), pe3u(:,:,:,Kmm), 'U' ) 238 238 CALL dom_vvl_interpol( pe3t(:,:,:,Kmm), pe3v(:,:,:,Kmm), 'V' ) 239 DO_3D( 1, 1, 1, 1, 1, jpkm1 )239 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 240 240 puu(ji,jj,jk,Kmm) = puu(ji,jj,jk,Kmm) + rn_atfp * ( puu(ji,jj,jk,Kbb) - 2._wp * puu(ji,jj,jk,Kmm) + puu(ji,jj,jk,Kaa) ) 241 241 pvv(ji,jj,jk,Kmm) = pvv(ji,jj,jk,Kmm) + rn_atfp * ( pvv(ji,jj,jk,Kbb) - 2._wp * pvv(ji,jj,jk,Kmm) + pvv(ji,jj,jk,Kaa) ) … … 248 248 CALL dom_vvl_interpol( pe3t(:,:,:,Kmm), ze3u_f, 'U' ) 249 249 CALL dom_vvl_interpol( pe3t(:,:,:,Kmm), ze3v_f, 'V' ) 250 DO_3D( 1, 1, 1, 1, 1, jpkm1 )250 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 251 251 zue3a = pe3u(ji,jj,jk,Kaa) * puu(ji,jj,jk,Kaa) 252 252 zve3a = pe3v(ji,jj,jk,Kaa) * pvv(ji,jj,jk,Kaa) … … 285 285 ENDIF ! .NOT. l_1st_euler 286 286 ! 287 ! This is needed for dyn_ldf_blp to be restartable 288 IF( nn_hls == 2 ) CALL lbc_lnk( 'dynatf', puu(:,:,:,Kmm), 'U', -1.0_wp, pvv(:,:,:,Kmm), 'V', -1.0_wp ) 287 289 ! Set "now" and "before" barotropic velocities for next time step: 288 290 ! JC: Would be more clever to swap variables than to make a full vertical -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynatf_qco.F90
r14475 r14958 139 139 IF( ln_linssh ) THEN ! Fixed volume ! 140 140 ! ! =============! 141 DO_3D( 1, 1, 1, 1, 1, jpkm1 )141 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 142 142 puu(ji,jj,jk,Kmm) = puu(ji,jj,jk,Kmm) + rn_atfp * ( puu(ji,jj,jk,Kbb) - 2._wp * puu(ji,jj,jk,Kmm) + puu(ji,jj,jk,Kaa) ) 143 143 pvv(ji,jj,jk,Kmm) = pvv(ji,jj,jk,Kmm) + rn_atfp * ( pvv(ji,jj,jk,Kbb) - 2._wp * pvv(ji,jj,jk,Kmm) + pvv(ji,jj,jk,Kaa) ) … … 149 149 IF( ln_dynadv_vec ) THEN ! Asselin filter applied on velocity 150 150 ! Before filtered scale factor at (u/v)-points 151 DO_3D( 1, 1, 1, 1, 1, jpkm1 )151 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 152 152 puu(ji,jj,jk,Kmm) = puu(ji,jj,jk,Kmm) + rn_atfp * ( puu(ji,jj,jk,Kbb) - 2._wp * puu(ji,jj,jk,Kmm) + puu(ji,jj,jk,Kaa) ) 153 153 pvv(ji,jj,jk,Kmm) = pvv(ji,jj,jk,Kmm) + rn_atfp * ( pvv(ji,jj,jk,Kbb) - 2._wp * pvv(ji,jj,jk,Kmm) + pvv(ji,jj,jk,Kaa) ) … … 156 156 ELSE ! Asselin filter applied on thickness weighted velocity 157 157 ! 158 DO_3D( 1, 1, 1, 1, 1, jpkm1 )158 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 159 159 zue3a = ( 1._wp + r3u(ji,jj,Kaa) * umask(ji,jj,jk) ) * puu(ji,jj,jk,Kaa) 160 160 zve3a = ( 1._wp + r3v(ji,jj,Kaa) * vmask(ji,jj,jk) ) * pvv(ji,jj,jk,Kaa) … … 195 195 ENDIF ! .NOT. l_1st_euler 196 196 ! 197 ! This is needed for dyn_ldf_blp to be restartable 198 IF( nn_hls == 2 ) CALL lbc_lnk( 'dynatfqco', puu(:,:,:,Kmm), 'U', -1.0_wp, pvv(:,:,:,Kmm), 'V', -1.0_wp ) 199 197 200 ! Set "now" and "before" barotropic velocities for next time step: 198 201 ! JC: Would be more clever to swap variables than to make a full vertical -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynhpg.F90
r14433 r14958 266 266 INTEGER :: ji, jj, jk ! dummy loop indices 267 267 REAL(wp) :: zcoef0, zcoef1 ! temporary scalars 268 REAL(wp), DIMENSION(jpi,jpj) :: zhpi, zhpj 269 !!---------------------------------------------------------------------- 270 ! 271 IF( kt == nit000 ) THEN 272 IF(lwp) WRITE(numout,*) 273 IF(lwp) WRITE(numout,*) 'dyn:hpg_zco : hydrostatic pressure gradient trend' 274 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate case ' 268 REAL(wp), DIMENSION(A2D(nn_hls)) :: zhpi, zhpj 269 !!---------------------------------------------------------------------- 270 ! 271 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 272 IF( kt == nit000 ) THEN 273 IF(lwp) WRITE(numout,*) 274 IF(lwp) WRITE(numout,*) 'dyn:hpg_zco : hydrostatic pressure gradient trend' 275 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate case ' 276 ENDIF 275 277 ENDIF 276 278 ! … … 318 320 INTEGER :: iku, ikv ! temporary integers 319 321 REAL(wp) :: zcoef0, zcoef1, zcoef2, zcoef3 ! temporary scalars 320 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zhpi, zhpj 321 REAL(wp), DIMENSION(jpi,jpj,jpts) :: zgtsu, zgtsv 322 REAL(wp), DIMENSION(jpi,jpj) :: zgru, zgrv 323 !!---------------------------------------------------------------------- 324 ! 325 IF( kt == nit000 ) THEN 326 IF(lwp) WRITE(numout,*) 327 IF(lwp) WRITE(numout,*) 'dyn:hpg_zps : hydrostatic pressure gradient trend' 328 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate with partial steps - vector optimization' 322 REAL(wp), DIMENSION(A2D(nn_hls),jpk ) :: zhpi, zhpj 323 REAL(wp), DIMENSION(A2D(nn_hls),jpts) :: zgtsu, zgtsv 324 REAL(wp), DIMENSION(A2D(nn_hls) ) :: zgru, zgrv 325 !!---------------------------------------------------------------------- 326 ! 327 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 328 IF( kt == nit000 ) THEN 329 IF(lwp) WRITE(numout,*) 330 IF(lwp) WRITE(numout,*) 'dyn:hpg_zps : hydrostatic pressure gradient trend' 331 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ z-coordinate with partial steps - vector optimization' 332 ENDIF 329 333 ENDIF 330 334 … … 410 414 REAL(wp) :: zcoef0, zuap, zvap, ztmp ! local scalars 411 415 LOGICAL :: ll_tmp1, ll_tmp2 ! local logical variables 412 REAL(wp), DIMENSION( jpi,jpj,jpk):: zhpi, zhpj416 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zhpi, zhpj 413 417 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zcpx, zcpy !W/D pressure filter 414 418 !!---------------------------------------------------------------------- 415 419 ! 416 IF( ln_wd_il ) ALLOCATE(zcpx(jpi,jpj), zcpy(jpi,jpj)) 417 ! 418 IF( kt == nit000 ) THEN 419 IF(lwp) WRITE(numout,*) 420 IF(lwp) WRITE(numout,*) 'dyn:hpg_sco : hydrostatic pressure gradient trend' 421 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, OCE original scheme used' 420 IF( ln_wd_il ) ALLOCATE(zcpx(A2D(nn_hls)), zcpy(A2D(nn_hls))) 421 ! 422 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 423 IF( kt == nit000 ) THEN 424 IF(lwp) WRITE(numout,*) 425 IF(lwp) WRITE(numout,*) 'dyn:hpg_sco : hydrostatic pressure gradient trend' 426 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, OCE original scheme used' 427 ENDIF 422 428 ENDIF 423 429 ! … … 462 468 END IF 463 469 END_2D 464 CALL lbc_lnk( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )465 470 END IF 466 471 ! … … 548 553 REAL(wp) :: ze3w, ze3wi1, ze3wj1 ! local scalars 549 554 REAL(wp) :: zcoef0, zuap, zvap ! - - 550 REAL(wp), DIMENSION( jpi,jpj,jpk ) :: zhpi, zhpj551 REAL(wp), DIMENSION( jpi,jpj,jpts) :: zts_top552 REAL(wp), DIMENSION( jpi,jpj) :: zrhdtop_oce555 REAL(wp), DIMENSION(A2D(nn_hls),jpk ) :: zhpi, zhpj 556 REAL(wp), DIMENSION(A2D(nn_hls),jpts) :: zts_top 557 REAL(wp), DIMENSION(A2D(nn_hls)) :: zrhdtop_oce 553 558 !!---------------------------------------------------------------------- 554 559 ! … … 560 565 ! compute rhd at the ice/oce interface (ocean side) 561 566 ! usefull to reduce residual current in the test case ISOMIP with no melting 562 DO ji = 1, jpi 563 DO jj = 1, jpj 564 ikt = mikt(ji,jj) 565 zts_top(ji,jj,1) = ts(ji,jj,ikt,1,Kmm) 566 zts_top(ji,jj,2) = ts(ji,jj,ikt,2,Kmm) 567 END DO 568 END DO 567 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 568 ikt = mikt(ji,jj) 569 zts_top(ji,jj,1) = ts(ji,jj,ikt,1,Kmm) 570 zts_top(ji,jj,2) = ts(ji,jj,ikt,2,Kmm) 571 END_2D 569 572 CALL eos( zts_top, risfdep, zrhdtop_oce ) 570 573 … … 636 639 INTEGER :: iktb, iktt ! jk indices at tracer points for top and bottom points 637 640 REAL(wp) :: zcoef0, zep, cffw ! temporary scalars 638 REAL(wp) :: z_grav_10, z1_12 641 REAL(wp) :: z_grav_10, z1_12, z1_cff 639 642 REAL(wp) :: cffu, cffx ! " " 640 643 REAL(wp) :: cffv, cffy ! " " 641 644 LOGICAL :: ll_tmp1, ll_tmp2 ! local logical variables 642 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zhpi, zhpj643 644 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zdzx, zdzy, zdzz ! Primitive grid differences ('delta_xyz')645 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zdz_i, zdz_j, zdz_k ! Harmonic average of primitive grid differences ('d_xyz')646 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zdrhox, zdrhoy, zdrhoz ! Primitive rho differences ('delta_rho')647 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zdrho_i, zdrho_j, zdrho_k ! Harmonic average of primitive rho differences ('d_rho')648 REAL(wp), DIMENSION( jpi,jpj,jpk) :: z_rho_i, z_rho_j, z_rho_k ! Face intergrals649 REAL(wp), DIMENSION( jpi,jpj) :: zz_dz_i, zz_dz_j, zz_drho_i, zz_drho_j ! temporary arrays645 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zhpi, zhpj 646 647 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zdzx, zdzy, zdzz ! Primitive grid differences ('delta_xyz') 648 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zdz_i, zdz_j, zdz_k ! Harmonic average of primitive grid differences ('d_xyz') 649 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zdrhox, zdrhoy, zdrhoz ! Primitive rho differences ('delta_rho') 650 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zdrho_i, zdrho_j, zdrho_k ! Harmonic average of primitive rho differences ('d_rho') 651 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: z_rho_i, z_rho_j, z_rho_k ! Face intergrals 652 REAL(wp), DIMENSION(A2D(nn_hls)) :: zz_dz_i, zz_dz_j, zz_drho_i, zz_drho_j ! temporary arrays 650 653 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zcpx, zcpy !W/D pressure filter 651 654 !!---------------------------------------------------------------------- 652 655 ! 653 656 IF( ln_wd_il ) THEN 654 ALLOCATE( zcpx( jpi,jpj) , zcpy(jpi,jpj) )657 ALLOCATE( zcpx(A2D(nn_hls)) , zcpy(A2D(nn_hls)) ) 655 658 DO_2D( 0, 0, 0, 0 ) 656 659 ll_tmp1 = MIN( ssh(ji,jj,Kmm) , ssh(ji+1,jj,Kmm) ) > & … … 689 692 END IF 690 693 END_2D 691 CALL lbc_lnk( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )692 694 END IF 693 695 694 IF( kt == nit000 ) THEN 695 IF(lwp) WRITE(numout,*) 696 IF(lwp) WRITE(numout,*) 'dyn:hpg_djc : hydrostatic pressure gradient trend' 697 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, density Jacobian with cubic polynomial scheme' 696 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 697 IF( kt == nit000 ) THEN 698 IF(lwp) WRITE(numout,*) 699 IF(lwp) WRITE(numout,*) 'dyn:hpg_djc : hydrostatic pressure gradient trend' 700 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, density Jacobian with cubic polynomial scheme' 701 ENDIF 698 702 ENDIF 699 703 … … 723 727 zdz_k (:,:,:) = 0._wp 724 728 725 DO_3D( 1, 1, 1, 1, 2, jpk-2 ) 726 cffw = 2._wp * zdrhoz(ji ,jj ,jk) * zdrhoz(ji,jj,jk+1) 727 IF( cffw > zep) THEN 728 zdrho_k(ji,jj,jk) = cffw / ( zdrhoz(ji,jj,jk) + zdrhoz(ji,jj,jk+1) ) 729 ENDIF 729 DO_3D( 1, 1, 1, 1, 2, jpk-2 ) 730 cffw = MAX( 2._wp * zdrhoz(ji,jj,jk) * zdrhoz(ji,jj,jk+1), 0._wp ) 731 z1_cff = zdrhoz(ji,jj,jk) + zdrhoz(ji,jj,jk+1) 732 zdrho_k(ji,jj,jk) = cffw / SIGN( MAX( ABS(z1_cff), zep ), z1_cff ) 730 733 zdz_k(ji,jj,jk) = 2._wp * zdzz(ji,jj,jk) * zdzz(ji,jj,jk+1) & 731 734 & / ( zdzz(ji,jj,jk) + zdzz(ji,jj,jk+1) ) … … 737 740 738 741 ! mb for sea-ice shelves we will need to re-write this upper boundary condition in the same form as the lower boundary condition 739 zdrho_k(:,:,1) = aco_bc_vrt * ( rhd (:,:,2) - rhd (:,:,1) ) - bco_bc_vrt * zdrho_k(:,:,2) 740 zdz_k (:,:,1) = aco_bc_vrt * (-gde3w(:,:,2) + gde3w(:,:,1) ) - bco_bc_vrt * zdz_k (:,:,2) 742 DO_2D( 1, 1, 1, 1 ) 743 zdrho_k(ji,jj,1) = aco_bc_vrt * ( rhd (ji,jj,2) - rhd (ji,jj,1) ) - bco_bc_vrt * zdrho_k(ji,jj,2) 744 zdz_k (ji,jj,1) = aco_bc_vrt * (-gde3w(ji,jj,2) + gde3w(ji,jj,1) ) - bco_bc_vrt * zdz_k (ji,jj,2) 745 END_2D 741 746 742 747 DO_2D( 1, 1, 1, 1 ) … … 785 790 ! 5. compute and store elementary horizontal differences in provisional arrays 786 791 !---------------------------------------------------------------------------------------- 787 788 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 789 zdrhox(ji,jj,jk) = rhd (ji+1,jj ,jk) - rhd (ji,jj,jk ) 790 zdzx (ji,jj,jk) = - gde3w(ji+1,jj ,jk) + gde3w(ji,jj,jk ) 791 zdrhoy(ji,jj,jk) = rhd (ji ,jj+1,jk) - rhd (ji,jj,jk ) 792 zdzy (ji,jj,jk) = - gde3w(ji ,jj+1,jk) + gde3w(ji,jj,jk ) 793 END_3D 794 795 CALL lbc_lnk( 'dynhpg', zdrhox, 'U', 1., zdzx, 'U', 1., zdrhoy, 'V', 1., zdzy, 'V', 1. ) 792 zdrhox(:,:,:) = 0._wp 793 zdzx (:,:,:) = 0._wp 794 zdrhoy(:,:,:) = 0._wp 795 zdzy (:,:,:) = 0._wp 796 797 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 798 zdrhox(ji,jj,jk) = rhd (ji+1,jj ,jk) - rhd (ji ,jj ,jk) 799 zdzx (ji,jj,jk) = gde3w(ji ,jj ,jk) - gde3w(ji+1,jj ,jk) 800 zdrhoy(ji,jj,jk) = rhd (ji ,jj+1,jk) - rhd (ji ,jj ,jk) 801 zdzy (ji,jj,jk) = gde3w(ji ,jj ,jk) - gde3w(ji ,jj+1,jk) 802 END_3D 803 804 IF( nn_hls == 1 ) CALL lbc_lnk( 'dynhpg', zdrhox, 'U', -1._wp, zdzx, 'U', -1._wp, zdrhoy, 'V', -1._wp, zdzy, 'V', -1._wp ) 796 805 797 806 !------------------------------------------------------------------------- … … 800 809 801 810 DO_3D( 0, 1, 0, 1, 1, jpkm1 ) 802 cffu = 2._wp * zdrhox(ji-1,jj ,jk) * zdrhox(ji,jj,jk ) 803 IF( cffu > zep ) THEN 804 zdrho_i(ji,jj,jk) = cffu / ( zdrhox(ji-1,jj,jk) + zdrhox(ji,jj,jk) ) 805 ELSE 806 zdrho_i(ji,jj,jk ) = 0._wp 807 ENDIF 808 809 cffx = 2._wp * zdzx (ji-1,jj ,jk) * zdzx (ji,jj,jk ) 810 IF( cffx > zep ) THEN 811 zdz_i(ji,jj,jk) = cffx / ( zdzx(ji-1,jj,jk) + zdzx(ji,jj,jk) ) 812 ELSE 813 zdz_i(ji,jj,jk) = 0._wp 814 ENDIF 815 816 cffv = 2._wp * zdrhoy(ji ,jj-1,jk) * zdrhoy(ji,jj,jk ) 817 IF( cffv > zep ) THEN 818 zdrho_j(ji,jj,jk) = cffv / ( zdrhoy(ji,jj-1,jk) + zdrhoy(ji,jj,jk) ) 819 ELSE 820 zdrho_j(ji,jj,jk) = 0._wp 821 ENDIF 822 823 cffy = 2._wp * zdzy (ji ,jj-1,jk) * zdzy (ji,jj,jk ) 824 IF( cffy > zep ) THEN 825 zdz_j(ji,jj,jk) = cffy / ( zdzy(ji,jj-1,jk) + zdzy(ji,jj,jk) ) 826 ELSE 827 zdz_j(ji,jj,jk) = 0._wp 828 ENDIF 811 cffu = MAX( 2._wp * zdrhox(ji-1,jj,jk) * zdrhox(ji,jj,jk), 0._wp ) 812 z1_cff = zdrhox(ji-1,jj,jk) + zdrhox(ji,jj,jk) 813 zdrho_i(ji,jj,jk) = cffu / SIGN( MAX( ABS(z1_cff), zep ), z1_cff ) 814 815 cffx = MAX( 2._wp * zdzx(ji-1,jj,jk) * zdzx(ji,jj,jk), 0._wp ) 816 z1_cff = zdzx(ji-1,jj,jk) + zdzx(ji,jj,jk) 817 zdz_i(ji,jj,jk) = cffx / SIGN( MAX( ABS(z1_cff), zep ), z1_cff ) 818 819 cffv = MAX( 2._wp * zdrhoy(ji,jj-1,jk) * zdrhoy(ji,jj,jk), 0._wp ) 820 z1_cff = zdrhoy(ji,jj-1,jk) + zdrhoy(ji,jj,jk) 821 zdrho_j(ji,jj,jk) = cffv / SIGN( MAX( ABS(z1_cff), zep ), z1_cff ) 822 823 cffy = MAX( 2._wp * zdzy(ji,jj-1,jk) * zdzy(ji,jj,jk), 0._wp ) 824 z1_cff = zdzy(ji,jj-1,jk) + zdzy(ji,jj,jk) 825 zdz_j(ji,jj,jk) = cffy / SIGN( MAX( ABS(z1_cff), zep ), z1_cff ) 829 826 END_3D 830 827 … … 840 837 zz_drho_j(:,:) = zdrho_j(:,:,jk) 841 838 zz_dz_j (:,:) = zdz_j (:,:,jk) 842 DO_2D( 0, 1, 0, 1) 843 ! Walls coming from left: should check from 2 to jpi-1 (and jpj=2-jpj) 844 IF (ji < jpi) THEN 845 IF ( umask(ji,jj,jk) > 0.5_wp .AND. umask(ji-1,jj,jk) < 0.5_wp .AND. umask(ji+1,jj,jk) > 0.5_wp) THEN 846 zz_drho_i(ji,jj) = aco_bc_hor * ( rhd (ji+1,jj,jk) - rhd (ji,jj,jk) ) - bco_bc_hor * zdrho_i(ji+1,jj,jk) 847 zz_dz_i (ji,jj) = aco_bc_hor * (-gde3w(ji+1,jj,jk) + gde3w(ji,jj,jk) ) - bco_bc_hor * zdz_i (ji+1,jj,jk) 848 END IF 839 ! Walls coming from left: should check from 2 to jpi-1 (and jpj=2-jpj) 840 DO_2D( 0, 0, 0, 1 ) 841 IF ( umask(ji,jj,jk) > 0.5_wp .AND. umask(ji-1,jj,jk) < 0.5_wp .AND. umask(ji+1,jj,jk) > 0.5_wp) THEN 842 zz_drho_i(ji,jj) = aco_bc_hor * ( rhd (ji+1,jj,jk) - rhd (ji,jj,jk) ) - bco_bc_hor * zdrho_i(ji+1,jj,jk) 843 zz_dz_i (ji,jj) = aco_bc_hor * (-gde3w(ji+1,jj,jk) + gde3w(ji,jj,jk) ) - bco_bc_hor * zdz_i (ji+1,jj,jk) 849 844 END IF 850 ! Walls coming from right: should check from 3 to jpi (and jpj=2-jpj)851 IF (ji > 2) THEN852 IF ( umask(ji,jj,jk) < 0.5_wp .AND. umask(ji-1,jj,jk) > 0.5_wp .AND. umask(ji-2,jj,jk) > 0.5_wp) THEN853 zz_drho_i(ji,jj) = aco_bc_hor * ( rhd (ji,jj,jk) - rhd (ji-1,jj,jk) ) - bco_bc_hor * zdrho_i(ji-1,jj,jk)854 zz_dz_i (ji,jj) = aco_bc_hor * (-gde3w(ji,jj,jk) + gde3w(ji-1,jj,jk) ) - bco_bc_hor * zdz_i(ji-1,jj,jk)855 END IF845 END_2D 846 ! Walls coming from right: should check from 3 to jpi (and jpj=2-jpj) 847 DO_2D( -1, 1, 0, 1 ) 848 IF ( umask(ji,jj,jk) < 0.5_wp .AND. umask(ji-1,jj,jk) > 0.5_wp .AND. umask(ji-2,jj,jk) > 0.5_wp) THEN 849 zz_drho_i(ji,jj) = aco_bc_hor * ( rhd (ji,jj,jk) - rhd (ji-1,jj,jk) ) - bco_bc_hor * zdrho_i(ji-1,jj,jk) 850 zz_dz_i (ji,jj) = aco_bc_hor * (-gde3w(ji,jj,jk) + gde3w(ji-1,jj,jk) ) - bco_bc_hor * zdz_i (ji-1,jj,jk) 856 851 END IF 857 ! Walls coming from left: should check from 2 to jpj-1 (and jpi=2-jpi)858 IF (jj < jpj) THEN859 IF ( vmask(ji,jj,jk) > 0.5_wp .AND. vmask(ji,jj-1,jk) < 0.5_wp .AND. vmask(ji,jj+1,jk) > 0.5_wp) THEN860 zz_drho_j(ji,jj) = aco_bc_hor * ( rhd (ji,jj+1,jk) - rhd (ji,jj,jk) ) - bco_bc_hor * zdrho_j(ji,jj+1,jk)861 zz_dz_j (ji,jj) = aco_bc_hor * (-gde3w(ji,jj+1,jk) + gde3w(ji,jj,jk) ) - bco_bc_hor * zdz_j(ji,jj+1,jk)862 END IF863 END IF 864 ! Walls coming from right: should check from 3 to jpj (and jpi=2-jpi)865 IF (jj > 2) THEN866 IF ( vmask(ji,jj,jk) < 0.5_wp .AND. vmask(ji,jj-1,jk) > 0.5_wp .AND. vmask(ji,jj-2,jk) > 0.5_wp) THEN867 zz_drho_j(ji,jj) = aco_bc_hor * ( rhd (ji,jj,jk) - rhd (ji,jj-1,jk) ) - bco_bc_hor * zdrho_j(ji,jj-1,jk)868 zz_dz_j (ji,jj) = aco_bc_hor * (-gde3w(ji,jj,jk) + gde3w(ji,jj-1,jk) ) - bco_bc_hor * zdz_j(ji,jj-1,jk)869 END IF852 END_2D 853 ! Walls coming from left: should check from 2 to jpj-1 (and jpi=2-jpi) 854 DO_2D( 0, 1, 0, 0 ) 855 IF ( vmask(ji,jj,jk) > 0.5_wp .AND. vmask(ji,jj-1,jk) < 0.5_wp .AND. vmask(ji,jj+1,jk) > 0.5_wp) THEN 856 zz_drho_j(ji,jj) = aco_bc_hor * ( rhd (ji,jj+1,jk) - rhd (ji,jj,jk) ) - bco_bc_hor * zdrho_j(ji,jj+1,jk) 857 zz_dz_j (ji,jj) = aco_bc_hor * (-gde3w(ji,jj+1,jk) + gde3w(ji,jj,jk) ) - bco_bc_hor * zdz_j (ji,jj+1,jk) 858 END IF 859 END_2D 860 ! Walls coming from right: should check from 3 to jpj (and jpi=2-jpi) 861 DO_2D( 0, 1, -1, 1 ) 862 IF ( vmask(ji,jj,jk) < 0.5_wp .AND. vmask(ji,jj-1,jk) > 0.5_wp .AND. vmask(ji,jj-2,jk) > 0.5_wp) THEN 863 zz_drho_j(ji,jj) = aco_bc_hor * ( rhd (ji,jj,jk) - rhd (ji,jj-1,jk) ) - bco_bc_hor * zdrho_j(ji,jj-1,jk) 864 zz_dz_j (ji,jj) = aco_bc_hor * (-gde3w(ji,jj,jk) + gde3w(ji,jj-1,jk) ) - bco_bc_hor * zdz_j (ji,jj-1,jk) 870 865 END IF 871 866 END_2D … … 974 969 REAL(wp) :: zrhdt1 975 970 REAL(wp) :: zdpdx1, zdpdx2, zdpdy1, zdpdy2 976 REAL(wp), DIMENSION( jpi,jpj) :: zpgu, zpgv ! 2D workspace977 REAL(wp), DIMENSION( jpi,jpj) :: zsshu_n, zsshv_n978 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zdept, zrhh979 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp971 REAL(wp), DIMENSION(A2D(nn_hls)) :: zpgu, zpgv ! 2D workspace 972 REAL(wp), DIMENSION(A2D(nn_hls)) :: zsshu_n, zsshv_n 973 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zdept, zrhh 974 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zhpi, zu, zv, fsp, xsp, asp, bsp, csp, dsp 980 975 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zcpx, zcpy !W/D pressure filter 981 976 !!---------------------------------------------------------------------- 982 977 ! 983 IF( kt == nit000 ) THEN 984 IF(lwp) WRITE(numout,*) 985 IF(lwp) WRITE(numout,*) 'dyn:hpg_prj : hydrostatic pressure gradient trend' 986 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, cubic spline pressure Jacobian' 978 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 979 IF( kt == nit000 ) THEN 980 IF(lwp) WRITE(numout,*) 981 IF(lwp) WRITE(numout,*) 'dyn:hpg_prj : hydrostatic pressure gradient trend' 982 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate case, cubic spline pressure Jacobian' 983 ENDIF 987 984 ENDIF 988 985 … … 1001 998 ! 1002 999 IF( ln_wd_il ) THEN 1003 ALLOCATE( zcpx( jpi,jpj) , zcpy(jpi,jpj) )1000 ALLOCATE( zcpx(A2D(nn_hls)) , zcpy(A2D(nn_hls)) ) 1004 1001 DO_2D( 0, 0, 0, 0 ) 1005 ll_tmp1 = MIN( ssh(ji,jj,Kmm) , ssh(ji+1,jj,Kmm) ) > & 1006 & MAX( -ht_0(ji,jj) , -ht_0(ji+1,jj) ) .AND. & 1007 & MAX( ssh(ji,jj,Kmm) + ht_0(ji,jj), ssh(ji+1,jj,Kmm) + ht_0(ji+1,jj) ) & 1008 & > rn_wdmin1 + rn_wdmin2 1009 ll_tmp2 = ( ABS( ssh(ji,jj,Kmm) - ssh(ji+1,jj,Kmm) ) > 1.E-12 ) .AND. ( & 1010 & MAX( ssh(ji,jj,Kmm) , ssh(ji+1,jj,Kmm) ) > & 1011 & MAX( -ht_0(ji,jj) , -ht_0(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2 ) 1012 1013 IF(ll_tmp1) THEN 1014 zcpx(ji,jj) = 1.0_wp 1015 ELSE IF(ll_tmp2) THEN 1016 ! no worries about ssh(ji+1,jj,Kmm) - ssh(ji ,jj,Kmm) = 0, it won't happen ! here 1017 zcpx(ji,jj) = ABS( (ssh(ji+1,jj,Kmm) + ht_0(ji+1,jj) - ssh(ji,jj,Kmm) - ht_0(ji,jj)) & 1018 & / (ssh(ji+1,jj,Kmm) - ssh(ji ,jj,Kmm)) ) 1019 1020 zcpx(ji,jj) = max(min( zcpx(ji,jj) , 1.0_wp),0.0_wp) 1021 ELSE 1022 zcpx(ji,jj) = 0._wp 1023 END IF 1024 1025 ll_tmp1 = MIN( ssh(ji,jj,Kmm) , ssh(ji,jj+1,Kmm) ) > & 1026 & MAX( -ht_0(ji,jj) , -ht_0(ji,jj+1) ) .AND. & 1027 & MAX( ssh(ji,jj,Kmm) + ht_0(ji,jj), ssh(ji,jj+1,Kmm) + ht_0(ji,jj+1) ) & 1028 & > rn_wdmin1 + rn_wdmin2 1029 ll_tmp2 = ( ABS( ssh(ji,jj,Kmm) - ssh(ji,jj+1,Kmm) ) > 1.E-12 ) .AND. ( & 1030 & MAX( ssh(ji,jj,Kmm) , ssh(ji,jj+1,Kmm) ) > & 1031 & MAX( -ht_0(ji,jj) , -ht_0(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2 ) 1032 1033 IF(ll_tmp1) THEN 1034 zcpy(ji,jj) = 1.0_wp 1035 ELSE IF(ll_tmp2) THEN 1036 ! no worries about ssh(ji,jj+1,Kmm) - ssh(ji,jj ,Kmm) = 0, it won't happen ! here 1037 zcpy(ji,jj) = ABS( (ssh(ji,jj+1,Kmm) + ht_0(ji,jj+1) - ssh(ji,jj,Kmm) - ht_0(ji,jj)) & 1038 & / (ssh(ji,jj+1,Kmm) - ssh(ji,jj ,Kmm)) ) 1039 zcpy(ji,jj) = max(min( zcpy(ji,jj) , 1.0_wp),0.0_wp) 1040 1002 ll_tmp1 = MIN( ssh(ji,jj,Kmm) , ssh(ji+1,jj,Kmm) ) > & 1003 & MAX( -ht_0(ji,jj) , -ht_0(ji+1,jj) ) .AND. & 1004 & MAX( ssh(ji,jj,Kmm) + ht_0(ji,jj), ssh(ji+1,jj,Kmm) + ht_0(ji+1,jj) ) > & 1005 & rn_wdmin1 + rn_wdmin2 1006 ll_tmp2 = ( ABS( ssh(ji,jj,Kmm) - ssh(ji+1,jj,Kmm) ) > 1.E-12 ) .AND. & 1007 & ( MAX( ssh(ji,jj,Kmm) , ssh(ji+1,jj,Kmm) ) > & 1008 & MAX( -ht_0(ji,jj) , -ht_0(ji+1,jj) ) + rn_wdmin1 + rn_wdmin2 ) 1009 1010 IF(ll_tmp1) THEN 1011 zcpx(ji,jj) = 1.0_wp 1012 ELSE IF(ll_tmp2) THEN 1013 ! no worries about ssh(ji+1,jj,Kmm) - ssh(ji ,jj,Kmm) = 0, it won't happen ! here 1014 zcpx(ji,jj) = ABS( (ssh(ji+1,jj,Kmm) + ht_0(ji+1,jj) - ssh(ji,jj,Kmm) - ht_0(ji,jj)) & 1015 & / (ssh(ji+1,jj,Kmm) - ssh(ji ,jj,Kmm)) ) 1016 zcpx(ji,jj) = MAX(MIN( zcpx(ji,jj) , 1.0_wp),0.0_wp) 1017 ELSE 1018 zcpx(ji,jj) = 0._wp 1019 END IF 1020 1021 ll_tmp1 = MIN( ssh(ji,jj,Kmm) , ssh(ji,jj+1,Kmm) ) > & 1022 & MAX( -ht_0(ji,jj) , -ht_0(ji,jj+1) ) .AND. & 1023 & MAX( ssh(ji,jj,Kmm) + ht_0(ji,jj), ssh(ji,jj+1,Kmm) + ht_0(ji,jj+1) ) > & 1024 & rn_wdmin1 + rn_wdmin2 1025 ll_tmp2 = ( ABS( ssh(ji,jj,Kmm) - ssh(ji,jj+1,Kmm) ) > 1.E-12 ) .AND. & 1026 & ( MAX( ssh(ji,jj,Kmm) , ssh(ji,jj+1,Kmm) ) > & 1027 & MAX( -ht_0(ji,jj) , -ht_0(ji,jj+1) ) + rn_wdmin1 + rn_wdmin2 ) 1028 1029 IF(ll_tmp1) THEN 1030 zcpy(ji,jj) = 1.0_wp 1031 ELSE IF(ll_tmp2) THEN 1032 ! no worries about ssh(ji,jj+1,Kmm) - ssh(ji,jj ,Kmm) = 0, it won't happen ! here 1033 zcpy(ji,jj) = ABS( (ssh(ji,jj+1,Kmm) + ht_0(ji,jj+1) - ssh(ji,jj,Kmm) - ht_0(ji,jj)) & 1034 & / (ssh(ji,jj+1,Kmm) - ssh(ji,jj ,Kmm)) ) 1035 zcpy(ji,jj) = MAX(MIN( zcpy(ji,jj) , 1.0_wp),0.0_wp) 1041 1036 ELSE 1042 1037 zcpy(ji,jj) = 0._wp 1043 1038 ENDIF 1044 1039 END_2D 1045 CALL lbc_lnk( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )1046 1040 ENDIF 1047 1041 1048 1042 ! Clean 3-D work arrays 1049 1043 zhpi(:,:,:) = 0._wp 1050 zrhh(:,:,:) = rhd( :,:,:)1044 zrhh(:,:,:) = rhd(A2D(nn_hls),:) 1051 1045 1052 1046 ! Preparing vertical density profile "zrhh(:,:,:)" for hybrid-sco coordinate 1053 1047 DO_2D( 1, 1, 1, 1 ) 1054 jk = mbkt(ji,jj)1055 IF( jk <= 1 ) THEN ; zrhh(ji,jj, : ) = 0._wp1056 ELSEIF( jk == 2 ) THEN ; zrhh(ji,jj,jk+1:jpk) = rhd(ji,jj,jk)1057 ELSEIF( jk < jpkm1 ) THEN1058 DO jkk = jk+1, jpk1059 zrhh(ji,jj,jkk) = interp1(gde3w(ji,jj,jkk ), gde3w(ji,jj,jkk-1), &1060 & gde3w(ji,jj,jkk-2), zrhh (ji,jj,jkk-1), zrhh(ji,jj,jkk-2))1061 END DO1062 ENDIF1048 jk = mbkt(ji,jj) 1049 IF( jk <= 1 ) THEN ; zrhh(ji,jj, : ) = 0._wp 1050 ELSEIF( jk == 2 ) THEN ; zrhh(ji,jj,jk+1:jpk) = rhd(ji,jj,jk) 1051 ELSEIF( jk < jpkm1 ) THEN 1052 DO jkk = jk+1, jpk 1053 zrhh(ji,jj,jkk) = interp1(gde3w(ji,jj,jkk ), gde3w(ji,jj,jkk-1), & 1054 & gde3w(ji,jj,jkk-2), zrhh (ji,jj,jkk-1), zrhh(ji,jj,jkk-2)) 1055 END DO 1056 ENDIF 1063 1057 END_2D 1064 1058 … … 1082 1076 ! Integrate the hydrostatic pressure "zhpi(:,:,:)" at "T(ji,jj,1)" 1083 1077 DO_2D( 0, 1, 0, 1 ) 1084 zrhdt1 = zrhh(ji,jj,1) - interp3( zdept(ji,jj,1), asp(ji,jj,1), bsp(ji,jj,1), &1085 & csp(ji,jj,1), dsp(ji,jj,1) ) * 0.25_wp * e3w(ji,jj,1,Kmm)1086 1087 ! assuming linear profile across the top half surface layer1088 zhpi(ji,jj,1) = 0.5_wp * e3w(ji,jj,1,Kmm) * zrhdt11078 zrhdt1 = zrhh(ji,jj,1) - interp3( zdept(ji,jj,1), asp(ji,jj,1), bsp(ji,jj,1), & 1079 & csp(ji,jj,1), dsp(ji,jj,1) ) * 0.25_wp * e3w(ji,jj,1,Kmm) 1080 1081 ! assuming linear profile across the top half surface layer 1082 zhpi(ji,jj,1) = 0.5_wp * e3w(ji,jj,1,Kmm) * zrhdt1 1089 1083 END_2D 1090 1084 1091 1085 ! Calculate the pressure "zhpi(:,:,:)" at "T(ji,jj,2:jpkm1)" 1092 1086 DO_3D( 0, 1, 0, 1, 2, jpkm1 ) 1093 zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + &1094 & integ_spline( zdept(ji,jj,jk-1), zdept(ji,jj,jk), &1095 & asp (ji,jj,jk-1), bsp (ji,jj,jk-1), &1096 & csp (ji,jj,jk-1), dsp (ji,jj,jk-1) )1087 zhpi(ji,jj,jk) = zhpi(ji,jj,jk-1) + & 1088 & integ_spline( zdept(ji,jj,jk-1), zdept(ji,jj,jk), & 1089 & asp (ji,jj,jk-1), bsp (ji,jj,jk-1), & 1090 & csp (ji,jj,jk-1), dsp (ji,jj,jk-1) ) 1097 1091 END_3D 1098 1092 … … 1107 1101 ! & r1_e1e2v(ji,jj) * vmask(ji,jj,1) * 0.5_wp 1108 1102 !!gm not this: 1109 zsshu_n(ji,jj) = (e1e2u(ji,jj) * ssh(ji,jj,Kmm) + e1e2u(ji+1, jj) * ssh(ji+1,jj,Kmm)) * & 1110 & r1_e1e2u(ji,jj) * umask(ji,jj,1) * 0.5_wp 1111 zsshv_n(ji,jj) = (e1e2v(ji,jj) * ssh(ji,jj,Kmm) + e1e2v(ji+1, jj) * ssh(ji,jj+1,Kmm)) * & 1112 & r1_e1e2v(ji,jj) * vmask(ji,jj,1) * 0.5_wp 1113 END_2D 1114 1115 CALL lbc_lnk ('dynhpg', zsshu_n, 'U', 1.0_wp, zsshv_n, 'V', 1.0_wp ) 1103 zsshu_n(ji,jj) = (e1e2u(ji,jj) * ssh(ji,jj,Kmm) + e1e2u(ji+1, jj) * ssh(ji+1,jj,Kmm)) * & 1104 & r1_e1e2u(ji,jj) * umask(ji,jj,1) * 0.5_wp 1105 zsshv_n(ji,jj) = (e1e2v(ji,jj) * ssh(ji,jj,Kmm) + e1e2v(ji+1, jj) * ssh(ji,jj+1,Kmm)) * & 1106 & r1_e1e2v(ji,jj) * vmask(ji,jj,1) * 0.5_wp 1107 END_2D 1116 1108 1117 1109 DO_2D( 0, 0, 0, 0 ) 1118 zu(ji,jj,1) = - ( e3u(ji,jj,1,Kmm) - zsshu_n(ji,jj) )1119 zv(ji,jj,1) = - ( e3v(ji,jj,1,Kmm) - zsshv_n(ji,jj) )1110 zu(ji,jj,1) = - ( e3u(ji,jj,1,Kmm) - zsshu_n(ji,jj) ) 1111 zv(ji,jj,1) = - ( e3v(ji,jj,1,Kmm) - zsshv_n(ji,jj) ) 1120 1112 END_2D 1121 1113 1122 1114 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 1123 zu(ji,jj,jk) = zu(ji,jj,jk-1) - e3u(ji,jj,jk,Kmm)1124 zv(ji,jj,jk) = zv(ji,jj,jk-1) - e3v(ji,jj,jk,Kmm)1115 zu(ji,jj,jk) = zu(ji,jj,jk-1) - e3u(ji,jj,jk,Kmm) 1116 zv(ji,jj,jk) = zv(ji,jj,jk-1) - e3v(ji,jj,jk,Kmm) 1125 1117 END_3D 1126 1118 1127 1119 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 1128 zu(ji,jj,jk) = zu(ji,jj,jk) + 0.5_wp * e3u(ji,jj,jk,Kmm)1129 zv(ji,jj,jk) = zv(ji,jj,jk) + 0.5_wp * e3v(ji,jj,jk,Kmm)1120 zu(ji,jj,jk) = zu(ji,jj,jk) + 0.5_wp * e3u(ji,jj,jk,Kmm) 1121 zv(ji,jj,jk) = zv(ji,jj,jk) + 0.5_wp * e3v(ji,jj,jk,Kmm) 1130 1122 END_3D 1131 1123 1132 1124 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 1133 zu(ji,jj,jk) = MIN( zu(ji,jj,jk) , MAX( -zdept(ji,jj,jk) , -zdept(ji+1,jj,jk) ) )1134 zu(ji,jj,jk) = MAX( zu(ji,jj,jk) , MIN( -zdept(ji,jj,jk) , -zdept(ji+1,jj,jk) ) )1135 zv(ji,jj,jk) = MIN( zv(ji,jj,jk) , MAX( -zdept(ji,jj,jk) , -zdept(ji,jj+1,jk) ) )1136 zv(ji,jj,jk) = MAX( zv(ji,jj,jk) , MIN( -zdept(ji,jj,jk) , -zdept(ji,jj+1,jk) ) )1125 zu(ji,jj,jk) = MIN( zu(ji,jj,jk) , MAX( -zdept(ji,jj,jk) , -zdept(ji+1,jj,jk) ) ) 1126 zu(ji,jj,jk) = MAX( zu(ji,jj,jk) , MIN( -zdept(ji,jj,jk) , -zdept(ji+1,jj,jk) ) ) 1127 zv(ji,jj,jk) = MIN( zv(ji,jj,jk) , MAX( -zdept(ji,jj,jk) , -zdept(ji,jj+1,jk) ) ) 1128 zv(ji,jj,jk) = MAX( zv(ji,jj,jk) , MIN( -zdept(ji,jj,jk) , -zdept(ji,jj+1,jk) ) ) 1137 1129 END_3D 1138 1130 1139 1131 1140 1132 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 1141 zpwes = 0._wp; zpwed = 0._wp 1142 zpnss = 0._wp; zpnsd = 0._wp 1143 zuijk = zu(ji,jj,jk) 1144 zvijk = zv(ji,jj,jk) 1145 1146 !!!!! for u equation 1147 IF( jk <= mbku(ji,jj) ) THEN 1148 IF( -zdept(ji+1,jj,jk) >= -zdept(ji,jj,jk) ) THEN 1149 jis = ji + 1; jid = ji 1150 ELSE 1151 jis = ji; jid = ji +1 1133 zpwes = 0._wp; zpwed = 0._wp 1134 zpnss = 0._wp; zpnsd = 0._wp 1135 zuijk = zu(ji,jj,jk) 1136 zvijk = zv(ji,jj,jk) 1137 1138 !!!!! for u equation 1139 IF( jk <= mbku(ji,jj) ) THEN 1140 IF( -zdept(ji+1,jj,jk) >= -zdept(ji,jj,jk) ) THEN 1141 jis = ji + 1; jid = ji 1142 ELSE 1143 jis = ji; jid = ji +1 1144 ENDIF 1145 1146 ! integrate the pressure on the shallow side 1147 jk1 = jk 1148 DO WHILE ( -zdept(jis,jj,jk1) > zuijk ) 1149 IF( jk1 == mbku(ji,jj) ) THEN 1150 zuijk = -zdept(jis,jj,jk1) 1151 EXIT 1152 ENDIF 1153 zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk) 1154 zpwes = zpwes + & 1155 integ_spline(zdept(jis,jj,jk1), zdeps, & 1156 asp(jis,jj,jk1), bsp(jis,jj,jk1), & 1157 csp(jis,jj,jk1), dsp(jis,jj,jk1)) 1158 jk1 = jk1 + 1 1159 END DO 1160 1161 ! integrate the pressure on the deep side 1162 jk1 = jk 1163 DO WHILE ( -zdept(jid,jj,jk1) < zuijk ) 1164 IF( jk1 == 1 ) THEN 1165 zdeps = zdept(jid,jj,1) + MIN(zuijk, ssh(jid,jj,Kmm)*znad) 1166 zrhdt1 = zrhh(jid,jj,1) - interp3(zdept(jid,jj,1), asp(jid,jj,1), & 1167 bsp(jid,jj,1) , csp(jid,jj,1), & 1168 dsp(jid,jj,1)) * zdeps 1169 zpwed = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps 1170 EXIT 1171 ENDIF 1172 zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk) 1173 zpwed = zpwed + & 1174 integ_spline(zdeps, zdept(jid,jj,jk1), & 1175 asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1), & 1176 csp(jid,jj,jk1-1), dsp(jid,jj,jk1-1) ) 1177 jk1 = jk1 - 1 1178 END DO 1179 1180 ! update the momentum trends in u direction 1181 zdpdx1 = zcoef0 * r1_e1u(ji,jj) * ( zhpi(ji+1,jj,jk) - zhpi(ji,jj,jk) ) 1182 IF( .NOT.ln_linssh ) THEN 1183 zdpdx2 = zcoef0 * r1_e1u(ji,jj) * & 1184 & ( REAL(jis-jid, wp) * (zpwes + zpwed) + (ssh(ji+1,jj,Kmm)-ssh(ji,jj,Kmm)) ) 1185 ELSE 1186 zdpdx2 = zcoef0 * r1_e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed) 1187 ENDIF 1188 IF( ln_wd_il ) THEN 1189 zdpdx1 = zdpdx1 * zcpx(ji,jj) * wdrampu(ji,jj) 1190 zdpdx2 = zdpdx2 * zcpx(ji,jj) * wdrampu(ji,jj) 1191 ENDIF 1192 puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + (zdpdx1 + zdpdx2 - zpgu(ji,jj)) * umask(ji,jj,jk) 1152 1193 ENDIF 1153 1194 1154 ! integrate the pressure on the shallow side 1155 jk1 = jk 1156 DO WHILE ( -zdept(jis,jj,jk1) > zuijk ) 1157 IF( jk1 == mbku(ji,jj) ) THEN 1158 zuijk = -zdept(jis,jj,jk1) 1159 EXIT 1160 ENDIF 1161 zdeps = MIN(zdept(jis,jj,jk1+1), -zuijk) 1162 zpwes = zpwes + & 1163 integ_spline(zdept(jis,jj,jk1), zdeps, & 1164 asp(jis,jj,jk1), bsp(jis,jj,jk1), & 1165 csp(jis,jj,jk1), dsp(jis,jj,jk1)) 1166 jk1 = jk1 + 1 1167 END DO 1168 1169 ! integrate the pressure on the deep side 1170 jk1 = jk 1171 DO WHILE ( -zdept(jid,jj,jk1) < zuijk ) 1172 IF( jk1 == 1 ) THEN 1173 zdeps = zdept(jid,jj,1) + MIN(zuijk, ssh(jid,jj,Kmm)*znad) 1174 zrhdt1 = zrhh(jid,jj,1) - interp3(zdept(jid,jj,1), asp(jid,jj,1), & 1175 bsp(jid,jj,1), csp(jid,jj,1), & 1176 dsp(jid,jj,1)) * zdeps 1177 zpwed = zpwed + 0.5_wp * (zrhh(jid,jj,1) + zrhdt1) * zdeps 1178 EXIT 1179 ENDIF 1180 zdeps = MAX(zdept(jid,jj,jk1-1), -zuijk) 1181 zpwed = zpwed + & 1182 integ_spline(zdeps, zdept(jid,jj,jk1), & 1183 asp(jid,jj,jk1-1), bsp(jid,jj,jk1-1), & 1184 csp(jid,jj,jk1-1), dsp(jid,jj,jk1-1) ) 1185 jk1 = jk1 - 1 1186 END DO 1187 1188 ! update the momentum trends in u direction 1189 1190 zdpdx1 = zcoef0 * r1_e1u(ji,jj) * ( zhpi(ji+1,jj,jk) - zhpi(ji,jj,jk) ) 1191 IF( .NOT.ln_linssh ) THEN 1192 zdpdx2 = zcoef0 * r1_e1u(ji,jj) * & 1193 & ( REAL(jis-jid, wp) * (zpwes + zpwed) + (ssh(ji+1,jj,Kmm)-ssh(ji,jj,Kmm)) ) 1194 ELSE 1195 zdpdx2 = zcoef0 * r1_e1u(ji,jj) * REAL(jis-jid, wp) * (zpwes + zpwed) 1195 !!!!! for v equation 1196 IF( jk <= mbkv(ji,jj) ) THEN 1197 IF( -zdept(ji,jj+1,jk) >= -zdept(ji,jj,jk) ) THEN 1198 jjs = jj + 1; jjd = jj 1199 ELSE 1200 jjs = jj ; jjd = jj + 1 1201 ENDIF 1202 1203 ! integrate the pressure on the shallow side 1204 jk1 = jk 1205 DO WHILE ( -zdept(ji,jjs,jk1) > zvijk ) 1206 IF( jk1 == mbkv(ji,jj) ) THEN 1207 zvijk = -zdept(ji,jjs,jk1) 1208 EXIT 1209 ENDIF 1210 zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk) 1211 zpnss = zpnss + & 1212 integ_spline(zdept(ji,jjs,jk1), zdeps, & 1213 asp(ji,jjs,jk1), bsp(ji,jjs,jk1), & 1214 csp(ji,jjs,jk1), dsp(ji,jjs,jk1) ) 1215 jk1 = jk1 + 1 1216 END DO 1217 1218 ! integrate the pressure on the deep side 1219 jk1 = jk 1220 DO WHILE ( -zdept(ji,jjd,jk1) < zvijk ) 1221 IF( jk1 == 1 ) THEN 1222 zdeps = zdept(ji,jjd,1) + MIN(zvijk, ssh(ji,jjd,Kmm)*znad) 1223 zrhdt1 = zrhh(ji,jjd,1) - interp3(zdept(ji,jjd,1), asp(ji,jjd,1), & 1224 bsp(ji,jjd,1) , csp(ji,jjd,1), & 1225 dsp(ji,jjd,1) ) * zdeps 1226 zpnsd = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps 1227 EXIT 1228 ENDIF 1229 zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk) 1230 zpnsd = zpnsd + & 1231 integ_spline(zdeps, zdept(ji,jjd,jk1), & 1232 asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), & 1233 csp(ji,jjd,jk1-1), dsp(ji,jjd,jk1-1) ) 1234 jk1 = jk1 - 1 1235 END DO 1236 1237 ! update the momentum trends in v direction 1238 zdpdy1 = zcoef0 * r1_e2v(ji,jj) * ( zhpi(ji,jj+1,jk) - zhpi(ji,jj,jk) ) 1239 IF( .NOT.ln_linssh ) THEN 1240 zdpdy2 = zcoef0 * r1_e2v(ji,jj) * & 1241 ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (ssh(ji,jj+1,Kmm)-ssh(ji,jj,Kmm)) ) 1242 ELSE 1243 zdpdy2 = zcoef0 * r1_e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd ) 1244 ENDIF 1245 IF( ln_wd_il ) THEN 1246 zdpdy1 = zdpdy1 * zcpy(ji,jj) * wdrampv(ji,jj) 1247 zdpdy2 = zdpdy2 * zcpy(ji,jj) * wdrampv(ji,jj) 1248 ENDIF 1249 1250 pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) + (zdpdy1 + zdpdy2 - zpgv(ji,jj)) * vmask(ji,jj,jk) 1196 1251 ENDIF 1197 IF( ln_wd_il ) THEN1198 zdpdx1 = zdpdx1 * zcpx(ji,jj) * wdrampu(ji,jj)1199 zdpdx2 = zdpdx2 * zcpx(ji,jj) * wdrampu(ji,jj)1200 ENDIF1201 puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + (zdpdx1 + zdpdx2 - zpgu(ji,jj)) * umask(ji,jj,jk)1202 ENDIF1203 1204 !!!!! for v equation1205 IF( jk <= mbkv(ji,jj) ) THEN1206 IF( -zdept(ji,jj+1,jk) >= -zdept(ji,jj,jk) ) THEN1207 jjs = jj + 1; jjd = jj1208 ELSE1209 jjs = jj ; jjd = jj + 11210 ENDIF1211 1212 ! integrate the pressure on the shallow side1213 jk1 = jk1214 DO WHILE ( -zdept(ji,jjs,jk1) > zvijk )1215 IF( jk1 == mbkv(ji,jj) ) THEN1216 zvijk = -zdept(ji,jjs,jk1)1217 EXIT1218 ENDIF1219 zdeps = MIN(zdept(ji,jjs,jk1+1), -zvijk)1220 zpnss = zpnss + &1221 integ_spline(zdept(ji,jjs,jk1), zdeps, &1222 asp(ji,jjs,jk1), bsp(ji,jjs,jk1), &1223 csp(ji,jjs,jk1), dsp(ji,jjs,jk1) )1224 jk1 = jk1 + 11225 END DO1226 1227 ! integrate the pressure on the deep side1228 jk1 = jk1229 DO WHILE ( -zdept(ji,jjd,jk1) < zvijk )1230 IF( jk1 == 1 ) THEN1231 zdeps = zdept(ji,jjd,1) + MIN(zvijk, ssh(ji,jjd,Kmm)*znad)1232 zrhdt1 = zrhh(ji,jjd,1) - interp3(zdept(ji,jjd,1), asp(ji,jjd,1), &1233 bsp(ji,jjd,1), csp(ji,jjd,1), &1234 dsp(ji,jjd,1) ) * zdeps1235 zpnsd = zpnsd + 0.5_wp * (zrhh(ji,jjd,1) + zrhdt1) * zdeps1236 EXIT1237 ENDIF1238 zdeps = MAX(zdept(ji,jjd,jk1-1), -zvijk)1239 zpnsd = zpnsd + &1240 integ_spline(zdeps, zdept(ji,jjd,jk1), &1241 asp(ji,jjd,jk1-1), bsp(ji,jjd,jk1-1), &1242 csp(ji,jjd,jk1-1), dsp(ji,jjd,jk1-1) )1243 jk1 = jk1 - 11244 END DO1245 1246 1247 ! update the momentum trends in v direction1248 1249 zdpdy1 = zcoef0 * r1_e2v(ji,jj) * ( zhpi(ji,jj+1,jk) - zhpi(ji,jj,jk) )1250 IF( .NOT.ln_linssh ) THEN1251 zdpdy2 = zcoef0 * r1_e2v(ji,jj) * &1252 ( REAL(jjs-jjd, wp) * (zpnss + zpnsd) + (ssh(ji,jj+1,Kmm)-ssh(ji,jj,Kmm)) )1253 ELSE1254 zdpdy2 = zcoef0 * r1_e2v(ji,jj) * REAL(jjs-jjd, wp) * (zpnss + zpnsd )1255 ENDIF1256 IF( ln_wd_il ) THEN1257 zdpdy1 = zdpdy1 * zcpy(ji,jj) * wdrampv(ji,jj)1258 zdpdy2 = zdpdy2 * zcpy(ji,jj) * wdrampv(ji,jj)1259 ENDIF1260 1261 pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) + (zdpdy1 + zdpdy2 - zpgv(ji,jj)) * vmask(ji,jj,jk)1262 ENDIF1263 1252 ! 1264 1253 END_3D … … 1279 1268 !! Reference: CJC Kruger, Constrained Cubic Spline Interpoltation 1280 1269 !!---------------------------------------------------------------------- 1281 REAL(wp), DIMENSION( :,:,:), INTENT(in ) :: fsp, xsp ! value and coordinate1282 REAL(wp), DIMENSION( :,:,:), INTENT( out) :: asp, bsp, csp, dsp ! coefficients of the interpoated function1283 INTEGER , INTENT(in ) :: polynomial_type ! 1: cubic spline ; 2: Linear1270 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: fsp, xsp ! value and coordinate 1271 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT( out) :: asp, bsp, csp, dsp ! coefficients of the interpoated function 1272 INTEGER , INTENT(in ) :: polynomial_type ! 1: cubic spline ; 2: Linear 1284 1273 ! 1285 1274 INTEGER :: ji, jj, jk ! dummy loop indices 1286 INTEGER :: jpi, jpj, jpkm11287 1275 REAL(wp) :: zdf1, zdf2, zddf1, zddf2, ztmp1, ztmp2, zdxtmp 1288 1276 REAL(wp) :: zdxtmp1, zdxtmp2, zalpha 1289 REAL(wp) :: zdf(size(fsp,3)) 1290 !!---------------------------------------------------------------------- 1291 ! 1292 !!gm WHAT !!!!! THIS IS VERY DANGEROUS !!!!! 1293 jpi = size(fsp,1) 1294 jpj = size(fsp,2) 1295 jpkm1 = MAX( 1, size(fsp,3) - 1 ) 1277 REAL(wp) :: zdf(jpk) 1278 !!---------------------------------------------------------------------- 1296 1279 ! 1297 1280 IF (polynomial_type == 1) THEN ! Constrained Cubic Spline 1298 DO ji = 1, jpi 1299 DO jj = 1, jpj 1300 !!Fritsch&Butland's method, 1984 (preferred, but more computation) 1301 ! DO jk = 2, jpkm1-1 1302 ! zdxtmp1 = xsp(ji,jj,jk) - xsp(ji,jj,jk-1) 1303 ! zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 1304 ! zdf1 = ( fsp(ji,jj,jk) - fsp(ji,jj,jk-1) ) / zdxtmp1 1305 ! zdf2 = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp2 1306 ! 1307 ! zalpha = ( zdxtmp1 + 2._wp * zdxtmp2 ) / ( zdxtmp1 + zdxtmp2 ) / 3._wp 1308 ! 1309 ! IF(zdf1 * zdf2 <= 0._wp) THEN 1310 ! zdf(jk) = 0._wp 1311 ! ELSE 1312 ! zdf(jk) = zdf1 * zdf2 / ( ( 1._wp - zalpha ) * zdf1 + zalpha * zdf2 ) 1313 ! ENDIF 1314 ! END DO 1315 1316 !!Simply geometric average 1317 DO jk = 2, jpkm1-1 1318 zdf1 = (fsp(ji,jj,jk ) - fsp(ji,jj,jk-1)) / (xsp(ji,jj,jk ) - xsp(ji,jj,jk-1)) 1319 zdf2 = (fsp(ji,jj,jk+1) - fsp(ji,jj,jk )) / (xsp(ji,jj,jk+1) - xsp(ji,jj,jk )) 1320 1321 IF(zdf1 * zdf2 <= 0._wp) THEN 1322 zdf(jk) = 0._wp 1323 ELSE 1324 zdf(jk) = 2._wp * zdf1 * zdf2 / (zdf1 + zdf2) 1325 ENDIF 1326 END DO 1327 1328 zdf(1) = 1.5_wp * ( fsp(ji,jj,2) - fsp(ji,jj,1) ) / & 1329 & ( xsp(ji,jj,2) - xsp(ji,jj,1) ) - 0.5_wp * zdf(2) 1330 zdf(jpkm1) = 1.5_wp * ( fsp(ji,jj,jpkm1) - fsp(ji,jj,jpkm1-1) ) / & 1331 & ( xsp(ji,jj,jpkm1) - xsp(ji,jj,jpkm1-1) ) - 0.5_wp * zdf(jpkm1 - 1) 1332 1333 DO jk = 1, jpkm1 - 1 1334 zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 1335 ztmp1 = (zdf(jk+1) + 2._wp * zdf(jk)) / zdxtmp 1336 ztmp2 = 6._wp * (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / zdxtmp / zdxtmp 1337 zddf1 = -2._wp * ztmp1 + ztmp2 1338 ztmp1 = (2._wp * zdf(jk+1) + zdf(jk)) / zdxtmp 1339 zddf2 = 2._wp * ztmp1 - ztmp2 1340 1341 dsp(ji,jj,jk) = (zddf2 - zddf1) / 6._wp / zdxtmp 1342 csp(ji,jj,jk) = ( xsp(ji,jj,jk+1) * zddf1 - xsp(ji,jj,jk)*zddf2 ) / 2._wp / zdxtmp 1343 bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - & 1344 & csp(ji,jj,jk) * ( xsp(ji,jj,jk+1) + xsp(ji,jj,jk) ) - & 1345 & dsp(ji,jj,jk) * ((xsp(ji,jj,jk+1) + xsp(ji,jj,jk))**2 - & 1346 & xsp(ji,jj,jk+1) * xsp(ji,jj,jk)) 1347 asp(ji,jj,jk) = fsp(ji,jj,jk) - xsp(ji,jj,jk) * (bsp(ji,jj,jk) + & 1348 & (xsp(ji,jj,jk) * (csp(ji,jj,jk) + & 1349 & dsp(ji,jj,jk) * xsp(ji,jj,jk)))) 1350 END DO 1281 DO_2D( 1, 1, 1, 1 ) 1282 !!Fritsch&Butland's method, 1984 (preferred, but more computation) 1283 ! DO jk = 2, jpkm1-1 1284 ! zdxtmp1 = xsp(ji,jj,jk) - xsp(ji,jj,jk-1) 1285 ! zdxtmp2 = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 1286 ! zdf1 = ( fsp(ji,jj,jk) - fsp(ji,jj,jk-1) ) / zdxtmp1 1287 ! zdf2 = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp2 1288 ! 1289 ! zalpha = ( zdxtmp1 + 2._wp * zdxtmp2 ) / ( zdxtmp1 + zdxtmp2 ) / 3._wp 1290 ! 1291 ! IF(zdf1 * zdf2 <= 0._wp) THEN 1292 ! zdf(jk) = 0._wp 1293 ! ELSE 1294 ! zdf(jk) = zdf1 * zdf2 / ( ( 1._wp - zalpha ) * zdf1 + zalpha * zdf2 ) 1295 ! ENDIF 1296 ! END DO 1297 1298 !!Simply geometric average 1299 DO jk = 2, jpk-2 1300 zdf1 = (fsp(ji,jj,jk ) - fsp(ji,jj,jk-1)) / (xsp(ji,jj,jk ) - xsp(ji,jj,jk-1)) 1301 zdf2 = (fsp(ji,jj,jk+1) - fsp(ji,jj,jk )) / (xsp(ji,jj,jk+1) - xsp(ji,jj,jk )) 1302 1303 IF(zdf1 * zdf2 <= 0._wp) THEN 1304 zdf(jk) = 0._wp 1305 ELSE 1306 zdf(jk) = 2._wp * zdf1 * zdf2 / (zdf1 + zdf2) 1307 ENDIF 1351 1308 END DO 1352 END DO 1309 1310 zdf(1) = 1.5_wp * ( fsp(ji,jj,2) - fsp(ji,jj,1) ) / & 1311 & ( xsp(ji,jj,2) - xsp(ji,jj,1) ) - 0.5_wp * zdf(2) 1312 zdf(jpkm1) = 1.5_wp * ( fsp(ji,jj,jpkm1) - fsp(ji,jj,jpkm1-1) ) / & 1313 & ( xsp(ji,jj,jpkm1) - xsp(ji,jj,jpkm1-1) ) - 0.5_wp * zdf(jpk - 2) 1314 1315 DO jk = 1, jpk-2 1316 zdxtmp = xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 1317 ztmp1 = (zdf(jk+1) + 2._wp * zdf(jk)) / zdxtmp 1318 ztmp2 = 6._wp * (fsp(ji,jj,jk+1) - fsp(ji,jj,jk)) / zdxtmp / zdxtmp 1319 zddf1 = -2._wp * ztmp1 + ztmp2 1320 ztmp1 = (2._wp * zdf(jk+1) + zdf(jk)) / zdxtmp 1321 zddf2 = 2._wp * ztmp1 - ztmp2 1322 1323 dsp(ji,jj,jk) = (zddf2 - zddf1) / 6._wp / zdxtmp 1324 csp(ji,jj,jk) = ( xsp(ji,jj,jk+1) * zddf1 - xsp(ji,jj,jk)*zddf2 ) / 2._wp / zdxtmp 1325 bsp(ji,jj,jk) = ( fsp(ji,jj,jk+1) - fsp(ji,jj,jk) ) / zdxtmp - & 1326 & csp(ji,jj,jk) * ( xsp(ji,jj,jk+1) + xsp(ji,jj,jk) ) - & 1327 & dsp(ji,jj,jk) * ((xsp(ji,jj,jk+1) + xsp(ji,jj,jk))**2 - & 1328 & xsp(ji,jj,jk+1) * xsp(ji,jj,jk)) 1329 asp(ji,jj,jk) = fsp(ji,jj,jk) - xsp(ji,jj,jk) * (bsp(ji,jj,jk) + & 1330 & (xsp(ji,jj,jk) * (csp(ji,jj,jk) + & 1331 & dsp(ji,jj,jk) * xsp(ji,jj,jk)))) 1332 END DO 1333 END_2D 1353 1334 1354 1335 ELSEIF ( polynomial_type == 2 ) THEN ! Linear 1355 DO ji = 1, jpi 1356 DO jj = 1, jpj 1357 DO jk = 1, jpkm1-1 1358 zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 1359 ztmp1 = fsp(ji,jj,jk+1) - fsp(ji,jj,jk) 1360 1361 dsp(ji,jj,jk) = 0._wp 1362 csp(ji,jj,jk) = 0._wp 1363 bsp(ji,jj,jk) = ztmp1 / zdxtmp 1364 asp(ji,jj,jk) = fsp(ji,jj,jk) - bsp(ji,jj,jk) * xsp(ji,jj,jk) 1365 END DO 1366 END DO 1367 END DO 1336 DO_3D( 1, 1, 1, 1, 1, jpk-2 ) 1337 zdxtmp =xsp(ji,jj,jk+1) - xsp(ji,jj,jk) 1338 ztmp1 = fsp(ji,jj,jk+1) - fsp(ji,jj,jk) 1339 1340 dsp(ji,jj,jk) = 0._wp 1341 csp(ji,jj,jk) = 0._wp 1342 bsp(ji,jj,jk) = ztmp1 / zdxtmp 1343 asp(ji,jj,jk) = fsp(ji,jj,jk) - bsp(ji,jj,jk) * xsp(ji,jj,jk) 1344 END_3D 1368 1345 ! 1369 1346 ELSE -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynkeg.F90
r13497 r14958 78 78 INTEGER :: ji, jj, jk ! dummy loop indices 79 79 REAL(wp) :: zu, zv ! local scalars 80 REAL(wp), DIMENSION( jpi,jpj,jpk):: zhke80 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zhke 81 81 REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: ztrdu, ztrdv 82 82 !!---------------------------------------------------------------------- … … 84 84 IF( ln_timing ) CALL timing_start('dyn_keg') 85 85 ! 86 IF( kt == nit000 ) THEN 87 IF(lwp) WRITE(numout,*) 88 IF(lwp) WRITE(numout,*) 'dyn_keg : kinetic energy gradient trend, scheme number=', kscheme 89 IF(lwp) WRITE(numout,*) '~~~~~~~' 86 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 87 IF( kt == nit000 ) THEN 88 IF(lwp) WRITE(numout,*) 89 IF(lwp) WRITE(numout,*) 'dyn_keg : kinetic energy gradient trend, scheme number=', kscheme 90 IF(lwp) WRITE(numout,*) '~~~~~~~' 91 ENDIF 90 92 ENDIF 91 93 … … 109 111 END_3D 110 112 CASE ( nkeg_HW ) !-- Hollingsworth scheme --! 111 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 113 DO_3D( 0, nn_hls-1, 0, nn_hls-1, 1, jpkm1 ) 114 ! round brackets added to fix the order of floating point operations 115 ! needed to ensure halo 1 - halo 2 compatibility 112 116 zu = 8._wp * ( puu(ji-1,jj ,jk,Kmm) * puu(ji-1,jj ,jk,Kmm) & 113 117 & + puu(ji ,jj ,jk,Kmm) * puu(ji ,jj ,jk,Kmm) ) & 114 & + ( puu(ji-1,jj-1,jk,Kmm) + puu(ji-1,jj+1,jk,Kmm) ) * ( puu(ji-1,jj-1,jk,Kmm) + puu(ji-1,jj+1,jk,Kmm) ) & 115 & + ( puu(ji ,jj-1,jk,Kmm) + puu(ji ,jj+1,jk,Kmm) ) * ( puu(ji ,jj-1,jk,Kmm) + puu(ji ,jj+1,jk,Kmm) ) 118 & + ( ( puu(ji-1,jj-1,jk,Kmm) + puu(ji-1,jj+1,jk,Kmm) ) * ( puu(ji-1,jj-1,jk,Kmm) + puu(ji-1,jj+1,jk,Kmm) ) & 119 & + ( puu(ji ,jj-1,jk,Kmm) + puu(ji ,jj+1,jk,Kmm) ) * ( puu(ji ,jj-1,jk,Kmm) + puu(ji ,jj+1,jk,Kmm) ) & 120 & ) ! bracket for halo 1 - halo 2 compatibility 116 121 ! 117 122 zv = 8._wp * ( pvv(ji ,jj-1,jk,Kmm) * pvv(ji ,jj-1,jk,Kmm) & 118 123 & + pvv(ji ,jj ,jk,Kmm) * pvv(ji ,jj ,jk,Kmm) ) & 119 & + ( pvv(ji-1,jj-1,jk,Kmm) + pvv(ji+1,jj-1,jk,Kmm) ) * ( pvv(ji-1,jj-1,jk,Kmm) + pvv(ji+1,jj-1,jk,Kmm) ) & 120 & + ( pvv(ji-1,jj ,jk,Kmm) + pvv(ji+1,jj ,jk,Kmm) ) * ( pvv(ji-1,jj ,jk,Kmm) + pvv(ji+1,jj ,jk,Kmm) ) 124 & + ( ( pvv(ji-1,jj-1,jk,Kmm) + pvv(ji+1,jj-1,jk,Kmm) ) * ( pvv(ji-1,jj-1,jk,Kmm) + pvv(ji+1,jj-1,jk,Kmm) ) & 125 & + ( pvv(ji-1,jj ,jk,Kmm) + pvv(ji+1,jj ,jk,Kmm) ) * ( pvv(ji-1,jj ,jk,Kmm) + pvv(ji+1,jj ,jk,Kmm) ) & 126 & ) ! bracket for halo 1 - halo 2 compatibility 121 127 zhke(ji,jj,jk) = r1_48 * ( zv + zu ) 122 128 END_3D 123 CALL lbc_lnk( 'dynkeg', zhke, 'T', 1.0_wp )129 IF (nn_hls==1) CALL lbc_lnk( 'dynkeg', zhke, 'T', 1.0_wp ) 124 130 ! 125 131 END SELECT -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynldf_iso.F90
r14433 r14958 28 28 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 29 29 USE prtctl ! Print control 30 #if defined key_loop_fusion 31 USE dynldf_iso_lf, ONLY: dyn_ldf_iso_lf ! lateral mixing - loop fusion version (dyn_ldf_iso routine ) 32 #endif 30 33 31 34 IMPLICIT NONE … … 36 39 37 40 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: akzu, akzv !: vertical component of rotated lateral viscosity 38 39 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: zfuw, zdiu, zdju, zdj1u ! 2D workspace (dyn_ldf_iso)40 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: zfvw, zdiv, zdjv, zdj1v ! - -41 41 42 42 !! * Substitutions … … 54 54 !! *** ROUTINE dyn_ldf_iso_alloc *** 55 55 !!---------------------------------------------------------------------- 56 ALLOCATE( akzu(jpi,jpj,jpk) , zfuw(jpi,jpk) , zdiu(jpi,jpk) , zdju(jpi,jpk) , zdj1u(jpi,jpk) , & 57 & akzv(jpi,jpj,jpk) , zfvw(jpi,jpk) , zdiv(jpi,jpk) , zdjv(jpi,jpk) , zdj1v(jpi,jpk) , STAT=dyn_ldf_iso_alloc ) 58 ! 59 IF( dyn_ldf_iso_alloc /= 0 ) CALL ctl_warn('dyn_ldf_iso_alloc: array allocate failed.') 56 dyn_ldf_iso_alloc = 0 57 IF( .NOT. ALLOCATED( akzu ) ) THEN 58 ALLOCATE( akzu(jpi,jpj,jpk), akzv(jpi,jpj,jpk), STAT=dyn_ldf_iso_alloc ) 59 ! 60 IF( dyn_ldf_iso_alloc /= 0 ) CALL ctl_warn('dyn_ldf_iso_alloc: array allocate failed.') 61 ENDIF 60 62 END FUNCTION dyn_ldf_iso_alloc 61 63 … … 112 114 REAL(wp) :: zabe2, zmskf, zmkf, zvav, zvwslpi, zvwslpj ! - - 113 115 REAL(wp) :: zcof0, zcof1, zcof2, zcof3, zcof4, zaht_0 ! - - 114 REAL(wp), DIMENSION(jpi,jpj) :: ziut, zivf, zdku, zdk1u ! 2D workspace 115 REAL(wp), DIMENSION(jpi,jpj) :: zjuf, zjvt, zdkv, zdk1v ! - - 116 REAL(wp), DIMENSION(A2D(nn_hls)) :: ziut, zivf, zdku, zdk1u ! 2D workspace 117 REAL(wp), DIMENSION(A2D(nn_hls)) :: zjuf, zjvt, zdkv, zdk1v ! - - 118 REAL(wp), DIMENSION(A1Di(nn_hls),jpk) :: zfuw, zdiu, zdju, zdj1u ! - - 119 REAL(wp), DIMENSION(A1Di(nn_hls),jpk) :: zfvw, zdiv, zdjv, zdj1v ! - - 116 120 !!---------------------------------------------------------------------- 117 121 ! 118 IF( kt == nit000 ) THEN 119 IF(lwp) WRITE(numout,*) 120 IF(lwp) WRITE(numout,*) 'dyn_ldf_iso : iso-neutral laplacian diffusive operator or ' 121 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate horizontal diffusive operator' 122 ! ! allocate dyn_ldf_bilap arrays 123 IF( dyn_ldf_iso_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_ldf_iso: failed to allocate arrays') 122 #if defined key_loop_fusion 123 CALL dyn_ldf_iso_lf( kt, Kbb, Kmm, puu, pvv, Krhs ) 124 #else 125 126 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 127 IF( kt == nit000 ) THEN 128 IF(lwp) WRITE(numout,*) 129 IF(lwp) WRITE(numout,*) 'dyn_ldf_iso : iso-neutral laplacian diffusive operator or ' 130 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ s-coordinate horizontal diffusive operator' 131 ! ! allocate dyn_ldf_iso arrays 132 IF( dyn_ldf_iso_alloc() /= 0 ) CALL ctl_stop('STOP', 'dyn_ldf_iso: failed to allocate arrays') 133 ENDIF 124 134 ENDIF 125 135 … … 128 138 IF( ln_dynldf_hor .AND. ln_traldf_iso ) THEN 129 139 ! 130 DO_3D ( 0, 0, 0, 0, 1, jpk ) ! set the slopes of iso-level140 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) ! set the slopes of iso-level 131 141 uslp (ji,jj,jk) = - ( gdept(ji+1,jj,jk,Kbb) - gdept(ji ,jj ,jk,Kbb) ) * r1_e1u(ji,jj) * umask(ji,jj,jk) 132 142 vslp (ji,jj,jk) = - ( gdept(ji,jj+1,jk,Kbb) - gdept(ji ,jj ,jk,Kbb) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk) … … 135 145 END_3D 136 146 ! Lateral boundary conditions on the slopes 137 CALL lbc_lnk( 'dynldf_iso', uslp , 'U', -1.0_wp, vslp , 'V', -1.0_wp, wslpi, 'W', -1.0_wp, wslpj, 'W', -1.0_wp )147 IF (nn_hls == 1) CALL lbc_lnk( 'dynldf_iso', uslp , 'U', -1.0_wp, vslp , 'V', -1.0_wp, wslpi, 'W', -1.0_wp, wslpj, 'W', -1.0_wp ) 138 148 ! 139 149 ENDIF 140 150 141 151 zaht_0 = 0.5_wp * rn_Ud * rn_Ld ! aht_0 from namtra_ldf = zaht_max … … 150 160 ! zdkv(jk=1)=zdkv(jk=2) 151 161 152 zdk1u(:,:) = ( puu(:,:,jk,Kbb) -puu(:,:,jk+1,Kbb) ) * umask(:,:,jk+1) 153 zdk1v(:,:) = ( pvv(:,:,jk,Kbb) -pvv(:,:,jk+1,Kbb) ) * vmask(:,:,jk+1) 162 DO_2D( 1, 1, 1, 1 ) 163 zdk1u(ji,jj) = ( puu(ji,jj,jk,Kbb) -puu(ji,jj,jk+1,Kbb) ) * umask(ji,jj,jk+1) 164 zdk1v(ji,jj) = ( pvv(ji,jj,jk,Kbb) -pvv(ji,jj,jk+1,Kbb) ) * vmask(ji,jj,jk+1) 165 END_2D 154 166 155 167 IF( jk == 1 ) THEN … … 157 169 zdkv(:,:) = zdk1v(:,:) 158 170 ELSE 159 zdku(:,:) = ( puu(:,:,jk-1,Kbb) - puu(:,:,jk,Kbb) ) * umask(:,:,jk) 160 zdkv(:,:) = ( pvv(:,:,jk-1,Kbb) - pvv(:,:,jk,Kbb) ) * vmask(:,:,jk) 171 DO_2D( 1, 1, 1, 1 ) 172 zdku(ji,jj) = ( puu(ji,jj,jk-1,Kbb) - puu(ji,jj,jk,Kbb) ) * umask(ji,jj,jk) 173 zdkv(ji,jj) = ( pvv(ji,jj,jk-1,Kbb) - pvv(ji,jj,jk,Kbb) ) * vmask(ji,jj,jk) 174 END_2D 161 175 ENDIF 162 176 … … 286 300 287 301 ! ! =============== 288 DO jj = 2, jpjm1! Vertical slab302 DO jj = ntsj, ntej ! Vertical slab 289 303 ! ! =============== 290 304 … … 299 313 300 314 DO jk = 1, jpk 301 DO ji = 2, jpi315 DO ji = ntsi, ntei + nn_hls 302 316 ! i-gradient of u at jj 303 317 zdiu (ji,jk) = tmask(ji,jj ,jk) * ( puu(ji,jj ,jk,Kbb) - puu(ji-1,jj ,jk,Kbb) ) … … 311 325 END DO 312 326 DO jk = 1, jpk 313 DO ji = 1, jpim1327 DO ji = ntsi - nn_hls, ntei 314 328 ! i-gradient of v at jj 315 329 zdiv (ji,jk) = fmask(ji,jj ,jk) * ( pvv(ji+1,jj,jk,Kbb) - pvv(ji ,jj ,jk,Kbb) ) … … 322 336 323 337 ! Surface and bottom vertical fluxes set to zero 324 DO ji = 1, jpi338 DO ji = ntsi - nn_hls, ntei + nn_hls 325 339 zfuw(ji, 1 ) = 0.e0 326 340 zfvw(ji, 1 ) = 0.e0 … … 331 345 ! interior (2=<jk=<jpk-1) on U field 332 346 DO jk = 2, jpkm1 333 DO ji = 2, jpim1347 DO ji = ntsi, ntei 334 348 zcof0 = 0.5_wp * zaht_0 * umask(ji,jj,jk) 335 349 ! … … 357 371 ! interior (2=<jk=<jpk-1) on V field 358 372 DO jk = 2, jpkm1 359 DO ji = 2, jpim1373 DO ji = ntsi, ntei 360 374 zcof0 = 0.5_wp * zaht_0 * vmask(ji,jj,jk) 361 375 ! … … 385 399 ! ------------------------------------------------------------------- 386 400 DO jk = 1, jpkm1 387 DO ji = 2, jpim1401 DO ji = ntsi, ntei 388 402 puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) + ( zfuw(ji,jk) - zfuw(ji,jk+1) ) * r1_e1e2u(ji,jj) & 389 403 & / e3u(ji,jj,jk,Kmm) … … 395 409 END DO ! End of slab 396 410 ! ! =============== 411 #endif 397 412 END SUBROUTINE dyn_ldf_iso 398 413 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynldf_lap_blp.F90
r14433 r14958 14 14 USE oce ! ocean dynamics and tracers 15 15 USE dom_oce ! ocean space and time domain 16 USE domutl, ONLY : is_tile 16 17 USE ldfdyn ! lateral diffusion: eddy viscosity coef. 17 18 USE ldfslp ! iso-neutral slopes … … 21 22 USE lbclnk ! ocean lateral boundary conditions (or mpp link) 22 23 USE lib_mpp 23 24 #if defined key_loop_fusion 25 USE dynldf_lap_blp_lf 26 #endif 27 24 28 IMPLICIT NONE 25 29 PRIVATE … … 39 43 40 44 SUBROUTINE dyn_ldf_lap( kt, Kbb, Kmm, pu, pv, pu_rhs, pv_rhs, kpass ) 45 !! 46 INTEGER , INTENT(in ) :: kt ! ocean time-step index 47 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 48 INTEGER , INTENT(in ) :: kpass ! =1/2 first or second passage 49 REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pu, pv ! before velocity [m/s] 50 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: pu_rhs, pv_rhs ! velocity trend [m/s2] 51 !! 52 #if defined key_loop_fusion 53 CALL dyn_ldf_lap_lf( kt, Kbb, Kmm, pu, pv, pu_rhs, pv_rhs, kpass ) 54 #else 55 CALL dyn_ldf_lap_t( kt, Kbb, Kmm, pu, pv, is_tile(pu), pu_rhs, pv_rhs, is_tile(pu_rhs), kpass ) 56 #endif 57 58 END SUBROUTINE dyn_ldf_lap 59 60 61 SUBROUTINE dyn_ldf_lap_t( kt, Kbb, Kmm, pu, pv, ktuv, pu_rhs, pv_rhs, ktuv_rhs, kpass ) 41 62 !!---------------------------------------------------------------------- 42 63 !! *** ROUTINE dyn_ldf_lap *** … … 52 73 !! Reference : S.Griffies, R.Hallberg 2000 Mon.Wea.Rev., DOI:/ 53 74 !!---------------------------------------------------------------------- 54 INTEGER , INTENT(in ) :: kt ! ocean time-step index 55 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 56 INTEGER , INTENT(in ) :: kpass ! =1/2 first or second passage 57 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pu, pv ! before velocity [m/s] 58 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pu_rhs, pv_rhs ! velocity trend [m/s2] 75 INTEGER , INTENT(in ) :: kt ! ocean time-step index 76 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 77 INTEGER , INTENT(in ) :: kpass ! =1/2 first or second passage 78 INTEGER , INTENT(in ) :: ktuv, ktuv_rhs 79 REAL(wp), DIMENSION(A2D_T(ktuv) ,JPK), INTENT(in ) :: pu, pv ! before velocity [m/s] 80 REAL(wp), DIMENSION(A2D_T(ktuv_rhs),JPK), INTENT(inout) :: pu_rhs, pv_rhs ! velocity trend [m/s2] 59 81 ! 60 82 INTEGER :: ji, jj, jk ! dummy loop indices 83 INTEGER :: iij 61 84 REAL(wp) :: zsign ! local scalars 62 85 REAL(wp) :: zua, zva ! local scalars … … 65 88 !!---------------------------------------------------------------------- 66 89 ! 67 IF( kt == nit000 .AND. lwp ) THEN 68 WRITE(numout,*) 69 WRITE(numout,*) 'dyn_ldf : iso-level harmonic (laplacian) operator, pass=', kpass 70 WRITE(numout,*) '~~~~~~~ ' 90 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 91 IF( kt == nit000 .AND. lwp ) THEN 92 WRITE(numout,*) 93 WRITE(numout,*) 'dyn_ldf : iso-level harmonic (laplacian) operator, pass=', kpass 94 WRITE(numout,*) '~~~~~~~ ' 95 ENDIF 96 ENDIF 97 ! 98 ! Define pu_rhs/pv_rhs halo points for multi-point haloes in bilaplacian case 99 IF( nldf_dyn == np_blp .AND. kpass == 1 ) THEN ; iij = nn_hls 100 ELSE ; iij = 1 71 101 ENDIF 72 102 ! … … 79 109 CASE ( np_typ_rot ) !== Vorticity-Divergence operator ==! 80 110 ! 81 ALLOCATE( zcur( jpi,jpj) , zdiv(jpi,jpj) )111 ALLOCATE( zcur(A2D(nn_hls)) , zdiv(A2D(nn_hls)) ) 82 112 ! 83 113 DO jk = 1, jpkm1 ! Horizontal slab 84 114 ! 85 DO_2D( 0, 1, 0, 1)115 DO_2D( iij-1, iij, iij-1, iij ) 86 116 ! ! ahm * e3 * curl (computed from 1 to jpim1/jpjm1) 87 117 zcur(ji-1,jj-1) = ahmf(ji-1,jj-1,jk) * e3f(ji-1,jj-1,jk) * r1_e1e2f(ji-1,jj-1) & ! ahmf already * by fmask … … 94 124 END_2D 95 125 ! 96 DO_2D( 0, 0, 0, 0 )! - curl( curl) + grad( div )126 DO_2D( iij-1, iij-1, iij-1, iij-1 ) ! - curl( curl) + grad( div ) 97 127 pu_rhs(ji,jj,jk) = pu_rhs(ji,jj,jk) + zsign * umask(ji,jj,jk) * ( & ! * by umask is mandatory for dyn_ldf_blp use 98 128 & - ( zcur(ji ,jj) - zcur(ji,jj-1) ) * r1_e2u(ji,jj) / e3u(ji,jj,jk,Kmm) & … … 110 140 CASE ( np_typ_sym ) !== Symmetric operator ==! 111 141 ! 112 ALLOCATE( zten( jpi,jpj) , zshe(jpi,jpj) )142 ALLOCATE( zten(A2D(nn_hls)) , zshe(A2D(nn_hls)) ) 113 143 ! 114 144 DO jk = 1, jpkm1 ! Horizontal slab 115 145 ! 116 DO_2D( 0, 1, 0, 1)146 DO_2D( iij-1, iij, iij-1, iij ) 117 147 ! ! shearing stress component (F-point) NB : ahmf has already been multiplied by fmask 118 148 zshe(ji-1,jj-1) = ahmf(ji-1,jj-1,jk) & … … 129 159 END_2D 130 160 ! 131 DO_2D( 0, 0, 0, 0)161 DO_2D( iij-1, iij-1, iij-1, iij-1 ) 132 162 pu_rhs(ji,jj,jk) = pu_rhs(ji,jj,jk) + zsign * r1_e1e2u(ji,jj) / e3u(ji,jj,jk,Kmm) & 133 163 & * ( ( zten(ji+1,jj ) * e2t(ji+1,jj )*e2t(ji+1,jj ) * e3t(ji+1,jj ,jk,Kmm) & … … 150 180 END SELECT 151 181 ! 152 END SUBROUTINE dyn_ldf_lap 182 END SUBROUTINE dyn_ldf_lap_t 153 183 154 184 … … 171 201 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pu_rhs, pv_rhs ! momentum trend 172 202 ! 173 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zulap, zvlap ! laplacian at u- and v-point 174 !!---------------------------------------------------------------------- 175 ! 176 IF( kt == nit000 ) THEN 177 IF(lwp) WRITE(numout,*) 178 IF(lwp) WRITE(numout,*) 'dyn_ldf_blp : bilaplacian operator momentum ' 179 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' 203 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zulap, zvlap ! laplacian at u- and v-point 204 !!---------------------------------------------------------------------- 205 ! 206 #if defined key_loop_fusion 207 CALL dyn_ldf_blp_lf( kt, Kbb, Kmm, pu, pv, pu_rhs, pv_rhs ) 208 #else 209 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 210 IF( kt == nit000 ) THEN 211 IF(lwp) WRITE(numout,*) 212 IF(lwp) WRITE(numout,*) 'dyn_ldf_blp : bilaplacian operator momentum ' 213 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~' 214 ENDIF 180 215 ENDIF 181 216 ! … … 185 220 CALL dyn_ldf_lap( kt, Kbb, Kmm, pu, pv, zulap, zvlap, 1 ) ! rotated laplacian applied to pt (output in zlap,Kbb) 186 221 ! 187 CALL lbc_lnk( 'dynldf_lap_blp', zulap, 'U', -1.0_wp, zvlap, 'V', -1.0_wp ) ! Lateral boundary conditions222 IF (nn_hls==1) CALL lbc_lnk( 'dynldf_lap_blp', zulap, 'U', -1.0_wp, zvlap, 'V', -1.0_wp ) ! Lateral boundary conditions 188 223 ! 189 224 CALL dyn_ldf_lap( kt, Kbb, Kmm, zulap, zvlap, pu_rhs, pv_rhs, 2 ) ! rotated laplacian applied to zlap (output in pt(:,:,:,:,Krhs)) 190 225 ! 226 #endif 191 227 END SUBROUTINE dyn_ldf_blp 192 228 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynspg_ts.F90
r14433 r14958 730 730 IF (ln_bt_fw) THEN 731 731 IF( .NOT.( kt == nit000 .AND. l_1st_euler ) ) THEN 732 DO_2D( 1, 1, 1, 1)732 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 733 733 zun_save = un_adv(ji,jj) 734 734 zvn_save = vn_adv(ji,jj) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynvor.F90
r14433 r14958 240 240 INTEGER :: ji, jj, jk ! dummy loop indices 241 241 REAL(wp) :: zx1, zy1, zx2, zy2 ! local scalars 242 REAL(wp), DIMENSION(jpi,jpj) :: zwx, zwy, zwt ! 2D workspace 243 REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zwz ! 3D workspace, jpkm1 -> avoid lbc_lnk on jpk that is not defined 244 !!---------------------------------------------------------------------- 245 ! 246 IF( kt == nit000 ) THEN 247 IF(lwp) WRITE(numout,*) 248 IF(lwp) WRITE(numout,*) 'dyn:vor_enT : vorticity term: t-point energy conserving scheme' 249 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 242 REAL(wp), DIMENSION(A2D(nn_hls)) :: zwx, zwy, zwt ! 2D workspace 243 REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zwz ! 3D workspace, jpkm1 -> avoid lbc_lnk on jpk that is not defined 244 !!---------------------------------------------------------------------- 245 ! 246 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 247 IF( kt == nit000 ) THEN 248 IF(lwp) WRITE(numout,*) 249 IF(lwp) WRITE(numout,*) 'dyn:vor_enT : vorticity term: t-point energy conserving scheme' 250 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 251 ENDIF 250 252 ENDIF 251 253 ! … … 254 256 ! 255 257 CASE ( np_RVO , np_CRV ) !* relative vorticity at f-point is used 256 ALLOCATE( zwz( jpi,jpj,jpk) )258 ALLOCATE( zwz(A2D(nn_hls),jpk) ) 257 259 DO jk = 1, jpkm1 ! Horizontal slab 258 DO_2D( 1, 0, 1, 0)260 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 259 261 zwz(ji,jj,jk) = ( e2v(ji+1,jj) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk) & 260 262 & - e1u(ji,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk) ) * r1_e1e2f(ji,jj) 261 263 END_2D 262 264 IF( ln_dynvor_msk ) THEN ! mask relative vorticity 263 DO_2D( 1, 0, 1, 0)265 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 264 266 zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk) 265 267 END_2D 266 268 ENDIF 267 269 END DO 268 CALL lbc_lnk( 'dynvor', zwz, 'F', 1.0_wp )270 IF (nn_hls==1) CALL lbc_lnk( 'dynvor', zwz, 'F', 1.0_wp ) 269 271 ! 270 272 END SELECT … … 277 279 ! 278 280 CASE ( np_COR ) !* Coriolis (planetary vorticity) 279 zwt(:,:) = ff_t(:,:) * e1e2t(:,:)*e3t(:,:,jk,Kmm) 281 DO_2D( 0, 1, 0, 1 ) 282 zwt(ji,jj) = ff_t(ji,jj) * e1e2t(ji,jj)*e3t(ji,jj,jk,Kmm) 283 END_2D 280 284 CASE ( np_RVO ) !* relative vorticity 281 285 DO_2D( 0, 1, 0, 1 ) … … 356 360 INTEGER :: ji, jj, jk ! dummy loop indices 357 361 REAL(wp) :: zx1, zy1, zx2, zy2, ze3f, zmsk ! local scalars 358 REAL(wp), DIMENSION(jpi,jpj) :: zwx, zwy, zwz ! 2D workspace 359 !!---------------------------------------------------------------------- 360 ! 361 IF( kt == nit000 ) THEN 362 IF(lwp) WRITE(numout,*) 363 IF(lwp) WRITE(numout,*) 'dyn:vor_ene : vorticity term: energy conserving scheme' 364 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 362 REAL(wp), DIMENSION(A2D(nn_hls)) :: zwx, zwy, zwz ! 2D workspace 363 !!---------------------------------------------------------------------- 364 ! 365 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 366 IF( kt == nit000 ) THEN 367 IF(lwp) WRITE(numout,*) 368 IF(lwp) WRITE(numout,*) 'dyn:vor_ene : vorticity term: energy conserving scheme' 369 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 370 ENDIF 365 371 ENDIF 366 372 ! … … 371 377 SELECT CASE( kvor ) !== vorticity considered ==! 372 378 CASE ( np_COR ) !* Coriolis (planetary vorticity) 373 zwz(:,:) = ff_f(:,:) 379 DO_2D( 1, 0, 1, 0 ) 380 zwz(ji,jj) = ff_f(ji,jj) 381 END_2D 374 382 CASE ( np_RVO ) !* relative vorticity 375 383 DO_2D( 1, 0, 1, 0 ) … … 437 445 #endif 438 446 ! !== horizontal fluxes ==! 439 zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk) 440 zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk) 447 DO_2D( 1, 1, 1, 1 ) 448 zwx(ji,jj) = e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * pu(ji,jj,jk) 449 zwy(ji,jj) = e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pv(ji,jj,jk) 450 END_2D 441 451 ! 442 452 ! !== compute and add the vorticity term trend =! … … 483 493 INTEGER :: ji, jj, jk ! dummy loop indices 484 494 REAL(wp) :: zuav, zvau, ze3f, zmsk ! local scalars 485 REAL(wp), DIMENSION(jpi,jpj) :: zwx, zwy, zwz, zww ! 2D workspace 486 !!---------------------------------------------------------------------- 487 ! 488 IF( kt == nit000 ) THEN 489 IF(lwp) WRITE(numout,*) 490 IF(lwp) WRITE(numout,*) 'dyn:vor_ens : vorticity term: enstrophy conserving scheme' 491 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 495 REAL(wp), DIMENSION(A2D(nn_hls)) :: zwx, zwy, zwz ! 2D workspace 496 !!---------------------------------------------------------------------- 497 ! 498 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 499 IF( kt == nit000 ) THEN 500 IF(lwp) WRITE(numout,*) 501 IF(lwp) WRITE(numout,*) 'dyn:vor_ens : vorticity term: enstrophy conserving scheme' 502 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 503 ENDIF 492 504 ENDIF 493 505 ! ! =============== … … 497 509 SELECT CASE( kvor ) !== vorticity considered ==! 498 510 CASE ( np_COR ) !* Coriolis (planetary vorticity) 499 zwz(:,:) = ff_f(:,:) 511 DO_2D( 1, 0, 1, 0 ) 512 zwz(ji,jj) = ff_f(ji,jj) 513 END_2D 500 514 CASE ( np_RVO ) !* relative vorticity 501 515 DO_2D( 1, 0, 1, 0 ) … … 564 578 #endif 565 579 ! !== horizontal fluxes ==! 566 zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk) 567 zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk) 580 DO_2D( 1, 1, 1, 1 ) 581 zwx(ji,jj) = e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * pu(ji,jj,jk) 582 zwy(ji,jj) = e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pv(ji,jj,jk) 583 END_2D 568 584 ! 569 585 ! !== compute and add the vorticity term trend =! … … 609 625 REAL(wp) :: zua, zva ! local scalars 610 626 REAL(wp) :: zmsk, ze3f ! local scalars 611 REAL(wp), DIMENSION(jpi,jpj) :: zwx , zwy , z1_e3f 612 REAL(wp), DIMENSION(jpi,jpj) :: ztnw, ztne, ztsw, ztse 613 REAL(wp), DIMENSION(jpi,jpj,jpkm1) :: zwz ! 3D workspace, jpkm1 -> jpkm1 -> avoid lbc_lnk on jpk that is not defined 614 !!---------------------------------------------------------------------- 615 ! 616 IF( kt == nit000 ) THEN 617 IF(lwp) WRITE(numout,*) 618 IF(lwp) WRITE(numout,*) 'dyn:vor_een : vorticity term: energy and enstrophy conserving scheme' 619 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 627 REAL(wp), DIMENSION(A2D(nn_hls)) :: z1_e3f 628 #if defined key_loop_fusion 629 REAL(wp) :: ztne, ztnw, ztnw_ip1, ztse, ztse_jp1, ztsw_jp1, ztsw_ip1 630 REAL(wp) :: zwx, zwx_im1, zwx_jp1, zwx_im1_jp1 631 REAL(wp) :: zwy, zwy_ip1, zwy_jm1, zwy_ip1_jm1 632 #else 633 REAL(wp), DIMENSION(A2D(nn_hls)) :: zwx , zwy 634 REAL(wp), DIMENSION(A2D(nn_hls)) :: ztnw, ztne, ztsw, ztse 635 #endif 636 REAL(wp), DIMENSION(A2D(nn_hls),jpkm1) :: zwz ! 3D workspace, jpkm1 -> jpkm1 -> avoid lbc_lnk on jpk that is not defined 637 !!---------------------------------------------------------------------- 638 ! 639 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 640 IF( kt == nit000 ) THEN 641 IF(lwp) WRITE(numout,*) 642 IF(lwp) WRITE(numout,*) 'dyn:vor_een : vorticity term: energy and enstrophy conserving scheme' 643 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 644 ENDIF 620 645 ENDIF 621 646 ! … … 625 650 ! 626 651 #if defined key_qco || defined key_linssh 627 DO_2D( 1, 0, 1, 0) ! == reciprocal of e3 at F-point (key_qco)652 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! == reciprocal of e3 at F-point (key_qco) 628 653 z1_e3f(ji,jj) = 1._wp / e3f_vor(ji,jj,jk) 629 654 END_2D … … 631 656 SELECT CASE( nn_e3f_typ ) ! == reciprocal of e3 at F-point 632 657 CASE ( 0 ) ! original formulation (masked averaging of e3t divided by 4) 633 DO_2D( 1, 0, 1, 0 ) 634 ze3f = ( e3t(ji ,jj+1,jk,Kmm)*tmask(ji ,jj+1,jk) & 635 & + e3t(ji+1,jj+1,jk,Kmm)*tmask(ji+1,jj+1,jk) & 636 & + e3t(ji ,jj ,jk,Kmm)*tmask(ji ,jj ,jk) & 637 & + e3t(ji+1,jj ,jk,Kmm)*tmask(ji+1,jj ,jk) ) 658 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 659 ! round brackets added to fix the order of floating point operations 660 ! needed to ensure halo 1 - halo 2 compatibility 661 ze3f = ( (e3t(ji ,jj+1,jk,Kmm)*tmask(ji ,jj+1,jk) & 662 & + e3t(ji+1,jj+1,jk,Kmm)*tmask(ji+1,jj+1,jk)) & 663 & + (e3t(ji ,jj ,jk,Kmm)*tmask(ji ,jj ,jk) & 664 & + e3t(ji+1,jj ,jk,Kmm)*tmask(ji+1,jj ,jk)) ) 638 665 IF( ze3f /= 0._wp ) THEN ; z1_e3f(ji,jj) = 4._wp / ze3f 639 666 ELSE ; z1_e3f(ji,jj) = 0._wp … … 641 668 END_2D 642 669 CASE ( 1 ) ! new formulation (masked averaging of e3t divided by the sum of mask) 643 DO_2D( 1, 0, 1, 0 ) 644 ze3f = ( e3t(ji ,jj+1,jk,Kmm)*tmask(ji ,jj+1,jk) & 645 & + e3t(ji+1,jj+1,jk,Kmm)*tmask(ji+1,jj+1,jk) & 646 & + e3t(ji ,jj ,jk,Kmm)*tmask(ji ,jj ,jk) & 647 & + e3t(ji+1,jj ,jk,Kmm)*tmask(ji+1,jj ,jk) ) 670 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 671 ! round brackets added to fix the order of floating point operations 672 ! needed to ensure halo 1 - halo 2 compatibility 673 ze3f = ( (e3t(ji ,jj+1,jk,Kmm)*tmask(ji ,jj+1,jk) & 674 & + e3t(ji+1,jj+1,jk,Kmm)*tmask(ji+1,jj+1,jk)) & 675 & + (e3t(ji ,jj ,jk,Kmm)*tmask(ji ,jj ,jk) & 676 & + e3t(ji+1,jj ,jk,Kmm)*tmask(ji+1,jj ,jk)) ) 648 677 zmsk = ( tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) & 649 678 & + tmask(ji,jj ,jk) + tmask(ji+1,jj ,jk) ) … … 658 687 ! 659 688 CASE ( np_COR ) !* Coriolis (planetary vorticity) 660 DO_2D( 1, 0, 1, 0)689 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 661 690 zwz(ji,jj,jk) = ff_f(ji,jj) * z1_e3f(ji,jj) 662 691 END_2D 663 692 CASE ( np_RVO ) !* relative vorticity 664 DO_2D( 1, 0, 1, 0)693 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 665 694 zwz(ji,jj,jk) = ( e2v(ji+1,jj ) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk) & 666 695 & - e1u(ji ,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk) ) * r1_e1e2f(ji,jj)*z1_e3f(ji,jj) 667 696 END_2D 668 697 IF( ln_dynvor_msk ) THEN ! mask the relative vorticity 669 DO_2D( 1, 0, 1, 0)698 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 670 699 zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk) 671 700 END_2D 672 701 ENDIF 673 702 CASE ( np_MET ) !* metric term 674 DO_2D( 1, 0, 1, 0)703 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 675 704 zwz(ji,jj,jk) = ( ( pv(ji+1,jj,jk) + pv(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj) & 676 705 & - ( pu(ji,jj+1,jk) + pu(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj) ) * z1_e3f(ji,jj) 677 706 END_2D 678 707 CASE ( np_CRV ) !* Coriolis + relative vorticity 679 DO_2D( 1, 0, 1, 0 ) 680 zwz(ji,jj,jk) = ( ff_f(ji,jj) + ( e2v(ji+1,jj ) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk) & 681 & - e1u(ji ,jj+1) * pu(ji,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk) ) & 682 & * r1_e1e2f(ji,jj) ) * z1_e3f(ji,jj) 708 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 709 ! round brackets added to fix the order of floating point operations 710 ! needed to ensure halo 1 - halo 2 compatibility 711 zwz(ji,jj,jk) = ( ff_f(ji,jj) + ( ( e2v(ji+1,jj ) * pv(ji+1,jj,jk) - e2v(ji,jj) * pv(ji,jj,jk) & 712 & ) & ! bracket for halo 1 - halo 2 compatibility 713 & - ( e1u(ji ,jj+1) * pu(ji,jj+1,jk) - e1u(ji,jj) * pu(ji,jj,jk) & 714 & ) & ! bracket for halo 1 - halo 2 compatibility 715 & ) * r1_e1e2f(ji,jj) ) * z1_e3f(ji,jj) 683 716 END_2D 684 717 IF( ln_dynvor_msk ) THEN ! mask the relative vorticity 685 DO_2D( 1, 0, 1, 0)718 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 686 719 zwz(ji,jj,jk) = ( zwz(ji,jj,jk) - ff_f(ji,jj) ) * fmask(ji,jj,jk) + ff_f(ji,jj) 687 720 END_2D 688 721 ENDIF 689 722 CASE ( np_CME ) !* Coriolis + metric 690 DO_2D( 1, 0, 1, 0)723 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 691 724 zwz(ji,jj,jk) = ( ff_f(ji,jj) + ( pv(ji+1,jj ,jk) + pv(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj) & 692 725 & - ( pu(ji ,jj+1,jk) + pu(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj) ) * z1_e3f(ji,jj) … … 699 732 ! ! =============== 700 733 ! 701 CALL lbc_lnk( 'dynvor', zwz, 'F', 1.0_wp ) 702 ! 703 ! ! =============== 704 DO jk = 1, jpkm1 ! Horizontal slab 705 ! ! =============== 706 ! 734 IF (nn_hls==1) CALL lbc_lnk( 'dynvor', zwz, 'F', 1.0_wp ) 735 ! 736 ! ! =============== 737 ! ! Horizontal slab 738 ! ! =============== 739 #if defined key_loop_fusion 740 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 707 741 ! !== horizontal fluxes ==! 708 zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk) 709 zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk) 742 zwx = e2u(ji ,jj ) * e3u(ji ,jj ,jk,Kmm) * pu(ji ,jj ,jk) 743 zwx_im1 = e2u(ji-1,jj ) * e3u(ji-1,jj ,jk,Kmm) * pu(ji-1,jj ,jk) 744 zwx_jp1 = e2u(ji ,jj+1) * e3u(ji ,jj+1,jk,Kmm) * pu(ji ,jj+1,jk) 745 zwx_im1_jp1 = e2u(ji-1,jj+1) * e3u(ji-1,jj+1,jk,Kmm) * pu(ji-1,jj+1,jk) 746 zwy = e1v(ji ,jj ) * e3v(ji ,jj ,jk,Kmm) * pv(ji ,jj ,jk) 747 zwy_ip1 = e1v(ji+1,jj ) * e3v(ji+1,jj ,jk,Kmm) * pv(ji+1,jj ,jk) 748 zwy_jm1 = e1v(ji ,jj-1) * e3v(ji ,jj-1,jk,Kmm) * pv(ji ,jj-1,jk) 749 zwy_ip1_jm1 = e1v(ji+1,jj-1) * e3v(ji+1,jj-1,jk,Kmm) * pv(ji+1,jj-1,jk) 750 ! !== compute and add the vorticity term trend =! 751 ztne = zwz(ji-1,jj ,jk) + zwz(ji ,jj ,jk) + zwz(ji ,jj-1,jk) 752 ztnw = zwz(ji-1,jj-1,jk) + zwz(ji-1,jj ,jk) + zwz(ji ,jj ,jk) 753 ztnw_ip1 = zwz(ji ,jj-1,jk) + zwz(ji ,jj ,jk) + zwz(ji+1,jj ,jk) 754 ztse = zwz(ji ,jj ,jk) + zwz(ji ,jj-1,jk) + zwz(ji-1,jj-1,jk) 755 ztse_jp1 = zwz(ji ,jj+1,jk) + zwz(ji ,jj ,jk) + zwz(ji-1,jj ,jk) 756 ztsw_jp1 = zwz(ji ,jj ,jk) + zwz(ji-1,jj ,jk) + zwz(ji-1,jj+1,jk) 757 ztsw_ip1 = zwz(ji+1,jj-1,jk) + zwz(ji ,jj-1,jk) + zwz(ji ,jj ,jk) 758 ! 759 zua = + r1_12 * r1_e1u(ji,jj) * ( ztne * zwy + ztnw_ip1 * zwy_ip1 & 760 & + ztse * zwy_jm1 + ztsw_ip1 * zwy_ip1_jm1 ) 761 zva = - r1_12 * r1_e2v(ji,jj) * ( ztsw_jp1 * zwx_im1_jp1 + ztse_jp1 * zwx_jp1 & 762 & + ztnw * zwx_im1 + ztne * zwx ) 763 pu_rhs(ji,jj,jk) = pu_rhs(ji,jj,jk) + zua 764 pv_rhs(ji,jj,jk) = pv_rhs(ji,jj,jk) + zva 765 END_3D 766 #else 767 DO jk = 1, jpkm1 768 ! 769 ! !== horizontal fluxes ==! 770 DO_2D( 1, 1, 1, 1 ) 771 zwx(ji,jj) = e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * pu(ji,jj,jk) 772 zwy(ji,jj) = e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pv(ji,jj,jk) 773 END_2D 710 774 ! 711 775 ! !== compute and add the vorticity term trend =! … … 725 789 pv_rhs(ji,jj,jk) = pv_rhs(ji,jj,jk) + zva 726 790 END_2D 727 ! ! =============== 728 END DO ! End of slab 791 END DO 792 #endif 793 ! ! =============== 794 ! ! End of slab 729 795 ! ! =============== 730 796 END SUBROUTINE vor_een … … 758 824 REAL(wp) :: zua, zva ! local scalars 759 825 REAL(wp) :: zmsk, z1_e3t ! local scalars 760 REAL(wp), DIMENSION(jpi,jpj) :: zwx , zwy 761 REAL(wp), DIMENSION(jpi,jpj) :: ztnw, ztne, ztsw, ztse 762 REAL(wp), DIMENSION(jpi,jpj,jpkm1) :: zwz ! 3D workspace, avoid lbc_lnk on jpk that is not defined 763 !!---------------------------------------------------------------------- 764 ! 765 IF( kt == nit000 ) THEN 766 IF(lwp) WRITE(numout,*) 767 IF(lwp) WRITE(numout,*) 'dyn:vor_eeT : vorticity term: energy and enstrophy conserving scheme' 768 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 826 REAL(wp), DIMENSION(A2D(nn_hls)) :: zwx , zwy 827 REAL(wp), DIMENSION(A2D(nn_hls)) :: ztnw, ztne, ztsw, ztse 828 REAL(wp), DIMENSION(A2D(nn_hls),jpkm1) :: zwz ! 3D workspace, avoid lbc_lnk on jpk that is not defined 829 !!---------------------------------------------------------------------- 830 ! 831 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 832 IF( kt == nit000 ) THEN 833 IF(lwp) WRITE(numout,*) 834 IF(lwp) WRITE(numout,*) 'dyn:vor_eeT : vorticity term: energy and enstrophy conserving scheme' 835 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 836 ENDIF 769 837 ENDIF 770 838 ! … … 776 844 SELECT CASE( kvor ) !== vorticity considered ==! 777 845 CASE ( np_COR ) !* Coriolis (planetary vorticity) 778 DO_2D( 1, 0, 1, 0)846 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 779 847 zwz(ji,jj,jk) = ff_f(ji,jj) 780 848 END_2D 781 849 CASE ( np_RVO ) !* relative vorticity 782 DO_2D( 1, 0, 1, 0 ) 783 zwz(ji,jj,jk) = ( e2v(ji+1,jj ) * pv(ji+1,jj ,jk) - e2v(ji,jj) * pv(ji,jj,jk) & 784 & - e1u(ji ,jj+1) * pu(ji ,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk) ) & 850 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 851 ! round brackets added to fix the order of floating point operations 852 ! needed to ensure halo 1 - halo 2 compatibility 853 zwz(ji,jj,jk) = ( (e2v(ji+1,jj ) * pv(ji+1,jj ,jk) - e2v(ji,jj) * pv(ji,jj,jk)) & 854 & - (e1u(ji ,jj+1) * pu(ji ,jj+1,jk) - e1u(ji,jj) * pu(ji,jj,jk)) ) & 785 855 & * r1_e1e2f(ji,jj) 786 856 END_2D 787 857 IF( ln_dynvor_msk ) THEN ! mask the relative vorticity 788 DO_2D( 1, 0, 1, 0)858 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 789 859 zwz(ji,jj,jk) = zwz(ji,jj,jk) * fmask(ji,jj,jk) 790 860 END_2D 791 861 ENDIF 792 862 CASE ( np_MET ) !* metric term 793 DO_2D( 1, 0, 1, 0)863 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 794 864 zwz(ji,jj,jk) = ( pv(ji+1,jj ,jk) + pv(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj) & 795 865 & - ( pu(ji ,jj+1,jk) + pu(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj) 796 866 END_2D 797 867 CASE ( np_CRV ) !* Coriolis + relative vorticity 798 DO_2D( 1, 0, 1, 0 ) 799 zwz(ji,jj,jk) = ( ff_f(ji,jj) + ( e2v(ji+1,jj ) * pv(ji+1,jj ,jk) - e2v(ji,jj) * pv(ji,jj,jk) & 800 & - e1u(ji ,jj+1) * pu(ji ,jj+1,jk) + e1u(ji,jj) * pu(ji,jj,jk) ) & 801 & * r1_e1e2f(ji,jj) ) 868 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 869 ! round brackets added to fix the order of floating point operations 870 ! needed to ensure halo 1 - halo 2 compatibility 871 zwz(ji,jj,jk) = ( ff_f(ji,jj) + ( (e2v(ji+1,jj ) * pv(ji+1,jj ,jk) - e2v(ji,jj) * pv(ji,jj,jk)) & 872 & - (e1u(ji ,jj+1) * pu(ji ,jj+1,jk) - e1u(ji,jj) * pu(ji,jj,jk)) ) & 873 & * r1_e1e2f(ji,jj) ) 802 874 END_2D 803 875 IF( ln_dynvor_msk ) THEN ! mask the relative vorticity 804 DO_2D( 1, 0, 1, 0)876 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 805 877 zwz(ji,jj,jk) = ( zwz(ji,jj,jk) - ff_f(ji,jj) ) * fmask(ji,jj,jk) + ff_f(ji,jj) 806 878 END_2D 807 879 ENDIF 808 880 CASE ( np_CME ) !* Coriolis + metric 809 DO_2D( 1, 0, 1, 0)881 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 810 882 zwz(ji,jj,jk) = ff_f(ji,jj) + ( pv(ji+1,jj ,jk) + pv(ji,jj,jk) ) * di_e2v_2e1e2f(ji,jj) & 811 883 & - ( pu(ji ,jj+1,jk) + pu(ji,jj,jk) ) * dj_e1u_2e1e2f(ji,jj) … … 819 891 ! ! =============== 820 892 ! 821 CALL lbc_lnk( 'dynvor', zwz, 'F', 1.0_wp )893 IF (nn_hls==1) CALL lbc_lnk( 'dynvor', zwz, 'F', 1.0_wp ) 822 894 ! 823 895 ! ! =============== … … 826 898 ! 827 899 ! !== horizontal fluxes ==! 828 zwx(:,:) = e2u(:,:) * e3u(:,:,jk,Kmm) * pu(:,:,jk) 829 zwy(:,:) = e1v(:,:) * e3v(:,:,jk,Kmm) * pv(:,:,jk) 900 DO_2D( 1, 1, 1, 1 ) 901 zwx(ji,jj) = e2u(ji,jj) * e3u(ji,jj,jk,Kmm) * pu(ji,jj,jk) 902 zwy(ji,jj) = e1v(ji,jj) * e3v(ji,jj,jk,Kmm) * pv(ji,jj,jk) 903 END_2D 830 904 ! 831 905 ! !== compute and add the vorticity term trend =! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynzad.F90
r14072 r14958 60 60 INTEGER :: ji, jj, jk ! dummy loop indices 61 61 REAL(wp) :: zua, zva ! local scalars 62 REAL(wp), DIMENSION( jpi,jpj) :: zww63 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zwuw, zwvw62 REAL(wp), DIMENSION(A2D(nn_hls)) :: zww 63 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zwuw, zwvw 64 64 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztrdu, ztrdv 65 65 !!---------------------------------------------------------------------- … … 67 67 IF( ln_timing ) CALL timing_start('dyn_zad') 68 68 ! 69 IF( kt == nit000 ) THEN 70 IF(lwp) WRITE(numout,*) 71 IF(lwp) WRITE(numout,*) 'dyn_zad : 2nd order vertical advection scheme' 69 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 70 IF( kt == nit000 ) THEN 71 IF(lwp) WRITE(numout,*) 72 IF(lwp) WRITE(numout,*) 'dyn_zad : 2nd order vertical advection scheme' 73 ENDIF 72 74 ENDIF 73 75 … … 79 81 80 82 DO jk = 2, jpkm1 ! Vertical momentum advection at level w and u- and v- vertical 81 DO_2D( 0, 1, 0, 1 ) ! vertical fluxes 82 IF( ln_vortex_force ) THEN 83 zww(ji,jj) = 0.25_wp * e1e2t(ji,jj) * ( ww(ji,jj,jk) + wsd(ji,jj,jk) ) 84 ELSE 85 zww(ji,jj) = 0.25_wp * e1e2t(ji,jj) * ww(ji,jj,jk) 86 ENDIF 87 END_2D 83 IF( ln_vortex_force ) THEN ! vertical fluxes 84 DO_2D( 0, 1, 0, 1 ) 85 zww(ji,jj) = 0.25_wp * e1e2t(ji,jj) * ( ww(ji,jj,jk) + wsd(ji,jj,jk) ) 86 END_2D 87 ELSE 88 DO_2D( 0, 1, 0, 1 ) 89 zww(ji,jj) = 0.25_wp * e1e2t(ji,jj) * ww(ji,jj,jk) 90 END_2D 91 ENDIF 88 92 DO_2D( 0, 0, 0, 0 ) ! vertical momentum advection at w-point 89 93 zwuw(ji,jj,jk) = ( zww(ji+1,jj ) + zww(ji,jj) ) * ( puu(ji,jj,jk-1,Kmm) - puu(ji,jj,jk,Kmm) ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/dynzdf.F90
r13497 r14958 19 19 USE zdfdrg ! vertical physics: top/bottom drag coef. 20 20 USE dynadv ,ONLY: ln_dynadv_vec ! dynamics: advection form 21 #if defined key_loop_fusion 22 USE dynldf_iso_lf,ONLY: akzu, akzv ! dynamics: vertical component of rotated lateral mixing 23 #else 21 24 USE dynldf_iso,ONLY: akzu, akzv ! dynamics: vertical component of rotated lateral mixing 25 #endif 22 26 USE ldfdyn ! lateral diffusion: eddy viscosity coef. and type of operator 23 27 USE trd_oce ! trends: ocean variables … … 78 82 REAL(wp) :: zWui, zWvi ! - - 79 83 REAL(wp) :: zWus, zWvs ! - - 80 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zwi, zwd, zws ! 3D workspace84 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zwi, zwd, zws ! 3D workspace 81 85 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztrdu, ztrdv ! - - 82 86 !!--------------------------------------------------------------------- … … 84 88 IF( ln_timing ) CALL timing_start('dyn_zdf') 85 89 ! 86 IF( kt == nit000 ) THEN !* initialization 87 IF(lwp) WRITE(numout,*) 88 IF(lwp) WRITE(numout,*) 'dyn_zdf_imp : vertical momentum diffusion implicit operator' 89 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ ' 90 ! 91 If( ln_linssh ) THEN ; r_vvl = 0._wp ! non-linear free surface indicator 92 ELSE ; r_vvl = 1._wp 90 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 91 IF( kt == nit000 ) THEN !* initialization 92 IF(lwp) WRITE(numout,*) 93 IF(lwp) WRITE(numout,*) 'dyn_zdf_imp : vertical momentum diffusion implicit operator' 94 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ ' 95 ! 96 If( ln_linssh ) THEN ; r_vvl = 0._wp ! non-linear free surface indicator 97 ELSE ; r_vvl = 1._wp 98 ENDIF 93 99 ENDIF 94 100 ENDIF -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/sshwzv.F90
r14205 r14958 78 78 REAL(wp), DIMENSION(jpi,jpj,jpt), INTENT(inout) :: pssh ! sea-surface height 79 79 ! 80 INTEGER :: j k ! dummy loop index80 INTEGER :: ji, jj, jk ! dummy loop index 81 81 REAL(wp) :: zcoef ! local scalar 82 82 REAL(wp), DIMENSION(jpi,jpj) :: zhdiv ! 2D workspace … … 103 103 ! 104 104 zhdiv(:,:) = 0._wp 105 DO jk = 1, jpkm1! Horizontal divergence of barotropic transports106 zhdiv( :,:) = zhdiv(:,:) + e3t(:,:,jk,Kmm) * hdiv(:,:,jk)107 END DO105 DO_3D( 1, nn_hls, 1, nn_hls, 1, jpkm1 ) ! Horizontal divergence of barotropic transports 106 zhdiv(ji,jj) = zhdiv(ji,jj) + e3t(ji,jj,jk,Kmm) * hdiv(ji,jj,jk) 107 END_3D 108 108 ! ! Sea surface elevation time stepping 109 109 ! In time-split case we need a first guess of the ssh after (using the baroclinic timestep) in order to 110 110 ! compute the vertical velocity which can be used to compute the non-linear terms of the momentum equations. 111 111 ! 112 pssh(:,:,Kaa) = ( pssh(:,:,Kbb) - rDt * ( zcoef * ( emp_b(:,:) + emp(:,:) ) + zhdiv(:,:) ) ) * ssmask(:,:) 112 DO_2D_OVR( 1, nn_hls, 1, nn_hls ) ! Loop bounds limited by hdiv definition in div_hor 113 pssh(ji,jj,Kaa) = ( pssh(ji,jj,Kbb) - rDt * ( zcoef * ( emp_b(ji,jj) + emp(ji,jj) ) + zhdiv(ji,jj) ) ) * ssmask(ji,jj) 114 END_2D 115 ! pssh must be defined everywhere (true for dyn_spg_ts, not for dyn_spg_exp) 116 IF ( .NOT. ln_dynspg_ts .AND. nn_hls == 2 ) CALL lbc_lnk( 'sshwzv', pssh(:,:,Kaa), 'T', 1.0_wp ) 113 117 ! 114 118 #if defined key_agrif … … 119 123 IF ( .NOT.ln_dynspg_ts ) THEN 120 124 IF( ln_bdy ) THEN 121 CALL lbc_lnk( 'sshwzv', pssh(:,:,Kaa), 'T', 1.0_wp ) ! Not sure that's necessary125 IF (nn_hls==1) CALL lbc_lnk( 'sshwzv', pssh(:,:,Kaa), 'T', 1.0_wp ) ! Not sure that's necessary 122 126 CALL bdy_ssh( pssh(:,:,Kaa) ) ! Duplicate sea level across open boundaries 123 127 ENDIF … … 178 182 ! horizontal divergence of thickness diffusion transport ( velocity multiplied by e3t) 179 183 ! - ML - note: computation already done in dom_vvl_sf_nxt. Could be optimized (not critical and clearer this way) 180 DO_2D( 0, 0, 0, 0)184 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 181 185 zhdiv(ji,jj,jk) = r1_e1e2t(ji,jj) * ( un_td(ji,jj,jk) - un_td(ji-1,jj,jk) + vn_td(ji,jj,jk) - vn_td(ji,jj-1,jk) ) 182 186 END_2D 183 187 END DO 184 CALL lbc_lnk('sshwzv', zhdiv, 'T', 1.0_wp) ! - ML - Perhaps not necessary: not used for horizontal "connexions"188 IF (nn_hls==1) CALL lbc_lnk('sshwzv', zhdiv, 'T', 1.0_wp) ! - ML - Perhaps not necessary: not used for horizontal "connexions" 185 189 ! ! Is it problematic to have a wrong vertical velocity in boundary cells? 186 190 ! ! Same question holds for hdiv. Perhaps just for security 187 DO jk = jpkm1, 1, -1! integrate from the bottom the hor. divergence191 DO_3DS( 1, 1, 1, 1, jpkm1, 1, -1 ) ! integrate from the bottom the hor. divergence 188 192 ! computation of w 189 pww( :,:,jk) = pww(:,:,jk+1) - ( e3t(:,:,jk,Kmm) * hdiv(:,:,jk) &190 & + zhdiv(:,:,jk) &191 & + r1_Dt * ( e3t(:,:,jk,Kaa) &192 & - e3t(:,:,jk,Kbb) ) ) * tmask(:,:,jk)193 END DO193 pww(ji,jj,jk) = pww(ji,jj,jk+1) - ( e3t(ji,jj,jk,Kmm) * hdiv(ji,jj,jk) & 194 & + zhdiv(ji,jj,jk) & 195 & + r1_Dt * ( e3t(ji,jj,jk,Kaa) & 196 & - e3t(ji,jj,jk,Kbb) ) ) * tmask(ji,jj,jk) 197 END_3D 194 198 ! IF( ln_vvl_layer ) pww(:,:,:) = 0.e0 195 199 DEALLOCATE( zhdiv ) … … 197 201 ELSEIF( ln_linssh ) THEN !== linear free surface cases ==! 198 202 ! !=================================! 199 DO jk = jpkm1, 1, -1! integrate from the bottom the hor. divergence200 pww( :,:,jk) = pww(:,:,jk+1) - ( e3t(:,:,jk,Kmm) * hdiv(:,:,jk) ) * tmask(:,:,jk)201 END DO203 DO_3DS( 1, 1, 1, 1, jpkm1, 1, -1 ) ! integrate from the bottom the hor. divergence 204 pww(ji,jj,jk) = pww(ji,jj,jk+1) - ( e3t(ji,jj,jk,Kmm) * hdiv(ji,jj,jk) ) * tmask(ji,jj,jk) 205 END_3D 202 206 ! !==========================================! 203 207 ELSE !== Quasi-Eulerian vertical coordinate ==! ('key_qco') 204 208 ! !==========================================! 205 DO jk = jpkm1, 1, -1! integrate from the bottom the hor. divergence206 pww( :,:,jk) = pww(:,:,jk+1) - ( e3t(:,:,jk,Kmm) * hdiv(:,:,jk)&207 & + r1_Dt * ( e3t(:,:,jk,Kaa) &208 & - e3t(:,:,jk,Kbb) ) ) * tmask(:,:,jk)209 END DO209 DO_3DS( 1, 1, 1, 1, jpkm1, 1, -1 ) ! integrate from the bottom the hor. divergence 210 pww(ji,jj,jk) = pww(ji,jj,jk+1) - ( e3t(ji,jj,jk,Kmm) * hdiv(ji,jj,jk) & 211 & + r1_Dt * ( e3t(ji,jj,jk,Kaa) & 212 & - e3t(ji,jj,jk,Kbb) ) ) * tmask(ji,jj,jk) 213 END_3D 210 214 ENDIF 211 215 … … 357 361 zdt = 2._wp * rn_Dt ! 2*rn_Dt and not rDt (for restartability) 358 362 IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN 359 DO_3D( 0, 0, 0, 0, 1, jpkm1 )363 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 360 364 z1_e3t = 1._wp / e3t(ji,jj,jk,Kmm) 361 365 Cu_adv(ji,jj,jk) = zdt * & … … 374 378 END_3D 375 379 ELSE 376 DO_3D( 0, 0, 0, 0, 1, jpkm1 )380 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 377 381 z1_e3t = 1._wp / e3t(ji,jj,jk,Kmm) 378 382 Cu_adv(ji,jj,jk) = zdt * & … … 387 391 END_3D 388 392 ENDIF 389 CALL lbc_lnk( 'sshwzv', Cu_adv, 'T', 1.0_wp )393 IF (nn_hls==1) CALL lbc_lnk( 'sshwzv', Cu_adv, 'T', 1.0_wp ) 390 394 ! 391 395 CALL iom_put("Courant",Cu_adv) 392 396 ! 393 397 IF( MAXVAL( Cu_adv(:,:,:) ) > Cu_min ) THEN ! Quick check if any breaches anywhere 394 DO_3DS( 1, 1, 1, 1, jpkm1, 2, -1 ) ! or scan Courant criterion and partition ! w where necessary398 DO_3DS( nn_hls, nn_hls, nn_hls, nn_hls, jpkm1, 2, -1 ) ! or scan Courant criterion and partition ! w where necessary 395 399 ! 396 400 zCu = MAX( Cu_adv(ji,jj,jk) , Cu_adv(ji,jj,jk-1) ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/DYN/wet_dry.F90
r14433 r14958 117 117 IF( ierr /= 0 ) CALL ctl_stop('STOP', 'wad_init : Array allocation error') 118 118 ENDIF 119 120 IF( ln_tile .AND. ln_wd_il ) CALL ctl_warn('Tiling has not been tested with ln_wd_il = T') 119 121 ! 120 122 END SUBROUTINE wad_init -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ICB/icbdia.F90
r14400 r14958 491 491 SUBROUTINE icb_dia_melt(ki, kj, pmnew, pheat_hcflux, pheat_latent, pmass_scale, & 492 492 & pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, & 493 & pdMv, pz1_dt_e1e2 )493 & pdMv, pz1_dt_e1e2, pz1_e1e2 ) 494 494 !!---------------------------------------------------------------------- 495 495 !!---------------------------------------------------------------------- 496 496 INTEGER , INTENT(in) :: ki, kj 497 497 REAL(wp), INTENT(in) :: pmnew, pheat_hcflux, pheat_latent, pmass_scale 498 REAL(wp), INTENT(in) :: pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, pdMv, pz1_dt_e1e2 498 REAL(wp), INTENT(in) :: pdM, pdMbitsE, pdMbitsM, pdMb, pdMe, pdMv, pz1_dt_e1e2, pz1_e1e2 499 499 !!---------------------------------------------------------------------- 500 500 ! … … 502 502 ! 503 503 berg_melt (ki,kj) = berg_melt (ki,kj) + pdM * pz1_dt_e1e2 ! kg/m2/s 504 berg_melt_hcflx (ki,kj) = berg_melt_hcflx (ki,kj) + pheat_hcflux * pz1_ dt_e1e2 ! J/m2/s505 berg_melt_qlat (ki,kj) = berg_melt_qlat (ki,kj) + pheat_latent * pz1_ dt_e1e2 ! J/m2/s504 berg_melt_hcflx (ki,kj) = berg_melt_hcflx (ki,kj) + pheat_hcflux * pz1_e1e2 ! W/m2 505 berg_melt_qlat (ki,kj) = berg_melt_qlat (ki,kj) + pheat_latent * pz1_e1e2 ! W/m2 506 506 bits_src (ki,kj) = bits_src (ki,kj) + pdMbitsE * pz1_dt_e1e2 ! mass flux into bergy bitskg/m2/s 507 507 bits_melt (ki,kj) = bits_melt (ki,kj) + pdMbitsM * pz1_dt_e1e2 ! melt rate of bergy bits kg/m2/s -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ICB/icbthm.F90
r14030 r14958 241 241 CALL icb_dia_melt( ii, ij, zMnew, zheat_hcflux, zheat_latent, this%mass_scaling, & 242 242 & zdM, zdMbitsE, zdMbitsM, zdMb, zdMe, & 243 & zdMv, z1_dt_e1e2 )243 & zdMv, z1_dt_e1e2, z1_e1e2 ) 244 244 ELSE 245 245 WRITE(numout,*) 'icb_thm: berg ',this%number(:),' appears to have grounded at ',narea,ii,ij -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/IOM/iom.F90
r14553 r14958 2026 2026 IF( iom_use(cdname) ) THEN 2027 2027 #if defined key_xios 2028 CALL xios_send_field( cdname, pfield2d ) 2028 IF( is_tile(pfield2d) == 1 ) THEN 2029 CALL xios_send_field( cdname, pfield2d, ntile - 1 ) 2030 ELSE IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 2031 CALL xios_send_field( cdname, pfield2d ) 2032 ENDIF 2029 2033 #else 2030 2034 WRITE(numout,*) pfield2d ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings … … 2038 2042 IF( iom_use(cdname) ) THEN 2039 2043 #if defined key_xios 2040 CALL xios_send_field( cdname, pfield2d ) 2044 IF( is_tile(pfield2d) == 1 ) THEN 2045 CALL xios_send_field( cdname, pfield2d, ntile - 1 ) 2046 ELSE IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 2047 CALL xios_send_field( cdname, pfield2d ) 2048 ENDIF 2041 2049 #else 2042 2050 WRITE(numout,*) pfield2d ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings … … 2050 2058 IF( iom_use(cdname) ) THEN 2051 2059 #if defined key_xios 2052 CALL xios_send_field( cdname, pfield3d ) 2060 IF( is_tile(pfield3d) == 1 ) THEN 2061 CALL xios_send_field( cdname, pfield3d, ntile - 1 ) 2062 ELSE IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 2063 CALL xios_send_field( cdname, pfield3d ) 2064 ENDIF 2053 2065 #else 2054 2066 WRITE(numout,*) pfield3d ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings … … 2062 2074 IF( iom_use(cdname) ) THEN 2063 2075 #if defined key_xios 2064 CALL xios_send_field( cdname, pfield3d ) 2076 IF( is_tile(pfield3d) == 1 ) THEN 2077 CALL xios_send_field( cdname, pfield3d, ntile - 1 ) 2078 ELSE IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 2079 CALL xios_send_field( cdname, pfield3d ) 2080 ENDIF 2065 2081 #else 2066 2082 WRITE(numout,*) pfield3d ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings … … 2074 2090 IF( iom_use(cdname) ) THEN 2075 2091 #if defined key_xios 2076 CALL xios_send_field (cdname, pfield4d ) 2092 IF( is_tile(pfield4d) == 1 ) THEN 2093 CALL xios_send_field( cdname, pfield4d, ntile - 1 ) 2094 ELSE IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 2095 CALL xios_send_field( cdname, pfield4d ) 2096 ENDIF 2077 2097 #else 2078 2098 WRITE(numout,*) pfield4d ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings … … 2086 2106 IF( iom_use(cdname) ) THEN 2087 2107 #if defined key_xios 2088 CALL xios_send_field (cdname, pfield4d ) 2108 IF( is_tile(pfield4d) == 1 ) THEN 2109 CALL xios_send_field( cdname, pfield4d, ntile - 1 ) 2110 ELSE IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN 2111 CALL xios_send_field( cdname, pfield4d ) 2112 ENDIF 2089 2113 #else 2090 2114 WRITE(numout,*) pfield4d ! iom_use(cdname) = .F. -> useless test to avoid compilation warnings … … 2100 2124 SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, & 2101 2125 & data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask, & 2126 & ntiles, tile_ibegin, tile_jbegin, tile_ni, tile_nj, & 2127 & tile_data_ibegin, tile_data_jbegin, tile_data_ni, tile_data_nj, & 2102 2128 & nvertex, bounds_lon, bounds_lat, area ) 2103 2129 !!---------------------------------------------------------------------- … … 2105 2131 CHARACTER(LEN=*) , INTENT(in) :: cdid 2106 2132 INTEGER , OPTIONAL, INTENT(in) :: ni_glo, nj_glo, ibegin, jbegin, ni, nj 2133 INTEGER, DIMENSION(:) , OPTIONAL, INTENT(in) :: tile_ibegin, tile_jbegin, tile_ni, tile_nj 2134 INTEGER, DIMENSION(:) , OPTIONAL, INTENT(in) :: tile_data_ibegin, tile_data_jbegin, tile_data_ni, tile_data_nj 2107 2135 INTEGER , OPTIONAL, INTENT(in) :: data_dim, data_ibegin, data_ni, data_jbegin, data_nj 2108 INTEGER , OPTIONAL, INTENT(in) :: nvertex 2136 INTEGER , OPTIONAL, INTENT(in) :: nvertex, ntiles 2109 2137 REAL(dp), DIMENSION(:) , OPTIONAL, INTENT(in) :: lonvalue, latvalue 2110 2138 REAL(dp), DIMENSION(:,:), OPTIONAL, INTENT(in) :: bounds_lon, bounds_lat, area … … 2115 2143 CALL xios_set_domain_attr ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & 2116 2144 & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & 2145 & ntiles=ntiles, tile_ibegin=tile_ibegin, tile_jbegin=tile_jbegin, tile_ni=tile_ni, tile_nj=tile_nj, & 2146 & tile_data_ibegin=tile_data_ibegin, tile_data_jbegin=tile_data_jbegin, & 2147 & tile_data_ni=tile_data_ni, tile_data_nj=tile_data_nj, & 2117 2148 & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & 2118 2149 & bounds_lat_1D=bounds_lat, area=area, type='curvilinear') … … 2121 2152 CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj, & 2122 2153 & data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj , & 2154 & ntiles=ntiles, tile_ibegin=tile_ibegin, tile_jbegin=tile_jbegin, tile_ni=tile_ni, tile_nj=tile_nj, & 2155 & tile_data_ibegin=tile_data_ibegin, tile_data_jbegin=tile_data_jbegin, & 2156 & tile_data_ni=tile_data_ni, tile_data_nj=tile_data_nj, & 2123 2157 & lonvalue_1D=lonvalue, latvalue_1D=latvalue, mask_1D=mask, nvertex=nvertex, bounds_lon_1D=bounds_lon, & 2124 2158 & bounds_lat_1D=bounds_lat, area=area, type='curvilinear' ) … … 2288 2322 ! 2289 2323 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zmask 2324 INTEGER :: jn 2325 INTEGER, DIMENSION(nijtile) :: ini, inj, idb 2290 2326 LOGICAL, INTENT(IN) :: ldxios, ldrxios 2291 2327 !!---------------------------------------------------------------------- … … 2293 2329 CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=Ni0glo,nj_glo=Nj0glo,ibegin=mig0(Nis0)-1,jbegin=mjg0(Njs0)-1,ni=Ni_0,nj=Nj_0) 2294 2330 CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = -nn_hls, data_ni=jpi, data_jbegin = -nn_hls, data_nj=jpj) 2331 2332 IF( ln_tile ) THEN 2333 DO jn = 1, nijtile 2334 ini(jn) = ntei_a(jn) - ntsi_a(jn) + 1 ! Tile size in i and j 2335 inj(jn) = ntej_a(jn) - ntsj_a(jn) + 1 2336 idb(jn) = -nn_hls ! Tile data offset (halo size) 2337 END DO 2338 2339 ! Tile_[ij]begin are defined with respect to the processor data domain, so data_[ij]begin is added 2340 CALL iom_set_domain_attr("grid_"//cdgrd, ntiles=nijtile, & 2341 & tile_ibegin=ntsi_a(1:nijtile) + idb(:) - 1, tile_jbegin=ntsj_a(1:nijtile) + idb(:) - 1, & 2342 & tile_ni=ini(:), tile_nj=inj(:), & 2343 & tile_data_ibegin=idb(:), tile_data_jbegin=idb(:), & 2344 & tile_data_ni=ini(:) - 2 * idb(:), tile_data_nj=inj(:) - 2 * idb(:)) 2345 ENDIF 2346 2295 2347 !don't define lon and lat for restart reading context. 2296 2348 IF ( .NOT.ldrxios ) & -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/IOM/restart.F90
r14239 r14958 410 410 ssh(:,:,Kbb) = -ssh_ref 411 411 ! 412 DO_2D( 1, 1, 1, 1)412 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 413 413 IF( ht_0(ji,jj)-ssh_ref < rn_wdmin1 ) THEN ! if total depth is less than min depth 414 414 ssh(ji,jj,Kbb) = rn_wdmin1 - ht_0(ji,jj) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ISF/isfhdiv.F90
r13295 r14958 52 52 IF ( ln_isfpar_mlt ) CALL isf_hdiv_mlt(misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par, fwfisf_par, fwfisf_par_b, phdiv) 53 53 ! 54 ! ice sheet coupling contribution 54 ! ice sheet coupling contribution 55 55 IF ( ln_isfcpl .AND. kt /= 0 ) THEN 56 56 ! … … 91 91 INTEGER :: ji, jj, jk ! dummy loop indices 92 92 INTEGER :: ikt, ikb 93 REAL(wp), DIMENSION( jpi,jpj) :: zhdiv93 REAL(wp), DIMENSION(A2D(nn_hls)) :: zhdiv 94 94 !!---------------------------------------------------------------------- 95 95 ! … … 97 97 ! 98 98 ! compute integrated divergence correction 99 zhdiv(:,:) = 0.5_wp * ( pfwf(:,:) + pfwf_b(:,:) ) * r1_rho0 / phtbl(:,:) 99 DO_2D( nn_hls-1, nn_hls, nn_hls-1, nn_hls ) 100 zhdiv(ji,jj) = 0.5_wp * ( pfwf(ji,jj) + pfwf_b(ji,jj) ) * r1_rho0 / phtbl(ji,jj) 101 END_2D 100 102 ! 101 103 ! update divergence at each level affected by ice shelf top boundary layer 102 DO_2D ( 1, 1, 1, 1)104 DO_2D_OVR( nn_hls-1, nn_hls, nn_hls-1, nn_hls ) 103 105 ikt = ktop(ji,jj) 104 106 ikb = kbot(ji,jj) … … 131 133 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pqvol 132 134 !!---------------------------------------------------------------------- 133 INTEGER :: j k135 INTEGER :: ji, jj, jk 134 136 !!---------------------------------------------------------------------- 135 137 ! 136 DO jk=1,jpk137 phdiv( :,:,jk) = phdiv(:,:,jk) + pqvol(:,:,jk) * r1_e1e2t(:,:) &138 & / e3t( :,:,jk,Kmm)139 END DO138 DO_3D_OVR( nn_hls-1, nn_hls, nn_hls-1, nn_hls, 1, jpk ) 139 phdiv(ji,jj,jk) = phdiv(ji,jj,jk) + pqvol(ji,jj,jk) * r1_e1e2t(ji,jj) & 140 & / e3t(ji,jj,jk,Kmm) 141 END_3D 140 142 ! 141 143 END SUBROUTINE isf_hdiv_cpl -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ISF/isftbl.F90
r14215 r14958 176 176 ! 177 177 ! get htbl 178 DO_2D( 1, 1, 1, 1)178 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 179 179 ! 180 180 ! tbl top/bottom indices initialisation … … 193 193 ! 194 194 ! get pfrac 195 DO_2D( 1, 1, 1, 1)195 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 196 196 ! 197 197 ! tbl top/bottom indices initialisation … … 227 227 ! 228 228 ! get ktbl 229 DO_2D( 1, 1, 1, 1)229 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 230 230 ! 231 231 ! determine the deepest level influenced by the boundary layer … … 261 261 ! test: this routine run with pdep = 0 should return 1 262 262 ! 263 DO_2D( 1, 1, 1, 1)263 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 264 264 ! comput ktop 265 265 ikt = 2 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/LBC/lbc_lnk_neicoll_generic.h90
r14433 r14958 26 26 INTEGER, DIMENSION(8) :: isizej, ishtSj, ishtRj, ishtPj 27 27 INTEGER, DIMENSION(8) :: ifill, iszall 28 INTEGER, DIMENSION(8) :: jnf 28 29 INTEGER, DIMENSION(:), ALLOCATABLE :: iScnt, iRcnt ! number of elements to be sent/received 29 30 INTEGER, DIMENSION(:), ALLOCATABLE :: iSdpl, iRdpl ! displacement in halos arrays … … 192 193 ! 193 194 idx = 1 195 ! MPI3 bug fix when domain decomposition has 2 columns/rows 196 IF (jpni .eq. 2) THEN 197 IF (jpnj .eq. 2) THEN 198 jnf(1:8) = (/ 2, 1, 4, 3, 8, 7, 6, 5 /) 199 ELSE 200 jnf(1:8) = (/ 2, 1, 3, 4, 6, 5, 8, 7 /) 201 ENDIF 202 ELSE 203 IF (jpnj .eq. 2) THEN 204 jnf(1:8) = (/ 1, 2, 4, 3, 7, 8, 5, 6 /) 205 ELSE 206 jnf(1:8) = (/ 1, 2, 3, 4, 5, 6, 7, 8 /) 207 ENDIF 208 ENDIF 209 194 210 DO jn = 1, 8 195 ishti = ishtRi(jn )196 ishtj = ishtRj(jn )197 SELECT CASE ( ifill(jn ) )211 ishti = ishtRi(jnf(jn)) 212 ishtj = ishtRj(jnf(jn)) 213 SELECT CASE ( ifill(jnf(jn)) ) 198 214 CASE ( jpfillnothing ) ! no filling 199 215 CASE ( jpfillmpi ) ! fill with data received by MPI 200 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jn ) ; DO ji = 1,isizei(jn)216 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jnf(jn)) ; DO ji = 1,isizei(jnf(jn)) 201 217 ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = BUFFRCV(idx) 202 218 idx = idx + 1 203 219 END DO ; END DO ; END DO ; END DO ; END DO 204 220 CASE ( jpfillperio ) ! use periodicity 205 ishti2 = ishtPi(jn )206 ishtj2 = ishtPj(jn )207 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jn ) ; DO ji = 1,isizei(jn)221 ishti2 = ishtPi(jnf(jn)) 222 ishtj2 = ishtPj(jnf(jn)) 223 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jnf(jn)) ; DO ji = 1,isizei(jnf(jn)) 208 224 ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl) 209 225 END DO ; END DO ; END DO ; END DO ; END DO 210 226 CASE ( jpfillcopy ) ! filling with inner domain values 211 ishti2 = ishtSi(jn )212 ishtj2 = ishtSj(jn )213 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jn ) ; DO ji = 1,isizei(jn)227 ishti2 = ishtSi(jnf(jn)) 228 ishtj2 = ishtSj(jnf(jn)) 229 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jnf(jn)) ; DO ji = 1,isizei(jnf(jn)) 214 230 ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl) 215 231 END DO ; END DO ; END DO ; END DO ; END DO 216 232 CASE ( jpfillcst ) ! filling with constant value 217 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jn ) ; DO ji = 1,isizei(jn)233 DO jf = 1, ipf ; DO jl = 1, ipl ; DO jk = 1, ipk ; DO jj = 1,isizej(jnf(jn)) ; DO ji = 1,isizei(jnf(jn)) 218 234 ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = zland 219 235 END DO ; END DO ; END DO ; END DO ; END DO -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/LBC/mppini.F90
r14619 r14958 628 628 klci(1:iresti ,:) = kimax 629 629 klci(iresti+1:knbi ,:) = kimax-1 630 IF( MINVAL(klci) < 2*i2hls ) THEN631 WRITE(ctmp1,*) ' mpp_basesplit: minimum value of jpi must be >= ', 2*i2hls630 IF( MINVAL(klci) < 3*khls ) THEN 631 WRITE(ctmp1,*) ' mpp_basesplit: minimum value of jpi must be >= ', 3*khls 632 632 WRITE(ctmp2,*) ' We have ', MINVAL(klci) 633 CALL ctl_stop( 'STOP', ctmp1, ctmp2 )633 CALL ctl_stop( 'STOP', ctmp1, ctmp2 ) 634 634 ENDIF 635 635 IF( l_NFold ) THEN … … 646 646 ENDIF 647 647 klcj(:,1:irestj) = kjmax 648 IF( MINVAL(klcj) < 2*i2hls ) THEN649 WRITE(ctmp1,*) ' mpp_basesplit: minimum value of jpj must be >= ', 2*i2hls648 IF( MINVAL(klcj) < 3*khls ) THEN 649 WRITE(ctmp1,*) ' mpp_basesplit: minimum value of jpj must be >= ', 3*khls 650 650 WRITE(ctmp2,*) ' We have ', MINVAL(klcj) 651 651 CALL ctl_stop( 'STOP', ctmp1, ctmp2 ) … … 725 725 iszjref = jpiglo*jpjglo+1 726 726 ! 727 iszimin = 4*nn_hls ! minimum size of the MPI subdomain so halos are always adressing neighbor inner domain728 iszjmin = 4*nn_hls727 iszimin = 3*nn_hls ! minimum size of the MPI subdomain so halos are always adressing neighbor inner domain 728 iszjmin = 3*nn_hls 729 729 IF( c_NFtype == 'T' ) iszjmin = MAX(iszjmin, 2+3*nn_hls) ! V and F folding must be outside of southern halos 730 730 IF( c_NFtype == 'F' ) iszjmin = MAX(iszjmin, 1+3*nn_hls) ! V and F folding must be outside of southern halos … … 756 756 ENDIF 757 757 END DO 758 IF( inbimax == 0 ) THEN 759 WRITE(ctmp1,'(a,i2,a,i2)') ' mpp_ini bestpartition: Ni0glo (', Ni0glo, ') is too small to be used with nn_hls = ', nn_hls 760 CALL ctl_stop( 'STOP', ctmp1 ) 761 ENDIF 762 IF( inbjmax == 0 ) THEN 763 WRITE(ctmp1,'(a,i2,a,i2)') ' mpp_ini bestpartition: Nj0glo (', Nj0glo, ') is too small to be used with nn_hls = ', nn_hls 764 CALL ctl_stop( 'STOP', ctmp1 ) 765 ENDIF 758 766 759 767 ! combine these 2 lists to get all possible knbi*knbj < inbijmax -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/LDF/ldfc1d_c2d.F90
r14433 r14958 135 135 ! 136 136 CASE( 'DYN' ) ! T- and F-points 137 DO_2D( 1, 1, 1, 1)137 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 138 138 pah1(ji,jj,1) = pUfac * MAX( e1t(ji,jj) , e2t(ji,jj) )**knn 139 139 pah2(ji,jj,1) = pUfac * MAX( e1f(ji,jj) , e2f(ji,jj) )**knn -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/LDF/ldfslp.F90
r14433 r14958 371 371 ! 372 372 ip = jl ; jp = jl ! guaranteed nonzero gradients ( absolute value larger than repsln) 373 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) ! done each pair of triad ! NB: not masked ==> a minimum value is set373 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) ! done each pair of triad ! NB: not masked ==> a minimum value is set 374 374 zdit = ( ts(ji+1,jj,jk,jp_tem,Kbb) - ts(ji,jj,jk,jp_tem,Kbb) ) ! i-gradient of T & S at u-point 375 375 zdis = ( ts(ji+1,jj,jk,jp_sal,Kbb) - ts(ji,jj,jk,jp_sal,Kbb) ) … … 383 383 ! 384 384 IF( ln_zps .AND. l_grad_zps ) THEN ! partial steps: correction of i- & j-grad on bottom 385 DO_2D( 1, 0, 1, 0)385 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 386 386 iku = mbku(ji,jj) ; ikv = mbkv(ji,jj) ! last ocean level (u- & v-points) 387 387 zdit = gtsu(ji,jj,jp_tem) ; zdjt = gtsv(ji,jj,jp_tem) ! i- & j-gradient of Temperature … … 397 397 398 398 DO kp = 0, 1 !== unmasked before density i- j-, k-gradients ==! 399 DO_3D( 1, 1, 1, 1, 1, jpkm1 )! done each pair of triad ! NB: not masked ==> a minimum value is set399 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) ! done each pair of triad ! NB: not masked ==> a minimum value is set 400 400 IF( jk+kp > 1 ) THEN ! k-gradient of T & S a jk+kp 401 401 zdkt = ( ts(ji,jj,jk+kp-1,jp_tem,Kbb) - ts(ji,jj,jk+kp,jp_tem,Kbb) ) … … 412 412 END DO 413 413 ! 414 DO_2D( 1, 1, 1, 1 ) !==Reciprocal depth of the w-point below ML base ==!414 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) !== Reciprocal depth of the w-point below ML base ==! 415 415 jk = MIN( nmln(ji,jj), mbkt(ji,jj) ) + 1 ! MIN in case ML depth is the ocean depth 416 416 z1_mlbw(ji,jj) = 1._wp / gdepw(ji,jj,jk,Kmm) … … 432 432 DO jl = 0, 1 ! calculate slope of the 4 triads immediately ONE level below mixed-layer base 433 433 DO kp = 0, 1 ! with only the slope-max limit and MASKED 434 DO_2D( 1, 0, 1, 0)434 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 435 435 ip = jl ; jp = jl 436 436 ! … … 469 469 ! Must mask contribution to slope from dz/dx at constant s for triads jk=1,kp=0 that poke up though ocean surface 470 470 znot_thru_surface = REAL( 1-1/(jk+kp), wp ) !jk+kp=1,=0.; otherwise=1.0 471 DO_2D( 1, 0, 1, 0)471 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 472 472 ! 473 473 ! Calculate slope relative to geopotentials used for GM skew fluxes -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/LDF/ldftra.F90
r14433 r14958 633 633 INTEGER , INTENT(in ) :: kt ! ocean time-step index 634 634 INTEGER , INTENT(in ) :: Kmm ! ocean time level indices 635 REAL(wp) , INTENT(in out) :: paei0 ! max value [m2/s]635 REAL(wp) , INTENT(in ) :: paei0 ! max value [m2/s] 636 636 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: paeiu, paeiv ! eiv coefficient [m2/s] 637 637 ! 638 638 INTEGER :: ji, jj, jk ! dummy loop indices 639 REAL(wp) :: zfw, ze3w, zn2, z1_f20, z aht, zaht_min, zzaei ! local scalars639 REAL(wp) :: zfw, ze3w, zn2, z1_f20, zzaei ! local scalars 640 640 REAL(wp), DIMENSION(jpi,jpj) :: zn, zah, zhw, zRo, zaeiw ! 2D workspace 641 641 !!---------------------------------------------------------------------- … … 647 647 ! ! Compute lateral diffusive coefficient at T-point 648 648 IF( ln_traldf_triad ) THEN 649 DO_3D( 0, 0, 0, 0, 1, jpk )649 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 650 650 ! Take the max of N^2 and zero then take the vertical sum 651 651 ! of the square root of the resulting N^2 ( required to compute … … 661 661 END_3D 662 662 ELSE 663 DO_3D( 0, 0, 0, 0, 1, jpk )663 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 664 664 ! Take the max of N^2 and zero then take the vertical sum 665 665 ! of the square root of the resulting N^2 ( required to compute … … 677 677 ENDIF 678 678 679 DO_2D( 0, 0, 0, 0)679 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 680 680 zfw = MAX( ABS( 2. * omega * SIN( rad * gphit(ji,jj) ) ) , 1.e-10 ) 681 681 ! Rossby radius at w-point taken betwenn 2 km and 40km … … 687 687 ! !== Bound on eiv coeff. ==! 688 688 z1_f20 = 1._wp / ( 2._wp * omega * sin( rad * 20._wp ) ) 689 DO_2D( 0, 0, 0, 0)689 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 690 690 zzaei = MIN( 1._wp, ABS( ff_t(ji,jj) * z1_f20 ) ) * zaeiw(ji,jj) ! tropical decrease 691 691 zaeiw(ji,jj) = MIN( zzaei , paei0 ) ! Max value = paei0 … … 693 693 CALL lbc_lnk( 'ldftra', zaeiw(:,:), 'W', 1.0_wp ) ! lateral boundary condition 694 694 ! 695 DO_2D( 0, 0, 0, 0 ) !== aei at u- and v-points ==!695 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 696 696 paeiu(ji,jj,1) = 0.5_wp * ( zaeiw(ji,jj) + zaeiw(ji+1,jj ) ) * umask(ji,jj,1) 697 697 paeiv(ji,jj,1) = 0.5_wp * ( zaeiw(ji,jj) + zaeiw(ji ,jj+1) ) * vmask(ji,jj,1) … … 729 729 INTEGER , INTENT(in ) :: Kmm, Krhs ! ocean time level indices 730 730 CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) 731 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: pu ! in : 3 ocean transport components [m3/s] 732 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: pv ! out: 3 ocean transport components [m3/s] 733 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: pw ! increased by the eiv [m3/s] 731 ! TEMP: [tiling] Can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 732 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pu ! in : 3 ocean transport components [m3/s] 733 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pv ! out: 3 ocean transport components [m3/s] 734 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pw ! increased by the eiv [m3/s] 734 735 !! 735 736 INTEGER :: ji, jj, jk ! dummy loop indices … … 739 740 !!---------------------------------------------------------------------- 740 741 ! 741 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile742 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 742 743 IF( kt == kit000 ) THEN 743 744 IF(lwp) WRITE(numout,*) … … 751 752 zpsi_uw(:,:,jpk) = 0._wp ; zpsi_vw(:,:,jpk) = 0._wp 752 753 ! 753 DO_3D( 1, 0, 1, 0, 2, jpkm1 )754 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 2, jpkm1 ) 754 755 zpsi_uw(ji,jj,jk) = - r1_4 * e2u(ji,jj) * ( wslpi(ji,jj,jk ) + wslpi(ji+1,jj,jk) ) & 755 756 & * ( aeiu (ji,jj,jk-1) + aeiu (ji ,jj,jk) ) * wumask(ji,jj,jk) … … 758 759 END_3D 759 760 ! 760 DO_3D ( 1, 0, 1, 0, 1, jpkm1 )761 DO_3D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) 761 762 pu(ji,jj,jk) = pu(ji,jj,jk) - ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji,jj,jk+1) ) 762 763 pv(ji,jj,jk) = pv(ji,jj,jk) - ( zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj,jk+1) ) 763 764 END_3D 764 DO_3D ( 0, 0, 0, 0, 1, jpkm1 )765 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 765 766 pw(ji,jj,jk) = pw(ji,jj,jk) + ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji-1,jj ,jk) & 766 & 767 & + zpsi_vw(ji,jj,jk) - zpsi_vw(ji ,jj-1,jk) ) 767 768 END_3D 768 769 ! … … 783 784 !! 784 785 !!---------------------------------------------------------------------- 785 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(in out) :: psi_uw, psi_vw ! streamfunction [m3/s]786 INTEGER , INTENT(in ) :: Kmm! ocean time level indices786 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(in) :: psi_uw, psi_vw ! streamfunction [m3/s] 787 INTEGER , INTENT(in) :: Kmm ! ocean time level indices 787 788 ! 788 789 INTEGER :: ji, jj, jk ! dummy loop indices -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/OBS/diaobs.F90
r14056 r14958 687 687 & nit000, idaystp, jvar, & 688 688 & zprofvar(:,:,:,jvar), & 689 & gdept(:,:,:,Kmm), gdepw(:,:,:,Kmm), & 689 & gdept(:,:,:,Kmm), gdepw(:,:,:,Kmm), & 690 690 & zprofmask(:,:,:,jvar), & 691 691 & zglam(:,:,jvar), zgphi(:,:,jvar), & -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/SBC/sbcblk.F90
r14433 r14958 892 892 REAL(wp) :: zztmp,zz1,zz2,zz3 ! local variable 893 893 REAL(wp), DIMENSION(jpi,jpj) :: zqlw ! net long wave radiative heat flux 894 !!--------------------------------------------------------------------- 895 ! 896 ! local scalars ( place there for vector optimisation purposes) 897 894 REAL(wp), DIMENSION(jpi,jpj) :: zcptrain, zcptsnw, zcptn ! Heat content per unit mass (J/kg) 895 !!--------------------------------------------------------------------- 896 ! 897 ! Heat content per unit mass (J/kg) 898 zcptrain(:,:) = ( ptair - rt0 ) * rcp * tmask(:,:,1) 899 zcptsnw (:,:) = ( MIN( ptair, rt0 ) - rt0 ) * rcpi * tmask(:,:,1) 900 zcptn (:,:) = ptsk * rcp * tmask(:,:,1) 901 ! 898 902 ! ----------------------------------------------------------------------------- ! 899 903 ! III Net longwave radiative FLUX ! … … 907 911 ! ----------------------------------------------------------------------------- ! 908 912 ! 909 emp (:,:) = ( pevp(:,:) & ! mass flux (evap. - precip.) 910 & - pprec(:,:) * rn_pfac ) * tmask(:,:,1) 911 ! 912 qns(:,:) = zqlw(:,:) + psen(:,:) + plat(:,:) & ! Downward Non Solar 913 & - psnow(:,:) * rn_pfac * rLfus & ! remove latent melting heat for solid precip 914 & - pevp(:,:) * ptsk(:,:) * rcp & ! remove evap heat content at SST 915 & + ( pprec(:,:) - psnow(:,:) ) * rn_pfac & ! add liquid precip heat content at Tair 916 & * ( ptair(:,:) - rt0 ) * rcp & 917 & + psnow(:,:) * rn_pfac & ! add solid precip heat content at min(Tair,Tsnow) 918 & * ( MIN( ptair(:,:), rt0 ) - rt0 ) * rcpi 913 emp (:,:) = ( pevp(:,:) - pprec(:,:) * rn_pfac ) * tmask(:,:,1) ! mass flux (evap. - precip.) 914 ! 915 qns(:,:) = zqlw(:,:) + psen(:,:) + plat(:,:) & ! Downward Non Solar 916 & - psnow(:,:) * rn_pfac * rLfus & ! remove latent melting heat for solid precip 917 & - pevp(:,:) * zcptn(:,:) & ! remove evap heat content at SST 918 & + ( pprec(:,:) - psnow(:,:) ) * rn_pfac * zcptrain(:,:) & ! add liquid precip heat content at Tair 919 & + psnow(:,:) * rn_pfac * zcptsnw(:,:) ! add solid precip heat content at min(Tair,Tsnow) 919 920 qns(:,:) = qns(:,:) * tmask(:,:,1) 920 921 ! … … 1000 1001 ! C-grid ice dynamics : U & V-points (same as ocean) 1001 1002 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 1002 wndm_ice(ji,jj) = SQRT( pwndi(ji,jj) * pwndi(ji,jj) + pwndj(ji,jj) * pwndj(ji,jj) )1003 wndm_ice(ji,jj) = SQRT( pwndi(ji,jj) * pwndi(ji,jj) + pwndj(ji,jj) * pwndj(ji,jj) ) 1003 1004 END_2D 1004 1005 ! … … 1120 1121 REAL(wp), DIMENSION(jpi,jpj,jpl) :: z_dqsb ! sensible heat sensitivity over ice 1121 1122 REAL(wp), DIMENSION(jpi,jpj) :: zevap, zsnw ! evaporation and snw distribution after wind blowing (SI3) 1122 REAL(wp), DIMENSION(jpi,jpj) :: ztmp, ztmp21123 1123 REAL(wp), DIMENSION(jpi,jpj) :: ztri 1124 REAL(wp), DIMENSION(jpi,jpj) :: zcptrain, zcptsnw, zcptn ! Heat content per unit mass (J/kg) 1124 1125 !!--------------------------------------------------------------------- 1125 1126 ! … … 1130 1131 dqla_ice(:,:,:) = 0._wp 1131 1132 1133 ! Heat content per unit mass (J/kg) 1134 zcptrain(:,:) = ( ptair - rt0 ) * rcp * tmask(:,:,1) 1135 zcptsnw (:,:) = ( MIN( ptair, rt0 ) - rt0 ) * rcpi * tmask(:,:,1) 1136 zcptn (:,:) = sst_m * rcp * tmask(:,:,1) 1137 ! 1132 1138 ! ! ========================== ! 1133 1139 DO jl = 1, jpl ! Loop over ice categories ! … … 1205 1211 1206 1212 ! --- heat flux associated with emp --- ! 1207 qemp_oce(:,:) = - ( 1._wp - at_i_b(:,:) ) * zevap(:,:) * sst_m(:,:) * rcp & ! evap at sst 1208 & + ( tprecip(:,:) - sprecip(:,:) ) * ( ptair(:,:) - rt0 ) * rcp & ! liquid precip at Tair 1209 & + sprecip(:,:) * ( 1._wp - zsnw ) * & ! solid precip at min(Tair,Tsnow) 1210 & ( ( MIN( ptair(:,:), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus ) 1211 qemp_ice(:,:) = sprecip(:,:) * zsnw * & ! solid precip (only) 1212 & ( ( MIN( ptair(:,:), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus ) 1213 qemp_oce(:,:) = - ( 1._wp - at_i_b(:,:) ) * zevap(:,:) * zcptn(:,:) & ! evap at sst 1214 & + ( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:) & ! liquid precip at Tair 1215 & + sprecip(:,:) * ( 1._wp - zsnw ) * ( zcptsnw (:,:) - rLfus ) ! solid precip at min(Tair,Tsnow) 1216 qemp_ice(:,:) = sprecip(:,:) * zsnw * ( zcptsnw (:,:) - rLfus ) ! solid precip (only) 1213 1217 1214 1218 ! --- total solar and non solar fluxes --- ! … … 1218 1222 1219 1223 ! --- heat content of precip over ice in J/m3 (to be used in 1D-thermo) --- ! 1220 qprec_ice(:,:) = rhos * ( ( MIN( ptair(:,:), rt0 ) - rt0 ) * rcpi * tmask(:,:,1) - rLfus )1224 qprec_ice(:,:) = rhos * ( zcptsnw(:,:) - rLfus ) 1221 1225 1222 1226 ! --- heat content of evap over ice in W/m2 (to be used in 1D-thermo) --- … … 1250 1254 ! 1251 1255 IF( iom_use('evap_ao_cea') .OR. iom_use('hflx_evap_cea') ) THEN 1252 ztmp(:,:) = zevap(:,:) * ( 1._wp - at_i_b(:,:) ) 1253 IF( iom_use('evap_ao_cea' ) ) CALL iom_put( 'evap_ao_cea' , ztmp(:,:) * tmask(:,:,1) ) ! ice-free oce evap (cell average) 1254 IF( iom_use('hflx_evap_cea') ) CALL iom_put( 'hflx_evap_cea', ztmp(:,:) * sst_m(:,:) * rcp * tmask(:,:,1) ) ! heat flux from evap (cell average) 1255 ENDIF 1256 IF( iom_use('hflx_rain_cea') ) THEN 1257 ztmp(:,:) = rcp * ( SUM( (ptsu-rt0) * a_i_b, dim=3 ) + sst_m(:,:) * ( 1._wp - at_i_b(:,:) ) ) 1258 IF( iom_use('hflx_rain_cea') ) CALL iom_put( 'hflx_rain_cea', ( tprecip(:,:) - sprecip(:,:) ) * ztmp(:,:) ) ! heat flux from rain (cell average) 1259 ENDIF 1260 IF( iom_use('hflx_snow_cea') .OR. iom_use('hflx_snow_ao_cea') .OR. iom_use('hflx_snow_ai_cea') ) THEN 1261 WHERE( SUM( a_i_b, dim=3 ) > 1.e-10 ) 1262 ztmp(:,:) = rcpi * SUM( (ptsu-rt0) * a_i_b, dim=3 ) / SUM( a_i_b, dim=3 ) 1263 ELSEWHERE 1264 ztmp(:,:) = rcp * sst_m(:,:) 1265 ENDWHERE 1266 ztmp2(:,:) = sprecip(:,:) * ( ztmp(:,:) - rLfus ) 1267 IF( iom_use('hflx_snow_cea') ) CALL iom_put('hflx_snow_cea' , ztmp2(:,:) ) ! heat flux from snow (cell average) 1268 IF( iom_use('hflx_snow_ao_cea') ) CALL iom_put('hflx_snow_ao_cea', ztmp2(:,:) * ( 1._wp - zsnw(:,:) ) ) ! heat flux from snow (over ocean) 1269 IF( iom_use('hflx_snow_ai_cea') ) CALL iom_put('hflx_snow_ai_cea', ztmp2(:,:) * zsnw(:,:) ) ! heat flux from snow (over ice) 1256 CALL iom_put( 'evap_ao_cea' , zevap(:,:) * ( 1._wp - at_i_b(:,:) ) * tmask(:,:,1) ) ! ice-free oce evap (cell average) 1257 CALL iom_put( 'hflx_evap_cea', zevap(:,:) * ( 1._wp - at_i_b(:,:) ) * tmask(:,:,1) * zcptn(:,:) ) ! heat flux from evap (cell average) 1258 ENDIF 1259 IF( iom_use('rain') .OR. iom_use('rain_ao_cea') .OR. iom_use('hflx_rain_cea') ) THEN 1260 CALL iom_put( 'rain' , tprecip(:,:) - sprecip(:,:) ) ! liquid precipitation 1261 CALL iom_put( 'rain_ao_cea' , ( tprecip(:,:) - sprecip(:,:) ) * ( 1._wp - at_i_b(:,:) ) ) ! liquid precipitation over ocean (cell average) 1262 CALL iom_put( 'hflx_rain_cea', ( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:) ) ! heat flux from rain (cell average) 1263 ENDIF 1264 IF( iom_use('snow_ao_cea') .OR. iom_use('snow_ai_cea') .OR. & 1265 & iom_use('hflx_snow_cea') .OR. iom_use('hflx_snow_ao_cea') .OR. iom_use('hflx_snow_ai_cea') ) THEN 1266 CALL iom_put( 'snow_ao_cea' , sprecip(:,:) * ( 1._wp - zsnw(:,:) ) ) ! Snow over ice-free ocean (cell average) 1267 CALL iom_put( 'snow_ai_cea' , sprecip(:,:) * zsnw(:,:) ) ! Snow over sea-ice (cell average) 1268 CALL iom_put( 'hflx_snow_cea' , sprecip(:,:) * ( zcptsnw(:,:) - rLfus ) ) ! heat flux from snow (cell average) 1269 CALL iom_put( 'hflx_snow_ao_cea', sprecip(:,:) * ( zcptsnw(:,:) - rLfus ) * ( 1._wp - zsnw(:,:) ) ) ! heat flux from snow (over ocean) 1270 CALL iom_put( 'hflx_snow_ai_cea', sprecip(:,:) * ( zcptsnw(:,:) - rLfus ) * zsnw(:,:) ) ! heat flux from snow (over ice) 1271 ENDIF 1272 IF( iom_use('hflx_prec_cea') ) THEN ! heat flux from precip (cell average) 1273 CALL iom_put('hflx_prec_cea' , sprecip(:,:) * ( zcptsnw (:,:) - rLfus ) & 1274 & + ( tprecip(:,:) - sprecip(:,:) ) * zcptrain(:,:) ) 1275 ENDIF 1276 IF( iom_use('subl_ai_cea') .OR. iom_use('hflx_subl_cea') ) THEN 1277 CALL iom_put( 'subl_ai_cea' , SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) * tmask(:,:,1) ) ! Sublimation over sea-ice (cell average) 1278 CALL iom_put( 'hflx_subl_cea', SUM( a_i_b(:,:,:) * qevap_ice(:,:,:), dim=3 ) * tmask(:,:,1) ) ! Heat flux from sublimation (cell average) 1270 1279 ENDIF 1271 1280 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/SBC/sbccpl.F90
r14595 r14958 1301 1301 IF( llnewtau ) THEN 1302 1302 zcoef = 1. / ( zrhoa * zcdrag ) 1303 DO_2D( 1, 1, 1, 1)1303 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 1304 1304 frcv(jpr_w10m)%z3(ji,jj,1) = SQRT( frcv(jpr_taum)%z3(ji,jj,1) * zcoef ) 1305 1305 END_2D … … 1924 1924 IF( iom_use('snow_ao_cea') ) CALL iom_put( 'snow_ao_cea' , sprecip(:,:) * ( 1._wp - zsnw(:,:) ) ) ! Snow over ice-free ocean (cell average) 1925 1925 IF( iom_use('snow_ai_cea') ) CALL iom_put( 'snow_ai_cea' , sprecip(:,:) * zsnw(:,:) ) ! Snow over sea-ice (cell average) 1926 IF( iom_use('rain_ao_cea') ) CALL iom_put( 'rain_ao_cea' , ( tprecip(:,:) - sprecip(:,:) ) * picefr(:,:) ) ! liquid precipitation over ocean (cell average)1927 IF( iom_use('subl_ai_cea') ) CALL iom_put( 'subl_ai_cea' , frcv(jpr_ievp)%z3(:,:,1) * picefr(:,:) * tmask(:,:,1) )! Sublimation over sea-ice (cell average)1926 IF( iom_use('rain_ao_cea') ) CALL iom_put( 'rain_ao_cea' , ( tprecip(:,:) - sprecip(:,:) ) * ziceld(:,:) ) ! liquid precipitation over ocean (cell average) 1927 IF( iom_use('subl_ai_cea') ) CALL iom_put( 'subl_ai_cea' , zevap_ice_total(:,:) * picefr(:,:) * tmask(:,:,1) ) ! Sublimation over sea-ice (cell average) 1928 1928 IF( iom_use('evap_ao_cea') ) CALL iom_put( 'evap_ao_cea' , ( frcv(jpr_tevp)%z3(:,:,1) & 1929 & - frcv(jpr_ievp)%z3(:,:,1) * picefr(:,:) ) * tmask(:,:,1) )! ice-free oce evap (cell average)1929 & - zevap_ice_total(:,:) * picefr(:,:) ) * tmask(:,:,1) ) ! ice-free oce evap (cell average) 1930 1930 ! note: runoff output is done in sbcrnf (which includes icebergs too) and iceshelf output is done in sbcisf 1931 1931 !! IF( srcv(jpr_rnf)%laction ) CALL iom_put( 'runoffs' , rnf(:,:) * tmask(:,:,1) ) ! runoff … … 2100 2100 IF ( iom_use('hflx_snow_ai_cea') ) & ! heat flux from snow (over ice) 2101 2101 & CALL iom_put('hflx_snow_ai_cea', sprecip(:,:) * ( zcptsnw(:,:) - rLfus ) * zsnw(:,:) ) 2102 IF( iom_use('hflx_subl_cea') ) & ! heat flux from sublimation 2103 & CALL iom_put('hflx_subl_cea' , SUM( qevap_ice(:,:,:) * a_i(:,:,:), dim=3 ) * tmask(:,:,1) ) 2102 2104 ! note: hflx for runoff and iceshelf are done in sbcrnf and sbcisf resp. 2103 2105 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/SBC/sbcfwb.F90
r14130 r14958 123 123 emp(:,:) = emp(:,:) - z_fwfprv(1) * tmask(:,:,1) 124 124 qns(:,:) = qns(:,:) + zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction 125 ! outputs 126 IF( iom_use('hflx_fwb_cea') ) CALL iom_put( 'hflx_fwb_cea', zcoef * sst_m(:,:) * tmask(:,:,1) ) 127 IF( iom_use('vflx_fwb_cea') ) CALL iom_put( 'vflx_fwb_cea', z_fwfprv(1) * tmask(:,:,1) ) 125 128 ENDIF 126 129 ! … … 154 157 emp(:,:) = emp(:,:) + a_fwb * tmask(:,:,1) 155 158 qns(:,:) = qns(:,:) - zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction 159 ! outputs 160 IF( iom_use('hflx_fwb_cea') ) CALL iom_put( 'hflx_fwb_cea', -zcoef * sst_m(:,:) * tmask(:,:,1) ) 161 IF( iom_use('vflx_fwb_cea') ) CALL iom_put( 'vflx_fwb_cea', -a_fwb * tmask(:,:,1) ) 156 162 ENDIF 157 163 ! Output restart information … … 201 207 qns(:,:) = qns(:,:) - zerp_cor(:,:) * rcp * sst_m(:,:) ! account for change to the heat budget due to fw correction 202 208 erp(:,:) = erp(:,:) + zerp_cor(:,:) 209 ! outputs 210 IF( iom_use('hflx_fwb_cea') ) CALL iom_put( 'hflx_fwb_cea', -zerp_cor(:,:) * rcp * sst_m(:,:) ) 211 IF( iom_use('vflx_fwb_cea') ) CALL iom_put( 'vflx_fwb_cea', -zerp_cor(:,:) ) 203 212 ! 204 213 IF( lwp ) THEN ! control print -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/SBC/sbcmod.F90
r14229 r14958 475 475 END SELECT 476 476 477 IF( ln_icebergs ) THEN 478 CALL icb_stp( kt, Kmm ) ! compute icebergs 479 ! Icebergs do not melt over the haloes. 480 ! So emp values over the haloes are no more consistent with the inner domain values. 481 ! A lbc_lnk is therefore needed to ensure reproducibility and restartability. 482 ! see ticket #2113 for discussion about this lbc_lnk. 483 IF( .NOT. ln_passive_mode ) CALL lbc_lnk( 'sbcmod', emp, 'T', 1.0_wp ) ! ensure restartability with icebergs 477 IF( ln_icebergs ) CALL icb_stp( kt, Kmm ) ! compute icebergs 478 479 ! Icebergs do not melt over the haloes. 480 ! So emp values over the haloes are no more consistent with the inner domain values. 481 ! A lbc_lnk is therefore needed to ensure reproducibility and restartability. 482 ! see ticket #2113 for discussion about this lbc_lnk. 483 ! The lbc_lnk is also needed for SI3 with nn_hls > 1 as emp is not yet defined for these points in iceupdate.F90 484 IF( (ln_icebergs .AND. .NOT. ln_passive_mode) .OR. (nn_ice == 2 .AND. nn_hls == 2) ) THEN 485 CALL lbc_lnk( 'sbcmod', emp, 'T', 1.0_wp ) 484 486 ENDIF 485 487 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/SBC/sbcrnf.F90
r14072 r14958 131 131 IF( ln_rnf_icb ) THEN 132 132 fwficb(:,:) = rn_rfact * ( sf_i_rnf(1)%fnow(:,:,1) ) * tmask(:,:,1) ! updated runoff value at time step kt 133 CALL iom_put( 'iceberg_cea' , fwficb(:,:) ) ! output iceberg flux 134 CALL iom_put( 'hflx_icb_cea' , fwficb(:,:) * rLfus ) ! output Heat Flux into Sea Water due to Iceberg Thermodynamics --> 133 rnf(:,:) = rnf(:,:) + fwficb(:,:) 134 qns(:,:) = qns(:,:) - fwficb(:,:) * rLfus 135 !!qns_tot(:,:) = qns_tot(:,:) - fwficb(:,:) * rLfus 136 !!qns_oce(:,:) = qns_oce(:,:) - fwficb(:,:) * rLfus 137 CALL iom_put( 'iceberg_cea' , fwficb(:,:) ) ! output iceberg flux 138 CALL iom_put( 'hflx_icb_cea' , -fwficb(:,:) * rLfus ) ! output Heat Flux into Sea Water due to Iceberg Thermodynamics --> 135 139 ENDIF 136 140 ENDIF … … 152 156 CALL iom_put( 'runoffs' , rnf(:,:) ) ! output runoff mass flux 153 157 IF( iom_use('hflx_rnf_cea') ) CALL iom_put( 'hflx_rnf_cea', rnf_tsc(:,:,jp_tem) * rho0 * rcp ) ! output runoff sensible heat (W/m2) 158 IF( iom_use('sflx_rnf_cea') ) CALL iom_put( 'sflx_rnf_cea', rnf_tsc(:,:,jp_sal) * rho0 ) ! output runoff salt flux (g/m2/s) 154 159 ENDIF 155 160 ! … … 206 211 IF( ln_rnf_depth .OR. ln_rnf_depth_ini ) THEN !== runoff distributed over several levels ==! 207 212 IF( ln_linssh ) THEN !* constant volume case : just apply the runoff input flow 208 DO_2D ( 1, 1, 1, 1)213 DO_2D_OVR( nn_hls-1, nn_hls, nn_hls-1, nn_hls ) 209 214 DO jk = 1, nk_rnf(ji,jj) 210 215 phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - ( rnf(ji,jj) + rnf_b(ji,jj) ) * zfact * r1_rho0 / h_rnf(ji,jj) … … 212 217 END_2D 213 218 ELSE !* variable volume case 214 DO_2D ( 1, 1, 1, 1 )! update the depth over which runoffs are distributed219 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) ! update the depth over which runoffs are distributed 215 220 h_rnf(ji,jj) = 0._wp 216 221 DO jk = 1, nk_rnf(ji,jj) ! recalculates h_rnf to be the depth in metres … … 224 229 ENDIF 225 230 ELSE !== runoff put only at the surface ==! 226 h_rnf (:,:) = e3t (:,:,1,Kmm) ! update h_rnf to be depth of top box 227 phdivn(:,:,1) = phdivn(:,:,1) - ( rnf(:,:) + rnf_b(:,:) ) * zfact * r1_rho0 / e3t(:,:,1,Kmm) 231 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 232 h_rnf (ji,jj) = e3t (ji,jj,1,Kmm) ! update h_rnf to be depth of top box 233 phdivn(ji,jj,1) = phdivn(ji,jj,1) - ( rnf(ji,jj) + rnf_b(ji,jj) ) * zfact * r1_rho0 / e3t(ji,jj,1,Kmm) 234 END_2D 228 235 ENDIF 229 236 ! … … 358 365 ! 359 366 nk_rnf(:,:) = 0 ! set the number of level over which river runoffs are applied 360 DO_2D( 1, 1, 1, 1)367 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 361 368 IF( h_rnf(ji,jj) > 0._wp ) THEN 362 369 jk = 2 … … 371 378 ENDIF 372 379 END_2D 373 DO_2D( 1, 1, 1, 1) ! set the associated depth380 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! set the associated depth 374 381 h_rnf(ji,jj) = 0._wp 375 382 DO jk = 1, nk_rnf(ji,jj) … … 401 408 WHERE( zrnfcl(:,:,1) > 0._wp ) h_rnf(:,:) = zacoef * zrnfcl(:,:,1) ! compute depth for all runoffs 402 409 ! 403 DO_2D( 1, 1, 1, 1) ! take in account min depth of ocean rn_hmin410 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! take in account min depth of ocean rn_hmin 404 411 IF( zrnfcl(ji,jj,1) > 0._wp ) THEN 405 412 jk = mbkt(ji,jj) … … 409 416 ! 410 417 nk_rnf(:,:) = 0 ! number of levels on which runoffs are distributed 411 DO_2D( 1, 1, 1, 1)418 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 412 419 IF( zrnfcl(ji,jj,1) > 0._wp ) THEN 413 420 jk = 2 … … 420 427 END_2D 421 428 ! 422 DO_2D( 1, 1, 1, 1) ! set the associated depth429 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! set the associated depth 423 430 h_rnf(ji,jj) = 0._wp 424 431 DO jk = 1, nk_rnf(ji,jj) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/SBC/sbcssr.F90
r13295 r14958 94 94 ! ! ========================= ! 95 95 ! 96 qrp(:,:) = 0._wp ! necessary init 97 erp(:,:) = 0._wp 98 ! 96 99 IF( nn_sstr == 1 ) THEN !* Temperature restoring term 97 DO_2D( 1, 1, 1, 1)100 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 98 101 zqrp = rn_dqdt * ( sst_m(ji,jj) - sf_sst(1)%fnow(ji,jj,1) ) * tmask(ji,jj,1) 99 102 qns(ji,jj) = qns(ji,jj) + zqrp … … 105 108 ! use fraction of ice ( fr_i ) to adjust relaxation under ice if nn_sssr_ice .ne. 1 106 109 ! n.b. coefice is initialised and fixed to 1._wp if nn_sssr_ice = 1 107 DO_2D( 1, 1, 1, 1)110 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 108 111 SELECT CASE ( nn_sssr_ice ) 109 112 CASE ( 0 ) ; coefice(ji,jj) = 1._wp - fr_i(ji,jj) ! no/reduced damping under ice … … 115 118 IF( nn_sssr == 1 ) THEN !* Salinity damping term (salt flux only (sfx)) 116 119 zsrp = rn_deds / rday ! from [mm/day] to [kg/m2/s] 117 DO_2D( 1, 1, 1, 1)120 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 118 121 zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths 119 122 & * coefice(ji,jj) & ! Optional control of damping under sea-ice … … 126 129 zsrp = rn_deds / rday ! from [mm/day] to [kg/m2/s] 127 130 zerp_bnd = rn_sssr_bnd / rday ! - - 128 DO_2D( 1, 1, 1, 1)131 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 129 132 zerp = zsrp * ( 1. - 2.*rnfmsk(ji,jj) ) & ! No damping in vicinity of river mouths 130 133 & * coefice(ji,jj) & ! Optional control of damping under sea-ice … … 135 138 qns(ji,jj) = qns(ji,jj) - zerp * rcp * sst_m(ji,jj) 136 139 erp(ji,jj) = zerp 140 qrp(ji,jj) = qrp(ji,jj) - zerp * rcp * sst_m(ji,jj) 137 141 END_2D 138 142 ENDIF 143 ! outputs 144 CALL iom_put( 'hflx_ssr_cea', qrp(:,:) ) 145 IF( nn_sssr == 1 ) CALL iom_put( 'sflx_ssr_cea', erp(:,:) * sss_m(:,:) ) 146 IF( nn_sssr == 2 ) CALL iom_put( 'vflx_ssr_cea', -erp(:,:) ) 139 147 ! 140 148 ENDIF -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/eosbn2.F90
r14131 r14958 577 577 578 578 SUBROUTINE eos_insitu_pot_2d( pts, prhop ) 579 !! 580 REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pts ! 1 : potential temperature [Celsius] 581 ! ! 2 : salinity [psu] 582 REAL(wp), DIMENSION(:,:) , INTENT( out) :: prhop ! potential density (surface referenced) 583 !! 584 CALL eos_insitu_pot_2d_t( pts, is_tile(pts), prhop, is_tile(prhop) ) 585 END SUBROUTINE eos_insitu_pot_2d 586 587 588 SUBROUTINE eos_insitu_pot_2d_t( pts, ktts, prhop, ktrhop ) 579 589 !!---------------------------------------------------------------------- 580 590 !! *** ROUTINE eos_insitu_pot *** … … 589 599 !! 590 600 !!---------------------------------------------------------------------- 591 REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in ) :: pts ! 1 : potential temperature [Celsius] 601 INTEGER , INTENT(in ) :: ktts, ktrhop 602 REAL(wp), DIMENSION(A2D_T(ktts),JPTS), INTENT(in ) :: pts ! 1 : potential temperature [Celsius] 592 603 ! ! 2 : salinity [psu] 593 REAL(wp), DIMENSION( jpi,jpj), INTENT( out) :: prhop ! potential density (surface referenced)604 REAL(wp), DIMENSION(A2D_T(ktrhop) ), INTENT( out) :: prhop ! potential density (surface referenced) 594 605 ! 595 606 INTEGER :: ji, jj, jk, jsmp ! dummy loop indices … … 606 617 CASE( np_teos10, np_eos80 ) !== polynomial TEOS-10 / EOS-80 ==! 607 618 ! 608 DO_2D( 1, 1, 1, 1)609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 619 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 620 ! 621 zt = pts (ji,jj,jp_tem) * r1_T0 ! temperature 622 zs = SQRT( ABS( pts(ji,jj,jp_sal) + rdeltaS ) * r1_S0 ) ! square root salinity 623 ztm = tmask(ji,jj,1) ! tmask 624 ! 625 zn0 = (((((EOS060*zt & 626 & + EOS150*zs+EOS050)*zt & 627 & + (EOS240*zs+EOS140)*zs+EOS040)*zt & 628 & + ((EOS330*zs+EOS230)*zs+EOS130)*zs+EOS030)*zt & 629 & + (((EOS420*zs+EOS320)*zs+EOS220)*zs+EOS120)*zs+EOS020)*zt & 630 & + ((((EOS510*zs+EOS410)*zs+EOS310)*zs+EOS210)*zs+EOS110)*zs+EOS010)*zt & 631 & + (((((EOS600*zs+EOS500)*zs+EOS400)*zs+EOS300)*zs+EOS200)*zs+EOS100)*zs+EOS000 632 ! 633 ! 634 prhop(ji,jj) = zn0 * ztm ! potential density referenced at the surface 635 ! 636 END_2D 626 637 627 638 CASE( np_seos ) !== simplified EOS ==! 628 639 ! 629 DO_2D( 1, 1, 1, 1)640 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 630 641 zt = pts (ji,jj,jp_tem) - 10._wp 631 642 zs = pts (ji,jj,jp_sal) - 35._wp … … 646 657 IF( ln_timing ) CALL timing_stop('eos-pot') 647 658 ! 648 END SUBROUTINE eos_insitu_pot_2d 659 END SUBROUTINE eos_insitu_pot_2d_t 649 660 650 661 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traadv.F90
r14433 r14958 18 18 USE oce ! ocean dynamics and active tracers 19 19 USE dom_oce ! ocean space and time domain 20 ! TEMP: [tiling] This change not necessary after extended haloes development20 ! TEMP: [tiling] This change not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 21 21 USE domtile 22 22 USE domvvl ! variable vertical scale factors … … 25 25 USE traadv_cen ! centered scheme (tra_adv_cen routine) 26 26 USE traadv_fct ! FCT scheme (tra_adv_fct routine) 27 USE traadv_fct_lf ! FCT scheme (tra_adv_fct routine - loop fusion version)28 27 USE traadv_mus ! MUSCL scheme (tra_adv_mus routine) 29 USE traadv_mus_lf ! MUSCL scheme (tra_adv_mus routine - loop fusion version)30 28 USE traadv_ubs ! UBS scheme (tra_adv_ubs routine) 31 29 USE traadv_qck ! QUICKEST scheme (tra_adv_qck routine) … … 61 59 LOGICAL :: ln_traadv_qck ! QUICKEST scheme flag 62 60 63 INTEGER :: nadv ! choice of the type of advection scheme61 INTEGER, PUBLIC :: nadv ! choice of the type of advection scheme 64 62 ! ! associated indices: 65 INTEGER, PARAMETER :: np_NO_adv = 0 ! no T-S advection66 INTEGER, PARAMETER :: np_CEN = 1 ! 2nd/4th order centered scheme67 INTEGER, PARAMETER :: np_FCT = 2 ! 2nd/4th order Flux Corrected Transport scheme68 INTEGER, PARAMETER :: np_MUS = 3 ! MUSCL scheme69 INTEGER, PARAMETER :: np_UBS = 4 ! 3rd order Upstream Biased Scheme70 INTEGER, PARAMETER :: np_QCK = 5 ! QUICK scheme63 INTEGER, PARAMETER, PUBLIC :: np_NO_adv = 0 ! no T-S advection 64 INTEGER, PARAMETER, PUBLIC :: np_CEN = 1 ! 2nd/4th order centered scheme 65 INTEGER, PARAMETER, PUBLIC :: np_FCT = 2 ! 2nd/4th order Flux Corrected Transport scheme 66 INTEGER, PARAMETER, PUBLIC :: np_MUS = 3 ! MUSCL scheme 67 INTEGER, PARAMETER, PUBLIC :: np_UBS = 4 ! 3rd order Upstream Biased Scheme 68 INTEGER, PARAMETER, PUBLIC :: np_QCK = 5 ! QUICK scheme 71 69 72 70 !! * Substitutions … … 93 91 ! 94 92 INTEGER :: ji, jj, jk ! dummy loop index 95 ! TEMP: [tiling] This change not necessary and can be A2D(nn_hls) if using XIOS (subdomain support)93 ! TEMP: [tiling] This change not necessary and can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 96 94 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, SAVE :: zuu, zvv, zww ! 3D workspace 97 95 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztrdt, ztrds 98 ! TEMP: [tiling] This change not necessary after extra haloes development96 ! TEMP: [tiling] This change not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 99 97 LOGICAL :: lskip 100 98 !!---------------------------------------------------------------------- … … 104 102 lskip = .FALSE. 105 103 106 ! TEMP: [tiling] These changes not necessary if using XIOS (subdomain support)107 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile104 ! TEMP: [tiling] These changes not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 105 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 108 106 ALLOCATE( zuu(jpi,jpj,jpk), zvv(jpi,jpj,jpk), zww(jpi,jpj,jpk) ) 109 107 ENDIF 110 108 111 ! TEMP: [tiling] These changes not necessary after extra haloes development (lbc_lnk removed from tra_adv_*) and if XIOS has subdomain support (ldf_eiv_dia) 112 IF( nadv /= np_CEN .OR. (nadv == np_CEN .AND. nn_cen_h == 4) .OR. ln_ldfeiv_dia ) THEN 113 IF( ln_tile ) THEN 114 IF( ntile == 1 ) THEN 115 CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) 116 ELSE 117 lskip = .TRUE. 118 ENDIF 109 ! TEMP: [tiling] These changes not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 110 IF( ln_tile .AND. nadv == np_FCT ) THEN 111 IF( ntile == 1 ) THEN 112 CALL dom_tile_stop( ldhold=.TRUE. ) 113 ELSE 114 lskip = .TRUE. 119 115 ENDIF 120 116 ENDIF … … 122 118 ! !== effective transport ==! 123 119 IF( ln_wave .AND. ln_sdw ) THEN 124 DO_3D ( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 )120 DO_3D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) 125 121 zuu(ji,jj,jk) = e2u (ji,jj) * e3u(ji,jj,jk,Kmm) * ( uu(ji,jj,jk,Kmm) + usd(ji,jj,jk) ) 126 122 zvv(ji,jj,jk) = e1v (ji,jj) * e3v(ji,jj,jk,Kmm) * ( vv(ji,jj,jk,Kmm) + vsd(ji,jj,jk) ) … … 128 124 END_3D 129 125 ELSE 130 DO_3D ( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 )126 DO_3D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) 131 127 zuu(ji,jj,jk) = e2u (ji,jj) * e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) ! eulerian transport only 132 128 zvv(ji,jj,jk) = e1v (ji,jj) * e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) … … 136 132 ! 137 133 IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN ! add z-tilde and/or vvl corrections 138 DO_3D ( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 )134 DO_3D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) 139 135 zuu(ji,jj,jk) = zuu(ji,jj,jk) + un_td(ji,jj,jk) 140 136 zvv(ji,jj,jk) = zvv(ji,jj,jk) + vn_td(ji,jj,jk) … … 142 138 ENDIF 143 139 ! 144 DO_2D ( nn_hls, nn_hls, nn_hls, nn_hls)140 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 145 141 zuu(ji,jj,jpk) = 0._wp ! no transport trough the bottom 146 142 zvv(ji,jj,jpk) = 0._wp … … 148 144 END_2D 149 145 ! 150 ! TEMP: [tiling] These changes not necessary if using XIOS (subdomain support)151 146 IF( ln_ldfeiv .AND. .NOT. ln_traldf_triad ) & 152 & CALL ldf_eiv_trp( kt, nit000, zuu(A2D(nn_hls),:), zvv(A2D(nn_hls),:), zww(A2D(nn_hls),:), & 153 & 'TRA', Kmm, Krhs ) ! add the eiv transport (if necessary) 154 ! 155 IF( ln_mle ) CALL tra_mle_trp( kt, nit000, zuu(A2D(nn_hls),:), zvv(A2D(nn_hls),:), zww(A2D(nn_hls),:), & 156 & 'TRA', Kmm ) ! add the mle transport (if necessary) 157 ! 158 ! TEMP: [tiling] This change not necessary if using XIOS (subdomain support) 159 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 147 & CALL ldf_eiv_trp( kt, nit000, zuu, zvv, zww, 'TRA', Kmm, Krhs ) ! add the eiv transport (if necessary) 148 ! 149 IF( ln_mle ) CALL tra_mle_trp( kt, nit000, zuu, zvv, zww, 'TRA', Kmm ) ! add the mle transport (if necessary) 150 ! 151 ! TEMP: [tiling] This change not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 152 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 160 153 CALL iom_put( "uocetr_eff", zuu ) ! output effective transport 161 154 CALL iom_put( "vocetr_eff", zvv ) … … 163 156 ENDIF 164 157 ! 165 166 ! TEMP: [tiling] This c hange not necessary if using XIOS (subdomain support)158 !!gm ??? 159 ! TEMP: [tiling] This copy-in not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 167 160 CALL dia_ptr( kt, Kmm, zvv(A2D(nn_hls),:) ) ! diagnose the effective MSF 168 161 !!gm ??? 169 162 ! 170 163 … … 178 171 ! 179 172 CASE ( np_CEN ) ! Centered scheme : 2nd / 4th order 180 IF (nn_hls.EQ.2) CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kmm), 'T', 1. )181 173 CALL tra_adv_cen ( kt, nit000, 'TRA', zuu, zvv, zww, Kmm, pts, jpts, Krhs, nn_cen_h, nn_cen_v ) 182 174 CASE ( np_FCT ) ! FCT scheme : 2nd / 4th order 183 IF (nn_hls.EQ.2) THEN184 CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1., pts(:,:,:,:,Kmm), 'T', 1.)185 CALL lbc_lnk( 'traadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1., zww(:,:,:), 'W', 1.)186 #if defined key_loop_fusion187 CALL tra_adv_fct_lf ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, nn_fct_h, nn_fct_v )188 #else189 175 CALL tra_adv_fct ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, nn_fct_h, nn_fct_v ) 190 #endif191 ELSE192 CALL tra_adv_fct ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, nn_fct_h, nn_fct_v )193 END IF194 176 CASE ( np_MUS ) ! MUSCL 195 IF (nn_hls.EQ.2) THEN196 CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1.)197 #if defined key_loop_fusion198 CALL tra_adv_mus_lf ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, ln_mus_ups )199 #else200 177 CALL tra_adv_mus ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, ln_mus_ups ) 201 #endif202 ELSE203 CALL tra_adv_mus ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, ln_mus_ups )204 END IF205 178 CASE ( np_UBS ) ! UBS 206 IF (nn_hls.EQ.2) CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1.)207 179 CALL tra_adv_ubs ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, nn_ubs_v ) 208 180 CASE ( np_QCK ) ! QUICKEST 209 IF (nn_hls.EQ.2) THEN210 CALL lbc_lnk( 'traadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1.)211 CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1.)212 END IF213 181 CALL tra_adv_qck ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs ) 214 182 ! … … 225 193 ENDIF 226 194 227 ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed from tra_adv_*) and if XIOS has subdomain support (ldf_eiv_dia) 228 IF( ln_tile .AND. ntile == 0 ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 1 ) 229 195 ! TEMP: [tiling] This change not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 196 IF( ln_tile .AND. .NOT. l_istiled ) CALL dom_tile_start( ldhold=.TRUE. ) 230 197 ENDIF 231 198 ! ! print mean trends (used for debugging) … … 233 200 & tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2= ' Sa: ', mask2=tmask, clinfo3='tra' ) 234 201 235 ! TEMP: [tiling] This change not necessary if using XIOS (subdomain support)236 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only for the full domain202 ! TEMP: [tiling] This change not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 203 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only for the full domain 237 204 DEALLOCATE( zuu, zvv, zww ) 238 205 ENDIF … … 306 273 CALL ctl_stop( 'tra_adv_init: FCT scheme, choose 2nd or 4th order' ) 307 274 ENDIF 275 ! TEMP: [tiling] This change not necessary after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 276 IF( ln_traadv_fct .AND. ln_tile ) THEN 277 CALL ctl_warn( 'tra_adv_init: FCT scheme does not yet work with tiling' ) 278 ENDIF 308 279 IF( ln_traadv_ubs .AND. ( nn_ubs_v /= 2 .AND. nn_ubs_v /= 4 ) ) THEN ! UBS 309 280 CALL ctl_stop( 'tra_adv_init: UBS scheme, choose 2nd or 4th order' ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traadv_cen.F90
r14433 r14958 23 23 USE trc_oce ! share passive tracers/Ocean variables 24 24 USE lib_mpp ! MPP library 25 #if defined key_loop_fusion 26 USE traadv_cen_lf ! centered scheme (tra_adv_cen routine - loop fusion version) 27 #endif 25 28 26 29 IMPLICIT NONE … … 71 74 INTEGER , INTENT(in ) :: kn_cen_h ! =2/4 (2nd or 4th order scheme) 72 75 INTEGER , INTENT(in ) :: kn_cen_v ! =2/4 (2nd or 4th order scheme) 73 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)76 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 74 77 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume flux components 75 78 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation … … 82 85 !!---------------------------------------------------------------------- 83 86 ! 84 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile 87 #if defined key_loop_fusion 88 CALL tra_adv_cen_lf ( kt, nit000, cdtype, pU, pV, pW, Kmm, pt, kjpt, Krhs, kn_cen_h, kn_cen_v ) 89 #else 90 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 85 91 IF( kt == kit000 ) THEN 86 92 IF(lwp) WRITE(numout,*) … … 119 125 ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) 120 126 END_3D 121 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_cen', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp) ! Lateral boundary cond.127 IF (nn_hls==1) CALL lbc_lnk( 'traadv_cen', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp, ld4only= .TRUE. ) ! Lateral boundary cond. 122 128 ! 123 129 DO_3D( nn_hls-1, 0, nn_hls-1, 0, 1, jpkm1 ) ! Horizontal advective fluxes … … 131 137 zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * zC4t_v 132 138 END_3D 133 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_cen', zwx, 'U', -1. , zwy, 'V', -1. )139 IF (nn_hls==1) CALL lbc_lnk( 'traadv_cen', zwx, 'U', -1. , zwy, 'V', -1. ) 134 140 ! 135 141 CASE DEFAULT … … 184 190 END DO 185 191 ! 192 #endif 186 193 END SUBROUTINE tra_adv_cen 187 194 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traadv_fct.F90
r14433 r14958 34 34 PUBLIC tra_adv_fct ! called by traadv.F90 35 35 PUBLIC interp_4th_cpt ! called by traadv_cen.F90 36 PUBLIC tridia_solver ! called by traadv_fct_lf.F9037 PUBLIC nonosc ! called by traadv_fct_lf.F90 - key_agrif38 36 39 37 LOGICAL :: l_trd ! flag to compute trends … … 81 79 INTEGER , INTENT(in ) :: kn_fct_v ! order of the FCT scheme (=2 or 4) 82 80 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 83 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)81 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case 84 82 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume flux components 85 83 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation … … 95 93 !!---------------------------------------------------------------------- 96 94 ! 97 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile 95 #if defined key_loop_fusion 96 CALL tra_adv_fct_lf ( kt, nit000, cdtype, p2dt, pU, pV, pW, Kbb, Kmm, pt, kjpt, Krhs, kn_fct_h, kn_fct_v ) 97 #else 98 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 98 99 IF( kt == kit000 ) THEN 99 100 IF(lwp) WRITE(numout,*) … … 136 137 ! If adaptive vertical advection, check if it is needed on this PE at this time 137 138 IF( ln_zad_Aimp ) THEN 138 IF( MAXVAL( ABS( wi(A2D( nn_hls),:) ) ) > 0._wp ) ll_zAimp = .TRUE.139 IF( MAXVAL( ABS( wi(A2D(1),:) ) ) > 0._wp ) ll_zAimp = .TRUE. 139 140 END IF 140 141 ! If active adaptive vertical advection, build tridiagonal matrix … … 162 163 zwy(ji,jj,jk) = 0.5 * ( zfp_vj * pt(ji,jj,jk,jn,Kbb) + zfm_vj * pt(ji ,jj+1,jk,jn,Kbb) ) 163 164 END_3D 165 ! !* upstream tracer flux in the k direction *! 166 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) 167 zfp_wk = pW(ji,jj,jk) + ABS( pW(ji,jj,jk) ) 168 zfm_wk = pW(ji,jj,jk) - ABS( pW(ji,jj,jk) ) 169 zwz(ji,jj,jk) = 0.5 * ( zfp_wk * pt(ji,jj,jk,jn,Kbb) + zfm_wk * pt(ji,jj,jk-1,jn,Kbb) ) * wmask(ji,jj,jk) 170 END_3D 171 IF( ln_linssh ) THEN ! top ocean value (only in linear free surface as zwz has been w-masked) 172 IF( ln_isfcav ) THEN ! top of the ice-shelf cavities and at the ocean surface 173 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 174 zwz(ji,jj, mikt(ji,jj) ) = pW(ji,jj,mikt(ji,jj)) * pt(ji,jj,mikt(ji,jj),jn,Kbb) ! linear free surface 175 END_2D 176 ELSE ! no cavities: only at the ocean surface 177 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 178 zwz(ji,jj,1) = pW(ji,jj,1) * pt(ji,jj,1,jn,Kbb) 179 END_2D 180 ENDIF 181 ENDIF 182 ! 183 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* trend and after field with monotonic scheme 184 ! ! total intermediate advective trends 185 ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & 186 & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & 187 & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) 188 ! ! update and guess with monotonic sheme 189 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra & 190 & / e3t(ji,jj,jk,Kmm ) * tmask(ji,jj,jk) 191 zwi(ji,jj,jk) = ( e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb) + p2dt * ztra ) & 192 & / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) 193 END_3D 194 195 IF ( ll_zAimp ) THEN 196 CALL tridia_solver( zwdia, zwsup, zwinf, zwi, zwi , 0 ) 197 ! 198 ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp ; 199 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) 200 zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) 201 zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) 202 ztw(ji,jj,jk) = 0.5 * e1e2t(ji,jj) * ( zfp_wk * zwi(ji,jj,jk) + zfm_wk * zwi(ji,jj,jk-1) ) * wmask(ji,jj,jk) 203 zwz(ji,jj,jk) = zwz(ji,jj,jk) + ztw(ji,jj,jk) ! update vertical fluxes 204 END_3D 205 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 206 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) - ( ztw(ji,jj,jk) - ztw(ji ,jj ,jk+1) ) & 207 & * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) 208 END_3D 209 ! 210 END IF 211 ! 212 IF( l_trd .OR. l_hst ) THEN ! trend diagnostics (contribution of upstream fluxes) 213 ztrdx(:,:,:) = zwx(:,:,:) ; ztrdy(:,:,:) = zwy(:,:,:) ; ztrdz(:,:,:) = zwz(:,:,:) 214 END IF 215 ! ! "Poleward" heat and salt transports (contribution of upstream fluxes) 216 IF( l_ptr ) zptry(:,:,:) = zwy(:,:,:) 217 ! 218 ! !== anti-diffusive flux : high order minus low order ==! 219 ! 220 SELECT CASE( kn_fct_h ) !* horizontal anti-diffusive fluxes 221 ! 222 CASE( 2 ) !- 2nd order centered 223 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) 224 zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj,jk,jn,Kmm) ) - zwx(ji,jj,jk) 225 zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj+1,jk,jn,Kmm) ) - zwy(ji,jj,jk) 226 END_3D 227 ! 228 CASE( 4 ) !- 4th order centered 229 zltu(:,:,jpk) = 0._wp ! Bottom value : flux set to zero 230 zltv(:,:,jpk) = 0._wp 231 DO jk = 1, jpkm1 ! Laplacian 232 DO_2D( 1, 0, 1, 0 ) ! 1st derivative (gradient) 233 ztu(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk) 234 ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) 235 END_2D 236 DO_2D( 0, 0, 0, 0 ) ! 2nd derivative * 1/ 6 237 zltu(ji,jj,jk) = ( ztu(ji,jj,jk) + ztu(ji-1,jj,jk) ) * r1_6 238 zltv(ji,jj,jk) = ( ztv(ji,jj,jk) + ztv(ji,jj-1,jk) ) * r1_6 239 END_2D 240 END DO 241 ! NOTE [ comm_cleanup ] : need to change sign to ensure halo 1 - halo 2 compatibility 242 CALL lbc_lnk( 'traadv_fct', zltu, 'T', -1.0_wp , zltv, 'T', -1.0_wp, ld4only= .TRUE. ) ! Lateral boundary cond. (unchanged sgn) 243 ! 244 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) 245 zC2t_u = pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj ,jk,jn,Kmm) ! 2 x C2 interpolation of T at u- & v-points 246 zC2t_v = pt(ji,jj,jk,jn,Kmm) + pt(ji ,jj+1,jk,jn,Kmm) 247 ! ! C4 minus upstream advective fluxes 248 ! round brackets added to fix the order of floating point operations 249 ! needed to ensure halo 1 - halo 2 compatibility 250 zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( zC2t_u + ( zltu(ji,jj,jk) - zltu(ji+1,jj,jk) & 251 & ) & ! bracket for halo 1 - halo 2 compatibility 252 & ) - zwx(ji,jj,jk) 253 zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( zC2t_v + ( zltv(ji,jj,jk) - zltv(ji,jj+1,jk) & 254 & ) & ! bracket for halo 1 - halo 2 compatibility 255 & ) - zwy(ji,jj,jk) 256 END_3D 257 ! 258 CASE( 41 ) !- 4th order centered ==>> !!gm coding attempt need to be tested 259 ztu(:,:,jpk) = 0._wp ! Bottom value : flux set to zero 260 ztv(:,:,jpk) = 0._wp 261 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) ! 1st derivative (gradient) 262 ztu(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk) 263 ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) 264 END_3D 265 IF (nn_hls==1) CALL lbc_lnk( 'traadv_fct', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp, ld4only= .TRUE. ) ! Lateral boundary cond. (unchanged sgn) 266 ! 267 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) ! Horizontal advective fluxes 268 zC2t_u = pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj ,jk,jn,Kmm) ! 2 x C2 interpolation of T at u- & v-points (x2) 269 zC2t_v = pt(ji,jj,jk,jn,Kmm) + pt(ji ,jj+1,jk,jn,Kmm) 270 ! ! C4 interpolation of T at u- & v-points (x2) 271 zC4t_u = zC2t_u + r1_6 * ( ztu(ji-1,jj ,jk) - ztu(ji+1,jj ,jk) ) 272 zC4t_v = zC2t_v + r1_6 * ( ztv(ji ,jj-1,jk) - ztv(ji ,jj+1,jk) ) 273 ! ! C4 minus upstream advective fluxes 274 zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * zC4t_u - zwx(ji,jj,jk) 275 zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * zC4t_v - zwy(ji,jj,jk) 276 END_3D 277 IF (nn_hls==2) CALL lbc_lnk( 'traadv_fct', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) 278 ! 279 END SELECT 280 ! 281 SELECT CASE( kn_fct_v ) !* vertical anti-diffusive fluxes (w-masked interior values) 282 ! 283 CASE( 2 ) !- 2nd order centered 284 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 285 zwz(ji,jj,jk) = ( pW(ji,jj,jk) * 0.5_wp * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj,jk-1,jn,Kmm) ) & 286 & - zwz(ji,jj,jk) ) * wmask(ji,jj,jk) 287 END_3D 288 ! 289 CASE( 4 ) !- 4th order COMPACT 290 CALL interp_4th_cpt( pt(:,:,:,jn,Kmm) , ztw ) ! zwt = COMPACT interpolation of T at w-point 291 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 292 zwz(ji,jj,jk) = ( pW(ji,jj,jk) * ztw(ji,jj,jk) - zwz(ji,jj,jk) ) * wmask(ji,jj,jk) 293 END_3D 294 ! 295 END SELECT 296 IF( ln_linssh ) THEN ! top ocean value: high order = upstream ==>> zwz=0 297 zwz(:,:,1) = 0._wp ! only ocean surface as interior zwz values have been w-masked 298 ENDIF 299 ! 300 IF (nn_hls==1) THEN 301 CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp, zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp ) 302 ELSE 303 CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp) 304 END IF 305 ! 306 IF ( ll_zAimp ) THEN 307 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* trend and after field with monotonic scheme 308 ! ! total intermediate advective trends 309 ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & 310 & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & 311 & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) 312 ztw(ji,jj,jk) = zwi(ji,jj,jk) + p2dt * ztra / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) 313 END_3D 314 ! 315 CALL tridia_solver( zwdia, zwsup, zwinf, ztw, ztw , 0 ) 316 ! 317 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) 318 zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) 319 zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) 320 zwz(ji,jj,jk) = zwz(ji,jj,jk) + 0.5 * e1e2t(ji,jj) * ( zfp_wk * ztw(ji,jj,jk) + zfm_wk * ztw(ji,jj,jk-1) ) * wmask(ji,jj,jk) 321 END_3D 322 END IF 323 ! 324 ! !== monotonicity algorithm ==! 325 ! 326 CALL nonosc( Kmm, pt(:,:,:,jn,Kbb), zwx, zwy, zwz, zwi, p2dt ) 327 ! 328 ! !== final trend with corrected fluxes ==! 329 ! 330 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 331 ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & 332 & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & 333 & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) 334 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra / e3t(ji,jj,jk,Kmm) 335 zwi(ji,jj,jk) = zwi(ji,jj,jk) + p2dt * ztra / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) 336 END_3D 337 ! 338 IF ( ll_zAimp ) THEN 339 ! 340 ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp 341 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! Interior value ( multiplied by wmask) 342 zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) 343 zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) 344 ztw(ji,jj,jk) = - 0.5 * e1e2t(ji,jj) * ( zfp_wk * zwi(ji,jj,jk) + zfm_wk * zwi(ji,jj,jk-1) ) * wmask(ji,jj,jk) 345 zwz(ji,jj,jk) = zwz(ji,jj,jk) + ztw(ji,jj,jk) ! Update vertical fluxes for trend diagnostic 346 END_3D 347 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 348 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) - ( ztw(ji,jj,jk) - ztw(ji ,jj ,jk+1) ) & 349 & * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) 350 END_3D 351 END IF 352 IF( l_trd .OR. l_hst ) THEN ! trend diagnostics // heat/salt transport 353 ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:) ! <<< add anti-diffusive fluxes 354 ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:) ! to upstream fluxes 355 ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:) ! 356 ! 357 IF( l_trd ) THEN ! trend diagnostics 358 CALL trd_tra( kt, Kmm, Krhs, cdtype, jn, jptra_xad, ztrdx, pU, pt(:,:,:,jn,Kmm) ) 359 CALL trd_tra( kt, Kmm, Krhs, cdtype, jn, jptra_yad, ztrdy, pV, pt(:,:,:,jn,Kmm) ) 360 CALL trd_tra( kt, Kmm, Krhs, cdtype, jn, jptra_zad, ztrdz, pW, pt(:,:,:,jn,Kmm) ) 361 ENDIF 362 ! ! heat/salt transport 363 IF( l_hst ) CALL dia_ar5_hst( jn, 'adv', ztrdx(:,:,:), ztrdy(:,:,:) ) 364 ! 365 ENDIF 366 IF( l_ptr ) THEN ! "Poleward" transports 367 zptry(:,:,:) = zptry(:,:,:) + zwy(:,:,:) ! <<< add anti-diffusive fluxes 368 CALL dia_ptr_hst( jn, 'adv', zptry(:,:,:) ) 369 ENDIF 370 ! 371 END DO ! end of tracer loop 372 ! 373 IF ( ll_zAimp ) THEN 374 DEALLOCATE( zwdia, zwinf, zwsup ) 375 ENDIF 376 IF( l_trd .OR. l_hst ) THEN 377 DEALLOCATE( ztrdx, ztrdy, ztrdz ) 378 ENDIF 379 IF( l_ptr ) THEN 380 DEALLOCATE( zptry ) 381 ENDIF 382 ! 383 #endif 384 END SUBROUTINE tra_adv_fct 385 386 387 SUBROUTINE nonosc( Kmm, pbef, paa, pbb, pcc, paft, p2dt ) 388 !!--------------------------------------------------------------------- 389 !! *** ROUTINE nonosc *** 390 !! 391 !! ** Purpose : compute monotonic tracer fluxes from the upstream 392 !! scheme and the before field by a nonoscillatory algorithm 393 !! 394 !! ** Method : ... ??? 395 !! warning : pbef and paft must be masked, but the boundaries 396 !! conditions on the fluxes are not necessary zalezak (1979) 397 !! drange (1995) multi-dimensional forward-in-time and upstream- 398 !! in-space based differencing for fluid 399 !!---------------------------------------------------------------------- 400 INTEGER , INTENT(in ) :: Kmm ! time level index 401 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 402 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pbef ! before field 403 REAL(wp), DIMENSION(A2D(nn_hls) ,jpk), INTENT(in ) :: paft ! after field 404 REAL(wp), DIMENSION(A2D(nn_hls) ,jpk), INTENT(inout) :: paa, pbb, pcc ! monotonic fluxes in the 3 directions 405 ! 406 INTEGER :: ji, jj, jk ! dummy loop indices 407 INTEGER :: ikm1 ! local integer 408 REAL(dp) :: zpos, zneg, zbt, za, zb, zc, zbig, zrtrn ! local scalars 409 REAL(dp) :: zau, zbu, zcu, zav, zbv, zcv, zup, zdo ! - - 410 REAL(dp), DIMENSION(A2D(nn_hls),jpk) :: zbetup, zbetdo, zbup, zbdo 411 !!---------------------------------------------------------------------- 412 ! 413 zbig = 1.e+40_dp 414 zrtrn = 1.e-15_dp 415 zbetup(:,:,:) = 0._dp ; zbetdo(:,:,:) = 0._dp 416 417 ! Search local extrema 418 ! -------------------- 419 ! max/min of pbef & paft with large negative/positive value (-/+zbig) inside land 420 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 421 zbup(ji,jj,jk) = MAX( pbef(ji,jj,jk) * tmask(ji,jj,jk) - zbig * ( 1._wp - tmask(ji,jj,jk) ), & 422 & paft(ji,jj,jk) * tmask(ji,jj,jk) - zbig * ( 1._wp - tmask(ji,jj,jk) ) ) 423 zbdo(ji,jj,jk) = MIN( pbef(ji,jj,jk) * tmask(ji,jj,jk) + zbig * ( 1._wp - tmask(ji,jj,jk) ), & 424 & paft(ji,jj,jk) * tmask(ji,jj,jk) + zbig * ( 1._wp - tmask(ji,jj,jk) ) ) 425 END_3D 426 427 DO jk = 1, jpkm1 428 ikm1 = MAX(jk-1,1) 429 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 430 431 ! search maximum in neighbourhood 432 zup = MAX( zbup(ji ,jj ,jk ), & 433 & zbup(ji-1,jj ,jk ), zbup(ji+1,jj ,jk ), & 434 & zbup(ji ,jj-1,jk ), zbup(ji ,jj+1,jk ), & 435 & zbup(ji ,jj ,ikm1), zbup(ji ,jj ,jk+1) ) 436 437 ! search minimum in neighbourhood 438 zdo = MIN( zbdo(ji ,jj ,jk ), & 439 & zbdo(ji-1,jj ,jk ), zbdo(ji+1,jj ,jk ), & 440 & zbdo(ji ,jj-1,jk ), zbdo(ji ,jj+1,jk ), & 441 & zbdo(ji ,jj ,ikm1), zbdo(ji ,jj ,jk+1) ) 442 443 ! positive part of the flux 444 zpos = MAX( 0., paa(ji-1,jj ,jk ) ) - MIN( 0., paa(ji ,jj ,jk ) ) & 445 & + MAX( 0., pbb(ji ,jj-1,jk ) ) - MIN( 0., pbb(ji ,jj ,jk ) ) & 446 & + MAX( 0., pcc(ji ,jj ,jk+1) ) - MIN( 0., pcc(ji ,jj ,jk ) ) 447 448 ! negative part of the flux 449 zneg = MAX( 0., paa(ji ,jj ,jk ) ) - MIN( 0., paa(ji-1,jj ,jk ) ) & 450 & + MAX( 0., pbb(ji ,jj ,jk ) ) - MIN( 0., pbb(ji ,jj-1,jk ) ) & 451 & + MAX( 0., pcc(ji ,jj ,jk ) ) - MIN( 0., pcc(ji ,jj ,jk+1) ) 452 453 ! up & down beta terms 454 zbt = e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) / p2dt 455 zbetup(ji,jj,jk) = ( zup - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt 456 zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo ) / ( zneg + zrtrn ) * zbt 457 END_2D 458 END DO 459 IF (nn_hls==1) CALL lbc_lnk( 'traadv_fct', zbetup, 'T', 1.0_wp , zbetdo, 'T', 1.0_wp, ld4only= .TRUE. ) ! lateral boundary cond. (unchanged sign) 460 461 ! 3. monotonic flux in the i & j direction (paa & pbb) 462 ! ---------------------------------------- 463 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 464 zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) ) 465 zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) ) 466 zcu = ( 0.5 + SIGN( 0.5_wp , paa(ji,jj,jk) ) ) 467 paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu ) 468 469 zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) ) 470 zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) ) 471 zcv = ( 0.5 + SIGN( 0.5_wp , pbb(ji,jj,jk) ) ) 472 pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv ) 473 474 ! monotonic flux in the k direction, i.e. pcc 475 ! ------------------------------------------- 476 za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) ) 477 zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) ) 478 zc = ( 0.5 + SIGN( 0.5_wp , pcc(ji,jj,jk+1) ) ) 479 pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb ) 480 END_3D 481 ! 482 END SUBROUTINE nonosc 483 484 485 SUBROUTINE interp_4th_cpt_org( pt_in, pt_out ) 486 !!---------------------------------------------------------------------- 487 !! *** ROUTINE interp_4th_cpt_org *** 488 !! 489 !! ** Purpose : Compute the interpolation of tracer at w-point 490 !! 491 !! ** Method : 4th order compact interpolation 492 !!---------------------------------------------------------------------- 493 REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pt_in ! now tracer fields 494 REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT( out) :: pt_out ! now tracer field interpolated at w-pts 495 ! 496 INTEGER :: ji, jj, jk ! dummy loop integers 497 REAL(wp),DIMENSION(jpi,jpj,jpk) :: zwd, zwi, zws, zwrm, zwt 498 !!---------------------------------------------------------------------- 499 500 DO_3D( 1, 1, 1, 1, 3, jpkm1 ) !== build the three diagonal matrix ==! 501 zwd (ji,jj,jk) = 4._wp 502 zwi (ji,jj,jk) = 1._wp 503 zws (ji,jj,jk) = 1._wp 504 zwrm(ji,jj,jk) = 3._wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) 505 ! 506 IF( tmask(ji,jj,jk+1) == 0._wp) THEN ! Switch to second order centered at bottom 507 zwd (ji,jj,jk) = 1._wp 508 zwi (ji,jj,jk) = 0._wp 509 zws (ji,jj,jk) = 0._wp 510 zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) 511 ENDIF 512 END_3D 513 ! 514 jk = 2 ! Switch to second order centered at top 515 DO_2D( 1, 1, 1, 1 ) 516 zwd (ji,jj,jk) = 1._wp 517 zwi (ji,jj,jk) = 0._wp 518 zws (ji,jj,jk) = 0._wp 519 zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) 520 END_2D 521 ! 522 ! !== tridiagonal solve ==! 523 DO_2D( 1, 1, 1, 1 ) ! first recurrence 524 zwt(ji,jj,2) = zwd(ji,jj,2) 525 END_2D 526 DO_3D( 1, 1, 1, 1, 3, jpkm1 ) 527 zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1) 528 END_3D 529 ! 530 DO_2D( 1, 1, 1, 1 ) ! second recurrence: Zk = Yk - Ik / Tk-1 Zk-1 531 pt_out(ji,jj,2) = zwrm(ji,jj,2) 532 END_2D 533 DO_3D( 1, 1, 1, 1, 3, jpkm1 ) 534 pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) 535 END_3D 536 537 DO_2D( 1, 1, 1, 1 ) ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk 538 pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) 539 END_2D 540 DO_3DS( 1, 1, 1, 1, jpk-2, 2, -1 ) 541 pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) 542 END_3D 543 ! 544 END SUBROUTINE interp_4th_cpt_org 545 546 547 SUBROUTINE interp_4th_cpt( pt_in, pt_out ) 548 !!---------------------------------------------------------------------- 549 !! *** ROUTINE interp_4th_cpt *** 550 !! 551 !! ** Purpose : Compute the interpolation of tracer at w-point 552 !! 553 !! ** Method : 4th order compact interpolation 554 !!---------------------------------------------------------------------- 555 REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pt_in ! field at t-point 556 REAL(wp),DIMENSION(A2D(nn_hls) ,jpk), INTENT( out) :: pt_out ! field interpolated at w-point 557 ! 558 INTEGER :: ji, jj, jk ! dummy loop integers 559 INTEGER :: ikt, ikb ! local integers 560 REAL(wp),DIMENSION(A2D(nn_hls),jpk) :: zwd, zwi, zws, zwrm, zwt 561 !!---------------------------------------------------------------------- 562 ! 563 ! !== build the three diagonal matrix & the RHS ==! 564 ! 565 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) ! interior (from jk=3 to jpk-1) 566 zwd (ji,jj,jk) = 3._wp * wmask(ji,jj,jk) + 1._wp ! diagonal 567 zwi (ji,jj,jk) = wmask(ji,jj,jk) ! lower diagonal 568 zws (ji,jj,jk) = wmask(ji,jj,jk) ! upper diagonal 569 zwrm(ji,jj,jk) = 3._wp * wmask(ji,jj,jk) & ! RHS 570 & * ( pt_in(ji,jj,jk) + pt_in(ji,jj,jk-1) ) 571 END_3D 572 ! 573 !!gm 574 ! SELECT CASE( kbc ) !* boundary condition 575 ! CASE( np_NH ) ! Neumann homogeneous at top & bottom 576 ! CASE( np_CEN2 ) ! 2nd order centered at top & bottom 577 ! END SELECT 578 !!gm 579 ! 580 IF ( ln_isfcav ) THEN ! set level two values which may not be set in ISF case 581 zwd(:,:,2) = 1._wp ; zwi(:,:,2) = 0._wp ; zws(:,:,2) = 0._wp ; zwrm(:,:,2) = 0._wp 582 END IF 583 ! 584 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! 2nd order centered at top & bottom 585 ikt = mikt(ji,jj) + 1 ! w-point below the 1st wet point 586 ikb = MAX(mbkt(ji,jj), 2) ! - above the last wet point 587 ! 588 zwd (ji,jj,ikt) = 1._wp ! top 589 zwi (ji,jj,ikt) = 0._wp 590 zws (ji,jj,ikt) = 0._wp 591 zwrm(ji,jj,ikt) = 0.5_wp * ( pt_in(ji,jj,ikt-1) + pt_in(ji,jj,ikt) ) 592 ! 593 zwd (ji,jj,ikb) = 1._wp ! bottom 594 zwi (ji,jj,ikb) = 0._wp 595 zws (ji,jj,ikb) = 0._wp 596 zwrm(ji,jj,ikb) = 0.5_wp * ( pt_in(ji,jj,ikb-1) + pt_in(ji,jj,ikb) ) 597 END_2D 598 ! 599 ! !== tridiagonal solver ==! 600 ! 601 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 1st recurrence: Tk = Dk - Ik Sk-1 / Tk-1 602 zwt(ji,jj,2) = zwd(ji,jj,2) 603 END_2D 604 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) 605 zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1) 606 END_3D 607 ! 608 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 2nd recurrence: Zk = Yk - Ik / Tk-1 Zk-1 609 pt_out(ji,jj,2) = zwrm(ji,jj,2) 610 END_2D 611 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) 612 pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) 613 END_3D 614 615 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 3d recurrence: Xk = (Zk - Sk Xk+1 ) / Tk 616 pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) 617 END_2D 618 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, 2, -1 ) 619 pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) 620 END_3D 621 ! 622 END SUBROUTINE interp_4th_cpt 623 624 625 SUBROUTINE tridia_solver( pD, pU, pL, pRHS, pt_out , klev ) 626 !!---------------------------------------------------------------------- 627 !! *** ROUTINE tridia_solver *** 628 !! 629 !! ** Purpose : solve a symmetric 3diagonal system 630 !! 631 !! ** Method : solve M.t_out = RHS(t) where M is a tri diagonal matrix ( jpk*jpk ) 632 !! 633 !! ( D_1 U_1 0 0 0 )( t_1 ) ( RHS_1 ) 634 !! ( L_2 D_2 U_2 0 0 )( t_2 ) ( RHS_2 ) 635 !! ( 0 L_3 D_3 U_3 0 )( t_3 ) = ( RHS_3 ) 636 !! ( ... )( ... ) ( ... ) 637 !! ( 0 0 0 L_k D_k )( t_k ) ( RHS_k ) 638 !! 639 !! M is decomposed in the product of an upper and lower triangular matrix. 640 !! The tri-diagonals matrix is given as input 3D arrays: pD, pU, pL 641 !! (i.e. the Diagonal, the Upper diagonal, and the Lower diagonal). 642 !! The solution is pta. 643 !! The 3d array zwt is used as a work space array. 644 !!---------------------------------------------------------------------- 645 REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: pD, pU, PL ! 3-diagonal matrix 646 REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: pRHS ! Right-Hand-Side 647 REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT( out) :: pt_out !!gm field at level=F(klev) 648 INTEGER , INTENT(in ) :: klev ! =1 pt_out at w-level 649 ! ! =0 pt at t-level 650 INTEGER :: ji, jj, jk ! dummy loop integers 651 INTEGER :: kstart ! local indices 652 REAL(wp),DIMENSION(A2D(nn_hls),jpk) :: zwt ! 3D work array 653 !!---------------------------------------------------------------------- 654 ! 655 kstart = 1 + klev 656 ! 657 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 1st recurrence: Tk = Dk - Ik Sk-1 / Tk-1 658 zwt(ji,jj,kstart) = pD(ji,jj,kstart) 659 END_2D 660 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, kstart+1, jpkm1 ) 661 zwt(ji,jj,jk) = pD(ji,jj,jk) - pL(ji,jj,jk) * pU(ji,jj,jk-1) /zwt(ji,jj,jk-1) 662 END_3D 663 ! 664 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 2nd recurrence: Zk = Yk - Ik / Tk-1 Zk-1 665 pt_out(ji,jj,kstart) = pRHS(ji,jj,kstart) 666 END_2D 667 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, kstart+1, jpkm1 ) 668 pt_out(ji,jj,jk) = pRHS(ji,jj,jk) - pL(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) 669 END_3D 670 671 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 3d recurrence: Xk = (Zk - Sk Xk+1 ) / Tk 672 pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) 673 END_2D 674 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, kstart, -1 ) 675 pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - pU(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) 676 END_3D 677 ! 678 END SUBROUTINE tridia_solver 679 680 #if defined key_loop_fusion 681 #define tracer_flux_i(out,zfp,zfm,ji,jj,jk) \ 682 zfp = pU(ji,jj,jk) + ABS( pU(ji,jj,jk) ) ; \ 683 zfm = pU(ji,jj,jk) - ABS( pU(ji,jj,jk) ) ; \ 684 out = 0.5 * ( zfp * pt(ji,jj,jk,jn,Kbb) + zfm * pt(ji+1,jj,jk,jn,Kbb) ) 685 686 #define tracer_flux_j(out,zfp,zfm,ji,jj,jk) \ 687 zfp = pV(ji,jj,jk) + ABS( pV(ji,jj,jk) ) ; \ 688 zfm = pV(ji,jj,jk) - ABS( pV(ji,jj,jk) ) ; \ 689 out = 0.5 * ( zfp * pt(ji,jj,jk,jn,Kbb) + zfm * pt(ji,jj+1,jk,jn,Kbb) ) 690 691 SUBROUTINE tra_adv_fct_lf( kt, kit000, cdtype, p2dt, pU, pV, pW, & 692 & Kbb, Kmm, pt, kjpt, Krhs, kn_fct_h, kn_fct_v ) 693 !!---------------------------------------------------------------------- 694 !! *** ROUTINE tra_adv_fct *** 695 !! 696 !! ** Purpose : Compute the now trend due to total advection of tracers 697 !! and add it to the general trend of tracer equations 698 !! 699 !! ** Method : - 2nd or 4th FCT scheme on the horizontal direction 700 !! (choice through the value of kn_fct) 701 !! - on the vertical the 4th order is a compact scheme 702 !! - corrected flux (monotonic correction) 703 !! 704 !! ** Action : - update pt(:,:,:,:,Krhs) with the now advective tracer trends 705 !! - send trends to trdtra module for further diagnostics (l_trdtra=T) 706 !! - poleward advective heat and salt transport (ln_diaptr=T) 707 !!---------------------------------------------------------------------- 708 INTEGER , INTENT(in ) :: kt ! ocean time-step index 709 INTEGER , INTENT(in ) :: Kbb, Kmm, Krhs ! ocean time level indices 710 INTEGER , INTENT(in ) :: kit000 ! first time step index 711 CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) 712 INTEGER , INTENT(in ) :: kjpt ! number of tracers 713 INTEGER , INTENT(in ) :: kn_fct_h ! order of the FCT scheme (=2 or 4) 714 INTEGER , INTENT(in ) :: kn_fct_v ! order of the FCT scheme (=2 or 4) 715 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 716 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume flux components 717 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation 718 ! 719 INTEGER :: ji, jj, jk, jn ! dummy loop indices 720 REAL(wp) :: ztra ! local scalar 721 REAL(wp) :: zwx_im1, zfp_ui, zfp_ui_m1, zfp_vj, zfp_vj_m1, zfp_wk, zC2t_u, zC4t_u ! - - 722 REAL(wp) :: zwy_jm1, zfm_ui, zfm_ui_m1, zfm_vj, zfm_vj_m1, zfm_wk, zC2t_v, zC4t_v ! - - 723 REAL(wp) :: ztu, ztv, ztu_im1, ztu_ip1, ztv_jm1, ztv_jp1 724 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwi, zwx_3d, zwy_3d, zwz, ztw, zltu_3d, zltv_3d 725 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztrdx, ztrdy, ztrdz, zptry 726 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zwinf, zwdia, zwsup 727 LOGICAL :: ll_zAimp ! flag to apply adaptive implicit vertical advection 728 !!---------------------------------------------------------------------- 729 ! 730 IF( kt == kit000 ) THEN 731 IF(lwp) WRITE(numout,*) 732 IF(lwp) WRITE(numout,*) 'tra_adv_fct_lf : FCT advection scheme on ', cdtype 733 IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 734 ENDIF 735 !! -- init to 0 736 zwx_3d(:,:,:) = 0._wp 737 zwy_3d(:,:,:) = 0._wp 738 zwz(:,:,:) = 0._wp 739 zwi(:,:,:) = 0._wp 740 ! 741 l_trd = .FALSE. ! set local switches 742 l_hst = .FALSE. 743 l_ptr = .FALSE. 744 ll_zAimp = .FALSE. 745 IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype =='TRC' .AND. l_trdtrc ) ) l_trd = .TRUE. 746 IF( cdtype == 'TRA' .AND. ( iom_use( 'sophtadv' ) .OR. iom_use( 'sophtadv' ) ) ) l_ptr = .TRUE. 747 IF( cdtype == 'TRA' .AND. ( iom_use("uadv_heattr") .OR. iom_use("vadv_heattr") .OR. & 748 & iom_use("uadv_salttr") .OR. iom_use("vadv_salttr") ) ) l_hst = .TRUE. 749 ! 750 IF( l_trd .OR. l_hst ) THEN 751 ALLOCATE( ztrdx(jpi,jpj,jpk), ztrdy(jpi,jpj,jpk), ztrdz(jpi,jpj,jpk) ) 752 ztrdx(:,:,:) = 0._wp ; ztrdy(:,:,:) = 0._wp ; ztrdz(:,:,:) = 0._wp 753 ENDIF 754 ! 755 IF( l_ptr ) THEN 756 ALLOCATE( zptry(jpi,jpj,jpk) ) 757 zptry(:,:,:) = 0._wp 758 ENDIF 759 ! 760 ! If adaptive vertical advection, check if it is needed on this PE at this time 761 IF( ln_zad_Aimp ) THEN 762 IF( MAXVAL( ABS( wi(:,:,:) ) ) > 0._wp ) ll_zAimp = .TRUE. 763 END IF 764 ! If active adaptive vertical advection, build tridiagonal matrix 765 IF( ll_zAimp ) THEN 766 ALLOCATE(zwdia(jpi,jpj,jpk), zwinf(jpi,jpj,jpk),zwsup(jpi,jpj,jpk)) 767 DO_3D( 1, 1, 1, 1, 1, jpkm1 ) 768 zwdia(ji,jj,jk) = 1._wp + p2dt * ( MAX( wi(ji,jj,jk) , 0._wp ) - MIN( wi(ji,jj,jk+1) , 0._wp ) ) & 769 & / e3t(ji,jj,jk,Krhs) 770 zwinf(ji,jj,jk) = p2dt * MIN( wi(ji,jj,jk ) , 0._wp ) / e3t(ji,jj,jk,Krhs) 771 zwsup(ji,jj,jk) = -p2dt * MAX( wi(ji,jj,jk+1) , 0._wp ) / e3t(ji,jj,jk,Krhs) 772 END_3D 773 END IF 774 ! 775 DO jn = 1, kjpt !== loop over the tracers ==! 776 ! 777 ! !== upstream advection with initial mass fluxes & intermediate update ==! 164 778 ! !* upstream tracer flux in the k direction *! 165 779 DO_3D( 1, 1, 1, 1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) … … 180 794 ENDIF 181 795 ! 182 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* trend and after field with monotonic scheme 183 ! ! total intermediate advective trends 184 ztra = - ( zwx(ji,jj,jk) - zwx(ji-1,jj ,jk ) & 185 & + zwy(ji,jj,jk) - zwy(ji ,jj-1,jk ) & 186 & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) 187 ! ! update and guess with monotonic sheme 188 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra & 189 & / e3t(ji,jj,jk,Kmm ) * tmask(ji,jj,jk) 190 zwi(ji,jj,jk) = ( e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb) + p2dt * ztra ) & 191 & / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) 192 END_3D 796 ! !* upstream tracer flux in the i and j direction 797 DO jk = 1, jpkm1 798 DO jj = 1, jpj-1 799 tracer_flux_i(zwx_3d(1,jj,jk),zfp_ui,zfm_ui,1,jj,jk) 800 tracer_flux_j(zwy_3d(1,jj,jk),zfp_vj,zfm_vj,1,jj,jk) 801 END DO 802 DO ji = 1, jpi-1 803 tracer_flux_i(zwx_3d(ji,1,jk),zfp_ui,zfm_ui,ji,1,jk) 804 tracer_flux_j(zwy_3d(ji,1,jk),zfp_vj,zfm_vj,ji,1,jk) 805 END DO 806 DO_2D( 1, 1, 1, 1 ) 807 tracer_flux_i(zwx_3d(ji,jj,jk),zfp_ui,zfm_ui,ji,jj,jk) 808 tracer_flux_i(zwx_im1,zfp_ui_m1,zfm_ui_m1,ji-1,jj,jk) 809 tracer_flux_j(zwy_3d(ji,jj,jk),zfp_vj,zfm_vj,ji,jj,jk) 810 tracer_flux_j(zwy_jm1,zfp_vj_m1,zfm_vj_m1,ji,jj-1,jk) 811 ztra = - ( zwx_3d(ji,jj,jk) - zwx_im1 + zwy_3d(ji,jj,jk) - zwy_jm1 + zwz(ji,jj,jk) - zwz(ji,jj,jk+1) ) * r1_e1e2t(ji,jj) 812 ! ! update and guess with monotonic sheme 813 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra & 814 & / e3t(ji,jj,jk,Kmm ) * tmask(ji,jj,jk) 815 zwi(ji,jj,jk) = ( e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb) + p2dt * ztra ) & 816 & / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) 817 END_2D 818 END DO 193 819 194 820 IF ( ll_zAimp ) THEN … … 196 822 ! 197 823 ztw(:,:,1) = 0._wp ; ztw(:,:,jpk) = 0._wp ; 198 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask)824 DO_3D( 1, 1, 1, 1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) 199 825 zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) 200 826 zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) … … 210 836 ! 211 837 IF( l_trd .OR. l_hst ) THEN ! trend diagnostics (contribution of upstream fluxes) 212 ztrdx(:,:,:) = zwx (:,:,:) ; ztrdy(:,:,:) = zwy(:,:,:) ; ztrdz(:,:,:) = zwz(:,:,:)838 ztrdx(:,:,:) = zwx_3d(:,:,:) ; ztrdy(:,:,:) = zwy_3d(:,:,:) ; ztrdz(:,:,:) = zwz(:,:,:) 213 839 END IF 214 840 ! ! "Poleward" heat and salt transports (contribution of upstream fluxes) 215 IF( l_ptr ) zptry(:,:,:) = zwy (:,:,:)841 IF( l_ptr ) zptry(:,:,:) = zwy_3d(:,:,:) 216 842 ! 217 843 ! !== anti-diffusive flux : high order minus low order ==! … … 220 846 ! 221 847 CASE( 2 ) !- 2nd order centered 222 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 )223 zwx (ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj,jk,jn,Kmm) ) - zwx(ji,jj,jk)224 zwy (ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj+1,jk,jn,Kmm) ) - zwy(ji,jj,jk)848 DO_3D( 2, 1, 2, 1, 1, jpkm1 ) 849 zwx_3d(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj,jk,jn,Kmm) ) - zwx_3d(ji,jj,jk) 850 zwy_3d(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj+1,jk,jn,Kmm) ) - zwy_3d(ji,jj,jk) 225 851 END_3D 226 852 ! 227 853 CASE( 4 ) !- 4th order centered 228 zltu(:,:,jpk) = 0._wp ! Bottom value : flux set to zero 229 zltv(:,:,jpk) = 0._wp 230 DO jk = 1, jpkm1 ! Laplacian 231 DO_2D( 1, 0, 1, 0 ) ! 1st derivative (gradient) 232 ztu(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk) 233 ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) 234 END_2D 235 DO_2D( 0, 0, 0, 0 ) ! 2nd derivative * 1/ 6 236 zltu(ji,jj,jk) = ( ztu(ji,jj,jk) + ztu(ji-1,jj,jk) ) * r1_6 237 zltv(ji,jj,jk) = ( ztv(ji,jj,jk) + ztv(ji,jj-1,jk) ) * r1_6 854 zltu_3d(:,:,jpk) = 0._wp ! Bottom value : flux set to zero 855 zltv_3d(:,:,jpk) = 0._wp 856 ! ! Laplacian 857 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) ! 2nd derivative * 1/ 6 858 ! ! 1st derivative (gradient) 859 ztu = ( pt(ji+1,jj,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk) 860 ztu_im1 = ( pt(ji,jj,jk,jn,Kmm) - pt(ji-1,jj,jk,jn,Kmm) ) * umask(ji-1,jj,jk) 861 ztv = ( pt(ji,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk) 862 ztv_jm1 = ( pt(ji,jj,jk,jn,Kmm) - pt(ji,jj-1,jk,jn,Kmm) ) * vmask(ji,jj-1,jk) 863 ! ! 2nd derivative * 1/ 6 864 zltu_3d(ji,jj,jk) = ( ztu + ztu_im1 ) * r1_6 865 zltv_3d(ji,jj,jk) = ( ztv + ztv_jm1 ) * r1_6 238 866 END_2D 239 867 END DO 240 CALL lbc_lnk( 'traadv_fct', zltu, 'T', 1.0_wp , zltv, 'T', 1.0_wp ) ! Lateral boundary cond. (unchanged sgn) 241 ! 242 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 868 ! NOTE [ comm_cleanup ] : need to change sign to ensure halo 1 - halo 2 compatibility 869 CALL lbc_lnk( 'traadv_fct', zltu_3d, 'T', -1.0_wp , zltv_3d, 'T', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) 870 ! 871 DO_3D( 2, 1, 2, 1, 1, jpkm1 ) 243 872 zC2t_u = pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj ,jk,jn,Kmm) ! 2 x C2 interpolation of T at u- & v-points 244 873 zC2t_v = pt(ji,jj,jk,jn,Kmm) + pt(ji ,jj+1,jk,jn,Kmm) 245 874 ! ! C4 minus upstream advective fluxes 246 zwx(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( zC2t_u + zltu(ji,jj,jk) - zltu(ji+1,jj,jk) ) - zwx(ji,jj,jk) 247 zwy(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( zC2t_v + zltv(ji,jj,jk) - zltv(ji,jj+1,jk) ) - zwy(ji,jj,jk) 248 END_3D 249 IF (nn_hls.EQ.2) CALL lbc_lnk( 'traadv_fct', zwx, 'U', -1.0_wp, zwy, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) 875 ! round brackets added to fix the order of floating point operations 876 ! needed to ensure halo 1 - halo 2 compatibility 877 zwx_3d(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * ( zC2t_u + ( zltu_3d(ji,jj,jk) - zltu_3d(ji+1,jj,jk) & 878 & ) & ! bracket for halo 1 - halo 2 compatibility 879 & ) - zwx_3d(ji,jj,jk) 880 zwy_3d(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * ( zC2t_v + ( zltv_3d(ji,jj,jk) - zltv_3d(ji,jj+1,jk) & 881 & ) & ! bracket for halo 1 - halo 2 compatibility 882 & ) - zwy_3d(ji,jj,jk) 883 END_3D 250 884 ! 251 885 CASE( 41 ) !- 4th order centered ==>> !!gm coding attempt need to be tested 252 ztu(:,:,jpk) = 0._wp ! Bottom value : flux set to zero253 ztv(:,:,jpk) = 0._wp254 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) ! 1st derivative (gradient)255 ztu(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * umask(ji,jj,jk)256 ztv(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk)257 END_3D258 IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_fct', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn)259 !260 886 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) ! Horizontal advective fluxes 887 ztu_im1 = ( pt(ji ,jj ,jk,jn,Kmm) - pt(ji-1,jj,jk,jn,Kmm) ) * umask(ji-1,jj,jk) 888 ztu_ip1 = ( pt(ji+2,jj ,jk,jn,Kmm) - pt(ji+1,jj,jk,jn,Kmm) ) * umask(ji+1,jj,jk) 889 890 ztv_jm1 = ( pt(ji,jj ,jk,jn,Kmm) - pt(ji,jj-1,jk,jn,Kmm) ) * vmask(ji,jj-1,jk) 891 ztv_jp1 = ( pt(ji,jj+2,jk,jn,Kmm) - pt(ji,jj+1,jk,jn,Kmm) ) * vmask(ji,jj+1,jk) 261 892 zC2t_u = pt(ji,jj,jk,jn,Kmm) + pt(ji+1,jj ,jk,jn,Kmm) ! 2 x C2 interpolation of T at u- & v-points (x2) 262 893 zC2t_v = pt(ji,jj,jk,jn,Kmm) + pt(ji ,jj+1,jk,jn,Kmm) 263 894 ! ! C4 interpolation of T at u- & v-points (x2) 264 zC4t_u = zC2t_u + r1_6 * ( ztu (ji-1,jj ,jk) - ztu(ji+1,jj ,jk))265 zC4t_v = zC2t_v + r1_6 * ( ztv (ji ,jj-1,jk) - ztv(ji ,jj+1,jk))895 zC4t_u = zC2t_u + r1_6 * ( ztu_im1 - ztu_ip1 ) 896 zC4t_v = zC2t_v + r1_6 * ( ztv_jm1 - ztv_jp1 ) 266 897 ! ! C4 minus upstream advective fluxes 267 zwx (ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * zC4t_u - zwx(ji,jj,jk)268 zwy (ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * zC4t_v - zwy(ji,jj,jk)269 END_3D 270 IF (nn_hls.EQ.2) CALL lbc_lnk( 'traadv_fct', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn)898 zwx_3d(ji,jj,jk) = 0.5_wp * pU(ji,jj,jk) * zC4t_u - zwx_3d(ji,jj,jk) 899 zwy_3d(ji,jj,jk) = 0.5_wp * pV(ji,jj,jk) * zC4t_v - zwy_3d(ji,jj,jk) 900 END_3D 901 CALL lbc_lnk( 'traadv_fct', zwx_3d, 'U', -1.0_wp , zwy_3d, 'V', -1.0_wp ) ! Lateral boundary cond. (unchanged sgn) 271 902 ! 272 903 END SELECT … … 275 906 ! 276 907 CASE( 2 ) !- 2nd order centered 277 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 )908 DO_3D( 1, 1, 1, 1, 2, jpkm1 ) 278 909 zwz(ji,jj,jk) = ( pW(ji,jj,jk) * 0.5_wp * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj,jk-1,jn,Kmm) ) & 279 910 & - zwz(ji,jj,jk) ) * wmask(ji,jj,jk) … … 282 913 CASE( 4 ) !- 4th order COMPACT 283 914 CALL interp_4th_cpt( pt(:,:,:,jn,Kmm) , ztw ) ! zwt = COMPACT interpolation of T at w-point 284 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 )915 DO_3D( 1, 1, 1, 1, 2, jpkm1 ) 285 916 zwz(ji,jj,jk) = ( pW(ji,jj,jk) * ztw(ji,jj,jk) - zwz(ji,jj,jk) ) * wmask(ji,jj,jk) 286 917 END_3D … … 291 922 ENDIF 292 923 ! 293 IF (nn_hls.EQ.1) THEN 294 CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp, zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp ) 295 ELSE 296 CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp) 297 END IF 924 CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp) 298 925 ! 299 926 IF ( ll_zAimp ) THEN 300 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* trend and after field with monotonic scheme927 DO_3D( 1, 1, 1, 1, 1, jpkm1 ) !* trend and after field with monotonic scheme 301 928 ! ! total intermediate advective trends 302 ztra = - ( zwx (ji,jj,jk) - zwx(ji-1,jj ,jk ) &303 & + zwy (ji,jj,jk) - zwy(ji ,jj-1,jk ) &929 ztra = - ( zwx_3d(ji,jj,jk) - zwx_3d(ji-1,jj ,jk ) & 930 & + zwy_3d(ji,jj,jk) - zwy_3d(ji ,jj-1,jk ) & 304 931 & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) 305 932 ztw(ji,jj,jk) = zwi(ji,jj,jk) + p2dt * ztra / e3t(ji,jj,jk,Krhs) * tmask(ji,jj,jk) … … 308 935 CALL tridia_solver( zwdia, zwsup, zwinf, ztw, ztw , 0 ) 309 936 ! 310 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Interior value ( multiplied by wmask)937 DO_3D( 1, 1, 1, 1, 2, jpkm1 ) ! Interior value ( multiplied by wmask) 311 938 zfp_wk = wi(ji,jj,jk) + ABS( wi(ji,jj,jk) ) 312 939 zfm_wk = wi(ji,jj,jk) - ABS( wi(ji,jj,jk) ) … … 317 944 ! !== monotonicity algorithm ==! 318 945 ! 319 CALL nonosc( Kmm, pt(:,:,:,jn,Kbb), zwx , zwy, zwz, zwi, p2dt )946 CALL nonosc( Kmm, pt(:,:,:,jn,Kbb), zwx_3d, zwy_3d, zwz, zwi, p2dt ) 320 947 ! 321 948 ! !== final trend with corrected fluxes ==! 322 949 ! 323 950 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 324 ztra = - ( zwx (ji,jj,jk) - zwx(ji-1,jj ,jk ) &325 & + zwy (ji,jj,jk) - zwy(ji ,jj-1,jk ) &951 ztra = - ( zwx_3d(ji,jj,jk) - zwx_3d(ji-1,jj ,jk ) & 952 & + zwy_3d(ji,jj,jk) - zwy_3d(ji ,jj-1,jk ) & 326 953 & + zwz(ji,jj,jk) - zwz(ji ,jj ,jk+1) ) * r1_e1e2t(ji,jj) 327 954 pt(ji,jj,jk,jn,Krhs) = pt(ji,jj,jk,jn,Krhs) + ztra / e3t(ji,jj,jk,Kmm) … … 343 970 END_3D 344 971 END IF 972 ! NOT TESTED - NEED l_trd OR l_hst TRUE 345 973 IF( l_trd .OR. l_hst ) THEN ! trend diagnostics // heat/salt transport 346 ztrdx(:,:,:) = ztrdx(:,:,:) + zwx (:,:,:) ! <<< add anti-diffusive fluxes347 ztrdy(:,:,:) = ztrdy(:,:,:) + zwy (:,:,:) ! to upstream fluxes974 ztrdx(:,:,:) = ztrdx(:,:,:) + zwx_3d(:,:,:) ! <<< add anti-diffusive fluxes 975 ztrdy(:,:,:) = ztrdy(:,:,:) + zwy_3d(:,:,:) ! to upstream fluxes 348 976 ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:) ! 349 977 ! … … 357 985 ! 358 986 ENDIF 987 ! NOT TESTED - NEED l_ptr TRUE 359 988 IF( l_ptr ) THEN ! "Poleward" transports 360 zptry(:,:,:) = zptry(:,:,:) + zwy (:,:,:) ! <<< add anti-diffusive fluxes989 zptry(:,:,:) = zptry(:,:,:) + zwy_3d(:,:,:) ! <<< add anti-diffusive fluxes 361 990 CALL dia_ptr_hst( jn, 'adv', zptry(:,:,:) ) 362 991 ENDIF … … 374 1003 ENDIF 375 1004 ! 376 END SUBROUTINE tra_adv_fct 377 378 379 SUBROUTINE nonosc( Kmm, pbef, paa, pbb, pcc, paft, p2dt ) 380 !!--------------------------------------------------------------------- 381 !! *** ROUTINE nonosc *** 382 !! 383 !! ** Purpose : compute monotonic tracer fluxes from the upstream 384 !! scheme and the before field by a nonoscillatory algorithm 385 !! 386 !! ** Method : ... ??? 387 !! warning : pbef and paft must be masked, but the boundaries 388 !! conditions on the fluxes are not necessary zalezak (1979) 389 !! drange (1995) multi-dimensional forward-in-time and upstream- 390 !! in-space based differencing for fluid 391 !!---------------------------------------------------------------------- 392 INTEGER , INTENT(in ) :: Kmm ! time level index 393 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 394 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pbef ! before field 395 REAL(wp), DIMENSION(A2D(nn_hls) ,jpk), INTENT(in ) :: paft ! after field 396 REAL(wp), DIMENSION(A2D(nn_hls) ,jpk), INTENT(inout) :: paa, pbb, pcc ! monotonic fluxes in the 3 directions 397 ! 398 INTEGER :: ji, jj, jk ! dummy loop indices 399 INTEGER :: ikm1 ! local integer 400 REAL(dp) :: zpos, zneg, zbt, za, zb, zc, zbig, zrtrn ! local scalars 401 REAL(dp) :: zau, zbu, zcu, zav, zbv, zcv, zup, zdo ! - - 402 REAL(dp), DIMENSION(A2D(nn_hls),jpk) :: zbetup, zbetdo, zbup, zbdo 403 !!---------------------------------------------------------------------- 404 ! 405 zbig = 1.e+40_dp 406 zrtrn = 1.e-15_dp 407 zbetup(:,:,:) = 0._dp ; zbetdo(:,:,:) = 0._dp 408 409 ! Search local extrema 410 ! -------------------- 411 ! max/min of pbef & paft with large negative/positive value (-/+zbig) inside land 412 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 413 zbup(ji,jj,jk) = MAX( pbef(ji,jj,jk) * tmask(ji,jj,jk) - zbig * ( 1._wp - tmask(ji,jj,jk) ), & 414 & paft(ji,jj,jk) * tmask(ji,jj,jk) - zbig * ( 1._wp - tmask(ji,jj,jk) ) ) 415 zbdo(ji,jj,jk) = MIN( pbef(ji,jj,jk) * tmask(ji,jj,jk) + zbig * ( 1._wp - tmask(ji,jj,jk) ), & 416 & paft(ji,jj,jk) * tmask(ji,jj,jk) + zbig * ( 1._wp - tmask(ji,jj,jk) ) ) 417 END_3D 418 419 DO jk = 1, jpkm1 420 ikm1 = MAX(jk-1,1) 421 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 422 423 ! search maximum in neighbourhood 424 zup = MAX( zbup(ji ,jj ,jk ), & 425 & zbup(ji-1,jj ,jk ), zbup(ji+1,jj ,jk ), & 426 & zbup(ji ,jj-1,jk ), zbup(ji ,jj+1,jk ), & 427 & zbup(ji ,jj ,ikm1), zbup(ji ,jj ,jk+1) ) 428 429 ! search minimum in neighbourhood 430 zdo = MIN( zbdo(ji ,jj ,jk ), & 431 & zbdo(ji-1,jj ,jk ), zbdo(ji+1,jj ,jk ), & 432 & zbdo(ji ,jj-1,jk ), zbdo(ji ,jj+1,jk ), & 433 & zbdo(ji ,jj ,ikm1), zbdo(ji ,jj ,jk+1) ) 434 435 ! positive part of the flux 436 zpos = MAX( 0., paa(ji-1,jj ,jk ) ) - MIN( 0., paa(ji ,jj ,jk ) ) & 437 & + MAX( 0., pbb(ji ,jj-1,jk ) ) - MIN( 0., pbb(ji ,jj ,jk ) ) & 438 & + MAX( 0., pcc(ji ,jj ,jk+1) ) - MIN( 0., pcc(ji ,jj ,jk ) ) 439 440 ! negative part of the flux 441 zneg = MAX( 0., paa(ji ,jj ,jk ) ) - MIN( 0., paa(ji-1,jj ,jk ) ) & 442 & + MAX( 0., pbb(ji ,jj ,jk ) ) - MIN( 0., pbb(ji ,jj-1,jk ) ) & 443 & + MAX( 0., pcc(ji ,jj ,jk ) ) - MIN( 0., pcc(ji ,jj ,jk+1) ) 444 445 ! up & down beta terms 446 zbt = e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) / p2dt 447 zbetup(ji,jj,jk) = ( zup - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt 448 zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo ) / ( zneg + zrtrn ) * zbt 449 END_2D 450 END DO 451 IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_fct', zbetup, 'T', 1.0_wp , zbetdo, 'T', 1.0_wp ) ! lateral boundary cond. (unchanged sign) 452 453 ! 3. monotonic flux in the i & j direction (paa & pbb) 454 ! ---------------------------------------- 455 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 456 zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) ) 457 zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) ) 458 zcu = ( 0.5 + SIGN( 0.5_wp , paa(ji,jj,jk) ) ) 459 paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu ) 460 461 zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) ) 462 zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) ) 463 zcv = ( 0.5 + SIGN( 0.5_wp , pbb(ji,jj,jk) ) ) 464 pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv ) 465 466 ! monotonic flux in the k direction, i.e. pcc 467 ! ------------------------------------------- 468 za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) ) 469 zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) ) 470 zc = ( 0.5 + SIGN( 0.5_wp , pcc(ji,jj,jk+1) ) ) 471 pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb ) 472 END_3D 473 ! 474 END SUBROUTINE nonosc 475 476 477 SUBROUTINE interp_4th_cpt_org( pt_in, pt_out ) 478 !!---------------------------------------------------------------------- 479 !! *** ROUTINE interp_4th_cpt_org *** 480 !! 481 !! ** Purpose : Compute the interpolation of tracer at w-point 482 !! 483 !! ** Method : 4th order compact interpolation 484 !!---------------------------------------------------------------------- 485 REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pt_in ! now tracer fields 486 REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT( out) :: pt_out ! now tracer field interpolated at w-pts 487 ! 488 INTEGER :: ji, jj, jk ! dummy loop integers 489 REAL(wp),DIMENSION(jpi,jpj,jpk) :: zwd, zwi, zws, zwrm, zwt 490 !!---------------------------------------------------------------------- 491 492 DO_3D( 1, 1, 1, 1, 3, jpkm1 ) !== build the three diagonal matrix ==! 493 zwd (ji,jj,jk) = 4._wp 494 zwi (ji,jj,jk) = 1._wp 495 zws (ji,jj,jk) = 1._wp 496 zwrm(ji,jj,jk) = 3._wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) 497 ! 498 IF( tmask(ji,jj,jk+1) == 0._wp) THEN ! Switch to second order centered at bottom 499 zwd (ji,jj,jk) = 1._wp 500 zwi (ji,jj,jk) = 0._wp 501 zws (ji,jj,jk) = 0._wp 502 zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) 503 ENDIF 504 END_3D 505 ! 506 jk = 2 ! Switch to second order centered at top 507 DO_2D( 1, 1, 1, 1 ) 508 zwd (ji,jj,jk) = 1._wp 509 zwi (ji,jj,jk) = 0._wp 510 zws (ji,jj,jk) = 0._wp 511 zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) ) 512 END_2D 513 ! 514 ! !== tridiagonal solve ==! 515 DO_2D( 1, 1, 1, 1 ) ! first recurrence 516 zwt(ji,jj,2) = zwd(ji,jj,2) 517 END_2D 518 DO_3D( 1, 1, 1, 1, 3, jpkm1 ) 519 zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1) 520 END_3D 521 ! 522 DO_2D( 1, 1, 1, 1 ) ! second recurrence: Zk = Yk - Ik / Tk-1 Zk-1 523 pt_out(ji,jj,2) = zwrm(ji,jj,2) 524 END_2D 525 DO_3D( 1, 1, 1, 1, 3, jpkm1 ) 526 pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) 527 END_3D 528 529 DO_2D( 1, 1, 1, 1 ) ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk 530 pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) 531 END_2D 532 DO_3DS( 1, 1, 1, 1, jpk-2, 2, -1 ) 533 pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) 534 END_3D 535 ! 536 END SUBROUTINE interp_4th_cpt_org 537 538 539 SUBROUTINE interp_4th_cpt( pt_in, pt_out ) 540 !!---------------------------------------------------------------------- 541 !! *** ROUTINE interp_4th_cpt *** 542 !! 543 !! ** Purpose : Compute the interpolation of tracer at w-point 544 !! 545 !! ** Method : 4th order compact interpolation 546 !!---------------------------------------------------------------------- 547 REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in ) :: pt_in ! field at t-point 548 REAL(wp),DIMENSION(A2D(nn_hls) ,jpk), INTENT( out) :: pt_out ! field interpolated at w-point 549 ! 550 INTEGER :: ji, jj, jk ! dummy loop integers 551 INTEGER :: ikt, ikb ! local integers 552 REAL(wp),DIMENSION(A2D(nn_hls),jpk) :: zwd, zwi, zws, zwrm, zwt 553 !!---------------------------------------------------------------------- 554 ! 555 ! !== build the three diagonal matrix & the RHS ==! 556 ! 557 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) ! interior (from jk=3 to jpk-1) 558 zwd (ji,jj,jk) = 3._wp * wmask(ji,jj,jk) + 1._wp ! diagonal 559 zwi (ji,jj,jk) = wmask(ji,jj,jk) ! lower diagonal 560 zws (ji,jj,jk) = wmask(ji,jj,jk) ! upper diagonal 561 zwrm(ji,jj,jk) = 3._wp * wmask(ji,jj,jk) & ! RHS 562 & * ( pt_in(ji,jj,jk) + pt_in(ji,jj,jk-1) ) 563 END_3D 564 ! 565 !!gm 566 ! SELECT CASE( kbc ) !* boundary condition 567 ! CASE( np_NH ) ! Neumann homogeneous at top & bottom 568 ! CASE( np_CEN2 ) ! 2nd order centered at top & bottom 569 ! END SELECT 570 !!gm 571 ! 572 IF ( ln_isfcav ) THEN ! set level two values which may not be set in ISF case 573 zwd(:,:,2) = 1._wp ; zwi(:,:,2) = 0._wp ; zws(:,:,2) = 0._wp ; zwrm(:,:,2) = 0._wp 574 END IF 575 ! 576 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! 2nd order centered at top & bottom 577 ikt = mikt(ji,jj) + 1 ! w-point below the 1st wet point 578 ikb = MAX(mbkt(ji,jj), 2) ! - above the last wet point 579 ! 580 zwd (ji,jj,ikt) = 1._wp ! top 581 zwi (ji,jj,ikt) = 0._wp 582 zws (ji,jj,ikt) = 0._wp 583 zwrm(ji,jj,ikt) = 0.5_wp * ( pt_in(ji,jj,ikt-1) + pt_in(ji,jj,ikt) ) 584 ! 585 zwd (ji,jj,ikb) = 1._wp ! bottom 586 zwi (ji,jj,ikb) = 0._wp 587 zws (ji,jj,ikb) = 0._wp 588 zwrm(ji,jj,ikb) = 0.5_wp * ( pt_in(ji,jj,ikb-1) + pt_in(ji,jj,ikb) ) 589 END_2D 590 ! 591 ! !== tridiagonal solver ==! 592 ! 593 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 1st recurrence: Tk = Dk - Ik Sk-1 / Tk-1 594 zwt(ji,jj,2) = zwd(ji,jj,2) 595 END_2D 596 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) 597 zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1) 598 END_3D 599 ! 600 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 2nd recurrence: Zk = Yk - Ik / Tk-1 Zk-1 601 pt_out(ji,jj,2) = zwrm(ji,jj,2) 602 END_2D 603 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 3, jpkm1 ) 604 pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) 605 END_3D 606 607 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 3d recurrence: Xk = (Zk - Sk Xk+1 ) / Tk 608 pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) 609 END_2D 610 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, 2, -1 ) 611 pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) 612 END_3D 613 ! 614 END SUBROUTINE interp_4th_cpt 615 616 617 SUBROUTINE tridia_solver( pD, pU, pL, pRHS, pt_out , klev ) 618 !!---------------------------------------------------------------------- 619 !! *** ROUTINE tridia_solver *** 620 !! 621 !! ** Purpose : solve a symmetric 3diagonal system 622 !! 623 !! ** Method : solve M.t_out = RHS(t) where M is a tri diagonal matrix ( jpk*jpk ) 624 !! 625 !! ( D_1 U_1 0 0 0 )( t_1 ) ( RHS_1 ) 626 !! ( L_2 D_2 U_2 0 0 )( t_2 ) ( RHS_2 ) 627 !! ( 0 L_3 D_3 U_3 0 )( t_3 ) = ( RHS_3 ) 628 !! ( ... )( ... ) ( ... ) 629 !! ( 0 0 0 L_k D_k )( t_k ) ( RHS_k ) 630 !! 631 !! M is decomposed in the product of an upper and lower triangular matrix. 632 !! The tri-diagonals matrix is given as input 3D arrays: pD, pU, pL 633 !! (i.e. the Diagonal, the Upper diagonal, and the Lower diagonal). 634 !! The solution is pta. 635 !! The 3d array zwt is used as a work space array. 636 !!---------------------------------------------------------------------- 637 REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: pD, pU, PL ! 3-diagonal matrix 638 REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: pRHS ! Right-Hand-Side 639 REAL(wp),DIMENSION(A2D(nn_hls),jpk), INTENT( out) :: pt_out !!gm field at level=F(klev) 640 INTEGER , INTENT(in ) :: klev ! =1 pt_out at w-level 641 ! ! =0 pt at t-level 642 INTEGER :: ji, jj, jk ! dummy loop integers 643 INTEGER :: kstart ! local indices 644 REAL(wp),DIMENSION(A2D(nn_hls),jpk) :: zwt ! 3D work array 645 !!---------------------------------------------------------------------- 646 ! 647 kstart = 1 + klev 648 ! 649 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 1st recurrence: Tk = Dk - Ik Sk-1 / Tk-1 650 zwt(ji,jj,kstart) = pD(ji,jj,kstart) 651 END_2D 652 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, kstart+1, jpkm1 ) 653 zwt(ji,jj,jk) = pD(ji,jj,jk) - pL(ji,jj,jk) * pU(ji,jj,jk-1) /zwt(ji,jj,jk-1) 654 END_3D 655 ! 656 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 2nd recurrence: Zk = Yk - Ik / Tk-1 Zk-1 657 pt_out(ji,jj,kstart) = pRHS(ji,jj,kstart) 658 END_2D 659 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, kstart+1, jpkm1 ) 660 pt_out(ji,jj,jk) = pRHS(ji,jj,jk) - pL(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1) 661 END_3D 662 663 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* 3d recurrence: Xk = (Zk - Sk Xk+1 ) / Tk 664 pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1) 665 END_2D 666 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, kstart, -1 ) 667 pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - pU(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk) 668 END_3D 669 ! 670 END SUBROUTINE tridia_solver 671 1005 END SUBROUTINE tra_adv_fct_lf 1006 #endif 672 1007 !!====================================================================== 673 1008 END MODULE traadv_fct -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traadv_mus.F90
r14433 r14958 81 81 LOGICAL , INTENT(in ) :: ld_msc_ups ! use upstream scheme within muscl 82 82 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 83 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)83 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 84 84 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume flux components 85 85 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation … … 93 93 !!---------------------------------------------------------------------- 94 94 ! 95 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile95 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 96 96 IF( kt == kit000 ) THEN 97 97 IF(lwp) WRITE(numout,*) … … 139 139 zwy(ji,jj,jk) = vmask(ji,jj,jk) * ( pt(ji,jj+1,jk,jn,Kbb) - pt(ji,jj,jk,jn,Kbb) ) 140 140 END_3D 141 ! lateral boundary conditions (changed sign)142 IF ( nn_hls.EQ.1 ) CALL lbc_lnk( 'traadv_mus', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )143 141 ! !-- Slopes of tracer 144 142 zslpx(:,:,jpk) = 0._wp ! bottom values 145 143 zslpy(:,:,jpk) = 0._wp 146 DO_3D( nn_hls-1, 1, nn_hls-1,1, 1, jpkm1 )144 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 147 145 zslpx(ji,jj,jk) = ( zwx(ji,jj,jk) + zwx(ji-1,jj ,jk) ) & 148 146 & * ( 0.25 + SIGN( 0.25_wp, zwx(ji,jj,jk) * zwx(ji-1,jj ,jk) ) ) … … 151 149 END_3D 152 150 ! 153 DO_3D( nn_hls-1, 1, nn_hls-1,1, 1, jpkm1 ) !-- Slopes limitation151 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !-- Slopes limitation 154 152 zslpx(ji,jj,jk) = SIGN( 1.0_wp, zslpx(ji,jj,jk) ) * MIN( ABS( zslpx(ji ,jj,jk) ), & 155 153 & 2.*ABS( zwx (ji-1,jj,jk) ), & … … 159 157 & 2.*ABS( zwy (ji,jj ,jk) ) ) 160 158 END_3D 161 ! 162 DO_3D( nn_hls-1, 0, nn_hls-1, 0, 1, jpkm1 ) !-- MUSCL horizontal advective fluxes 159 ! NOTE [ comm_cleanup ] : need to change sign to ensure halo 1 - halo 2 compatibility 160 IF ( nn_hls==1 ) CALL lbc_lnk( 'traadv_mus', zslpx, 'T', -1.0_wp , zslpy, 'T', -1.0_wp ) ! lateral boundary conditions (changed sign) 161 ! 162 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) !-- MUSCL horizontal advective fluxes 163 163 ! MUSCL fluxes 164 164 z0u = SIGN( 0.5_wp, pU(ji,jj,jk) ) … … 176 176 zwy(ji,jj,jk) = pV(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy ) 177 177 END_3D 178 IF ( nn_hls.EQ.1 ) CALL lbc_lnk( 'traadv_mus', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp ) ! lateral boundary conditions (changed sign)179 178 ! 180 179 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) !-- Tracer advective trend -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traadv_qck.F90
r14433 r14958 27 27 USE lbclnk ! ocean lateral boundary condition (or mpp link) 28 28 USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 29 #if defined key_loop_fusion 30 USE traadv_qck_lf ! QCK scheme (tra_adv_qck routine - loop fusion version) 31 #endif 29 32 30 33 IMPLICIT NONE … … 91 94 INTEGER , INTENT(in ) :: kjpt ! number of tracers 92 95 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 93 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)96 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 94 97 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume transport components 95 98 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation 96 99 !!---------------------------------------------------------------------- 97 100 ! 98 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile 101 #if defined key_loop_fusion 102 CALL tra_adv_qck_lf ( kt, kit000, cdtype, p2dt, pU, pV, pW, Kbb, Kmm, pt, kjpt, Krhs ) 103 #else 104 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 99 105 IF( kt == kit000 ) THEN 100 106 IF(lwp) WRITE(numout,*) … … 117 123 CALL tra_adv_cen2_k( kt, cdtype, pW, Kmm, pt, kjpt, Krhs ) 118 124 ! 125 #endif 119 126 END SUBROUTINE tra_adv_qck 120 127 … … 129 136 INTEGER , INTENT(in ) :: kjpt ! number of tracers 130 137 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 131 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)138 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 132 139 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU ! i-velocity components 133 140 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! active tracers and RHS of tracer equation … … 149 156 zfd(ji,jj,jk) = pt(ji+1,jj,jk,jn,Kbb) ! Downstream in the x-direction for the tracer 150 157 END_3D 151 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp) ! Lateral boundary conditions158 IF (nn_hls==1) CALL lbc_lnk( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, ld4only= .TRUE. ) ! Lateral boundary conditions 152 159 153 160 ! … … 167 174 END_3D 168 175 !--- Lateral boundary conditions 169 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp, zwx(:,:,:), 'T', 1.0_wp )176 IF (nn_hls==1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp, zwx(:,:,:), 'T', 1.0_wp ) 170 177 171 178 !--- QUICKEST scheme … … 176 183 zfu(ji,jj,jk) = tmask(ji-1,jj,jk) + tmask(ji,jj,jk) + tmask(ji+1,jj,jk) - 2. 177 184 END_3D 178 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp) ! Lateral boundary conditions185 IF (nn_hls==1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp, ld4only= .TRUE. ) ! Lateral boundary conditions 179 186 180 187 ! … … 214 221 INTEGER , INTENT(in ) :: kjpt ! number of tracers 215 222 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 216 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)223 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 217 224 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pV ! j-velocity components 218 225 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! active tracers and RHS of tracer equation … … 229 236 zfd(:,:,:) = 0.0 ; zwy(:,:,:) = 0.0 230 237 ! 231 DO jk = 1, jpkm1 232 ! 233 !--- Computation of the ustream and downstream value of the tracer and the mask 234 DO_2D( 0, 0, nn_hls-1, nn_hls-1 ) 235 ! Upstream in the x-direction for the tracer 236 zfc(ji,jj,jk) = pt(ji,jj-1,jk,jn,Kbb) 237 ! Downstream in the x-direction for the tracer 238 zfd(ji,jj,jk) = pt(ji,jj+1,jk,jn,Kbb) 239 END_2D 240 END DO 241 IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp ) ! Lateral boundary conditions 238 !--- Computation of the ustream and downstream value of the tracer and the mask 239 DO_3D( 0, 0, nn_hls-1, nn_hls-1, 1, jpkm1 ) 240 ! Upstream in the x-direction for the tracer 241 zfc(ji,jj,jk) = pt(ji,jj-1,jk,jn,Kbb) 242 ! Downstream in the x-direction for the tracer 243 zfd(ji,jj,jk) = pt(ji,jj+1,jk,jn,Kbb) 244 END_3D 245 246 IF (nn_hls==1) CALL lbc_lnk( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, ld4only= .TRUE. ) ! Lateral boundary conditions 242 247 243 248 ! … … 259 264 260 265 !--- Lateral boundary conditions 261 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp, zwy(:,:,:), 'T', 1.0_wp )266 IF (nn_hls==1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp, zwy(:,:,:), 'T', 1.0_wp ) 262 267 263 268 !--- QUICKEST scheme … … 268 273 zfu(ji,jj,jk) = tmask(ji,jj-1,jk) + tmask(ji,jj,jk) + tmask(ji,jj+1,jk) - 2. 269 274 END_3D 270 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp) !--- Lateral boundary conditions275 IF (nn_hls==1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp, ld4only= .TRUE. ) !--- Lateral boundary conditions 271 276 ! 272 277 ! Tracer flux on the x-direction … … 306 311 CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) 307 312 INTEGER , INTENT(in ) :: kjpt ! number of tracers 308 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)313 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 309 314 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pW ! vertical velocity 310 315 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! active tracers and RHS of tracer equation … … 365 370 !---------------------------------------------------------------------- 366 371 ! 367 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 )372 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 368 373 zc = puc(ji,jj,jk) ! Courant number 369 374 zcurv = pfd(ji,jj,jk) + pfu(ji,jj,jk) - 2. * pfc(ji,jj,jk) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traadv_ubs.F90
r14433 r14958 26 26 USE lbclnk ! ocean lateral boundary condition (or mpp link) 27 27 USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 28 #if defined key_loop_fusion 29 USE traadv_ubs_lf ! UBS scheme (tra_adv_ubs routine - loop fusion version) 30 #endif 28 31 29 32 IMPLICIT NONE … … 92 95 INTEGER , INTENT(in ) :: kn_ubs_v ! number of tracers 93 96 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 94 ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)97 ! TEMP: [tiling] This can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 95 98 REAL(wp), DIMENSION(jpi,jpj,jpk ), INTENT(in ) :: pU, pV, pW ! 3 ocean volume transport components 96 99 REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) :: pt ! tracers and RHS of tracer equation … … 103 106 !!---------------------------------------------------------------------- 104 107 ! 105 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile 108 #if defined key_loop_fusion 109 CALL tra_adv_ubs_lf ( kt, kit000, cdtype, p2dt, pU, pV, pW, Kbb, Kmm, pt, kjpt, Krhs, kn_ubs_v ) 110 #else 111 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 106 112 IF( kt == kit000 ) THEN 107 113 IF(lwp) WRITE(numout,*) … … 140 146 ! 141 147 END DO 142 IF (nn_hls .EQ.1) CALL lbc_lnk( 'traadv_ubs', zltu, 'T', 1.0_wp, zltv, 'T', 1.0_wp) ! Lateral boundary cond. (unchanged sgn)148 IF (nn_hls==1) CALL lbc_lnk( 'traadv_ubs', zltu, 'T', 1.0_wp, zltv, 'T', 1.0_wp, ld4only= .TRUE. ) ! Lateral boundary cond. (unchanged sgn) 143 149 ! 144 150 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) !== Horizontal advective fluxes ==! (UBS) … … 155 161 END_3D 156 162 ! 157 DO_3D( 1, 1, 1, 1, 1, jpk )163 DO_3D( 0, 0, 0, 0, 1, jpk ) 158 164 zltu(ji,jj,jk) = pt(ji,jj,jk,jn,Krhs) ! store the initial trends before its update 159 165 END_3D … … 169 175 END DO 170 176 ! 171 DO_3D( 1, 1, 1, 1, 1, jpk )177 DO_3D( 0, 0, 0, 0, 1, jpk ) 172 178 zltu(ji,jj,jk) = pt(ji,jj,jk,jn,Krhs) - zltu(ji,jj,jk) ! Horizontal advective trend used in vertical 2nd order FCT case 173 179 END_3D ! and/or in trend diagnostic (l_trd=T) … … 197 203 ! 198 204 ! !* upstream advection with initial mass fluxes & intermediate update ==! 199 DO_3D( 1, 1, 1, 1, 2, jpkm1 )205 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 200 206 zfp_wk = pW(ji,jj,jk) + ABS( pW(ji,jj,jk) ) 201 207 zfm_wk = pW(ji,jj,jk) - ABS( pW(ji,jj,jk) ) … … 204 210 IF( ln_linssh ) THEN ! top ocean value (only in linear free surface as ztw has been w-masked) 205 211 IF( ln_isfcav ) THEN ! top of the ice-shelf cavities and at the ocean surface 206 DO_2D( 1, 1, 1, 1)212 DO_2D( 0, 0, 0, 0 ) 207 213 ztw(ji,jj, mikt(ji,jj) ) = pW(ji,jj,mikt(ji,jj)) * pt(ji,jj,mikt(ji,jj),jn,Kbb) ! linear free surface 208 214 END_2D 209 215 ELSE ! no cavities: only at the ocean surface 210 DO_2D( 1, 1, 1, 1)216 DO_2D( 0, 0, 0, 0 ) 211 217 ztw(ji,jj,1) = pW(ji,jj,1) * pt(ji,jj,1,jn,Kbb) 212 218 END_2D … … 222 228 ! 223 229 ! !* anti-diffusive flux : high order minus low order 224 DO_3D( 1, 1, 1, 1, 2, jpkm1 )230 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 225 231 ztw(ji,jj,jk) = ( 0.5_wp * pW(ji,jj,jk) * ( pt(ji,jj,jk,jn,Kmm) + pt(ji,jj,jk-1,jn,Kmm) ) & 226 232 & - ztw(ji,jj,jk) ) * wmask(ji,jj,jk) … … 237 243 END_3D 238 244 IF( ln_linssh ) THEN 239 DO_2D( 1, 1, 1, 1)245 DO_2D( 0, 0, 0, 0 ) 240 246 ztw(ji,jj,1) = pW(ji,jj,1) * pt(ji,jj,1,jn,Kmm) !!gm ISF & 4th COMPACT doesn't work 241 247 END_2D … … 260 266 END DO 261 267 ! 268 #endif 262 269 END SUBROUTINE tra_adv_ubs 263 270 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/trabbc.F90
r14072 r14958 102 102 ENDIF 103 103 ! 104 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only for the full domain 105 CALL iom_put ( "hfgeou" , rho0_rcp * qgh_trd0(:,:) ) 106 ENDIF 104 CALL iom_put ( "hfgeou" , rho0_rcp * qgh_trd0(:,:) ) 105 107 106 IF(sn_cfctl%l_prtctl) CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' bbc - Ta: ', mask1=tmask, clinfo3='tra-ta' ) 108 107 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/trabbl.F90
r14433 r14958 126 126 CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' bbl_ldf - Ta: ', mask1=tmask, & 127 127 & tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2= ' Sa: ', mask2=tmask, clinfo3='tra' ) 128 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 129 CALL iom_put( "ahu_bbl", ahu_bbl ) ! bbl diffusive flux i-coef 130 CALL iom_put( "ahv_bbl", ahv_bbl ) ! bbl diffusive flux j-coef 131 ENDIF 128 CALL iom_put( "ahu_bbl", ahu_bbl ) ! bbl diffusive flux i-coef 129 CALL iom_put( "ahv_bbl", ahv_bbl ) ! bbl diffusive flux j-coef 132 130 ! 133 131 ENDIF … … 139 137 CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' bbl_adv - Ta: ', mask1=tmask, & 140 138 & tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2= ' Sa: ', mask2=tmask, clinfo3='tra' ) 141 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 142 ! lateral boundary conditions ; just need for outputs 143 CALL lbc_lnk( 'trabbl', utr_bbl, 'U', 1.0_wp , vtr_bbl, 'V', 1.0_wp ) 144 CALL iom_put( "uoce_bbl", utr_bbl ) ! bbl i-transport 145 CALL iom_put( "voce_bbl", vtr_bbl ) ! bbl j-transport 146 ENDIF 139 CALL iom_put( "uoce_bbl", utr_bbl ) ! bbl i-transport 140 CALL iom_put( "voce_bbl", vtr_bbl ) ! bbl j-transport 147 141 ! 148 142 ENDIF … … 215 209 216 210 211 ! NOTE: [tiling] tiling changes the results, but only the order of floating point operations is different 217 212 SUBROUTINE tra_bbl_adv( pt, pt_rhs, kjpt, Kmm ) 218 213 !!---------------------------------------------------------------------- … … 238 233 INTEGER :: iis , iid , ijs , ijd ! local integers 239 234 INTEGER :: ikus, ikud, ikvs, ikvd ! - - 240 INTEGER :: isi, isj ! - -241 235 REAL(wp) :: zbtr, ztra ! local scalars 242 236 REAL(wp) :: zu_bbl, zv_bbl ! - - 243 237 !!---------------------------------------------------------------------- 244 !245 IF( ntsi == Nis0 ) THEN ; isi = 1 ; ELSE ; isi = 0 ; ENDIF ! Avoid double-counting when using tiling246 IF( ntsj == Njs0 ) THEN ; isj = 1 ; ELSE ; isj = 0 ; ENDIF247 238 ! ! =========== 248 239 DO jn = 1, kjpt ! tracer loop 249 240 ! ! =========== 250 DO_2D ( isi, 0, isj, 0 ) ! CAUTION start from i=1 to update i=2 when cyclic east-west241 DO_2D_OVR( 1, 0, 1, 0 ) ! CAUTION start from i=1 to update i=2 when cyclic east-west 251 242 IF( utr_bbl(ji,jj) /= 0.e0 ) THEN ! non-zero i-direction bbl advection 252 243 ! down-slope i/k-indices (deep) & up-slope i/k indices (shelf) … … 340 331 !!---------------------------------------------------------------------- 341 332 ! 342 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile333 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 343 334 IF( kt == kit000 ) THEN 344 335 IF(lwp) WRITE(numout,*) … … 363 354 IF( nn_bbl_ldf == 1 ) THEN ! diffusive bbl ! 364 355 ! !-------------------! 365 DO_2D ( 1, 0, 1, 0 ) ! (criteria for non zero flux: grad(rho).grad(h) < 0 )356 DO_2D_OVR( 1, 0, 1, 0 ) ! (criteria for non zero flux: grad(rho).grad(h) < 0 ) 366 357 ! ! i-direction 367 358 za = zab(ji+1,jj,jp_tem) + zab(ji,jj,jp_tem) ! 2*(alpha,beta) at u-point … … 393 384 ! 394 385 CASE( 1 ) != use of upper velocity 395 DO_2D ( 1, 0, 1, 0 ) ! criteria: grad(rho).grad(h)<0 and grad(rho).grad(h)<0386 DO_2D_OVR( 1, 0, 1, 0 ) ! criteria: grad(rho).grad(h)<0 and grad(rho).grad(h)<0 396 387 ! ! i-direction 397 388 za = zab(ji+1,jj,jp_tem) + zab(ji,jj,jp_tem) ! 2*(alpha,beta) at u-point … … 422 413 CASE( 2 ) != bbl velocity = F( delta rho ) 423 414 zgbbl = grav * rn_gambbl 424 DO_2D ( 1, 0, 1, 0 ) ! criteria: rho_up > rho_down415 DO_2D_OVR( 1, 0, 1, 0 ) ! criteria: rho_up > rho_down 425 416 ! ! i-direction 426 417 ! down-slope T-point i/k-index (deep) & up-slope T-point i/k-index (shelf) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/tradmp.F90
r14072 r14958 101 101 IF( ln_timing ) CALL timing_start('tra_dmp') 102 102 ! 103 IF( l_trdtra ) THEN!* Save ta and sa trends103 IF( l_trdtra .OR. iom_use('hflx_dmp_cea') .OR. iom_use('sflx_dmp_cea') ) THEN !* Save ta and sa trends 104 104 ALLOCATE( ztrdts(jpi,jpj,jpk,jpts) ) 105 105 ztrdts(:,:,:,:) = pts(:,:,:,:,Krhs) … … 139 139 ! 140 140 END SELECT 141 ! 142 ! outputs (clem trunk) 143 IF( iom_use('hflx_dmp_cea') ) & 144 & CALL iom_put('hflx_dmp_cea', & 145 & SUM( ( pts(:,:,:,jp_tem,Krhs) - ztrdts(:,:,:,jp_tem) ) * e3t(:,:,:,Kmm), dim=3 ) * rcp * rho0 ) ! W/m2 146 IF( iom_use('sflx_dmp_cea') ) & 147 & CALL iom_put('sflx_dmp_cea', & 148 & SUM( ( pts(:,:,:,jp_sal,Krhs) - ztrdts(:,:,:,jp_sal) ) * e3t(:,:,:,Kmm), dim=3 ) * rho0 ) ! g/m2/s 141 149 ! 142 150 IF( l_trdtra ) THEN ! trend diagnostic -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traisf.F90
r14072 r14958 47 47 IF( ln_timing ) CALL timing_start('tra_isf') 48 48 ! 49 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile49 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 50 50 IF( kt == nit000 ) THEN 51 51 IF(lwp) WRITE(numout,*) … … 79 79 ! 80 80 IF ( ln_isfdebug ) THEN 81 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only for the full domain81 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only for the full domain 82 82 CALL debug('tra_isf: pts(:,:,:,:,Krhs) T', pts(:,:,:,1,Krhs)) 83 83 CALL debug('tra_isf: pts(:,:,:,:,Krhs) S', pts(:,:,:,2,Krhs)) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traldf.F90
r14189 r14958 17 17 USE oce ! ocean dynamics and tracers 18 18 USE dom_oce ! ocean space and time domain 19 ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed from tra_ldf_blp, zps_hde*)20 USE domtile21 19 USE phycst ! physical constants 22 20 USE ldftra ! lateral diffusion: eddy diffusivity & EIV coeff. … … 58 56 !! 59 57 REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: ztrdt, ztrds 60 ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed from tra_ldf_blp, zps_hde*)61 LOGICAL :: lskip62 58 !!---------------------------------------------------------------------- 63 59 ! 64 60 IF( ln_timing ) CALL timing_start('tra_ldf') 65 61 ! 66 lskip = .FALSE.67 68 62 IF( l_trdtra ) THEN !* Save ta and sa trends 69 63 ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) ) … … 71 65 ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) 72 66 ENDIF 73 74 ! TEMP: [tiling] These changes not necessary after extra haloes development (lbc_lnk removed from tra_ldf_blp, zps_hde*) 75 IF( nldf_tra == np_blp .OR. nldf_tra == np_blp_i .OR. nldf_tra == np_blp_it ) THEN 76 IF( ln_tile ) THEN 77 IF( ntile == 1 ) THEN 78 CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) 79 ELSE 80 lskip = .TRUE. 81 ENDIF 82 ENDIF 83 ENDIF 84 IF( .NOT. lskip ) THEN 85 ! 86 SELECT CASE ( nldf_tra ) !* compute lateral mixing trend and add it to the general trend 87 CASE ( np_lap ) ! laplacian: iso-level operator 88 CALL tra_ldf_lap ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, 1 ) 89 CASE ( np_lap_i ) ! laplacian: standard iso-neutral operator (Madec) 90 CALL tra_ldf_iso ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, 1 ) 91 CASE ( np_lap_it ) ! laplacian: triad iso-neutral operator (griffies) 92 CALL tra_ldf_triad( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, 1 ) 93 CASE ( np_blp , np_blp_i , np_blp_it ) ! bilaplacian: iso-level & iso-neutral operators 94 IF(nn_hls.EQ.2) CALL lbc_lnk( 'tra_ldf', pts(:,:,:,:,Kbb), 'T',1.) 95 CALL tra_ldf_blp ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, nldf_tra ) 96 END SELECT 97 ! 98 IF( l_trdtra ) THEN !* save the horizontal diffusive trends for further diagnostics 99 ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:) 100 ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) - ztrds(:,:,:) 101 CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_ldf, ztrdt ) 102 CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_ldf, ztrds ) 103 DEALLOCATE( ztrdt, ztrds ) 104 ENDIF 105 106 ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed from tra_ldf_blp, zps_hde*) 107 IF( ln_tile .AND. ntile == 0 ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 1 ) 67 ! 68 SELECT CASE ( nldf_tra ) !* compute lateral mixing trend and add it to the general trend 69 CASE ( np_lap ) ! laplacian: iso-level operator 70 CALL tra_ldf_lap ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, 1 ) 71 CASE ( np_lap_i ) ! laplacian: standard iso-neutral operator (Madec) 72 CALL tra_ldf_iso ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, 1 ) 73 CASE ( np_lap_it ) ! laplacian: triad iso-neutral operator (griffies) 74 CALL tra_ldf_triad( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, 1 ) 75 CASE ( np_blp , np_blp_i , np_blp_it ) ! bilaplacian: iso-level & iso-neutral operators 76 CALL tra_ldf_blp ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts, nldf_tra ) 77 END SELECT 78 ! 79 IF( l_trdtra ) THEN !* save the horizontal diffusive trends for further diagnostics 80 ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:) 81 ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) - ztrds(:,:,:) 82 CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_ldf, ztrdt ) 83 CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_ldf, ztrds ) 84 DEALLOCATE( ztrdt, ztrds ) 108 85 ENDIF 109 86 ! !* print mean trends (used for debugging) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traldf_iso.F90
r14072 r14958 132 132 INTEGER :: ji, jj, jk, jn ! dummy loop indices 133 133 INTEGER :: ikt 134 INTEGER :: ierr 134 INTEGER :: ierr, iij ! local integer 135 135 REAL(wp) :: zmsku, zahu_w, zabe1, zcof1, zcoef3 ! local scalars 136 136 REAL(wp) :: zmskv, zahv_w, zabe2, zcof2, zcoef4 ! - - … … 141 141 ! 142 142 IF( kpass == 1 .AND. kt == kit000 ) THEN 143 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile143 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 144 144 IF(lwp) WRITE(numout,*) 145 145 IF(lwp) WRITE(numout,*) 'tra_ldf_iso : rotated laplacian diffusion operator on ', cdtype … … 147 147 ENDIF 148 148 ! 149 DO_3D ( 0, 0, 0, 0, 1, jpk )149 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 150 150 akz (ji,jj,jk) = 0._wp 151 151 ah_wslp2(ji,jj,jk) = 0._wp … … 153 153 ENDIF 154 154 ! 155 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile155 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 156 156 l_hst = .FALSE. 157 157 l_ptr = .FALSE. … … 161 161 ENDIF 162 162 ! 163 ! Define pt_rhs halo points for multi-point haloes in bilaplacian case 164 IF( nldf_tra == np_blp_i .AND. kpass == 1 ) THEN ; iij = nn_hls 165 ELSE ; iij = 1 166 ENDIF 167 163 168 ! 164 169 IF( kpass == 1 ) THEN ; zsign = 1._wp ! bilaplacian operator require a minus sign (eddy diffusivity >0) … … 172 177 IF( kpass == 1 ) THEN !== first pass only ==! 173 178 ! 174 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )179 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 175 180 ! 176 181 zmsku = wmask(ji,jj,jk) / MAX( umask(ji ,jj,jk-1) + umask(ji-1,jj,jk) & … … 179 184 & + vmask(ji,jj-1,jk-1) + vmask(ji,jj ,jk) , 1._wp ) 180 185 ! 181 zahu_w = ( pahu(ji ,jj,jk-1) + pahu(ji-1,jj,jk) & 182 & + pahu(ji-1,jj,jk-1) + pahu(ji ,jj,jk) ) * zmsku 183 zahv_w = ( pahv(ji,jj ,jk-1) + pahv(ji,jj-1,jk) & 184 & + pahv(ji,jj-1,jk-1) + pahv(ji,jj ,jk) ) * zmskv 186 ! round brackets added to fix the order of floating point operations 187 ! needed to ensure halo 1 - halo 2 compatibility 188 zahu_w = ( ( pahu(ji ,jj,jk-1) + pahu(ji-1,jj,jk) & 189 & ) & ! bracket for halo 1 - halo 2 compatibility 190 & + ( pahu(ji-1,jj,jk-1) + pahu(ji ,jj,jk) & 191 & ) & ! bracket for halo 1 - halo 2 compatibility 192 & ) * zmsku 193 zahv_w = ( ( pahv(ji,jj ,jk-1) + pahv(ji,jj-1,jk) & 194 & ) & ! bracket for halo 1 - halo 2 compatibility 195 & + ( pahv(ji,jj-1,jk-1) + pahv(ji,jj ,jk) & 196 & ) & ! bracket for halo 1 - halo 2 compatibility 197 & ) * zmskv 185 198 ! 186 199 ah_wslp2(ji,jj,jk) = zahu_w * wslpi(ji,jj,jk) * wslpi(ji,jj,jk) & … … 189 202 ! 190 203 IF( ln_traldf_msc ) THEN ! stabilizing vertical diffusivity coefficient 191 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 204 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 205 ! round brackets added to fix the order of floating point operations 206 ! needed to ensure halo 1 - halo 2 compatibility 192 207 akz(ji,jj,jk) = 0.25_wp * ( & 193 & 208 & ( ( pahu(ji ,jj,jk) + pahu(ji ,jj,jk-1) ) / ( e1u(ji ,jj) * e1u(ji ,jj) ) & 194 209 & + ( pahu(ji-1,jj,jk) + pahu(ji-1,jj,jk-1) ) / ( e1u(ji-1,jj) * e1u(ji-1,jj) ) & 195 & + ( pahv(ji,jj ,jk) + pahv(ji,jj ,jk-1) ) / ( e2v(ji,jj ) * e2v(ji,jj ) ) & 196 & + ( pahv(ji,jj-1,jk) + pahv(ji,jj-1,jk-1) ) / ( e2v(ji,jj-1) * e2v(ji,jj-1) ) ) 210 & ) & ! bracket for halo 1 - halo 2 compatibility 211 & + ( ( pahv(ji,jj ,jk) + pahv(ji,jj ,jk-1) ) / ( e2v(ji,jj ) * e2v(ji,jj ) ) & 212 & + ( pahv(ji,jj-1,jk) + pahv(ji,jj-1,jk-1) ) / ( e2v(ji,jj-1) * e2v(ji,jj-1) ) & 213 & ) & ! bracket for halo 1 - halo 2 compatibility 214 & ) 197 215 END_3D 198 216 ! 199 217 IF( ln_traldf_blp ) THEN ! bilaplacian operator 200 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )218 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 201 219 akz(ji,jj,jk) = 16._wp & 202 220 & * ah_wslp2 (ji,jj,jk) & … … 206 224 END_3D 207 225 ELSEIF( ln_traldf_lap ) THEN ! laplacian operator 208 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )226 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 209 227 ze3w_2 = e3w(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 210 228 zcoef0 = rDt * ( akz(ji,jj,jk) + ah_wslp2(ji,jj,jk) / ze3w_2 ) … … 214 232 ! 215 233 ELSE ! 33 flux set to zero with akz=ah_wslp2 ==>> computed in full implicit 216 DO_3D ( 0, 0, 0, 0, 1, jpk )234 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 217 235 akz(ji,jj,jk) = ah_wslp2(ji,jj,jk) 218 236 END_3D … … 227 245 !! I - masked horizontal derivative 228 246 !!---------------------------------------------------------------------- 229 !!gm : bug.... why (x,:,:)? (1,jpj,:) and (jpi,1,:) should be sufficient.... 230 zdit (ntsi-nn_hls,:,:) = 0._wp ; zdit (ntei+nn_hls,:,:) = 0._wp 231 zdjt (ntsi-nn_hls,:,:) = 0._wp ; zdjt (ntei+nn_hls,:,:) = 0._wp 232 !!end 247 zdit(:,:,:) = 0._wp 248 zdjt(:,:,:) = 0._wp 233 249 234 250 ! Horizontal tracer gradient 235 DO_3D( 1, 0, 1, 0, 1, jpkm1 )251 DO_3D( iij, iij-1, iij, iij-1, 1, jpkm1 ) 236 252 zdit(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn) - pt(ji,jj,jk,jn) ) * umask(ji,jj,jk) 237 253 zdjt(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn) - pt(ji,jj,jk,jn) ) * vmask(ji,jj,jk) 238 254 END_3D 239 255 IF( ln_zps ) THEN ! botton and surface ocean correction of the horizontal gradient 240 DO_2D( 1, 0, 1, 0 )! bottom correction (partial bottom cell)256 DO_2D( iij, iij-1, iij, iij-1 ) ! bottom correction (partial bottom cell) 241 257 zdit(ji,jj,mbku(ji,jj)) = pgu(ji,jj,jn) 242 258 zdjt(ji,jj,mbkv(ji,jj)) = pgv(ji,jj,jn) 243 259 END_2D 244 260 IF( ln_isfcav ) THEN ! first wet level beneath a cavity 245 DO_2D( 1, 0, 1, 0)261 DO_2D( iij, iij-1, iij, iij-1 ) 246 262 IF( miku(ji,jj) > 1 ) zdit(ji,jj,miku(ji,jj)) = pgui(ji,jj,jn) 247 263 IF( mikv(ji,jj) > 1 ) zdjt(ji,jj,mikv(ji,jj)) = pgvi(ji,jj,jn) … … 256 272 DO jk = 1, jpkm1 ! Horizontal slab 257 273 ! 258 DO_2D( 1, 1, 1, 1)274 DO_2D( iij, iij, iij, iij ) 259 275 ! !== Vertical tracer gradient 260 276 zdk1t(ji,jj) = ( pt(ji,jj,jk,jn) - pt(ji,jj,jk+1,jn) ) * wmask(ji,jj,jk+1) ! level jk+1 … … 265 281 END_2D 266 282 ! 267 DO_2D( 1, 0, 1, 0) !== Horizontal fluxes283 DO_2D( iij, iij-1, iij, iij-1 ) !== Horizontal fluxes 268 284 zabe1 = pahu(ji,jj,jk) * e2_e1u(ji,jj) * e3u(ji,jj,jk,Kmm) 269 285 zabe2 = pahv(ji,jj,jk) * e1_e2v(ji,jj) * e3v(ji,jj,jk,Kmm) … … 278 294 zcof2 = - pahv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv 279 295 ! 280 zftu(ji,jj,jk ) = ( zabe1 * zdit(ji,jj,jk) & 281 & + zcof1 * ( zdkt (ji+1,jj) + zdk1t(ji,jj) & 282 & + zdk1t(ji+1,jj) + zdkt (ji,jj) ) ) * umask(ji,jj,jk) 283 zftv(ji,jj,jk) = ( zabe2 * zdjt(ji,jj,jk) & 284 & + zcof2 * ( zdkt (ji,jj+1) + zdk1t(ji,jj) & 285 & + zdk1t(ji,jj+1) + zdkt (ji,jj) ) ) * vmask(ji,jj,jk) 296 ! round brackets added to fix the order of floating point operations 297 ! needed to ensure halo 1 - halo 2 compatibility 298 zftu(ji,jj,jk ) = ( zabe1 * zdit(ji,jj,jk) & 299 & + zcof1 * ( ( zdkt (ji+1,jj) + zdk1t(ji,jj) & 300 & ) & ! bracket for halo 1 - halo 2 compatibility 301 & + ( zdk1t(ji+1,jj) + zdkt (ji,jj) & 302 & ) & ! bracket for halo 1 - halo 2 compatibility 303 & ) ) * umask(ji,jj,jk) 304 zftv(ji,jj,jk) = ( zabe2 * zdjt(ji,jj,jk) & 305 & + zcof2 * ( ( zdkt (ji,jj+1) + zdk1t(ji,jj) & 306 & ) & ! bracket for halo 1 - halo 2 compatibility 307 & + ( zdk1t(ji,jj+1) + zdkt (ji,jj) & 308 & ) & ! bracket for halo 1 - halo 2 compatibility 309 & ) ) * vmask(ji,jj,jk) 286 310 END_2D 287 311 ! 288 DO_2D( 0, 0, 0, 0 ) !== horizontal divergence and add to pta 289 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) & 290 & + zsign * ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk) ) & 291 & * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) 312 DO_2D( iij-1, iij-1, iij-1, iij-1 ) !== horizontal divergence and add to pta 313 ! round brackets added to fix the order of floating point operations 314 ! needed to ensure halo 1 - halo 2 compatibility 315 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) & 316 & + zsign * ( ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk) & 317 & ) & ! bracket for halo 1 - halo 2 compatibility 318 & + ( zftv(ji,jj,jk) - zftv(ji,jj-1,jk) & 319 & ) & ! bracket for halo 1 - halo 2 compatibility 320 & ) * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm) 292 321 END_2D 293 322 END DO ! End of slab … … 302 331 ztfw(:,:, 1 ) = 0._wp ; ztfw(:,:,jpk) = 0._wp 303 332 304 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! interior (2=<jk=<jpk-1)333 DO_3D( iij-1, iij-1, iij-1, iij-1, 2, jpkm1 ) ! interior (2=<jk=<jpk-1) 305 334 ! 306 335 zmsku = wmask(ji,jj,jk) / MAX( umask(ji ,jj,jk-1) + umask(ji-1,jj,jk) & … … 317 346 zcoef4 = - zahv_w * e1t(ji,jj) * zmskv * wslpj (ji,jj,jk) 318 347 ! 319 ztfw(ji,jj,jk) = zcoef3 * ( zdit(ji ,jj ,jk-1) + zdit(ji-1,jj ,jk) & 320 & + zdit(ji-1,jj ,jk-1) + zdit(ji ,jj ,jk) ) & 321 & + zcoef4 * ( zdjt(ji ,jj ,jk-1) + zdjt(ji ,jj-1,jk) & 322 & + zdjt(ji ,jj-1,jk-1) + zdjt(ji ,jj ,jk) ) 348 ! round brackets added to fix the order of floating point operations 349 ! needed to ensure halo 1 - halo 2 compatibility 350 ztfw(ji,jj,jk) = zcoef3 * ( ( zdit(ji ,jj ,jk-1) + zdit(ji-1,jj ,jk) & 351 & ) & ! bracket for halo 1 - halo 2 compatibility 352 & + ( zdit(ji-1,jj ,jk-1) + zdit(ji ,jj ,jk) & 353 & ) & ! bracket for halo 1 - halo 2 compatibility 354 & ) & 355 & + zcoef4 * ( ( zdjt(ji ,jj ,jk-1) + zdjt(ji ,jj-1,jk) & 356 & ) & ! bracket for halo 1 - halo 2 compatibility 357 & + ( zdjt(ji ,jj-1,jk-1) + zdjt(ji ,jj ,jk) & 358 & ) & ! bracket for halo 1 - halo 2 compatibility 359 & ) 323 360 END_3D 324 361 ! !== add the vertical 33 flux ==! 325 362 IF( ln_traldf_lap ) THEN ! laplacian case: eddy coef = ah_wslp2 - akz 326 DO_3D( 0, 0, 0, 0, 2, jpkm1 )363 DO_3D( iij-1, iij-1, iij-1, iij-1, 2, jpkm1 ) 327 364 ztfw(ji,jj,jk) = ztfw(ji,jj,jk) + e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * wmask(ji,jj,jk) & 328 365 & * ( ah_wslp2(ji,jj,jk) - akz(ji,jj,jk) ) & … … 333 370 SELECT CASE( kpass ) 334 371 CASE( 1 ) ! 1st pass : eddy coef = ah_wslp2 335 DO_3D( 0, 0, 0, 0, 2, jpkm1 )372 DO_3D( iij-1, iij-1, iij-1, iij-1, 2, jpkm1 ) 336 373 ztfw(ji,jj,jk) = & 337 374 & ztfw(ji,jj,jk) + ah_wslp2(ji,jj,jk) * e1e2t(ji,jj) & … … 347 384 ENDIF 348 385 ! 349 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) !== Divergence of vertical fluxes added to pta ==!386 DO_3D( iij-1, iij-1, iij-1, iij-1, 1, jpkm1 ) !== Divergence of vertical fluxes added to pta ==! 350 387 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) + zsign * ( ztfw (ji,jj,jk) - ztfw(ji,jj,jk+1) ) * r1_e1e2t(ji,jj) & 351 388 & / e3t(ji,jj,jk,Kmm) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traldf_lap_blp.F90
r14215 r14958 103 103 ! 104 104 INTEGER :: ji, jj, jk, jn ! dummy loop indices 105 INTEGER :: i si, iei, isj, iej ! local integers105 INTEGER :: iij 106 106 REAL(wp) :: zsign ! local scalars 107 107 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: ztu, ztv, zaheeu, zaheev 108 108 !!---------------------------------------------------------------------- 109 109 ! 110 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile110 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 111 111 IF( kt == nit000 .AND. lwp ) THEN 112 112 WRITE(numout,*) … … 122 122 ENDIF 123 123 ! 124 ! Define pt_rhs halo points for multi-point haloes in bilaplacian case 125 IF( nldf_tra == np_blp .AND. kpass == 1 ) THEN ; iij = nn_hls 126 ELSE ; iij = 1 127 ENDIF 128 124 129 ! !== Initialization of metric arrays used for all tracers ==! 125 130 IF( kpass == 1 ) THEN ; zsign = 1._wp ! bilaplacian operator require a minus sign (eddy diffusivity >0) … … 127 132 ENDIF 128 133 129 IF( ntsi == Nis0 ) THEN ; isi = nn_hls - 1 ; ELSE ; isi = 0 ; ENDIF ! Avoid double-counting when using tiling 130 IF( ntsj == Njs0 ) THEN ; isj = nn_hls - 1 ; ELSE ; isj = 0 ; ENDIF 131 IF( ntei == Nie0 ) THEN ; iei = nn_hls - 1 ; ELSE ; iei = 0 ; ENDIF 132 IF( ntej == Nje0 ) THEN ; iej = nn_hls - 1 ; ELSE ; iej = 0 ; ENDIF 133 134 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) !== First derivative (gradient) ==! 134 DO_3D( iij, iij-1, iij, iij-1, 1, jpkm1 ) !== First derivative (gradient) ==! 135 135 zaheeu(ji,jj,jk) = zsign * pahu(ji,jj,jk) * e2_e1u(ji,jj) * e3u(ji,jj,jk,Kmm) !!gm * umask(ji,jj,jk) pah masked! 136 136 zaheev(ji,jj,jk) = zsign * pahv(ji,jj,jk) * e1_e2v(ji,jj) * e3v(ji,jj,jk,Kmm) !!gm * vmask(ji,jj,jk) … … 141 141 ! ! =========== ! 142 142 ! 143 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 ) !== First derivative (gradient) ==!143 DO_3D( iij, iij-1, iij, iij-1, 1, jpkm1 ) !== First derivative (gradient) ==! 144 144 ztu(ji,jj,jk) = zaheeu(ji,jj,jk) * ( pt(ji+1,jj ,jk,jn) - pt(ji,jj,jk,jn) ) 145 145 ztv(ji,jj,jk) = zaheev(ji,jj,jk) * ( pt(ji ,jj+1,jk,jn) - pt(ji,jj,jk,jn) ) 146 146 END_3D 147 147 IF( ln_zps ) THEN ! set gradient at bottom/top ocean level 148 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) ! bottom148 DO_2D( iij, iij-1, iij, iij-1 ) ! bottom 149 149 ztu(ji,jj,mbku(ji,jj)) = zaheeu(ji,jj,mbku(ji,jj)) * pgu(ji,jj,jn) 150 150 ztv(ji,jj,mbkv(ji,jj)) = zaheev(ji,jj,mbkv(ji,jj)) * pgv(ji,jj,jn) 151 151 END_2D 152 152 IF( ln_isfcav ) THEN ! top in ocean cavities only 153 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 )153 DO_2D( iij, iij-1, iij, iij-1 ) 154 154 IF( miku(ji,jj) > 1 ) ztu(ji,jj,miku(ji,jj)) = zaheeu(ji,jj,miku(ji,jj)) * pgui(ji,jj,jn) 155 155 IF( mikv(ji,jj) > 1 ) ztv(ji,jj,mikv(ji,jj)) = zaheev(ji,jj,mikv(ji,jj)) * pgvi(ji,jj,jn) … … 158 158 ENDIF 159 159 ! 160 DO_3D( isi, iei, isj, iej, 1, jpkm1 ) !== Second derivative (divergence) added to the general tracer trends ==! 161 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) + ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) & 162 & + ztv(ji,jj,jk) - ztv(ji,jj-1,jk) ) & 163 & / ( e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) ) 160 DO_3D( iij-1, iij-1, iij-1, iij-1, 1, jpkm1 ) !== Second derivative (divergence) added to the general tracer trends ==! 161 ! round brackets added to fix the order of floating point operations 162 ! needed to ensure halo 1 - halo 2 compatibility 163 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) + ( ( ztu(ji,jj,jk) - ztu(ji-1,jj,jk) & 164 & ) & ! bracket for halo 1 - halo 2 compatibility 165 & + ( ztv(ji,jj,jk) - ztv(ji,jj-1,jk) & 166 & ) & ! bracket for halo 1 - halo 2 compatibility 167 & ) / ( e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) ) 164 168 END_3D 165 169 ! … … 211 215 !!--------------------------------------------------------------------- 212 216 ! 213 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile217 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 214 218 IF( kt == kit000 .AND. lwp ) THEN 215 219 WRITE(numout,*) … … 235 239 END SELECT 236 240 ! 237 CALL lbc_lnk( 'traldf_lap_blp', zlap(:,:,:,:) , 'T', 1.0_wp ) ! Lateral boundary conditions (unchanged sign)241 IF (nn_hls==1) CALL lbc_lnk( 'traldf_lap_blp', zlap(:,:,:,:) , 'T', 1.0_wp ) ! Lateral boundary conditions (unchanged sign) 238 242 ! ! Partial top/bottom cell: GRADh( zlap ) 239 243 IF( ln_isfcav .AND. ln_zps ) THEN ; CALL zps_hde_isf( kt, Kmm, kjpt, zlap, zglu, zglv, zgui, zgvi ) ! both top & bottom -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traldf_triad.F90
r14215 r14958 13 13 USE oce ! ocean dynamics and active tracers 14 14 USE dom_oce ! ocean space and time domain 15 ! TEMP: [tiling] This change not necessary if XIOS has subdomain support16 USE domtile17 15 USE domutl, ONLY : is_tile 18 16 USE phycst ! physical constants … … 109 107 REAL(wp), DIMENSION(A2D_T(ktt_rhs),JPK,KJPT), INTENT(inout) :: pt_rhs ! tracer trend 110 108 ! 111 INTEGER :: ji, jj, jk, jn ! dummy loop indices 112 INTEGER :: ip,jp,kp ! dummy loop indices 113 INTEGER :: ierr ! local integer 114 REAL(wp) :: zmsku, zabe1, zcof1, zcoef3 ! local scalars 115 REAL(wp) :: zmskv, zabe2, zcof2, zcoef4 ! - - 109 INTEGER :: ji, jj, jk, jn, kp, iij ! dummy loop indices 116 110 REAL(wp) :: zcoef0, ze3w_2, zsign ! - - 117 111 ! 118 REAL(wp) :: zslope_skew, zslope_iso, zslope2, zbu, zbv 119 REAL(wp) :: ze1ur, ze2vr, ze3wr, zdxt, zdyt, zdzt 120 REAL(wp) :: zah, zah_slp, zaei_slp 121 REAL(wp), DIMENSION(A2D(nn_hls),0:1) :: zdkt3d ! vertical tracer gradient at 2 levels 122 REAL(wp), DIMENSION(A2D(nn_hls) ) :: z2d ! 2D workspace 123 REAL(wp), DIMENSION(A2D(nn_hls) ,jpk) :: zdit, zdjt, zftu, zftv, ztfw ! 3D - 124 ! TEMP: [tiling] This can be A2D(nn_hls) if XIOS has subdomain support 125 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zpsi_uw, zpsi_vw 112 REAL(wp) :: zslope2, zbu, zbv, zbu1, zbv1, zslope21, zah, zah1, zah_ip1, zah_jp1, zbu_ip1, zbv_jp1 113 REAL(wp) :: ze1ur, ze2vr, ze3wr, zdxt, zdyt, zdzt, zdyt_jp1, ze3wr_jp1, zdzt_jp1, zah_slp1, zah_slp_jp1, zaei_slp_jp1 114 REAL(wp) :: zah_slp, zaei_slp, zdxt_ip1, ze3wr_ip1, zdzt_ip1, zah_slp_ip1, zaei_slp_ip1, zaei_slp1 115 REAL(wp), DIMENSION(A2D(nn_hls),0:1) :: zdkt3d ! vertical tracer gradient at 2 levels 116 REAL(wp), DIMENSION(A2D(nn_hls) ) :: z2d ! 2D workspace 117 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zdit, zdjt, zftu, zftv, ztfw, zpsi_uw, zpsi_vw ! 3D - 126 118 !!---------------------------------------------------------------------- 127 119 ! 128 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile120 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 129 121 IF( kpass == 1 .AND. kt == kit000 ) THEN 130 122 IF(lwp) WRITE(numout,*) … … 142 134 ENDIF 143 135 ! 136 ! Define pt_rhs halo points for multi-point haloes in bilaplacian case 137 IF( nldf_tra == np_blp_it .AND. kpass == 1 ) THEN ; iij = nn_hls 138 ELSE ; iij = 1 139 ENDIF 140 141 ! 144 142 IF( kpass == 1 ) THEN ; zsign = 1._wp ! bilaplacian operator require a minus sign (eddy diffusivity >0) 145 143 ELSE ; zsign = -1._wp … … 152 150 IF( kpass == 1 ) THEN !== first pass only and whatever the tracer is ==! 153 151 ! 154 DO_3D ( 0, 0, 0, 0, 1, jpk )152 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 155 153 akz (ji,jj,jk) = 0._wp 156 154 ah_wslp2(ji,jj,jk) = 0._wp 157 155 END_3D 158 156 ! 159 DO ip = 0, 1 ! i-k triads 160 DO kp = 0, 1 161 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 162 ze3wr = 1._wp / e3w(ji,jj,jk+kp,Kmm) 163 zbu = e1e2u(ji-ip,jj) * e3u(ji-ip,jj,jk,Kmm) 164 zah = 0.25_wp * pahu(ji-ip,jj,jk) 165 zslope_skew = triadi_g(ji,jj,jk,1-ip,kp) 166 ! Subtract s-coordinate slope at t-points to give slope rel to s-surfaces (do this by *adding* gradient of depth) 167 zslope2 = zslope_skew + ( gdept(ji-ip+1,jj,jk,Kmm) - gdept(ji-ip,jj,jk,Kmm) ) * r1_e1u(ji-ip,jj) * umask(ji-ip,jj,jk+kp) 168 zslope2 = zslope2 *zslope2 169 ah_wslp2(ji,jj,jk+kp) = ah_wslp2(ji,jj,jk+kp) + zah * zbu * ze3wr * r1_e1e2t(ji,jj) * zslope2 170 akz (ji,jj,jk+kp) = akz (ji,jj,jk+kp) + zah * r1_e1u(ji-ip,jj) & 171 & * r1_e1u(ji-ip,jj) * umask(ji-ip,jj,jk+kp) 172 ! 173 END_3D 174 END DO 157 DO kp = 0, 1 ! i-k triads 158 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 159 ze3wr = 1._wp / e3w(ji,jj,jk+kp,Kmm) 160 zbu = e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm) 161 zbu1 = e1e2u(ji-1,jj) * e3u(ji-1,jj,jk,Kmm) 162 zah = 0.25_wp * pahu(ji,jj,jk) 163 zah1 = 0.25_wp * pahu(ji-1,jj,jk) 164 ! Subtract s-coordinate slope at t-points to give slope rel to s-surfaces (do this by *adding* gradient of depth) 165 zslope2 = triadi_g(ji,jj,jk,1,kp) + ( gdept(ji+1,jj,jk,Kmm) - gdept(ji,jj,jk,Kmm) ) * r1_e1u(ji,jj) * umask(ji,jj,jk+kp) 166 zslope2 = zslope2 *zslope2 167 zslope21 = triadi_g(ji,jj,jk,0,kp) + ( gdept(ji,jj,jk,Kmm) - gdept(ji-1,jj,jk,Kmm) ) * r1_e1u(ji-1,jj) * umask(ji-1,jj,jk+kp) 168 zslope21 = zslope21 *zslope21 169 ! round brackets added to fix the order of floating point operations 170 ! needed to ensure halo 1 - halo 2 compatibility 171 ah_wslp2(ji,jj,jk+kp) = ah_wslp2(ji,jj,jk+kp) + ( zah * zbu * ze3wr * r1_e1e2t(ji,jj) * zslope2 & 172 & + zah1 * zbu1 * ze3wr * r1_e1e2t(ji,jj) * zslope21 & 173 & ) ! bracket for halo 1 - halo 2 compatibility 174 akz (ji,jj,jk+kp) = akz (ji,jj,jk+kp) + ( zah * r1_e1u(ji,jj) * r1_e1u(ji,jj) * umask(ji,jj,jk+kp) & 175 + zah1 * r1_e1u(ji-1,jj) * r1_e1u(ji-1,jj) * umask(ji-1,jj,jk+kp) & 176 & ) ! bracket for halo 1 - halo 2 compatibility 177 END_3D 175 178 END DO 176 179 ! 177 DO jp = 0, 1 ! j-k triads 178 DO kp = 0, 1 179 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 180 ze3wr = 1.0_wp / e3w(ji,jj,jk+kp,Kmm) 181 zbv = e1e2v(ji,jj-jp) * e3v(ji,jj-jp,jk,Kmm) 182 zah = 0.25_wp * pahv(ji,jj-jp,jk) 183 zslope_skew = triadj_g(ji,jj,jk,1-jp,kp) 184 ! Subtract s-coordinate slope at t-points to give slope rel to s surfaces 185 ! (do this by *adding* gradient of depth) 186 zslope2 = zslope_skew + ( gdept(ji,jj-jp+1,jk,Kmm) - gdept(ji,jj-jp,jk,Kmm) ) * r1_e2v(ji,jj-jp) * vmask(ji,jj-jp,jk+kp) 187 zslope2 = zslope2 * zslope2 188 ah_wslp2(ji,jj,jk+kp) = ah_wslp2(ji,jj,jk+kp) + zah * zbv * ze3wr * r1_e1e2t(ji,jj) * zslope2 189 akz (ji,jj,jk+kp) = akz (ji,jj,jk+kp) + zah * r1_e2v(ji,jj-jp) & 190 & * r1_e2v(ji,jj-jp) * vmask(ji,jj-jp,jk+kp) 191 ! 192 END_3D 193 END DO 180 DO kp = 0, 1 ! j-k triads 181 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 182 ze3wr = 1.0_wp / e3w(ji,jj,jk+kp,Kmm) 183 zbv = e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm) 184 zbv1 = e1e2v(ji,jj-1) * e3v(ji,jj-1,jk,Kmm) 185 zah = 0.25_wp * pahv(ji,jj,jk) 186 zah1 = 0.25_wp * pahv(ji,jj-1,jk) 187 ! Subtract s-coordinate slope at t-points to give slope rel to s surfaces 188 ! (do this by *adding* gradient of depth) 189 zslope2 = triadj_g(ji,jj,jk,1,kp) + ( gdept(ji,jj+1,jk,Kmm) - gdept(ji,jj,jk,Kmm) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk+kp) 190 zslope2 = zslope2 * zslope2 191 zslope21 = triadj_g(ji,jj,jk,0,kp) + ( gdept(ji,jj,jk,Kmm) - gdept(ji,jj-1,jk,Kmm) ) * r1_e2v(ji,jj-1) * vmask(ji,jj-1,jk+kp) 192 zslope21 = zslope21 * zslope21 193 ! round brackets added to fix the order of floating point operations 194 ! needed to ensure halo 1 - halo 2 compatibility 195 ah_wslp2(ji,jj,jk+kp) = ah_wslp2(ji,jj,jk+kp) + ( zah * zbv * ze3wr * r1_e1e2t(ji,jj) * zslope2 & 196 & + zah1 * zbv1 * ze3wr * r1_e1e2t(ji,jj) * zslope21 & 197 & ) ! bracket for halo 1 - halo 2 compatibility 198 akz (ji,jj,jk+kp) = akz (ji,jj,jk+kp) + ( zah * r1_e2v(ji,jj) * r1_e2v(ji,jj) * vmask(ji,jj,jk+kp) & 199 & + zah1 * r1_e2v(ji,jj-1) * r1_e2v(ji,jj-1) * vmask(ji,jj-1,jk+kp) & 200 & ) ! bracket for halo 1 - halo 2 compatibility 201 END_3D 194 202 END DO 195 203 ! … … 197 205 ! 198 206 IF( ln_traldf_blp ) THEN ! bilaplacian operator 199 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )207 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 200 208 akz(ji,jj,jk) = 16._wp & 201 209 & * ah_wslp2 (ji,jj,jk) & … … 205 213 END_3D 206 214 ELSEIF( ln_traldf_lap ) THEN ! laplacian operator 207 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )215 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 208 216 ze3w_2 = e3w(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 209 217 zcoef0 = rDt * ( akz(ji,jj,jk) + ah_wslp2(ji,jj,jk) / ze3w_2 ) … … 213 221 ! 214 222 ELSE ! 33 flux set to zero with akz=ah_wslp2 ==>> computed in full implicit 215 DO_3D ( 0, 0, 0, 0, 1, jpk )223 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 216 224 akz(ji,jj,jk) = ah_wslp2(ji,jj,jk) 217 225 END_3D 218 226 ENDIF 219 227 ! 220 ! TEMP: [tiling] These changes not necessary if XIOS has subdomain support 221 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only for the full domain 222 IF( ln_ldfeiv_dia .AND. cdtype == 'TRA' ) THEN 223 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) 224 225 zpsi_uw(:,:,:) = 0._wp 226 zpsi_vw(:,:,:) = 0._wp 227 228 DO jp = 0, 1 229 DO kp = 0, 1 230 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 231 zpsi_uw(ji,jj,jk+kp) = zpsi_uw(ji,jj,jk+kp) & 232 & + 0.25_wp * aeiu(ji,jj,jk) * e2u(ji,jj) * triadi_g(ji+jp,jj,jk,1-jp,kp) 233 zpsi_vw(ji,jj,jk+kp) = zpsi_vw(ji,jj,jk+kp) & 234 & + 0.25_wp * aeiv(ji,jj,jk) * e1v(ji,jj) * triadj_g(ji,jj+jp,jk,1-jp,kp) 235 END_3D 236 END DO 237 END DO 238 CALL ldf_eiv_dia( zpsi_uw, zpsi_vw, Kmm ) 239 240 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = nijtile ) 241 ENDIF 228 IF( ln_ldfeiv_dia .AND. cdtype == 'TRA' ) THEN 229 zpsi_uw(:,:,:) = 0._wp 230 zpsi_vw(:,:,:) = 0._wp 231 232 DO kp = 0, 1 233 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) 234 ! round brackets added to fix the order of floating point operations 235 ! needed to ensure halo 1 - halo 2 compatibility 236 zpsi_uw(ji,jj,jk+kp) = zpsi_uw(ji,jj,jk+kp) & 237 & + ( 0.25_wp * aeiu(ji,jj,jk) * e2u(ji,jj) * triadi_g(ji,jj,jk,1,kp) & 238 & + 0.25_wp * aeiu(ji,jj,jk) * e2u(ji,jj) * triadi_g(ji+1,jj,jk,0,kp) & 239 & ) ! bracket for halo 1 - halo 2 compatibility 240 zpsi_vw(ji,jj,jk+kp) = zpsi_vw(ji,jj,jk+kp) & 241 & + ( 0.25_wp * aeiv(ji,jj,jk) * e1v(ji,jj) * triadj_g(ji,jj,jk,1,kp) & 242 & + 0.25_wp * aeiv(ji,jj,jk) * e1v(ji,jj) * triadj_g(ji,jj+1,jk,0,kp) & 243 & ) ! bracket for halo 1 - halo 2 compatibility 244 END_3D 245 END DO 246 CALL ldf_eiv_dia( zpsi_uw, zpsi_vw, Kmm ) 242 247 ENDIF 243 248 ! … … 252 257 zftu(:,:,:) = 0._wp 253 258 zftv(:,:,:) = 0._wp 254 ! 255 DO_3D( 1, 0, 1, 0, 1, jpkm1 ) !== before lateral T & S gradients at T-level jk ==! 259 zdit(:,:,:) = 0._wp 260 zdjt(:,:,:) = 0._wp 261 ! 262 DO_3D( iij, iij-1, iij, iij-1, 1, jpkm1 ) !== before lateral T & S gradients at T-level jk ==! 256 263 zdit(ji,jj,jk) = ( pt(ji+1,jj ,jk,jn) - pt(ji,jj,jk,jn) ) * umask(ji,jj,jk) 257 264 zdjt(ji,jj,jk) = ( pt(ji ,jj+1,jk,jn) - pt(ji,jj,jk,jn) ) * vmask(ji,jj,jk) 258 265 END_3D 259 266 IF( ln_zps .AND. l_grad_zps ) THEN ! partial steps: correction at top/bottom ocean level 260 DO_2D( 1, 0, 1, 0) ! bottom level267 DO_2D( iij, iij-1, iij, iij-1 ) ! bottom level 261 268 zdit(ji,jj,mbku(ji,jj)) = pgu(ji,jj,jn) 262 269 zdjt(ji,jj,mbkv(ji,jj)) = pgv(ji,jj,jn) 263 270 END_2D 264 271 IF( ln_isfcav ) THEN ! top level (ocean cavities only) 265 DO_2D( 1, 0, 1, 0)272 DO_2D( iij, iij-1, iij, iij-1 ) 266 273 IF( miku(ji,jj) > 1 ) zdit(ji,jj,miku(ji,jj) ) = pgui(ji,jj,jn) 267 274 IF( mikv(ji,jj) > 1 ) zdjt(ji,jj,mikv(ji,jj) ) = pgvi(ji,jj,jn) … … 276 283 DO jk = 1, jpkm1 277 284 ! !== Vertical tracer gradient at level jk and jk+1 278 DO_2D( 1, 1, 1, 1)285 DO_2D( iij, iij, iij, iij ) 279 286 zdkt3d(ji,jj,1) = ( pt(ji,jj,jk,jn) - pt(ji,jj,jk+1,jn) ) * tmask(ji,jj,jk+1) 280 287 END_2D … … 283 290 IF( jk == 1 ) THEN ; zdkt3d(:,:,0) = zdkt3d(:,:,1) 284 291 ELSE 285 DO_2D( 1, 1, 1, 1)292 DO_2D( iij, iij, iij, iij ) 286 293 zdkt3d(ji,jj,0) = ( pt(ji,jj,jk-1,jn) - pt(ji,jj,jk,jn) ) * tmask(ji,jj,jk) 287 294 END_2D … … 289 296 ! 290 297 zaei_slp = 0._wp 298 zaei_slp_ip1 = 0._wp 299 zaei_slp_jp1 = 0._wp 300 zaei_slp1 = 0._wp 291 301 ! 292 302 IF( ln_botmix_triad ) THEN 293 DO ip = 0, 1 !== Horizontal & vertical fluxes 294 DO kp = 0, 1 295 DO_2D( 1, 0, 1, 0 ) 296 ze1ur = r1_e1u(ji,jj) 297 zdxt = zdit(ji,jj,jk) * ze1ur 298 ze3wr = 1._wp / e3w(ji+ip,jj,jk+kp,Kmm) 299 zdzt = zdkt3d(ji+ip,jj,kp) * ze3wr 300 zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp) 301 zslope_iso = triadi (ji+ip,jj,jk,1-ip,kp) 302 ! 303 zbu = 0.25_wp * e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm) 304 ! ln_botmix_triad is .T. don't mask zah for bottom half cells !!gm ????? ahu is masked.... 305 zah = pahu(ji,jj,jk) 306 zah_slp = zah * zslope_iso 307 IF( ln_ldfeiv ) zaei_slp = aeiu(ji,jj,jk) * zslope_skew 308 zftu(ji ,jj,jk ) = zftu(ji ,jj,jk ) - ( zah * zdxt + (zah_slp - zaei_slp) * zdzt ) * zbu * ze1ur 309 ztfw(ji+ip,jj,jk+kp) = ztfw(ji+ip,jj,jk+kp) - ( zah_slp + zaei_slp) * zdxt * zbu * ze3wr 310 END_2D 311 END DO 303 DO kp = 0, 1 !== Horizontal & vertical fluxes 304 DO_2D( iij, iij-1, iij, iij-1 ) 305 ze1ur = r1_e1u(ji,jj) 306 zdxt = zdit(ji,jj,jk) * ze1ur 307 zdxt_ip1 = zdit(ji+1,jj,jk) * r1_e1u(ji+1,jj) 308 ze3wr = 1._wp / e3w(ji,jj,jk+kp,Kmm) 309 ze3wr_ip1 = 1._wp / e3w(ji+1,jj,jk+kp,Kmm) 310 zdzt = zdkt3d(ji,jj,kp) * ze3wr 311 zdzt_ip1 = zdkt3d(ji+1,jj,kp) * ze3wr_ip1 312 ! 313 zbu = 0.25_wp * e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm) 314 zbu_ip1 = 0.25_wp * e1e2u(ji+1,jj) * e3u(ji+1,jj,jk,Kmm) 315 ! ln_botmix_triad is .T. don't mask zah for bottom half cells !!gm ????? ahu is masked.... 316 zah = pahu(ji,jj,jk) 317 zah_ip1 = pahu(ji+1,jj,jk) 318 zah_slp = zah * triadi(ji,jj,jk,1,kp) 319 zah_slp_ip1 = zah_ip1 * triadi(ji+1,jj,jk,1,kp) 320 zah_slp1 = zah * triadi(ji+1,jj,jk,0,kp) 321 IF( ln_ldfeiv ) THEN 322 zaei_slp = aeiu(ji,jj,jk) * triadi_g(ji,jj,jk,1,kp) 323 zaei_slp_ip1 = aeiu(ji+1,jj,jk) * triadi_g(ji+1,jj,jk,1,kp) 324 zaei_slp1 = aeiu(ji,jj,jk) * triadi_g(ji+1,jj,jk,0,kp) 325 ENDIF 326 ! round brackets added to fix the order of floating point operations 327 ! needed to ensure halo 1 - halo 2 compatibility 328 zftu(ji ,jj,jk ) = zftu(ji ,jj,jk ) & 329 & - ( ( zah * zdxt + ( zah_slp - zaei_slp ) * zdzt ) * zbu * ze1ur & 330 & + ( zah * zdxt + zah_slp1 * zdzt_ip1 - zaei_slp1 * zdzt_ip1 ) * zbu * ze1ur & 331 & ) ! bracket for halo 1 - halo 2 compatibility 332 ztfw(ji+1,jj,jk+kp) = ztfw(ji+1,jj,jk+kp) & 333 & - ( (zah_slp_ip1 + zaei_slp_ip1) * zdxt_ip1 * zbu_ip1 * ze3wr_ip1 & 334 & + ( zah_slp1 + zaei_slp1) * zdxt * zbu * ze3wr_ip1 & 335 & ) ! bracket for halo 1 - halo 2 compatibility 336 END_2D 312 337 END DO 313 338 ! 314 DO jp = 0, 1 315 DO kp = 0, 1 316 DO_2D( 1, 0, 1, 0 ) 317 ze2vr = r1_e2v(ji,jj) 318 zdyt = zdjt(ji,jj,jk) * ze2vr 319 ze3wr = 1._wp / e3w(ji,jj+jp,jk+kp,Kmm) 320 zdzt = zdkt3d(ji,jj+jp,kp) * ze3wr 321 zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp) 322 zslope_iso = triadj(ji,jj+jp,jk,1-jp,kp) 323 zbv = 0.25_wp * e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm) 324 ! ln_botmix_triad is .T. don't mask zah for bottom half cells !!gm ????? ahv is masked... 325 zah = pahv(ji,jj,jk) 326 zah_slp = zah * zslope_iso 327 IF( ln_ldfeiv ) zaei_slp = aeiv(ji,jj,jk) * zslope_skew 328 zftv(ji,jj ,jk ) = zftv(ji,jj ,jk ) - ( zah * zdyt + (zah_slp - zaei_slp) * zdzt ) * zbv * ze2vr 329 ztfw(ji,jj+jp,jk+kp) = ztfw(ji,jj+jp,jk+kp) - ( zah_slp + zaei_slp ) * zdyt * zbv * ze3wr 330 END_2D 331 END DO 339 DO kp = 0, 1 340 DO_2D( iij, iij-1, iij, iij-1 ) 341 ze2vr = r1_e2v(ji,jj) 342 zdyt = zdjt(ji,jj,jk) * ze2vr 343 zdyt_jp1 = zdjt(ji,jj+1,jk) * r1_e2v(ji,jj+1) 344 ze3wr = 1._wp / e3w(ji,jj,jk+kp,Kmm) 345 ze3wr_jp1 = 1._wp / e3w(ji,jj+1,jk+kp,Kmm) 346 zdzt = zdkt3d(ji,jj,kp) * ze3wr 347 zdzt_jp1 = zdkt3d(ji,jj+1,kp) * ze3wr_jp1 348 zbv = 0.25_wp * e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm) 349 zbv_jp1 = 0.25_wp * e1e2v(ji,jj+1) * e3v(ji,jj+1,jk,Kmm) 350 ! ln_botmix_triad is .T. don't mask zah for bottom half cells !!gm ????? ahu is masked.... 351 zah = pahv(ji,jj,jk) ! pahv(ji,jj+jp,jk) ???? 352 zah_jp1 = pahv(ji,jj+1,jk) 353 zah_slp = zah * triadj(ji,jj,jk,1,kp) 354 zah_slp1 = zah * triadj(ji,jj+1,jk,0,kp) 355 zah_slp_jp1 = zah_jp1 * triadj(ji,jj+1,jk,1,kp) 356 IF( ln_ldfeiv ) THEN 357 zaei_slp = aeiv(ji,jj,jk) * triadj_g(ji,jj,jk,1,kp) 358 zaei_slp_jp1 = aeiv(ji,jj+1,jk) * triadj_g(ji,jj+1,jk,1,kp) 359 zaei_slp1 = aeiv(ji,jj,jk) * triadj_g(ji,jj+1,jk,0,kp) 360 ENDIF 361 ! round brackets added to fix the order of floating point operations 362 ! needed to ensure halo 1 - halo 2 compatibility 363 zftv(ji,jj ,jk ) = zftv(ji,jj ,jk ) & 364 & - ( ( zah * zdyt + ( zah_slp - zaei_slp ) * zdzt ) * zbv * ze2vr & 365 & + ( zah * zdyt + zah_slp1 * zdzt_jp1 - zaei_slp1 * zdzt_jp1 ) * zbv * ze2vr & 366 & ) ! bracket for halo 1 - halo 2 compatibility 367 ztfw(ji,jj+1,jk+kp) = ztfw(ji,jj+1,jk+kp) & 368 & - ( ( zah_slp_jp1 + zaei_slp_jp1) * zdyt_jp1 * zbv_jp1 * ze3wr_jp1 & 369 & + ( zah_slp1 + zaei_slp1) * zdyt * zbv * ze3wr_jp1 & 370 & ) ! bracket for halo 1 - halo 2 compatibility 371 END_2D 332 372 END DO 333 373 ! 334 374 ELSE 335 375 ! 336 DO ip = 0, 1 !== Horizontal & vertical fluxes 337 DO kp = 0, 1 338 DO_2D( 1, 0, 1, 0 ) 339 ze1ur = r1_e1u(ji,jj) 340 zdxt = zdit(ji,jj,jk) * ze1ur 341 ze3wr = 1._wp / e3w(ji+ip,jj,jk+kp,Kmm) 342 zdzt = zdkt3d(ji+ip,jj,kp) * ze3wr 343 zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp) 344 zslope_iso = triadi(ji+ip,jj,jk,1-ip,kp) 345 ! 346 zbu = 0.25_wp * e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm) 347 ! ln_botmix_triad is .F. mask zah for bottom half cells 348 zah = pahu(ji,jj,jk) * umask(ji,jj,jk+kp) ! pahu(ji+ip,jj,jk) ===>> ???? 349 zah_slp = zah * zslope_iso 350 IF( ln_ldfeiv ) zaei_slp = aeiu(ji,jj,jk) * zslope_skew ! aeit(ji+ip,jj,jk)*zslope_skew 351 zftu(ji ,jj,jk ) = zftu(ji ,jj,jk ) - ( zah * zdxt + (zah_slp - zaei_slp) * zdzt ) * zbu * ze1ur 352 ztfw(ji+ip,jj,jk+kp) = ztfw(ji+ip,jj,jk+kp) - (zah_slp + zaei_slp) * zdxt * zbu * ze3wr 353 END_2D 354 END DO 376 DO kp = 0, 1 !== Horizontal & vertical fluxes 377 DO_2D( iij, iij-1, iij, iij-1 ) 378 ze1ur = r1_e1u(ji,jj) 379 zdxt = zdit(ji,jj,jk) * ze1ur 380 zdxt_ip1 = zdit(ji+1,jj,jk) * r1_e1u(ji+1,jj) 381 ze3wr = 1._wp / e3w(ji,jj,jk+kp,Kmm) 382 ze3wr_ip1 = 1._wp / e3w(ji+1,jj,jk+kp,Kmm) 383 zdzt = zdkt3d(ji,jj,kp) * ze3wr 384 zdzt_ip1 = zdkt3d(ji+1,jj,kp) * ze3wr_ip1 385 ! 386 zbu = 0.25_wp * e1e2u(ji,jj) * e3u(ji,jj,jk,Kmm) 387 zbu_ip1 = 0.25_wp * e1e2u(ji+1,jj) * e3u(ji+1,jj,jk,Kmm) 388 ! ln_botmix_triad is .F. mask zah for bottom half cells 389 zah = pahu(ji,jj,jk) * umask(ji,jj,jk+kp) ! pahu(ji+ip,jj,jk) ===>> ???? 390 zah_ip1 = pahu(ji+1,jj,jk) * umask(ji+1,jj,jk+kp) 391 zah_slp = zah * triadi(ji,jj,jk,1,kp) 392 zah_slp_ip1 = zah_ip1 * triadi(ji+1,jj,jk,1,kp) 393 zah_slp1 = zah * triadi(ji+1,jj,jk,0,kp) 394 IF( ln_ldfeiv ) THEN 395 zaei_slp = aeiu(ji,jj,jk) * triadi_g(ji,jj,jk,1,kp) 396 zaei_slp_ip1 = aeiu(ji+1,jj,jk) * triadi_g(ji+1,jj,jk,1,kp) 397 zaei_slp1 = aeiu(ji,jj,jk) * triadi_g(ji+1,jj,jk,0,kp) 398 ENDIF 399 ! round brackets added to fix the order of floating point operations 400 ! needed to ensure halo 1 - halo 2 compatibility 401 zftu(ji ,jj,jk ) = zftu(ji ,jj,jk ) & 402 & - ( ( zah * zdxt + ( zah_slp - zaei_slp ) * zdzt ) * zbu * ze1ur & 403 & + ( zah * zdxt + zah_slp1 * zdzt_ip1 - zaei_slp1 * zdzt_ip1 ) * zbu * ze1ur & 404 & ) ! bracket for halo 1 - halo 2 compatibility 405 ztfw(ji+1,jj,jk+kp) = ztfw(ji+1,jj,jk+kp) & 406 & - ( (zah_slp_ip1 + zaei_slp_ip1) * zdxt_ip1 * zbu_ip1 * ze3wr_ip1 & 407 & + ( zah_slp1 + zaei_slp1) * zdxt * zbu * ze3wr_ip1 & 408 & ) ! bracket for halo 1 - halo 2 compatibility 409 END_2D 355 410 END DO 356 411 ! 357 DO jp = 0, 1 358 DO kp = 0, 1 359 DO_2D( 1, 0, 1, 0 ) 360 ze2vr = r1_e2v(ji,jj) 361 zdyt = zdjt(ji,jj,jk) * ze2vr 362 ze3wr = 1._wp / e3w(ji,jj+jp,jk+kp,Kmm) 363 zdzt = zdkt3d(ji,jj+jp,kp) * ze3wr 364 zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp) 365 zslope_iso = triadj(ji,jj+jp,jk,1-jp,kp) 366 zbv = 0.25_wp * e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm) 367 ! ln_botmix_triad is .F. mask zah for bottom half cells 368 zah = pahv(ji,jj,jk) * vmask(ji,jj,jk+kp) ! pahv(ji,jj+jp,jk) ???? 369 zah_slp = zah * zslope_iso 370 IF( ln_ldfeiv ) zaei_slp = aeiv(ji,jj,jk) * zslope_skew ! aeit(ji,jj+jp,jk)*zslope_skew 371 zftv(ji,jj,jk) = zftv(ji,jj,jk) - ( zah * zdyt + (zah_slp - zaei_slp) * zdzt ) * zbv * ze2vr 372 ztfw(ji,jj+jp,jk+kp) = ztfw(ji,jj+jp,jk+kp) - (zah_slp + zaei_slp) * zdyt * zbv * ze3wr 373 END_2D 374 END DO 412 DO kp = 0, 1 413 DO_2D( iij, iij-1, iij, iij-1 ) 414 ze2vr = r1_e2v(ji,jj) 415 zdyt = zdjt(ji,jj,jk) * ze2vr 416 zdyt_jp1 = zdjt(ji,jj+1,jk) * r1_e2v(ji,jj+1) 417 ze3wr = 1._wp / e3w(ji,jj,jk+kp,Kmm) 418 ze3wr_jp1 = 1._wp / e3w(ji,jj+1,jk+kp,Kmm) 419 zdzt = zdkt3d(ji,jj,kp) * ze3wr 420 zdzt_jp1 = zdkt3d(ji,jj+1,kp) * ze3wr_jp1 421 zbv = 0.25_wp * e1e2v(ji,jj) * e3v(ji,jj,jk,Kmm) 422 zbv_jp1 = 0.25_wp * e1e2v(ji,jj+1) * e3v(ji,jj+1,jk,Kmm) 423 ! ln_botmix_triad is .F. mask zah for bottom half cells 424 zah = pahv(ji,jj,jk) * vmask(ji,jj,jk+kp) ! pahv(ji,jj+jp,jk) ???? 425 zah_jp1 = pahv(ji,jj+1,jk) * vmask(ji,jj+1,jk+kp) 426 zah_slp = zah * triadj(ji,jj,jk,1,kp) 427 zah_slp1 = zah * triadj(ji,jj+1,jk,0,kp) 428 zah_slp_jp1 = zah_jp1 * triadj(ji,jj+1,jk,1,kp) 429 IF( ln_ldfeiv ) THEN 430 zaei_slp = aeiv(ji,jj,jk) * triadj_g(ji,jj,jk,1,kp) 431 zaei_slp_jp1 = aeiv(ji,jj+1,jk) * triadj_g(ji,jj+1,jk,1,kp) 432 zaei_slp1 = aeiv(ji,jj,jk) * triadj_g(ji,jj+1,jk,0,kp) 433 ENDIF 434 ! round brackets added to fix the order of floating point operations 435 ! needed to ensure halo 1 - halo 2 compatibility 436 zftv(ji,jj ,jk ) = zftv(ji,jj ,jk ) & 437 & - ( ( zah * zdyt + ( zah_slp - zaei_slp ) * zdzt ) * zbv * ze2vr & 438 & + ( zah * zdyt + zah_slp1 * zdzt_jp1 - zaei_slp1 * zdzt_jp1 ) * zbv * ze2vr & 439 & ) ! bracket for halo 1 - halo 2 compatibility 440 ztfw(ji,jj+1,jk+kp) = ztfw(ji,jj+1,jk+kp) & 441 & - ( ( zah_slp_jp1 + zaei_slp_jp1) * zdyt_jp1 * zbv_jp1 * ze3wr_jp1 & 442 & + ( zah_slp1 + zaei_slp1) * zdyt * zbv * ze3wr_jp1 & 443 & ) ! bracket for halo 1 - halo 2 compatibility 444 END_2D 375 445 END DO 376 446 ENDIF 377 447 ! !== horizontal divergence and add to the general trend ==! 378 DO_2D( 0, 0, 0, 0 ) 379 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) & 380 & + zsign * ( zftu(ji-1,jj ,jk) - zftu(ji,jj,jk) & 381 & + zftv(ji,jj-1,jk) - zftv(ji,jj,jk) ) & 382 & / ( e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) ) 448 DO_2D( iij-1, iij-1, iij-1, iij-1 ) 449 ! round brackets added to fix the order of floating point operations 450 ! needed to ensure halo 1 - halo 2 compatibility 451 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) & 452 & + zsign * ( ( zftu(ji-1,jj ,jk) - zftu(ji,jj,jk) & 453 & ) & ! bracket for halo 1 - halo 2 compatibility 454 & + ( zftv(ji,jj-1,jk) - zftv(ji,jj,jk) & 455 & ) & ! bracket for halo 1 - halo 2 compatibility 456 & ) / ( e1e2t(ji,jj) * e3t(ji,jj,jk,Kmm) ) 383 457 END_2D 384 458 ! … … 387 461 ! !== add the vertical 33 flux ==! 388 462 IF( ln_traldf_lap ) THEN ! laplacian case: eddy coef = ah_wslp2 - akz 389 DO_3D( 0, 0, 1, 0, 2, jpkm1 )463 DO_3D( iij-1, iij-1, iij-1, iij-1, 2, jpkm1 ) 390 464 ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * tmask(ji,jj,jk) & 391 465 & * ( ah_wslp2(ji,jj,jk) - akz(ji,jj,jk) ) & … … 395 469 SELECT CASE( kpass ) 396 470 CASE( 1 ) ! 1st pass : eddy coef = ah_wslp2 397 DO_3D( 0, 0, 1, 0, 2, jpkm1 )471 DO_3D( iij-1, iij-1, iij-1, iij-1, 2, jpkm1 ) 398 472 ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * tmask(ji,jj,jk) & 399 473 & * ah_wslp2(ji,jj,jk) * ( pt(ji,jj,jk-1,jn) - pt(ji,jj,jk,jn) ) 400 474 END_3D 401 475 CASE( 2 ) ! 2nd pass : eddy flux = ah_wslp2 and akz applied on pt and pt2 gradients, resp. 402 DO_3D( 0, 0, 1, 0, 2, jpkm1 )476 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 403 477 ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * tmask(ji,jj,jk) & 404 478 & * ( ah_wslp2(ji,jj,jk) * ( pt (ji,jj,jk-1,jn) - pt (ji,jj,jk,jn) ) & … … 408 482 ENDIF 409 483 ! 410 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) !== Divergence of vertical fluxes added to pta ==!484 DO_3D( iij-1, iij-1, iij-1, iij-1, 1, jpkm1 ) !== Divergence of vertical fluxes added to pta ==! 411 485 pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) & 412 486 & + zsign * ( ztfw(ji,jj,jk+1) - ztfw(ji,jj,jk) ) & -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/tramle.F90
r14433 r14958 87 87 INTEGER , INTENT(in ) :: Kmm ! ocean time level index 88 88 CHARACTER(len=3) , INTENT(in ) :: cdtype ! =TRA or TRC (tracer indicator) 89 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: pu ! in : 3 ocean transport components 90 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: pv ! out: same 3 transport components 91 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: pw ! increased by the MLE induced transport 89 ! TEMP: [tiling] Can be A2D(nn_hls) after all lbc_lnks removed in the nn_hls = 2 case in tra_adv_fct 90 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pu ! in : 3 ocean transport components 91 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pv ! out: same 3 transport components 92 REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) :: pw ! increased by the MLE induced transport 92 93 ! 93 94 INTEGER :: ji, jj, jk ! dummy loop indices … … 96 97 REAL(wp) :: zcvw, zmvw ! - - 97 98 INTEGER , DIMENSION(A2D(nn_hls)) :: inml_mle 98 REAL(wp), DIMENSION(A2D(nn_hls)) :: zpsim_u, zpsim_v, zmld, zbm, zhu, zhv, zn2, zLf_ MH99 REAL(wp), DIMENSION(A2D(nn_hls)) :: zpsim_u, zpsim_v, zmld, zbm, zhu, zhv, zn2, zLf_NH, zLf_MH 99 100 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zpsi_uw, zpsi_vw 100 ! TEMP: [tiling] These changes not necessary if using XIOS (subdomain support)101 REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE :: zLf_NH102 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, SAVE :: zpsiu_mle, zpsiv_mle103 101 !!---------------------------------------------------------------------- 104 102 ! … … 110 108 SELECT CASE( nn_mld_uv ) ! MLD at u- & v-pts 111 109 CASE ( 0 ) != min of the 2 neighbour MLDs 112 DO_2D( 1, 0, 1, 0)110 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 113 111 zhu(ji,jj) = MIN( hmle(ji+1,jj), hmle(ji,jj) ) 114 112 zhv(ji,jj) = MIN( hmle(ji,jj+1), hmle(ji,jj) ) 115 113 END_2D 116 114 CASE ( 1 ) != average of the 2 neighbour MLDs 117 DO_2D( 1, 0, 1, 0)115 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 118 116 zhu(ji,jj) = MAX( hmle(ji+1,jj), hmle(ji,jj) ) 119 117 zhv(ji,jj) = MAX( hmle(ji,jj+1), hmle(ji,jj) ) 120 118 END_2D 121 119 CASE ( 2 ) != max of the 2 neighbour MLDs 122 DO_2D( 1, 0, 1, 0)120 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 123 121 zhu(ji,jj) = MAX( hmle(ji+1,jj), hmle(ji,jj) ) 124 122 zhv(ji,jj) = MAX( hmle(ji,jj+1), hmle(ji,jj) ) … … 126 124 END SELECT 127 125 IF( nn_mle == 0 ) THEN ! Fox-Kemper et al. 2010 formulation 128 DO_2D( 1, 0, 1, 0)126 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 129 127 zpsim_u(ji,jj) = rn_ce * zhu(ji,jj) * zhu(ji,jj) * e2u(ji,jj) & 130 128 & * dbdx_mle(ji,jj) * MIN( 111.e3_wp , e1u(ji,jj) ) & … … 137 135 ! 138 136 ELSEIF( nn_mle == 1 ) THEN ! New formulation (Lf = 5km fo/ff with fo=Coriolis parameter at latitude rn_lat) 139 DO_2D( 1, 0, 1, 0)137 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 140 138 zpsim_u(ji,jj) = rc_f * zhu(ji,jj) * zhu(ji,jj) * e2u(ji,jj) & 141 139 & * dbdx_mle(ji,jj) * MIN( 111.e3_wp , e1u(ji,jj) ) … … 149 147 ! !== MLD used for MLE ==! 150 148 ! ! compute from the 10m density to deal with the diurnal cycle 151 DO_2D( 1, 1, 1, 1)149 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 152 150 inml_mle(ji,jj) = mbkt(ji,jj) + 1 ! init. to number of ocean w-level (T-level + 1) 153 151 END_2D 154 152 IF ( nla10 > 0 ) THEN ! avoid case where first level is thicker than 10m 155 DO_3DS( 1, 1, 1, 1, jpkm1, nlb10, -1 ) ! from the bottom to nlb10 (10m)153 DO_3DS( nn_hls, nn_hls, nn_hls, nn_hls, jpkm1, nlb10, -1 ) ! from the bottom to nlb10 (10m) 156 154 IF( rhop(ji,jj,jk) > rhop(ji,jj,nla10) + rn_rho_c_mle ) inml_mle(ji,jj) = jk ! Mixed layer 157 155 END_3D … … 163 161 zbm (:,:) = 0._wp 164 162 zn2 (:,:) = 0._wp 165 DO_3D( 1, 1, 1, 1, 1, ikmax ) ! MLD and mean buoyancy and N2 over the mixed layer163 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, ikmax ) ! MLD and mean buoyancy and N2 over the mixed layer 166 164 zc = e3t(ji,jj,jk,Kmm) * REAL( MIN( MAX( 0, inml_mle(ji,jj)-jk ) , 1 ) ) ! zc being 0 outside the ML t-points 167 165 zmld(ji,jj) = zmld(ji,jj) + zc … … 172 170 SELECT CASE( nn_mld_uv ) ! MLD at u- & v-pts 173 171 CASE ( 0 ) != min of the 2 neighbour MLDs 174 DO_2D( 1, 0, 1, 0)172 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 175 173 zhu(ji,jj) = MIN( zmld(ji+1,jj), zmld(ji,jj) ) 176 174 zhv(ji,jj) = MIN( zmld(ji,jj+1), zmld(ji,jj) ) 177 175 END_2D 178 176 CASE ( 1 ) != average of the 2 neighbour MLDs 179 DO_2D( 1, 0, 1, 0)177 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 180 178 zhu(ji,jj) = ( zmld(ji+1,jj) + zmld(ji,jj) ) * 0.5_wp 181 179 zhv(ji,jj) = ( zmld(ji,jj+1) + zmld(ji,jj) ) * 0.5_wp 182 180 END_2D 183 181 CASE ( 2 ) != max of the 2 neighbour MLDs 184 DO_2D( 1, 0, 1, 0)182 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 185 183 zhu(ji,jj) = MAX( zmld(ji+1,jj), zmld(ji,jj) ) 186 184 zhv(ji,jj) = MAX( zmld(ji,jj+1), zmld(ji,jj) ) … … 188 186 END SELECT 189 187 ! ! convert density into buoyancy 190 DO_2D( 1, 1, 1, 1)188 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 191 189 zbm(ji,jj) = + grav * zbm(ji,jj) / MAX( e3t(ji,jj,1,Kmm), zmld(ji,jj) ) 192 190 END_2D … … 201 199 ! 202 200 IF( nn_mle == 0 ) THEN ! Fox-Kemper et al. 2010 formulation 203 DO_2D( 1, 0, 1, 0)201 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 204 202 zpsim_u(ji,jj) = rn_ce * zhu(ji,jj) * zhu(ji,jj) * e2_e1u(ji,jj) & 205 203 & * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp , e1u(ji,jj) ) & … … 212 210 ! 213 211 ELSEIF( nn_mle == 1 ) THEN ! New formulation (Lf = 5km fo/ff with fo=Coriolis parameter at latitude rn_lat) 214 DO_2D( 1, 0, 1, 0)212 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 215 213 zpsim_u(ji,jj) = rc_f * zhu(ji,jj) * zhu(ji,jj) * e2_e1u(ji,jj) & 216 214 & * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp , e1u(ji,jj) ) … … 222 220 ! 223 221 IF( nn_conv == 1 ) THEN ! No MLE in case of convection 224 DO_2D( 1, 0, 1, 0)222 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 225 223 IF( MIN( zn2(ji,jj) , zn2(ji+1,jj) ) < 0._wp ) zpsim_u(ji,jj) = 0._wp 226 224 IF( MIN( zn2(ji,jj) , zn2(ji,jj+1) ) < 0._wp ) zpsim_v(ji,jj) = 0._wp … … 230 228 ENDIF ! end of ln_osm_mle conditional 231 229 ! !== structure function value at uw- and vw-points ==! 232 DO_2D( 1, 0, 1, 0)230 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 233 231 zhu(ji,jj) = 1._wp / MAX(zhu(ji,jj), rsmall) ! hu --> 1/hu 234 232 zhv(ji,jj) = 1._wp / MAX(zhv(ji,jj), rsmall) … … 238 236 zpsi_vw(:,:,:) = 0._wp 239 237 ! 240 DO_3D( 1, 0, 1, 0, 2, ikmax ) ! start from 2 : surface value = 0 238 DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 2, ikmax ) ! start from 2 : surface value = 0 239 241 240 zcuw = 1._wp - ( gdepw(ji+1,jj,jk,Kmm) + gdepw(ji,jj,jk,Kmm) ) * zhu(ji,jj) 242 241 zcvw = 1._wp - ( gdepw(ji,jj+1,jk,Kmm) + gdepw(ji,jj,jk,Kmm) ) * zhv(ji,jj) … … 252 251 ! !== transport increased by the MLE induced transport ==! 253 252 DO jk = 1, ikmax 254 DO_2D ( 1, 0, 1, 0 ) ! CAUTION pu,pv must be defined at row/column i=1 / j=1253 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 255 254 pu(ji,jj,jk) = pu(ji,jj,jk) + ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji,jj,jk+1) ) 256 255 pv(ji,jj,jk) = pv(ji,jj,jk) + ( zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj,jk+1) ) 257 256 END_2D 258 DO_2D ( 0, 0, 0, 0)257 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 259 258 pw(ji,jj,jk) = pw(ji,jj,jk) - ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji-1,jj,jk) & 260 259 & + zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj-1,jk) ) * wmask(ji,jj,1) … … 262 261 END DO 263 262 264 ! TEMP: [tiling] These changes not necessary if using XIOS (subdomain support)265 263 IF( cdtype == 'TRA') THEN !== outputs ==! 266 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile267 ALLOCATE( zLf_NH(jpi,jpj), zpsiu_mle(jpi,jpj,jpk), zpsiv_mle(jpi,jpj,jpk) )268 zpsiu_mle(:,:,:) = 0._wp ; zpsiv_mle(:,:,:) = 0._wp269 ENDIF270 264 ! 271 265 IF (ln_osm_mle.and.ln_zdfosm) THEN … … 279 273 ENDIF 280 274 ! 275 CALL iom_put( "Lf_NHpf" , zLf_NH ) ! Lf = N H / f 276 ! 281 277 ! divide by cross distance to give streamfunction with dimensions m^2/s 282 278 DO_3D( 0, 0, 0, 0, 1, ikmax+1 ) 283 zpsi u_mle(ji,jj,jk) = zpsi_uw(ji,jj,jk) * r1_e2u(ji,jj)284 zpsi v_mle(ji,jj,jk) = zpsi_vw(ji,jj,jk) * r1_e1v(ji,jj)279 zpsi_uw(ji,jj,jk) = zpsi_uw(ji,jj,jk) * r1_e2u(ji,jj) 280 zpsi_vw(ji,jj,jk) = zpsi_vw(ji,jj,jk) * r1_e1v(ji,jj) 285 281 END_3D 286 287 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 288 CALL iom_put( "Lf_NHpf" , zLf_NH ) ! Lf = N H / f 289 CALL iom_put( "psiu_mle", zpsiu_mle ) ! i-mle streamfunction 290 CALL iom_put( "psiv_mle", zpsiv_mle ) ! j-mle streamfunction 291 DEALLOCATE( zLf_NH, zpsiu_mle, zpsiv_mle ) 292 ENDIF 282 CALL iom_put( "psiu_mle", zpsi_uw ) ! i-mle streamfunction 283 CALL iom_put( "psiv_mle", zpsi_vw ) ! j-mle streamfunction 293 284 ENDIF 294 285 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/tranpc.F90
r14215 r14958 17 17 USE oce ! ocean dynamics and active tracers 18 18 USE dom_oce ! ocean space and time domain 19 ! TEMP: [tiling] This change not necessary after extra haloes development (lbc_lnk removed)20 USE domtile21 19 USE phycst ! physical constants 22 20 USE zdf_oce ! ocean vertical physics … … 81 79 LOGICAL, PARAMETER :: l_LB_debug = .FALSE. ! set to true if you want to follow what is 82 80 INTEGER :: ilc1, jlc1, klc1, nncpu ! actually happening in a water column at point "ilc1, jlc1" 83 INTEGER :: isi, isj, iei, iej84 81 LOGICAL :: lp_monitor_point = .FALSE. ! in CPU domain "nncpu" 85 82 !!---------------------------------------------------------------------- … … 105 102 CALL bn2 ( pts(:,:,:,:,Kaa), zab, zn2, Kmm ) ! after Brunt-Vaisala (given on W-points) 106 103 ! 107 IF( ntile == 0 .OR. ntile == 1 ) nnpcc = 0 ! Do only on the first tile 108 ! 109 IF( ntsi == Nis0 ) THEN ; isi = nn_hls ; ELSE ; isi = 0 ; ENDIF ! Avoid double-counting when using tiling 110 IF( ntsj == Njs0 ) THEN ; isj = nn_hls ; ELSE ; isj = 0 ; ENDIF 111 IF( ntei == Nie0 ) THEN ; iei = nn_hls ; ELSE ; iei = 0 ; ENDIF 112 IF( ntej == Nje0 ) THEN ; iej = nn_hls ; ELSE ; iej = 0 ; ENDIF 113 ! 114 DO_2D( isi, iei, isj, iej ) ! interior column only 104 IF( .NOT. l_istiled .OR. ntile == 1 ) nnpcc = 0 ! Do only on the first tile 105 ! 106 DO_2D_OVR( 0, 0, 0, 0 ) ! interior column only 115 107 ! 116 108 IF( tmask(ji,jj,2) == 1 ) THEN ! At least 2 ocean points … … 319 311 ENDIF 320 312 ! 321 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only for the full domain313 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only for the full domain 322 314 IF( lwp .AND. l_LB_debug ) THEN 323 315 WRITE(numout,*) 'Exiting tra_npc , kt = ',kt,', => numb. of statically instable water-columns: ', nnpcc -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/traqsr.F90
r14215 r14958 108 108 ! 109 109 INTEGER :: ji, jj, jk ! dummy loop indices 110 INTEGER :: irgb , isi, iei, isj, iej! local integers110 INTEGER :: irgb ! local integers 111 111 REAL(wp) :: zchl, zcoef, z1_2 ! local scalars 112 112 REAL(wp) :: zc0 , zc1 , zc2 , zc3 ! - - … … 121 121 IF( ln_timing ) CALL timing_start('tra_qsr') 122 122 ! 123 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile123 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 124 124 IF( kt == nit000 ) THEN 125 125 IF(lwp) WRITE(numout,*) … … 137 137 ! ! before qsr induced heat content ! 138 138 ! !-----------------------------------! 139 IF( ntsi == Nis0 ) THEN ; isi = nn_hls ; ELSE ; isi = 0 ; ENDIF ! Avoid double-counting when using tiling140 IF( ntsj == Njs0 ) THEN ; isj = nn_hls ; ELSE ; isj = 0 ; ENDIF141 IF( ntei == Nie0 ) THEN ; iei = nn_hls ; ELSE ; iei = 0 ; ENDIF142 IF( ntej == Nje0 ) THEN ; iej = nn_hls ; ELSE ; iej = 0 ; ENDIF143 144 139 IF( kt == nit000 ) THEN !== 1st time step ==! 145 140 IF( ln_rstart .AND. .NOT.l_1st_euler ) THEN ! read in restart 146 141 z1_2 = 0.5_wp 147 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile142 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 148 143 IF(lwp) WRITE(numout,*) ' nit000-1 qsr tracer content forcing field read in the restart file' 149 144 CALL iom_get( numror, jpdom_auto, 'qsr_hc_b', qsr_hc_b ) ! before heat content trend due to Qsr flux … … 151 146 ELSE ! No restart or Euler forward at 1st time step 152 147 z1_2 = 1._wp 153 DO_3D ( isi, iei, isj, iej, 1, jpk )148 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 154 149 qsr_hc_b(ji,jj,jk) = 0._wp 155 150 END_3D … … 157 152 ELSE !== Swap of qsr heat content ==! 158 153 z1_2 = 0.5_wp 159 DO_3D ( isi, iei, isj, iej, 1, jpk )154 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 160 155 qsr_hc_b(ji,jj,jk) = qsr_hc(ji,jj,jk) 161 156 END_3D … … 168 163 CASE( np_BIO ) !== bio-model fluxes ==! 169 164 ! 170 DO_3D ( isi, iei, isj, iej, 1, nksr )165 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, nksr ) 171 166 qsr_hc(ji,jj,jk) = r1_rho0_rcp * ( etot3(ji,jj,jk) - etot3(ji,jj,jk+1) ) 172 167 END_3D … … 179 174 ! 180 175 IF( nqsr == np_RGBc ) THEN !* Variable Chlorophyll 181 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only for the full domain182 IF( ln_tile ) CALL dom_tile ( ntsi, ntsj, ntei, ntej, ktile = 0 )! Use full domain176 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only for the full domain 177 IF( ln_tile ) CALL dom_tile_stop( ldhold=.TRUE. ) ! Use full domain 183 178 CALL fld_read( kt, 1, sf_chl ) ! Read Chl data and provides it at the current time step 184 IF( ln_tile ) CALL dom_tile ( ntsi, ntsj, ntei, ntej, ktile = 1) ! Revert to tile domain179 IF( ln_tile ) CALL dom_tile_start( ldhold=.TRUE. ) ! Revert to tile domain 185 180 ENDIF 186 181 ! … … 190 185 ! most expensive calculations) 191 186 ! 192 DO_2D ( isi, iei, isj, iej)187 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 193 188 ! zlogc = log(zchl) 194 189 zlogc = LOG ( MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) ) ) … … 209 204 210 205 ! 211 DO_3D ( isi, iei, isj, iej, 1, nksr + 1 )206 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, nksr + 1 ) 212 207 ! zchl = ALOG( ze0(ji,jj) ) 213 208 zlogc = ze0(ji,jj) … … 239 234 ! 240 235 zcoef = ( 1. - rn_abs ) / 3._wp !* surface equi-partition in R-G-B 241 DO_2D ( isi, iei, isj, iej)236 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 242 237 ze0(ji,jj) = rn_abs * qsr(ji,jj) 243 238 ze1(ji,jj) = zcoef * qsr(ji,jj) … … 250 245 ! 251 246 ! !* interior equi-partition in R-G-B depending on vertical profile of Chl 252 DO_3D ( isi, iei, isj, iej, 2, nksr + 1 )247 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 2, nksr + 1 ) 253 248 ze3t = e3t(ji,jj,jk-1,Kmm) 254 249 irgb = NINT( ztmp3d(ji,jj,jk) ) … … 264 259 END_3D 265 260 ! 266 DO_3D ( isi, iei, isj, iej, 1, nksr ) !* now qsr induced heat content261 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, nksr ) !* now qsr induced heat content 267 262 qsr_hc(ji,jj,jk) = r1_rho0_rcp * ( ztmp3d(ji,jj,jk) - ztmp3d(ji,jj,jk+1) ) 268 263 END_3D … … 274 269 zz0 = rn_abs * r1_rho0_rcp ! surface equi-partition in 2-bands 275 270 zz1 = ( 1. - rn_abs ) * r1_rho0_rcp 276 DO_3D ( isi, iei, isj, iej, 1, nksr ) !* now qsr induced heat content271 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, nksr ) !* now qsr induced heat content 277 272 zc0 = zz0 * EXP( -gdepw(ji,jj,jk ,Kmm)*xsi0r ) + zz1 * EXP( -gdepw(ji,jj,jk ,Kmm)*xsi1r ) 278 273 zc1 = zz0 * EXP( -gdepw(ji,jj,jk+1,Kmm)*xsi0r ) + zz1 * EXP( -gdepw(ji,jj,jk+1,Kmm)*xsi1r ) … … 292 287 ! 293 288 ! sea-ice: store the 1st ocean level attenuation coefficient 294 DO_2D ( isi, iei, isj, iej)289 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 295 290 IF( qsr(ji,jj) /= 0._wp ) THEN ; fraqsr_1lev(ji,jj) = qsr_hc(ji,jj,1) / ( r1_rho0_rcp * qsr(ji,jj) ) 296 291 ELSE ; fraqsr_1lev(ji,jj) = 1._wp … … 298 293 END_2D 299 294 ! 300 ! TEMP: [tiling] This change not necessary and working array can use A2D(nn_hls) if using XIOS (subdomain support) 301 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only for the full domain 302 IF( iom_use('qsr3d') ) THEN ! output the shortwave Radiation distribution 303 ALLOCATE( zetot(jpi,jpj,jpk) ) 304 zetot(:,:,nksr+1:jpk) = 0._wp ! below ~400m set to zero 305 DO jk = nksr, 1, -1 306 zetot(:,:,jk) = zetot(:,:,jk+1) + qsr_hc(:,:,jk) * rho0_rcp 307 END DO 308 CALL iom_put( 'qsr3d', zetot ) ! 3D distribution of shortwave Radiation 309 DEALLOCATE( zetot ) 310 ENDIF 311 ENDIF 312 ! 313 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 295 IF( iom_use('qsr3d') ) THEN ! output the shortwave Radiation distribution 296 ALLOCATE( zetot(A2D(nn_hls),jpk) ) 297 zetot(:,:,nksr+1:jpk) = 0._wp ! below ~400m set to zero 298 DO_3DS(0, 0, 0, 0, nksr, 1, -1) 299 zetot(ji,jj,jk) = zetot(ji,jj,jk+1) + qsr_hc(ji,jj,jk) * rho0_rcp 300 END_3D 301 CALL iom_put( 'qsr3d', zetot ) ! 3D distribution of shortwave Radiation 302 DEALLOCATE( zetot ) 303 ENDIF 304 ! 305 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 314 306 IF( lrst_oce ) THEN ! write in the ocean restart file 315 307 CALL iom_rstput( kt, nitrst, numrow, 'qsr_hc_b' , qsr_hc ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/trasbc.F90
r14215 r14958 77 77 ! 78 78 INTEGER :: ji, jj, jk, jn ! dummy loop indices 79 INTEGER :: ikt, ikb , isi, iei, isj, iej! local integers79 INTEGER :: ikt, ikb ! local integers 80 80 REAL(wp) :: zfact, z1_e3t, zdep, ztim ! local scalar 81 81 REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: ztrdt, ztrds … … 84 84 IF( ln_timing ) CALL timing_start('tra_sbc') 85 85 ! 86 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile86 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 87 87 IF( kt == nit000 ) THEN 88 88 IF(lwp) WRITE(numout,*) … … 98 98 ENDIF 99 99 ! 100 IF( ntsi == Nis0 ) THEN ; isi = nn_hls ; ELSE ; isi = 0 ; ENDIF ! Avoid double-counting when using tiling101 IF( ntsj == Njs0 ) THEN ; isj = nn_hls ; ELSE ; isj = 0 ; ENDIF102 IF( ntei == Nie0 ) THEN ; iei = nn_hls ; ELSE ; iei = 0 ; ENDIF103 IF( ntej == Nje0 ) THEN ; iej = nn_hls ; ELSE ; iej = 0 ; ENDIF104 105 100 !!gm This should be moved into sbcmod.F90 module ? (especially now that ln_traqsr is read in namsbc namelist) 106 101 IF( .NOT.ln_traqsr ) THEN ! no solar radiation penetration 107 DO_2D ( isi, iei, isj, iej)102 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 108 103 qns(ji,jj) = qns(ji,jj) + qsr(ji,jj) ! total heat flux in qns 109 104 qsr(ji,jj) = 0._wp ! qsr set to zero … … 118 113 IF( ln_rstart .AND. .NOT.l_1st_euler ) THEN ! Restart: read in restart file 119 114 zfact = 0.5_wp 120 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile115 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 121 116 IF(lwp) WRITE(numout,*) ' nit000-1 sbc tracer content field read in the restart file' 122 117 sbc_tsc(:,:,:) = 0._wp … … 126 121 ELSE ! No restart or restart not found: Euler forward time stepping 127 122 zfact = 1._wp 128 DO_2D ( isi, iei, isj, iej)123 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 129 124 sbc_tsc(ji,jj,:) = 0._wp 130 125 sbc_tsc_b(ji,jj,:) = 0._wp … … 133 128 ELSE !* other time-steps: swap of forcing fields 134 129 zfact = 0.5_wp 135 DO_2D ( isi, iei, isj, iej)130 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 136 131 sbc_tsc_b(ji,jj,:) = sbc_tsc(ji,jj,:) 137 132 END_2D 138 133 ENDIF 139 134 ! !== Now sbc tracer content fields ==! 140 DO_2D ( isi, iei, isj, iej)135 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 141 136 sbc_tsc(ji,jj,jp_tem) = r1_rho0_rcp * qns(ji,jj) ! non solar heat flux 142 137 sbc_tsc(ji,jj,jp_sal) = r1_rho0 * sfx(ji,jj) ! salt flux due to freezing/melting 143 138 END_2D 144 139 IF( ln_linssh ) THEN !* linear free surface 145 DO_2D ( isi, iei, isj, iej) !==>> add concentration/dilution effect due to constant volume cell140 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) !==>> add concentration/dilution effect due to constant volume cell 146 141 sbc_tsc(ji,jj,jp_tem) = sbc_tsc(ji,jj,jp_tem) + r1_rho0 * emp(ji,jj) * pts(ji,jj,1,jp_tem,Kmm) 147 142 sbc_tsc(ji,jj,jp_sal) = sbc_tsc(ji,jj,jp_sal) + r1_rho0 * emp(ji,jj) * pts(ji,jj,1,jp_sal,Kmm) 148 143 END_2D !==>> output c./d. term 149 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 150 IF( iom_use('emp_x_sst') ) CALL iom_put( "emp_x_sst", emp (:,:) * pts(:,:,1,jp_tem,Kmm) ) 151 IF( iom_use('emp_x_sss') ) CALL iom_put( "emp_x_sss", emp (:,:) * pts(:,:,1,jp_sal,Kmm) ) 152 ENDIF 144 IF( iom_use('emp_x_sst') ) CALL iom_put( "emp_x_sst", emp (:,:) * pts(:,:,1,jp_tem,Kmm) ) 145 IF( iom_use('emp_x_sss') ) CALL iom_put( "emp_x_sss", emp (:,:) * pts(:,:,1,jp_sal,Kmm) ) 153 146 ENDIF 154 147 ! … … 160 153 END DO 161 154 ! 162 IF( ntile == 0.OR. ntile == nijtile ) THEN ! Do only on the last tile155 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 163 156 IF( lrst_oce ) THEN !== write sbc_tsc in the ocean restart file ==! 164 157 CALL iom_rstput( kt, nitrst, numrow, 'sbc_hc_b', sbc_tsc(:,:,jp_tem) ) … … 186 179 ENDIF 187 180 188 IF( ntile == 0 .OR. ntile == nijtile ) THEN ! Do only on the last tile 189 IF( iom_use('rnf_x_sst') ) CALL iom_put( "rnf_x_sst", rnf*pts(:,:,1,jp_tem,Kmm) ) ! runoff term on sst 190 IF( iom_use('rnf_x_sss') ) CALL iom_put( "rnf_x_sss", rnf*pts(:,:,1,jp_sal,Kmm) ) ! runoff term on sss 191 ENDIF 181 IF( iom_use('rnf_x_sst') ) CALL iom_put( "rnf_x_sst", rnf*pts(:,:,1,jp_tem,Kmm) ) ! runoff term on sst 182 IF( iom_use('rnf_x_sss') ) CALL iom_put( "rnf_x_sss", rnf*pts(:,:,1,jp_sal,Kmm) ) ! runoff term on sss 192 183 193 184 #if defined key_asminc -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/trazdf.F90
r14433 r14958 64 64 ! 65 65 IF( kt == nit000 ) THEN 66 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile66 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 67 67 IF(lwp)WRITE(numout,*) 68 68 IF(lwp)WRITE(numout,*) 'tra_zdf : implicit vertical mixing on T & S' -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRA/zpshde.F90
r14433 r14958 47 47 INTEGER , INTENT(in ) :: Kmm ! ocean time level index 48 48 INTEGER , INTENT(in ) :: kjpt ! number of tracers 49 REAL(wp), DIMENSION(:,:,:,:), INTENT(in out) :: pta ! 4D tracers fields49 REAL(wp), DIMENSION(:,:,:,:), INTENT(in ) :: pta ! 4D tracers fields 50 50 REAL(wp), DIMENSION(:,:,:) , INTENT( out) :: pgtu, pgtv ! hor. grad. of ptra at u- & v-pts 51 REAL(wp), DIMENSION(:,:,:) , INTENT(in out), OPTIONAL :: prd ! 3D density anomaly fields51 REAL(wp), DIMENSION(:,:,:) , INTENT(in ), OPTIONAL :: prd ! 3D density anomaly fields 52 52 REAL(wp), DIMENSION(:,:) , INTENT( out), OPTIONAL :: pgru, pgrv ! hor. grad of prd at u- & v-pts (bottom) 53 53 ! … … 111 111 INTEGER , INTENT(in ) :: kjpt ! number of tracers 112 112 INTEGER , INTENT(in ) :: ktta, ktgt, ktrd, ktgr 113 REAL(wp), DIMENSION(A2D_T(ktta),JPK,KJPT), INTENT(in out) :: pta ! 4D tracers fields113 REAL(wp), DIMENSION(A2D_T(ktta),JPK,KJPT), INTENT(in ) :: pta ! 4D tracers fields 114 114 REAL(wp), DIMENSION(A2D_T(ktgt) ,KJPT), INTENT( out) :: pgtu, pgtv ! hor. grad. of ptra at u- & v-pts 115 REAL(wp), DIMENSION(A2D_T(ktrd),JPK ), INTENT(in out), OPTIONAL :: prd ! 3D density anomaly fields115 REAL(wp), DIMENSION(A2D_T(ktrd),JPK ), INTENT(in ), OPTIONAL :: prd ! 3D density anomaly fields 116 116 REAL(wp), DIMENSION(A2D_T(ktgr) ), INTENT( out), OPTIONAL :: pgru, pgrv ! hor. grad of prd at u- & v-pts (bottom) 117 117 ! … … 124 124 ! 125 125 IF( ln_timing ) CALL timing_start( 'zps_hde') 126 IF (nn_hls.EQ.2) THEN127 CALL lbc_lnk( 'zpshde', pta, 'T', 1.0_wp)128 IF(PRESENT(prd)) CALL lbc_lnk( 'zpshde', prd, 'T', 1.0_wp)129 END IF130 126 ! 131 127 pgtu(:,:,:) = 0._wp ; zti (:,:,:) = 0._wp ; zhi (:,:) = 0._wp … … 134 130 DO jn = 1, kjpt !== Interpolation of tracers at the last ocean level ==! 135 131 ! 136 DO_2D( nn_hls -1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! Gradient of density at the last level132 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) ! Gradient of density at the last level 137 133 iku = mbku(ji,jj) ; ikum1 = MAX( iku - 1 , 1 ) ! last and before last ocean level at u- & v-points 138 134 ikv = mbkv(ji,jj) ; ikvm1 = MAX( ikv - 1 , 1 ) ! if level first is a p-step, ik.m1=1 … … 173 169 END DO 174 170 ! 175 IF (nn_hls .EQ.1) CALL lbc_lnk( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp ) ! Lateral boundary cond.171 IF (nn_hls==1) CALL lbc_lnk( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp ) ! Lateral boundary cond. 176 172 ! 177 173 IF( PRESENT( prd ) ) THEN !== horizontal derivative of density anomalies (rd) ==! (optional part) … … 206 202 ENDIF 207 203 END_2D 208 IF (nn_hls .EQ.1) CALL lbc_lnk( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp ) ! Lateral boundary conditions204 IF (nn_hls==1) CALL lbc_lnk( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp ) ! Lateral boundary conditions 209 205 ! 210 206 END IF … … 221 217 INTEGER , INTENT(in ) :: Kmm ! ocean time level index 222 218 INTEGER , INTENT(in ) :: kjpt ! number of tracers 223 REAL(wp), DIMENSION(:,:,:,:), INTENT(in out) :: pta ! 4D tracers fields219 REAL(wp), DIMENSION(:,:,:,:), INTENT(in ) :: pta ! 4D tracers fields 224 220 REAL(wp), DIMENSION(:,:,:) , INTENT( out) :: pgtu, pgtv ! hor. grad. of ptra at u- & v-pts 225 221 REAL(wp), DIMENSION(:,:,:) , INTENT( out) :: pgtui, pgtvi ! hor. grad. of stra at u- & v-pts (ISF) 226 REAL(wp), DIMENSION(:,:,:) , INTENT(in out), OPTIONAL :: prd ! 3D density anomaly fields222 REAL(wp), DIMENSION(:,:,:) , INTENT(in ), OPTIONAL :: prd ! 3D density anomaly fields 227 223 REAL(wp), DIMENSION(:,:) , INTENT( out), OPTIONAL :: pgru, pgrv ! hor. grad of prd at u- & v-pts (bottom) 228 224 REAL(wp), DIMENSION(:,:) , INTENT( out), OPTIONAL :: pgrui, pgrvi ! hor. grad of prd at u- & v-pts (top) … … 291 287 INTEGER , INTENT(in ) :: kjpt ! number of tracers 292 288 INTEGER , INTENT(in ) :: ktta, ktgt, ktgti, ktrd, ktgr, ktgri 293 REAL(wp), DIMENSION(A2D_T(ktta),JPK,KJPT), INTENT(in out) :: pta ! 4D tracers fields289 REAL(wp), DIMENSION(A2D_T(ktta),JPK,KJPT), INTENT(in ) :: pta ! 4D tracers fields 294 290 REAL(wp), DIMENSION(A2D_T(ktgt) ,KJPT), INTENT( out) :: pgtu, pgtv ! hor. grad. of ptra at u- & v-pts 295 291 REAL(wp), DIMENSION(A2D_T(ktgti) ,KJPT), INTENT( out) :: pgtui, pgtvi ! hor. grad. of stra at u- & v-pts (ISF) 296 REAL(wp), DIMENSION(A2D_T(ktrd),JPK ), INTENT(in out), OPTIONAL :: prd ! 3D density anomaly fields292 REAL(wp), DIMENSION(A2D_T(ktrd),JPK ), INTENT(in ), OPTIONAL :: prd ! 3D density anomaly fields 297 293 REAL(wp), DIMENSION(A2D_T(ktgr) ), INTENT( out), OPTIONAL :: pgru, pgrv ! hor. grad of prd at u- & v-pts (bottom) 298 294 REAL(wp), DIMENSION(A2D_T(ktgri) ), INTENT( out), OPTIONAL :: pgrui, pgrvi ! hor. grad of prd at u- & v-pts (top) … … 307 303 IF( ln_timing ) CALL timing_start( 'zps_hde_isf') 308 304 ! 309 IF (nn_hls.EQ.2) THEN310 CALL lbc_lnk( 'zpshde', pta, 'T', 1.0_wp)311 IF (PRESENT(prd)) CALL lbc_lnk( 'zpshde', prd, 'T', 1.0_wp)312 END IF313 314 305 pgtu (:,:,:) = 0._wp ; pgtv (:,:,:) =0._wp 315 306 pgtui(:,:,:) = 0._wp ; pgtvi(:,:,:) =0._wp … … 319 310 DO jn = 1, kjpt !== Interpolation of tracers at the last ocean level ==! 320 311 ! 321 DO_2D( nn_hls -1, nn_hls-1, nn_hls-1, nn_hls-1 )312 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 322 313 323 314 iku = mbku(ji,jj); ikum1 = MAX( iku - 1 , 1 ) ! last and before last ocean level at u- & v-points … … 359 350 END DO 360 351 ! 361 IF (nn_hls .EQ.1) CALL lbc_lnk( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp ) ! Lateral boundary cond.352 IF (nn_hls==1) CALL lbc_lnk( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp ) ! Lateral boundary cond. 362 353 363 354 ! horizontal derivative of density anomalies (rd) … … 401 392 END_2D 402 393 403 IF (nn_hls .EQ.1) CALL lbc_lnk( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp ) ! Lateral boundary conditions394 IF (nn_hls==1) CALL lbc_lnk( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp ) ! Lateral boundary conditions 404 395 ! 405 396 END IF … … 408 399 ! 409 400 DO jn = 1, kjpt !== Interpolation of tracers at the last ocean level ==! ! 410 DO_2D( nn_hls -1, nn_hls-1, nn_hls-1, nn_hls-1 )401 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 411 402 iku = miku(ji,jj); ikup1 = miku(ji,jj) + 1 412 403 ikv = mikv(ji,jj); ikvp1 = mikv(ji,jj) + 1 … … 452 443 ! 453 444 END DO 454 IF (nn_hls .EQ.1) CALL lbc_lnk( 'zpshde', pgtui(:,:,:), 'U', -1.0_wp , pgtvi(:,:,:), 'V', -1.0_wp ) ! Lateral boundary cond.445 IF (nn_hls==1) CALL lbc_lnk( 'zpshde', pgtui(:,:,:), 'U', -1.0_wp , pgtvi(:,:,:), 'V', -1.0_wp ) ! Lateral boundary cond. 455 446 456 447 IF( PRESENT( prd ) ) THEN !== horizontal derivative of density anomalies (rd) ==! (optional part) … … 491 482 492 483 END_2D 493 IF (nn_hls .EQ.1) CALL lbc_lnk( 'zpshde', pgrui, 'U', -1.0_wp , pgrvi, 'V', -1.0_wp ) ! Lateral boundary conditions484 IF (nn_hls==1) CALL lbc_lnk( 'zpshde', pgrui, 'U', -1.0_wp , pgrvi, 'V', -1.0_wp ) ! Lateral boundary conditions 494 485 ! 495 486 END IF -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/TRD/trdini.F90
r14090 r14958 93 93 CALL ctl_warn('Tiling is not yet implemented for the trends diagnostics; ln_tile is forced to FALSE') 94 94 ln_tile = .FALSE. 95 CALL dom_tile ( ntsi, ntsj, ntei, ntej )95 CALL dom_tile_init 96 96 ENDIF 97 97 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/USR/usrdef_istate.F90
r14053 r14958 61 61 pv (:,:,:) = 0._wp 62 62 ! 63 DO_3D( 1, 1, 1, 1, 1, jpk ) ! horizontally uniform T & S profiles63 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) ! horizontally uniform T & S profiles 64 64 pts(ji,jj,jk,jp_tem) = ( ( 16. - 12. * TANH( (pdept(ji,jj,jk) - 400) / 700 ) ) & 65 65 & * (-TANH( (500. - pdept(ji,jj,jk)) / 150. ) + 1.) / 2. & -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfddm.F90
r14053 r14958 83 83 REAL(dp) :: zavfs ! - - 84 84 REAL(wp) :: zavdt, zavds ! - - 85 REAL(wp), DIMENSION( jpi,jpj) :: zrau, zmsks, zmskf, zmskd1, zmskd2, zmskd385 REAL(wp), DIMENSION(A2D(nn_hls)) :: zrau, zmsks, zmskf, zmskd1, zmskd2, zmskd3 86 86 !!---------------------------------------------------------------------- 87 87 ! … … 95 95 !!gm and many acces in memory 96 96 97 DO_2D( 1, 1, 1,1 ) !== R=zrau = (alpha / beta) (dk[t] / dk[s]) ==!97 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !== R=zrau = (alpha / beta) (dk[t] / dk[s]) ==! 98 98 zrw = ( gdepw(ji,jj,jk ,Kmm) - gdept(ji,jj,jk,Kmm) ) & 99 99 !!gm please, use e3w at Kmm below … … 111 111 END_2D 112 112 113 DO_2D( 1, 1, 1,1 ) !== indicators ==!113 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !== indicators ==! 114 114 ! stability indicator: msks=1 if rn2>0; 0 elsewhere 115 115 IF( rn2(ji,jj,jk) + 1.e-12 <= 0. ) THEN ; zmsks(ji,jj) = 0._wp 116 ELSE ; zmsks(ji,jj) = 1._wp 116 ELSE ; zmsks(ji,jj) = 1._wp * wmask(ji,jj,jk) ! mask so avt and avs masked 117 117 ENDIF 118 118 ! salt fingering indicator: msksf=1 if R>1; 0 elsewhere … … 134 134 ENDIF 135 135 END_2D 136 ! mask zmsk in order to have avt and avs masked137 zmsks(:,:) = zmsks(:,:) * wmask(:,:,jk)138 139 136 140 137 ! Update avt and avs 141 138 ! ------------------ 142 139 ! Constant eddy coefficient: reset to the background value 143 DO_2D ( 1, 1, 1,1 )140 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 144 141 zinr = 1._wp / zrau(ji,jj) 145 142 ! salt fingering -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfdrg.F90
r13558 r14958 117 117 ! 118 118 IF( l_log_not_linssh ) THEN !== "log layer" ==! compute Cd and -Cd*|U| 119 DO_2D ( 0, 0, 0, 0)119 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 120 120 imk = k_mk(ji,jj) ! ocean bottom level at t-points 121 121 zut = uu(ji,jj,imk,Kmm) + uu(ji-1,jj,imk,Kmm) ! 2 x velocity at t-point … … 129 129 END_2D 130 130 ELSE !== standard Cd ==! 131 DO_2D ( 0, 0, 0, 0)131 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 132 132 imk = k_mk(ji,jj) ! ocean bottom level at t-points 133 133 zut = uu(ji,jj,imk,Kmm) + uu(ji-1,jj,imk,Kmm) ! 2 x velocity at t-point … … 432 432 l_log_not_linssh = .FALSE. !- don't update Cd at each time step 433 433 ! 434 DO_2D( 1, 1, 1, 1) ! pCd0 = mask (and boosted) logarithmic drag coef.434 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! pCd0 = mask (and boosted) logarithmic drag coef. 435 435 zzz = 0.5_wp * e3t_0(ji,jj,k_mk(ji,jj)) 436 436 zcd = ( vkarmn / LOG( zzz / rn_z0 ) )**2 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfevd.F90
r13295 r14958 62 62 ! 63 63 INTEGER :: ji, jj, jk ! dummy loop indices 64 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zavt_evd, zavm_evd 64 ! NOTE: [tiling] use a SAVE array to store diagnostics, then send after all tiles are finished. This is necessary because p_avt/p_avm are modified on adjacent tiles when using nn_hls > 1. zavt_evd/zavm_evd are then zero on some points when subsequently calculated for these tiles. 65 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:,:) :: zavt_evd, zavm_evd 65 66 !!---------------------------------------------------------------------- 66 67 ! 67 IF( kt == nit000 ) THEN 68 IF(lwp) WRITE(numout,*) 69 IF(lwp) WRITE(numout,*) 'zdf_evd : Enhanced Vertical Diffusion (evd)' 70 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 71 IF(lwp) WRITE(numout,*) 68 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 69 IF( kt == nit000 ) THEN 70 IF(lwp) WRITE(numout,*) 71 IF(lwp) WRITE(numout,*) 'zdf_evd : Enhanced Vertical Diffusion (evd)' 72 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 73 IF(lwp) WRITE(numout,*) 74 ENDIF 75 76 ALLOCATE( zavt_evd(jpi,jpj,jpk) ) 77 IF( nn_evdm == 1 ) ALLOCATE( zavm_evd(jpi,jpj,jpk) ) 72 78 ENDIF 73 79 ! 74 80 ! 75 zavt_evd(:,:,:) = p_avt(:,:,:) ! set avt prior to evd application 81 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 82 zavt_evd(ji,jj,jk) = p_avt(ji,jj,jk) ! set avt prior to evd application 83 END_3D 76 84 ! 77 85 SELECT CASE ( nn_evdm ) … … 79 87 CASE ( 1 ) !== enhance tracer & momentum Kz ==! (if rn2<-1.e-12) 80 88 ! 81 zavm_evd(:,:,:) = p_avm(:,:,:) ! set avm prior to evd application 89 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 90 zavm_evd(ji,jj,jk) = p_avm(ji,jj,jk) ! set avm prior to evd application 91 END_3D 82 92 ! 83 93 !! change last digits results … … 87 97 ! END WHERE 88 98 ! 89 DO_3D ( 0, 0, 0, 0, 1, jpkm1 )99 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 90 100 IF( MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) THEN 91 101 p_avt(ji,jj,jk) = rn_evd * wmask(ji,jj,jk) … … 94 104 END_3D 95 105 ! 96 zavm_evd(:,:,:) = p_avm(:,:,:) - zavm_evd(:,:,:) ! change in avm due to evd 97 CALL iom_put( "avm_evd", zavm_evd ) ! output this change 106 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 107 zavm_evd(ji,jj,jk) = p_avm(ji,jj,jk) - zavm_evd(ji,jj,jk) ! change in avm due to evd 108 END_3D 109 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 110 CALL iom_put( "avm_evd", zavm_evd ) ! output this change 111 DEALLOCATE( zavm_evd ) 112 ENDIF 98 113 ! 99 114 CASE DEFAULT !== enhance tracer Kz ==! (if rn2<-1.e-12) … … 103 118 ! END WHERE 104 119 105 DO_3D ( 0, 0, 0, 0, 1, jpkm1 )120 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 106 121 IF( MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) & 107 122 p_avt(ji,jj,jk) = rn_evd * wmask(ji,jj,jk) … … 110 125 END SELECT 111 126 ! 112 zavt_evd(:,:,:) = p_avt(:,:,:) - zavt_evd(:,:,:) ! change in avt due to evd 113 CALL iom_put( "avt_evd", zavt_evd ) ! output this change 127 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 128 zavt_evd(ji,jj,jk) = p_avt(ji,jj,jk) - zavt_evd(ji,jj,jk) ! change in avt due to evd 129 END_3D 130 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 131 CALL iom_put( "avt_evd", zavt_evd ) ! output this change 132 DEALLOCATE( zavt_evd ) 133 ENDIF 114 134 IF( l_trdtra ) CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_evd, zavt_evd ) 115 135 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfgls.F90
r14156 r14958 137 137 USE zdf_oce , ONLY : en, avtb, avmb ! ocean vertical physics 138 138 !! 139 INTEGER , INTENT(in ) :: kt ! ocean time step140 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices141 REAL(wp), DIMENSION( :,:,:), INTENT(in ) :: p_sh2 ! shear production term142 REAL(wp), DIMENSION(:,:,:) , INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points)139 INTEGER , INTENT(in ) :: kt ! ocean time step 140 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 141 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: p_sh2 ! shear production term 142 REAL(wp), DIMENSION(:,:,:) , INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points) 143 143 ! 144 144 INTEGER :: ji, jj, jk ! dummy loop arguments … … 151 151 REAL(wp) :: gh, gm, shr, dif, zsqen, zavt, zavm ! - - 152 152 REAL(wp) :: zmsku, zmskv ! - - 153 REAL(wp), DIMENSION( jpi,jpj) :: zdep154 REAL(wp), DIMENSION( jpi,jpj) :: zkar155 REAL(wp), DIMENSION( jpi,jpj) :: zflxs! Turbulence fluxed induced by internal waves156 REAL(wp), DIMENSION( jpi,jpj) :: zhsro! Surface roughness (surface waves)157 REAL(wp), DIMENSION( jpi,jpj) :: zice_fra! Tapering of wave breaking under sea ice158 REAL(wp), DIMENSION( jpi,jpj,jpk) :: eb! tke at time before159 REAL(wp), DIMENSION( jpi,jpj,jpk) :: hmxl_b! mixing length at time before160 REAL(wp), DIMENSION( jpi,jpj,jpk) :: eps! dissipation rate161 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zwall_psi! Wall function use in the wb case (ln_sigpsi)162 REAL(wp), DIMENSION( jpi,jpj,jpk) :: psi! psi at time now163 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zd_lw, zd_up, zdiag ! lower, upper and diagonal of the matrix164 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zstt, zstm! stability function on tracer and momentum153 REAL(wp), DIMENSION(A2D(nn_hls)) :: zdep 154 REAL(wp), DIMENSION(A2D(nn_hls)) :: zkar 155 REAL(wp), DIMENSION(A2D(nn_hls)) :: zflxs ! Turbulence fluxed induced by internal waves 156 REAL(wp), DIMENSION(A2D(nn_hls)) :: zhsro ! Surface roughness (surface waves) 157 REAL(wp), DIMENSION(A2D(nn_hls)) :: zice_fra ! Tapering of wave breaking under sea ice 158 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: eb ! tke at time before 159 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: hmxl_b ! mixing length at time before 160 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: eps ! dissipation rate 161 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zwall_psi ! Wall function use in the wb case (ln_sigpsi) 162 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: psi ! psi at time now 163 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zd_lw, zd_up, zdiag ! lower, upper and diagonal of the matrix 164 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zstt, zstm ! stability function on tracer and momentum 165 165 !!-------------------------------------------------------------------- 166 166 ! 167 167 ! Preliminary computing 168 169 ustar2_surf(:,:) = 0._wp ; psi(:,:,:) = 0._wp 170 ustar2_top (:,:) = 0._wp ; zwall_psi(:,:,:) = 0._wp 171 ustar2_bot (:,:) = 0._wp 168 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 169 ustar2_surf(ji,jj) = 0._wp ; ustar2_top(ji,jj) = 0._wp ; ustar2_bot(ji,jj) = 0._wp 170 END_2D 171 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 172 psi(ji,jj,jk) = 0._wp ; zwall_psi(ji,jj,jk) = 0._wp 173 END_3D 172 174 173 175 SELECT CASE ( nn_z0_ice ) 174 176 CASE( 0 ) ; zice_fra(:,:) = 0._wp 175 CASE( 1 ) ; zice_fra(:,:) = TANH( fr_i( :,:) * 10._wp )176 CASE( 2 ) ; zice_fra(:,:) = fr_i( :,:)177 CASE( 3 ) ; zice_fra(:,:) = MIN( 4._wp * fr_i( :,:) , 1._wp )177 CASE( 1 ) ; zice_fra(:,:) = TANH( fr_i(A2D(nn_hls)) * 10._wp ) 178 CASE( 2 ) ; zice_fra(:,:) = fr_i(A2D(nn_hls)) 179 CASE( 3 ) ; zice_fra(:,:) = MIN( 4._wp * fr_i(A2D(nn_hls)) , 1._wp ) 178 180 END SELECT 179 181 180 182 ! Compute surface, top and bottom friction at T-points 181 DO_2D ( 0, 0, 0, 0) !== surface ocean friction183 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !== surface ocean friction 182 184 ustar2_surf(ji,jj) = r1_rho0 * taum(ji,jj) * tmask(ji,jj,1) ! surface friction 183 185 END_2D … … 186 188 ! 187 189 IF( .NOT.ln_drg_OFF ) THEN !== top/bottom friction (explicit before friction) 188 DO_2D ( 0, 0, 0, 0 )! bottom friction (explicit before friction)190 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! bottom friction (explicit before friction) 189 191 zmsku = 0.5_wp * ( 2._wp - umask(ji-1,jj,mbkt(ji,jj)) * umask(ji,jj,mbkt(ji,jj)) ) 190 192 zmskv = 0.5_wp * ( 2._wp - vmask(ji,jj-1,mbkt(ji,jj)) * vmask(ji,jj,mbkt(ji,jj)) ) ! (CAUTION: CdU<0) … … 193 195 END_2D 194 196 IF( ln_isfcav ) THEN 195 DO_2D ( 0, 0, 0, 0) ! top friction197 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! top friction 196 198 zmsku = 0.5_wp * ( 2. - umask(ji-1,jj,mikt(ji,jj)) * umask(ji,jj,mikt(ji,jj)) ) 197 199 zmskv = 0.5_wp * ( 2. - vmask(ji,jj-1,mikt(ji,jj)) * vmask(ji,jj,mikt(ji,jj)) ) ! (CAUTION: CdU<0) … … 206 208 zhsro(:,:) = rn_hsro 207 209 CASE ( 1 ) ! Standard Charnock formula 208 zhsro(:,:) = MAX( rsbc_zs1 * ustar2_surf(:,:) , rn_hsro ) 210 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 211 zhsro(ji,jj) = MAX( rsbc_zs1 * ustar2_surf(ji,jj) , rn_hsro ) 212 END_2D 209 213 CASE ( 2 ) ! Roughness formulae according to Rascle et al., Ocean Modelling (2008) 210 214 !!gm faster coding : the 2 comment lines should be used 211 215 !!gm zcof = 2._wp * 0.6_wp / 28._wp 212 216 !!gm zdep(:,:) = 30._wp * TANH( zcof/ SQRT( MAX(ustar2_surf(:,:),rsmall) ) ) ! Wave age (eq. 10) 213 zdep (:,:) = 30.*TANH( 2.*0.3/(28.*SQRT(MAX(ustar2_surf(:,:),rsmall))) ) ! Wave age (eq. 10) 214 zhsro(:,:) = MAX(rsbc_zs2 * ustar2_surf(:,:) * zdep(:,:)**1.5, rn_hsro) ! zhsro = rn_frac_hs * Hsw (eq. 11) 217 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 218 zcof = 30.*TANH( 2.*0.3/(28.*SQRT(MAX(ustar2_surf(ji,jj),rsmall))) ) ! Wave age (eq. 10) 219 zhsro(ji,jj) = MAX(rsbc_zs2 * ustar2_surf(ji,jj) * zcof**1.5, rn_hsro) ! zhsro = rn_frac_hs * Hsw (eq. 11) 220 END_2D 215 221 CASE ( 3 ) ! Roughness given by the wave model (coupled or read in file) 216 zhsro(:,:) = MAX(rn_frac_hs * hsw( :,:), rn_hsro) ! (rn_frac_hs=1.6 see Eq. (5) of Rascle et al. 2008 )222 zhsro(:,:) = MAX(rn_frac_hs * hsw(A2D(nn_hls)), rn_hsro) ! (rn_frac_hs=1.6 see Eq. (5) of Rascle et al. 2008 ) 217 223 END SELECT 218 224 ! 219 225 ! adapt roughness where there is sea ice 220 zhsro(:,:) = ( (1._wp-zice_fra(:,:)) * zhsro(:,:) + zice_fra(:,:) * rn_hsri )*tmask(:,:,1) + (1._wp - tmask(:,:,1))*rn_hsro 221 ! 222 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) !== Compute dissipation rate ==! 226 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 227 zhsro(ji,jj) = ( (1._wp-zice_fra(ji,jj)) * zhsro(ji,jj) + zice_fra(ji,jj) * rn_hsri )*tmask(ji,jj,1) + & 228 & (1._wp - tmask(ji,jj,1))*rn_hsro 229 END_2D 230 ! 231 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) !== Compute dissipation rate ==! 223 232 eps(ji,jj,jk) = rc03 * en(ji,jj,jk) * SQRT( en(ji,jj,jk) ) / hmxl_n(ji,jj,jk) 224 233 END_3D 225 234 226 235 ! Save tke at before time step 227 eb (:,:,:) = en (:,:,:) 228 hmxl_b(:,:,:) = hmxl_n(:,:,:) 236 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 237 eb (ji,jj,jk) = en (ji,jj,jk) 238 hmxl_b(ji,jj,jk) = hmxl_n(ji,jj,jk) 239 END_3D 229 240 230 241 IF( nn_clos == 0 ) THEN ! Mellor-Yamada 231 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )242 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 232 243 zup = hmxl_n(ji,jj,jk) * gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) 233 244 zdown = vkarmn * gdepw(ji,jj,jk,Kmm) * ( -gdepw(ji,jj,jk,Kmm) + gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) ) … … 250 261 ! Warning : after this step, en : right hand side of the matrix 251 262 252 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )263 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 253 264 ! 254 265 buoy = - p_avt(ji,jj,jk) * rn2(ji,jj,jk) ! stratif. destruction … … 303 314 ! 304 315 CASE ( 0 ) ! Dirichlet boundary condition (set e at k=1 & 2) 305 ! First level 306 en (:,:,1) = MAX( rn_emin , rc02r * ustar2_surf(:,:) * (1._wp + (1._wp-zice_fra(:,:))*rsbc_tke1)**r2_3 ) 307 zd_lw(:,:,1) = en(:,:,1) 308 zd_up(:,:,1) = 0._wp 309 zdiag(:,:,1) = 1._wp 310 ! 311 ! One level below 312 en (:,:,2) = MAX( rc02r * ustar2_surf(:,:) * ( 1._wp + (1._wp-zice_fra(:,:))*rsbc_tke1 * ((zhsro(:,:)+gdepw(:,:,2,Kmm)) & 313 & / zhsro(:,:) )**(1.5_wp*ra_sf) )**(2._wp/3._wp) , rn_emin ) 314 zd_lw(:,:,2) = 0._wp 315 zd_up(:,:,2) = 0._wp 316 zdiag(:,:,2) = 1._wp 317 ! 318 ! 316 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 317 ! First level 318 en (ji,jj,1) = MAX( rn_emin , rc02r * ustar2_surf(ji,jj) * (1._wp + (1._wp-zice_fra(ji,jj))*rsbc_tke1)**r2_3 ) 319 zd_lw(ji,jj,1) = en(ji,jj,1) 320 zd_up(ji,jj,1) = 0._wp 321 zdiag(ji,jj,1) = 1._wp 322 ! 323 ! One level below 324 en (ji,jj,2) = MAX( rn_emin , rc02r * ustar2_surf(ji,jj) * (1._wp + (1._wp-zice_fra(ji,jj))*rsbc_tke1 & 325 & * ((zhsro(ji,jj)+gdepw(ji,jj,2,Kmm)) / zhsro(ji,jj) )**(1.5_wp*ra_sf) )**r2_3 ) 326 zd_lw(ji,jj,2) = 0._wp 327 zd_up(ji,jj,2) = 0._wp 328 zdiag(ji,jj,2) = 1._wp 329 END_2D 330 ! 331 ! 319 332 CASE ( 1 ) ! Neumann boundary condition (set d(e)/dz) 320 ! 321 ! Dirichlet conditions at k=1 322 en (:,:,1) = MAX( rc02r * ustar2_surf(:,:) * (1._wp + (1._wp-zice_fra(:,:))*rsbc_tke1)**r2_3 , rn_emin ) 323 zd_lw(:,:,1) = en(:,:,1) 324 zd_up(:,:,1) = 0._wp 325 zdiag(:,:,1) = 1._wp 326 ! 327 ! at k=2, set de/dz=Fw 328 !cbr 329 DO_2D( 0, 0, 0, 0 ) ! zdiag zd_lw not defined/used on the halo 330 zdiag(ji,jj,2) = zdiag(ji,jj,2) + zd_lw(ji,jj,2) ! Remove zd_lw from zdiag 331 zd_lw(ji,jj,2) = 0._wp 332 END_2D 333 zkar (:,:) = (rl_sf + (vkarmn-rl_sf)*(1.-EXP(-rtrans*gdept(:,:,1,Kmm)/zhsro(:,:)) )) 334 zflxs(:,:) = rsbc_tke2 * (1._wp-zice_fra(:,:)) * ustar2_surf(:,:)**1.5_wp * zkar(:,:) & 335 & * ( ( zhsro(:,:)+gdept(:,:,1,Kmm) ) / zhsro(:,:) )**(1.5_wp*ra_sf) 333 ! 334 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 335 ! Dirichlet conditions at k=1 336 en (ji,jj,1) = MAX( rn_emin , rc02r * ustar2_surf(ji,jj) * (1._wp + (1._wp-zice_fra(ji,jj))*rsbc_tke1)**r2_3 ) 337 zd_lw(ji,jj,1) = en(ji,jj,1) 338 zd_up(ji,jj,1) = 0._wp 339 zdiag(ji,jj,1) = 1._wp 340 ! 341 ! at k=2, set de/dz=Fw 342 !cbr 343 ! zdiag zd_lw not defined/used on the halo 344 zdiag(ji,jj,2) = zdiag(ji,jj,2) + zd_lw(ji,jj,2) ! Remove zd_lw from zdiag 345 zd_lw(ji,jj,2) = 0._wp 346 ! 347 zkar (ji,jj) = (rl_sf + (vkarmn-rl_sf)*(1.-EXP(-rtrans*gdept(ji,jj,1,Kmm)/zhsro(ji,jj)) )) 348 zflxs(ji,jj) = rsbc_tke2 * (1._wp-zice_fra(ji,jj)) * ustar2_surf(ji,jj)**1.5_wp * zkar(ji,jj) & 349 & * ( ( zhsro(ji,jj)+gdept(ji,jj,1,Kmm) ) / zhsro(ji,jj) )**(1.5_wp*ra_sf) 336 350 !!gm why not : * ( 1._wp + gdept(:,:,1,Kmm) / zhsro(:,:) )**(1.5_wp*ra_sf) 337 en(:,:,2) = en(:,:,2) + zflxs(:,:) / e3w(:,:,2,Kmm) 338 ! 339 ! 351 en(ji,jj,2) = en(ji,jj,2) + zflxs(ji,jj) / e3w(ji,jj,2,Kmm) 352 END_2D 353 ! 354 ! 340 355 END SELECT 341 356 … … 348 363 ! ! en(ibot) = u*^2 / Co2 and hmxl_n(ibot) = rn_lmin 349 364 ! ! Balance between the production and the dissipation terms 350 DO_2D ( 0, 0, 0, 0)365 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 351 366 !!gm This means that bottom and ocean w-level above have a specified "en" value. Sure ???? 352 367 !! With thick deep ocean level thickness, this may be quite large, no ??? … … 365 380 END_2D 366 381 ! 382 ! NOTE: ctl_stop with ln_isfcav when using GLS 367 383 IF( ln_isfcav) THEN ! top boundary (ocean cavity) 368 DO_2D ( 0, 0, 0, 0)384 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 369 385 itop = mikt(ji,jj) ! k top w-point 370 386 itopp1 = mikt(ji,jj) + 1 ! k+1 1st w-point below the top one … … 384 400 CASE ( 1 ) ! Neumman boundary condition 385 401 ! 386 DO_2D ( 0, 0, 0, 0)402 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 387 403 ibot = mbkt(ji,jj) + 1 ! k bottom level of w-point 388 404 ibotm1 = mbkt(ji,jj) ! k-1 bottom level of w-point but >=1 … … 398 414 en (ji,jj,ibot) = z_en 399 415 END_2D 416 ! NOTE: ctl_stop with ln_isfcav when using GLS 400 417 IF( ln_isfcav) THEN ! top boundary (ocean cavity) 401 DO_2D ( 0, 0, 0, 0)418 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 402 419 itop = mikt(ji,jj) ! k top w-point 403 420 itopp1 = mikt(ji,jj) + 1 ! k+1 1st w-point below the top one … … 420 437 ! ---------------------------------------------------------- 421 438 ! 422 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1439 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1 423 440 zdiag(ji,jj,jk) = zdiag(ji,jj,jk) - zd_lw(ji,jj,jk) * zd_up(ji,jj,jk-1) / zdiag(ji,jj,jk-1) 424 441 END_3D 425 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1442 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1 426 443 zd_lw(ji,jj,jk) = en(ji,jj,jk) - zd_lw(ji,jj,jk) / zdiag(ji,jj,jk-1) * zd_lw(ji,jj,jk-1) 427 444 END_3D 428 DO_3DS ( 0, 0, 0, 0, jpkm1, 2, -1 ) ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk445 DO_3DS_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpkm1, 2, -1 ) ! Third recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk 429 446 en(ji,jj,jk) = ( zd_lw(ji,jj,jk) - zd_up(ji,jj,jk) * en(ji,jj,jk+1) ) / zdiag(ji,jj,jk) 430 447 END_3D 431 448 ! ! set the minimum value of tke 432 en(:,:,:) = MAX( en(:,:,:), rn_emin ) 449 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 450 en(ji,jj,jk) = MAX( en(ji,jj,jk), rn_emin ) 451 END_3D 433 452 434 453 !!----------------------------------------!! … … 441 460 ! 442 461 CASE( 0 ) ! k-kl (Mellor-Yamada) 443 DO_3D( 0, 0, 0, 0, 2, jpkm1 )462 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 444 463 psi(ji,jj,jk) = eb(ji,jj,jk) * hmxl_b(ji,jj,jk) 445 464 END_3D 446 465 ! 447 466 CASE( 1 ) ! k-eps 448 DO_3D( 0, 0, 0, 0, 2, jpkm1 )467 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 449 468 psi(ji,jj,jk) = eps(ji,jj,jk) 450 469 END_3D 451 470 ! 452 471 CASE( 2 ) ! k-w 453 DO_3D( 0, 0, 0, 0, 2, jpkm1 )472 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 454 473 psi(ji,jj,jk) = SQRT( eb(ji,jj,jk) ) / ( rc0 * hmxl_b(ji,jj,jk) ) 455 474 END_3D 456 475 ! 457 476 CASE( 3 ) ! generic 458 DO_3D( 0, 0, 0, 0, 2, jpkm1 )477 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 459 478 psi(ji,jj,jk) = rc02 * eb(ji,jj,jk) * hmxl_b(ji,jj,jk)**rnn 460 479 END_3D … … 469 488 ! Warning : after this step, en : right hand side of the matrix 470 489 471 DO_3D( 0, 0, 0, 0, 2, jpkm1 )490 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 472 491 ! 473 492 ! psi / k … … 516 535 CASE ( 0 ) ! Dirichlet boundary conditions 517 536 ! 518 ! Surface value 519 zdep (:,:) = zhsro(:,:) * rl_sf ! Cosmetic 520 psi (:,:,1) = rc0**rpp * en(:,:,1)**rmm * zdep(:,:)**rnn * tmask(:,:,1) 521 zd_lw(:,:,1) = psi(:,:,1) 522 zd_up(:,:,1) = 0._wp 523 zdiag(:,:,1) = 1._wp 524 ! 525 ! One level below 526 zkar (:,:) = (rl_sf + (vkarmn-rl_sf)*(1._wp-EXP(-rtrans*gdepw(:,:,2,Kmm)/zhsro(:,:) ))) 527 zdep (:,:) = (zhsro(:,:) + gdepw(:,:,2,Kmm)) * zkar(:,:) 528 psi (:,:,2) = rc0**rpp * en(:,:,2)**rmm * zdep(:,:)**rnn * tmask(:,:,1) 529 zd_lw(:,:,2) = 0._wp 530 zd_up(:,:,2) = 0._wp 531 zdiag(:,:,2) = 1._wp 537 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 538 ! Surface value 539 zdep (ji,jj) = zhsro(ji,jj) * rl_sf ! Cosmetic 540 psi (ji,jj,1) = rc0**rpp * en(ji,jj,1)**rmm * zdep(ji,jj)**rnn * tmask(ji,jj,1) 541 zd_lw(ji,jj,1) = psi(ji,jj,1) 542 zd_up(ji,jj,1) = 0._wp 543 zdiag(ji,jj,1) = 1._wp 544 ! 545 ! One level below 546 zkar (ji,jj) = (rl_sf + (vkarmn-rl_sf)*(1._wp-EXP(-rtrans*gdepw(ji,jj,2,Kmm)/zhsro(ji,jj) ))) 547 zdep (ji,jj) = (zhsro(ji,jj) + gdepw(ji,jj,2,Kmm)) * zkar(ji,jj) 548 psi (ji,jj,2) = rc0**rpp * en(ji,jj,2)**rmm * zdep(ji,jj)**rnn * tmask(ji,jj,1) 549 zd_lw(ji,jj,2) = 0._wp 550 zd_up(ji,jj,2) = 0._wp 551 zdiag(ji,jj,2) = 1._wp 552 END_2D 532 553 ! 533 554 CASE ( 1 ) ! Neumann boundary condition on d(psi)/dz 534 555 ! 535 ! Surface value: Dirichlet536 zdep (:,:) = zhsro(:,:) * rl_sf537 psi (:,:,1) = rc0**rpp * en(:,:,1)**rmm * zdep(:,:)**rnn * tmask(:,:,1)538 zd_lw(:,:,1) = psi(:,:,1)539 zd_up(:,:,1) = 0._wp540 zdiag(:,:,1) = 1._wp541 !542 ! Neumann condition at k=2543 DO_2D( 0, 0, 0, 0 ) !zdiag zd_lw not defined/used on the halo556 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 557 ! Surface value: Dirichlet 558 zdep (ji,jj) = zhsro(ji,jj) * rl_sf 559 psi (ji,jj,1) = rc0**rpp * en(ji,jj,1)**rmm * zdep(ji,jj)**rnn * tmask(ji,jj,1) 560 zd_lw(ji,jj,1) = psi(ji,jj,1) 561 zd_up(ji,jj,1) = 0._wp 562 zdiag(ji,jj,1) = 1._wp 563 ! 564 ! Neumann condition at k=2, zdiag zd_lw not defined/used on the halo 544 565 zdiag(ji,jj,2) = zdiag(ji,jj,2) + zd_lw(ji,jj,2) ! Remove zd_lw from zdiag 545 566 zd_lw(ji,jj,2) = 0._wp 567 ! 568 ! Set psi vertical flux at the surface: 569 zkar (ji,jj) = rl_sf + (vkarmn-rl_sf)*(1._wp-EXP(-rtrans*gdept(ji,jj,1,Kmm)/zhsro(ji,jj) )) ! Lengh scale slope 570 zdep (ji,jj) = ((zhsro(ji,jj) + gdept(ji,jj,1,Kmm)) / zhsro(ji,jj))**(rmm*ra_sf) 571 zflxs(ji,jj) = (rnn + (1._wp-zice_fra(ji,jj))*rsbc_tke1 * (rnn + rmm*ra_sf) * zdep(ji,jj)) & 572 & *(1._wp + (1._wp-zice_fra(ji,jj))*rsbc_tke1*zdep(ji,jj))**(2._wp*rmm/3._wp-1_wp) 573 zdep (ji,jj) = rsbc_psi1 * (zwall_psi(ji,jj,1)*p_avm(ji,jj,1)+zwall_psi(ji,jj,2)*p_avm(ji,jj,2)) * & 574 & ustar2_surf(ji,jj)**rmm * zkar(ji,jj)**rnn * (zhsro(ji,jj) + gdept(ji,jj,1,Kmm))**(rnn-1.) 575 zflxs(ji,jj) = zdep(ji,jj) * zflxs(ji,jj) 576 psi (ji,jj,2) = psi(ji,jj,2) + zflxs(ji,jj) / e3w(ji,jj,2,Kmm) 546 577 END_2D 547 !548 ! Set psi vertical flux at the surface:549 zkar (:,:) = rl_sf + (vkarmn-rl_sf)*(1._wp-EXP(-rtrans*gdept(:,:,1,Kmm)/zhsro(:,:) )) ! Lengh scale slope550 zdep (:,:) = ((zhsro(:,:) + gdept(:,:,1,Kmm)) / zhsro(:,:))**(rmm*ra_sf)551 zflxs(:,:) = (rnn + (1._wp-zice_fra(:,:))*rsbc_tke1 * (rnn + rmm*ra_sf) * zdep(:,:)) &552 & *(1._wp + (1._wp-zice_fra(:,:))*rsbc_tke1*zdep(:,:))**(2._wp*rmm/3._wp-1_wp)553 zdep (:,:) = rsbc_psi1 * (zwall_psi(:,:,1)*p_avm(:,:,1)+zwall_psi(:,:,2)*p_avm(:,:,2)) * &554 & ustar2_surf(:,:)**rmm * zkar(:,:)**rnn * (zhsro(:,:) + gdept(:,:,1,Kmm))**(rnn-1.)555 zflxs(:,:) = zdep(:,:) * zflxs(:,:)556 psi (:,:,2) = psi(:,:,2) + zflxs(:,:) / e3w(:,:,2,Kmm)557 578 ! 558 579 END SELECT … … 569 590 ! ! en(ibot) = u*^2 / Co2 and hmxl_n(ibot) = vkarmn * r_z0_bot 570 591 ! ! Balance between the production and the dissipation terms 571 DO_2D( 0, 0, 0, 0)592 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 572 593 ibot = mbkt(ji,jj) + 1 ! k bottom level of w-point 573 594 ibotm1 = mbkt(ji,jj) ! k-1 bottom level of w-point but >=1 … … 588 609 CASE ( 1 ) ! Neumman boundary condition 589 610 ! 590 DO_2D( 0, 0, 0, 0)611 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 591 612 ibot = mbkt(ji,jj) + 1 ! k bottom level of w-point 592 613 ibotm1 = mbkt(ji,jj) ! k-1 bottom level of w-point but >=1 … … 616 637 ! ---------------- 617 638 ! 618 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1639 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1 619 640 zdiag(ji,jj,jk) = zdiag(ji,jj,jk) - zd_lw(ji,jj,jk) * zd_up(ji,jj,jk-1) / zdiag(ji,jj,jk-1) 620 641 END_3D 621 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1642 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1 622 643 zd_lw(ji,jj,jk) = psi(ji,jj,jk) - zd_lw(ji,jj,jk) / zdiag(ji,jj,jk-1) * zd_lw(ji,jj,jk-1) 623 644 END_3D 624 DO_3DS( 0, 0, 0, 0, jpkm1, 2, -1 ) ! Third recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk645 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpkm1, 2, -1 ) ! Third recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk 625 646 psi(ji,jj,jk) = ( zd_lw(ji,jj,jk) - zd_up(ji,jj,jk) * psi(ji,jj,jk+1) ) / zdiag(ji,jj,jk) 626 647 END_3D … … 632 653 ! 633 654 CASE( 0 ) ! k-kl (Mellor-Yamada) 634 DO_3D( 0, 0, 0, 0, 1, jpkm1 )655 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 635 656 eps(ji,jj,jk) = rc03 * en(ji,jj,jk) * en(ji,jj,jk) * SQRT( en(ji,jj,jk) ) / MAX( psi(ji,jj,jk), rn_epsmin) 636 657 END_3D 637 658 ! 638 659 CASE( 1 ) ! k-eps 639 DO_3D( 0, 0, 0, 0, 1, jpkm1 )660 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 640 661 eps(ji,jj,jk) = psi(ji,jj,jk) 641 662 END_3D 642 663 ! 643 664 CASE( 2 ) ! k-w 644 DO_3D( 0, 0, 0, 0, 1, jpkm1 )665 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 645 666 eps(ji,jj,jk) = rc04 * en(ji,jj,jk) * psi(ji,jj,jk) 646 667 END_3D … … 650 671 zex1 = ( 1.5_wp + rmm/rnn ) 651 672 zex2 = -1._wp / rnn 652 DO_3D( 0, 0, 0, 0, 1, jpkm1 )673 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 653 674 eps(ji,jj,jk) = zcoef * en(ji,jj,jk)**zex1 * psi(ji,jj,jk)**zex2 654 675 END_3D … … 658 679 ! Limit dissipation rate under stable stratification 659 680 ! -------------------------------------------------- 660 DO_3D ( 0, 0, 0, 0, 1, jpkm1 ) ! Note that this set boundary conditions on hmxl_n at the same time681 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) ! Note that this set boundary conditions on hmxl_n at the same time 661 682 ! limitation 662 683 eps (ji,jj,jk) = MAX( eps(ji,jj,jk), rn_epsmin ) 663 684 hmxl_n(ji,jj,jk) = rc03 * en(ji,jj,jk) * SQRT( en(ji,jj,jk) ) / eps(ji,jj,jk) 664 ! Galperin criterium (NOTE : Not required if the proper value of C3 in stable cases is calculated) 665 zrn2 = MAX( rn2(ji,jj,jk), rsmall ) 666 IF( ln_length_lim ) hmxl_n(ji,jj,jk) = MIN( rn_clim_galp * SQRT( 2._wp * en(ji,jj,jk) / zrn2 ), hmxl_n(ji,jj,jk) ) 667 END_3D 685 END_3D 686 IF( ln_length_lim ) THEN ! Galperin criterium (NOTE : Not required if the proper value of C3 in stable cases is calculated) 687 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 688 zrn2 = MAX( rn2(ji,jj,jk), rsmall ) 689 hmxl_n(ji,jj,jk) = MIN( rn_clim_galp * SQRT( 2._wp * en(ji,jj,jk) / zrn2 ), hmxl_n(ji,jj,jk) ) 690 END_3D 691 ENDIF 668 692 669 693 ! … … 674 698 ! 675 699 CASE ( 0 , 1 ) ! Galperin or Kantha-Clayson stability functions 676 DO_3D( 0, 0, 0, 0, 2, jpkm1 )700 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 677 701 ! zcof = l²/q² 678 702 zcof = hmxl_b(ji,jj,jk) * hmxl_b(ji,jj,jk) / ( 2._wp*eb(ji,jj,jk) ) … … 691 715 ! 692 716 CASE ( 2, 3 ) ! Canuto stability functions 693 DO_3D( 0, 0, 0, 0, 2, jpkm1 )717 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 694 718 ! zcof = l²/q² 695 719 zcof = hmxl_b(ji,jj,jk)*hmxl_b(ji,jj,jk) / ( 2._wp * eb(ji,jj,jk) ) … … 723 747 ! default value, in case jpk > mbkt(ji,jj)+1. Not needed but avoid a bug when looking for undefined values (-fpe0) 724 748 zstm(:,:,jpk) = 0. 725 DO_2D( 0, 0, 0, 0) ! update bottom with good values749 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! update bottom with good values 726 750 zstm(ji,jj,mbkt(ji,jj)+1) = zstm(ji,jj,mbkt(ji,jj)) 727 751 END_2D 728 752 729 zstt(:,:, 1) = wmask( :,:, 1) ! default value not needed but avoid a bug when looking for undefined values (-fpe0)730 zstt(:,:,jpk) = wmask( :,:,jpk) ! default value not needed but avoid a bug when looking for undefined values (-fpe0)753 zstt(:,:, 1) = wmask(A2D(nn_hls), 1) ! default value not needed but avoid a bug when looking for undefined values (-fpe0) 754 zstt(:,:,jpk) = wmask(A2D(nn_hls),jpk) ! default value not needed but avoid a bug when looking for undefined values (-fpe0) 731 755 732 756 !!gm should be done for ISF (top boundary cond.) … … 738 762 ! later overwritten by surface/bottom boundaries conditions, so we don't really care of p_avm(:,:1) and p_avm(:,:jpk) 739 763 ! for zd_lw and zd_up but they have to be defined to avoid a bug when looking for undefined values (-fpe0) 740 DO_3D ( 0, 0, 0, 0, 1, jpk )764 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 741 765 zsqen = SQRT( 2._wp * en(ji,jj,jk) ) * hmxl_n(ji,jj,jk) 742 766 zavt = zsqen * zstt(ji,jj,jk) … … 745 769 p_avm(ji,jj,jk) = MAX( zavm, avmb(jk) ) ! Note that avm is not masked at the surface and the bottom 746 770 END_3D 747 p_avt( :,:,1) = 0._wp771 p_avt(A2D(nn_hls),1) = 0._wp 748 772 ! 749 773 IF(sn_cfctl%l_prtctl) THEN -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfiwm.F90
r13497 r14958 125 125 ! 126 126 INTEGER :: ji, jj, jk ! dummy loop indices 127 REAL(wp) :: zztmp, ztmp1, ztmp2 ! scalar workspace 128 REAL(wp), DIMENSION(jpi,jpj) :: zfact ! Used for vertical structure 129 REAL(wp), DIMENSION(jpi,jpj) :: zhdep ! Ocean depth 130 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zwkb ! WKB-stretched height above bottom 131 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zweight ! Weight for high mode vertical distribution 132 REAL(wp), DIMENSION(jpi,jpj,jpk) :: znu_t ! Molecular kinematic viscosity (T grid) 133 REAL(wp), DIMENSION(jpi,jpj,jpk) :: znu_w ! Molecular kinematic viscosity (W grid) 134 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zReb ! Turbulence intensity parameter 135 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zemx_iwm ! local energy density available for mixing (W/kg) 136 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zav_ratio ! S/T diffusivity ratio (only for ln_tsdiff=T) 137 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zav_wave ! Internal wave-induced diffusivity 127 REAL(wp), SAVE :: zztmp 128 REAL(wp) :: ztmp1, ztmp2 ! scalar workspace 129 REAL(wp), DIMENSION(A2D(nn_hls)) :: zfact ! Used for vertical structure 130 REAL(wp), DIMENSION(A2D(nn_hls)) :: zhdep ! Ocean depth 131 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zwkb ! WKB-stretched height above bottom 132 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zweight ! Weight for high mode vertical distribution 133 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: znu_t ! Molecular kinematic viscosity (T grid) 134 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: znu_w ! Molecular kinematic viscosity (W grid) 135 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zReb ! Turbulence intensity parameter 136 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zemx_iwm ! local energy density available for mixing (W/kg) 137 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zav_ratio ! S/T diffusivity ratio (only for ln_tsdiff=T) 138 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zav_wave ! Internal wave-induced diffusivity 138 139 REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: z3d ! 3D workspace used for iom_put 139 140 REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z2d ! 2D - - - - … … 143 144 ! Set to zero the 1st and last vertical levels of appropriate variables 144 145 IF( iom_use("emix_iwm") ) THEN 145 DO_2D( 0, 0, 0, 0 ) 146 zemx_iwm (ji,jj,1) = 0._wp ; zemx_iwm (ji,jj,jpk) = 0._wp 147 END_2D 146 zemx_iwm(:,:,:) = 0._wp 148 147 ENDIF 149 148 IF( iom_use("av_ratio") ) THEN 150 DO_2D( 0, 0, 0, 0 ) 151 zav_ratio(ji,jj,1) = 0._wp ; zav_ratio(ji,jj,jpk) = 0._wp 152 END_2D 149 zav_ratio(:,:,:) = 0._wp 153 150 ENDIF 154 151 IF( iom_use("av_wave") .OR. sn_cfctl%l_prtctl ) THEN 155 DO_2D( 0, 0, 0, 0 ) 156 zav_wave (ji,jj,1) = 0._wp ; zav_wave (ji,jj,jpk) = 0._wp 157 END_2D 152 zav_wave(:,:,:) = 0._wp 158 153 ENDIF 159 154 ! … … 164 159 ! !* Critical slope mixing: distribute energy over the time-varying ocean depth, 165 160 ! using an exponential decay from the seafloor. 166 DO_2D( 0, 0, 0, 0) ! part independent of the level161 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! part independent of the level 167 162 zhdep(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1) ! depth of the ocean 168 163 zfact(ji,jj) = rho0 * ( 1._wp - EXP( -zhdep(ji,jj) / hcri_iwm(ji,jj) ) ) … … 170 165 END_2D 171 166 !!gm gde3w ==>>> check for ssh taken into account.... seem OK gde3w_n=gdept(:,:,:,Kmm) - ssh(:,:,Kmm) 172 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! complete with the level-dependent part167 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! complete with the level-dependent part 173 168 IF ( zfact(ji,jj) == 0._wp .OR. wmask(ji,jj,jk) == 0._wp ) THEN ! optimization 174 169 zemx_iwm(ji,jj,jk) = 0._wp … … 190 185 CASE ( 1 ) ! Dissipation scales as N (recommended) 191 186 ! 192 DO_2D( 0, 0, 0, 0)187 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 193 188 zfact(ji,jj) = 0._wp 194 189 END_2D 195 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! part independent of the level190 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! part independent of the level 196 191 zfact(ji,jj) = zfact(ji,jj) + e3w(ji,jj,jk,Kmm) * SQRT( MAX( 0._wp, rn2(ji,jj,jk) ) ) * wmask(ji,jj,jk) 197 192 END_3D 198 193 ! 199 DO_2D( 0, 0, 0, 0)194 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 200 195 IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = epyc_iwm(ji,jj) / ( rho0 * zfact(ji,jj) ) 201 196 END_2D 202 197 ! 203 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! complete with the level-dependent part198 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! complete with the level-dependent part 204 199 zemx_iwm(ji,jj,jk) = zemx_iwm(ji,jj,jk) + zfact(ji,jj) * SQRT( MAX( 0._wp, rn2(ji,jj,jk) ) ) * wmask(ji,jj,jk) 205 200 END_3D … … 207 202 CASE ( 2 ) ! Dissipation scales as N^2 208 203 ! 209 DO_2D( 0, 0, 0, 0)204 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 210 205 zfact(ji,jj) = 0._wp 211 206 END_2D 212 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! part independent of the level207 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! part independent of the level 213 208 zfact(ji,jj) = zfact(ji,jj) + e3w(ji,jj,jk,Kmm) * MAX( 0._wp, rn2(ji,jj,jk) ) * wmask(ji,jj,jk) 214 209 END_3D 215 210 ! 216 DO_2D( 0, 0, 0, 0)211 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 217 212 IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = epyc_iwm(ji,jj) / ( rho0 * zfact(ji,jj) ) 218 213 END_2D 219 214 ! 220 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! complete with the level-dependent part215 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 221 216 zemx_iwm(ji,jj,jk) = zemx_iwm(ji,jj,jk) + zfact(ji,jj) * MAX( 0._wp, rn2(ji,jj,jk) ) * wmask(ji,jj,jk) 222 217 END_3D … … 227 222 ! !* ocean depth as proportional to rn2 * exp(-z_wkb/rn_hbot) 228 223 ! 229 DO_2D( 0, 0, 0, 0)224 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 230 225 zwkb(ji,jj,1) = 0._wp 231 226 END_2D 232 DO_3D( 0, 0, 0, 0, 2, jpkm1 )227 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 233 228 zwkb(ji,jj,jk) = zwkb(ji,jj,jk-1) + e3w(ji,jj,jk,Kmm) * SQRT( MAX( 0._wp, rn2(ji,jj,jk) ) ) * wmask(ji,jj,jk) 234 229 END_3D 235 DO_2D( 0, 0, 0, 0)230 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 236 231 zfact(ji,jj) = zwkb(ji,jj,jpkm1) 237 232 END_2D 238 233 ! 239 DO_3D( 0, 0, 0, 0, 2, jpkm1 )234 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 240 235 IF( zfact(ji,jj) /= 0 ) zwkb(ji,jj,jk) = zhdep(ji,jj) * ( zfact(ji,jj) - zwkb(ji,jj,jk) ) & 241 236 & * wmask(ji,jj,jk) / zfact(ji,jj) 242 237 END_3D 243 DO_2D( 0, 0, 0, 0)238 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 244 239 zwkb (ji,jj,1) = zhdep(ji,jj) * wmask(ji,jj,1) 245 240 END_2D 246 241 ! 247 DO_3D( 0, 0, 0, 0, 2, jpkm1 )242 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 248 243 IF ( rn2(ji,jj,jk) <= 0._wp .OR. wmask(ji,jj,jk) == 0._wp ) THEN ! optimization: EXP coast a lot 249 244 zweight(ji,jj,jk) = 0._wp … … 254 249 END_3D 255 250 ! 256 DO_2D( 0, 0, 0, 0)251 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 257 252 zfact(ji,jj) = 0._wp 258 253 END_2D 259 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! part independent of the level254 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! part independent of the level 260 255 zfact(ji,jj) = zfact(ji,jj) + zweight(ji,jj,jk) 261 256 END_3D 262 257 ! 263 DO_2D( 0, 0, 0, 0)258 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 264 259 IF( zfact(ji,jj) /= 0 ) zfact(ji,jj) = ebot_iwm(ji,jj) / ( rho0 * zfact(ji,jj) ) 265 260 END_2D 266 261 ! 267 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! complete with the level-dependent part262 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! complete with the level-dependent part 268 263 zemx_iwm(ji,jj,jk) = zemx_iwm(ji,jj,jk) + zweight(ji,jj,jk) * zfact(ji,jj) * wmask(ji,jj,jk) & 269 264 & / ( gde3w(ji,jj,jk) - gde3w(ji,jj,jk-1) ) … … 273 268 !!gm this is to be replaced by just a constant value znu=1.e-6 m2/s 274 269 ! Calculate molecular kinematic viscosity 275 DO_3D( 0, 0, 0, 0, 1, jpkm1 )270 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 276 271 znu_t(ji,jj,jk) = 1.e-4_wp * ( 17.91_wp - 0.53810_wp * ts(ji,jj,jk,jp_tem,Kmm) & 277 272 & + 0.00694_wp * ts(ji,jj,jk,jp_tem,Kmm) * ts(ji,jj,jk,jp_tem,Kmm) & 278 273 & + 0.02305_wp * ts(ji,jj,jk,jp_sal,Kmm) ) * tmask(ji,jj,jk) * r1_rho0 279 274 END_3D 280 DO_3D( 0, 0, 0, 0, 2, jpkm1 )275 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 281 276 znu_w(ji,jj,jk) = 0.5_wp * ( znu_t(ji,jj,jk-1) + znu_t(ji,jj,jk) ) * wmask(ji,jj,jk) 282 277 END_3D … … 284 279 ! 285 280 ! Calculate turbulence intensity parameter Reb 286 DO_3D( 0, 0, 0, 0, 2, jpkm1 )281 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 287 282 zReb(ji,jj,jk) = zemx_iwm(ji,jj,jk) / MAX( 1.e-20_wp, znu_w(ji,jj,jk) * rn2(ji,jj,jk) ) 288 283 END_3D 289 284 ! 290 285 ! Define internal wave-induced diffusivity 291 DO_3D( 0, 0, 0, 0, 2, jpkm1 )286 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 292 287 zav_wave(ji,jj,jk) = znu_w(ji,jj,jk) * zReb(ji,jj,jk) * r1_6 ! This corresponds to a constant mixing efficiency of 1/6 293 288 END_3D 294 289 ! 295 290 IF( ln_mevar ) THEN ! Variable mixing efficiency case : modify zav_wave in the 296 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! energetic (Reb > 480) and buoyancy-controlled (Reb <10.224 ) regimes291 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! energetic (Reb > 480) and buoyancy-controlled (Reb <10.224 ) regimes 297 292 IF( zReb(ji,jj,jk) > 480.00_wp ) THEN 298 293 zav_wave(ji,jj,jk) = 3.6515_wp * znu_w(ji,jj,jk) * SQRT( zReb(ji,jj,jk) ) … … 303 298 ENDIF 304 299 ! 305 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! Bound diffusivity by molecular value and 100 cm2/s300 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Bound diffusivity by molecular value and 100 cm2/s 306 301 zav_wave(ji,jj,jk) = MIN( MAX( 1.4e-7_wp, zav_wave(ji,jj,jk) ), 1.e-2_wp ) * wmask(ji,jj,jk) 307 302 END_3D 308 303 ! 309 304 IF( kt == nit000 ) THEN !* Control print at first time-step: diagnose the energy consumed by zav_wave 310 zztmp = 0._wp305 IF( .NOT. l_istiled .OR. ntile == 1 ) zztmp = 0._wp ! Do only on the first tile 311 306 !!gm used of glosum 3D.... 312 307 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) … … 314 309 & * MAX( 0._wp, rn2(ji,jj,jk) ) * zav_wave(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj) 315 310 END_3D 316 CALL mpp_sum( 'zdfiwm', zztmp ) 317 zztmp = rho0 * zztmp ! Global integral of rauo * Kz * N^2 = power contributing to mixing 318 ! 319 IF(lwp) THEN 320 WRITE(numout,*) 321 WRITE(numout,*) 'zdf_iwm : Internal wave-driven mixing (iwm)' 322 WRITE(numout,*) '~~~~~~~ ' 323 WRITE(numout,*) 324 WRITE(numout,*) ' Total power consumption by av_wave = ', zztmp * 1.e-12_wp, 'TW' 311 312 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 313 CALL mpp_sum( 'zdfiwm', zztmp ) 314 zztmp = rho0 * zztmp ! Global integral of rauo * Kz * N^2 = power contributing to mixing 315 ! 316 IF(lwp) THEN 317 WRITE(numout,*) 318 WRITE(numout,*) 'zdf_iwm : Internal wave-driven mixing (iwm)' 319 WRITE(numout,*) '~~~~~~~ ' 320 WRITE(numout,*) 321 WRITE(numout,*) ' Total power consumption by av_wave = ', zztmp * 1.e-12_wp, 'TW' 322 ENDIF 325 323 ENDIF 326 324 ENDIF … … 332 330 IF( ln_tsdiff ) THEN !* Option for differential mixing of salinity and temperature 333 331 ztmp1 = 0.505_wp + 0.495_wp * TANH( 0.92_wp * ( LOG10( 1.e-20_wp ) - 0.60_wp ) ) 334 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! Calculate S/T diffusivity ratio as a function of Reb332 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! Calculate S/T diffusivity ratio as a function of Reb 335 333 ztmp2 = zReb(ji,jj,jk) * 5._wp * r1_6 336 334 IF ( ztmp2 > 1.e-20_wp .AND. wmask(ji,jj,jk) == 1._wp ) THEN … … 341 339 END_3D 342 340 CALL iom_put( "av_ratio", zav_ratio ) 343 DO_3D ( 0, 0, 0, 0, 2, jpkm1 ) !* update momentum & tracer diffusivity with wave-driven mixing341 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) !* update momentum & tracer diffusivity with wave-driven mixing 344 342 p_avs(ji,jj,jk) = p_avs(ji,jj,jk) + zav_wave(ji,jj,jk) * zav_ratio(ji,jj,jk) 345 343 p_avt(ji,jj,jk) = p_avt(ji,jj,jk) + zav_wave(ji,jj,jk) … … 348 346 ! 349 347 ELSE !* update momentum & tracer diffusivity with wave-driven mixing 350 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )348 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 351 349 p_avs(ji,jj,jk) = p_avs(ji,jj,jk) + zav_wave(ji,jj,jk) 352 350 p_avt(ji,jj,jk) = p_avt(ji,jj,jk) + zav_wave(ji,jj,jk) … … 361 359 ! vertical integral of rho0 * Kz * N^2 , energy density (zemx_iwm) 362 360 IF( iom_use("bflx_iwm") .OR. iom_use("pcmap_iwm") ) THEN 363 ALLOCATE( z2d( jpi,jpj) , z3d(jpi,jpj,jpk) )361 ALLOCATE( z2d(A2D(nn_hls)) , z3d(A2D(nn_hls),jpk) ) 364 362 ! Initialisation for iom_put 365 DO_2D( 0, 0, 0, 0 ) 366 z3d(ji,jj,1) = 0._wp ; z3d(ji,jj,jpk) = 0._wp 367 END_2D 368 z3d( 1:nn_hls,:,:) = 0._wp ; z3d(:, 1:nn_hls,:) = 0._wp 369 z3d(jpi-nn_hls+1:jpi ,:,:) = 0._wp ; z3d(:,jpj-nn_hls+1: jpj,:) = 0._wp 370 z2d( 1:nn_hls,: ) = 0._wp ; z2d(:, 1:nn_hls ) = 0._wp 371 z2d(jpi-nn_hls+1:jpi ,: ) = 0._wp ; z2d(:,jpj-nn_hls+1: jpj ) = 0._wp 363 z2d(:,:) = 0._wp ; z3d(:,:,:) = 0._wp 372 364 373 365 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 374 366 z3d(ji,jj,jk) = MAX( 0._wp, rn2(ji,jj,jk) ) * zav_wave(ji,jj,jk) 375 END_3D376 DO_2D( 0, 0, 0, 0 )377 z2d(ji,jj) = 0._wp378 END_2D379 DO_3D( 0, 0, 0, 0, 2, jpkm1 )380 367 z2d(ji,jj) = z2d(ji,jj) + e3w(ji,jj,jk,Kmm) * z3d(ji,jj,jk) * wmask(ji,jj,jk) 381 368 END_3D -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfmfc.F90
r14433 r14958 96 96 INTEGER , INTENT(in) :: Kmm, Krhs ! time level indices 97 97 REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts ! active tracers and RHS of tracer equation 98 REAL(wp), DIMENSION( jpi,jpj,jpk,2) :: ztsp ! T/S of the plume99 REAL(wp), DIMENSION( jpi,jpj,jpk,2) :: ztse ! T/S at W point100 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zrwp !101 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zrwp2 !102 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zapp !103 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zedmf !104 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zepsT, zepsW !105 ! 106 REAL(wp), DIMENSION( jpi,jpj) :: zustar, zustar2 !107 REAL(wp), DIMENSION( jpi,jpj) :: zuws, zvws, zsws, zfnet !108 REAL(wp), DIMENSION( jpi,jpj) :: zfbuo, zrautbm1, zrautb, zraupl109 REAL(wp), DIMENSION( jpi,jpj) :: zwpsurf !110 REAL(wp), DIMENSION( jpi,jpj) :: zop0 , zsp0 !111 REAL(wp), DIMENSION( jpi,jpj) :: zrwp_0, zrwp2_0 !112 REAL(wp), DIMENSION( jpi,jpj) :: zapp0 !113 REAL(wp), DIMENSION( jpi,jpj) :: zphp, zph, zphpm1, zphm1, zNHydro114 REAL(wp), DIMENSION( jpi,jpj) :: zhcmo !115 ! 116 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zn2 ! N^2117 REAL(wp), DIMENSION( jpi,jpj,2 ) :: zab, zabm1, zabp ! alpha and beta98 REAL(wp), DIMENSION(A2D(nn_hls),jpk,2) :: ztsp ! T/S of the plume 99 REAL(wp), DIMENSION(A2D(nn_hls),jpk,2) :: ztse ! T/S at W point 100 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zrwp ! 101 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zrwp2 ! 102 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zapp ! 103 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zedmf ! 104 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zepsT, zepsW ! 105 ! 106 REAL(wp), DIMENSION(A2D(nn_hls)) :: zustar, zustar2 ! 107 REAL(wp), DIMENSION(A2D(nn_hls)) :: zuws, zvws, zsws, zfnet ! 108 REAL(wp), DIMENSION(A2D(nn_hls)) :: zfbuo, zrautbm1, zrautb, zraupl 109 REAL(wp), DIMENSION(A2D(nn_hls)) :: zwpsurf ! 110 REAL(wp), DIMENSION(A2D(nn_hls)) :: zop0 , zsp0 ! 111 REAL(wp), DIMENSION(A2D(nn_hls)) :: zrwp_0, zrwp2_0 ! 112 REAL(wp), DIMENSION(A2D(nn_hls)) :: zapp0 ! 113 REAL(wp), DIMENSION(A2D(nn_hls)) :: zphp, zph, zphpm1, zphm1, zNHydro 114 REAL(wp), DIMENSION(A2D(nn_hls)) :: zhcmo ! 115 ! 116 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zn2 ! N^2 117 REAL(wp), DIMENSION(A2D(nn_hls),2 ) :: zab, zabm1, zabp ! alpha and beta 118 118 119 119 REAL(wp), PARAMETER :: zepsilon = 1.e-30 ! local small value … … 136 136 zcd = 1._wp 137 137 138 !------------------------------------------------------------------ 139 ! Surface boundary condition 140 !------------------------------------------------------------------ 141 ! surface Stress 142 !-------------------- 143 zuws(:,:) = utau(:,:) * r1_rho0 144 zvws(:,:) = vtau(:,:) * r1_rho0 145 zustar2(:,:) = SQRT(zuws(:,:)*zuws(:,:)+zvws(:,:)*zvws(:,:)) 146 zustar(:,:) = SQRT(zustar2(:,:)) 147 148 ! Heat Flux 149 !-------------------- 150 zfnet(:,:) = qns(:,:) + qsr(:,:) 151 zfnet(:,:) = zfnet(:,:) / (rho0 * rcp) 152 153 ! Water Flux 154 !--------------------- 155 zsws(:,:) = emp(:,:) 156 157 !------------------------------------------- 158 ! Initialisation of prognostic variables 159 !------------------------------------------- 160 zrwp (:,:,:) = 0._wp ; zrwp2(:,:,:) = 0._wp ; zedmf(:,:,:) = 0._wp 161 zph (:,:) = 0._wp ; zphm1(:,:) = 0._wp ; zphpm1(:,:) = 0._wp 162 ztsp(:,:,:,:)= 0._wp 163 164 ! Tracers inside plume (ztsp) and environment (ztse) 165 ztsp(:,:,1,jp_tem) = pts(:,:,1,jp_tem,Kmm) * tmask(:,:,1) 166 ztsp(:,:,1,jp_sal) = pts(:,:,1,jp_sal,Kmm) * tmask(:,:,1) 167 ztse(:,:,1,jp_tem) = pts(:,:,1,jp_tem,Kmm) * tmask(:,:,1) 168 ztse(:,:,1,jp_sal) = pts(:,:,1,jp_sal,Kmm) * tmask(:,:,1) 138 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 139 !------------------------------------------------------------------ 140 ! Surface boundary condition 141 !------------------------------------------------------------------ 142 ! surface Stress 143 !-------------------- 144 zuws(ji,jj) = utau(ji,jj) * r1_rho0 145 zvws(ji,jj) = vtau(ji,jj) * r1_rho0 146 zustar2(ji,jj) = SQRT(zuws(ji,jj)*zuws(ji,jj)+zvws(ji,jj)*zvws(ji,jj)) 147 zustar(ji,jj) = SQRT(zustar2(ji,jj)) 148 149 ! Heat Flux 150 !-------------------- 151 zfnet(ji,jj) = qns(ji,jj) + qsr(ji,jj) 152 zfnet(ji,jj) = zfnet(ji,jj) / (rho0 * rcp) 153 154 ! Water Flux 155 !--------------------- 156 zsws(ji,jj) = emp(ji,jj) 157 158 !------------------------------------------- 159 ! Initialisation of prognostic variables 160 !------------------------------------------- 161 zrwp (ji,jj,:) = 0._wp ; zrwp2(ji,jj,:) = 0._wp ; zedmf(ji,jj,:) = 0._wp 162 zph (ji,jj) = 0._wp ; zphm1(ji,jj) = 0._wp ; zphpm1(ji,jj) = 0._wp 163 ztsp(ji,jj,:,:)= 0._wp 164 165 ! Tracers inside plume (ztsp) and environment (ztse) 166 ztsp(ji,jj,1,jp_tem) = pts(ji,jj,1,jp_tem,Kmm) * tmask(ji,jj,1) 167 ztsp(ji,jj,1,jp_sal) = pts(ji,jj,1,jp_sal,Kmm) * tmask(ji,jj,1) 168 ztse(ji,jj,1,jp_tem) = pts(ji,jj,1,jp_tem,Kmm) * tmask(ji,jj,1) 169 ztse(ji,jj,1,jp_sal) = pts(ji,jj,1,jp_sal,Kmm) * tmask(ji,jj,1) 170 END_2D 169 171 170 172 CALL eos( ztse(:,:,1,:) , zrautb(:,:) ) … … 174 176 ! Boundary Condition of Mass Flux (plume velo.; convective area, entrain/detrain) 175 177 !------------------------------------------- 176 zhcmo(:,:) = e3t( :,:,1,Kmm)178 zhcmo(:,:) = e3t(A1Di(nn_hls),A1Dj(nn_hls),1,Kmm) 177 179 zfbuo(:,:) = 0._wp 178 180 WHERE ( ABS(zrautb(:,:)) > 1.e-20 ) zfbuo(:,:) = & 179 & grav * ( 2.e-4_wp *zfnet(:,:) - 7.6E-4_wp*pts(:,:,1,jp_sal,Kmm)*zsws(:,:)/zrautb(:,:)) * zhcmo(:,:) 181 & grav * ( 2.e-4_wp *zfnet(:,:) & 182 & - 7.6E-4_wp*pts(A2D(nn_hls),1,jp_sal,Kmm) & 183 & * zsws(:,:)/zrautb(:,:)) * zhcmo(:,:) 180 184 181 185 zedmf(:,:,1) = -0.065_wp*(ABS(zfbuo(:,:)))**(1._wp/3._wp)*SIGN(1.,zfbuo(:,:)) … … 211 215 CALL eos( ztsp(:,:,jk-1,: ) , zraupl(:,:) ) 212 216 213 zphm1(:,:) = zphm1(:,:) + grav * zrautbm1(:,:) * e3t(:,:,jk-1, Kmm) 214 zphpm1(:,:) = zphpm1(:,:) + grav * zraupl(:,:) * e3t(:,:,jk-1, Kmm) 215 zph(:,:) = zphm1(:,:) + grav * zrautb(:,:) * e3t(:,:,jk , Kmm) 216 zph(:,:) = MAX( zph(:,:), zepsilon) 217 DO_2D( 0, 0, 0, 0 ) 218 zphm1(ji,jj) = zphm1(ji,jj) + grav * zrautbm1(ji,jj) * e3t(ji,jj,jk-1, Kmm) 219 zphpm1(ji,jj) = zphpm1(ji,jj) + grav * zraupl(ji,jj) * e3t(ji,jj,jk-1, Kmm) 220 zph(ji,jj) = zphm1(ji,jj) + grav * zrautb(ji,jj) * e3t(ji,jj,jk , Kmm) 221 zph(ji,jj) = MAX( zph(ji,jj), zepsilon) 222 END_2D 217 223 218 224 WHERE(zrautbm1 .NE. 0.) zfbuo(:,:) = grav * (zraupl(:,:) - zrautbm1(:,:)) / zrautbm1(:,:) … … 322 328 323 329 ! Compute Mass Flux on T-point 324 DO jk=1,jpk-1 325 edmfm(:,:,jk) = (zedmf(:,:,jk+1) + zedmf(:,:,jk) )*0.5_wp 326 END DO 327 edmfm(:,:,jpk) = zedmf(:,:,jpk) 330 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 331 edmfm(ji,jj,jk) = (zedmf(ji,jj,jk+1) + zedmf(ji,jj,jk) )*0.5_wp 332 END_3D 333 DO_2D( 0, 0, 0, 0 ) 334 edmfm(ji,jj,jpk) = zedmf(ji,jj,jpk) 335 END_2D 328 336 329 337 ! Save variable (on T point) … … 338 346 ! Computation of a tridiagonal matrix and right hand side terms of the linear system 339 347 !================================================================================= 340 edmfa(:,:,:) = 0._wp 341 edmfb(:,:,:) = 0._wp 342 edmfc(:,:,:) = 0._wp 343 edmftra(:,:,:,:) = 0._wp 348 DO_3D( 0, 0, 0, 0, 1, jpk ) 349 edmfa(ji,jj,jk) = 0._wp 350 edmfb(ji,jj,jk) = 0._wp 351 edmfc(ji,jj,jk) = 0._wp 352 edmftra(ji,jj,jk,:) = 0._wp 353 END_3D 344 354 345 355 !--------------------------------------------------------------- 346 356 ! Diagonal terms 347 357 !--------------------------------------------------------------- 348 DO jk=1,jpk-1 349 edmfa(:,:,jk) = 0._wp 350 edmfb(:,:,jk) = -edmfm(:,:,jk ) / e3w(:,:,jk+1,Kmm) 351 edmfc(:,:,jk) = edmfm(:,:,jk+1) / e3w(:,:,jk+1,Kmm) 352 END DO 353 edmfa(:,:,jpk) = -edmfm(:,:,jpk-1) / e3w(:,:,jpk,Kmm) 354 edmfb(:,:,jpk) = edmfm(:,:,jpk ) / e3w(:,:,jpk,Kmm) 355 edmfc(:,:,jpk) = 0._wp 358 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 359 edmfa(ji,jj,jk) = 0._wp 360 edmfb(ji,jj,jk) = -edmfm(ji,jj,jk ) / e3w(ji,jj,jk+1,Kmm) 361 edmfc(ji,jj,jk) = edmfm(ji,jj,jk+1) / e3w(ji,jj,jk+1,Kmm) 362 END_3D 363 DO_2D( 0, 0, 0, 0 ) 364 edmfa(ji,jj,jpk) = -edmfm(ji,jj,jpk-1) / e3w(ji,jj,jpk,Kmm) 365 edmfb(ji,jj,jpk) = edmfm(ji,jj,jpk ) / e3w(ji,jj,jpk,Kmm) 366 edmfc(ji,jj,jpk) = 0._wp 367 END_2D 356 368 357 369 !--------------------------------------------------------------- 358 370 ! right hand side term for Temperature 359 371 !--------------------------------------------------------------- 360 DO jk=1,jpk-1 361 edmftra(:,:,jk,1) = - edmfm(:,:,jk ) * ztsp(:,:,jk ,jp_tem) / e3w(:,:,jk+1,Kmm) & 362 & + edmfm(:,:,jk+1) * ztsp(:,:,jk+1,jp_tem) / e3w(:,:,jk+1,Kmm) 363 END DO 364 edmftra(:,:,jpk,1) = - edmfm(:,:,jpk-1) * ztsp(:,:,jpk-1,jp_tem) / e3w(:,:,jpk,Kmm) & 365 & + edmfm(:,:,jpk ) * ztsp(:,:,jpk ,jp_tem) / e3w(:,:,jpk,Kmm) 366 372 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 373 edmftra(ji,jj,jk,1) = - edmfm(ji,jj,jk ) * ztsp(ji,jj,jk ,jp_tem) / e3w(ji,jj,jk+1,Kmm) & 374 & + edmfm(ji,jj,jk+1) * ztsp(ji,jj,jk+1,jp_tem) / e3w(ji,jj,jk+1,Kmm) 375 END_3D 376 DO_2D( 0, 0, 0, 0 ) 377 edmftra(ji,jj,jpk,1) = - edmfm(ji,jj,jpk-1) * ztsp(ji,jj,jpk-1,jp_tem) / e3w(ji,jj,jpk,Kmm) & 378 & + edmfm(ji,jj,jpk ) * ztsp(ji,jj,jpk ,jp_tem) / e3w(ji,jj,jpk,Kmm) 379 END_2D 380 367 381 !--------------------------------------------------------------- 368 382 ! Right hand side term for Salinity 369 383 !--------------------------------------------------------------- 370 DO jk=1,jpk-1 371 edmftra(:,:,jk,2) = - edmfm(:,:,jk ) * ztsp(:,:,jk ,jp_sal) / e3w(:,:,jk+1,Kmm) & 372 & + edmfm(:,:,jk+1) * ztsp(:,:,jk+1,jp_sal) / e3w(:,:,jk+1,Kmm) 373 END DO 374 edmftra(:,:,jpk,2) = - edmfm(:,:,jpk-1) * ztsp(:,:,jpk-1,jp_sal) / e3w(:,:,jpk,Kmm) & 375 & + edmfm(:,:,jpk ) * ztsp(:,:,jpk ,jp_sal) / e3w(:,:,jpk,Kmm) 376 ! 377 ! 378 CALL lbc_lnk( 'zdfmfc', edmfm,'T',1., edmfa,'T',1., edmfb,'T',1., edmfc,'T',1., edmftra(:,:,:,jp_tem),'T',1., edmftra(:,:,:,jp_sal),'T',1.) 384 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 385 edmftra(ji,jj,jk,2) = - edmfm(ji,jj,jk ) * ztsp(ji,jj,jk ,jp_sal) / e3w(ji,jj,jk+1,Kmm) & 386 & + edmfm(ji,jj,jk+1) * ztsp(ji,jj,jk+1,jp_sal) / e3w(ji,jj,jk+1,Kmm) 387 END_3D 388 DO_2D( 0, 0, 0, 0 ) 389 edmftra(ji,jj,jpk,2) = - edmfm(ji,jj,jpk-1) * ztsp(ji,jj,jpk-1,jp_sal) / e3w(ji,jj,jpk,Kmm) & 390 & + edmfm(ji,jj,jpk ) * ztsp(ji,jj,jpk ,jp_sal) / e3w(ji,jj,jpk,Kmm) 391 END_2D 379 392 ! 380 393 END SUBROUTINE tra_mfc … … 383 396 SUBROUTINE diag_mfc( zdiagi, zdiagd, zdiags, p2dt, Kaa ) 384 397 385 REAL(wp), DIMENSION( jpi,jpj,jpk), INTENT(inout) :: zdiagi, zdiagd, zdiags ! inout: tridaig. terms386 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step387 INTEGER , INTENT(in ) :: Kaa ! ocean time level indices398 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(inout) :: zdiagi, zdiagd, zdiags ! inout: tridaig. terms 399 REAL(wp) , INTENT(in ) :: p2dt ! tracer time-step 400 INTEGER , INTENT(in ) :: Kaa ! ocean time level indices 388 401 389 402 INTEGER :: ji, jj, jk ! dummy loop arguments -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfmxl.F90
r13497 r14958 26 26 PRIVATE 27 27 28 PUBLIC zdf_mxl ! called by zdfphy.F9028 PUBLIC zdf_mxl, zdf_mxl_turb ! called by zdfphy.F90 29 29 30 30 INTEGER , PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nmln !: number of level in the mixed layer (used by LDF, ZDF, TRD, TOP) … … 41 41 !!---------------------------------------------------------------------- 42 42 !! NEMO/OCE 4.0 , NEMO Consortium (2018) 43 !! $Id$ 43 !! $Id$ 44 44 !! Software governed by the CeCILL license (see ./LICENSE) 45 45 !!---------------------------------------------------------------------- … … 65 65 !! *** ROUTINE zdfmxl *** 66 66 !! 67 !! ** Purpose : Compute the turbocline depth and the mixed layer depth 68 !! with density criteria. 67 !! ** Purpose : Compute the mixed layer depth with density criteria. 69 68 !! 70 69 !! ** Method : The mixed layer depth is the shallowest W depth with 71 70 !! the density of the corresponding T point (just bellow) bellow a 72 71 !! given value defined locally as rho(10m) + rho_c 73 !! The turbocline depth is the depth at which the vertical74 !! eddy diffusivity coefficient (resulting from the vertical physics75 !! alone, not the isopycnal part, see trazdf.F) fall below a given76 !! value defined locally (avt_c here taken equal to 5 cm/s2 by default)77 72 !! 78 !! ** Action : nmln, hml d, hmlp, hmlpt73 !! ** Action : nmln, hmlp, hmlpt 79 74 !!---------------------------------------------------------------------- 80 75 INTEGER, INTENT(in) :: kt ! ocean time-step index … … 82 77 ! 83 78 INTEGER :: ji, jj, jk ! dummy loop indices 84 INTEGER :: iik n, iiki, ikt! local integer79 INTEGER :: iik, ikt ! local integer 85 80 REAL(wp) :: zN2_c ! local scalar 86 INTEGER, DIMENSION(jpi,jpj) :: imld ! 2D workspace87 81 !!---------------------------------------------------------------------- 88 82 ! 89 IF( kt == nit000 ) THEN 90 IF(lwp) WRITE(numout,*) 91 IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth' 92 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 93 ! ! allocate zdfmxl arrays 94 IF( zdf_mxl_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'zdf_mxl : unable to allocate arrays' ) 83 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 84 IF( kt == nit000 ) THEN 85 IF(lwp) WRITE(numout,*) 86 IF(lwp) WRITE(numout,*) 'zdf_mxl : mixed layer depth' 87 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 88 ! ! allocate zdfmxl arrays 89 IF( zdf_mxl_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'zdf_mxl : unable to allocate arrays' ) 90 ENDIF 95 91 ENDIF 96 92 ! 97 93 ! w-level of the mixing and mixed layers 98 nmln(:,:) = nlb10 ! Initialization to the number of w ocean point 99 hmlp(:,:) = 0._wp ! here hmlp used as a dummy variable, integrating vertically N^2 94 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 95 nmln(ji,jj) = nlb10 ! Initialization to the number of w ocean point 96 hmlp(ji,jj) = 0._wp ! here hmlp used as a dummy variable, integrating vertically N^2 97 END_2D 100 98 zN2_c = grav * rho_c * r1_rho0 ! convert density criteria into N^2 criteria 101 DO_3D ( 1, 1, 1, 1, nlb10, jpkm1 ) ! Mixed layer level: w-level99 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, nlb10, jpkm1 ) ! Mixed layer level: w-level 102 100 ikt = mbkt(ji,jj) 103 101 hmlp(ji,jj) = & … … 105 103 IF( hmlp(ji,jj) < zN2_c ) nmln(ji,jj) = MIN( jk , ikt ) + 1 ! Mixed layer level 106 104 END_3D 107 ! 108 ! w-level of the turbocline and mixing layer (iom_use) 109 imld(:,:) = mbkt(:,:) + 1 ! Initialization to the number of w ocean point 110 DO_3DS( 1, 1, 1, 1, jpkm1, nlb10, -1 ) ! from the bottom to nlb10 111 IF( avt (ji,jj,jk) < avt_c * wmask(ji,jj,jk) ) imld(ji,jj) = jk ! Turbocline 112 END_3D 113 ! depth of the mixing and mixed layers 114 DO_2D( 1, 1, 1, 1 ) 115 iiki = imld(ji,jj) 116 iikn = nmln(ji,jj) 117 hmld (ji,jj) = gdepw(ji,jj,iiki ,Kmm) * ssmask(ji,jj) ! Turbocline depth 118 hmlp (ji,jj) = gdepw(ji,jj,iikn ,Kmm) * ssmask(ji,jj) ! Mixed layer depth 119 hmlpt(ji,jj) = gdept(ji,jj,iikn-1,Kmm) * ssmask(ji,jj) ! depth of the last T-point inside the mixed layer 105 ! depth of the mixed layer 106 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 107 iik = nmln(ji,jj) 108 hmlp (ji,jj) = gdepw(ji,jj,iik ,Kmm) * ssmask(ji,jj) ! Mixed layer depth 109 hmlpt(ji,jj) = gdept(ji,jj,iik-1,Kmm) * ssmask(ji,jj) ! depth of the last T-point inside the mixed layer 120 110 END_2D 121 111 ! 122 IF( .NOT.l_offline ) THEN 123 IF( iom_use("mldr10_1") ) THEN 124 IF( ln_isfcav ) THEN ; CALL iom_put( "mldr10_1", hmlp - risfdep) ! mixed layer thickness 125 ELSE ; CALL iom_put( "mldr10_1", hmlp ) ! mixed layer depth 126 END IF 112 IF( .NOT.l_offline .AND. iom_use("mldr10_1") ) THEN 113 IF( ln_isfcav ) THEN ; CALL iom_put( "mldr10_1", hmlp - risfdep) ! mixed layer thickness 114 ELSE ; CALL iom_put( "mldr10_1", hmlp ) ! mixed layer depth 127 115 END IF 128 IF( iom_use("mldkz5") ) THEN129 IF( ln_isfcav ) THEN ; CALL iom_put( "mldkz5" , hmld - risfdep ) ! turbocline thickness130 ELSE ; CALL iom_put( "mldkz5" , hmld ) ! turbocline depth131 END IF132 ENDIF133 116 ENDIF 134 117 ! … … 137 120 END SUBROUTINE zdf_mxl 138 121 122 123 SUBROUTINE zdf_mxl_turb( kt, Kmm ) 124 !!---------------------------------------------------------------------- 125 !! *** ROUTINE zdf_mxl_turb *** 126 !! 127 !! ** Purpose : Compute the turbocline depth. 128 !! 129 !! ** Method : The turbocline depth is the depth at which the vertical 130 !! eddy diffusivity coefficient (resulting from the vertical physics 131 !! alone, not the isopycnal part, see trazdf.F) fall below a given 132 !! value defined locally (avt_c here taken equal to 5 cm/s2 by default) 133 !! 134 !! ** Action : hmld 135 !!---------------------------------------------------------------------- 136 INTEGER, INTENT(in) :: kt ! ocean time-step index 137 INTEGER, INTENT(in) :: Kmm ! ocean time level index 138 ! 139 INTEGER :: ji, jj, jk ! dummy loop indices 140 INTEGER :: iik ! local integer 141 INTEGER, DIMENSION(A2D(nn_hls)) :: imld ! 2D workspace 142 !!---------------------------------------------------------------------- 143 ! 144 ! w-level of the turbocline and mixing layer (iom_use) 145 imld(:,:) = mbkt(A2D(nn_hls)) + 1 ! Initialization to the number of w ocean point 146 DO_3DS( 1, 1, 1, 1, jpkm1, nlb10, -1 ) ! from the bottom to nlb10 147 IF( avt (ji,jj,jk) < avt_c * wmask(ji,jj,jk) ) imld(ji,jj) = jk ! Turbocline 148 END_3D 149 ! depth of the mixing layer 150 DO_2D_OVR( 1, 1, 1, 1 ) 151 iik = imld(ji,jj) 152 hmld (ji,jj) = gdepw(ji,jj,iik ,Kmm) * ssmask(ji,jj) ! Turbocline depth 153 END_2D 154 ! 155 IF( .NOT.l_offline .AND. iom_use("mldkz5") ) THEN 156 IF( ln_isfcav ) THEN ; CALL iom_put( "mldkz5" , hmld - risfdep ) ! turbocline thickness 157 ELSE ; CALL iom_put( "mldkz5" , hmld ) ! turbocline depth 158 END IF 159 ENDIF 160 ! 161 END SUBROUTINE zdf_mxl_turb 139 162 !!====================================================================== 140 163 END MODULE zdfmxl -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfosm.F90
r14433 r14958 34 34 !! 16/05/2019 (19) Fox-Kemper parametrization of restratification through mixed layer eddies added to revised code. 35 35 !! 23/05/19 (20) Old code where key_osmldpth1` is *not* set removed, together with the key key_osmldpth1 36 !! 4.2 ! 2021-05 (S. Mueller) Efficiency improvements, source-code clarity enhancements, and adaptation to tiling 36 37 !!---------------------------------------------------------------------- 37 38 38 39 !!---------------------------------------------------------------------- 39 !! 'ln_zdfosm' 40 !! 'ln_zdfosm' OSMOSIS scheme 40 41 !!---------------------------------------------------------------------- 41 !! zdf_osm : update momentum and tracer Kz from osm scheme 42 !! zdf_osm_init : initialization, namelist read, and parameters control 43 !! osm_rst : read (or initialize) and write osmosis restart fields 44 !! tra_osm : compute and add to the T & S trend the non-local flux 45 !! trc_osm : compute and add to the passive tracer trend the non-local flux (TBD) 46 !! dyn_osm : compute and add to u & v trensd the non-local flux 47 !! 48 !! Subroutines in revised code. 42 !! zdf_osm : update momentum and tracer Kz from osm scheme 43 !! zdf_osm_vertical_average : compute vertical averages over boundary layers 44 !! zdf_osm_velocity_rotation : rotate velocity components 45 !! zdf_osm_velocity_rotation_2d : rotation of 2d fields 46 !! zdf_osm_velocity_rotation_3d : rotation of 3d fields 47 !! zdf_osm_osbl_state : determine the state of the OSBL 48 !! zdf_osm_external_gradients : calculate gradients below the OSBL 49 !! zdf_osm_calculate_dhdt : calculate rate of change of hbl 50 !! zdf_osm_timestep_hbl : hbl timestep 51 !! zdf_osm_pycnocline_thickness : calculate thickness of pycnocline 52 !! zdf_osm_diffusivity_viscosity : compute eddy diffusivity and viscosity profiles 53 !! zdf_osm_fgr_terms : compute flux-gradient relationship terms 54 !! zdf_osm_pycnocline_buoyancy_profiles : calculate pycnocline buoyancy profiles 55 !! zdf_osm_zmld_horizontal_gradients : calculate horizontal buoyancy gradients for use with Fox-Kemper parametrization 56 !! zdf_osm_osbl_state_fk : determine state of OSBL and MLE layers 57 !! zdf_osm_mle_parameters : timestep MLE depth and calculate MLE fluxes 58 !! zdf_osm_init : initialization, namelist read, and parameters control 59 !! zdf_osm_alloc : memory allocation 60 !! osm_rst : read (or initialize) and write osmosis restart fields 61 !! tra_osm : compute and add to the T & S trend the non-local flux 62 !! trc_osm : compute and add to the passive tracer trend the non-local flux (TBD) 63 !! dyn_osm : compute and add to u & v trensd the non-local flux 64 !! zdf_osm_iomput : iom_put wrapper that accepts arrays without halo 65 !! zdf_osm_iomput_2d : iom_put wrapper for 2D fields 66 !! zdf_osm_iomput_3d : iom_put wrapper for 3D fields 49 67 !!---------------------------------------------------------------------- 50 USE oce ! ocean dynamics and active tracers51 ! uses ww from previous time step (which is now wb) to calculate hbl52 USE dom_oce ! ocean space and time domain53 USE zdf_oce ! ocean vertical physics54 USE sbc_oce ! surface boundary condition: ocean55 USE sbcwave ! surface wave parameters56 USE phycst ! physical constants57 USE eosbn2 ! equation of state58 USE traqsr ! details of solar radiation absorption59 USE zdfd dm ! double diffusion mixing (avs array)60 USE iom ! I/O library61 USE lib_mpp ! MPPlibrary62 USE trd_oce ! ocean trends definition63 USE trd tra ! tracers trends64 !65 USE in_out_manager ! I/O manager66 USE lbclnk ! ocean lateral boundary conditions (or mpp link)67 USE prtctl ! Print control68 USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)68 USE oce ! Ocean dynamics and active tracers 69 ! ! Uses ww from previous time step (which is now wb) to calculate hbl 70 USE dom_oce ! Ocean space and time domain 71 USE zdf_oce ! Ocean vertical physics 72 USE sbc_oce ! Surface boundary condition: ocean 73 USE sbcwave ! Surface wave parameters 74 USE phycst ! Physical constants 75 USE eosbn2 ! Equation of state 76 USE traqsr ! Details of solar radiation absorption 77 USE zdfdrg, ONLY : rCdU_bot ! Bottom friction velocity 78 USE zdfddm ! Double diffusion mixing (avs array) 79 USE iom ! I/O library 80 USE lib_mpp ! MPP library 81 USE trd_oce ! Ocean trends definition 82 USE trdtra ! Tracers trends 83 USE in_out_manager ! I/O manager 84 USE lbclnk ! Ocean lateral boundary conditions (or mpp link) 85 USE prtctl ! Print control 86 USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 69 87 70 88 IMPLICIT NONE 71 89 PRIVATE 72 90 73 PUBLIC zdf_osm ! routine called by step.F90 74 PUBLIC zdf_osm_init ! routine called by nemogcm.F90 75 PUBLIC osm_rst ! routine called by step.F90 76 PUBLIC tra_osm ! routine called by step.F90 77 PUBLIC trc_osm ! routine called by trcstp.F90 78 PUBLIC dyn_osm ! routine called by step.F90 79 80 PUBLIC ln_osm_mle ! logical needed by tra_mle_init in tramle.F90 81 82 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamu !: non-local u-momentum flux 83 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamv !: non-local v-momentum flux 84 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamt !: non-local temperature flux (gamma/<ws>o) 85 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghams !: non-local salinity flux (gamma/<ws>o) 86 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: etmean !: averaging operator for avt 87 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hbl !: boundary layer depth 88 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dh ! depth of pycnocline 89 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hml ! ML depth 90 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dstokes !: penetration depth of the Stokes drift. 91 92 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: r1_ft ! inverse of the modified Coriolis parameter at t-pts 93 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hmle ! Depth of layer affexted by mixed layer eddies in Fox-Kemper parametrization 94 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdx_mle ! zonal buoyancy gradient in ML 95 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdy_mle ! meridional buoyancy gradient in ML 96 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: mld_prof ! level of base of MLE layer. 97 98 ! !!** Namelist namzdf_osm ** 99 LOGICAL :: ln_use_osm_la ! Use namelist rn_osm_la 100 101 LOGICAL :: ln_osm_mle !: flag to activate the Mixed Layer Eddy (MLE) parameterisation 102 103 REAL(wp) :: rn_osm_la ! Turbulent Langmuir number 104 REAL(wp) :: rn_osm_dstokes ! Depth scale of Stokes drift 105 REAL(wp) :: rn_zdfosm_adjust_sd = 1.0 ! factor to reduce Stokes drift by 106 REAL(wp) :: rn_osm_hblfrac = 0.1! for nn_osm_wave = 3/4 specify fraction in top of hbl 107 LOGICAL :: ln_zdfosm_ice_shelter ! flag to activate ice sheltering 108 REAL(wp) :: rn_osm_hbl0 = 10._wp ! Initial value of hbl for 1D runs 109 INTEGER :: nn_ave ! = 0/1 flag for horizontal average on avt 110 INTEGER :: nn_osm_wave = 0 ! = 0/1/2 flag for getting stokes drift from La# / PM wind-waves/Inputs into sbcwave 111 INTEGER :: nn_osm_SD_reduce ! = 0/1/2 flag for getting effective stokes drift from surface value 112 LOGICAL :: ln_dia_osm ! Use namelist rn_osm_la 113 114 115 LOGICAL :: ln_kpprimix = .true. ! Shear instability mixing 116 REAL(wp) :: rn_riinfty = 0.7 ! local Richardson Number limit for shear instability 117 REAL(wp) :: rn_difri = 0.005 ! maximum shear mixing at Rig = 0 (m2/s) 118 LOGICAL :: ln_convmix = .true. ! Convective instability mixing 119 REAL(wp) :: rn_difconv = 1._wp ! diffusivity when unstable below BL (m2/s) 120 121 ! OSMOSIS mixed layer eddy parametrization constants 122 INTEGER :: nn_osm_mle ! = 0/1 flag for horizontal average on avt 123 REAL(wp) :: rn_osm_mle_ce ! MLE coefficient 124 ! ! parameters used in nn_osm_mle = 0 case 125 REAL(wp) :: rn_osm_mle_lf ! typical scale of mixed layer front 126 REAL(wp) :: rn_osm_mle_time ! time scale for mixing momentum across the mixed layer 127 ! ! parameters used in nn_osm_mle = 1 case 128 REAL(wp) :: rn_osm_mle_lat ! reference latitude for a 5 km scale of ML front 129 LOGICAL :: ln_osm_hmle_limit ! If true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 130 REAL(wp) :: rn_osm_hmle_limit ! If ln_osm_hmle_limit true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 131 REAL(wp) :: rn_osm_mle_rho_c ! Density criterion for definition of MLD used by FK 132 REAL(wp) :: r5_21 = 5.e0 / 21.e0 ! factor used in mle streamfunction computation 133 REAL(wp) :: rb_c ! ML buoyancy criteria = g rho_c /rho0 where rho_c is defined in zdfmld 134 REAL(wp) :: rc_f ! MLE coefficient (= rn_ce / (5 km * fo) ) in nn_osm_mle=1 case 135 REAL(wp) :: rn_osm_mle_thresh ! Threshold buoyancy for deepening of MLE layer below OSBL base. 136 REAL(wp) :: rn_osm_bl_thresh ! Threshold buoyancy for deepening of OSBL base. 137 REAL(wp) :: rn_osm_mle_tau ! Adjustment timescale for MLE. 138 139 140 ! !!! ** General constants ** 141 REAL(wp) :: epsln = 1.0e-20_wp ! a small positive number to ensure no div by zero 142 REAL(wp) :: depth_tol = 1.0e-6_wp ! a small-ish positive number to give a hbl slightly shallower than gdepw 143 REAL(wp) :: pthird = 1._wp/3._wp ! 1/3 144 REAL(wp) :: p2third = 2._wp/3._wp ! 2/3 145 146 INTEGER :: idebug = 236 147 INTEGER :: jdebug = 228 91 ! Public subroutines 92 PUBLIC zdf_osm ! Routine called by step.F90 93 PUBLIC zdf_osm_init ! Routine called by nemogcm.F90 94 PUBLIC osm_rst ! Routine called by step.F90 95 PUBLIC tra_osm ! Routine called by step.F90 96 PUBLIC trc_osm ! Routine called by trcstp.F90 97 PUBLIC dyn_osm ! Routine called by step.F90 98 99 ! Public variables 100 LOGICAL, PUBLIC :: ln_osm_mle !: Flag to activate the Mixed Layer Eddy (MLE) 101 ! ! parameterisation, needed by tra_mle_init in 102 ! ! tramle.F90 103 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamu !: Non-local u-momentum flux 104 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamv !: Non-local v-momentum flux 105 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghamt !: Non-local temperature flux (gamma/<ws>o) 106 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: ghams !: Non-local salinity flux (gamma/<ws>o) 107 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hbl !: Boundary layer depth 108 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hml !: ML depth 109 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: hmle !: Depth of layer affexted by mixed layer eddies in Fox-Kemper parametrization 110 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdx_mle !: Zonal buoyancy gradient in ML 111 REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: dbdy_mle !: Meridional buoyancy gradient in ML 112 INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: mld_prof !: Level of base of MLE layer 113 114 INTERFACE zdf_osm_velocity_rotation 115 !!--------------------------------------------------------------------- 116 !! *** INTERFACE zdf_velocity_rotation *** 117 !!--------------------------------------------------------------------- 118 MODULE PROCEDURE zdf_osm_velocity_rotation_2d 119 MODULE PROCEDURE zdf_osm_velocity_rotation_3d 120 END INTERFACE 121 ! 122 INTERFACE zdf_osm_iomput 123 !!--------------------------------------------------------------------- 124 !! *** INTERFACE zdf_osm_iomput *** 125 !!--------------------------------------------------------------------- 126 MODULE PROCEDURE zdf_osm_iomput_2d 127 MODULE PROCEDURE zdf_osm_iomput_3d 128 END INTERFACE 129 130 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: etmean ! Averaging operator for avt 131 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: dh ! Depth of pycnocline 132 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: r1_ft ! Inverse of the modified Coriolis parameter at t-pts 133 ! Layer indices 134 INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nbld ! Level of boundary layer base 135 INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) :: nmld ! Level of mixed-layer depth (pycnocline top) 136 ! Layer type 137 INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) :: n_ddh ! Type of shear layer 138 ! ! n_ddh=0: active shear layer 139 ! ! n_ddh=1: shear layer not active 140 ! ! n_ddh=2: shear production low 141 ! Layer flags 142 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_conv ! Unstable/stable bl 143 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_shear ! Shear layers 144 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_coup ! Coupling to bottom 145 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_pyc ! OSBL pycnocline present 146 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_flux ! Surface flux extends below OSBL into MLE layer 147 LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:,:) :: l_mle ! MLE layer increases in hickness. 148 ! Scales 149 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swth0 ! Surface heat flux (Kinematic) 150 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sws0 ! Surface freshwater flux 151 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swb0 ! Surface buoyancy flux 152 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: suw0 ! Surface u-momentum flux 153 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sustar ! Friction velocity 154 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: scos_wind ! Cos angle of surface stress 155 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: ssin_wind ! Sin angle of surface stress 156 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swthav ! Heat flux - bl average 157 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swsav ! Freshwater flux - bl average 158 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swbav ! Buoyancy flux - bl average 159 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sustke ! Surface Stokes drift 160 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: dstokes ! Penetration depth of the Stokes drift 161 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swstrl ! Langmuir velocity scale 162 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: swstrc ! Convective velocity scale 163 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: sla ! Trubulent Langmuir number 164 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: svstr ! Velocity scale that tends to sustar for large Langmuir number 165 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: shol ! Stability parameter for boundary layer 166 ! Layer averages: BL 167 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_t_bl ! Temperature average 168 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_s_bl ! Salinity average 169 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_u_bl ! Velocity average (u) 170 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_v_bl ! Velocity average (v) 171 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_b_bl ! Buoyancy average 172 ! Difference between layer average and parameter at the base of the layer: BL 173 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_dt_bl ! Temperature difference 174 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_ds_bl ! Salinity difference 175 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_du_bl ! Velocity difference (u) 176 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_dv_bl ! Velocity difference (v) 177 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_db_bl ! Buoyancy difference 178 ! Layer averages: ML 179 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_t_ml ! Temperature average 180 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_s_ml ! Salinity average 181 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_u_ml ! Velocity average (u) 182 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_v_ml ! Velocity average (v) 183 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_b_ml ! Buoyancy average 184 ! Difference between layer average and parameter at the base of the layer: ML 185 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_dt_ml ! Temperature difference 186 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_ds_ml ! Salinity difference 187 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_du_ml ! Velocity difference (u) 188 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_dv_ml ! Velocity difference (v) 189 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_db_ml ! Buoyancy difference 190 ! Layer averages: MLE 191 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_t_mle ! Temperature average 192 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_s_mle ! Salinity average 193 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_u_mle ! Velocity average (u) 194 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_v_mle ! Velocity average (v) 195 REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: av_b_mle ! Buoyancy average 196 ! Diagnostic output 197 REAL(WP), ALLOCATABLE, SAVE, DIMENSION(:,:) :: osmdia2d ! Auxiliary array for diagnostic output 198 REAL(WP), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: osmdia3d ! Auxiliary array for diagnostic output 199 LOGICAL :: ln_dia_pyc_scl = .FALSE. ! Output of pycnocline scalar-gradient profiles 200 LOGICAL :: ln_dia_pyc_shr = .FALSE. ! Output of pycnocline velocity-shear profiles 201 202 ! !!* namelist namzdf_osm * 203 LOGICAL :: ln_use_osm_la ! Use namelist rn_osm_la 204 REAL(wp) :: rn_osm_la ! Turbulent Langmuir number 205 REAL(wp) :: rn_osm_dstokes ! Depth scale of Stokes drift 206 REAL(wp) :: rn_zdfosm_adjust_sd = 1.0_wp ! Factor to reduce Stokes drift by 207 REAL(wp) :: rn_osm_hblfrac = 0.1_wp ! For nn_osm_wave = 3/4 specify fraction in top of hbl 208 LOGICAL :: ln_zdfosm_ice_shelter ! Flag to activate ice sheltering 209 REAL(wp) :: rn_osm_hbl0 = 10.0_wp ! Initial value of hbl for 1D runs 210 INTEGER :: nn_ave ! = 0/1 flag for horizontal average on avt 211 INTEGER :: nn_osm_wave = 0 ! = 0/1/2 flag for getting stokes drift from La# / PM wind-waves/Inputs into 212 ! ! sbcwave 213 INTEGER :: nn_osm_SD_reduce ! = 0/1/2 flag for getting effective stokes drift from surface value 214 LOGICAL :: ln_dia_osm ! Use namelist rn_osm_la 215 LOGICAL :: ln_kpprimix = .TRUE. ! Shear instability mixing 216 REAL(wp) :: rn_riinfty = 0.7_wp ! Local Richardson Number limit for shear instability 217 REAL(wp) :: rn_difri = 0.005_wp ! Maximum shear mixing at Rig = 0 (m2/s) 218 LOGICAL :: ln_convmix = .TRUE. ! Convective instability mixing 219 REAL(wp) :: rn_difconv = 1.0_wp ! Diffusivity when unstable below BL (m2/s) 220 ! OSMOSIS mixed layer eddy parametrization constants 221 INTEGER :: nn_osm_mle ! = 0/1 flag for horizontal average on avt 222 REAL(wp) :: rn_osm_mle_ce ! MLE coefficient 223 ! Parameters used in nn_osm_mle = 0 case 224 REAL(wp) :: rn_osm_mle_lf ! Typical scale of mixed layer front 225 REAL(wp) :: rn_osm_mle_time ! Time scale for mixing momentum across the mixed layer 226 ! Parameters used in nn_osm_mle = 1 case 227 REAL(wp) :: rn_osm_mle_lat ! Reference latitude for a 5 km scale of ML front 228 LOGICAL :: ln_osm_hmle_limit ! If true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 229 REAL(wp) :: rn_osm_hmle_limit ! If ln_osm_hmle_limit true arbitrarily restrict hmle to rn_osm_hmle_limit*zmld 230 REAL(wp) :: rn_osm_mle_rho_c ! Density criterion for definition of MLD used by FK 231 REAL(wp) :: rb_c ! ML buoyancy criteria = g rho_c /rho0 where rho_c is defined in zdfmld 232 REAL(wp) :: rc_f ! MLE coefficient (= rn_ce / (5 km * fo) ) in nn_osm_mle=1 case 233 REAL(wp) :: rn_osm_mle_thresh ! Threshold buoyancy for deepening of MLE layer below OSBL base 234 REAL(wp) :: rn_osm_bl_thresh ! Threshold buoyancy for deepening of OSBL base 235 REAL(wp) :: rn_osm_mle_tau ! Adjustment timescale for MLE 236 237 ! General constants 238 REAL(wp) :: epsln = 1.0e-20_wp ! A small positive number to ensure no div by zero 239 REAL(wp) :: depth_tol = 1.0e-6_wp ! A small-ish positive number to give a hbl slightly shallower than gdepw 240 REAL(wp) :: pthird = 1.0_wp/3.0_wp ! 1/3 241 REAL(wp) :: p2third = 2.0_wp/3.0_wp ! 2/3 148 242 149 243 !! * Substitutions … … 161 255 !! *** FUNCTION zdf_osm_alloc *** 162 256 !!---------------------------------------------------------------------- 163 ALLOCATE( ghamu(jpi,jpj,jpk), ghamv(jpi,jpj,jpk), ghamt(jpi,jpj,jpk),ghams(jpi,jpj,jpk), & 164 & hbl(jpi,jpj), dh(jpi,jpj), hml(jpi,jpj), dstokes(jpi, jpj), & 165 & etmean(jpi,jpj,jpk), STAT= zdf_osm_alloc ) 166 167 ALLOCATE( hmle(jpi,jpj), r1_ft(jpi,jpj), dbdx_mle(jpi,jpj), dbdy_mle(jpi,jpj), & 168 & mld_prof(jpi,jpj), STAT= zdf_osm_alloc ) 169 170 CALL mpp_sum ( 'zdfosm', zdf_osm_alloc ) 171 IF( zdf_osm_alloc /= 0 ) CALL ctl_warn('zdf_osm_alloc: failed to allocate zdf_osm arrays') 172 257 INTEGER :: ierr 258 !!---------------------------------------------------------------------- 259 ! 260 zdf_osm_alloc = 0 261 ! 262 ALLOCATE( ghamu(jpi,jpj,jpk), ghamv(jpi,jpj,jpk), ghamt(jpi,jpj,jpk), ghams(jpi,jpj,jpk), hbl(jpi,jpj), hml(jpi,jpj), & 263 & hmle(jpi,jpj), dbdx_mle(jpi,jpj), dbdy_mle(jpi,jpj), mld_prof(jpi,jpj), STAT=ierr ) 264 zdf_osm_alloc = zdf_osm_alloc + ierr 265 ! 266 ALLOCATE( etmean(A2D(nn_hls-1),jpk), dh(jpi,jpj), r1_ft(A2D(nn_hls-1)), STAT=ierr ) 267 zdf_osm_alloc = zdf_osm_alloc + ierr 268 ! 269 ALLOCATE( nbld(jpi,jpj), nmld(A2D(nn_hls-1)), STAT=ierr ) 270 zdf_osm_alloc = zdf_osm_alloc + ierr 271 ! 272 ALLOCATE( n_ddh(A2D(nn_hls-1)), STAT=ierr ) 273 zdf_osm_alloc = zdf_osm_alloc + ierr 274 ! 275 ALLOCATE( l_conv(A2D(nn_hls-1)), l_shear(A2D(nn_hls-1)), l_coup(A2D(nn_hls-1)), l_pyc(A2D(nn_hls-1)), & 276 & l_flux(A2D(nn_hls-1)), l_mle(A2D(nn_hls-1)), STAT=ierr ) 277 zdf_osm_alloc = zdf_osm_alloc + ierr 278 ! 279 ALLOCATE( swth0(A2D(nn_hls-1)), sws0(A2D(nn_hls-1)), swb0(A2D(nn_hls-1)), suw0(A2D(nn_hls-1)), & 280 & sustar(A2D(nn_hls-1)), scos_wind(A2D(nn_hls-1)), ssin_wind(A2D(nn_hls-1)), swthav(A2D(nn_hls-1)), & 281 & swsav(A2D(nn_hls-1)), swbav(A2D(nn_hls-1)), sustke(A2D(nn_hls-1)), dstokes(A2D(nn_hls-1)), & 282 & swstrl(A2D(nn_hls-1)), swstrc(A2D(nn_hls-1)), sla(A2D(nn_hls-1)), svstr(A2D(nn_hls-1)), & 283 & shol(A2D(nn_hls-1)), STAT=ierr ) 284 zdf_osm_alloc = zdf_osm_alloc + ierr 285 ! 286 ALLOCATE( av_t_bl(jpi,jpj), av_s_bl(jpi,jpj), av_u_bl(jpi,jpj), av_v_bl(jpi,jpj), & 287 & av_b_bl(jpi,jpj), STAT=ierr) 288 zdf_osm_alloc = zdf_osm_alloc + ierr 289 ! 290 ALLOCATE( av_dt_bl(jpi,jpj), av_ds_bl(jpi,jpj), av_du_bl(jpi,jpj), av_dv_bl(jpi,jpj), & 291 & av_db_bl(jpi,jpj), STAT=ierr) 292 zdf_osm_alloc = zdf_osm_alloc + ierr 293 ! 294 ALLOCATE( av_t_ml(jpi,jpj), av_s_ml(jpi,jpj), av_u_ml(jpi,jpj), av_v_ml(jpi,jpj), & 295 & av_b_ml(jpi,jpj), STAT=ierr) 296 zdf_osm_alloc = zdf_osm_alloc + ierr 297 ! 298 ALLOCATE( av_dt_ml(jpi,jpj), av_ds_ml(jpi,jpj), av_du_ml(jpi,jpj), av_dv_ml(jpi,jpj), & 299 & av_db_ml(jpi,jpj), STAT=ierr) 300 zdf_osm_alloc = zdf_osm_alloc + ierr 301 ! 302 ALLOCATE( av_t_mle(jpi,jpj), av_s_mle(jpi,jpj), av_u_mle(jpi,jpj), av_v_mle(jpi,jpj), & 303 & av_b_mle(jpi,jpj), STAT=ierr) 304 zdf_osm_alloc = zdf_osm_alloc + ierr 305 ! 306 IF ( ln_dia_osm ) THEN 307 ALLOCATE( osmdia2d(jpi,jpj), osmdia3d(jpi,jpj,jpk), STAT=ierr ) 308 zdf_osm_alloc = zdf_osm_alloc + ierr 309 END IF 310 ! 311 CALL mpp_sum ( 'zdfosm', zdf_osm_alloc ) 312 IF( zdf_osm_alloc /= 0 ) CALL ctl_warn( 'zdf_osm_alloc: failed to allocate zdf_osm arrays' ) 313 ! 173 314 END FUNCTION zdf_osm_alloc 174 315 175 176 SUBROUTINE zdf_osm( kt, Kbb, Kmm, Krhs, p_avm,p_avt )316 SUBROUTINE zdf_osm( kt, Kbb, Kmm, Krhs, p_avm, & 317 & p_avt ) 177 318 !!---------------------------------------------------------------------- 178 319 !! *** ROUTINE zdf_osm *** … … 209 350 !! the equation number. (LMD94, here after) 210 351 !!---------------------------------------------------------------------- 211 INTEGER , INTENT(in ) :: kt ! ocean time step 212 INTEGER , INTENT(in ) :: Kbb, Kmm, Krhs ! ocean time level indices 213 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points) 214 !! 215 INTEGER :: ji, jj, jk ! dummy loop indices 216 217 INTEGER :: jl ! dummy loop indices 218 219 INTEGER :: ikbot, jkmax, jkm1, jkp2 ! 220 221 REAL(wp) :: ztx, zty, zflageos, zstabl, zbuofdep,zucube ! 222 REAL(wp) :: zbeta, zthermal ! 223 REAL(wp) :: zehat, zeta, zhrib, zsig, zscale, zwst, zws, zwm ! Velocity scales 224 REAL(wp) :: zwsun, zwmun, zcons, zconm, zwcons, zwconm ! 225 REAL(wp) :: zsr, zbw, ze, zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zcomp , zrhd,zrhdr,zbvzed ! In situ density 226 INTEGER :: jm ! dummy loop indices 227 REAL(wp) :: zr1, zr2, zr3, zr4, zrhop ! Compression terms 228 REAL(wp) :: zflag, zrn2, zdep21, zdep32, zdep43 229 REAL(wp) :: zesh2, zri, zfri ! Interior richardson mixing 230 REAL(wp) :: zdelta, zdelta2, zdzup, zdzdn, zdzh, zvath, zgat1, zdat1, zkm1m, zkm1t 231 REAL(wp) :: zt,zs,zu,zv,zrh ! variables used in constructing averages 232 ! Scales 233 REAL(wp), DIMENSION(jpi,jpj) :: zrad0 ! Surface solar temperature flux (deg m/s) 234 REAL(wp), DIMENSION(jpi,jpj) :: zradh ! Radiative flux at bl base (Buoyancy units) 235 REAL(wp), DIMENSION(jpi,jpj) :: zradav ! Radiative flux, bl average (Buoyancy Units) 236 REAL(wp), DIMENSION(jpi,jpj) :: zustar ! friction velocity 237 REAL(wp), DIMENSION(jpi,jpj) :: zwstrl ! Langmuir velocity scale 238 REAL(wp), DIMENSION(jpi,jpj) :: zvstr ! Velocity scale that ends to zustar for large Langmuir number. 239 REAL(wp), DIMENSION(jpi,jpj) :: zwstrc ! Convective velocity scale 240 REAL(wp), DIMENSION(jpi,jpj) :: zuw0 ! Surface u-momentum flux 241 REAL(wp), DIMENSION(jpi,jpj) :: zvw0 ! Surface v-momentum flux 242 REAL(wp), DIMENSION(jpi,jpj) :: zwth0 ! Surface heat flux (Kinematic) 243 REAL(wp), DIMENSION(jpi,jpj) :: zws0 ! Surface freshwater flux 244 REAL(wp), DIMENSION(jpi,jpj) :: zwb0 ! Surface buoyancy flux 245 REAL(wp), DIMENSION(jpi,jpj) :: zwthav ! Heat flux - bl average 246 REAL(wp), DIMENSION(jpi,jpj) :: zwsav ! freshwater flux - bl average 247 REAL(wp), DIMENSION(jpi,jpj) :: zwbav ! Buoyancy flux - bl average 248 REAL(wp), DIMENSION(jpi,jpj) :: zwb_ent ! Buoyancy entrainment flux 249 REAL(wp), DIMENSION(jpi,jpj) :: zwb_min 250 251 252 REAL(wp), DIMENSION(jpi,jpj) :: zwb_fk_b ! MLE buoyancy flux averaged over OSBL 253 REAL(wp), DIMENSION(jpi,jpj) :: zwb_fk ! max MLE buoyancy flux 254 REAL(wp), DIMENSION(jpi,jpj) :: zdiff_mle ! extra MLE vertical diff 255 REAL(wp), DIMENSION(jpi,jpj) :: zvel_mle ! velocity scale for dhdt with stable ML and FK 256 257 REAL(wp), DIMENSION(jpi,jpj) :: zustke ! Surface Stokes drift 258 REAL(wp), DIMENSION(jpi,jpj) :: zla ! Trubulent Langmuir number 259 REAL(wp), DIMENSION(jpi,jpj) :: zcos_wind ! Cos angle of surface stress 260 REAL(wp), DIMENSION(jpi,jpj) :: zsin_wind ! Sin angle of surface stress 261 REAL(wp), DIMENSION(jpi,jpj) :: zhol ! Stability parameter for boundary layer 262 LOGICAL, DIMENSION(jpi,jpj) :: lconv ! unstable/stable bl 263 LOGICAL, DIMENSION(jpi,jpj) :: lshear ! Shear layers 264 LOGICAL, DIMENSION(jpi,jpj) :: lpyc ! OSBL pycnocline present 265 LOGICAL, DIMENSION(jpi,jpj) :: lflux ! surface flux extends below OSBL into MLE layer. 266 LOGICAL, DIMENSION(jpi,jpj) :: lmle ! MLE layer increases in hickness. 267 268 ! mixed-layer variables 269 270 INTEGER, DIMENSION(jpi,jpj) :: ibld ! level of boundary layer base 271 INTEGER, DIMENSION(jpi,jpj) :: imld ! level of mixed-layer depth (pycnocline top) 272 INTEGER, DIMENSION(jpi,jpj) :: jp_ext, jp_ext_mle ! offset for external level 273 INTEGER, DIMENSION(jpi, jpj) :: j_ddh ! Type of shear layer 274 275 REAL(wp) :: ztgrad,zsgrad,zbgrad ! Temporary variables used to calculate pycnocline gradients 276 REAL(wp) :: zugrad,zvgrad ! temporary variables for calculating pycnocline shear 277 278 REAL(wp), DIMENSION(jpi,jpj) :: zhbl ! bl depth - grid 279 REAL(wp), DIMENSION(jpi,jpj) :: zhml ! ml depth - grid 280 281 REAL(wp), DIMENSION(jpi,jpj) :: zhmle ! MLE depth - grid 282 REAL(wp), DIMENSION(jpi,jpj) :: zmld ! ML depth on grid 283 284 REAL(wp), DIMENSION(jpi,jpj) :: zdh ! pycnocline depth - grid 285 REAL(wp), DIMENSION(jpi,jpj) :: zdhdt ! BL depth tendency 286 REAL(wp), DIMENSION(jpi,jpj) :: zddhdt ! correction to dhdt due to internal structure. 287 REAL(wp), DIMENSION(jpi,jpj) :: zdtdz_bl_ext,zdsdz_bl_ext,zdbdz_bl_ext ! external temperature/salinity and buoyancy gradients 288 REAL(wp), DIMENSION(jpi,jpj) :: zdtdz_mle_ext,zdsdz_mle_ext,zdbdz_mle_ext ! external temperature/salinity and buoyancy gradients 289 REAL(wp), DIMENSION(jpi,jpj) :: zdtdx, zdtdy, zdsdx, zdsdy ! horizontal gradients for Fox-Kemper parametrization. 290 291 REAL(wp), DIMENSION(jpi,jpj) :: zt_bl,zs_bl,zu_bl,zv_bl,zb_bl ! averages over the depth of the blayer 292 REAL(wp), DIMENSION(jpi,jpj) :: zt_ml,zs_ml,zu_ml,zv_ml,zb_ml ! averages over the depth of the mixed layer 293 REAL(wp), DIMENSION(jpi,jpj) :: zt_mle,zs_mle,zu_mle,zv_mle,zb_mle ! averages over the depth of the MLE layer 294 REAL(wp), DIMENSION(jpi,jpj) :: zdt_bl,zds_bl,zdu_bl,zdv_bl,zdb_bl ! difference between blayer average and parameter at base of blayer 295 REAL(wp), DIMENSION(jpi,jpj) :: zdt_ml,zds_ml,zdu_ml,zdv_ml,zdb_ml ! difference between mixed layer average and parameter at base of blayer 296 REAL(wp), DIMENSION(jpi,jpj) :: zdt_mle,zds_mle,zdu_mle,zdv_mle,zdb_mle ! difference between MLE layer average and parameter at base of blayer 297 ! REAL(wp), DIMENSION(jpi,jpj) :: zwth_ent,zws_ent ! heat and salinity fluxes at the top of the pycnocline 298 REAL(wp) :: zwth_ent,zws_ent ! heat and salinity fluxes at the top of the pycnocline 299 REAL(wp) :: zuw_bse,zvw_bse ! momentum fluxes at the top of the pycnocline 300 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdtdz_pyc ! parametrized gradient of temperature in pycnocline 301 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdsdz_pyc ! parametrised gradient of salinity in pycnocline 302 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdbdz_pyc ! parametrised gradient of buoyancy in the pycnocline 303 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdudz_pyc ! u-shear across the pycnocline 304 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdvdz_pyc ! v-shear across the pycnocline 305 REAL(wp), DIMENSION(jpi,jpj) :: zdbds_mle ! Magnitude of horizontal buoyancy gradient. 306 ! Flux-gradient relationship variables 307 REAL(wp), DIMENSION(jpi, jpj) :: zshear, zri_i ! Shear production and interfacial richardon number. 308 309 REAL(wp) :: zl_c,zl_l,zl_eps ! Used to calculate turbulence length scale. 310 311 REAL(wp) :: za_cubic, zb_cubic, zc_cubic, zd_cubic ! coefficients in cubic polynomial specifying diffusivity in pycnocline. 312 REAL(wp), DIMENSION(jpi,jpj) :: zsc_wth_1,zsc_ws_1 ! Temporary scales used to calculate scalar non-gradient terms. 313 REAL(wp), DIMENSION(jpi,jpj) :: zsc_wth_pyc, zsc_ws_pyc ! Scales for pycnocline transport term/ 314 REAL(wp), DIMENSION(jpi,jpj) :: zsc_uw_1,zsc_uw_2,zsc_vw_1,zsc_vw_2 ! Temporary scales for non-gradient momentum flux terms. 315 REAL(wp), DIMENSION(jpi,jpj) :: zhbl_t ! holds boundary layer depth updated by full timestep 316 317 ! For calculating Ri#-dependent mixing 318 REAL(wp), DIMENSION(jpi,jpj,jpk) :: z3du ! u-shear^2 319 REAL(wp), DIMENSION(jpi,jpj,jpk) :: z3dv ! v-shear^2 320 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zrimix ! spatial form of ri#-induced diffusion 321 322 ! Temporary variables 323 INTEGER :: inhml 324 REAL(wp) :: znd,znd_d,zznd_ml,zznd_pyc,zznd_d ! temporary non-dimensional depths used in various routines 325 REAL(wp) :: ztemp, zari, zpert, zzdhdt, zdb ! temporary variables 326 REAL(wp) :: zthick, zz0, zz1 ! temporary variables 327 REAL(wp) :: zvel_max, zhbl_s ! temporary variables 328 REAL(wp) :: zfac, ztmp ! temporary variable 329 REAL(wp) :: zus_x, zus_y ! temporary Stokes drift 330 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zviscos ! viscosity 331 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdiffut ! t-diffusivity 332 REAL(wp), DIMENSION(jpi,jpj) :: zalpha_pyc 333 REAL(wp), DIMENSION(jpi,jpj) :: ztau_sc_u ! dissipation timescale at baes of WML. 334 REAL(wp) :: zdelta_pyc, zwt_pyc_sc_1, zws_pyc_sc_1, zzeta_pyc 335 REAL(wp) :: zbuoy_pyc_sc, zomega, zvw_max 336 INTEGER :: ibld_ext=0 ! does not have to be zero for modified scheme 337 REAL(wp) :: zgamma_b_nd, zgamma_b, zdhoh, ztau 338 REAL(wp) :: zzeta_s = 0._wp 339 REAL(wp) :: zzeta_v = 0.46 340 REAL(wp) :: zabsstke 341 REAL(wp) :: zsqrtpi, z_two_thirds, zproportion, ztransp, zthickness 342 REAL(wp) :: z2k_times_thickness, zsqrt_depth, zexp_depth, zdstokes0, zf, zexperfc 343 344 ! For debugging 345 INTEGER :: ikt 346 !!-------------------------------------------------------------------- 347 ! 348 ibld(:,:) = 0 ; imld(:,:) = 0 349 zrad0(:,:) = 0._wp ; zradh(:,:) = 0._wp ; zradav(:,:) = 0._wp ; zustar(:,:) = 0._wp 350 zwstrl(:,:) = 0._wp ; zvstr(:,:) = 0._wp ; zwstrc(:,:) = 0._wp ; zuw0(:,:) = 0._wp 351 zvw0(:,:) = 0._wp ; zwth0(:,:) = 0._wp ; zws0(:,:) = 0._wp ; zwb0(:,:) = 0._wp 352 zwthav(:,:) = 0._wp ; zwsav(:,:) = 0._wp ; zwbav(:,:) = 0._wp ; zwb_ent(:,:) = 0._wp 353 zustke(:,:) = 0._wp ; zla(:,:) = 0._wp ; zcos_wind(:,:) = 0._wp ; zsin_wind(:,:) = 0._wp 354 zhol(:,:) = 0._wp 355 lconv(:,:) = .FALSE.; lpyc(:,:) = .FALSE. ; lflux(:,:) = .FALSE. ; lmle(:,:) = .FALSE. 356 ! mixed layer 357 ! no initialization of zhbl or zhml (or zdh?) 358 zhbl(:,:) = 1._wp ; zhml(:,:) = 1._wp ; zdh(:,:) = 1._wp ; zdhdt(:,:) = 0._wp 359 zt_bl(:,:) = 0._wp ; zs_bl(:,:) = 0._wp ; zu_bl(:,:) = 0._wp 360 zv_bl(:,:) = 0._wp ; zb_bl(:,:) = 0._wp 361 zt_ml(:,:) = 0._wp ; zs_ml(:,:) = 0._wp ; zu_ml(:,:) = 0._wp 362 zt_mle(:,:) = 0._wp ; zs_mle(:,:) = 0._wp ; zu_mle(:,:) = 0._wp 363 zb_mle(:,:) = 0._wp 364 zv_ml(:,:) = 0._wp ; zdt_bl(:,:) = 0._wp ; zds_bl(:,:) = 0._wp 365 zdu_bl(:,:) = 0._wp ; zdv_bl(:,:) = 0._wp ; zdb_bl(:,:) = 0._wp 366 zdt_ml(:,:) = 0._wp ; zds_ml(:,:) = 0._wp ; zdu_ml(:,:) = 0._wp ; zdv_ml(:,:) = 0._wp 367 zdb_ml(:,:) = 0._wp 368 zdt_mle(:,:) = 0._wp ; zds_mle(:,:) = 0._wp ; zdu_mle(:,:) = 0._wp 369 zdv_mle(:,:) = 0._wp ; zdb_mle(:,:) = 0._wp 370 zwth_ent = 0._wp ; zws_ent = 0._wp 371 ! 372 zdtdz_pyc(:,:,:) = 0._wp ; zdsdz_pyc(:,:,:) = 0._wp ; zdbdz_pyc(:,:,:) = 0._wp 373 zdudz_pyc(:,:,:) = 0._wp ; zdvdz_pyc(:,:,:) = 0._wp 374 ! 375 zdtdz_bl_ext(:,:) = 0._wp ; zdsdz_bl_ext(:,:) = 0._wp ; zdbdz_bl_ext(:,:) = 0._wp 376 377 IF ( ln_osm_mle ) THEN ! only initialise arrays if needed 378 zdtdx(:,:) = 0._wp ; zdtdy(:,:) = 0._wp ; zdsdx(:,:) = 0._wp 379 zdsdy(:,:) = 0._wp ; dbdx_mle(:,:) = 0._wp ; dbdy_mle(:,:) = 0._wp 380 zwb_fk(:,:) = 0._wp ; zvel_mle(:,:) = 0._wp; zdiff_mle(:,:) = 0._wp 381 zhmle(:,:) = 0._wp ; zmld(:,:) = 0._wp 352 INTEGER , INTENT(in ) :: kt ! Ocean time step 353 INTEGER , INTENT(in ) :: Kbb, Kmm, Krhs ! Ocean time level indices 354 REAL(wp), DIMENSION(:,:,:), INTENT(inout) :: p_avm, p_avt ! Momentum and tracer Kz (w-points) 355 !! 356 INTEGER :: ji, jj, jk, jl, jm, jkflt ! Dummy loop indices 357 !! 358 REAL(wp) :: zthermal, zbeta 359 REAL(wp) :: zesh2, zri, zfri ! Interior Richardson mixing 360 !! Scales 361 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zrad0 ! Surface solar temperature flux (deg m/s) 362 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zradh ! Radiative flux at bl base (Buoyancy units) 363 REAL(wp) :: zradav ! Radiative flux, bl average (Buoyancy Units) 364 REAL(wp) :: zvw0 ! Surface v-momentum flux 365 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwb0tot ! Total surface buoyancy flux including insolation 366 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwb_ent ! Buoyancy entrainment flux 367 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwb_min 368 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwb_fk_b ! MLE buoyancy flux averaged over OSBL 369 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwb_fk ! Max MLE buoyancy flux 370 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdiff_mle ! Extra MLE vertical diff 371 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zvel_mle ! Velocity scale for dhdt with stable ML and FK 372 !! Mixed-layer variables 373 INTEGER, DIMENSION(A2D(nn_hls-1)) :: jk_nlev ! Number of levels 374 INTEGER, DIMENSION(A2D(nn_hls-1)) :: jk_ext ! Offset for external level 375 !! 376 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zhbl ! BL depth - grid 377 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zhml ! ML depth - grid 378 !! 379 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zhmle ! MLE depth - grid 380 REAL(wp), DIMENSION(A2D(nn_hls)) :: zmld ! ML depth on grid 381 !! 382 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdh ! Pycnocline depth - grid 383 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdhdt ! BL depth tendency 384 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdtdz_bl_ext, zdsdz_bl_ext ! External temperature/salinity gradients 385 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdbdz_bl_ext ! External buoyancy gradients 386 REAL(wp), DIMENSION(A2D(nn_hls)) :: zdtdx, zdtdy, zdsdx, zdsdy ! Horizontal gradients for Fox-Kemper parametrization 387 !! 388 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdbds_mle ! Magnitude of horizontal buoyancy gradient 389 !! Flux-gradient relationship variables 390 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zshear ! Shear production 391 !! 392 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zhbl_t ! Holds boundary layer depth updated by full timestep 393 !! For calculating Ri#-dependent mixing 394 REAL(wp), DIMENSION(A2D(nn_hls)) :: z2du ! u-shear^2 395 REAL(wp), DIMENSION(A2D(nn_hls)) :: z2dv ! v-shear^2 396 REAL(wp) :: zrimix ! Spatial form of ri#-induced diffusion 397 !! Temporary variables 398 REAL(wp) :: znd ! Temporary non-dimensional depth 399 REAL(wp) :: zz0, zz1, zfac 400 REAL(wp) :: zus_x, zus_y ! Temporary Stokes drift 401 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk) :: zviscos ! Viscosity 402 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk) :: zdiffut ! t-diffusivity 403 REAL(wp) :: zabsstke 404 REAL(wp) :: zsqrtpi, z_two_thirds, zthickness 405 REAL(wp) :: z2k_times_thickness, zsqrt_depth, zexp_depth, zf, zexperfc 406 !! For debugging 407 REAL(wp), PARAMETER :: pp_large = -1e10_wp 408 !!---------------------------------------------------------------------- 409 ! 410 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 411 nmld(ji,jj) = 0 412 sustke(ji,jj) = pp_large 413 l_pyc(ji,jj) = .FALSE. 414 l_flux(ji,jj) = .FALSE. 415 l_mle(ji,jj) = .FALSE. 416 END_2D 417 ! Mixed layer 418 ! No initialization of zhbl or zhml (or zdh?) 419 zhbl(:,:) = pp_large 420 zhml(:,:) = pp_large 421 zdh(:,:) = pp_large 422 ! 423 IF ( ln_osm_mle ) THEN ! Only initialise arrays if needed 424 zdtdx(:,:) = pp_large ; zdtdy(:,:) = pp_large ; zdsdx(:,:) = pp_large 425 zdsdy(:,:) = pp_large 426 zwb_fk(:,:) = pp_large ; zvel_mle(:,:) = pp_large 427 zhmle(:,:) = pp_large ; zmld(:,:) = pp_large 428 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 429 dbdx_mle(ji,jj) = pp_large 430 dbdy_mle(ji,jj) = pp_large 431 END_2D 382 432 ENDIF 383 zwb_fk_b(:,:) = 0._wp ! must be initialised even with ln_osm_mle=F as used in zdf_osm_calculate_dhdt 384 385 ! Flux-Gradient arrays. 386 zsc_wth_1(:,:) = 0._wp ; zsc_ws_1(:,:) = 0._wp ; zsc_uw_1(:,:) = 0._wp 387 zsc_uw_2(:,:) = 0._wp ; zsc_vw_1(:,:) = 0._wp ; zsc_vw_2(:,:) = 0._wp 388 zhbl_t(:,:) = 0._wp ; zdhdt(:,:) = 0._wp 389 390 zdiffut(:,:,:) = 0._wp ; zviscos(:,:,:) = 0._wp ; ghamt(:,:,:) = 0._wp 391 ghams(:,:,:) = 0._wp ; ghamu(:,:,:) = 0._wp ; ghamv(:,:,:) = 0._wp 392 393 zddhdt(:,:) = 0._wp 394 ! hbl = MAX(hbl,epsln) 433 zhbl_t(:,:) = pp_large 434 ! 435 zdiffut(:,:,:) = 0.0_wp 436 zviscos(:,:,:) = 0.0_wp 437 ! 438 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 439 ghamt(ji,jj,jk) = pp_large 440 ghams(ji,jj,jk) = pp_large 441 ghamu(ji,jj,jk) = pp_large 442 ghamv(ji,jj,jk) = pp_large 443 END_3D 444 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpk ) 445 ghamt(ji,jj,jk) = 0.0_wp 446 ghams(ji,jj,jk) = 0.0_wp 447 ghamu(ji,jj,jk) = 0.0_wp 448 ghamv(ji,jj,jk) = 0.0_wp 449 END_3D 450 ! 451 zdiff_mle(:,:) = 0.0_wp 452 ! 453 ! Ensure only positive hbl values are accessed when using extended halo 454 ! (nn_hls==2) 455 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 456 hbl(ji,jj) = MAX( hbl(ji,jj), epsln ) 457 END_2D 458 ! 395 459 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 396 460 ! Calculate boundary layer scales 397 461 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 398 399 ! Assume two-band radiation model for depth of OSBL 400 zz0 = rn_abs ! surface equi-partition in 2-bands 401 zz1 = 1. - rn_abs 402 DO_2D( 0, 0, 0, 0 ) 403 ! Surface downward irradiance (so always +ve) 404 zrad0(ji,jj) = qsr(ji,jj) * r1_rho0_rcp 405 ! Downwards irradiance at base of boundary layer 406 zradh(ji,jj) = zrad0(ji,jj) * ( zz0 * EXP( -hbl(ji,jj)/rn_si0 ) + zz1 * EXP( -hbl(ji,jj)/rn_si1) ) 407 ! Downwards irradiance averaged over depth of the OSBL 408 zradav(ji,jj) = zrad0(ji,jj) * ( zz0 * ( 1.0 - EXP( -hbl(ji,jj)/rn_si0 ) )*rn_si0 & 409 & + zz1 * ( 1.0 - EXP( -hbl(ji,jj)/rn_si1 ) )*rn_si1 ) / hbl(ji,jj) 410 END_2D 411 ! Turbulent surface fluxes and fluxes averaged over depth of the OSBL 412 DO_2D( 0, 0, 0, 0 ) 413 zthermal = rab_n(ji,jj,1,jp_tem) 414 zbeta = rab_n(ji,jj,1,jp_sal) 415 ! Upwards surface Temperature flux for non-local term 416 zwth0(ji,jj) = - qns(ji,jj) * r1_rho0_rcp * tmask(ji,jj,1) 417 ! Upwards surface salinity flux for non-local term 418 zws0(ji,jj) = - ( ( emp(ji,jj)-rnf(ji,jj) ) * ts(ji,jj,1,jp_sal,Kmm) + sfx(ji,jj) ) * r1_rho0 * tmask(ji,jj,1) 419 ! Non radiative upwards surface buoyancy flux 420 zwb0(ji,jj) = grav * zthermal * zwth0(ji,jj) - grav * zbeta * zws0(ji,jj) 421 ! turbulent heat flux averaged over depth of OSBL 422 zwthav(ji,jj) = 0.5 * zwth0(ji,jj) - ( 0.5*( zrad0(ji,jj) + zradh(ji,jj) ) - zradav(ji,jj) ) 423 ! turbulent salinity flux averaged over depth of the OBSL 424 zwsav(ji,jj) = 0.5 * zws0(ji,jj) 425 ! turbulent buoyancy flux averaged over the depth of the OBSBL 426 zwbav(ji,jj) = grav * zthermal * zwthav(ji,jj) - grav * zbeta * zwsav(ji,jj) 427 ! Surface upward velocity fluxes 428 zuw0(ji,jj) = - 0.5 * (utau(ji-1,jj) + utau(ji,jj)) * r1_rho0 * tmask(ji,jj,1) 429 zvw0(ji,jj) = - 0.5 * (vtau(ji,jj-1) + vtau(ji,jj)) * r1_rho0 * tmask(ji,jj,1) 430 ! Friction velocity (zustar), at T-point : LMD94 eq. 2 431 zustar(ji,jj) = MAX( SQRT( SQRT( zuw0(ji,jj) * zuw0(ji,jj) + zvw0(ji,jj) * zvw0(ji,jj) ) ), 1.0e-8 ) 432 zcos_wind(ji,jj) = -zuw0(ji,jj) / ( zustar(ji,jj) * zustar(ji,jj) ) 433 zsin_wind(ji,jj) = -zvw0(ji,jj) / ( zustar(ji,jj) * zustar(ji,jj) ) 434 END_2D 435 ! Calculate Stokes drift in direction of wind (zustke) and Stokes penetration depth (dstokes) 436 SELECT CASE (nn_osm_wave) 437 ! Assume constant La#=0.3 438 CASE(0) 439 DO_2D( 0, 0, 0, 0 ) 440 zus_x = zcos_wind(ji,jj) * zustar(ji,jj) / 0.3**2 441 zus_y = zsin_wind(ji,jj) * zustar(ji,jj) / 0.3**2 442 ! Linearly 443 zustke(ji,jj) = MAX ( SQRT( zus_x*zus_x + zus_y*zus_y), 1.0e-8 ) 444 dstokes(ji,jj) = rn_osm_dstokes 445 END_2D 446 ! Assume Pierson-Moskovitz wind-wave spectrum 447 CASE(1) 448 DO_2D( 0, 0, 0, 0 ) 449 ! Use wind speed wndm included in sbc_oce module 450 zustke(ji,jj) = MAX ( 0.016 * wndm(ji,jj), 1.0e-8 ) 451 dstokes(ji,jj) = MAX ( 0.12 * wndm(ji,jj)**2 / grav, 5.e-1) 452 END_2D 453 ! Use ECMWF wave fields as output from SBCWAVE 454 CASE(2) 455 zfac = 2.0_wp * rpi / 16.0_wp 456 457 DO_2D( 0, 0, 0, 0 ) 458 IF (hsw(ji,jj) > 1.e-4) THEN 459 ! Use wave fields 460 zabsstke = SQRT(ut0sd(ji,jj)**2 + vt0sd(ji,jj)**2) 461 zustke(ji,jj) = MAX ( ( zcos_wind(ji,jj) * ut0sd(ji,jj) + zsin_wind(ji,jj) * vt0sd(ji,jj) ), 1.0e-8) 462 dstokes(ji,jj) = MAX (zfac * hsw(ji,jj)*hsw(ji,jj) / ( MAX(zabsstke * wmp(ji,jj), 1.0e-7 ) ), 5.0e-1) 463 ELSE 464 ! Assume masking issue (e.g. ice in ECMWF reanalysis but not in model run) 465 ! .. so default to Pierson-Moskowitz 466 zustke(ji,jj) = MAX ( 0.016 * wndm(ji,jj), 1.0e-8 ) 467 dstokes(ji,jj) = MAX ( 0.12 * wndm(ji,jj)**2 / grav, 5.e-1) 468 END IF 469 END_2D 470 END SELECT 471 472 IF (ln_zdfosm_ice_shelter) THEN 473 ! Reduce both Stokes drift and its depth scale by ocean fraction to represent sheltering by ice 474 DO_2D( 0, 0, 0, 0 ) 475 zustke(ji,jj) = zustke(ji,jj) * (1.0_wp - fr_i(ji,jj)) 476 dstokes(ji,jj) = dstokes(ji,jj) * (1.0_wp - fr_i(ji,jj)) 477 END_2D 478 END IF 479 480 SELECT CASE (nn_osm_SD_reduce) 481 ! Reduce surface Stokes drift by a constant factor or following Breivik (2016) + van Roekel (2012) or Grant (2020). 482 CASE(0) 483 ! The Langmur number from the ECMWF model (or from PM) appears to give La<0.3 for wind-driven seas. 484 ! The coefficient rn_zdfosm_adjust_sd = 0.8 gives La=0.3 in this situation. 485 ! It could represent the effects of the spread of wave directions 486 ! around the mean wind. The effect of this adjustment needs to be tested. 487 IF(nn_osm_wave > 0) THEN 488 zustke(2:jpim1,2:jpjm1) = rn_zdfosm_adjust_sd * zustke(2:jpim1,2:jpjm1) 489 END IF 490 CASE(1) 491 ! van Roekel (2012): consider average SD over top 10% of boundary layer 492 ! assumes approximate depth profile of SD from Breivik (2016) 493 zsqrtpi = SQRT(rpi) 494 z_two_thirds = 2.0_wp / 3.0_wp 495 496 DO_2D( 0, 0, 0, 0 ) 497 zthickness = rn_osm_hblfrac*hbl(ji,jj) 498 z2k_times_thickness = zthickness * 2.0_wp / MAX( ABS( 5.97_wp * dstokes(ji,jj) ), 0.0000001_wp ) 499 zsqrt_depth = SQRT(z2k_times_thickness) 500 zexp_depth = EXP(-z2k_times_thickness) 501 zustke(ji,jj) = zustke(ji,jj) * (1.0_wp - zexp_depth & 502 & - z_two_thirds * ( zsqrtpi*zsqrt_depth*z2k_times_thickness * ERFC(zsqrt_depth) & 503 & + 1.0_wp - (1.0_wp + z2k_times_thickness)*zexp_depth ) ) / z2k_times_thickness 504 505 END_2D 506 CASE(2) 507 ! Grant (2020): Match to exponential with same SD and d/dz(Sd) at depth 10% of boundary layer 508 ! assumes approximate depth profile of SD from Breivik (2016) 509 zsqrtpi = SQRT(rpi) 510 511 DO_2D( 0, 0, 0, 0 ) 512 zthickness = rn_osm_hblfrac*hbl(ji,jj) 513 z2k_times_thickness = zthickness * 2.0_wp / MAX( ABS( 5.97_wp * dstokes(ji,jj) ), 0.0000001_wp ) 514 515 IF(z2k_times_thickness < 50._wp) THEN 516 zsqrt_depth = SQRT(z2k_times_thickness) 517 zexperfc = zsqrtpi * zsqrt_depth * ERFC(zsqrt_depth) * EXP(z2k_times_thickness) 518 ELSE 519 ! asymptotic expansion of sqrt(pi)*zsqrt_depth*EXP(z2k_times_thickness)*ERFC(zsqrt_depth) for large z2k_times_thickness 520 ! See Abramowitz and Stegun, Eq. 7.1.23 521 ! zexperfc = 1._wp - (1/2)/(z2k_times_thickness) + (3/4)/(z2k_times_thickness**2) - (15/8)/(z2k_times_thickness**3) 522 zexperfc = ((- 1.875_wp/z2k_times_thickness + 0.75_wp)/z2k_times_thickness - 0.5_wp)/z2k_times_thickness + 1.0_wp 523 END IF 524 zf = z2k_times_thickness*(1.0_wp/zexperfc - 1.0_wp) 525 dstokes(ji,jj) = 5.97 * zf * dstokes(ji,jj) 526 zustke(ji,jj) = zustke(ji,jj) * EXP(z2k_times_thickness * ( 1.0_wp / (2. * zf) - 1.0_wp )) * ( 1.0_wp - zexperfc) 527 END_2D 528 END SELECT 529 530 ! Langmuir velocity scale (zwstrl), La # (zla) 531 ! mixed scale (zvstr), convective velocity scale (zwstrc) 532 DO_2D( 0, 0, 0, 0 ) 533 ! Langmuir velocity scale (zwstrl), at T-point 534 zwstrl(ji,jj) = ( zustar(ji,jj) * zustar(ji,jj) * zustke(ji,jj) )**pthird 535 zla(ji,jj) = MAX(MIN(SQRT ( zustar(ji,jj) / ( zwstrl(ji,jj) + epsln ) )**3, 4.0), 0.2) 536 IF(zla(ji,jj) > 0.45) dstokes(ji,jj) = MIN(dstokes(ji,jj), 0.5_wp*hbl(ji,jj)) 537 ! Velocity scale that tends to zustar for large Langmuir numbers 538 zvstr(ji,jj) = ( zwstrl(ji,jj)**3 + & 539 & ( 1.0 - EXP( -0.5 * zla(ji,jj)**2 ) ) * zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj) )**pthird 540 541 ! limit maximum value of Langmuir number as approximate treatment for shear turbulence. 542 ! Note zustke and zwstrl are not amended. 543 ! 544 ! get convective velocity (zwstrc), stabilty scale (zhol) and logical conection flag lconv 545 IF ( zwbav(ji,jj) > 0.0) THEN 546 zwstrc(ji,jj) = ( 2.0 * zwbav(ji,jj) * 0.9 * hbl(ji,jj) )**pthird 547 zhol(ji,jj) = -0.9 * hbl(ji,jj) * 2.0 * zwbav(ji,jj) / (zvstr(ji,jj)**3 + epsln ) 462 ! 463 ! Turbulent surface fluxes and fluxes averaged over depth of the OSBL 464 zz0 = rn_abs ! Assume two-band radiation model for depth of OSBL - surface equi-partition in 2-bands 465 zz1 = 1.0_wp - rn_abs 466 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 467 zrad0(ji,jj) = qsr(ji,jj) * r1_rho0_rcp ! Surface downward irradiance (so always +ve) 468 zradh(ji,jj) = zrad0(ji,jj) * & ! Downwards irradiance at base of boundary layer 469 & ( zz0 * EXP( -1.0_wp * hbl(ji,jj) / rn_si0 ) + zz1 * EXP( -1.0_wp * hbl(ji,jj) / rn_si1 ) ) 470 zradav = zrad0(ji,jj) * & ! Downwards irradiance averaged 471 & ( zz0 * ( 1.0_wp - EXP( -hbl(ji,jj)/rn_si0 ) ) * rn_si0 + & ! over depth of the OSBL 472 & zz1 * ( 1.0_wp - EXP( -hbl(ji,jj)/rn_si1 ) ) * rn_si1 ) / hbl(ji,jj) 473 swth0(ji,jj) = - qns(ji,jj) * r1_rho0_rcp * tmask(ji,jj,1) ! Upwards surface Temperature flux for non-local term 474 swthav(ji,jj) = 0.5_wp * swth0(ji,jj) - ( 0.5_wp * ( zrad0(ji,jj) + zradh(ji,jj) ) - & ! Turbulent heat flux averaged 475 & zradav ) ! over depth of OSBL 476 END_2D 477 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 478 sws0(ji,jj) = -1.0_wp * ( ( emp(ji,jj) - rnf(ji,jj) ) * ts(ji,jj,1,jp_sal,Kmm) + & ! Upwards surface salinity flux 479 & sfx(ji,jj) ) * r1_rho0 * tmask(ji,jj,1) ! for non-local term 480 zthermal = rab_n(ji,jj,1,jp_tem) 481 zbeta = rab_n(ji,jj,1,jp_sal) 482 swb0(ji,jj) = grav * zthermal * swth0(ji,jj) - grav * zbeta * sws0(ji,jj) ! Non radiative upwards surface buoyancy flux 483 zwb0tot(ji,jj) = swb0(ji,jj) - grav * zthermal * ( zrad0(ji,jj) - zradh(ji,jj) ) ! Total upwards surface buoyancy flux 484 swsav(ji,jj) = 0.5_wp * sws0(ji,jj) ! Turbulent salinity flux averaged over depth of the OBSL 485 swbav(ji,jj) = grav * zthermal * swthav(ji,jj) - & ! Turbulent buoyancy flux averaged over the depth of the 486 & grav * zbeta * swsav(ji,jj) ! OBSBL 487 END_2D 488 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 489 suw0(ji,jj) = -0.5_wp * (utau(ji-1,jj) + utau(ji,jj)) * r1_rho0 * tmask(ji,jj,1) ! Surface upward velocity fluxes 490 zvw0 = -0.5_wp * (vtau(ji,jj-1) + vtau(ji,jj)) * r1_rho0 * tmask(ji,jj,1) 491 sustar(ji,jj) = MAX( SQRT( SQRT( suw0(ji,jj) * suw0(ji,jj) + zvw0 * zvw0 ) ), & ! Friction velocity (sustar), at 492 & 1e-8_wp ) ! T-point : LMD94 eq. 2 493 scos_wind(ji,jj) = -1.0_wp * suw0(ji,jj) / ( sustar(ji,jj) * sustar(ji,jj) ) 494 ssin_wind(ji,jj) = -1.0_wp * zvw0 / ( sustar(ji,jj) * sustar(ji,jj) ) 495 END_2D 496 ! Calculate Stokes drift in direction of wind (sustke) and Stokes penetration depth (dstokes) 497 SELECT CASE (nn_osm_wave) 498 ! Assume constant La#=0.3 499 CASE(0) 500 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 501 zus_x = scos_wind(ji,jj) * sustar(ji,jj) / 0.3_wp**2 502 zus_y = ssin_wind(ji,jj) * sustar(ji,jj) / 0.3_wp**2 503 ! Linearly 504 sustke(ji,jj) = MAX( SQRT( zus_x * zus_x + zus_y * zus_y ), 1e-8_wp ) 505 dstokes(ji,jj) = rn_osm_dstokes 506 END_2D 507 ! Assume Pierson-Moskovitz wind-wave spectrum 508 CASE(1) 509 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 510 ! Use wind speed wndm included in sbc_oce module 511 sustke(ji,jj) = MAX ( 0.016_wp * wndm(ji,jj), 1e-8_wp ) 512 dstokes(ji,jj) = MAX ( 0.12_wp * wndm(ji,jj)**2 / grav, 5e-1_wp ) 513 END_2D 514 ! Use ECMWF wave fields as output from SBCWAVE 515 CASE(2) 516 zfac = 2.0_wp * rpi / 16.0_wp 517 ! 518 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 519 IF ( hsw(ji,jj) > 1e-4_wp ) THEN 520 ! Use wave fields 521 zabsstke = SQRT( ut0sd(ji,jj)**2 + vt0sd(ji,jj)**2 ) 522 sustke(ji,jj) = MAX( ( scos_wind(ji,jj) * ut0sd(ji,jj) + ssin_wind(ji,jj) * vt0sd(ji,jj) ), 1e-8_wp ) 523 dstokes(ji,jj) = MAX( zfac * hsw(ji,jj) * hsw(ji,jj) / ( MAX( zabsstke * wmp(ji,jj), 1e-7 ) ), 5e-1_wp ) 524 ELSE 525 ! Assume masking issue (e.g. ice in ECMWF reanalysis but not in model run) 526 ! .. so default to Pierson-Moskowitz 527 sustke(ji,jj) = MAX( 0.016_wp * wndm(ji,jj), 1e-8_wp ) 528 dstokes(ji,jj) = MAX( 0.12_wp * wndm(ji,jj)**2 / grav, 5e-1_wp ) 529 END IF 530 END_2D 531 END SELECT 532 ! 533 IF (ln_zdfosm_ice_shelter) THEN 534 ! Reduce both Stokes drift and its depth scale by ocean fraction to represent sheltering by ice 535 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 536 sustke(ji,jj) = sustke(ji,jj) * ( 1.0_wp - fr_i(ji,jj) ) 537 dstokes(ji,jj) = dstokes(ji,jj) * ( 1.0_wp - fr_i(ji,jj) ) 538 END_2D 539 END IF 540 ! 541 SELECT CASE (nn_osm_SD_reduce) 542 ! Reduce surface Stokes drift by a constant factor or following Breivik (2016) + van Roekel (2012) or Grant (2020). 543 CASE(0) 544 ! The Langmur number from the ECMWF model (or from PM) appears to give La<0.3 for wind-driven seas. 545 ! The coefficient rn_zdfosm_adjust_sd = 0.8 gives La=0.3 in this situation. 546 ! It could represent the effects of the spread of wave directions around the mean wind. The effect of this adjustment needs to be tested. 547 IF(nn_osm_wave > 0) THEN 548 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 549 sustke(ji,jj) = rn_zdfosm_adjust_sd * sustke(ji,jj) 550 END_2D 551 END IF 552 CASE(1) 553 ! Van Roekel (2012): consider average SD over top 10% of boundary layer 554 ! Assumes approximate depth profile of SD from Breivik (2016) 555 zsqrtpi = SQRT(rpi) 556 z_two_thirds = 2.0_wp / 3.0_wp 557 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 558 zthickness = rn_osm_hblfrac*hbl(ji,jj) 559 z2k_times_thickness = zthickness * 2.0_wp / MAX( ABS( 5.97_wp * dstokes(ji,jj) ), 1e-7_wp ) 560 zsqrt_depth = SQRT( z2k_times_thickness ) 561 zexp_depth = EXP( -1.0_wp * z2k_times_thickness ) 562 sustke(ji,jj) = sustke(ji,jj) * ( 1.0_wp - zexp_depth - & 563 & z_two_thirds * ( zsqrtpi * zsqrt_depth * z2k_times_thickness * ERFC(zsqrt_depth) + & 564 & 1.0_wp - ( 1.0_wp + z2k_times_thickness ) * zexp_depth ) ) / & 565 & z2k_times_thickness 566 END_2D 567 CASE(2) 568 ! Grant (2020): Match to exponential with same SD and d/dz(Sd) at depth 10% of boundary layer 569 ! Assumes approximate depth profile of SD from Breivik (2016) 570 zsqrtpi = SQRT(rpi) 571 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 572 zthickness = rn_osm_hblfrac*hbl(ji,jj) 573 z2k_times_thickness = zthickness * 2.0_wp / MAX( ABS( 5.97_wp * dstokes(ji,jj) ), 1e-7_wp ) 574 IF( z2k_times_thickness < 50.0_wp ) THEN 575 zsqrt_depth = SQRT( z2k_times_thickness ) 576 zexperfc = zsqrtpi * zsqrt_depth * ERFC(zsqrt_depth) * EXP( z2k_times_thickness ) 577 ELSE 578 ! Asymptotic expansion of sqrt(pi)*zsqrt_depth*EXP(z2k_times_thickness)*ERFC(zsqrt_depth) for large 579 ! z2k_times_thickness 580 ! See Abramowitz and Stegun, Eq. 7.1.23 581 ! zexperfc = 1._wp - (1/2)/(z2k_times_thickness) + (3/4)/(z2k_times_thickness**2) - (15/8)/(z2k_times_thickness**3) 582 zexperfc = ( ( -1.875_wp / z2k_times_thickness + 0.75_wp ) / z2k_times_thickness - 0.5_wp ) / & 583 & z2k_times_thickness + 1.0_wp 584 END IF 585 zf = z2k_times_thickness * ( 1.0_wp / zexperfc - 1.0_wp ) 586 dstokes(ji,jj) = 5.97_wp * zf * dstokes(ji,jj) 587 sustke(ji,jj) = sustke(ji,jj) * EXP( z2k_times_thickness * ( 1.0_wp / ( 2.0_wp * zf ) - 1.0_wp ) ) * & 588 & ( 1.0_wp - zexperfc ) 589 END_2D 590 END SELECT 591 ! 592 ! Langmuir velocity scale (swstrl), La # (sla) 593 ! Mixed scale (svstr), convective velocity scale (swstrc) 594 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 595 ! Langmuir velocity scale (swstrl), at T-point 596 swstrl(ji,jj) = ( sustar(ji,jj) * sustar(ji,jj) * sustke(ji,jj) )**pthird 597 sla(ji,jj) = MAX( MIN( SQRT( sustar(ji,jj) / ( swstrl(ji,jj) + epsln ) )**3, 4.0_wp ), 0.2_wp ) 598 IF ( sla(ji,jj) > 0.45_wp ) dstokes(ji,jj) = MIN( dstokes(ji,jj), 0.5_wp * hbl(ji,jj) ) 599 ! Velocity scale that tends to sustar for large Langmuir numbers 600 svstr(ji,jj) = ( swstrl(ji,jj)**3 + ( 1.0_wp - EXP( -0.5_wp * sla(ji,jj)**2 ) ) * sustar(ji,jj) * sustar(ji,jj) * & 601 & sustar(ji,jj) )**pthird 602 ! 603 ! Limit maximum value of Langmuir number as approximate treatment for shear turbulence 604 ! Note sustke and swstrl are not amended 605 ! 606 ! Get convective velocity (swstrc), stabilty scale (shol) and logical conection flag l_conv 607 IF ( swbav(ji,jj) > 0.0_wp ) THEN 608 swstrc(ji,jj) = ( 2.0_wp * swbav(ji,jj) * 0.9_wp * hbl(ji,jj) )**pthird 609 shol(ji,jj) = -0.9_wp * hbl(ji,jj) * 2.0_wp * swbav(ji,jj) / ( svstr(ji,jj)**3 + epsln ) 548 610 ELSE 549 zhol(ji,jj) = -hbl(ji,jj) * 2.0 * zwbav(ji,jj)/ (zvstr(ji,jj)**3 + epsln ) 550 ENDIF 551 END_2D 552 553 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 554 ! Mixed-layer model - calculate averages over the boundary layer, and the change in the boundary layer depth 555 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 556 ! BL must be always 4 levels deep. 557 ! For calculation of lateral buoyancy gradients for FK in 558 ! zdf_osm_zmld_horizontal_gradients need halo values for ibld, so must 559 ! previously exist for hbl also. 560 561 ! agn 23/6/20: not clear all this is needed, as hbl checked after it is re-calculated anyway 562 ! ########################################################################## 563 hbl(:,:) = MAX(hbl(:,:), gdepw(:,:,4,Kmm) ) 564 ibld(:,:) = 4 565 DO_3D( 1, 1, 1, 1, 5, jpkm1 ) 566 IF ( hbl(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) THEN 567 ibld(ji,jj) = MIN(mbkt(ji,jj), jk) 611 swstrc(ji,jj) = 0.0_wp 612 shol(ji,jj) = -1.0_wp * hbl(ji,jj) * 2.0_wp * swbav(ji,jj) / ( svstr(ji,jj)**3 + epsln ) 613 ENDIF 614 END_2D 615 ! 616 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 617 ! Mixed-layer model - calculate averages over the boundary layer, and the change in the boundary layer depth 618 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 619 ! BL must be always 4 levels deep. 620 ! For calculation of lateral buoyancy gradients for FK in 621 ! zdf_osm_zmld_horizontal_gradients need halo values for nbld 622 ! 623 ! agn 23/6/20: not clear all this is needed, as hbl checked after it is re-calculated anyway 624 ! ########################################################################## 625 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 626 hbl(ji,jj) = MAX(hbl(ji,jj), gdepw(ji,jj,4,Kmm) ) 627 END_2D 628 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 629 nbld(ji,jj) = 4 630 END_2D 631 DO_3D_OVR( nn_hls, nn_hls, nn_hls, nn_hls, 5, jpkm1 ) 632 IF ( MAX( hbl(ji,jj), gdepw(ji,jj,4,Kmm) ) >= gdepw(ji,jj,jk,Kmm) ) THEN 633 nbld(ji,jj) = MIN(mbkt(ji,jj)-2, jk) 568 634 ENDIF 569 635 END_3D 570 ! ##########################################################################571 572 DO_2D ( 0, 0, 0, 0)573 zhbl(ji,jj) = gdepw(ji,jj, ibld(ji,jj),Kmm)574 imld(ji,jj) = MAX(3,ibld(ji,jj) - MAX( INT( dh(ji,jj) / e3t(ji, jj, ibld(ji,jj), Kmm )) , 1 ))575 zhml(ji,jj) = gdepw(ji,jj, imld(ji,jj),Kmm)636 ! ########################################################################## 637 ! 638 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 639 zhbl(ji,jj) = gdepw(ji,jj,nbld(ji,jj),Kmm) 640 nmld(ji,jj) = MAX( 3, nbld(ji,jj) - MAX( INT( dh(ji,jj) / e3t(ji,jj,nbld(ji,jj)-1,Kmm) ), 1 ) ) 641 zhml(ji,jj) = gdepw(ji,jj,nmld(ji,jj),Kmm) 576 642 zdh(ji,jj) = zhbl(ji,jj) - zhml(ji,jj) 577 643 END_2D 578 ! Averages over well-mixed and boundary layer 579 jp_ext(:,:) = 2 580 CALL zdf_osm_vertical_average(ibld, jp_ext, zt_bl, zs_bl, zb_bl, zu_bl, zv_bl, zdt_bl, zds_bl, zdb_bl, zdu_bl, zdv_bl) 581 ! jp_ext(:,:) = ibld(:,:) - imld(:,:) + 1 582 CALL zdf_osm_vertical_average(ibld, ibld-imld+1, zt_ml, zs_ml, zb_ml, zu_ml, zv_ml, zdt_ml, zds_ml, zdb_ml, zdu_ml, zdv_ml) 583 ! Velocity components in frame aligned with surface stress. 584 CALL zdf_osm_velocity_rotation( zcos_wind, zsin_wind, zu_ml, zv_ml, zdu_ml, zdv_ml ) 585 CALL zdf_osm_velocity_rotation( zcos_wind, zsin_wind, zu_bl, zv_bl, zdu_bl, zdv_bl ) 586 ! Determine the state of the OSBL, stable/unstable, shear/no shear 587 CALL zdf_osm_osbl_state( lconv, lshear, j_ddh, zwb_ent, zwb_min, zshear, zri_i ) 588 644 ! 645 ! Averages over well-mixed and boundary layer, note BL averages use jk_ext=2 everywhere 646 jk_nlev(:,:) = nbld(A2D(nn_hls-1)) 647 jk_ext(:,:) = 1 ! ag 19/03 648 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_bl, av_s_bl, & 649 & av_b_bl, av_u_bl, av_v_bl, jk_ext, av_dt_bl, & 650 & av_ds_bl, av_db_bl, av_du_bl, av_dv_bl ) 651 jk_nlev(:,:) = nmld(A2D(nn_hls-1)) - 1 652 jk_ext(:,:) = nbld(A2D(nn_hls-1)) - nmld(A2D(nn_hls-1)) + jk_ext(:,:) + 1 ! ag 19/03 653 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_ml, av_s_ml, & 654 & av_b_ml, av_u_ml, av_v_ml, jk_ext, av_dt_ml, & 655 & av_ds_ml, av_db_ml, av_du_ml, av_dv_ml ) 656 ! Velocity components in frame aligned with surface stress 657 CALL zdf_osm_velocity_rotation( av_u_ml, av_v_ml ) 658 CALL zdf_osm_velocity_rotation( av_du_ml, av_dv_ml ) 659 CALL zdf_osm_velocity_rotation( av_u_bl, av_v_bl ) 660 CALL zdf_osm_velocity_rotation( av_du_bl, av_dv_bl ) 661 ! 662 ! Determine the state of the OSBL, stable/unstable, shear/no shear 663 CALL zdf_osm_osbl_state( Kmm, zwb_ent, zwb_min, zshear, zhbl, & 664 & zhml, zdh ) 665 ! 589 666 IF ( ln_osm_mle ) THEN 590 ! Fox-Kemper Scheme 591 mld_prof = 4 592 DO_3D( 0, 0, 0, 0, 5, jpkm1 ) 593 IF ( hmle(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) mld_prof(ji,jj) = MIN(mbkt(ji,jj), jk) 667 ! Fox-Kemper Scheme 668 DO_2D_OVR( nn_hls, nn_hls, nn_hls, nn_hls ) 669 mld_prof(ji,jj) = 4 670 END_2D 671 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 5, jpkm1 ) 672 IF ( hmle(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) mld_prof(ji,jj) = MIN( mbkt(ji,jj), jk) 594 673 END_3D 595 jp_ext_mle(:,:) = 2 596 CALL zdf_osm_vertical_average(mld_prof, jp_ext_mle, zt_mle, zs_mle, zb_mle, zu_mle, zv_mle, zdt_mle, zds_mle, zdb_mle, zdu_mle, zdv_mle) 597 598 DO_2D( 0, 0, 0, 0 ) 599 zhmle(ji,jj) = gdepw(ji,jj,mld_prof(ji,jj),Kmm) 674 jk_nlev(:,:) = mld_prof(A2D(nn_hls-1)) 675 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_mle, av_s_mle, & 676 & av_b_mle, av_u_mle, av_v_mle ) 677 ! 678 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 679 zhmle(ji,jj) = gdepw(ji,jj,mld_prof(ji,jj),Kmm) 600 680 END_2D 601 602 !! External gradient 603 CALL zdf_osm_external_gradients( ibld+2, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) 604 CALL zdf_osm_zmld_horizontal_gradients( zmld, zdtdx, zdtdy, zdsdx, zdsdy, dbdx_mle, dbdy_mle, zdbds_mle ) 605 CALL zdf_osm_external_gradients( mld_prof, zdtdz_mle_ext, zdsdz_mle_ext, zdbdz_mle_ext ) 606 CALL zdf_osm_osbl_state_fk( lpyc, lflux, lmle, zwb_fk ) 607 CALL zdf_osm_mle_parameters( mld_prof, hmle, zhmle, zvel_mle, zdiff_mle ) 681 ! 682 ! Calculate fairly-well-mixed depth zmld & its index mld_prof + lateral zmld-averaged gradients 683 CALL zdf_osm_zmld_horizontal_gradients( Kmm, zmld, zdtdx, zdtdy, zdsdx, & 684 & zdsdy, zdbds_mle ) 685 ! Calculate max vertical FK flux zwb_fk & set logical descriptors 686 CALL zdf_osm_osbl_state_fk( Kmm, zwb_fk, zhbl, zhmle, zwb_ent, & 687 & zdbds_mle ) 688 ! Recalculate hmle, zmle, zvel_mle, zdiff_mle & redefine mld_proc to be index for new hmle 689 CALL zdf_osm_mle_parameters( Kmm, zmld, zhmle, zvel_mle, zdiff_mle, & 690 & zdbds_mle, zhbl, zwb0tot ) 608 691 ELSE ! ln_osm_mle 609 ! FK not selected, Boundary Layer only.610 lpyc(:,:) = .TRUE.611 lflux(:,:) = .FALSE.612 lmle(:,:) = .FALSE.613 DO_2D( 0, 0, 0, 0 )614 IF ( lconv(ji,jj) .AND. zdb_bl(ji,jj) < rn_osm_bl_thresh ) lpyc(ji,jj) = .FALSE.692 ! FK not selected, Boundary Layer only. 693 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 694 l_pyc(ji,jj) = .TRUE. 695 l_flux(ji,jj) = .FALSE. 696 l_mle(ji,jj) = .FALSE. 697 IF ( l_conv(ji,jj) .AND. av_db_bl(ji,jj) < rn_osm_bl_thresh ) l_pyc(ji,jj) = .FALSE. 615 698 END_2D 616 699 ENDIF ! ln_osm_mle 617 618 ! Test if pycnocline well resolved 619 DO_2D( 0, 0, 0, 0 ) 620 IF (lconv(ji,jj) ) THEN 621 ztmp = 0.2 * zhbl(ji,jj) / e3w(ji,jj,ibld(ji,jj),Kmm) 622 IF ( ztmp > 6 ) THEN 623 ! pycnocline well resolved 624 jp_ext(ji,jj) = 1 625 ELSE 626 ! pycnocline poorly resolved 627 jp_ext(ji,jj) = 0 628 ENDIF 629 ELSE 630 ! Stable conditions 631 jp_ext(ji,jj) = 0 632 ENDIF 633 END_2D 634 635 CALL zdf_osm_vertical_average(ibld, jp_ext, zt_bl, zs_bl, zb_bl, zu_bl, zv_bl, zdt_bl, zds_bl, zdb_bl, zdu_bl, zdv_bl ) 636 ! jp_ext = ibld-imld+1 637 CALL zdf_osm_vertical_average(imld-1, ibld-imld+1, zt_ml, zs_ml, zb_ml, zu_ml, zv_ml, zdt_ml, zds_ml, zdb_ml, zdu_ml, zdv_ml) 638 ! Rate of change of hbl 639 CALL zdf_osm_calculate_dhdt( zdhdt, zddhdt ) 640 DO_2D( 0, 0, 0, 0 ) 641 zhbl_t(ji,jj) = hbl(ji,jj) + (zdhdt(ji,jj) - ww(ji,jj,ibld(ji,jj)))* rn_Dt ! certainly need ww here, so subtract it 642 ! adjustment to represent limiting by ocean bottom 643 IF ( zhbl_t(ji,jj) >= gdepw(ji, jj, mbkt(ji,jj) + 1, Kmm ) ) THEN 644 zhbl_t(ji,jj) = MIN(zhbl_t(ji,jj), gdepw(ji,jj, mbkt(ji,jj) + 1, Kmm) - depth_tol)! ht(:,:)) 645 lpyc(ji,jj) = .FALSE. 646 ENDIF 647 END_2D 648 649 imld(:,:) = ibld(:,:) ! use imld to hold previous blayer index 650 ibld(:,:) = 4 651 652 DO_3D( 0, 0, 0, 0, 4, jpkm1 ) 700 ! 701 !! External gradient below BL needed both with and w/o FK 702 jk_ext(:,:) = nbld(A2D(nn_hls-1)) + 1 703 CALL zdf_osm_external_gradients( Kmm, jk_ext, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) ! ag 19/03 704 ! 705 ! Test if pycnocline well resolved 706 ! DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) Removed with ag 19/03 changes. A change in eddy diffusivity/viscosity 707 ! IF (l_conv(ji,jj) ) THEN should account for this. 708 ! ztmp = 0.2 * zhbl(ji,jj) / e3w(ji,jj,nbld(ji,jj),Kmm) 709 ! IF ( ztmp > 6 ) THEN 710 ! ! pycnocline well resolved 711 ! jk_ext(ji,jj) = 1 712 ! ELSE 713 ! ! pycnocline poorly resolved 714 ! jk_ext(ji,jj) = 0 715 ! ENDIF 716 ! ELSE 717 ! ! Stable conditions 718 ! jk_ext(ji,jj) = 0 719 ! ENDIF 720 ! END_2D 721 ! 722 ! Recalculate bl averages using jk_ext & ml averages .... note no rotation of u & v here.. 723 jk_nlev(:,:) = nbld(A2D(nn_hls-1)) 724 jk_ext(:,:) = 1 ! ag 19/03 725 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_bl, av_s_bl, & 726 & av_b_bl, av_u_bl, av_v_bl, jk_ext, av_dt_bl, & 727 & av_ds_bl, av_db_bl, av_du_bl, av_dv_bl ) 728 jk_nlev(:,:) = nmld(A2D(nn_hls-1)) - 1 729 jk_ext(:,:) = nbld(A2D(nn_hls-1)) - nmld(A2D(nn_hls-1)) + jk_ext(:,:) + 1 ! ag 19/03 730 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_ml, av_s_ml, & 731 & av_b_ml, av_u_ml, av_v_ml, jk_ext, av_dt_ml, & 732 & av_ds_ml, av_db_ml, av_du_ml, av_dv_ml ) ! ag 19/03 733 ! 734 ! Rate of change of hbl 735 CALL zdf_osm_calculate_dhdt( zdhdt, zhbl, zdh, zwb_ent, zwb_min, & 736 & zdbdz_bl_ext, zwb_fk_b, zwb_fk, zvel_mle ) 737 ! Test if surface boundary layer coupled to bottom 738 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 739 l_coup(ji,jj) = .FALSE. ! ag 19/03 740 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 741 ! Adjustment to represent limiting by ocean bottom 742 IF ( mbkt(ji,jj) > 2 ) THEN ! To ensure mbkt(ji,jj) - 2 > 0 so no incorrect array access 743 IF ( zhbl_t(ji,jj) > gdepw(ji, jj,mbkt(ji,jj)-2,Kmm) ) THEN 744 zhbl_t(ji,jj) = MIN( zhbl_t(ji,jj), gdepw(ji,jj,mbkt(ji,jj)-2,Kmm) ) ! ht(:,:)) 745 l_pyc(ji,jj) = .FALSE. 746 l_coup(ji,jj) = .TRUE. ! ag 19/03 747 END IF 748 END IF 749 END_2D 750 ! 751 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 752 nmld(ji,jj) = nbld(ji,jj) ! use nmld to hold previous blayer index 753 nbld(ji,jj) = 4 754 END_2D 755 ! 756 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 4, jpkm1 ) 653 757 IF ( zhbl_t(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) THEN 654 ibld(ji,jj) = jk 758 nbld(ji,jj) = jk 759 END IF 760 END_3D 761 ! 762 ! 763 ! Step through model levels taking account of buoyancy change to determine the effect on dhdt 764 ! 765 CALL zdf_osm_timestep_hbl( Kmm, zdhdt, zhbl, zhbl_t, zwb_ent, & 766 & zwb_fk_b ) 767 ! Is external level in bounds? 768 ! 769 ! Recalculate BL averages and differences using new BL depth 770 jk_nlev(:,:) = nbld(A2D(nn_hls-1)) 771 jk_ext(:,:) = 1 ! ag 19/03 772 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_bl, av_s_bl, & 773 & av_b_bl, av_u_bl, av_v_bl, jk_ext, av_dt_bl, & 774 & av_ds_bl, av_db_bl, av_du_bl, av_dv_bl ) 775 ! 776 CALL zdf_osm_pycnocline_thickness( Kmm, zdh, zhml, zdhdt, zhbl, & 777 & zwb_ent, zdbdz_bl_ext, zwb_fk_b ) 778 ! 779 ! Reset l_pyc before calculating terms in the flux-gradient relationship 780 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 781 IF ( av_db_bl(ji,jj) < rn_osm_bl_thresh .OR. nbld(ji,jj) >= mbkt(ji,jj) - 2 .OR. & 782 & nbld(ji,jj) - nmld(ji,jj) == 1 .OR. zdhdt(ji,jj) < 0.0_wp ) THEN ! ag 19/03 783 l_pyc(ji,jj) = .FALSE. ! ag 19/03 784 IF ( nbld(ji,jj) >= mbkt(ji,jj) -2 ) THEN 785 nmld(ji,jj) = nbld(ji,jj) - 1 ! ag 19/03 786 zdh(ji,jj) = gdepw(ji,jj,nbld(ji,jj),Kmm) - gdepw(ji,jj,nmld(ji,jj),Kmm) ! ag 19/03 787 zhml(ji,jj) = gdepw(ji,jj,nmld(ji,jj),Kmm) ! ag 19/03 788 dh(ji,jj) = zdh(ji,jj) ! ag 19/03 789 hml(ji,jj) = hbl(ji,jj) - dh(ji,jj) ! ag 19/03 790 ENDIF 791 ENDIF ! ag 19/03 792 END_2D 793 ! 794 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! Limit delta for shallow boundary layers for calculating 795 dstokes(ji,jj) = MIN ( dstokes(ji,jj), hbl(ji,jj) / 3.0_wp ) ! flux-gradient terms 796 END_2D 797 ! 798 ! 799 ! Average over the depth of the mixed layer in the convective boundary layer 800 ! jk_ext = nbld - nmld + 1 801 ! Recalculate ML averages and differences using new ML depth 802 jk_nlev(:,:) = nmld(A2D(nn_hls-1)) - 1 803 jk_ext(:,:) = nbld(A2D(nn_hls-1)) - nmld(A2D(nn_hls-1)) + jk_ext(:,:) + 1 ! ag 19/03 804 CALL zdf_osm_vertical_average( Kbb, Kmm, jk_nlev, av_t_ml, av_s_ml, & 805 & av_b_ml, av_u_ml, av_v_ml, jk_ext, av_dt_ml, & 806 & av_ds_ml, av_db_ml, av_du_ml, av_dv_ml ) 807 ! 808 jk_ext(:,:) = nbld(A2D(nn_hls-1)) + 1 809 CALL zdf_osm_external_gradients( Kmm, jk_ext, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) 810 ! Rotate mean currents and changes onto wind aligned co-ordinates 811 CALL zdf_osm_velocity_rotation( av_u_ml, av_v_ml ) 812 CALL zdf_osm_velocity_rotation( av_du_ml, av_dv_ml ) 813 CALL zdf_osm_velocity_rotation( av_u_bl, av_v_bl ) 814 CALL zdf_osm_velocity_rotation( av_du_bl, av_dv_bl ) 815 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 816 ! Eddy viscosity/diffusivity and non-gradient terms in the flux-gradient relationship 817 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 818 CALL zdf_osm_diffusivity_viscosity( Kbb, Kmm, zdiffut, zviscos, zhbl, & 819 & zhml, zdh, zdhdt, zshear, zwb_ent, & 820 & zwb_min ) 821 ! 822 ! Calculate non-gradient components of the flux-gradient relationships 823 ! -------------------------------------------------------------------- 824 jk_ext(:,:) = 1 ! ag 19/03 825 CALL zdf_osm_fgr_terms( Kmm, jk_ext, zhbl, zhml, zdh, & 826 & zdhdt, zshear, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext, & 827 & zdiffut, zviscos ) 828 ! 829 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 830 ! Need to put in code for contributions that are applied explicitly to 831 ! the prognostic variables 832 ! 1. Entrainment flux 833 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 834 ! 835 ! Rotate non-gradient velocity terms back to model reference frame 836 jk_nlev(:,:) = nbld(A2D(nn_hls-1)) 837 CALL zdf_osm_velocity_rotation( ghamu, ghamv, .FALSE., 2, jk_nlev ) 838 ! 839 ! KPP-style Ri# mixing 840 IF ( ln_kpprimix ) THEN 841 jkflt = jpk 842 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 843 IF ( nbld(ji,jj) < jkflt ) jkflt = nbld(ji,jj) 844 END_2D 845 DO jk = jkflt+1, jpkm1 846 ! Shear production at uw- and vw-points (energy conserving form) 847 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 848 z2du(ji,jj) = 0.5_wp * ( uu(ji,jj,jk-1,Kmm) - uu(ji,jj,jk,Kmm) ) * ( uu(ji,jj,jk-1,Kbb) - uu(ji,jj,jk,Kbb) ) * & 849 & wumask(ji,jj,jk) / ( e3uw(ji,jj,jk,Kmm) * e3uw(ji,jj,jk,Kbb) ) 850 z2dv(ji,jj) = 0.5_wp * ( vv(ji,jj,jk-1,Kmm) - vv(ji,jj,jk,Kmm) ) * ( vv(ji,jj,jk-1,Kbb) - vv(ji,jj,jk,Kbb) ) * & 851 & wvmask(ji,jj,jk) / ( e3vw(ji,jj,jk,Kmm) * e3vw(ji,jj,jk,Kbb) ) 852 END_2D 853 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 854 IF ( jk > nbld(ji,jj) ) THEN 855 ! Shear prod. at w-point weightened by mask 856 zesh2 = ( z2du(ji-1,jj) + z2du(ji,jj) ) / MAX( 1.0_wp , umask(ji-1,jj,jk) + umask(ji,jj,jk) ) + & 857 & ( z2dv(ji,jj-1) + z2dv(ji,jj) ) / MAX( 1.0_wp , vmask(ji,jj-1,jk) + vmask(ji,jj,jk) ) 858 ! Local Richardson number 859 zri = MAX( rn2b(ji,jj,jk), 0.0_wp ) / MAX( zesh2, epsln ) 860 zfri = MIN( zri / rn_riinfty, 1.0_wp ) 861 zfri = ( 1.0_wp - zfri * zfri ) 862 zrimix = zfri * zfri * zfri * wmask(ji, jj, jk) 863 zdiffut(ji,jj,jk) = MAX( zdiffut(ji,jj,jk), zrimix*rn_difri ) 864 zviscos(ji,jj,jk) = MAX( zviscos(ji,jj,jk), zrimix*rn_difri ) 865 END IF 866 END_2D 867 END DO 868 END IF ! ln_kpprimix = .true. 869 ! 870 ! KPP-style set diffusivity large if unstable below BL 871 IF ( ln_convmix) THEN 872 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 873 DO jk = nbld(ji,jj) + 1, jpkm1 874 IF ( MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1e-12_wp ) zdiffut(ji,jj,jk) = MAX( rn_difconv, zdiffut(ji,jj,jk) ) 875 END DO 876 END_2D 877 END IF ! ln_convmix = .true. 878 ! 879 IF ( ln_osm_mle ) THEN ! Set up diffusivity and non-gradient mixing 880 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 881 IF ( l_flux(ji,jj) ) THEN ! MLE mixing extends below boundary layer 882 ! Calculate MLE flux contribution from surface fluxes 883 DO jk = 1, nbld(ji,jj) 884 znd = gdepw(ji,jj,jk,Kmm) / MAX( zhbl(ji,jj), epsln ) 885 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) - ( swth0(ji,jj) - zrad0(ji,jj) + zradh(ji,jj) ) * ( 1.0_wp - znd ) 886 ghams(ji,jj,jk) = ghams(ji,jj,jk) - sws0(ji,jj) * ( 1.0_wp - znd ) 887 END DO 888 DO jk = 1, mld_prof(ji,jj) 889 znd = gdepw(ji,jj,jk,Kmm) / MAX( zhmle(ji,jj), epsln ) 890 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + ( swth0(ji,jj) - zrad0(ji,jj) + zradh(ji,jj) ) * ( 1.0_wp - znd ) 891 ghams(ji,jj,jk) = ghams(ji,jj,jk) + sws0(ji,jj) * ( 1.0_wp -znd ) 892 END DO 893 ! Viscosity for MLEs 894 DO jk = 1, mld_prof(ji,jj) 895 znd = -1.0_wp * gdepw(ji,jj,jk,Kmm) / MAX( zhmle(ji,jj), epsln ) 896 zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) + zdiff_mle(ji,jj) * ( 1.0_wp - ( 2.0_wp * znd + 1.0_wp )**2 ) * & 897 & ( 1.0_wp + 5.0_wp / 21.0_wp * ( 2.0_wp * znd + 1.0_wp )**2 ) 898 END DO 899 ELSE ! Surface transports limited to OSBL 900 ! Viscosity for MLEs 901 DO jk = 1, mld_prof(ji,jj) 902 znd = -1.0_wp * gdepw(ji,jj,jk,Kmm) / MAX( zhmle(ji,jj), epsln ) 903 zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) + zdiff_mle(ji,jj) * ( 1.0_wp - ( 2.0_wp * znd + 1.0_wp )**2 ) * & 904 & ( 1.0_wp + 5.0_wp / 21.0_wp * ( 2.0_wp * znd + 1.0_wp )**2 ) 905 END DO 906 END IF 907 END_2D 908 ENDIF 909 ! 910 ! Lateral boundary conditions on zvicos (sign unchanged), needed to caclulate viscosities on u and v grids 911 ! CALL lbc_lnk( 'zdfosm', zviscos(:,:,:), 'W', 1.0_wp ) 912 ! GN 25/8: need to change tmask --> wmask 913 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 914 p_avt(ji,jj,jk) = MAX( zdiffut(ji,jj,jk), avtb(jk) ) * tmask(ji,jj,jk) 915 p_avm(ji,jj,jk) = MAX( zviscos(ji,jj,jk), avmb(jk) ) * tmask(ji,jj,jk) 916 END_3D 917 ! 918 IF ( ln_dia_osm ) THEN 919 SELECT CASE (nn_osm_wave) 920 ! Stokes drift set by assumimg onstant La#=0.3 (=0) or Pierson-Moskovitz spectrum (=1) 921 CASE(0:1) 922 CALL zdf_osm_iomput( "us_x", tmask(A2D(0),1) * sustke(A2D(0)) * scos_wind(A2D(0)) ) ! x surface Stokes drift 923 CALL zdf_osm_iomput( "us_y", tmask(A2D(0),1) * sustke(A2D(0)) * scos_wind(A2D(0)) ) ! y surface Stokes drift 924 CALL zdf_osm_iomput( "wind_wave_abs_power", 1000.0_wp * rho0 * tmask(A2D(0),1) * sustar(A2D(0))**2 * sustke(A2D(0)) ) 925 ! Stokes drift read in from sbcwave (=2). 926 CASE(2:3) 927 CALL zdf_osm_iomput( "us_x", ut0sd(A2D(0)) * umask(A2D(0),1) ) ! x surface Stokes drift 928 CALL zdf_osm_iomput( "us_y", vt0sd(A2D(0)) * vmask(A2D(0),1) ) ! y surface Stokes drift 929 CALL zdf_osm_iomput( "wmp", wmp(A2D(0)) * tmask(A2D(0),1) ) ! Wave mean period 930 CALL zdf_osm_iomput( "hsw", hsw(A2D(0)) * tmask(A2D(0),1) ) ! Significant wave height 931 CALL zdf_osm_iomput( "wmp_NP", ( 2.0_wp * rpi * 1.026_wp / ( 0.877_wp * grav ) ) * & ! Wave mean period from NP 932 & wndm(A2D(0)) * tmask(A2D(0),1) ) ! spectrum 933 CALL zdf_osm_iomput( "hsw_NP", ( 0.22_wp / grav ) * wndm(A2D(0))**2 * tmask(A2D(0),1) ) ! Significant wave height from 934 ! ! NP spectrum 935 CALL zdf_osm_iomput( "wndm", wndm(A2D(0)) * tmask(A2D(0),1) ) ! U_10 936 CALL zdf_osm_iomput( "wind_wave_abs_power", 1000.0_wp * rho0 * tmask(A2D(0),1) * sustar(A2D(0))**2 * & 937 & SQRT( ut0sd(A2D(0))**2 + vt0sd(A2D(0))**2 ) ) 938 END SELECT 939 CALL zdf_osm_iomput( "zwth0", tmask(A2D(0),1) * swth0(A2D(0)) ) ! <Tw_0> 940 CALL zdf_osm_iomput( "zws0", tmask(A2D(0),1) * sws0(A2D(0)) ) ! <Sw_0> 941 CALL zdf_osm_iomput( "zwb0", tmask(A2D(0),1) * swb0(A2D(0)) ) ! <Sw_0> 942 CALL zdf_osm_iomput( "zwbav", tmask(A2D(0),1) * swth0(A2D(0)) ) ! Upward BL-avged turb buoyancy flux 943 CALL zdf_osm_iomput( "ibld", tmask(A2D(0),1) * nbld(A2D(0)) ) ! Boundary-layer max k 944 CALL zdf_osm_iomput( "zdt_bl", tmask(A2D(0),1) * av_dt_bl(A2D(0)) ) ! dt at ml base 945 CALL zdf_osm_iomput( "zds_bl", tmask(A2D(0),1) * av_ds_bl(A2D(0)) ) ! ds at ml base 946 CALL zdf_osm_iomput( "zdb_bl", tmask(A2D(0),1) * av_db_bl(A2D(0)) ) ! db at ml base 947 CALL zdf_osm_iomput( "zdu_bl", tmask(A2D(0),1) * av_du_bl(A2D(0)) ) ! du at ml base 948 CALL zdf_osm_iomput( "zdv_bl", tmask(A2D(0),1) * av_dv_bl(A2D(0)) ) ! dv at ml base 949 CALL zdf_osm_iomput( "dh", tmask(A2D(0),1) * dh(A2D(0)) ) ! Initial boundary-layer depth 950 CALL zdf_osm_iomput( "hml", tmask(A2D(0),1) * hml(A2D(0)) ) ! Initial boundary-layer depth 951 CALL zdf_osm_iomput( "zdt_ml", tmask(A2D(0),1) * av_dt_ml(A2D(0)) ) ! dt at ml base 952 CALL zdf_osm_iomput( "zds_ml", tmask(A2D(0),1) * av_ds_ml(A2D(0)) ) ! ds at ml base 953 CALL zdf_osm_iomput( "zdb_ml", tmask(A2D(0),1) * av_db_ml(A2D(0)) ) ! db at ml base 954 CALL zdf_osm_iomput( "dstokes", tmask(A2D(0),1) * dstokes(A2D(0)) ) ! Stokes drift penetration depth 955 CALL zdf_osm_iomput( "zustke", tmask(A2D(0),1) * sustke(A2D(0)) ) ! Stokes drift magnitude at T-points 956 CALL zdf_osm_iomput( "zwstrc", tmask(A2D(0),1) * swstrc(A2D(0)) ) ! Convective velocity scale 957 CALL zdf_osm_iomput( "zwstrl", tmask(A2D(0),1) * swstrl(A2D(0)) ) ! Langmuir velocity scale 958 CALL zdf_osm_iomput( "zustar", tmask(A2D(0),1) * sustar(A2D(0)) ) ! Friction velocity scale 959 CALL zdf_osm_iomput( "zvstr", tmask(A2D(0),1) * svstr(A2D(0)) ) ! Mixed velocity scale 960 CALL zdf_osm_iomput( "zla", tmask(A2D(0),1) * sla(A2D(0)) ) ! Langmuir # 961 CALL zdf_osm_iomput( "wind_power", 1000.0_wp * rho0 * tmask(A2D(0),1) * & ! BL depth internal to zdf_osm routine 962 & sustar(A2D(0))**3 ) 963 CALL zdf_osm_iomput( "wind_wave_power", 1000.0_wp * rho0 * tmask(A2D(0),1) * & 964 & sustar(A2D(0))**2 * sustke(A2D(0)) ) 965 CALL zdf_osm_iomput( "zhbl", tmask(A2D(0),1) * zhbl(A2D(0)) ) ! BL depth internal to zdf_osm routine 966 CALL zdf_osm_iomput( "zhml", tmask(A2D(0),1) * zhml(A2D(0)) ) ! ML depth internal to zdf_osm routine 967 CALL zdf_osm_iomput( "imld", tmask(A2D(0),1) * nmld(A2D(0)) ) ! Index for ML depth internal to zdf_osm 968 ! ! routine 969 CALL zdf_osm_iomput( "jp_ext", tmask(A2D(0),1) * jk_ext(A2D(0)) ) ! =1 if pycnocline resolved internal to 970 ! ! zdf_osm routine 971 CALL zdf_osm_iomput( "j_ddh", tmask(A2D(0),1) * n_ddh(A2D(0)) ) ! Index forpyc thicknessh internal to 972 ! ! zdf_osm routine 973 CALL zdf_osm_iomput( "zshear", tmask(A2D(0),1) * zshear(A2D(0)) ) ! Shear production of TKE internal to 974 ! ! zdf_osm routine 975 CALL zdf_osm_iomput( "zdh", tmask(A2D(0),1) * zdh(A2D(0)) ) ! Pyc thicknessh internal to zdf_osm 976 ! ! routine 977 CALL zdf_osm_iomput( "zhol", tmask(A2D(0),1) * shol(A2D(0)) ) ! ML depth internal to zdf_osm routine 978 CALL zdf_osm_iomput( "zwb_ent", tmask(A2D(0),1) * zwb_ent(A2D(0)) ) ! Upward turb buoyancy entrainment flux 979 CALL zdf_osm_iomput( "zt_ml", tmask(A2D(0),1) * av_t_ml(A2D(0)) ) ! Average T in ML 980 CALL zdf_osm_iomput( "zmld", tmask(A2D(0),1) * zmld(A2D(0)) ) ! FK target layer depth 981 CALL zdf_osm_iomput( "zwb_fk", tmask(A2D(0),1) * zwb_fk(A2D(0)) ) ! FK b flux 982 CALL zdf_osm_iomput( "zwb_fk_b", tmask(A2D(0),1) * zwb_fk_b(A2D(0)) ) ! FK b flux averaged over ML 983 CALL zdf_osm_iomput( "mld_prof", tmask(A2D(0),1) * mld_prof(A2D(0)) ) ! FK layer max k 984 CALL zdf_osm_iomput( "zdtdx", umask(A2D(0),1) * zdtdx(A2D(0)) ) ! FK dtdx at u-pt 985 CALL zdf_osm_iomput( "zdtdy", vmask(A2D(0),1) * zdtdy(A2D(0)) ) ! FK dtdy at v-pt 986 CALL zdf_osm_iomput( "zdsdx", umask(A2D(0),1) * zdsdx(A2D(0)) ) ! FK dtdx at u-pt 987 CALL zdf_osm_iomput( "zdsdy", vmask(A2D(0),1) * zdsdy(A2D(0)) ) ! FK dsdy at v-pt 988 CALL zdf_osm_iomput( "dbdx_mle", umask(A2D(0),1) * dbdx_mle(A2D(0)) ) ! FK dbdx at u-pt 989 CALL zdf_osm_iomput( "dbdy_mle", vmask(A2D(0),1) * dbdy_mle(A2D(0)) ) ! FK dbdy at v-pt 990 CALL zdf_osm_iomput( "zdiff_mle", tmask(A2D(0),1) * zdiff_mle(A2D(0)) ) ! FK diff in MLE at t-pt 991 CALL zdf_osm_iomput( "zvel_mle", tmask(A2D(0),1) * zdiff_mle(A2D(0)) ) ! FK diff in MLE at t-pt 992 END IF 993 ! 994 ! Lateral boundary conditions on ghamu and ghamv, currently on W-grid (sign unchanged), needed to caclulate gham[uv] on u and 995 ! v grids 996 IF ( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Finalise ghamu, ghamv, hbl, and hmle only after full domain has been 997 ! ! processed 998 IF ( nn_hls == 1 ) CALL lbc_lnk( 'zdfosm', ghamu, 'W', 1.0_wp, & 999 & ghamv, 'W', 1.0_wp ) 1000 DO jk = 2, jpkm1 1001 DO jj = Njs0, Nje0 1002 DO ji = Nis0, Nie0 1003 ghamu(ji,jj,jk) = ( ghamu(ji,jj,jk) + ghamu(ji+1,jj,jk) ) / & 1004 & MAX( 1.0_wp, tmask(ji,jj,jk) + tmask (ji+1,jj,jk) ) * umask(ji,jj,jk) 1005 ghamv(ji,jj,jk) = ( ghamv(ji,jj,jk) + ghamv(ji,jj+1,jk) ) / & 1006 & MAX( 1.0_wp, tmask(ji,jj,jk) + tmask (ji,jj+1,jk) ) * vmask(ji,jj,jk) 1007 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) * tmask(ji,jj,jk) 1008 ghams(ji,jj,jk) = ghams(ji,jj,jk) * tmask(ji,jj,jk) 1009 END DO 1010 END DO 1011 END DO 1012 ! Lateral boundary conditions on final outputs for hbl, on T-grid (sign unchanged) 1013 CALL lbc_lnk( 'zdfosm', hbl, 'T', 1.0_wp, & 1014 & hmle, 'T', 1.0_wp ) 1015 ! 1016 CALL zdf_osm_iomput( "ghamt", tmask * ghamt ) ! <Tw_NL> 1017 CALL zdf_osm_iomput( "ghams", tmask * ghams ) ! <Sw_NL> 1018 CALL zdf_osm_iomput( "ghamu", umask * ghamu ) ! <uw_NL> 1019 CALL zdf_osm_iomput( "ghamv", vmask * ghamv ) ! <vw_NL> 1020 CALL zdf_osm_iomput( "hbl", tmask(:,:,1) * hbl ) ! Boundary-layer depth 1021 CALL zdf_osm_iomput( "hmle", tmask(:,:,1) * hmle ) ! FK layer depth 1022 END IF 1023 ! 1024 END SUBROUTINE zdf_osm 1025 1026 SUBROUTINE zdf_osm_vertical_average( Kbb, Kmm, knlev, pt, ps, & 1027 & pb, pu, pv, kp_ext, pdt, & 1028 & pds, pdb, pdu, pdv ) 1029 !!--------------------------------------------------------------------- 1030 !! *** ROUTINE zdf_vertical_average *** 1031 !! 1032 !! ** Purpose : Determines vertical averages from surface to knlev, 1033 !! and optionally the differences between these vertical 1034 !! averages and values at an external level 1035 !! 1036 !! ** Method : Averages are calculated from the surface to knlev. 1037 !! The external level used to calculate differences is 1038 !! knlev+kp_ext 1039 !!---------------------------------------------------------------------- 1040 INTEGER, INTENT(in ) :: Kbb, Kmm ! Ocean time-level indices 1041 INTEGER, DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: knlev ! Number of levels to average over. 1042 REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: pt, ps ! Average temperature and salinity 1043 REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: pb ! Average buoyancy 1044 REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: pu, pv ! Average current components 1045 INTEGER, DIMENSION(A2D(nn_hls-1)), INTENT(in ), OPTIONAL :: kp_ext ! External-level offsets 1046 REAL(wp), DIMENSION(jpi,jpj), INTENT( out), OPTIONAL :: pdt ! Difference between average temperature, 1047 REAL(wp), DIMENSION(jpi,jpj), INTENT( out), OPTIONAL :: pds ! salinity, 1048 REAL(wp), DIMENSION(jpi,jpj), INTENT( out), OPTIONAL :: pdb ! buoyancy, and 1049 REAL(wp), DIMENSION(jpi,jpj), INTENT( out), OPTIONAL :: pdu, pdv ! velocity components and the OSBL 1050 !! 1051 INTEGER :: jk, jkflt, jkmax, ji, jj ! Loop indices 1052 INTEGER :: ibld_ext ! External-layer index 1053 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zthick ! Layer thickness 1054 REAL(wp) :: zthermal ! Thermal expansion coefficient 1055 REAL(wp) :: zbeta ! Haline contraction coefficient 1056 !!---------------------------------------------------------------------- 1057 ! 1058 ! Averages over depth of boundary layer 1059 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1060 pt(ji,jj) = 0.0_wp 1061 ps(ji,jj) = 0.0_wp 1062 pu(ji,jj) = 0.0_wp 1063 pv(ji,jj) = 0.0_wp 1064 END_2D 1065 zthick(:,:) = epsln 1066 jkflt = jpk 1067 jkmax = 0 1068 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1069 IF ( knlev(ji,jj) < jkflt ) jkflt = knlev(ji,jj) 1070 IF ( knlev(ji,jj) > jkmax ) jkmax = knlev(ji,jj) 1071 END_2D 1072 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jkflt ) ! Upper, flat part of layer 1073 zthick(ji,jj) = zthick(ji,jj) + e3t(ji,jj,jk,Kmm) 1074 pt(ji,jj) = pt(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_tem,Kmm) 1075 ps(ji,jj) = ps(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_sal,Kmm) 1076 pu(ji,jj) = pu(ji,jj) + e3t(ji,jj,jk,Kmm) * & 1077 & ( uu(ji,jj,jk,Kbb) + uu(ji - 1,jj,jk,Kbb) ) / & 1078 & MAX( 1.0_wp , umask(ji,jj,jk) + umask(ji - 1,jj,jk) ) 1079 pv(ji,jj) = pv(ji,jj) + e3t(ji,jj,jk,Kmm) * & 1080 & ( vv(ji,jj,jk,Kbb) + vv(ji,jj - 1,jk,Kbb) ) / & 1081 & MAX( 1.0_wp , vmask(ji,jj,jk) + vmask(ji,jj - 1,jk) ) 1082 END_3D 1083 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jkflt+1, jkmax ) ! Lower, non-flat part of layer 1084 IF ( knlev(ji,jj) >= jk ) THEN 1085 zthick(ji,jj) = zthick(ji,jj) + e3t(ji,jj,jk,Kmm) 1086 pt(ji,jj) = pt(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_tem,Kmm) 1087 ps(ji,jj) = ps(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_sal,Kmm) 1088 pu(ji,jj) = pu(ji,jj) + e3t(ji,jj,jk,Kmm) * & 1089 & ( uu(ji,jj,jk,Kbb) + uu(ji - 1,jj,jk,Kbb) ) / & 1090 & MAX( 1.0_wp , umask(ji,jj,jk) + umask(ji - 1,jj,jk) ) 1091 pv(ji,jj) = pv(ji,jj) + e3t(ji,jj,jk,Kmm) * & 1092 & ( vv(ji,jj,jk,Kbb) + vv(ji,jj - 1,jk,Kbb) ) / & 1093 & MAX( 1.0_wp , vmask(ji,jj,jk) + vmask(ji,jj - 1,jk) ) 1094 END IF 1095 END_3D 1096 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1097 pt(ji,jj) = pt(ji,jj) / zthick(ji,jj) 1098 ps(ji,jj) = ps(ji,jj) / zthick(ji,jj) 1099 pu(ji,jj) = pu(ji,jj) / zthick(ji,jj) 1100 pv(ji,jj) = pv(ji,jj) / zthick(ji,jj) 1101 zthermal = rab_n(ji,jj,1,jp_tem) ! ideally use nbld not 1?? 1102 zbeta = rab_n(ji,jj,1,jp_sal) 1103 pb(ji,jj) = grav * zthermal * pt(ji,jj) - grav * zbeta * ps(ji,jj) 1104 END_2D 1105 ! 1106 ! Differences between vertical averages and values at an external layer 1107 IF ( PRESENT( kp_ext ) ) THEN 1108 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1109 ibld_ext = knlev(ji,jj) + kp_ext(ji,jj) 1110 IF ( ibld_ext <= mbkt(ji,jj)-1 ) THEN ! ag 09/03 1111 ! Two external levels are available 1112 pdt(ji,jj) = pt(ji,jj) - ts(ji,jj,ibld_ext,jp_tem,Kmm) 1113 pds(ji,jj) = ps(ji,jj) - ts(ji,jj,ibld_ext,jp_sal,Kmm) 1114 pdu(ji,jj) = pu(ji,jj) - ( uu(ji,jj,ibld_ext,Kbb) + uu(ji-1,jj,ibld_ext,Kbb ) ) / & 1115 & MAX(1.0_wp , umask(ji,jj,ibld_ext ) + umask(ji-1,jj,ibld_ext ) ) 1116 pdv(ji,jj) = pv(ji,jj) - ( vv(ji,jj,ibld_ext,Kbb) + vv(ji,jj-1,ibld_ext,Kbb ) ) / & 1117 & MAX(1.0_wp , vmask(ji,jj,ibld_ext ) + vmask(ji,jj-1,ibld_ext ) ) 1118 zthermal = rab_n(ji,jj,1,jp_tem) ! ideally use nbld not 1?? 1119 zbeta = rab_n(ji,jj,1,jp_sal) 1120 pdb(ji,jj) = grav * zthermal * pdt(ji,jj) - grav * zbeta * pds(ji,jj) 1121 ELSE 1122 pdt(ji,jj) = 0.0_wp 1123 pds(ji,jj) = 0.0_wp 1124 pdu(ji,jj) = 0.0_wp 1125 pdv(ji,jj) = 0.0_wp 1126 pdb(ji,jj) = 0.0_wp 1127 ENDIF 1128 END_2D 1129 END IF 1130 ! 1131 END SUBROUTINE zdf_osm_vertical_average 1132 1133 SUBROUTINE zdf_osm_velocity_rotation_2d( pu, pv, fwd ) 1134 !!--------------------------------------------------------------------- 1135 !! *** ROUTINE zdf_velocity_rotation_2d *** 1136 !! 1137 !! ** Purpose : Rotates frame of reference of velocity components pu and 1138 !! pv (2d) 1139 !! 1140 !! ** Method : The velocity components are rotated into (fwd=.TRUE.) or 1141 !! from (fwd=.FALSE.) the frame specified by scos_wind and 1142 !! ssin_wind 1143 !! 1144 !!---------------------------------------------------------------------- 1145 REAL(wp), INTENT(inout), DIMENSION(jpi,jpj) :: pu, pv ! Components of current 1146 LOGICAL, OPTIONAL, INTENT(in ) :: fwd ! Forward (default) or reverse rotation 1147 !! 1148 INTEGER :: ji, jj ! Loop indices 1149 REAL(wp) :: ztmp, zfwd ! Auxiliary variables 1150 !!---------------------------------------------------------------------- 1151 ! 1152 zfwd = 1.0_wp 1153 IF( PRESENT(fwd) .AND. ( .NOT. fwd ) ) zfwd = -1.0_wp 1154 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1155 ztmp = pu(ji,jj) 1156 pu(ji,jj) = pu(ji,jj) * scos_wind(ji,jj) + zfwd * pv(ji,jj) * ssin_wind(ji,jj) 1157 pv(ji,jj) = pv(ji,jj) * scos_wind(ji,jj) - zfwd * ztmp * ssin_wind(ji,jj) 1158 END_2D 1159 ! 1160 END SUBROUTINE zdf_osm_velocity_rotation_2d 1161 1162 SUBROUTINE zdf_osm_velocity_rotation_3d( pu, pv, fwd, ktop, knlev ) 1163 !!--------------------------------------------------------------------- 1164 !! *** ROUTINE zdf_velocity_rotation_3d *** 1165 !! 1166 !! ** Purpose : Rotates frame of reference of velocity components pu and 1167 !! pv (3d) 1168 !! 1169 !! ** Method : The velocity components are rotated into (fwd=.TRUE.) or 1170 !! from (fwd=.FALSE.) the frame specified by scos_wind and 1171 !! ssin_wind; optionally, the rotation can be restricted at 1172 !! each water column to span from the a minimum index ktop to 1173 !! the depth index specified in array knlev 1174 !! 1175 !!---------------------------------------------------------------------- 1176 REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) :: pu, pv ! Components of current 1177 LOGICAL, OPTIONAL, INTENT(in ) :: fwd ! Forward (default) or reverse rotation 1178 INTEGER, OPTIONAL, INTENT(in ) :: ktop ! Minimum depth index 1179 INTEGER, OPTIONAL, INTENT(in ), DIMENSION(A2D(nn_hls-1)) :: knlev ! Array of maximum depth indices 1180 !! 1181 INTEGER :: ji, jj, jk, jktop, jkmax ! Loop indices 1182 REAL(wp) :: ztmp, zfwd ! Auxiliary variables 1183 LOGICAL :: llkbot ! Auxiliary variable 1184 !!---------------------------------------------------------------------- 1185 ! 1186 zfwd = 1.0_wp 1187 IF( PRESENT(fwd) .AND. ( .NOT. fwd ) ) zfwd = -1.0_wp 1188 jktop = 1 1189 IF( PRESENT(ktop) ) jktop = ktop 1190 IF( PRESENT(knlev) ) THEN 1191 jkmax = 0 1192 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1193 IF ( knlev(ji,jj) > jkmax ) jkmax = knlev(ji,jj) 1194 END_2D 1195 llkbot = .FALSE. 1196 ELSE 1197 jkmax = jpk 1198 llkbot = .TRUE. 1199 END IF 1200 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jktop, jkmax ) 1201 IF ( llkbot .OR. knlev(ji,jj) >= jk ) THEN 1202 ztmp = pu(ji,jj,jk) 1203 pu(ji,jj,jk) = pu(ji,jj,jk) * scos_wind(ji,jj) + zfwd * pv(ji,jj,jk) * ssin_wind(ji,jj) 1204 pv(ji,jj,jk) = pv(ji,jj,jk) * scos_wind(ji,jj) - zfwd * ztmp * ssin_wind(ji,jj) 1205 END IF 1206 END_3D 1207 ! 1208 END SUBROUTINE zdf_osm_velocity_rotation_3d 1209 1210 SUBROUTINE zdf_osm_osbl_state( Kmm, pwb_ent, pwb_min, pshear, phbl, & 1211 & phml, pdh ) 1212 !!--------------------------------------------------------------------- 1213 !! *** ROUTINE zdf_osm_osbl_state *** 1214 !! 1215 !! ** Purpose : Determines the state of the OSBL, stable/unstable, 1216 !! shear/ noshear. Also determines shear production, 1217 !! entrainment buoyancy flux and interfacial Richardson 1218 !! number 1219 !! 1220 !! ** Method : 1221 !! 1222 !!---------------------------------------------------------------------- 1223 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1224 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pwb_ent ! Buoyancy fluxes at base 1225 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pwb_min ! of well-mixed layer 1226 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pshear ! Production of TKE due to shear across the pycnocline 1227 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 1228 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phml ! ML depth 1229 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdh ! Pycnocline depth 1230 !! 1231 INTEGER :: jj, ji ! Loop indices 1232 !! 1233 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zekman 1234 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zri_p, zri_b ! Richardson numbers 1235 REAL(wp) :: zshear_u, zshear_v, zwb_shr 1236 REAL(wp) :: zwcor, zrf_conv, zrf_shear, zrf_langmuir, zr_stokes 1237 !! 1238 REAL(wp), PARAMETER :: pp_a_shr = 0.4_wp, pp_b_shr = 6.5_wp, pp_a_wb_s = 0.8_wp 1239 REAL(wp), PARAMETER :: pp_alpha_c = 0.2_wp, pp_alpha_lc = 0.03_wp 1240 REAL(wp), PARAMETER :: pp_alpha_ls = 0.06_wp, pp_alpha_s = 0.15_wp 1241 REAL(wp), PARAMETER :: pp_ri_p_thresh = 27.0_wp 1242 REAL(wp), PARAMETER :: pp_ri_c = 0.25_wp 1243 REAL(wp), PARAMETER :: pp_ek = 4.0_wp 1244 REAL(wp), PARAMETER :: pp_large = -1e10_wp 1245 !!---------------------------------------------------------------------- 1246 ! 1247 ! Initialise arrays 1248 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1249 l_conv(ji,jj) = .FALSE. 1250 l_shear(ji,jj) = .FALSE. 1251 n_ddh(ji,jj) = 1 1252 END_2D 1253 ! Initialise INTENT( out) arrays 1254 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1255 pwb_ent(ji,jj) = pp_large 1256 pwb_min(ji,jj) = pp_large 1257 END_2D 1258 ! 1259 ! Determins stability and set flag l_conv 1260 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1261 IF ( shol(ji,jj) < 0.0_wp ) THEN 1262 l_conv(ji,jj) = .TRUE. 1263 ELSE 1264 l_conv(ji,jj) = .FALSE. 655 1265 ENDIF 656 END_3D 657 658 ! 659 ! Step through model levels taking account of buoyancy change to determine the effect on dhdt 660 ! 661 CALL zdf_osm_timestep_hbl( zdhdt ) 662 ! is external level in bounds? 663 664 CALL zdf_osm_vertical_average( ibld, jp_ext, zt_bl, zs_bl, zb_bl, zu_bl, zv_bl, zdt_bl, zds_bl, zdb_bl, zdu_bl, zdv_bl ) 665 ! 666 ! 667 ! Check to see if lpyc needs to be changed 668 669 CALL zdf_osm_pycnocline_thickness( dh, zdh ) 670 671 DO_2D( 0, 0, 0, 0 ) 672 IF ( zdb_bl(ji,jj) < rn_osm_bl_thresh .or. ibld(ji,jj) + jp_ext(ji,jj) >= mbkt(ji,jj) .or. ibld(ji,jj)-imld(ji,jj) == 1 ) lpyc(ji,jj) = .FALSE. 673 END_2D 674 675 dstokes(:,:) = MIN ( dstokes(:,:), hbl(:,:)/3. ) ! Limit delta for shallow boundary layers for calculating flux-gradient terms. 676 ! 677 ! Average over the depth of the mixed layer in the convective boundary layer 678 ! jp_ext = ibld - imld +1 679 CALL zdf_osm_vertical_average( imld-1, ibld-imld+1, zt_ml, zs_ml, zb_ml, zu_ml, zv_ml, zdt_ml, zds_ml, zdb_ml, zdu_ml, zdv_ml ) 680 ! rotate mean currents and changes onto wind align co-ordinates 681 ! 682 CALL zdf_osm_velocity_rotation( zcos_wind, zsin_wind, zu_ml, zv_ml, zdu_ml, zdv_ml ) 683 CALL zdf_osm_velocity_rotation( zcos_wind, zsin_wind, zu_bl, zv_bl, zdu_bl, zdv_bl ) 684 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 685 ! Pycnocline gradients for scalars and velocity 686 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 687 688 CALL zdf_osm_external_gradients( ibld+2, zdtdz_bl_ext, zdsdz_bl_ext, zdbdz_bl_ext ) 689 CALL zdf_osm_pycnocline_scalar_profiles( zdtdz_pyc, zdsdz_pyc, zdbdz_pyc, zalpha_pyc ) 690 CALL zdf_osm_pycnocline_shear_profiles( zdudz_pyc, zdvdz_pyc ) 691 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 692 ! Eddy viscosity/diffusivity and non-gradient terms in the flux-gradient relationship 693 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 694 CALL zdf_osm_diffusivity_viscosity( zdiffut, zviscos ) 695 696 ! 697 ! calculate non-gradient components of the flux-gradient relationships 698 ! 699 ! Stokes term in scalar flux, flux-gradient relationship 700 WHERE ( lconv ) 701 zsc_wth_1 = zwstrl**3 * zwth0 / ( zvstr**3 + 0.5 * zwstrc**3 + epsln) 702 ! 703 zsc_ws_1 = zwstrl**3 * zws0 / ( zvstr**3 + 0.5 * zwstrc**3 + epsln ) 704 ELSEWHERE 705 zsc_wth_1 = 2.0 * zwthav 706 ! 707 zsc_ws_1 = 2.0 * zwsav 708 ENDWHERE 709 710 711 DO_2D( 0, 0, 0, 0 ) 712 IF ( lconv(ji,jj) ) THEN 713 DO jk = 2, imld(ji,jj) 714 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 715 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 1.35 * EXP ( -zznd_d ) * ( 1.0 - EXP ( -2.0 * zznd_d ) ) * zsc_wth_1(ji,jj) 716 ! 717 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 1.35 * EXP ( -zznd_d ) * ( 1.0 - EXP ( -2.0 * zznd_d ) ) * zsc_ws_1(ji,jj) 718 END DO ! end jk loop 719 ELSE ! else for if (lconv) 720 ! Stable conditions 721 DO jk = 2, ibld(ji,jj) 722 zznd_d=gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 723 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 1.5 * EXP ( -0.9 * zznd_d ) & 724 & * ( 1.0 - EXP ( -4.0 * zznd_d ) ) * zsc_wth_1(ji,jj) 725 ! 726 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 1.5 * EXP ( -0.9 * zznd_d ) & 727 & * ( 1.0 - EXP ( -4.0 * zznd_d ) ) * zsc_ws_1(ji,jj) 728 END DO 729 ENDIF ! endif for check on lconv 730 731 END_2D 732 733 ! Stokes term in flux-gradient relationship (note in zsc_uw_n don't use zvstr since term needs to go to zero as zwstrl goes to zero) 734 WHERE ( lconv ) 735 zsc_uw_1 = ( zwstrl**3 + 0.5 * zwstrc**3 )**pthird * zustke / MAX( ( 1.0 - 1.0 * 6.5 * zla**(8.0/3.0) ), 0.2 ) 736 zsc_uw_2 = ( zwstrl**3 + 0.5 * zwstrc**3 )**pthird * zustke / MIN( zla**(8.0/3.0) + epsln, 0.12 ) 737 zsc_vw_1 = ff_t * zhml * zustke**3 * MIN( zla**(8.0/3.0), 0.12 ) / ( ( zvstr**3 + 0.5 * zwstrc**3 )**(2.0/3.0) + epsln ) 738 ELSEWHERE 739 zsc_uw_1 = zustar**2 740 zsc_vw_1 = ff_t * zhbl * zustke**3 * MIN( zla**(8.0/3.0), 0.12 ) / (zvstr**2 + epsln) 741 ENDWHERE 742 IF(ln_dia_osm) THEN 743 IF ( iom_use("ghamu_00") ) CALL iom_put( "ghamu_00", wmask*ghamu ) 744 IF ( iom_use("ghamv_00") ) CALL iom_put( "ghamv_00", wmask*ghamv ) 745 END IF 746 DO_2D( 0, 0, 0, 0 ) 747 IF ( lconv(ji,jj) ) THEN 748 DO jk = 2, imld(ji,jj) 749 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 750 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + ( -0.05 * EXP ( -0.4 * zznd_d ) * zsc_uw_1(ji,jj) & 751 & + 0.00125 * EXP ( - zznd_d ) * zsc_uw_2(ji,jj) ) & 752 & * ( 1.0 - EXP ( -2.0 * zznd_d ) ) 753 ! 754 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) - 0.65 * 0.15 * EXP ( - zznd_d ) & 755 & * ( 1.0 - EXP ( -2.0 * zznd_d ) ) * zsc_vw_1(ji,jj) 756 END DO ! end jk loop 757 ELSE 758 ! Stable conditions 759 DO jk = 2, ibld(ji,jj) ! corrected to ibld 760 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 761 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) - 0.75 * 1.3 * EXP ( -0.5 * zznd_d ) & 762 & * ( 1.0 - EXP ( -4.0 * zznd_d ) ) * zsc_uw_1(ji,jj) 763 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + 0._wp 764 END DO ! end jk loop 765 ENDIF 766 END_2D 767 768 ! Buoyancy term in flux-gradient relationship [note : includes ROI ratio (X0.3) and pressure (X0.5)] 769 770 WHERE ( lconv ) 771 zsc_wth_1 = zwbav * zwth0 * ( 1.0 + EXP ( 0.2 * zhol ) ) / ( zvstr**3 + 0.5 * zwstrc**3 + epsln ) 772 zsc_ws_1 = zwbav * zws0 * ( 1.0 + EXP ( 0.2 * zhol ) ) / ( zvstr**3 + 0.5 * zwstrc**3 + epsln ) 773 ELSEWHERE 774 zsc_wth_1 = 0._wp 775 zsc_ws_1 = 0._wp 776 ENDWHERE 777 778 DO_2D( 0, 0, 0, 0 ) 779 IF (lconv(ji,jj) ) THEN 780 DO jk = 2, imld(ji,jj) 781 zznd_ml = gdepw(ji,jj,jk,Kmm) / zhml(ji,jj) 782 ! calculate turbulent length scale 783 zl_c = 0.9 * ( 1.0 - EXP ( - 7.0 * ( zznd_ml - zznd_ml**3 / 3.0 ) ) ) & 784 & * ( 1.0 - EXP ( -15.0 * ( 1.1 - zznd_ml ) ) ) 785 zl_l = 2.0 * ( 1.0 - EXP ( - 2.0 * ( zznd_ml - zznd_ml**3 / 3.0 ) ) ) & 786 & * ( 1.0 - EXP ( - 5.0 * ( 1.0 - zznd_ml ) ) ) * ( 1.0 + dstokes(ji,jj) / zhml (ji,jj) ) 787 zl_eps = zl_l + ( zl_c - zl_l ) / ( 1.0 + EXP ( -3.0 * LOG10 ( - zhol(ji,jj) ) ) ) ** (3.0 / 2.0) 788 ! non-gradient buoyancy terms 789 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3 * 0.5 * zsc_wth_1(ji,jj) * zl_eps * zhml(ji,jj) / ( 0.15 + zznd_ml ) 790 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.3 * 0.5 * zsc_ws_1(ji,jj) * zl_eps * zhml(ji,jj) / ( 0.15 + zznd_ml ) 791 END DO 792 793 IF ( lpyc(ji,jj) ) THEN 794 ztau_sc_u(ji,jj) = zhml(ji,jj) / ( zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**pthird 795 ztau_sc_u(ji,jj) = ztau_sc_u(ji,jj) * ( 1.4 -0.4 / ( 1.0 + EXP( -3.5 * LOG10( -zhol(ji,jj) ) ) )**1.5 ) 796 zwth_ent = -0.003 * ( 0.15 * zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**pthird * ( 1.0 - zdh(ji,jj) /zhbl(ji,jj) ) * zdt_ml(ji,jj) 797 zws_ent = -0.003 * ( 0.15 * zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**pthird * ( 1.0 - zdh(ji,jj) /zhbl(ji,jj) ) * zds_ml(ji,jj) 798 ! Cubic profile used for buoyancy term 799 za_cubic = 0.755 * ztau_sc_u(ji,jj) 800 zb_cubic = 0.25 * ztau_sc_u(ji,jj) 801 DO jk = 2, ibld(ji,jj) 802 zznd_pyc = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / zdh(ji,jj) 803 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) - 0.045 * ( ( zwth_ent * zdbdz_pyc(ji,jj,jk) ) * ztau_sc_u(ji,jj)**2 ) * MAX( ( 1.75 * zznd_pyc -0.15 * zznd_pyc**2 - 0.2 * zznd_pyc**3 ), 0.0 ) 804 805 ghams(ji,jj,jk) = ghams(ji,jj,jk) - 0.045 * ( ( zws_ent * zdbdz_pyc(ji,jj,jk) ) * ztau_sc_u(ji,jj)**2 ) * MAX( ( 1.75 * zznd_pyc -0.15 * zznd_pyc**2 - 0.2 * zznd_pyc**3 ), 0.0 ) 806 END DO 807 ! 808 zbuoy_pyc_sc = zalpha_pyc(ji,jj) * zdb_ml(ji,jj) / zdh(ji,jj) + zdbdz_bl_ext(ji,jj) 809 zdelta_pyc = ( zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**pthird / SQRT( MAX( zbuoy_pyc_sc, ( zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**p2third / zdh(ji,jj)**2 ) ) 810 ! 811 zwt_pyc_sc_1 = 0.325 * ( zalpha_pyc(ji,jj) * zdt_ml(ji,jj) / zdh(ji,jj) + zdtdz_bl_ext(ji,jj) ) * zdelta_pyc**2 / zdh(ji,jj) 812 ! 813 zws_pyc_sc_1 = 0.325 * ( zalpha_pyc(ji,jj) * zds_ml(ji,jj) / zdh(ji,jj) + zdsdz_bl_ext(ji,jj) ) * zdelta_pyc**2 / zdh(ji,jj) 814 ! 815 zzeta_pyc = 0.15 - 0.175 / ( 1.0 + EXP( -3.5 * LOG10( -zhol(ji,jj) ) ) ) 816 DO jk = 2, ibld(ji,jj) 817 zznd_pyc = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / zdh(ji,jj) 818 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.05 * zwt_pyc_sc_1 * EXP( -0.25 * ( zznd_pyc / zzeta_pyc )**2 ) * zdh(ji,jj) / ( zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**pthird 819 ! 820 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.05 * zws_pyc_sc_1 * EXP( -0.25 * ( zznd_pyc / zzeta_pyc )**2 ) * zdh(ji,jj) / ( zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 )**pthird 821 END DO 822 ENDIF ! End of pycnocline 823 ELSE ! lconv test - stable conditions 824 DO jk = 2, ibld(ji,jj) 825 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + zsc_wth_1(ji,jj) 826 ghams(ji,jj,jk) = ghams(ji,jj,jk) + zsc_ws_1(ji,jj) 827 END DO 828 ENDIF 829 END_2D 830 831 WHERE ( lconv ) 832 zsc_uw_1 = -zwb0 * zustar**2 * zhml / ( zvstr**3 + 0.5 * zwstrc**3 + epsln ) 833 zsc_uw_2 = zwb0 * zustke * zhml / ( zvstr**3 + 0.5 * zwstrc**3 + epsln )**(2.0/3.0) 834 zsc_vw_1 = 0._wp 835 ELSEWHERE 836 zsc_uw_1 = 0._wp 837 zsc_vw_1 = 0._wp 838 ENDWHERE 839 840 DO_2D( 0, 0, 0, 0 ) 841 IF ( lconv(ji,jj) ) THEN 842 DO jk = 2 , imld(ji,jj) 843 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 844 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + 0.3 * 0.5 * ( zsc_uw_1(ji,jj) + 0.125 * EXP( -0.5 * zznd_d ) & 845 & * ( 1.0 - EXP( -0.5 * zznd_d ) ) & 846 & * zsc_uw_2(ji,jj) ) 847 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + zsc_vw_1(ji,jj) 848 END DO ! jk loop 849 ELSE 850 ! stable conditions 851 DO jk = 2, ibld(ji,jj) 852 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + zsc_uw_1(ji,jj) 853 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + zsc_vw_1(ji,jj) 854 END DO 855 ENDIF 856 END_2D 857 858 DO_2D( 0, 0, 0, 0 ) 859 IF ( lpyc(ji,jj) ) THEN 860 IF ( j_ddh(ji,jj) == 0 ) THEN 861 ! Place holding code. Parametrization needs checking for these conditions. 862 zomega = ( 0.15 * zwstrl(ji,jj)**3 + zwstrc(ji,jj)**3 + 4.75 * ( zshear(ji,jj)* zhbl(ji,jj) )**pthird )**pthird 863 zuw_bse = -0.0035 * zomega * ( 1.0 - zdh(ji,jj) / zhbl(ji,jj) ) * zdu_ml(ji,jj) 864 zvw_bse = -0.0075 * zomega * ( 1.0 - zdh(ji,jj) / zhbl(ji,jj) ) * zdv_ml(ji,jj) 865 ELSE 866 zomega = ( 0.15 * zwstrl(ji,jj)**3 + zwstrc(ji,jj)**3 + 4.75 * ( zshear(ji,jj)* zhbl(ji,jj) )**pthird )**pthird 867 zuw_bse = -0.0035 * zomega * ( 1.0 - zdh(ji,jj) / zhbl(ji,jj) ) * zdu_ml(ji,jj) 868 zvw_bse = -0.0075 * zomega * ( 1.0 - zdh(ji,jj) / zhbl(ji,jj) ) * zdv_ml(ji,jj) 869 ENDIF 870 zd_cubic = zdh(ji,jj) / zhbl(ji,jj) * zuw0(ji,jj) - ( 2.0 + zdh(ji,jj) /zhml(ji,jj) ) * zuw_bse 871 zc_cubic = zuw_bse - zd_cubic 872 ! need ztau_sc_u to be available. Change to array. 873 DO jk = imld(ji,jj), ibld(ji,jj) 874 zznd_pyc = - ( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / zdh(ji,jj) 875 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) - 0.045 * ztau_sc_u(ji,jj)**2 * ( zc_cubic * zznd_pyc**2 + zd_cubic * zznd_pyc**3 ) * ( 0.75 + 0.25 * zznd_pyc )**2 * zdbdz_pyc(ji,jj,jk) 876 END DO 877 zvw_max = 0.7 * ff_t(ji,jj) * ( zustke(ji,jj) * dstokes(ji,jj) + 0.75 * zustar(ji,jj) * zhml(ji,jj) ) 878 zd_cubic = zvw_max * zdh(ji,jj) / zhml(ji,jj) - ( 2.0 + zdh(ji,jj) /zhml(ji,jj) ) * zvw_bse 879 zc_cubic = zvw_bse - zd_cubic 880 DO jk = imld(ji,jj), ibld(ji,jj) 881 zznd_pyc = -( gdepw(ji,jj,jk,Kmm) -zhbl(ji,jj) ) / zdh(ji,jj) 882 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) - 0.045 * ztau_sc_u(ji,jj)**2 * ( zc_cubic * zznd_pyc**2 + zd_cubic * zznd_pyc**3 ) * ( 0.75 + 0.25 * zznd_pyc )**2 * zdbdz_pyc(ji,jj,jk) 883 END DO 884 ENDIF ! lpyc 885 END_2D 886 887 IF(ln_dia_osm) THEN 888 IF ( iom_use("ghamu_0") ) CALL iom_put( "ghamu_0", wmask*ghamu ) 889 IF ( iom_use("zsc_uw_1_0") ) CALL iom_put( "zsc_uw_1_0", tmask(:,:,1)*zsc_uw_1 ) 890 END IF 891 ! Transport term in flux-gradient relationship [note : includes ROI ratio (X0.3) ] 892 893 DO_2D( 1, 0, 1, 0 ) 894 895 IF ( lconv(ji,jj) ) THEN 896 zsc_wth_1(ji,jj) = zwth0(ji,jj) / ( 1.0 - 0.56 * EXP( zhol(ji,jj) ) ) 897 zsc_ws_1(ji,jj) = zws0(ji,jj) / (1.0 - 0.56 *EXP( zhol(ji,jj) ) ) 898 IF ( lpyc(ji,jj) ) THEN 899 ! Pycnocline scales 900 zsc_wth_pyc(ji,jj) = -0.2 * zwb0(ji,jj) * zdt_bl(ji,jj) / zdb_bl(ji,jj) 901 zsc_ws_pyc(ji,jj) = -0.2 * zwb0(ji,jj) * zds_bl(ji,jj) / zdb_bl(ji,jj) 902 ENDIF 903 ELSE 904 zsc_wth_1(ji,jj) = 2.0 * zwthav(ji,jj) 905 zsc_ws_1(ji,jj) = zws0(ji,jj) 906 ENDIF 907 END_2D 908 909 DO_2D( 0, 0, 0, 0 ) 910 IF ( lconv(ji,jj) ) THEN 911 DO jk = 2, imld(ji,jj) 912 zznd_ml=gdepw(ji,jj,jk,Kmm) / zhml(ji,jj) 913 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3 * zsc_wth_1(ji,jj) & 914 & * ( -2.0 + 2.75 * ( ( 1.0 + 0.6 * zznd_ml**4 ) & 915 & - EXP( - 6.0 * zznd_ml ) ) ) & 916 & * ( 1.0 - EXP( - 15.0 * ( 1.0 - zznd_ml ) ) ) 917 ! 918 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.3 * zsc_ws_1(ji,jj) & 919 & * ( -2.0 + 2.75 * ( ( 1.0 + 0.6 * zznd_ml**4 ) & 920 & - EXP( - 6.0 * zznd_ml ) ) ) & 921 & * ( 1.0 - EXP ( -15.0 * ( 1.0 - zznd_ml ) ) ) 922 END DO 923 ! 924 IF ( lpyc(ji,jj) ) THEN 925 ! pycnocline 926 DO jk = imld(ji,jj), ibld(ji,jj) 927 zznd_pyc = - ( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / zdh(ji,jj) 928 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 4.0 * zsc_wth_pyc(ji,jj) * ( 0.48 - EXP( -1.5 * ( zznd_pyc -0.3)**2 ) ) 929 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 4.0 * zsc_ws_pyc(ji,jj) * ( 0.48 - EXP( -1.5 * ( zznd_pyc -0.3)**2 ) ) 930 END DO 931 ENDIF 932 ELSE 933 IF( zdhdt(ji,jj) > 0. ) THEN 934 DO jk = 2, ibld(ji,jj) 935 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 936 znd = gdepw(ji,jj,jk,Kmm) / zhbl(ji,jj) 937 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3 * ( -4.06 * EXP( -2.0 * zznd_d ) * (1.0 - EXP( -4.0 * zznd_d ) ) + & 938 & 7.5 * EXP ( -10.0 * ( 0.95 - znd )**2 ) * ( 1.0 - znd ) ) * zsc_wth_1(ji,jj) 939 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.3 * ( -4.06 * EXP( -2.0 * zznd_d ) * (1.0 - EXP( -4.0 * zznd_d ) ) + & 940 & 7.5 * EXP ( -10.0 * ( 0.95 - znd )**2 ) * ( 1.0 - znd ) ) * zsc_ws_1(ji,jj) 941 END DO 1266 END_2D 1267 ! 1268 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1269 pshear(ji,jj) = 0.0_wp 1270 END_2D 1271 zekman(:,:) = EXP( -1.0_wp * pp_ek * ABS( ff_t(A2D(nn_hls-1)) ) * phbl(A2D(nn_hls-1)) / & 1272 & MAX( sustar(A2D(nn_hls-1)), 1.e-8 ) ) 1273 ! 1274 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1275 IF ( l_conv(ji,jj) ) THEN 1276 IF ( av_db_bl(ji,jj) > 0.0_wp ) THEN 1277 zri_p(ji,jj) = MAX ( SQRT( av_db_bl(ji,jj) * pdh(ji,jj) / MAX( av_du_bl(ji,jj)**2 + av_dv_bl(ji,jj)**2, & 1278 & 1e-8_wp ) ) * ( phbl(ji,jj) / pdh(ji,jj) ) * & 1279 & ( svstr(ji,jj) / MAX( sustar(ji,jj), 1e-6_wp ) )**2 / & 1280 & MAX( zekman(ji,jj), 1.0e-6_wp ), 5.0_wp ) 1281 IF ( ff_t(ji,jj) >= 0.0_wp ) THEN ! Northern hemisphere 1282 zri_b(ji,jj) = av_db_ml(ji,jj) * pdh(ji,jj) / ( MAX( av_du_ml(ji,jj), 1e-5_wp )**2 + & 1283 & MAX( -1.0_wp * av_dv_ml(ji,jj), 1e-5_wp)**2 ) 1284 ELSE ! Southern hemisphere 1285 zri_b(ji,jj) = av_db_ml(ji,jj) * pdh(ji,jj) / ( MAX( av_du_ml(ji,jj), 1e-5_wp )**2 + & 1286 & MAX( av_dv_ml(ji,jj), 1e-5_wp)**2 ) 1287 END IF 1288 pshear(ji,jj) = pp_a_shr * zekman(ji,jj) * & 1289 & ( MAX( sustar(ji,jj)**2 * av_du_ml(ji,jj) / phbl(ji,jj), 0.0_wp ) + & 1290 & pp_b_shr * MAX( -1.0_wp * ff_t(ji,jj) * sustke(ji,jj) * dstokes(ji,jj) * & 1291 & av_dv_ml(ji,jj) / phbl(ji,jj), 0.0_wp ) ) 1292 ! Stability dependence 1293 pshear(ji,jj) = pshear(ji,jj) * EXP( -0.75_wp * MAX( 0.0_wp, ( zri_b(ji,jj) - pp_ri_c ) / pp_ri_c ) ) 1294 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1295 ! Test ensures n_ddh=0 is not selected. Change to zri_p<27 when ! 1296 ! full code available ! 1297 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1298 IF ( pshear(ji,jj) > 1e-10 ) THEN 1299 IF ( zri_p(ji,jj) < pp_ri_p_thresh .AND. & 1300 & MIN( hu(ji,jj,Kmm), hu(ji-1,jj,Kmm), hv(ji,jj,Kmm), hv(ji,jj-1,Kmm) ) > 100.0_wp ) THEN 1301 ! Growing shear layer 1302 n_ddh(ji,jj) = 0 1303 l_shear(ji,jj) = .TRUE. 1304 ELSE 1305 n_ddh(ji,jj) = 1 1306 ! IF ( zri_b <= 1.5 .and. pshear(ji,jj) > 0._wp ) THEN 1307 ! Shear production large enough to determine layer charcteristics, but can't maintain a shear layer 1308 l_shear(ji,jj) = .TRUE. 1309 ! ELSE 1310 END IF 1311 ELSE 1312 n_ddh(ji,jj) = 2 1313 l_shear(ji,jj) = .FALSE. 1314 END IF 1315 ! Shear production may not be zero, but is small and doesn't determine characteristics of pycnocline 1316 ! pshear(ji,jj) = 0.5 * pshear(ji,jj) 1317 ! l_shear(ji,jj) = .FALSE. 1318 ! ENDIF 1319 ELSE ! av_db_bl test, note pshear set to zero 1320 n_ddh(ji,jj) = 2 1321 l_shear(ji,jj) = .FALSE. 942 1322 ENDIF 943 1323 ENDIF 944 END_2D 945 946 WHERE ( lconv ) 947 zsc_uw_1 = zustar**2 948 zsc_vw_1 = ff_t * zustke * zhml 949 ELSEWHERE 950 zsc_uw_1 = zustar**2 951 zsc_uw_2 = (2.25 - 3.0 * ( 1.0 - EXP( -1.25 * 2.0 ) ) ) * ( 1.0 - EXP( -4.0 * 2.0 ) ) * zsc_uw_1 952 zsc_vw_1 = ff_t * zustke * zhbl 953 zsc_vw_2 = -0.11 * SIN( 3.14159 * ( 2.0 + 0.4 ) ) * EXP(-( 1.5 + 2.0 )**2 ) * zsc_vw_1 954 ENDWHERE 955 956 DO_2D( 0, 0, 0, 0 ) 957 IF ( lconv(ji,jj) ) THEN 958 DO jk = 2, imld(ji,jj) 959 zznd_ml = gdepw(ji,jj,jk,Kmm) / zhml(ji,jj) 960 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 961 ghamu(ji,jj,jk) = ghamu(ji,jj,jk)& 962 & + 0.3 * ( -2.0 + 2.5 * ( 1.0 + 0.1 * zznd_ml**4 ) - EXP ( -8.0 * zznd_ml ) ) * zsc_uw_1(ji,jj) 1324 END_2D 1325 ! 1326 ! Calculate entrainment buoyancy flux due to surface fluxes. 1327 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1328 IF ( l_conv(ji,jj) ) THEN 1329 zwcor = ABS( ff_t(ji,jj) ) * phbl(ji,jj) + epsln 1330 zrf_conv = TANH( ( swstrc(ji,jj) / zwcor )**0.69_wp ) 1331 zrf_shear = TANH( ( sustar(ji,jj) / zwcor )**0.69_wp ) 1332 zrf_langmuir = TANH( ( swstrl(ji,jj) / zwcor )**0.69_wp ) 1333 IF ( nn_osm_SD_reduce > 0 ) THEN 1334 ! Effective Stokes drift already reduced from surface value 1335 zr_stokes = 1.0_wp 1336 ELSE 1337 ! Effective Stokes drift only reduced by factor rn_zdfodm_adjust_sd, 1338 ! requires further reduction where BL is deep 1339 zr_stokes = 1.0 - EXP( -25.0_wp * dstokes(ji,jj) / hbl(ji,jj) * ( 1.0_wp + 4.0_wp * dstokes(ji,jj) / hbl(ji,jj) ) ) 1340 END IF 1341 pwb_ent(ji,jj) = -2.0_wp * pp_alpha_c * zrf_conv * swbav(ji,jj) - & 1342 & pp_alpha_s * zrf_shear * sustar(ji,jj)**3 / phml(ji,jj) + & 1343 & zr_stokes * ( pp_alpha_s * EXP( -1.5_wp * sla(ji,jj) ) * zrf_shear * sustar(ji,jj)**3 - & 1344 & zrf_langmuir * pp_alpha_lc * swstrl(ji,jj)**3 ) / phml(ji,jj) 1345 ENDIF 1346 END_2D 1347 ! 1348 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1349 IF ( l_shear(ji,jj) ) THEN 1350 IF ( l_conv(ji,jj) ) THEN 1351 ! Unstable OSBL 1352 zwb_shr = -1.0_wp * pp_a_wb_s * zri_b(ji,jj) * pshear(ji,jj) 1353 IF ( n_ddh(ji,jj) == 0 ) THEN 1354 ! Developing shear layer, additional shear production possible. 1355 1356 ! pshear_u = MAX( zustar(ji,jj)**2 * MAX( av_du_ml(ji,jj), 0._wp ) / phbl(ji,jj), 0._wp ) 1357 ! pshear(ji,jj) = pshear(ji,jj) + pshear_u * ( 1.0 - MIN( zri_p(ji,jj) / pp_ri_p_thresh, 1.d0 )**2 ) 1358 ! pshear(ji,jj) = MIN( pshear(ji,jj), pshear_u ) 1359 1360 ! zwb_shr = zwb_shr - 0.25 * MAX ( pshear_u, 0._wp) * ( 1.0 - MIN( zri_p(ji,jj) / pp_ri_p_thresh, 1._wp )**2 ) 1361 ! zwb_shr = MAX( zwb_shr, -0.25 * pshear_u ) 1362 ENDIF 1363 pwb_ent(ji,jj) = pwb_ent(ji,jj) + zwb_shr 1364 ! pwb_min(ji,jj) = pwb_ent(ji,jj) + pdh(ji,jj) / phbl(ji,jj) * zwb0(ji,jj) 1365 ELSE ! IF ( l_conv ) THEN - ENDIF 1366 ! Stable OSBL - shear production not coded for first attempt. 1367 ENDIF ! l_conv 1368 END IF ! l_shear 1369 IF ( l_conv(ji,jj) ) THEN 1370 ! Unstable OSBL 1371 pwb_min(ji,jj) = pwb_ent(ji,jj) + pdh(ji,jj) / phbl(ji,jj) * 2.0_wp * swbav(ji,jj) 1372 END IF ! l_conv 1373 END_2D 1374 ! 1375 END SUBROUTINE zdf_osm_osbl_state 1376 1377 SUBROUTINE zdf_osm_external_gradients( Kmm, kbase, pdtdz, pdsdz, pdbdz ) 1378 !!--------------------------------------------------------------------- 1379 !! *** ROUTINE zdf_osm_external_gradients *** 1380 !! 1381 !! ** Purpose : Calculates the gradients below the OSBL 1382 !! 1383 !! ** Method : Uses nbld and ibld_ext to determine levels to calculate the gradient. 1384 !! 1385 !!---------------------------------------------------------------------- 1386 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1387 INTEGER, DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: kbase ! OSBL base layer index 1388 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pdtdz, pdsdz ! External gradients of temperature, salinity 1389 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pdbdz ! and buoyancy 1390 !! 1391 INTEGER :: ji, jj, jkb, jkb1 1392 REAL(wp) :: zthermal, zbeta 1393 !! 1394 REAL(wp), PARAMETER :: pp_large = -1e10_wp 1395 !!---------------------------------------------------------------------- 1396 ! 1397 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1398 pdtdz(ji,jj) = pp_large 1399 pdsdz(ji,jj) = pp_large 1400 pdbdz(ji,jj) = pp_large 1401 END_2D 1402 ! 1403 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1404 IF ( kbase(ji,jj)+1 < mbkt(ji,jj) ) THEN 1405 zthermal = rab_n(ji,jj,1,jp_tem) ! Ideally use nbld not 1?? 1406 zbeta = rab_n(ji,jj,1,jp_sal) 1407 jkb = kbase(ji,jj) 1408 jkb1 = MIN( jkb + 1, mbkt(ji,jj) ) 1409 pdtdz(ji,jj) = -1.0_wp * ( ts(ji,jj,jkb1,jp_tem,Kmm) - ts(ji,jj,jkb,jp_tem,Kmm ) ) / e3w(ji,jj,jkb1,Kmm) 1410 pdsdz(ji,jj) = -1.0_wp * ( ts(ji,jj,jkb1,jp_sal,Kmm) - ts(ji,jj,jkb,jp_sal,Kmm ) ) / e3w(ji,jj,jkb1,Kmm) 1411 pdbdz(ji,jj) = grav * zthermal * pdtdz(ji,jj) - grav * zbeta * pdsdz(ji,jj) 1412 ELSE 1413 pdtdz(ji,jj) = 0.0_wp 1414 pdsdz(ji,jj) = 0.0_wp 1415 pdbdz(ji,jj) = 0.0_wp 1416 END IF 1417 END_2D 1418 ! 1419 END SUBROUTINE zdf_osm_external_gradients 1420 1421 SUBROUTINE zdf_osm_calculate_dhdt( pdhdt, phbl, pdh, pwb_ent, pwb_min, & 1422 & pdbdz_bl_ext, pwb_fk_b, pwb_fk, pvel_mle ) 1423 !!--------------------------------------------------------------------- 1424 !! *** ROUTINE zdf_osm_calculate_dhdt *** 1425 !! 1426 !! ** Purpose : Calculates the rate at which hbl changes. 1427 !! 1428 !! ** Method : 1429 !! 1430 !!---------------------------------------------------------------------- 1431 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pdhdt ! Rate of change of hbl 1432 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 1433 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdh ! Pycnocline depth 1434 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_ent ! Buoyancy entrainment flux 1435 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_min 1436 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdbdz_bl_ext ! External buoyancy gradients 1437 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: pwb_fk_b ! MLE buoyancy flux averaged over OSBL 1438 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_fk ! Max MLE buoyancy flux 1439 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pvel_mle ! Vvelocity scale for dhdt with stable ML and FK 1440 !! 1441 INTEGER :: jj, ji 1442 REAL(wp) :: zgamma_b_nd, zgamma_dh_nd, zpert, zpsi, zari 1443 REAL(wp) :: zvel_max, zddhdt 1444 !! 1445 REAL(wp), PARAMETER :: pp_alpha_b = 0.3_wp 1446 REAL(wp), PARAMETER :: pp_ddh = 2.5_wp, pp_ddh_2 = 3.5_wp ! Also in pycnocline_depth 1447 REAL(wp), PARAMETER :: pp_large = -1e10_wp 1448 !!---------------------------------------------------------------------- 1449 ! 1450 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1451 pdhdt(ji,jj) = pp_large 1452 pwb_fk_b(ji,jj) = pp_large 1453 END_2D 1454 ! 1455 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1456 ! 1457 IF ( l_shear(ji,jj) ) THEN 1458 ! 1459 IF ( l_conv(ji,jj) ) THEN ! Convective 963 1460 ! 964 ghamv(ji,jj,jk) = ghamv(ji,jj,jk)& 965 & + 0.3 * 0.1 * ( EXP( -zznd_d ) + EXP( -5.0 * ( 1.0 - zznd_ml ) ) ) * zsc_vw_1(ji,jj) 966 END DO 967 ELSE 968 DO jk = 2, ibld(ji,jj) 969 znd = gdepw(ji,jj,jk,Kmm) / zhbl(ji,jj) 970 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 971 IF ( zznd_d <= 2.0 ) THEN 972 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + 0.5 * 0.3 & 973 &* ( 2.25 - 3.0 * ( 1.0 - EXP( - 1.25 * zznd_d ) ) * ( 1.0 - EXP( -2.0 * zznd_d ) ) ) * zsc_uw_1(ji,jj) 1461 IF ( ln_osm_mle ) THEN 1462 IF ( hmle(ji,jj) > hbl(ji,jj) ) THEN ! Fox-Kemper buoyancy flux average over OSBL 1463 pwb_fk_b(ji,jj) = pwb_fk(ji,jj) * ( 1.0_wp + hmle(ji,jj) / ( 6.0_wp * hbl(ji,jj) ) * & 1464 & ( -1.0_wp + ( 1.0_wp - 2.0_wp * hbl(ji,jj) / hmle(ji,jj) )**3 ) ) 1465 ELSE 1466 pwb_fk_b(ji,jj) = 0.5_wp * pwb_fk(ji,jj) * hmle(ji,jj) / hbl(ji,jj) 1467 ENDIF 1468 zvel_max = ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 1469 IF ( ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) < 0.0_wp ) THEN ! OSBL is deepening, 1470 ! ! entrainment > restratification 1471 IF ( av_db_bl(ji,jj) > 1e-15_wp ) THEN 1472 zgamma_b_nd = MAX( pdbdz_bl_ext(ji,jj), 0.0_wp ) * pdh(ji,jj) / & 1473 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1474 zpsi = ( 1.0_wp - 0.5_wp * pdh(ji,jj) / phbl(ji,jj) ) * & 1475 & ( swb0(ji,jj) - MIN( ( pwb_min(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ), 0.0_wp ) ) * pdh(ji,jj) / & 1476 & phbl(ji,jj) 1477 zpsi = zpsi + 1.75_wp * ( 1.0_wp - 0.5_wp * pdh(ji,jj) / phbl(ji,jj) ) * & 1478 & ( pdh(ji,jj) / phbl(ji,jj) + zgamma_b_nd ) * & 1479 & MIN( ( pwb_min(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ), 0.0_wp ) 1480 zpsi = pp_alpha_b * MAX( zpsi, 0.0_wp ) 1481 pdhdt(ji,jj) = -1.0_wp * ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) / & 1482 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) + & 1483 & zpsi / ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1484 IF ( n_ddh(ji,jj) == 1 ) THEN 1485 IF ( ( swstrc(ji,jj) / svstr(ji,jj) )**3 <= 0.5_wp ) THEN 1486 zari = MIN( 1.5_wp * av_db_bl(ji,jj) / & 1487 & ( phbl(ji,jj) * ( MAX( pdbdz_bl_ext(ji,jj), 0.0_wp ) + & 1488 & av_db_bl(ji,jj)**2 / MAX( 4.5_wp * svstr(ji,jj)**2, & 1489 & 1e-12_wp ) ) ), 0.2_wp ) 1490 ELSE 1491 zari = MIN( 1.5_wp * av_db_bl(ji,jj) / & 1492 & ( phbl(ji,jj) * ( MAX( pdbdz_bl_ext(ji,jj), 0.0_wp ) + & 1493 & av_db_bl(ji,jj)**2 / MAX( 4.5_wp * swstrc(ji,jj)**2, & 1494 & 1e-12_wp ) ) ), 0.2_wp ) 1495 ENDIF 1496 ! Relaxation to dh_ref = zari * hbl 1497 zddhdt = -1.0_wp * pp_ddh_2 * ( 1.0_wp - pdh(ji,jj) / ( zari * phbl(ji,jj) ) ) * pwb_ent(ji,jj) / & 1498 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1499 ELSE IF ( n_ddh(ji,jj) == 0 ) THEN ! Growing shear layer 1500 zddhdt = -1.0_wp * pp_ddh * ( 1.0_wp - 1.6_wp * pdh(ji,jj) / phbl(ji,jj) ) * pwb_ent(ji,jj) / & 1501 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1502 zddhdt = EXP( -4.0_wp * ABS( ff_t(ji,jj) ) * phbl(ji,jj) / MAX( sustar(ji,jj), 1e-8_wp ) ) * zddhdt 1503 ELSE 1504 zddhdt = 0.0_wp 1505 ENDIF ! n_ddh 1506 pdhdt(ji,jj) = pdhdt(ji,jj) + pp_alpha_b * ( 1.0_wp - 0.5_wp * pdh(ji,jj) / phbl(ji,jj) ) * & 1507 & av_db_ml(ji,jj) * MAX( zddhdt, 0.0_wp ) / & 1508 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1509 ELSE ! av_db_bl >0 1510 pdhdt(ji,jj) = -1.0_wp * ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) / MAX( zvel_max, 1e-15_wp ) 1511 ENDIF 1512 ELSE ! pwb_min + 2*pwb_fk_b < 0 1513 ! OSBL shoaling due to restratification flux. This is the velocity defined in Fox-Kemper et al (2008) 1514 pdhdt(ji,jj) = -1.0_wp * MIN( pvel_mle(ji,jj), hbl(ji,jj) / 10800.0_wp ) 1515 ENDIF 1516 ELSE ! Fox-Kemper not used. 1517 zvel_max = -1.0_wp * ( 1.0_wp + 1.0_wp * ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird * & 1518 & rn_Dt / hbl(ji,jj) ) * pwb_ent(ji,jj) / & 1519 & MAX( ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird, epsln ) 1520 pdhdt(ji,jj) = -1.0_wp * pwb_ent(ji,jj) / ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1521 ! added ajgn 23 July as temporay fix 1522 ENDIF ! ln_osm_mle 1523 ! 1524 ELSE ! l_conv - Stable 1525 ! 1526 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) 1527 IF ( pdhdt(ji,jj) < 0.0_wp ) THEN ! For long timsteps factor in brackets slows the rapid collapse of the OSBL 1528 zpert = 2.0_wp * ( 1.0_wp + 0.0_wp * 2.0_wp * svstr(ji,jj) * rn_Dt / hbl(ji,jj) ) * svstr(ji,jj)**2 / hbl(ji,jj) 1529 ELSE 1530 zpert = MAX( svstr(ji,jj)**2 / hbl(ji,jj), av_db_bl(ji,jj) ) 1531 ENDIF 1532 pdhdt(ji,jj) = 2.0_wp * pdhdt(ji,jj) / MAX( zpert, epsln ) 1533 pdhdt(ji,jj) = MAX( pdhdt(ji,jj), -1.0_wp * hbl(ji,jj) / 5400.0_wp ) 1534 ! 1535 ENDIF ! l_conv 1536 ! 1537 ELSE ! l_shear 1538 ! 1539 IF ( l_conv(ji,jj) ) THEN ! Convective 1540 ! 1541 IF ( ln_osm_mle ) THEN 1542 IF ( hmle(ji,jj) > hbl(ji,jj) ) THEN ! Fox-Kemper buoyancy flux average over OSBL 1543 pwb_fk_b(ji,jj) = pwb_fk(ji,jj) * & 1544 ( 1.0_wp + hmle(ji,jj) / ( 6.0_wp * hbl(ji,jj) ) * & 1545 & ( -1.0_wp + ( 1.0_wp - 2.0_wp * hbl(ji,jj) / hmle(ji,jj))**3) ) 1546 ELSE 1547 pwb_fk_b(ji,jj) = 0.5_wp * pwb_fk(ji,jj) * hmle(ji,jj) / hbl(ji,jj) 1548 ENDIF 1549 zvel_max = ( swstrl(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 1550 IF ( ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) < 0.0_wp ) THEN ! OSBL is deepening, 1551 ! ! entrainment > restratification 1552 IF ( av_db_bl(ji,jj) > 0.0_wp .AND. pdbdz_bl_ext(ji,jj) > 0.0_wp ) THEN 1553 pdhdt(ji,jj) = -1.0_wp * ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) / & 1554 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1555 ELSE 1556 pdhdt(ji,jj) = -1.0_wp * ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) / MAX( zvel_max, 1e-15_wp ) 1557 ENDIF 1558 ELSE ! OSBL shoaling due to restratification flux. This is the velocity defined in Fox-Kemper et al (2008) 1559 pdhdt(ji,jj) = -1.0_wp * MIN( pvel_mle(ji,jj), hbl(ji,jj) / 10800.0_wp ) 1560 ENDIF 1561 ELSE ! Fox-Kemper not used 1562 zvel_max = -1.0_wp * pwb_ent(ji,jj) / MAX( ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird, epsln ) 1563 pdhdt(ji,jj) = -1.0_wp * pwb_ent(ji,jj) / ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15_wp ) ) 1564 ! added ajgn 23 July as temporay fix 1565 ENDIF ! ln_osm_mle 1566 ! 1567 ELSE ! Stable 1568 ! 1569 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) 1570 IF ( pdhdt(ji,jj) < 0.0_wp ) THEN 1571 ! For long timsteps factor in brackets slows the rapid collapse of the OSBL 1572 zpert = 2.0_wp * svstr(ji,jj)**2 / hbl(ji,jj) 1573 ELSE 1574 zpert = MAX( svstr(ji,jj)**2 / hbl(ji,jj), av_db_bl(ji,jj) ) 1575 ENDIF 1576 pdhdt(ji,jj) = 2.0_wp * pdhdt(ji,jj) / MAX(zpert, epsln) 1577 pdhdt(ji,jj) = MAX( pdhdt(ji,jj), -1.0_wp * hbl(ji,jj) / 5400.0_wp ) 1578 ! 1579 ENDIF ! l_conv 1580 ! 1581 ENDIF ! l_shear 1582 ! 1583 END_2D 1584 ! 1585 END SUBROUTINE zdf_osm_calculate_dhdt 1586 1587 SUBROUTINE zdf_osm_timestep_hbl( Kmm, pdhdt, phbl, phbl_t, pwb_ent, & 1588 & pwb_fk_b ) 1589 !!--------------------------------------------------------------------- 1590 !! *** ROUTINE zdf_osm_timestep_hbl *** 1591 !! 1592 !! ** Purpose : Increments hbl. 1593 !! 1594 !! ** Method : If the change in hbl exceeds one model level the change is 1595 !! is calculated by moving down the grid, changing the 1596 !! buoyancy jump. This is to ensure that the change in hbl 1597 !! does not overshoot a stable layer. 1598 !! 1599 !!---------------------------------------------------------------------- 1600 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1601 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: pdhdt ! Rates of change of hbl 1602 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: phbl ! BL depth 1603 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl_t ! BL depth 1604 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_ent ! Buoyancy entrainment flux 1605 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_fk_b ! MLE buoyancy flux averaged over OSBL 1606 !! 1607 INTEGER :: jk, jj, ji, jm 1608 REAL(wp) :: zhbl_s, zvel_max, zdb 1609 REAL(wp) :: zthermal, zbeta 1610 !!---------------------------------------------------------------------- 1611 ! 1612 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1613 IF ( nbld(ji,jj) - nmld(ji,jj) > 1 ) THEN 1614 ! 1615 ! If boundary layer changes by more than one level, need to check for stable layers between initial and final depths. 1616 ! 1617 zhbl_s = hbl(ji,jj) 1618 jm = nmld(ji,jj) 1619 zthermal = rab_n(ji,jj,1,jp_tem) 1620 zbeta = rab_n(ji,jj,1,jp_sal) 1621 ! 1622 IF ( l_conv(ji,jj) ) THEN ! Unstable 1623 ! 1624 IF( ln_osm_mle ) THEN 1625 zvel_max = ( swstrl(ji,jj)**3 + swstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 1626 ELSE 1627 zvel_max = -1.0_wp * ( 1.0_wp + 1.0_wp * ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird * rn_Dt / & 1628 & hbl(ji,jj) ) * pwb_ent(ji,jj) / & 1629 & ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird 1630 ENDIF 1631 DO jk = nmld(ji,jj), nbld(ji,jj) 1632 zdb = MAX( grav * ( zthermal * ( av_t_bl(ji,jj) - ts(ji,jj,jm,jp_tem,Kmm) ) - & 1633 & zbeta * ( av_s_bl(ji,jj) - ts(ji,jj,jm,jp_sal,Kmm) ) ), 0.0_wp ) + zvel_max 974 1634 ! 975 ELSE 976 ghamu(ji,jj,jk) = ghamu(ji,jj,jk)& 977 & + 0.5 * 0.3 * ( 1.0 - EXP( -5.0 * ( 1.0 - znd ) ) ) * zsc_uw_2(ji,jj) 1635 IF ( ln_osm_mle ) THEN 1636 zhbl_s = zhbl_s + MIN( rn_Dt * ( ( -1.0_wp * pwb_ent(ji,jj) - 2.0_wp * pwb_fk_b(ji,jj) ) / zdb ) / & 1637 & REAL( nbld(ji,jj) - nmld(ji,jj), KIND=wp ), e3w(ji,jj,jm,Kmm) ) 1638 ELSE 1639 zhbl_s = zhbl_s + MIN( rn_Dt * ( -1.0_wp * pwb_ent(ji,jj) / zdb ) / & 1640 & REAL( nbld(ji,jj) - nmld(ji,jj), KIND=wp ), e3w(ji,jj,jm,Kmm) ) 1641 ENDIF 1642 ! zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 1643 IF ( zhbl_s >= gdepw(ji,jj,mbkt(ji,jj) + 1,Kmm) ) THEN 1644 zhbl_s = MIN( zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1, Kmm ) - depth_tol ) 1645 l_pyc(ji,jj) = .FALSE. 1646 ENDIF 1647 IF ( zhbl_s >= gdepw(ji,jj,jm+1,Kmm) ) jm = jm + 1 1648 END DO 1649 hbl(ji,jj) = zhbl_s 1650 nbld(ji,jj) = jm 1651 ELSE ! Stable 1652 DO jk = nmld(ji,jj), nbld(ji,jj) 1653 zdb = MAX( grav * ( zthermal * ( av_t_bl(ji,jj) - ts(ji,jj,jm,jp_tem,Kmm) ) - & 1654 & zbeta * ( av_s_bl(ji,jj) - ts(ji,jj,jm,jp_sal,Kmm) ) ), 0.0_wp ) + & 1655 & 2.0_wp * svstr(ji,jj)**2 / zhbl_s 978 1656 ! 979 ENDIF 980 981 ghamv(ji,jj,jk) = ghamv(ji,jj,jk)& 982 & + 0.3 * 0.15 * SIN( 3.14159 * ( 0.65 * zznd_d ) ) * EXP( -0.25 * zznd_d**2 ) * zsc_vw_1(ji,jj) 983 ghamv(ji,jj,jk) = ghamv(ji,jj,jk)& 984 & + 0.3 * 0.15 * EXP( -5.0 * ( 1.0 - znd ) ) * ( 1.0 - EXP( -20.0 * ( 1.0 - znd ) ) ) * zsc_vw_2(ji,jj) 985 END DO 986 ENDIF 987 END_2D 988 989 IF(ln_dia_osm) THEN 990 IF ( iom_use("ghamu_f") ) CALL iom_put( "ghamu_f", wmask*ghamu ) 991 IF ( iom_use("ghamv_f") ) CALL iom_put( "ghamv_f", wmask*ghamv ) 992 IF ( iom_use("zsc_uw_1_f") ) CALL iom_put( "zsc_uw_1_f", tmask(:,:,1)*zsc_uw_1 ) 993 IF ( iom_use("zsc_vw_1_f") ) CALL iom_put( "zsc_vw_1_f", tmask(:,:,1)*zsc_vw_1 ) 994 IF ( iom_use("zsc_uw_2_f") ) CALL iom_put( "zsc_uw_2_f", tmask(:,:,1)*zsc_uw_2 ) 995 IF ( iom_use("zsc_vw_2_f") ) CALL iom_put( "zsc_vw_2_f", tmask(:,:,1)*zsc_vw_2 ) 996 END IF 997 ! 998 ! Make surface forced velocity non-gradient terms go to zero at the base of the mixed layer. 999 1000 1001 ! Make surface forced velocity non-gradient terms go to zero at the base of the boundary layer. 1002 1003 DO_2D( 0, 0, 0, 0 ) 1004 IF ( .not. lconv(ji,jj) ) THEN 1005 DO jk = 2, ibld(ji,jj) 1006 znd = ( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / zhbl(ji,jj) !ALMG to think about 1007 IF ( znd >= 0.0 ) THEN 1008 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) * ( 1.0 - EXP( -10.0 * znd**2 ) ) 1009 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) * ( 1.0 - EXP( -10.0 * znd**2 ) ) 1010 ELSE 1011 ghamu(ji,jj,jk) = 0._wp 1012 ghamv(ji,jj,jk) = 0._wp 1013 ENDIF 1014 END DO 1657 ! Alan is thuis right? I have simply changed hbli to hbl 1658 shol(ji,jj) = -1.0_wp * zhbl_s / ( ( svstr(ji,jj)**3 + epsln ) / swbav(ji,jj) ) 1659 pdhdt(ji,jj) = -1.0_wp * ( swbav(ji,jj) - 0.04_wp / 2.0_wp * swstrl(ji,jj)**3 / zhbl_s - & 1660 & 0.15_wp / 2.0_wp * ( 1.0_wp - EXP( -1.5_wp * sla(ji,jj) ) ) * & 1661 & sustar(ji,jj)**3 / zhbl_s ) * & 1662 & ( 0.725_wp + 0.225_wp * EXP( -7.5_wp * shol(ji,jj) ) ) 1663 pdhdt(ji,jj) = pdhdt(ji,jj) + swbav(ji,jj) 1664 zhbl_s = zhbl_s + MIN( pdhdt(ji,jj) / zdb * rn_Dt / REAL( nbld(ji,jj) - nmld(ji,jj), KIND=wp ), & 1665 & e3w(ji,jj,jm,Kmm) ) 1666 1667 ! zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 1668 IF ( zhbl_s >= mbkt(ji,jj) + 1 ) THEN 1669 zhbl_s = MIN( zhbl_s, gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) - depth_tol ) 1670 l_pyc(ji,jj) = .FALSE. 1671 ENDIF 1672 IF ( zhbl_s >= gdepw(ji,jj,jm,Kmm) ) jm = jm + 1 1673 END DO 1674 ENDIF ! IF ( l_conv ) 1675 hbl(ji,jj) = MAX( zhbl_s, gdepw(ji,jj,4,Kmm) ) 1676 nbld(ji,jj) = MAX( jm, 4 ) 1677 ELSE 1678 ! change zero or one model level. 1679 hbl(ji,jj) = MAX( phbl_t(ji,jj), gdepw(ji,jj,4,Kmm) ) 1015 1680 ENDIF 1016 END_2D 1017 1018 ! pynocline contributions 1019 DO_2D( 0, 0, 0, 0 ) 1020 IF ( .not. lconv(ji,jj) ) THEN 1021 IF ( ibld(ji,jj) + jp_ext(ji,jj) < mbkt(ji,jj) ) THEN 1022 DO jk= 2, ibld(ji,jj) 1023 znd = gdepw(ji,jj,jk,Kmm) / zhbl(ji,jj) 1024 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + zdiffut(ji,jj,jk) * zdtdz_pyc(ji,jj,jk) 1025 ghams(ji,jj,jk) = ghams(ji,jj,jk) + zdiffut(ji,jj,jk) * zdsdz_pyc(ji,jj,jk) 1026 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + zviscos(ji,jj,jk) * zdudz_pyc(ji,jj,jk) 1027 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + zviscos(ji,jj,jk) * zdvdz_pyc(ji,jj,jk) 1028 END DO 1029 END IF 1030 END IF 1031 END_2D 1032 IF(ln_dia_osm) THEN 1033 IF ( iom_use("ghamu_b") ) CALL iom_put( "ghamu_b", wmask*ghamu ) 1034 IF ( iom_use("ghamv_b") ) CALL iom_put( "ghamv_b", wmask*ghamv ) 1035 END IF 1036 1037 DO_2D( 0, 0, 0, 0 ) 1038 ghamt(ji,jj,ibld(ji,jj)+ibld_ext) = 0._wp 1039 ghams(ji,jj,ibld(ji,jj)+ibld_ext) = 0._wp 1040 ghamu(ji,jj,ibld(ji,jj)+ibld_ext) = 0._wp 1041 ghamv(ji,jj,ibld(ji,jj)+ibld_ext) = 0._wp 1042 END_2D 1043 1044 IF(ln_dia_osm) THEN 1045 IF ( iom_use("ghamu_1") ) CALL iom_put( "ghamu_1", wmask*ghamu ) 1046 IF ( iom_use("ghamv_1") ) CALL iom_put( "ghamv_1", wmask*ghamv ) 1047 IF ( iom_use("zdudz_pyc") ) CALL iom_put( "zdudz_pyc", wmask*zdudz_pyc ) 1048 IF ( iom_use("zdvdz_pyc") ) CALL iom_put( "zdvdz_pyc", wmask*zdvdz_pyc ) 1049 IF ( iom_use("zviscos") ) CALL iom_put( "zviscos", wmask*zviscos ) 1050 END IF 1051 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 1052 ! Need to put in code for contributions that are applied explicitly to 1053 ! the prognostic variables 1054 ! 1. Entrainment flux 1055 ! 1056 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1057 1058 1059 1060 ! rotate non-gradient velocity terms back to model reference frame 1061 1062 DO_2D( 0, 0, 0, 0 ) 1063 DO jk = 2, ibld(ji,jj) 1064 ztemp = ghamu(ji,jj,jk) 1065 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) * zcos_wind(ji,jj) - ghamv(ji,jj,jk) * zsin_wind(ji,jj) 1066 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) * zcos_wind(ji,jj) + ztemp * zsin_wind(ji,jj) 1067 END DO 1068 END_2D 1069 1070 IF(ln_dia_osm) THEN 1071 IF ( iom_use("zdtdz_pyc") ) CALL iom_put( "zdtdz_pyc", wmask*zdtdz_pyc ) 1072 IF ( iom_use("zdsdz_pyc") ) CALL iom_put( "zdsdz_pyc", wmask*zdsdz_pyc ) 1073 IF ( iom_use("zdbdz_pyc") ) CALL iom_put( "zdbdz_pyc", wmask*zdbdz_pyc ) 1074 END IF 1075 1076 ! KPP-style Ri# mixing 1077 IF( ln_kpprimix) THEN 1078 DO_3D( 1, 0, 1, 0, 2, jpkm1 ) !* Shear production at uw- and vw-points (energy conserving form) 1079 z3du(ji,jj,jk) = 0.5 * ( uu(ji,jj,jk-1,Kmm) - uu(ji ,jj,jk,Kmm) ) & 1080 & * ( uu(ji,jj,jk-1,Kbb) - uu(ji ,jj,jk,Kbb) ) * wumask(ji,jj,jk) & 1081 & / ( e3uw(ji,jj,jk,Kmm) * e3uw(ji,jj,jk,Kbb) ) 1082 z3dv(ji,jj,jk) = 0.5 * ( vv(ji,jj,jk-1,Kmm) - vv(ji,jj ,jk,Kmm) ) & 1083 & * ( vv(ji,jj,jk-1,Kbb) - vv(ji,jj ,jk,Kbb) ) * wvmask(ji,jj,jk) & 1084 & / ( e3vw(ji,jj,jk,Kmm) * e3vw(ji,jj,jk,Kbb) ) 1085 END_3D 1086 ! 1087 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 1088 ! ! shear prod. at w-point weightened by mask 1089 zesh2 = ( z3du(ji-1,jj,jk) + z3du(ji,jj,jk) ) / MAX( 1._wp , umask(ji-1,jj,jk) + umask(ji,jj,jk) ) & 1090 & + ( z3dv(ji,jj-1,jk) + z3dv(ji,jj,jk) ) / MAX( 1._wp , vmask(ji,jj-1,jk) + vmask(ji,jj,jk) ) 1091 ! ! local Richardson number 1092 zri = MAX( rn2b(ji,jj,jk), 0._wp ) / MAX(zesh2, epsln) 1093 zfri = MIN( zri / rn_riinfty , 1.0_wp ) 1094 zfri = ( 1.0_wp - zfri * zfri ) 1095 zrimix(ji,jj,jk) = zfri * zfri * zfri * wmask(ji, jj, jk) 1096 END_3D 1097 1098 DO_2D( 0, 0, 0, 0 ) 1099 DO jk = ibld(ji,jj) + 1, jpkm1 1100 zdiffut(ji,jj,jk) = zrimix(ji,jj,jk)*rn_difri 1101 zviscos(ji,jj,jk) = zrimix(ji,jj,jk)*rn_difri 1102 END DO 1103 END_2D 1104 1105 END IF ! ln_kpprimix = .true. 1106 1107 ! KPP-style set diffusivity large if unstable below BL 1108 IF( ln_convmix) THEN 1109 DO_2D( 0, 0, 0, 0 ) 1110 DO jk = ibld(ji,jj) + 1, jpkm1 1111 IF( MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) zdiffut(ji,jj,jk) = rn_difconv 1112 END DO 1113 END_2D 1114 END IF ! ln_convmix = .true. 1115 1116 1117 1118 IF ( ln_osm_mle ) THEN ! set up diffusivity and non-gradient mixing 1119 DO_2D( 0, 0, 0, 0 ) 1120 IF ( lflux(ji,jj) ) THEN ! MLE mixing extends below boundary layer 1121 ! Calculate MLE flux contribution from surface fluxes 1122 DO jk = 1, ibld(ji,jj) 1123 znd = gdepw(ji,jj,jk,Kmm) / MAX(zhbl(ji,jj),epsln) 1124 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) - zwth0(ji,jj) * ( 1.0 - znd ) 1125 ghams(ji,jj,jk) = ghams(ji,jj,jk) - zws0(ji,jj) * ( 1.0 - znd ) 1126 END DO 1127 DO jk = 1, mld_prof(ji,jj) 1128 znd = gdepw(ji,jj,jk,Kmm) / MAX(zhmle(ji,jj),epsln) 1129 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + zwth0(ji,jj) * ( 1.0 - znd ) 1130 ghams(ji,jj,jk) = ghams(ji,jj,jk) + zws0(ji,jj) * ( 1.0 -znd ) 1131 END DO 1132 ! Viscosity for MLEs 1133 DO jk = 1, mld_prof(ji,jj) 1134 znd = -gdepw(ji,jj,jk,Kmm) / MAX(zhmle(ji,jj),epsln) 1135 zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) + zdiff_mle(ji,jj) * ( 1.0 - ( 2.0 * znd + 1.0 )**2 ) * ( 1.0 + 5.0 / 21.0 * ( 2.0 * znd + 1.0 )** 2 ) 1136 END DO 1137 ELSE 1138 ! Surface transports limited to OSBL. 1139 ! Viscosity for MLEs 1140 DO jk = 1, mld_prof(ji,jj) 1141 znd = -gdepw(ji,jj,jk,Kmm) / MAX(zhmle(ji,jj),epsln) 1142 zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) + zdiff_mle(ji,jj) * ( 1.0 - ( 2.0 * znd + 1.0 )**2 ) * ( 1.0 + 5.0 / 21.0 * ( 2.0 * znd + 1.0 )** 2 ) 1143 END DO 1144 ENDIF 1145 END_2D 1146 ENDIF 1147 1148 IF(ln_dia_osm) THEN 1149 IF ( iom_use("zdtdz_pyc") ) CALL iom_put( "zdtdz_pyc", wmask*zdtdz_pyc ) 1150 IF ( iom_use("zdsdz_pyc") ) CALL iom_put( "zdsdz_pyc", wmask*zdsdz_pyc ) 1151 IF ( iom_use("zdbdz_pyc") ) CALL iom_put( "zdbdz_pyc", wmask*zdbdz_pyc ) 1152 END IF 1153 1154 1155 ! Lateral boundary conditions on zvicos (sign unchanged), needed to caclulate viscosities on u and v grids 1156 !CALL lbc_lnk( 'zdfosm', zviscos(:,:,:), 'W', 1.0_wp ) 1157 1158 ! GN 25/8: need to change tmask --> wmask 1159 1160 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 1161 p_avt(ji,jj,jk) = MAX( zdiffut(ji,jj,jk), avtb(jk) ) * tmask(ji,jj,jk) 1162 p_avm(ji,jj,jk) = MAX( zviscos(ji,jj,jk), avmb(jk) ) * tmask(ji,jj,jk) 1163 END_3D 1164 ! Lateral boundary conditions on ghamu and ghamv, currently on W-grid (sign unchanged), needed to caclulate gham[uv] on u and v grids 1165 CALL lbc_lnk( 'zdfosm', p_avt, 'W', 1.0_wp , p_avm, 'W', 1.0_wp, & 1166 & ghamu, 'W', 1.0_wp , ghamv, 'W', 1.0_wp ) 1167 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) 1168 ghamu(ji,jj,jk) = ( ghamu(ji,jj,jk) + ghamu(ji+1,jj,jk) ) & 1169 & / MAX( 1., tmask(ji,jj,jk) + tmask (ji + 1,jj,jk) ) * umask(ji,jj,jk) 1170 1171 ghamv(ji,jj,jk) = ( ghamv(ji,jj,jk) + ghamv(ji,jj+1,jk) ) & 1172 & / MAX( 1., tmask(ji,jj,jk) + tmask (ji,jj+1,jk) ) * vmask(ji,jj,jk) 1173 1174 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) * tmask(ji,jj,jk) 1175 ghams(ji,jj,jk) = ghams(ji,jj,jk) * tmask(ji,jj,jk) 1176 END_3D 1177 ! Lateral boundary conditions on final outputs for hbl, on T-grid (sign unchanged) 1178 CALL lbc_lnk( 'zdfosm', hbl, 'T', 1., dh, 'T', 1., hmle, 'T', 1. ) 1179 ! Lateral boundary conditions on final outputs for gham[ts], on W-grid (sign unchanged) 1180 ! Lateral boundary conditions on final outputs for gham[uv], on [UV]-grid (sign changed) 1181 CALL lbc_lnk( 'zdfosm', ghamt, 'W', 1.0_wp , ghams, 'W', 1.0_wp, & 1182 & ghamu, 'U', -1.0_wp , ghamv, 'V', -1.0_wp ) 1183 1184 IF(ln_dia_osm) THEN 1185 SELECT CASE (nn_osm_wave) 1186 ! Stokes drift set by assumimg onstant La#=0.3(=0) or Pierson-Moskovitz spectrum (=1). 1187 CASE(0:1) 1188 IF ( iom_use("us_x") ) CALL iom_put( "us_x", tmask(:,:,1)*zustke*zcos_wind ) ! x surface Stokes drift 1189 IF ( iom_use("us_y") ) CALL iom_put( "us_y", tmask(:,:,1)*zustke*zsin_wind ) ! y surface Stokes drift 1190 IF ( iom_use("wind_wave_abs_power") ) CALL iom_put( "wind_wave_abs_power", 1000.*rho0*tmask(:,:,1)*zustar**2*zustke ) 1191 ! Stokes drift read in from sbcwave (=2). 1192 CASE(2:3) 1193 IF ( iom_use("us_x") ) CALL iom_put( "us_x", ut0sd*umask(:,:,1) ) ! x surface Stokes drift 1194 IF ( iom_use("us_y") ) CALL iom_put( "us_y", vt0sd*vmask(:,:,1) ) ! y surface Stokes drift 1195 IF ( iom_use("wmp") ) CALL iom_put( "wmp", wmp*tmask(:,:,1) ) ! wave mean period 1196 IF ( iom_use("hsw") ) CALL iom_put( "hsw", hsw*tmask(:,:,1) ) ! significant wave height 1197 IF ( iom_use("wmp_NP") ) CALL iom_put( "wmp_NP", (2.*rpi*1.026/(0.877*grav) )*wndm*tmask(:,:,1) ) ! wave mean period from NP spectrum 1198 IF ( iom_use("hsw_NP") ) CALL iom_put( "hsw_NP", (0.22/grav)*wndm**2*tmask(:,:,1) ) ! significant wave height from NP spectrum 1199 IF ( iom_use("wndm") ) CALL iom_put( "wndm", wndm*tmask(:,:,1) ) ! U_10 1200 IF ( iom_use("wind_wave_abs_power") ) CALL iom_put( "wind_wave_abs_power", 1000.*rho0*tmask(:,:,1)*zustar**2* & 1201 & SQRT(ut0sd**2 + vt0sd**2 ) ) 1202 END SELECT 1203 IF ( iom_use("ghamt") ) CALL iom_put( "ghamt", tmask*ghamt ) ! <Tw_NL> 1204 IF ( iom_use("ghams") ) CALL iom_put( "ghams", tmask*ghams ) ! <Sw_NL> 1205 IF ( iom_use("ghamu") ) CALL iom_put( "ghamu", umask*ghamu ) ! <uw_NL> 1206 IF ( iom_use("ghamv") ) CALL iom_put( "ghamv", vmask*ghamv ) ! <vw_NL> 1207 IF ( iom_use("zwth0") ) CALL iom_put( "zwth0", tmask(:,:,1)*zwth0 ) ! <Tw_0> 1208 IF ( iom_use("zws0") ) CALL iom_put( "zws0", tmask(:,:,1)*zws0 ) ! <Sw_0> 1209 IF ( iom_use("hbl") ) CALL iom_put( "hbl", tmask(:,:,1)*hbl ) ! boundary-layer depth 1210 IF ( iom_use("ibld") ) CALL iom_put( "ibld", tmask(:,:,1)*ibld ) ! boundary-layer max k 1211 IF ( iom_use("zdt_bl") ) CALL iom_put( "zdt_bl", tmask(:,:,1)*zdt_bl ) ! dt at ml base 1212 IF ( iom_use("zds_bl") ) CALL iom_put( "zds_bl", tmask(:,:,1)*zds_bl ) ! ds at ml base 1213 IF ( iom_use("zdb_bl") ) CALL iom_put( "zdb_bl", tmask(:,:,1)*zdb_bl ) ! db at ml base 1214 IF ( iom_use("zdu_bl") ) CALL iom_put( "zdu_bl", tmask(:,:,1)*zdu_bl ) ! du at ml base 1215 IF ( iom_use("zdv_bl") ) CALL iom_put( "zdv_bl", tmask(:,:,1)*zdv_bl ) ! dv at ml base 1216 IF ( iom_use("dh") ) CALL iom_put( "dh", tmask(:,:,1)*dh ) ! Initial boundary-layer depth 1217 IF ( iom_use("hml") ) CALL iom_put( "hml", tmask(:,:,1)*hml ) ! Initial boundary-layer depth 1218 IF ( iom_use("dstokes") ) CALL iom_put( "dstokes", tmask(:,:,1)*dstokes ) ! Stokes drift penetration depth 1219 IF ( iom_use("zustke") ) CALL iom_put( "zustke", tmask(:,:,1)*zustke ) ! Stokes drift magnitude at T-points 1220 IF ( iom_use("zwstrc") ) CALL iom_put( "zwstrc", tmask(:,:,1)*zwstrc ) ! convective velocity scale 1221 IF ( iom_use("zwstrl") ) CALL iom_put( "zwstrl", tmask(:,:,1)*zwstrl ) ! Langmuir velocity scale 1222 IF ( iom_use("zustar") ) CALL iom_put( "zustar", tmask(:,:,1)*zustar ) ! friction velocity scale 1223 IF ( iom_use("zvstr") ) CALL iom_put( "zvstr", tmask(:,:,1)*zvstr ) ! mixed velocity scale 1224 IF ( iom_use("zla") ) CALL iom_put( "zla", tmask(:,:,1)*zla ) ! langmuir # 1225 IF ( iom_use("wind_power") ) CALL iom_put( "wind_power", 1000.*rho0*tmask(:,:,1)*zustar**3 ) ! BL depth internal to zdf_osm routine 1226 IF ( iom_use("wind_wave_power") ) CALL iom_put( "wind_wave_power", 1000.*rho0*tmask(:,:,1)*zustar**2*zustke ) 1227 IF ( iom_use("zhbl") ) CALL iom_put( "zhbl", tmask(:,:,1)*zhbl ) ! BL depth internal to zdf_osm routine 1228 IF ( iom_use("zhml") ) CALL iom_put( "zhml", tmask(:,:,1)*zhml ) ! ML depth internal to zdf_osm routine 1229 IF ( iom_use("imld") ) CALL iom_put( "imld", tmask(:,:,1)*imld ) ! index for ML depth internal to zdf_osm routine 1230 IF ( iom_use("zdh") ) CALL iom_put( "zdh", tmask(:,:,1)*zdh ) ! pyc thicknessh internal to zdf_osm routine 1231 IF ( iom_use("zhol") ) CALL iom_put( "zhol", tmask(:,:,1)*zhol ) ! ML depth internal to zdf_osm routine 1232 IF ( iom_use("zwthav") ) CALL iom_put( "zwthav", tmask(:,:,1)*zwthav ) ! upward BL-avged turb temp flux 1233 IF ( iom_use("zwth_ent") ) CALL iom_put( "zwth_ent", tmask(:,:,1)*zwth_ent ) ! upward turb temp entrainment flux 1234 IF ( iom_use("zwb_ent") ) CALL iom_put( "zwb_ent", tmask(:,:,1)*zwb_ent ) ! upward turb buoyancy entrainment flux 1235 IF ( iom_use("zws_ent") ) CALL iom_put( "zws_ent", tmask(:,:,1)*zws_ent ) ! upward turb salinity entrainment flux 1236 IF ( iom_use("zt_ml") ) CALL iom_put( "zt_ml", tmask(:,:,1)*zt_ml ) ! average T in ML 1237 1238 IF ( iom_use("hmle") ) CALL iom_put( "hmle", tmask(:,:,1)*hmle ) ! FK layer depth 1239 IF ( iom_use("zmld") ) CALL iom_put( "zmld", tmask(:,:,1)*zmld ) ! FK target layer depth 1240 IF ( iom_use("zwb_fk") ) CALL iom_put( "zwb_fk", tmask(:,:,1)*zwb_fk ) ! FK b flux 1241 IF ( iom_use("zwb_fk_b") ) CALL iom_put( "zwb_fk_b", tmask(:,:,1)*zwb_fk_b ) ! FK b flux averaged over ML 1242 IF ( iom_use("mld_prof") ) CALL iom_put( "mld_prof", tmask(:,:,1)*mld_prof )! FK layer max k 1243 IF ( iom_use("zdtdx") ) CALL iom_put( "zdtdx", umask(:,:,1)*zdtdx ) ! FK dtdx at u-pt 1244 IF ( iom_use("zdtdy") ) CALL iom_put( "zdtdy", vmask(:,:,1)*zdtdy ) ! FK dtdy at v-pt 1245 IF ( iom_use("zdsdx") ) CALL iom_put( "zdsdx", umask(:,:,1)*zdsdx ) ! FK dtdx at u-pt 1246 IF ( iom_use("zdsdy") ) CALL iom_put( "zdsdy", vmask(:,:,1)*zdsdy ) ! FK dsdy at v-pt 1247 IF ( iom_use("dbdx_mle") ) CALL iom_put( "dbdx_mle", umask(:,:,1)*dbdx_mle ) ! FK dbdx at u-pt 1248 IF ( iom_use("dbdy_mle") ) CALL iom_put( "dbdy_mle", vmask(:,:,1)*dbdy_mle ) ! FK dbdy at v-pt 1249 IF ( iom_use("zdiff_mle") ) CALL iom_put( "zdiff_mle", tmask(:,:,1)*zdiff_mle )! FK diff in MLE at t-pt 1250 IF ( iom_use("zvel_mle") ) CALL iom_put( "zvel_mle", tmask(:,:,1)*zdiff_mle )! FK diff in MLE at t-pt 1251 1252 END IF 1253 1254 CONTAINS 1255 ! subroutine code changed, needs syntax checking. 1256 SUBROUTINE zdf_osm_diffusivity_viscosity( zdiffut, zviscos ) 1257 1258 !!--------------------------------------------------------------------- 1259 !! *** ROUTINE zdf_osm_diffusivity_viscosity *** 1260 !! 1261 !! ** Purpose : Determines the eddy diffusivity and eddy viscosity profiles in the mixed layer and the pycnocline. 1262 !! 1263 !! ** Method : 1264 !! 1265 !! !!---------------------------------------------------------------------- 1266 REAL(wp), DIMENSION(:,:,:) :: zdiffut 1267 REAL(wp), DIMENSION(:,:,:) :: zviscos 1268 ! local 1269 1270 ! Scales used to calculate eddy diffusivity and viscosity profiles 1271 REAL(wp), DIMENSION(jpi,jpj) :: zdifml_sc, zvisml_sc 1272 REAL(wp), DIMENSION(jpi,jpj) :: zdifpyc_n_sc, zdifpyc_s_sc, zdifpyc_shr 1273 REAL(wp), DIMENSION(jpi,jpj) :: zvispyc_n_sc, zvispyc_s_sc,zvispyc_shr 1274 REAL(wp), DIMENSION(jpi,jpj) :: zbeta_d_sc, zbeta_v_sc 1275 ! 1276 REAL(wp) :: zvel_sc_pyc, zvel_sc_ml, zstab_fac 1277 1278 REAL(wp), PARAMETER :: rn_dif_ml = 0.8, rn_vis_ml = 0.375 1279 REAL(wp), PARAMETER :: rn_dif_pyc = 0.15, rn_vis_pyc = 0.142 1280 REAL(wp), PARAMETER :: rn_vispyc_shr = 0.15 1281 1282 DO_2D( 0, 0, 0, 0 ) 1283 IF ( lconv(ji,jj) ) THEN 1284 1285 zvel_sc_pyc = ( 0.15 * zvstr(ji,jj)**3 + zwstrc(ji,jj)**3 + 4.25 * zshear(ji,jj) * zhbl(ji,jj) )**pthird 1286 zvel_sc_ml = ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird 1287 zstab_fac = ( zhml(ji,jj) / zvel_sc_ml * ( 1.4 - 0.4 / ( 1.0 + EXP(-3.5 * LOG10(-zhol(ji,jj) ) ) )**1.25 ) )**2 1288 1289 zdifml_sc(ji,jj) = rn_dif_ml * zhml(ji,jj) * zvel_sc_ml 1290 zvisml_sc(ji,jj) = rn_vis_ml * zdifml_sc(ji,jj) 1291 1292 IF ( lpyc(ji,jj) ) THEN 1293 zdifpyc_n_sc(ji,jj) = rn_dif_pyc * zvel_sc_ml * zdh(ji,jj) 1294 1295 IF ( lshear(ji,jj) .and. j_ddh(ji,jj) == 1 ) THEN 1296 zdifpyc_n_sc(ji,jj) = zdifpyc_n_sc(ji,jj) + rn_vispyc_shr * ( zshear(ji,jj) * zhbl(ji,jj) )**pthird * zhbl(ji,jj) 1297 ENDIF 1298 1299 zdifpyc_s_sc(ji,jj) = zwb_ent(ji,jj) + 0.0025 * zvel_sc_pyc * ( zhbl(ji,jj) / zdh(ji,jj) - 1.0 ) * ( zb_ml(ji,jj) - zb_bl(ji,jj) ) 1300 zdifpyc_s_sc(ji,jj) = 0.09 * zdifpyc_s_sc(ji,jj) * zstab_fac 1301 zdifpyc_s_sc(ji,jj) = MAX( zdifpyc_s_sc(ji,jj), -0.5 * zdifpyc_n_sc(ji,jj) ) 1302 1303 zvispyc_n_sc(ji,jj) = 0.09 * zvel_sc_pyc * ( 1.0 - zhbl(ji,jj) / zdh(ji,jj) )**2 * ( 0.005 * ( zu_ml(ji,jj)-zu_bl(ji,jj) )**2 + 0.0075 * ( zv_ml(ji,jj)-zv_bl(ji,jj) )**2 ) / zdh(ji,jj) 1304 zvispyc_n_sc(ji,jj) = rn_vis_pyc * zvel_sc_ml * zdh(ji,jj) + zvispyc_n_sc(ji,jj) * zstab_fac 1305 IF ( lshear(ji,jj) .and. j_ddh(ji,jj) == 1 ) THEN 1306 zvispyc_n_sc(ji,jj) = zvispyc_n_sc(ji,jj) + rn_vispyc_shr * ( zshear(ji,jj) * zhbl(ji,jj ) )**pthird * zhbl(ji,jj) 1307 ENDIF 1308 1309 zvispyc_s_sc(ji,jj) = 0.09 * ( zwb_min(ji,jj) + 0.0025 * zvel_sc_pyc * ( zhbl(ji,jj) / zdh(ji,jj) - 1.0 ) * ( zb_ml(ji,jj) - zb_bl(ji,jj) ) ) 1310 zvispyc_s_sc(ji,jj) = zvispyc_s_sc(ji,jj) * zstab_fac 1311 zvispyc_s_sc(ji,jj) = MAX( zvispyc_s_sc(ji,jj), -0.5 * zvispyc_s_sc(ji,jj) ) 1312 1313 zbeta_d_sc(ji,jj) = 1.0 - ( ( zdifpyc_n_sc(ji,jj) + 1.4 * zdifpyc_s_sc(ji,jj) ) / ( zdifml_sc(ji,jj) + epsln ) )**p2third 1314 zbeta_v_sc(ji,jj) = 1.0 - 2.0 * ( zvispyc_n_sc(ji,jj) + zvispyc_s_sc(ji,jj) ) / ( zvisml_sc(ji,jj) + epsln ) 1315 ELSE 1316 zbeta_d_sc(ji,jj) = 1.0 1317 zbeta_v_sc(ji,jj) = 1.0 1318 ENDIF 1319 ELSE 1320 zdifml_sc(ji,jj) = zvstr(ji,jj) * zhbl(ji,jj) * MAX( EXP ( -( zhol(ji,jj) / 0.6_wp )**2 ), 0.2_wp) 1321 zvisml_sc(ji,jj) = zvstr(ji,jj) * zhbl(ji,jj) * MAX( EXP ( -( zhol(ji,jj) / 0.6_wp )**2 ), 0.2_wp) 1322 END IF 1323 END_2D 1324 ! 1325 DO_2D( 0, 0, 0, 0 ) 1326 IF ( lconv(ji,jj) ) THEN 1327 DO jk = 2, imld(ji,jj) ! mixed layer diffusivity 1328 zznd_ml = gdepw(ji,jj,jk,Kmm) / zhml(ji,jj) 1329 ! 1330 zdiffut(ji,jj,jk) = zdifml_sc(ji,jj) * zznd_ml * ( 1.0 - zbeta_d_sc(ji,jj) * zznd_ml )**1.5 1331 ! 1332 zviscos(ji,jj,jk) = zvisml_sc(ji,jj) * zznd_ml * ( 1.0 - zbeta_v_sc(ji,jj) * zznd_ml ) & 1333 & * ( 1.0 - 0.5 * zznd_ml**2 ) 1334 END DO 1335 ! pycnocline 1336 IF ( lpyc(ji,jj) ) THEN 1337 ! Diffusivity profile in the pycnocline given by cubic polynomial. 1338 za_cubic = 0.5 1339 zb_cubic = -1.75 * zdifpyc_s_sc(ji,jj) / zdifpyc_n_sc(ji,jj) 1340 zd_cubic = ( zdh(ji,jj) * zdifml_sc(ji,jj) / zhml(ji,jj) * SQRT( 1.0 - zbeta_d_sc(ji,jj) ) * ( 2.5 * zbeta_d_sc(ji,jj) - 1.0 ) & 1341 & - 0.85 * zdifpyc_s_sc(ji,jj) ) / MAX(zdifpyc_n_sc(ji,jj), 1.e-8) 1342 zd_cubic = zd_cubic - zb_cubic - 2.0 * ( 1.0 - za_cubic - zb_cubic ) 1343 zc_cubic = 1.0 - za_cubic - zb_cubic - zd_cubic 1344 DO jk = imld(ji,jj) , ibld(ji,jj) 1345 zznd_pyc = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / MAX(zdh(ji,jj), 1.e-6) 1346 ! 1347 zdiffut(ji,jj,jk) = zdifpyc_n_sc(ji,jj) * ( za_cubic + zb_cubic * zznd_pyc + zc_cubic * zznd_pyc**2 + zd_cubic * zznd_pyc**3 ) 1348 1349 zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) + zdifpyc_s_sc(ji,jj) * ( 1.75 * zznd_pyc - 0.15 * zznd_pyc**2 - 0.2 * zznd_pyc**3 ) 1350 END DO 1351 ! viscosity profiles. 1352 za_cubic = 0.5 1353 zb_cubic = -1.75 * zvispyc_s_sc(ji,jj) / zvispyc_n_sc(ji,jj) 1354 zd_cubic = ( 0.5 * zvisml_sc(ji,jj) * zdh(ji,jj) / zhml(ji,jj) - 0.85 * zvispyc_s_sc(ji,jj) ) / MAX(zvispyc_n_sc(ji,jj), 1.e-8) 1355 zd_cubic = zd_cubic - zb_cubic - 2.0 * ( 1.0 - za_cubic - zd_cubic ) 1356 zc_cubic = 1.0 - za_cubic - zb_cubic - zd_cubic 1357 DO jk = imld(ji,jj) , ibld(ji,jj) 1358 zznd_pyc = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / MAX(zdh(ji,jj), 1.e-6) 1359 zviscos(ji,jj,jk) = zvispyc_n_sc(ji,jj) * ( za_cubic + zb_cubic * zznd_pyc + zc_cubic * zznd_pyc**2 + zd_cubic * zznd_pyc**3 ) 1360 zviscos(ji,jj,jk) = zviscos(ji,jj,jk) + zvispyc_s_sc(ji,jj) * ( 1.75 * zznd_pyc - 0.15 * zznd_pyc**2 -0.2 * zznd_pyc**3 ) 1361 END DO 1362 IF ( zdhdt(ji,jj) > 0._wp ) THEN 1363 zdiffut(ji,jj,ibld(ji,jj)+1) = MAX( 0.5 * zdhdt(ji,jj) * e3w(ji,jj,ibld(ji,jj)+1,Kmm), 1.0e-6 ) 1364 zviscos(ji,jj,ibld(ji,jj)+1) = MAX( 0.5 * zdhdt(ji,jj) * e3w(ji,jj,ibld(ji,jj)+1,Kmm), 1.0e-6 ) 1365 ELSE 1366 zdiffut(ji,jj,ibld(ji,jj)) = 0._wp 1367 zviscos(ji,jj,ibld(ji,jj)) = 0._wp 1368 ENDIF 1369 ENDIF 1370 ELSE 1371 ! stable conditions 1372 DO jk = 2, ibld(ji,jj) 1373 zznd_ml = gdepw(ji,jj,jk,Kmm) / zhbl(ji,jj) 1374 zdiffut(ji,jj,jk) = 0.75 * zdifml_sc(ji,jj) * zznd_ml * ( 1.0 - zznd_ml )**1.5 1375 zviscos(ji,jj,jk) = 0.375 * zvisml_sc(ji,jj) * zznd_ml * (1.0 - zznd_ml) * ( 1.0 - zznd_ml**2 ) 1376 END DO 1377 1378 IF ( zdhdt(ji,jj) > 0._wp ) THEN 1379 zdiffut(ji,jj,ibld(ji,jj)) = MAX(zdhdt(ji,jj), 1.0e-6) * e3w(ji, jj, ibld(ji,jj), Kmm) 1380 zviscos(ji,jj,ibld(ji,jj)) = MAX(zdhdt(ji,jj), 1.0e-6) * e3w(ji, jj, ibld(ji,jj), Kmm) 1381 ENDIF 1382 ENDIF ! end if ( lconv ) 1383 ! 1384 END_2D 1385 1386 END SUBROUTINE zdf_osm_diffusivity_viscosity 1387 1388 SUBROUTINE zdf_osm_osbl_state( lconv, lshear, j_ddh, zwb_ent, zwb_min, zshear, zri_i ) 1389 1390 !!--------------------------------------------------------------------- 1391 !! *** ROUTINE zdf_osm_osbl_state *** 1392 !! 1393 !! ** Purpose : Determines the state of the OSBL, stable/unstable, shear/ noshear. Also determines shear production, entrainment buoyancy flux and interfacial Richardson number 1394 !! 1395 !! ** Method : 1396 !! 1397 !! !!---------------------------------------------------------------------- 1398 1399 INTEGER, DIMENSION(jpi,jpj) :: j_ddh ! j_ddh = 0, active shear layer; j_ddh=1, shear layer not active; j_ddh=2 shear production low. 1400 1401 LOGICAL, DIMENSION(jpi,jpj) :: lconv, lshear 1402 1403 REAL(wp), DIMENSION(jpi,jpj) :: zwb_ent, zwb_min ! Buoyancy fluxes at base of well-mixed layer. 1404 REAL(wp), DIMENSION(jpi,jpj) :: zshear ! production of TKE due to shear across the pycnocline 1405 REAL(wp), DIMENSION(jpi,jpj) :: zri_i ! Interfacial Richardson Number 1406 1407 ! Local Variables 1408 1409 INTEGER :: jj, ji 1410 1411 REAL(wp), DIMENSION(jpi,jpj) :: zekman 1412 REAL(wp) :: zri_p, zri_b ! Richardson numbers 1413 REAL(wp) :: zshear_u, zshear_v, zwb_shr 1414 REAL(wp) :: zwcor, zrf_conv, zrf_shear, zrf_langmuir, zr_stokes 1415 1416 REAL, PARAMETER :: za_shr = 0.4, zb_shr = 6.5, za_wb_s = 0.1 1417 REAL, PARAMETER :: rn_ri_thres_a = 0.5, rn_ri_thresh_b = 0.59 1418 REAL, PARAMETER :: zalpha_c = 0.2, zalpha_lc = 0.04 1419 REAL, PARAMETER :: zalpha_ls = 0.06, zalpha_s = 0.15 1420 REAL, PARAMETER :: rn_ri_p_thresh = 27.0 1421 REAL, PARAMETER :: zrot=0._wp ! dummy rotation rate of surface stress. 1422 1423 ! Determins stability and set flag lconv 1424 DO_2D( 0, 0, 0, 0 ) 1425 IF ( zhol(ji,jj) < 0._wp ) THEN 1426 lconv(ji,jj) = .TRUE. 1427 ELSE 1428 lconv(ji,jj) = .FALSE. 1429 ENDIF 1430 END_2D 1431 1432 zekman(:,:) = EXP( - 4.0 * ABS( ff_t(:,:) ) * zhbl(:,:) / MAX(zustar(:,:), 1.e-8 ) ) 1433 1434 WHERE ( lconv ) 1435 zri_i = zdb_ml * zhml**2 / MAX( ( zvstr**3 + 0.5 * zwstrc**3 )**p2third * zdh, 1.e-12 ) 1436 END WHERE 1437 1438 zshear(:,:) = 0._wp 1439 j_ddh(:,:) = 1 1440 1441 DO_2D( 0, 0, 0, 0 ) 1442 IF ( lconv(ji,jj) ) THEN 1443 IF ( zdb_bl(ji,jj) > 0._wp ) THEN 1444 zri_p = MAX ( SQRT( zdb_bl(ji,jj) * zdh(ji,jj) / MAX( zdu_bl(ji,jj)**2 + zdv_bl(ji,jj)**2, 1.e-8) ) * ( zhbl(ji,jj) / zdh(ji,jj) ) * ( zvstr(ji,jj) / MAX( zustar(ji,jj), 1.e-6 ) )**2 & 1445 & / MAX( zekman(ji,jj), 1.e-6 ) , 5._wp ) 1446 1447 zri_b = zdb_ml(ji,jj) * zdh(ji,jj) / MAX( zdu_ml(ji,jj)**2 + zdv_ml(ji,jj)**2, 1.e-8 ) 1448 1449 zshear(ji,jj) = za_shr * zekman(ji,jj) * ( MAX( zustar(ji,jj)**2 * zdu_ml(ji,jj) / zhbl(ji,jj), 0._wp ) + zb_shr * MAX( -ff_t(ji,jj) * zustke(ji,jj) * dstokes(ji,jj) * zdv_ml(ji,jj) / zhbl(ji,jj), 0._wp ) ) 1450 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1451 ! Test ensures j_ddh=0 is not selected. Change to zri_p<27 when ! 1452 ! full code available ! 1453 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1454 IF ( zri_p < -rn_ri_p_thresh .and. zshear(ji,jj) > 0._wp ) THEN 1455 ! Growing shear layer 1456 j_ddh(ji,jj) = 0 1457 lshear(ji,jj) = .TRUE. 1458 ELSE 1459 j_ddh(ji,jj) = 1 1460 IF ( zri_b <= 1.5 .and. zshear(ji,jj) > 0._wp ) THEN 1461 ! shear production large enough to determine layer charcteristics, but can't maintain a shear layer. 1462 lshear(ji,jj) = .TRUE. 1463 ELSE 1464 ! Shear production may not be zero, but is small and doesn't determine characteristics of pycnocline. 1465 zshear(ji,jj) = 0.5 * zshear(ji,jj) 1466 lshear(ji,jj) = .FALSE. 1467 ENDIF 1468 ENDIF 1469 ELSE ! zdb_bl test, note zshear set to zero 1470 j_ddh(ji,jj) = 2 1471 lshear(ji,jj) = .FALSE. 1472 ENDIF 1473 ENDIF 1474 END_2D 1475 1476 ! Calculate entrainment buoyancy flux due to surface fluxes. 1477 1478 DO_2D( 0, 0, 0, 0 ) 1479 IF ( lconv(ji,jj) ) THEN 1480 zwcor = ABS(ff_t(ji,jj)) * zhbl(ji,jj) + epsln 1481 zrf_conv = TANH( ( zwstrc(ji,jj) / zwcor )**0.69 ) 1482 zrf_shear = TANH( ( zustar(ji,jj) / zwcor )**0.69 ) 1483 zrf_langmuir = TANH( ( zwstrl(ji,jj) / zwcor )**0.69 ) 1484 IF (nn_osm_SD_reduce > 0 ) THEN 1485 ! Effective Stokes drift already reduced from surface value 1486 zr_stokes = 1.0_wp 1487 ELSE 1488 ! Effective Stokes drift only reduced by factor rn_zdfodm_adjust_sd, 1489 ! requires further reduction where BL is deep 1490 zr_stokes = 1.0 - EXP( -25.0 * dstokes(ji,jj) / hbl(ji,jj) & 1491 & * ( 1.0 + 4.0 * dstokes(ji,jj) / hbl(ji,jj) ) ) 1492 END IF 1493 zwb_ent(ji,jj) = - 2.0 * 0.2 * zrf_conv * zwbav(ji,jj) & 1494 & - 0.15 * zrf_shear * zustar(ji,jj)**3 /zhml(ji,jj) & 1495 & + zr_stokes * ( 0.15 * EXP( -1.5 * zla(ji,jj) ) * zrf_shear * zustar(ji,jj)**3 & 1496 & - zrf_langmuir * 0.03 * zwstrl(ji,jj)**3 ) / zhml(ji,jj) 1497 ! 1498 ENDIF 1499 END_2D 1500 1501 zwb_min(:,:) = 0._wp 1502 1503 DO_2D( 0, 0, 0, 0 ) 1504 IF ( lshear(ji,jj) ) THEN 1505 IF ( lconv(ji,jj) ) THEN 1506 ! Unstable OSBL 1507 zwb_shr = -za_wb_s * zshear(ji,jj) 1508 IF ( j_ddh(ji,jj) == 0 ) THEN 1509 1510 ! Developing shear layer, additional shear production possible. 1511 1512 zshear_u = MAX( zustar(ji,jj)**2 * zdu_ml(ji,jj) / zhbl(ji,jj), 0._wp ) 1513 zshear(ji,jj) = zshear(ji,jj) + zshear_u * ( 1.0 - MIN( zri_p / rn_ri_p_thresh, 1.d0 ) ) 1514 zshear(ji,jj) = MIN( zshear(ji,jj), zshear_u ) 1515 1516 zwb_shr = -za_wb_s * zshear(ji,jj) 1517 1518 ENDIF 1519 zwb_ent(ji,jj) = zwb_ent(ji,jj) + zwb_shr 1520 zwb_min(ji,jj) = zwb_ent(ji,jj) + zdh(ji,jj) / zhbl(ji,jj) * zwb0(ji,jj) 1521 ELSE ! IF ( lconv ) THEN - ENDIF 1522 ! Stable OSBL - shear production not coded for first attempt. 1523 ENDIF ! lconv 1524 ELSE ! lshear 1525 IF ( lconv(ji,jj) ) THEN 1526 ! Unstable OSBL 1527 zwb_shr = -za_wb_s * zshear(ji,jj) 1528 zwb_ent(ji,jj) = zwb_ent(ji,jj) + zwb_shr 1529 zwb_min(ji,jj) = zwb_ent(ji,jj) + zdh(ji,jj) / zhbl(ji,jj) * zwb0(ji,jj) 1530 ENDIF ! lconv 1531 ENDIF ! lshear 1532 END_2D 1533 END SUBROUTINE zdf_osm_osbl_state 1534 1535 1536 SUBROUTINE zdf_osm_vertical_average( jnlev_av, jp_ext, zt, zs, zb, zu, zv, zdt, zds, zdb, zdu, zdv ) 1537 !!--------------------------------------------------------------------- 1538 !! *** ROUTINE zdf_vertical_average *** 1539 !! 1540 !! ** Purpose : Determines vertical averages from surface to jnlev. 1541 !! 1542 !! ** Method : Averages are calculated from the surface to jnlev. 1543 !! The external level used to calculate differences is ibld+ibld_ext 1544 !! 1545 !!---------------------------------------------------------------------- 1546 1547 INTEGER, DIMENSION(jpi,jpj) :: jnlev_av ! Number of levels to average over. 1548 INTEGER, DIMENSION(jpi,jpj) :: jp_ext 1549 1550 ! Alan: do we need zb? 1551 REAL(wp), DIMENSION(jpi,jpj) :: zt, zs, zb ! Average temperature and salinity 1552 REAL(wp), DIMENSION(jpi,jpj) :: zu,zv ! Average current components 1553 REAL(wp), DIMENSION(jpi,jpj) :: zdt, zds, zdb ! Difference between average and value at base of OSBL 1554 REAL(wp), DIMENSION(jpi,jpj) :: zdu, zdv ! Difference for velocity components. 1555 1556 INTEGER :: jk, ji, jj, ibld_ext 1557 REAL(wp) :: zthick, zthermal, zbeta 1558 1559 1560 zt = 0._wp 1561 zs = 0._wp 1562 zu = 0._wp 1563 zv = 0._wp 1564 DO_2D( 0, 0, 0, 0 ) 1565 zthermal = rab_n(ji,jj,1,jp_tem) !ideally use ibld not 1?? 1566 zbeta = rab_n(ji,jj,1,jp_sal) 1567 ! average over depth of boundary layer 1568 zthick = epsln 1569 DO jk = 2, jnlev_av(ji,jj) 1570 zthick = zthick + e3t(ji,jj,jk,Kmm) 1571 zt(ji,jj) = zt(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_tem,Kmm) 1572 zs(ji,jj) = zs(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_sal,Kmm) 1573 zu(ji,jj) = zu(ji,jj) + e3t(ji,jj,jk,Kmm) & 1574 & * ( uu(ji,jj,jk,Kbb) + uu(ji - 1,jj,jk,Kbb) ) & 1575 & / MAX( 1. , umask(ji,jj,jk) + umask(ji - 1,jj,jk) ) 1576 zv(ji,jj) = zv(ji,jj) + e3t(ji,jj,jk,Kmm) & 1577 & * ( vv(ji,jj,jk,Kbb) + vv(ji,jj - 1,jk,Kbb) ) & 1578 & / MAX( 1. , vmask(ji,jj,jk) + vmask(ji,jj - 1,jk) ) 1579 END DO 1580 zt(ji,jj) = zt(ji,jj) / zthick 1581 zs(ji,jj) = zs(ji,jj) / zthick 1582 zu(ji,jj) = zu(ji,jj) / zthick 1583 zv(ji,jj) = zv(ji,jj) / zthick 1584 zb(ji,jj) = grav * zthermal * zt(ji,jj) - grav * zbeta * zs(ji,jj) 1585 ibld_ext = jnlev_av(ji,jj) + jp_ext(ji,jj) 1586 IF ( ibld_ext < mbkt(ji,jj) ) THEN 1587 zdt(ji,jj) = zt(ji,jj) - ts(ji,jj,ibld_ext,jp_tem,Kmm) 1588 zds(ji,jj) = zs(ji,jj) - ts(ji,jj,ibld_ext,jp_sal,Kmm) 1589 zdu(ji,jj) = zu(ji,jj) - ( uu(ji,jj,ibld_ext,Kbb) + uu(ji-1,jj,ibld_ext,Kbb ) ) & 1590 & / MAX(1. , umask(ji,jj,ibld_ext ) + umask(ji-1,jj,ibld_ext ) ) 1591 zdv(ji,jj) = zv(ji,jj) - ( vv(ji,jj,ibld_ext,Kbb) + vv(ji,jj-1,ibld_ext,Kbb ) ) & 1592 & / MAX(1. , vmask(ji,jj,ibld_ext ) + vmask(ji,jj-1,ibld_ext ) ) 1593 zdb(ji,jj) = grav * zthermal * zdt(ji,jj) - grav * zbeta * zds(ji,jj) 1594 ELSE 1595 zdt(ji,jj) = 0._wp 1596 zds(ji,jj) = 0._wp 1597 zdu(ji,jj) = 0._wp 1598 zdv(ji,jj) = 0._wp 1599 zdb(ji,jj) = 0._wp 1600 ENDIF 1601 END_2D 1602 END SUBROUTINE zdf_osm_vertical_average 1603 1604 SUBROUTINE zdf_osm_velocity_rotation( zcos_w, zsin_w, zu, zv, zdu, zdv ) 1605 !!--------------------------------------------------------------------- 1606 !! *** ROUTINE zdf_velocity_rotation *** 1607 !! 1608 !! ** Purpose : Rotates frame of reference of averaged velocity components. 1609 !! 1610 !! ** Method : The velocity components are rotated into frame specified by zcos_w and zsin_w 1611 !! 1612 !!---------------------------------------------------------------------- 1613 1614 REAL(wp), DIMENSION(jpi,jpj) :: zcos_w, zsin_w ! Cos and Sin of rotation angle 1615 REAL(wp), DIMENSION(jpi,jpj) :: zu, zv ! Components of current 1616 REAL(wp), DIMENSION(jpi,jpj) :: zdu, zdv ! Change in velocity components across pycnocline 1617 1618 INTEGER :: ji, jj 1619 REAL(wp) :: ztemp 1620 1621 DO_2D( 0, 0, 0, 0 ) 1622 ztemp = zu(ji,jj) 1623 zu(ji,jj) = zu(ji,jj) * zcos_w(ji,jj) + zv(ji,jj) * zsin_w(ji,jj) 1624 zv(ji,jj) = zv(ji,jj) * zcos_w(ji,jj) - ztemp * zsin_w(ji,jj) 1625 ztemp = zdu(ji,jj) 1626 zdu(ji,jj) = zdu(ji,jj) * zcos_w(ji,jj) + zdv(ji,jj) * zsin_w(ji,jj) 1627 zdv(ji,jj) = zdv(ji,jj) * zsin_w(ji,jj) - ztemp * zsin_w(ji,jj) 1628 END_2D 1629 END SUBROUTINE zdf_osm_velocity_rotation 1630 1631 SUBROUTINE zdf_osm_osbl_state_fk( lpyc, lflux, lmle, zwb_fk ) 1632 !!--------------------------------------------------------------------- 1633 !! *** ROUTINE zdf_osm_osbl_state_fk *** 1634 !! 1635 !! ** Purpose : Determines the state of the OSBL and MLE layer. Info is returned in the logicals lpyc,lflux and lmle. Used with Fox-Kemper scheme. 1636 !! lpyc :: determines whether pycnocline flux-grad relationship needs to be determined 1637 !! lflux :: determines whether effects of surface flux extend below the base of the OSBL 1638 !! lmle :: determines whether the layer with MLE is increasing with time or if base is relaxing towards hbl. 1639 !! 1640 !! ** Method : 1641 !! 1642 !! 1643 !!---------------------------------------------------------------------- 1644 1645 ! Outputs 1646 LOGICAL, DIMENSION(jpi,jpj) :: lpyc, lflux, lmle 1647 REAL(wp), DIMENSION(jpi,jpj) :: zwb_fk 1648 ! 1649 REAL(wp), DIMENSION(jpi,jpj) :: znd_param 1650 REAL(wp) :: zbuoy, ztmp, zpe_mle_layer 1651 REAL(wp) :: zpe_mle_ref, zwb_ent, zdbdz_mle_int 1652 1653 znd_param(:,:) = 0._wp 1654 1655 DO_2D( 0, 0, 0, 0 ) 1656 ztmp = r1_ft(ji,jj) * MIN( 111.e3_wp , e1u(ji,jj) ) / rn_osm_mle_lf 1657 zwb_fk(ji,jj) = rn_osm_mle_ce * hmle(ji,jj) * hmle(ji,jj) * ztmp * zdbds_mle(ji,jj) * zdbds_mle(ji,jj) 1658 END_2D 1659 DO_2D( 0, 0, 0, 0 ) 1660 ! 1661 IF ( lconv(ji,jj) ) THEN 1662 IF ( zhmle(ji,jj) > 1.2 * zhbl(ji,jj) ) THEN 1663 zt_mle(ji,jj) = ( zt_mle(ji,jj) * zhmle(ji,jj) - zt_bl(ji,jj) * zhbl(ji,jj) ) / ( zhmle(ji,jj) - zhbl(ji,jj) ) 1664 zs_mle(ji,jj) = ( zs_mle(ji,jj) * zhmle(ji,jj) - zs_bl(ji,jj) * zhbl(ji,jj) ) / ( zhmle(ji,jj) - zhbl(ji,jj) ) 1665 zb_mle(ji,jj) = ( zb_mle(ji,jj) * zhmle(ji,jj) - zb_bl(ji,jj) * zhbl(ji,jj) ) / ( zhmle(ji,jj) - zhbl(ji,jj) ) 1666 zdbdz_mle_int = ( zb_bl(ji,jj) - ( 2.0 * zb_mle(ji,jj) -zb_bl(ji,jj) ) ) / ( zhmle(ji,jj) - zhbl(ji,jj) ) 1667 ! Calculate potential energies of actual profile and reference profile. 1668 zpe_mle_layer = 0._wp 1669 zpe_mle_ref = 0._wp 1670 DO jk = ibld(ji,jj), mld_prof(ji,jj) 1671 zbuoy = grav * ( zthermal * ts(ji,jj,jk,jp_tem,Kmm) - zbeta * ts(ji,jj,jk,jp_sal,Kmm) ) 1672 zpe_mle_layer = zpe_mle_layer + zbuoy * gdepw(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 1673 zpe_mle_ref = zpe_mle_ref + ( zb_bl(ji,jj) - zdbdz_mle_int * ( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) ) * gdepw(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 1674 END DO 1675 ! Non-dimensional parameter to diagnose the presence of thermocline 1676 1677 znd_param(ji,jj) = ( zpe_mle_layer - zpe_mle_ref ) * ABS( ff_t(ji,jj) ) / ( MAX( zwb_fk(ji,jj), 1.0e-10 ) * zhmle(ji,jj) ) 1678 ENDIF 1679 ENDIF 1680 END_2D 1681 1682 ! Diagnosis 1683 DO_2D( 0, 0, 0, 0 ) 1684 IF ( lconv(ji,jj) ) THEN 1685 zwb_ent = - 2.0 * 0.2 * zwbav(ji,jj) & 1686 & - 0.15 * zustar(ji,jj)**3 /zhml(ji,jj) & 1687 & + ( 0.15 * EXP( -1.5 * zla(ji,jj) ) * zustar(ji,jj)**3 & 1688 & - 0.03 * zwstrl(ji,jj)**3 ) / zhml(ji,jj) 1689 IF ( -2.0 * zwb_fk(ji,jj) / zwb_ent > 0.5 ) THEN 1690 IF ( zhmle(ji,jj) > 1.2 * zhbl(ji,jj) ) THEN 1691 ! MLE layer growing 1692 IF ( znd_param (ji,jj) > 100. ) THEN 1693 ! Thermocline present 1694 lflux(ji,jj) = .FALSE. 1695 lmle(ji,jj) =.FALSE. 1696 ELSE 1697 ! Thermocline not present 1698 lflux(ji,jj) = .TRUE. 1699 lmle(ji,jj) = .TRUE. 1700 ENDIF ! znd_param > 100 1701 ! 1702 IF ( zdb_bl(ji,jj) < rn_osm_bl_thresh ) THEN 1703 lpyc(ji,jj) = .FALSE. 1704 ELSE 1705 lpyc = .TRUE. 1706 ENDIF 1707 ELSE 1708 ! MLE layer restricted to OSBL or just below. 1709 IF ( zdb_bl(ji,jj) < rn_osm_bl_thresh ) THEN 1710 ! Weak stratification MLE layer can grow. 1711 lpyc(ji,jj) = .FALSE. 1712 lflux(ji,jj) = .TRUE. 1713 lmle(ji,jj) = .TRUE. 1714 ELSE 1715 ! Strong stratification 1716 lpyc(ji,jj) = .TRUE. 1717 lflux(ji,jj) = .FALSE. 1718 lmle(ji,jj) = .FALSE. 1719 ENDIF ! zdb_bl < rn_mle_thresh_bl and 1720 ENDIF ! zhmle > 1.2 zhbl 1721 ELSE 1722 lpyc(ji,jj) = .TRUE. 1723 lflux(ji,jj) = .FALSE. 1724 lmle(ji,jj) = .FALSE. 1725 IF ( zdb_bl(ji,jj) < rn_osm_bl_thresh ) lpyc(ji,jj) = .FALSE. 1726 ENDIF ! -2.0 * zwb_fk(ji,jj) / zwb_ent > 0.5 1727 ELSE 1728 ! Stable Boundary Layer 1729 lpyc(ji,jj) = .FALSE. 1730 lflux(ji,jj) = .FALSE. 1731 lmle(ji,jj) = .FALSE. 1732 ENDIF ! lconv 1733 END_2D 1734 END SUBROUTINE zdf_osm_osbl_state_fk 1735 1736 SUBROUTINE zdf_osm_external_gradients(jbase, zdtdz, zdsdz, zdbdz ) 1737 !!--------------------------------------------------------------------- 1738 !! *** ROUTINE zdf_osm_external_gradients *** 1739 !! 1740 !! ** Purpose : Calculates the gradients below the OSBL 1741 !! 1742 !! ** Method : Uses ibld and ibld_ext to determine levels to calculate the gradient. 1743 !! 1744 !!---------------------------------------------------------------------- 1745 1746 INTEGER, DIMENSION(jpi,jpj) :: jbase 1747 REAL(wp), DIMENSION(jpi,jpj) :: zdtdz, zdsdz, zdbdz ! External gradients of temperature, salinity and buoyancy. 1748 1749 INTEGER :: jj, ji, jkb, jkb1 1750 REAL(wp) :: zthermal, zbeta 1751 1752 1753 DO_2D( 0, 0, 0, 0 ) 1754 IF ( jbase(ji,jj)+1 < mbkt(ji,jj) ) THEN 1755 zthermal = rab_n(ji,jj,1,jp_tem) !ideally use ibld not 1?? 1756 zbeta = rab_n(ji,jj,1,jp_sal) 1757 jkb = jbase(ji,jj) 1758 jkb1 = MIN(jkb + 1, mbkt(ji,jj)) 1759 zdtdz(ji,jj) = - ( ts(ji,jj,jkb1,jp_tem,Kmm) - ts(ji,jj,jkb,jp_tem,Kmm ) ) & 1760 & / e3t(ji,jj,ibld(ji,jj),Kmm) 1761 zdsdz(ji,jj) = - ( ts(ji,jj,jkb1,jp_sal,Kmm) - ts(ji,jj,jkb,jp_sal,Kmm ) ) & 1762 & / e3t(ji,jj,ibld(ji,jj),Kmm) 1763 zdbdz(ji,jj) = grav * zthermal * zdtdz(ji,jj) - grav * zbeta * zdsdz(ji,jj) 1764 ELSE 1765 zdtdz(ji,jj) = 0._wp 1766 zdsdz(ji,jj) = 0._wp 1767 zdbdz(ji,jj) = 0._wp 1768 END IF 1769 END_2D 1770 END SUBROUTINE zdf_osm_external_gradients 1771 1772 SUBROUTINE zdf_osm_pycnocline_scalar_profiles( zdtdz, zdsdz, zdbdz, zalpha ) 1773 1774 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdtdz, zdsdz, zdbdz ! gradients in the pycnocline 1775 REAL(wp), DIMENSION(jpi,jpj) :: zalpha 1776 1777 INTEGER :: jk, jj, ji 1778 REAL(wp) :: ztgrad, zsgrad, zbgrad 1779 REAL(wp) :: zgamma_b_nd, znd 1780 REAL(wp) :: zzeta_m, zzeta_en, zbuoy_pyc_sc 1781 REAL(wp), PARAMETER :: zgamma_b = 2.25, zzeta_sh = 0.15 1782 1783 DO_2D( 0, 0, 0, 0 ) 1784 IF ( ibld(ji,jj) + jp_ext(ji,jj) < mbkt(ji,jj) ) THEN 1785 IF ( lconv(ji,jj) ) THEN ! convective conditions 1786 IF ( lpyc(ji,jj) ) THEN 1787 zzeta_m = 0.1 + 0.3 / ( 1.0 + EXP( -3.5 * LOG10( -zhol(ji,jj) ) ) ) 1788 zalpha(ji,jj) = 2.0 * ( 1.0 - ( 0.80 * zzeta_m + 0.5 * SQRT( 3.14159 / zgamma_b ) ) * zdbdz_bl_ext(ji,jj) * zdh(ji,jj) / zdb_ml(ji,jj) ) / ( 0.723 + SQRT( 3.14159 / zgamma_b ) ) 1789 zalpha(ji,jj) = MAX( zalpha(ji,jj), 0._wp ) 1790 1791 ztmp = 1._wp/MAX(zdh(ji,jj), epsln) 1792 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1793 ! Commented lines in this section are not needed in new code, once tested ! 1794 ! can be removed ! 1795 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1796 ! ztgrad = zalpha * zdt_ml(ji,jj) * ztmp + zdtdz_bl_ext(ji,jj) 1797 ! zsgrad = zalpha * zds_ml(ji,jj) * ztmp + zdsdz_bl_ext(ji,jj) 1798 zbgrad = zalpha(ji,jj) * zdb_ml(ji,jj) * ztmp + zdbdz_bl_ext(ji,jj) 1799 zgamma_b_nd = zdbdz_bl_ext(ji,jj) * zdh(ji,jj) / MAX(zdb_ml(ji,jj), epsln) 1800 DO jk = 2, ibld(ji,jj)+ibld_ext 1801 znd = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) * ztmp 1802 IF ( znd <= zzeta_m ) THEN 1803 ! zdtdz(ji,jj,jk) = zdtdz_bl_ext(ji,jj) + zalpha * zdt_ml(ji,jj) * ztmp * & 1804 ! & EXP( -6.0 * ( znd -zzeta_m )**2 ) 1805 ! zdsdz(ji,jj,jk) = zdsdz_bl_ext(ji,jj) + zalpha * zds_ml(ji,jj) * ztmp * & 1806 ! & EXP( -6.0 * ( znd -zzeta_m )**2 ) 1807 zdbdz(ji,jj,jk) = zdbdz_bl_ext(ji,jj) + zalpha(ji,jj) * zdb_ml(ji,jj) * ztmp * & 1808 & EXP( -6.0 * ( znd -zzeta_m )**2 ) 1809 ELSE 1810 ! zdtdz(ji,jj,jk) = ztgrad * EXP( -zgamma_b * ( znd - zzeta_m )**2 ) 1811 ! zdsdz(ji,jj,jk) = zsgrad * EXP( -zgamma_b * ( znd - zzeta_m )**2 ) 1812 zdbdz(ji,jj,jk) = zbgrad * EXP( -zgamma_b * ( znd - zzeta_m )**2 ) 1813 ENDIF 1814 END DO 1815 ENDIF ! if no pycnocline pycnocline gradients set to zero 1816 ELSE 1817 ! stable conditions 1818 ! if pycnocline profile only defined when depth steady of increasing. 1819 IF ( zdhdt(ji,jj) > 0.0 ) THEN ! Depth increasing, or steady. 1820 IF ( zdb_bl(ji,jj) > 0._wp ) THEN 1821 IF ( zhol(ji,jj) >= 0.5 ) THEN ! Very stable - 'thick' pycnocline 1822 ztmp = 1._wp/MAX(zhbl(ji,jj), epsln) 1823 ztgrad = zdt_bl(ji,jj) * ztmp 1824 zsgrad = zds_bl(ji,jj) * ztmp 1825 zbgrad = zdb_bl(ji,jj) * ztmp 1826 DO jk = 2, ibld(ji,jj) 1827 znd = gdepw(ji,jj,jk,Kmm) * ztmp 1828 zdtdz(ji,jj,jk) = ztgrad * EXP( -15.0 * ( znd - 0.9 )**2 ) 1829 zdbdz(ji,jj,jk) = zbgrad * EXP( -15.0 * ( znd - 0.9 )**2 ) 1830 zdsdz(ji,jj,jk) = zsgrad * EXP( -15.0 * ( znd - 0.9 )**2 ) 1831 END DO 1832 ELSE ! Slightly stable - 'thin' pycnoline - needed when stable layer begins to form. 1833 ztmp = 1._wp/MAX(zdh(ji,jj), epsln) 1834 ztgrad = zdt_bl(ji,jj) * ztmp 1835 zsgrad = zds_bl(ji,jj) * ztmp 1836 zbgrad = zdb_bl(ji,jj) * ztmp 1837 DO jk = 2, ibld(ji,jj) 1838 znd = -( gdepw(ji,jj,jk,Kmm) - zhml(ji,jj) ) * ztmp 1839 zdtdz(ji,jj,jk) = ztgrad * EXP( -1.75 * ( znd + 0.75 )**2 ) 1840 zdbdz(ji,jj,jk) = zbgrad * EXP( -1.75 * ( znd + 0.75 )**2 ) 1841 zdsdz(ji,jj,jk) = zsgrad * EXP( -1.75 * ( znd + 0.75 )**2 ) 1842 END DO 1843 ENDIF ! IF (zhol >=0.5) 1844 ENDIF ! IF (zdb_bl> 0.) 1845 ENDIF ! IF (zdhdt >= 0) zdhdt < 0 not considered since pycnocline profile is zero and profile arrays are intialized to zero 1846 ENDIF ! IF (lconv) 1847 ENDIF ! IF ( ibld(ji,jj) < mbkt(ji,jj) ) 1848 END_2D 1849 1850 END SUBROUTINE zdf_osm_pycnocline_scalar_profiles 1851 1852 SUBROUTINE zdf_osm_pycnocline_shear_profiles( zdudz, zdvdz ) 1681 phbl(ji,jj) = gdepw(ji,jj,nbld(ji,jj),Kmm) 1682 END_2D 1683 ! 1684 END SUBROUTINE zdf_osm_timestep_hbl 1685 1686 SUBROUTINE zdf_osm_pycnocline_thickness( Kmm, pdh, phml, pdhdt, phbl, & 1687 & pwb_ent, pdbdz_bl_ext, pwb_fk_b ) 1853 1688 !!--------------------------------------------------------------------- 1854 !! *** ROUTINE zdf_osm_pycnocline_shear_profiles *** 1855 !! 1856 !! ** Purpose : Calculates velocity shear in the pycnocline 1857 !! 1858 !! ** Method : 1859 !! 1860 !!---------------------------------------------------------------------- 1861 1862 REAL(wp), DIMENSION(jpi,jpj,jpk) :: zdudz, zdvdz 1863 1864 INTEGER :: jk, jj, ji 1865 REAL(wp) :: zugrad, zvgrad, znd 1866 REAL(wp) :: zzeta_v = 0.45 1867 ! 1868 DO_2D( 0, 0, 0, 0 ) 1869 ! 1870 IF ( ibld(ji,jj) + jp_ext(ji,jj) < mbkt(ji,jj) ) THEN 1871 IF ( lconv (ji,jj) ) THEN 1872 ! Unstable conditions. Shouldn;t be needed with no pycnocline code. 1873 ! zugrad = 0.7 * zdu_ml(ji,jj) / zdh(ji,jj) + 0.3 * zustar(ji,jj)*zustar(ji,jj) / & 1874 ! & ( ( ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird * zhml(ji,jj) ) * & 1875 ! & MIN(zla(ji,jj)**(8.0/3.0) + epsln, 0.12 )) 1876 !Alan is this right? 1877 ! zvgrad = ( 0.7 * zdv_ml(ji,jj) + & 1878 ! & 2.0 * ff_t(ji,jj) * zustke(ji,jj) * dstokes(ji,jj) / & 1879 ! & ( ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird + epsln ) & 1880 ! & )/ (zdh(ji,jj) + epsln ) 1881 ! DO jk = 2, ibld(ji,jj) - 1 + ibld_ext 1882 ! znd = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / (zdh(ji,jj) + epsln ) - zzeta_v 1883 ! IF ( znd <= 0.0 ) THEN 1884 ! zdudz(ji,jj,jk) = 1.25 * zugrad * EXP( 3.0 * znd ) 1885 ! zdvdz(ji,jj,jk) = 1.25 * zvgrad * EXP( 3.0 * znd ) 1886 ! ELSE 1887 ! zdudz(ji,jj,jk) = 1.25 * zugrad * EXP( -2.0 * znd ) 1888 ! zdvdz(ji,jj,jk) = 1.25 * zvgrad * EXP( -2.0 * znd ) 1889 ! ENDIF 1890 ! END DO 1891 ELSE 1892 ! stable conditions 1893 zugrad = 3.25 * zdu_bl(ji,jj) / zhbl(ji,jj) 1894 zvgrad = 2.75 * zdv_bl(ji,jj) / zhbl(ji,jj) 1895 DO jk = 2, ibld(ji,jj) 1896 znd = gdepw(ji,jj,jk,Kmm) / zhbl(ji,jj) 1897 IF ( znd < 1.0 ) THEN 1898 zdudz(ji,jj,jk) = zugrad * EXP( -40.0 * ( znd - 1.0 )**2 ) 1899 ELSE 1900 zdudz(ji,jj,jk) = zugrad * EXP( -20.0 * ( znd - 1.0 )**2 ) 1901 ENDIF 1902 zdvdz(ji,jj,jk) = zvgrad * EXP( -20.0 * ( znd - 0.85 )**2 ) 1903 END DO 1904 ENDIF 1905 ! 1906 END IF ! IF ( ibld(ji,jj) + ibld_ext < mbkt(ji,jj) ) 1907 END_2D 1908 END SUBROUTINE zdf_osm_pycnocline_shear_profiles 1909 1910 SUBROUTINE zdf_osm_calculate_dhdt( zdhdt, zddhdt ) 1911 !!--------------------------------------------------------------------- 1912 !! *** ROUTINE zdf_osm_calculate_dhdt *** 1913 !! 1914 !! ** Purpose : Calculates the rate at which hbl changes. 1915 !! 1916 !! ** Method : 1917 !! 1918 !!---------------------------------------------------------------------- 1919 1920 REAL(wp), DIMENSION(jpi,jpj) :: zdhdt, zddhdt ! Rate of change of hbl 1921 1922 INTEGER :: jj, ji 1923 REAL(wp) :: zgamma_b_nd, zgamma_dh_nd, zpert, zpsi 1924 REAL(wp) :: zvel_max!, zwb_min 1925 REAL(wp) :: zzeta_m = 0.3 1926 REAL(wp) :: zgamma_c = 2.0 1927 REAL(wp) :: zdhoh = 0.1 1928 REAL(wp) :: alpha_bc = 0.5 1929 REAL, PARAMETER :: a_ddh = 2.5, a_ddh_2 = 3.5 ! also in pycnocline_depth 1930 1931 DO_2D( 0, 0, 0, 0 ) 1932 1933 IF ( lshear(ji,jj) ) THEN 1934 IF ( lconv(ji,jj) ) THEN ! Convective 1935 1936 IF ( ln_osm_mle ) THEN 1937 1938 IF ( hmle(ji,jj) > hbl(ji,jj) ) THEN 1939 ! Fox-Kemper buoyancy flux average over OSBL 1940 zwb_fk_b(ji,jj) = zwb_fk(ji,jj) * & 1941 (1.0 + hmle(ji,jj) / ( 6.0 * hbl(ji,jj) ) * (-1.0 + ( 1.0 - 2.0 * hbl(ji,jj) / hmle(ji,jj))**3) ) 1942 ELSE 1943 zwb_fk_b(ji,jj) = 0.5 * zwb_fk(ji,jj) * hmle(ji,jj) / hbl(ji,jj) 1944 ENDIF 1945 zvel_max = ( zwstrl(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 1946 IF ( ( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) < 0.0 ) THEN 1947 ! OSBL is deepening, entrainment > restratification 1948 IF ( zdb_bl(ji,jj) > 0.0 .and. zdbdz_bl_ext(ji,jj) > 0.0 ) THEN 1949 ! *** Used for shear Needs to be changed to work stabily 1950 ! zgamma_b_nd = zdbdz_bl_ext * dh / zdb_ml 1951 ! zalpha_b = 6.7 * zgamma_b_nd / ( 1.0 + zgamma_b_nd ) 1952 ! zgamma_b = zgamma_b_nd / ( 0.12 * ( 1.25 + zgamma_b_nd ) ) 1953 ! za_1 = 1.0 / zgamma_b**2 - 0.017 1954 ! za_2 = 1.0 / zgamma_b**3 - 0.0025 1955 ! zpsi = zalpha_b * ( 1.0 + zgamma_b_nd ) * ( za_1 - 2.0 * za_2 * dh / hbl ) 1956 zpsi = 0._wp 1957 zdhdt(ji,jj) = -( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) / ( zvel_max + MAX(zdb_bl(ji,jj), 1.0e-15) ) 1958 zdhdt(ji,jj) = zdhdt(ji,jj)! - zpsi * ( -1.0 / zhml(ji,jj) + 2.4 * zdbdz_bl_ext(ji,jj) / zdb_ml(ji,jj) ) * zwb_min(ji,jj) * zdh(ji,jj) / zdb_bl(ji,jj) 1959 IF ( j_ddh(ji,jj) == 1 ) THEN 1960 IF ( ( zwstrc(ji,jj) / zvstr(ji,jj) )**3 <= 0.5 ) THEN 1961 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zvstr(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 1962 ELSE 1963 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zwstrc(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 1964 ENDIF 1965 ! Relaxation to dh_ref = zari * hbl 1966 zddhdt(ji,jj) = -a_ddh_2 * ( 1.0 - zdh(ji,jj) / ( zari * zhbl(ji,jj) ) ) * zwb_ent(ji,jj) / zdb_bl(ji,jj) 1967 1968 ELSE ! j_ddh == 0 1969 ! Growing shear layer 1970 zddhdt(ji,jj) = -a_ddh * ( 1.0 - zdh(ji,jj) / zhbl(ji,jj) ) * zwb_ent(ji,jj) / zdb_bl(ji,jj) 1971 ENDIF ! j_ddh 1972 zdhdt(ji,jj) = zdhdt(ji,jj) ! + zpsi * zddhdt(ji,jj) 1973 ELSE ! zdb_bl >0 1974 zdhdt(ji,jj) = -( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) / MAX( zvel_max, 1.0e-15) 1975 ENDIF 1976 ELSE ! zwb_min + 2*zwb_fk_b < 0 1977 ! OSBL shoaling due to restratification flux. This is the velocity defined in Fox-Kemper et al (2008) 1978 zdhdt(ji,jj) = - zvel_mle(ji,jj) 1979 1980 1981 ENDIF 1982 1983 ELSE 1984 ! Fox-Kemper not used. 1985 1986 zvel_max = - ( 1.0 + 1.0 * ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird * rn_Dt / hbl(ji,jj) ) * zwb_ent(ji,jj) / & 1987 & MAX((zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird, epsln) 1988 zdhdt(ji,jj) = -zwb_ent(ji,jj) / ( zvel_max + MAX(zdb_bl(ji,jj), 1.0e-15) ) 1989 ! added ajgn 23 July as temporay fix 1990 1991 ENDIF ! ln_osm_mle 1992 1993 ELSE ! lconv - Stable 1994 zdhdt(ji,jj) = ( 0.06 + 0.52 * zhol(ji,jj) / 2.0 ) * zvstr(ji,jj)**3 / hbl(ji,jj) + zwbav(ji,jj) 1995 IF ( zdhdt(ji,jj) < 0._wp ) THEN 1996 ! For long timsteps factor in brackets slows the rapid collapse of the OSBL 1997 zpert = 2.0 * ( 1.0 + 0.0 * 2.0 * zvstr(ji,jj) * rn_Dt / hbl(ji,jj) ) * zvstr(ji,jj)**2 / hbl(ji,jj) 1998 ELSE 1999 zpert = MAX( 2.0 * zvstr(ji,jj)**2 / hbl(ji,jj), zdb_bl(ji,jj) ) 2000 ENDIF 2001 zdhdt(ji,jj) = 2.0 * zdhdt(ji,jj) / MAX(zpert, epsln) 2002 ENDIF ! lconv 2003 ELSE ! lshear 2004 IF ( lconv(ji,jj) ) THEN ! Convective 2005 2006 IF ( ln_osm_mle ) THEN 2007 2008 IF ( hmle(ji,jj) > hbl(ji,jj) ) THEN 2009 ! Fox-Kemper buoyancy flux average over OSBL 2010 zwb_fk_b(ji,jj) = zwb_fk(ji,jj) * & 2011 (1.0 + hmle(ji,jj) / ( 6.0 * hbl(ji,jj) ) * (-1.0 + ( 1.0 - 2.0 * hbl(ji,jj) / hmle(ji,jj))**3) ) 2012 ELSE 2013 zwb_fk_b(ji,jj) = 0.5 * zwb_fk(ji,jj) * hmle(ji,jj) / hbl(ji,jj) 2014 ENDIF 2015 zvel_max = ( zwstrl(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 2016 IF ( ( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) < 0.0 ) THEN 2017 ! OSBL is deepening, entrainment > restratification 2018 IF ( zdb_bl(ji,jj) > 0.0 .and. zdbdz_bl_ext(ji,jj) > 0.0 ) THEN 2019 zdhdt(ji,jj) = -( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) / ( zvel_max + MAX(zdb_bl(ji,jj), 1.0e-15) ) 2020 ELSE 2021 zdhdt(ji,jj) = -( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) / MAX( zvel_max, 1.0e-15) 2022 ENDIF 2023 ELSE 2024 ! OSBL shoaling due to restratification flux. This is the velocity defined in Fox-Kemper et al (2008) 2025 zdhdt(ji,jj) = - zvel_mle(ji,jj) 2026 2027 2028 ENDIF 2029 2030 ELSE 2031 ! Fox-Kemper not used. 2032 2033 zvel_max = -zwb_ent(ji,jj) / & 2034 & MAX((zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird, epsln) 2035 zdhdt(ji,jj) = -zwb_ent(ji,jj) / ( zvel_max + MAX(zdb_bl(ji,jj), 1.0e-15) ) 2036 ! added ajgn 23 July as temporay fix 2037 2038 ENDIF ! ln_osm_mle 2039 2040 ELSE ! Stable 2041 zdhdt(ji,jj) = ( 0.06 + 0.52 * zhol(ji,jj) / 2.0 ) * zvstr(ji,jj)**3 / hbl(ji,jj) + zwbav(ji,jj) 2042 IF ( zdhdt(ji,jj) < 0._wp ) THEN 2043 ! For long timsteps factor in brackets slows the rapid collapse of the OSBL 2044 zpert = 2.0 * zvstr(ji,jj)**2 / hbl(ji,jj) 2045 ELSE 2046 zpert = MAX( 2.0 * zvstr(ji,jj)**2 / hbl(ji,jj), zdb_bl(ji,jj) ) 2047 ENDIF 2048 zdhdt(ji,jj) = 2.0 * zdhdt(ji,jj) / MAX(zpert, epsln) 2049 ENDIF ! lconv 2050 ENDIF ! lshear 2051 END_2D 2052 END SUBROUTINE zdf_osm_calculate_dhdt 2053 2054 SUBROUTINE zdf_osm_timestep_hbl( zdhdt ) 2055 !!--------------------------------------------------------------------- 2056 !! *** ROUTINE zdf_osm_timestep_hbl *** 2057 !! 2058 !! ** Purpose : Increments hbl. 2059 !! 2060 !! ** Method : If thechange in hbl exceeds one model level the change is 2061 !! is calculated by moving down the grid, changing the buoyancy 2062 !! jump. This is to ensure that the change in hbl does not 2063 !! overshoot a stable layer. 2064 !! 2065 !!---------------------------------------------------------------------- 2066 2067 2068 REAL(wp), DIMENSION(jpi,jpj) :: zdhdt ! rates of change of hbl. 2069 2070 INTEGER :: jk, jj, ji, jm 2071 REAL(wp) :: zhbl_s, zvel_max, zdb 2072 REAL(wp) :: zthermal, zbeta 2073 2074 DO_2D( 0, 0, 0, 0 ) 2075 IF ( ibld(ji,jj) - imld(ji,jj) > 1 ) THEN 2076 ! 2077 ! If boundary layer changes by more than one level, need to check for stable layers between initial and final depths. 2078 ! 2079 zhbl_s = hbl(ji,jj) 2080 jm = imld(ji,jj) 2081 zthermal = rab_n(ji,jj,1,jp_tem) 2082 zbeta = rab_n(ji,jj,1,jp_sal) 2083 2084 2085 IF ( lconv(ji,jj) ) THEN 2086 !unstable 2087 2088 IF( ln_osm_mle ) THEN 2089 zvel_max = ( zwstrl(ji,jj)**3 + zwstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 2090 ELSE 2091 2092 zvel_max = -( 1.0 + 1.0 * ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird * rn_Dt / hbl(ji,jj) ) * zwb_ent(ji,jj) / & 2093 & ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird 2094 2095 ENDIF 2096 2097 DO jk = imld(ji,jj), ibld(ji,jj) 2098 zdb = MAX( grav * ( zthermal * ( zt_bl(ji,jj) - ts(ji,jj,jm,jp_tem,Kmm) ) & 2099 & - zbeta * ( zs_bl(ji,jj) - ts(ji,jj,jm,jp_sal,Kmm) ) ), & 2100 & 0.0 ) + zvel_max 2101 2102 2103 IF ( ln_osm_mle ) THEN 2104 zhbl_s = zhbl_s + MIN( & 2105 & rn_Dt * ( ( -zwb_ent(ji,jj) - 2.0 * zwb_fk_b(ji,jj) )/ zdb ) / FLOAT(ibld(ji,jj) - imld(ji,jj) ), & 2106 & e3w(ji,jj,jm,Kmm) ) 2107 ELSE 2108 zhbl_s = zhbl_s + MIN( & 2109 & rn_Dt * ( -zwb_ent(ji,jj) / zdb ) / FLOAT(ibld(ji,jj) - imld(ji,jj) ), & 2110 & e3w(ji,jj,jm,Kmm) ) 2111 ENDIF 2112 2113 ! zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 2114 IF ( zhbl_s >= gdepw(ji,jj,mbkt(ji,jj) + 1,Kmm) ) THEN 2115 zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 2116 lpyc(ji,jj) = .FALSE. 2117 ENDIF 2118 IF ( zhbl_s >= gdepw(ji,jj,jm+1,Kmm) ) jm = jm + 1 2119 END DO 2120 hbl(ji,jj) = zhbl_s 2121 ibld(ji,jj) = jm 2122 ELSE 2123 ! stable 2124 DO jk = imld(ji,jj), ibld(ji,jj) 2125 zdb = MAX( & 2126 & grav * ( zthermal * ( zt_bl(ji,jj) - ts(ji,jj,jm,jp_tem,Kmm) )& 2127 & - zbeta * ( zs_bl(ji,jj) - ts(ji,jj,jm,jp_sal,Kmm) ) ),& 2128 & 0.0 ) + & 2129 & 2.0 * zvstr(ji,jj)**2 / zhbl_s 2130 2131 ! Alan is thuis right? I have simply changed hbli to hbl 2132 zhol(ji,jj) = -zhbl_s / ( ( zvstr(ji,jj)**3 + epsln )/ zwbav(ji,jj) ) 2133 zdhdt(ji,jj) = -( zwbav(ji,jj) - 0.04 / 2.0 * zwstrl(ji,jj)**3 / zhbl_s - 0.15 / 2.0 * ( 1.0 - EXP( -1.5 * zla(ji,jj) ) ) * & 2134 & zustar(ji,jj)**3 / zhbl_s ) * ( 0.725 + 0.225 * EXP( -7.5 * zhol(ji,jj) ) ) 2135 zdhdt(ji,jj) = zdhdt(ji,jj) + zwbav(ji,jj) 2136 zhbl_s = zhbl_s + MIN( zdhdt(ji,jj) / zdb * rn_Dt / FLOAT( ibld(ji,jj) - imld(ji,jj) ), e3w(ji,jj,jm,Kmm) ) 2137 2138 ! zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 2139 IF ( zhbl_s >= mbkt(ji,jj) + 1 ) THEN 2140 zhbl_s = MIN(zhbl_s, gdepw(ji,jj, mbkt(ji,jj) + 1,Kmm) - depth_tol) 2141 lpyc(ji,jj) = .FALSE. 2142 ENDIF 2143 IF ( zhbl_s >= gdepw(ji,jj,jm,Kmm) ) jm = jm + 1 2144 END DO 2145 ENDIF ! IF ( lconv ) 2146 hbl(ji,jj) = MAX(zhbl_s, gdepw(ji,jj,4,Kmm) ) 2147 ibld(ji,jj) = MAX(jm, 4 ) 2148 ELSE 2149 ! change zero or one model level. 2150 hbl(ji,jj) = MAX(zhbl_t(ji,jj), gdepw(ji,jj,4,Kmm) ) 2151 ENDIF 2152 zhbl(ji,jj) = gdepw(ji,jj,ibld(ji,jj),Kmm) 2153 END_2D 2154 2155 END SUBROUTINE zdf_osm_timestep_hbl 2156 2157 SUBROUTINE zdf_osm_pycnocline_thickness( dh, zdh ) 2158 !!--------------------------------------------------------------------- 2159 !! *** ROUTINE zdf_osm_pycnocline_thickness *** 1689 !! *** ROUTINE zdf_osm_pycnocline_thickness *** 2160 1690 !! 2161 1691 !! ** Purpose : Calculates thickness of the pycnocline … … 2168 1698 !! 2169 1699 !!---------------------------------------------------------------------- 2170 2171 REAL(wp), DIMENSION(jpi,jpj) :: dh, zdh ! pycnocline thickness. 2172 ! 2173 INTEGER :: jj, ji 2174 INTEGER :: inhml 2175 REAL(wp) :: zari, ztau, zdh_ref 2176 REAL, PARAMETER :: a_ddh_2 = 3.5 ! also in pycnocline_depth 2177 2178 DO_2D( 0, 0, 0, 0 ) 2179 2180 IF ( lshear(ji,jj) ) THEN 2181 IF ( lconv(ji,jj) ) THEN 2182 IF ( j_ddh(ji,jj) == 0 ) THEN 2183 ! ddhdt for pycnocline determined in osm_calculate_dhdt 2184 dh(ji,jj) = dh(ji,jj) + zddhdt(ji,jj) * rn_Dt 2185 ELSE 2186 ! Temporary (probably) Recalculate dh_ref to ensure dh doesn't go negative. Can't do this using zddhdt from calculate_dhdt 2187 IF ( ( zwstrc(ji,jj) / zvstr(ji,jj) )**3 <= 0.5 ) THEN 2188 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zvstr(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 2189 ELSE 2190 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zwstrc(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 2191 ENDIF 2192 ztau = MAX( zdb_bl(ji,jj) * ( zari * hbl(ji,jj) ) / ( a_ddh_2 * MAX(-zwb_ent(ji,jj), 1.e-12) ), 2.0 * rn_Dt ) 2193 dh(ji,jj) = dh(ji,jj) * EXP( -rn_Dt / ztau ) + zari * zhbl(ji,jj) * ( 1.0 - EXP( -rn_Dt / ztau ) ) 2194 IF ( dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zari * zhbl(ji,jj) 2195 ENDIF 2196 2197 ELSE ! lconv 2198 ! Initially shear only for entraining OSBL. Stable code will be needed if extended to stable OSBL 2199 2200 ztau = hbl(ji,jj) / MAX(zvstr(ji,jj), epsln) 2201 IF ( zdhdt(ji,jj) >= 0.0 ) THEN ! probably shouldn't include wm here 2202 ! boundary layer deepening 2203 IF ( zdb_bl(ji,jj) > 0._wp ) THEN 2204 ! pycnocline thickness set by stratification - use same relationship as for neutral conditions. 2205 zari = MIN( 4.5 * ( zvstr(ji,jj)**2 ) & 2206 & / MAX(zdb_bl(ji,jj) * zhbl(ji,jj), epsln ) + 0.01 , 0.2 ) 2207 zdh_ref = MIN( zari, 0.2 ) * hbl(ji,jj) 1700 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1701 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: pdh ! Pycnocline thickness 1702 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: phml ! ML depth 1703 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdhdt ! BL depth tendency 1704 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 1705 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_ent ! Buoyancy entrainment flux 1706 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdbdz_bl_ext ! External buoyancy gradients 1707 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_fk_b ! MLE buoyancy flux averaged over OSBL 1708 !! 1709 INTEGER :: jj, ji 1710 INTEGER :: inhml 1711 REAL(wp) :: zari, ztau, zdh_ref, zddhdt, zvel_max 1712 REAL(wp) :: ztmp ! Auxiliary variable 1713 !! 1714 REAL, PARAMETER :: pp_ddh = 2.5_wp, pp_ddh_2 = 3.5_wp ! Also in pycnocline_depth 1715 !!---------------------------------------------------------------------- 1716 ! 1717 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1718 ! 1719 IF ( l_shear(ji,jj) ) THEN 1720 ! 1721 IF ( l_conv(ji,jj) ) THEN 1722 ! 1723 IF ( av_db_bl(ji,jj) > 1e-15_wp ) THEN 1724 IF ( n_ddh(ji,jj) == 0 ) THEN 1725 zvel_max = ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**p2third / hbl(ji,jj) 1726 ! ddhdt for pycnocline determined in osm_calculate_dhdt 1727 zddhdt = -1.0_wp * pp_ddh * ( 1.0_wp - 1.6_wp * pdh(ji,jj) / phbl(ji,jj) ) * pwb_ent(ji,jj) / & 1728 & ( zvel_max + MAX( av_db_bl(ji,jj), 1e-15 ) ) 1729 zddhdt = EXP( -4.0_wp * ABS( ff_t(ji,jj) ) * phbl(ji,jj) / MAX( sustar(ji,jj), 1e-8 ) ) * zddhdt 1730 ! Maximum limit for how thick the shear layer can grow relative to the thickness of the boundary layer 1731 dh(ji,jj) = MIN( dh(ji,jj) + zddhdt * rn_Dt, 0.625_wp * hbl(ji,jj) ) 1732 ELSE ! Need to recalculate because hbl has been updated 1733 IF ( ( swstrc(ji,jj) / svstr(ji,jj) )**3 <= 0.5_wp ) THEN 1734 ztmp = svstr(ji,jj) 1735 ELSE 1736 ztmp = swstrc(ji,jj) 1737 END IF 1738 zari = MIN( 1.5_wp * av_db_bl(ji,jj) / ( phbl(ji,jj) * ( MAX( pdbdz_bl_ext(ji,jj), 0.0_wp ) + & 1739 & av_db_bl(ji,jj)**2 / MAX( 4.5_wp * ztmp**2, & 1740 & 1e-12_wp ) ) ), 0.2_wp ) 1741 ztau = MAX( av_db_bl(ji,jj) * ( zari * hbl(ji,jj) ) / & 1742 & ( pp_ddh_2 * MAX( -1.0_wp * pwb_ent(ji,jj), 1e-12_wp ) ), 2.0_wp * rn_Dt ) 1743 dh(ji,jj) = dh(ji,jj) * EXP( -1.0_wp * rn_Dt / ztau ) + & 1744 & zari * phbl(ji,jj) * ( 1.0_wp - EXP( -1.0_wp * rn_Dt / ztau ) ) 1745 IF ( dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zari * phbl(ji,jj) 1746 END IF 2208 1747 ELSE 2209 zdh_ref = 0.2 * hbl(ji,jj) 1748 ztau = MAX( MAX( hbl(ji,jj) / ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird, epsln), 2.0_wp * rn_Dt ) 1749 dh(ji,jj) = dh(ji,jj) * EXP( -1.0_wp * rn_Dt / ztau ) + & 1750 & 0.2_wp * phbl(ji,jj) * ( 1.0_wp - EXP( -1.0_wp * rn_Dt / ztau ) ) 1751 IF ( dh(ji,jj) > hbl(ji,jj) ) dh(ji,jj) = 0.2_wp * hbl(ji,jj) 1752 END IF 1753 ! 1754 ELSE ! l_conv 1755 ! Initially shear only for entraining OSBL. Stable code will be needed if extended to stable OSBL 1756 ztau = hbl(ji,jj) / MAX(svstr(ji,jj), epsln) 1757 IF ( pdhdt(ji,jj) >= 0.0_wp ) THEN ! Probably shouldn't include wm here 1758 ! Boundary layer deepening 1759 IF ( av_db_bl(ji,jj) > 0.0_wp ) THEN 1760 ! Pycnocline thickness set by stratification - use same relationship as for neutral conditions 1761 zari = MIN( 4.5_wp * ( svstr(ji,jj)**2 ) / MAX( av_db_bl(ji,jj) * phbl(ji,jj), epsln ) + 0.01_wp, 0.2_wp ) 1762 zdh_ref = MIN( zari, 0.2_wp ) * hbl(ji,jj) 1763 ELSE 1764 zdh_ref = 0.2_wp * hbl(ji,jj) 1765 ENDIF 1766 ELSE ! IF(dhdt < 0) 1767 zdh_ref = 0.2_wp * hbl(ji,jj) 1768 ENDIF ! IF (dhdt >= 0) 1769 dh(ji,jj) = dh(ji,jj) * EXP( -1.0_wp * rn_Dt / ztau ) + zdh_ref * ( 1.0_wp - EXP( -1.0_wp * rn_Dt / ztau ) ) 1770 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 1771 ! ! rapid collapse 1772 ENDIF 1773 ! 1774 ELSE ! l_shear = .FALSE., calculate ddhdt here 1775 ! 1776 IF ( l_conv(ji,jj) ) THEN 1777 ! 1778 IF( ln_osm_mle ) THEN 1779 IF ( ( pwb_ent(ji,jj) + 2.0_wp * pwb_fk_b(ji,jj) ) < 0.0_wp ) THEN ! OSBL is deepening. Note wb_fk_b is zero if 1780 ! ! ln_osm_mle=F 1781 IF ( av_db_bl(ji,jj) > 0.0_wp .AND. pdbdz_bl_ext(ji,jj) > 0.0_wp ) THEN 1782 IF ( ( swstrc(ji,jj) / MAX( svstr(ji,jj), epsln) )**3 <= 0.5_wp ) THEN ! Near neutral stability 1783 ztmp = svstr(ji,jj) 1784 ELSE ! Unstable 1785 ztmp = swstrc(ji,jj) 1786 END IF 1787 zari = MIN( 1.5_wp * av_db_bl(ji,jj) / & 1788 & ( phbl(ji,jj) * ( MAX( pdbdz_bl_ext(ji,jj), 0.0_wp ) + & 1789 & av_db_bl(ji,jj)**2 / MAX( 4.5_wp * ztmp**2 , 1e-12_wp ) ) ), 0.2_wp ) 1790 ELSE 1791 zari = 0.2_wp 1792 END IF 1793 ELSE 1794 zari = 0.2_wp 1795 END IF 1796 ztau = 0.2_wp * hbl(ji,jj) / MAX( epsln, ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird ) 1797 zdh_ref = zari * hbl(ji,jj) 1798 ELSE ! ln_osm_mle 1799 IF ( av_db_bl(ji,jj) > 0.0_wp .AND. pdbdz_bl_ext(ji,jj) > 0.0_wp ) THEN 1800 IF ( ( swstrc(ji,jj) / MAX( svstr(ji,jj), epsln ) )**3 <= 0.5_wp ) THEN ! Near neutral stability 1801 ztmp = svstr(ji,jj) 1802 ELSE ! Unstable 1803 ztmp = swstrc(ji,jj) 1804 END IF 1805 zari = MIN( 1.5_wp * av_db_bl(ji,jj) / & 1806 & ( phbl(ji,jj) * ( MAX( pdbdz_bl_ext(ji,jj), 0.0_wp ) + & 1807 & av_db_bl(ji,jj)**2 / MAX( 4.5_wp * ztmp**2 , 1e-12_wp ) ) ), 0.2_wp ) 1808 ELSE 1809 zari = 0.2_wp 1810 END IF 1811 ztau = hbl(ji,jj) / MAX( epsln, ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird ) 1812 zdh_ref = zari * hbl(ji,jj) 1813 END IF ! ln_osm_mle 1814 dh(ji,jj) = dh(ji,jj) * EXP( -1.0_wp * rn_Dt / ztau ) + zdh_ref * ( 1.0_wp - EXP( -1.0_wp * rn_Dt / ztau ) ) 1815 ! IF ( pdhdt(ji,jj) < 0._wp .and. dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref 1816 IF ( dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref 1817 ! Alan: this hml is never defined or used 1818 ELSE ! IF (l_conv) 1819 ! 1820 ztau = hbl(ji,jj) / MAX( svstr(ji,jj), epsln ) 1821 IF ( pdhdt(ji,jj) >= 0.0_wp ) THEN ! Probably shouldn't include wm here 1822 ! Boundary layer deepening 1823 IF ( av_db_bl(ji,jj) > 0.0_wp ) THEN 1824 ! Pycnocline thickness set by stratification - use same relationship as for neutral conditions. 1825 zari = MIN( 4.5_wp * ( svstr(ji,jj)**2 ) / MAX( av_db_bl(ji,jj) * phbl(ji,jj), epsln ) + 0.01_wp , 0.2_wp ) 1826 zdh_ref = MIN( zari, 0.2_wp ) * hbl(ji,jj) 1827 ELSE 1828 zdh_ref = 0.2_wp * hbl(ji,jj) 1829 END IF 1830 ELSE ! IF(dhdt < 0) 1831 zdh_ref = 0.2_wp * hbl(ji,jj) 1832 END IF ! IF (dhdt >= 0) 1833 dh(ji,jj) = dh(ji,jj) * EXP( -1.0_wp * rn_Dt / ztau ) + zdh_ref * ( 1.0_wp - EXP( -1.0_wp * rn_Dt / ztau ) ) 1834 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 1835 ! ! rapid collapse 1836 END IF ! IF (l_conv) 1837 ! 1838 END IF ! l_shear 1839 ! 1840 hml(ji,jj) = hbl(ji,jj) - dh(ji,jj) 1841 inhml = MAX( INT( dh(ji,jj) / MAX( e3t(ji,jj,nbld(ji,jj)-1,Kmm), 1e-3_wp ) ), 1 ) 1842 nmld(ji,jj) = MAX( nbld(ji,jj) - inhml, 3 ) 1843 phml(ji,jj) = gdepw(ji,jj,nmld(ji,jj),Kmm) 1844 pdh(ji,jj) = phbl(ji,jj) - phml(ji,jj) 1845 ! 1846 END_2D 1847 ! 1848 END SUBROUTINE zdf_osm_pycnocline_thickness 1849 1850 SUBROUTINE zdf_osm_pycnocline_buoyancy_profiles( Kmm, kp_ext, pdbdz, palpha, pdh, & 1851 & phbl, pdbdz_bl_ext, phml, pdhdt ) 1852 !!--------------------------------------------------------------------- 1853 !! *** ROUTINE zdf_osm_pycnocline_buoyancy_profiles *** 1854 !! 1855 !! ** Purpose : calculate pycnocline buoyancy profiles 1856 !! 1857 !! ** Method : 1858 !! 1859 !!---------------------------------------------------------------------- 1860 INTEGER, INTENT(in ) :: Kmm ! Ocean time-level index 1861 INTEGER, DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: kp_ext ! External-level offsets 1862 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk), INTENT( out) :: pdbdz ! Gradients in the pycnocline 1863 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT( out) :: palpha 1864 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdh ! Pycnocline thickness 1865 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 1866 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdbdz_bl_ext ! External buoyancy gradients 1867 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phml ! ML depth 1868 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdhdt ! Rates of change of hbl 1869 !! 1870 INTEGER :: jk, jj, ji 1871 REAL(wp) :: zbgrad 1872 REAL(wp) :: zgamma_b_nd, znd 1873 REAL(wp) :: zzeta_m 1874 REAL(wp) :: ztmp ! Auxiliary variable 1875 !! 1876 REAL(wp), PARAMETER :: pp_gamma_b = 2.25_wp 1877 REAL(wp), PARAMETER :: pp_large = -1e10_wp 1878 !!---------------------------------------------------------------------- 1879 ! 1880 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1881 pdbdz(ji,jj,:) = pp_large 1882 palpha(ji,jj) = pp_large 1883 END_2D 1884 ! 1885 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 1886 ! 1887 IF ( nbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN 1888 ! 1889 IF ( l_conv(ji,jj) ) THEN ! Convective conditions 1890 ! 1891 IF ( l_pyc(ji,jj) ) THEN 1892 ! 1893 zzeta_m = 0.1_wp + 0.3_wp / ( 1.0_wp + EXP( -3.5_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) ) 1894 palpha(ji,jj) = 2.0_wp * ( 1.0_wp - ( 0.80_wp * zzeta_m + 0.5_wp * SQRT( 3.14159_wp / pp_gamma_b ) ) * & 1895 & pdbdz_bl_ext(ji,jj) * pdh(ji,jj) / av_db_ml(ji,jj) ) / & 1896 & ( 0.723_wp + SQRT( 3.14159_wp / pp_gamma_b ) ) 1897 palpha(ji,jj) = MAX( palpha(ji,jj), 0.0_wp ) 1898 ztmp = 1.0_wp / MAX( pdh(ji,jj), epsln ) 1899 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1900 ! Commented lines in this section are not needed in new code, once tested ! 1901 ! can be removed ! 1902 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1903 ! ztgrad = zalpha * av_dt_ml(ji,jj) * ztmp + zdtdz_bl_ext(ji,jj) 1904 ! zsgrad = zalpha * av_ds_ml(ji,jj) * ztmp + zdsdz_bl_ext(ji,jj) 1905 zbgrad = palpha(ji,jj) * av_db_ml(ji,jj) * ztmp + pdbdz_bl_ext(ji,jj) 1906 zgamma_b_nd = pdbdz_bl_ext(ji,jj) * pdh(ji,jj) / MAX( av_db_ml(ji,jj), epsln ) 1907 DO jk = 2, nbld(ji,jj) 1908 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) * ztmp 1909 IF ( znd <= zzeta_m ) THEN 1910 ! zdtdz(ji,jj,jk) = zdtdz_bl_ext(ji,jj) + zalpha * av_dt_ml(ji,jj) * ztmp * & 1911 ! & EXP( -6.0 * ( znd -zzeta_m )**2 ) 1912 ! zdsdz(ji,jj,jk) = zdsdz_bl_ext(ji,jj) + zalpha * av_ds_ml(ji,jj) * ztmp * & 1913 ! & EXP( -6.0 * ( znd -zzeta_m )**2 ) 1914 pdbdz(ji,jj,jk) = pdbdz_bl_ext(ji,jj) + palpha(ji,jj) * av_db_ml(ji,jj) * ztmp * & 1915 & EXP( -6.0_wp * ( znd -zzeta_m )**2 ) 1916 ELSE 1917 ! zdtdz(ji,jj,jk) = ztgrad * EXP( -pp_gamma_b * ( znd - zzeta_m )**2 ) 1918 ! zdsdz(ji,jj,jk) = zsgrad * EXP( -pp_gamma_b * ( znd - zzeta_m )**2 ) 1919 pdbdz(ji,jj,jk) = zbgrad * EXP( -1.0_wp * pp_gamma_b * ( znd - zzeta_m )**2 ) 1920 END IF 1921 END DO 1922 END IF ! If no pycnocline pycnocline gradients set to zero 1923 ! 1924 ELSE ! Stable conditions 1925 ! If pycnocline profile only defined when depth steady of increasing. 1926 IF ( pdhdt(ji,jj) > 0.0_wp ) THEN ! Depth increasing, or steady. 1927 IF ( av_db_bl(ji,jj) > 0.0_wp ) THEN 1928 IF ( shol(ji,jj) >= 0.5_wp ) THEN ! Very stable - 'thick' pycnocline 1929 ztmp = 1.0_wp / MAX( phbl(ji,jj), epsln ) 1930 zbgrad = av_db_bl(ji,jj) * ztmp 1931 DO jk = 2, nbld(ji,jj) 1932 znd = gdepw(ji,jj,jk,Kmm) * ztmp 1933 pdbdz(ji,jj,jk) = zbgrad * EXP( -15.0_wp * ( znd - 0.9_wp )**2 ) 1934 END DO 1935 ELSE ! Slightly stable - 'thin' pycnoline - needed when stable layer begins to form. 1936 ztmp = 1.0_wp / MAX( pdh(ji,jj), epsln ) 1937 zbgrad = av_db_bl(ji,jj) * ztmp 1938 DO jk = 2, nbld(ji,jj) 1939 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phml(ji,jj) ) * ztmp 1940 pdbdz(ji,jj,jk) = zbgrad * EXP( -1.75_wp * ( znd + 0.75_wp )**2 ) 1941 END DO 1942 END IF ! IF (shol >=0.5) 1943 END IF ! IF (av_db_bl> 0.) 1944 END IF ! IF (pdhdt >= 0) pdhdt < 0 not considered since pycnocline profile is zero and profile arrays are 1945 ! ! intialized to zero 1946 ! 1947 END IF ! IF (l_conv) 1948 ! 1949 END IF ! IF ( nbld(ji,jj) < mbkt(ji,jj) ) 1950 ! 1951 END_2D 1952 ! 1953 IF ( ln_dia_pyc_scl ) THEN ! Output of pycnocline gradient profiles 1954 CALL zdf_osm_iomput( "zdbdz_pyc", wmask(A2D(0),:) * pdbdz(A2D(0),:) ) 1955 END IF 1956 ! 1957 END SUBROUTINE zdf_osm_pycnocline_buoyancy_profiles 1958 1959 SUBROUTINE zdf_osm_diffusivity_viscosity( Kbb, Kmm, pdiffut, pviscos, phbl, & 1960 & phml, pdh, pdhdt, pshear, & 1961 & pwb_ent, pwb_min ) 1962 !!--------------------------------------------------------------------- 1963 !! *** ROUTINE zdf_osm_diffusivity_viscosity *** 1964 !! 1965 !! ** Purpose : Determines the eddy diffusivity and eddy viscosity 1966 !! profiles in the mixed layer and the pycnocline. 1967 !! 1968 !! ** Method : 1969 !! 1970 !!---------------------------------------------------------------------- 1971 INTEGER, INTENT(in ) :: Kbb, Kmm ! Ocean time-level indices 1972 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk), INTENT(inout) :: pdiffut ! t-diffusivity 1973 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk), INTENT(inout) :: pviscos ! Viscosity 1974 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 1975 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phml ! ML depth 1976 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdh ! Pycnocline depth 1977 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdhdt ! BL depth tendency 1978 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pshear ! Shear production 1979 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_ent ! Buoyancy entrainment flux 1980 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_min 1981 !! 1982 INTEGER :: ji, jj, jk ! Loop indices 1983 !! Scales used to calculate eddy diffusivity and viscosity profiles 1984 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdifml_sc, zvisml_sc 1985 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zdifpyc_n_sc, zdifpyc_s_sc 1986 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zvispyc_n_sc, zvispyc_s_sc 1987 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zbeta_d_sc, zbeta_v_sc 1988 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zb_coup, zc_coup_vis, zc_coup_dif 1989 !! 1990 REAL(wp) :: zvel_sc_pyc, zvel_sc_ml, zstab_fac, zz_b 1991 REAL(wp) :: za_cubic, zb_d_cubic, zc_d_cubic, zd_d_cubic, & ! Coefficients in cubic polynomial specifying diffusivity 1992 & zb_v_cubic, zc_v_cubic, zd_v_cubic ! and viscosity in pycnocline 1993 REAL(wp) :: zznd_ml, zznd_pyc, ztmp 1994 REAL(wp) :: zmsku, zmskv 1995 !! 1996 REAL(wp), PARAMETER :: pp_dif_ml = 0.8_wp, pp_vis_ml = 0.375_wp 1997 REAL(wp), PARAMETER :: pp_dif_pyc = 0.15_wp, pp_vis_pyc = 0.142_wp 1998 REAL(wp), PARAMETER :: pp_vispyc_shr = 0.15_wp 1999 !!---------------------------------------------------------------------- 2000 ! 2001 zb_coup(:,:) = 0.0_wp 2002 ! 2003 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2004 IF ( l_conv(ji,jj) ) THEN 2005 ! 2006 zvel_sc_pyc = ( 0.15_wp * svstr(ji,jj)**3 + swstrc(ji,jj)**3 + 4.25_wp * pshear(ji,jj) * phbl(ji,jj) )**pthird 2007 zvel_sc_ml = ( svstr(ji,jj)**3 + 0.5_wp * swstrc(ji,jj)**3 )**pthird 2008 zstab_fac = ( phml(ji,jj) / zvel_sc_ml * & 2009 & ( 1.4_wp - 0.4_wp / ( 1.0_wp + EXP(-3.5_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) )**1.25_wp ) )**2 2010 ! 2011 zdifml_sc(ji,jj) = pp_dif_ml * phml(ji,jj) * zvel_sc_ml 2012 zvisml_sc(ji,jj) = pp_vis_ml * zdifml_sc(ji,jj) 2013 ! 2014 IF ( l_pyc(ji,jj) ) THEN 2015 zdifpyc_n_sc(ji,jj) = pp_dif_pyc * zvel_sc_ml * pdh(ji,jj) 2016 zvispyc_n_sc(ji,jj) = 0.09_wp * zvel_sc_pyc * ( 1.0_wp - phbl(ji,jj) / pdh(ji,jj) )**2 * & 2017 & ( 0.005_wp * ( av_u_ml(ji,jj) - av_u_bl(ji,jj) )**2 + & 2018 & 0.0075_wp * ( av_v_ml(ji,jj) - av_v_bl(ji,jj) )**2 ) / & 2019 & pdh(ji,jj) 2020 zvispyc_n_sc(ji,jj) = pp_vis_pyc * zvel_sc_ml * pdh(ji,jj) + zvispyc_n_sc(ji,jj) * zstab_fac 2021 ! 2022 IF ( l_shear(ji,jj) .AND. n_ddh(ji,jj) /= 2 ) THEN 2023 ztmp = pp_vispyc_shr * ( pshear(ji,jj) * phbl(ji,jj) )**pthird * phbl(ji,jj) 2024 zdifpyc_n_sc(ji,jj) = zdifpyc_n_sc(ji,jj) + ztmp 2025 zvispyc_n_sc(ji,jj) = zvispyc_n_sc(ji,jj) + ztmp 2210 2026 ENDIF 2211 ELSE ! IF(dhdt < 0) 2212 zdh_ref = 0.2 * hbl(ji,jj) 2213 ENDIF ! IF (dhdt >= 0) 2214 dh(ji,jj) = dh(ji,jj) * EXP( -rn_Dt / ztau )+ zdh_ref * ( 1.0 - EXP( -rn_Dt / ztau ) ) 2215 IF ( zdhdt(ji,jj) < 0._wp .and. dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref ! can be a problem with dh>hbl for rapid collapse 2216 ! Alan: this hml is never defined or used -- do we need it? 2027 ! 2028 zdifpyc_s_sc(ji,jj) = pwb_ent(ji,jj) + 0.0025_wp * zvel_sc_pyc * ( phbl(ji,jj) / pdh(ji,jj) - 1.0_wp ) * & 2029 & ( av_b_ml(ji,jj) - av_b_bl(ji,jj) ) 2030 zvispyc_s_sc(ji,jj) = 0.09_wp * ( pwb_min(ji,jj) + 0.0025_wp * zvel_sc_pyc * & 2031 & ( phbl(ji,jj) / pdh(ji,jj) - 1.0_wp ) * & 2032 & ( av_b_ml(ji,jj) - av_b_bl(ji,jj) ) ) 2033 zdifpyc_s_sc(ji,jj) = 0.09_wp * zdifpyc_s_sc(ji,jj) * zstab_fac 2034 zvispyc_s_sc(ji,jj) = zvispyc_s_sc(ji,jj) * zstab_fac 2035 ! 2036 zdifpyc_s_sc(ji,jj) = MAX( zdifpyc_s_sc(ji,jj), -0.5_wp * zdifpyc_n_sc(ji,jj) ) 2037 zvispyc_s_sc(ji,jj) = MAX( zvispyc_s_sc(ji,jj), -0.5_wp * zvispyc_n_sc(ji,jj) ) 2038 2039 zbeta_d_sc(ji,jj) = 1.0_wp - ( ( zdifpyc_n_sc(ji,jj) + 1.4_wp * zdifpyc_s_sc(ji,jj) ) / & 2040 & ( zdifml_sc(ji,jj) + epsln ) )**p2third 2041 zbeta_v_sc(ji,jj) = 1.0_wp - 2.0_wp * ( zvispyc_n_sc(ji,jj) + zvispyc_s_sc(ji,jj) ) / ( zvisml_sc(ji,jj) + epsln ) 2042 ELSE 2043 zdifpyc_n_sc(ji,jj) = pp_dif_pyc * zvel_sc_ml * pdh(ji,jj) ! ag 19/03 2044 zdifpyc_s_sc(ji,jj) = 0.0_wp ! ag 19/03 2045 zvispyc_n_sc(ji,jj) = pp_vis_pyc * zvel_sc_ml * pdh(ji,jj) ! ag 19/03 2046 zvispyc_s_sc(ji,jj) = 0.0_wp ! ag 19/03 2047 IF(l_coup(ji,jj) ) THEN ! ag 19/03 2048 ! code from SUBROUTINE tke_tke zdftke.F90; uses bottom drag velocity rCdU_bot(ji,jj) = -Cd|ub| 2049 ! already calculated at T-points in SUBROUTINE zdf_drg from zdfdrg.F90 2050 ! Gives friction velocity sqrt bottom drag/rho_0 i.e. u* = SQRT(rCdU_bot*ub) 2051 ! wet-cell averaging .. 2052 zmsku = 0.5_wp * ( 2.0_wp - umask(ji-1,jj,mbkt(ji,jj)) * umask(ji,jj,mbkt(ji,jj)) ) 2053 zmskv = 0.5_wp * ( 2.0_wp - vmask(ji,jj-1,mbkt(ji,jj)) * vmask(ji,jj,mbkt(ji,jj)) ) 2054 zb_coup(ji,jj) = 0.4_wp * SQRT(-1.0_wp * rCdU_bot(ji,jj) * & 2055 & SQRT( ( zmsku*( uu(ji,jj,mbkt(ji,jj),Kbb)+uu(ji-1,jj,mbkt(ji,jj),Kbb) ) )**2 & 2056 & + ( zmskv*( vv(ji,jj,mbkt(ji,jj),Kbb)+vv(ji,jj-1,mbkt(ji,jj),Kbb) ) )**2 ) ) 2057 2058 zz_b = -1.0_wp * gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) ! ag 19/03 2059 zc_coup_vis(ji,jj) = -0.5_wp * ( 0.5_wp * zvisml_sc(ji,jj) / phml(ji,jj) - zb_coup(ji,jj) ) / & 2060 & ( phml(ji,jj) + zz_b ) ! ag 19/03 2061 zz_b = -1.0_wp * phml(ji,jj) + gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) ! ag 19/03 2062 zbeta_v_sc(ji,jj) = 1.0_wp - 2.0_wp * ( zb_coup(ji,jj) * zz_b + zc_coup_vis(ji,jj) * zz_b**2 ) / & 2063 & zvisml_sc(ji,jj) ! ag 19/03 2064 zbeta_d_sc(ji,jj) = 1.0_wp - ( ( zb_coup(ji,jj) * zz_b + zc_coup_vis(ji,jj) * zz_b**2 ) / & 2065 & zdifml_sc(ji,jj) )**p2third 2066 zc_coup_dif(ji,jj) = 0.5_wp * ( -zdifml_sc(ji,jj) / phml(ji,jj) * ( 1.0_wp - zbeta_d_sc(ji,jj) )**1.5_wp + & 2067 & 1.5_wp * ( zdifml_sc(ji,jj) / phml(ji,jj) ) * zbeta_d_sc(ji,jj) * & 2068 & SQRT( 1.0_wp - zbeta_d_sc(ji,jj) ) - zb_coup(ji,jj) ) / zz_b ! ag 19/03 2069 ELSE ! ag 19/03 2070 zbeta_d_sc(ji,jj) = 1.0_wp - ( ( zdifpyc_n_sc(ji,jj) + 1.4_wp * zdifpyc_s_sc(ji,jj) ) / & 2071 & ( zdifml_sc(ji,jj) + epsln ) )**p2third ! ag 19/03 2072 zbeta_v_sc(ji,jj) = 1.0_wp - 2.0_wp * ( zvispyc_n_sc(ji,jj) + zvispyc_s_sc(ji,jj) ) / & 2073 & ( zvisml_sc(ji,jj) + epsln ) ! ag 19/03 2074 ENDIF ! ag 19/03 2075 ENDIF ! ag 19/03 2076 ELSE 2077 zdifml_sc(ji,jj) = svstr(ji,jj) * phbl(ji,jj) * MAX( EXP ( -1.0_wp * ( shol(ji,jj) / 0.6_wp )**2 ), 0.2_wp) 2078 zvisml_sc(ji,jj) = zdifml_sc(ji,jj) 2079 END IF 2080 END_2D 2081 ! 2082 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2083 IF ( l_conv(ji,jj) ) THEN 2084 DO jk = 2, nmld(ji,jj) ! Mixed layer diffusivity 2085 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2086 pdiffut(ji,jj,jk) = zdifml_sc(ji,jj) * zznd_ml * ( 1.0_wp - zbeta_d_sc(ji,jj) * zznd_ml )**1.5 2087 pviscos(ji,jj,jk) = zvisml_sc(ji,jj) * zznd_ml * ( 1.0_wp - zbeta_v_sc(ji,jj) * zznd_ml ) * & 2088 & ( 1.0_wp - 0.5_wp * zznd_ml**2 ) 2089 END DO 2090 ! 2091 ! Coupling to bottom 2092 ! 2093 IF ( l_coup(ji,jj) ) THEN ! ag 19/03 2094 DO jk = mbkt(ji,jj), nmld(ji,jj), -1 ! ag 19/03 2095 zz_b = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) ) ! ag 19/03 2096 pviscos(ji,jj,jk) = zb_coup(ji,jj) * zz_b + zc_coup_vis(ji,jj) * zz_b**2 ! ag 19/03 2097 pdiffut(ji,jj,jk) = zb_coup(ji,jj) * zz_b + zc_coup_dif(ji,jj) * zz_b**2 ! ag 19/03 2098 END DO ! ag 19/03 2099 ENDIF ! ag 19/03 2100 ! Pycnocline 2101 IF ( l_pyc(ji,jj) ) THEN 2102 ! Diffusivity and viscosity profiles in the pycnocline given by 2103 ! cubic polynomial. Note, if l_pyc TRUE can't be coupled to seabed. 2104 za_cubic = 0.5_wp 2105 zb_d_cubic = -1.75_wp * zdifpyc_s_sc(ji,jj) / zdifpyc_n_sc(ji,jj) 2106 zd_d_cubic = ( pdh(ji,jj) * zdifml_sc(ji,jj) / phml(ji,jj) * SQRT( 1.0_wp - zbeta_d_sc(ji,jj) ) * & 2107 & ( 2.5_wp * zbeta_d_sc(ji,jj) - 1.0_wp ) - 0.85_wp * zdifpyc_s_sc(ji,jj) ) / & 2108 & MAX( zdifpyc_n_sc(ji,jj), 1.0e-8_wp ) 2109 zd_d_cubic = zd_d_cubic - zb_d_cubic - 2.0_wp * ( 1.0_wp - za_cubic - zb_d_cubic ) 2110 zc_d_cubic = 1.0_wp - za_cubic - zb_d_cubic - zd_d_cubic 2111 zb_v_cubic = -1.75_wp * zvispyc_s_sc(ji,jj) / zvispyc_n_sc(ji,jj) 2112 zd_v_cubic = ( 0.5_wp * zvisml_sc(ji,jj) * pdh(ji,jj) / phml(ji,jj) - 0.85_wp * zvispyc_s_sc(ji,jj) ) / & 2113 & MAX( zvispyc_n_sc(ji,jj), 1.0e-8_wp ) 2114 zd_v_cubic = zd_v_cubic - zb_v_cubic - 2.0_wp * ( 1.0_wp - za_cubic - zb_v_cubic ) 2115 zc_v_cubic = 1.0_wp - za_cubic - zb_v_cubic - zd_v_cubic 2116 DO jk = nmld(ji,jj) , nbld(ji,jj) 2117 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / MAX(pdh(ji,jj), 1.0e-6_wp ) 2118 ztmp = ( 1.75_wp * zznd_pyc - 0.15_wp * zznd_pyc**2 - 0.2_wp * zznd_pyc**3 ) 2119 ! 2120 pdiffut(ji,jj,jk) = zdifpyc_n_sc(ji,jj) * & 2121 & ( za_cubic + zb_d_cubic * zznd_pyc + zc_d_cubic * zznd_pyc**2 + zd_d_cubic * zznd_pyc**3 ) 2122 ! 2123 pdiffut(ji,jj,jk) = pdiffut(ji,jj,jk) + zdifpyc_s_sc(ji,jj) * ztmp 2124 pviscos(ji,jj,jk) = zvispyc_n_sc(ji,jj) * & 2125 & ( za_cubic + zb_v_cubic * zznd_pyc + zc_v_cubic * zznd_pyc**2 + zd_v_cubic * zznd_pyc**3 ) 2126 pviscos(ji,jj,jk) = pviscos(ji,jj,jk) + zvispyc_s_sc(ji,jj) * ztmp 2127 END DO 2128 ! IF ( pdhdt(ji,jj) > 0._wp ) THEN 2129 ! zdiffut(ji,jj,nbld(ji,jj)+1) = MAX( 0.5 * pdhdt(ji,jj) * e3w(ji,jj,nbld(ji,jj)+1,Kmm), 1.0e-6 ) 2130 ! zviscos(ji,jj,nbld(ji,jj)+1) = MAX( 0.5 * pdhdt(ji,jj) * e3w(ji,jj,nbld(ji,jj)+1,Kmm), 1.0e-6 ) 2131 ! ELSE 2132 ! zdiffut(ji,jj,nbld(ji,jj)) = 0._wp 2133 ! zviscos(ji,jj,nbld(ji,jj)) = 0._wp 2134 ! ENDIF 2135 ENDIF 2136 ELSE 2137 ! Stable conditions 2138 DO jk = 2, nbld(ji,jj) 2139 zznd_ml = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 2140 pdiffut(ji,jj,jk) = 0.75_wp * zdifml_sc(ji,jj) * zznd_ml * ( 1.0_wp - zznd_ml )**1.5_wp 2141 pviscos(ji,jj,jk) = 0.375_wp * zvisml_sc(ji,jj) * zznd_ml * ( 1.0_wp - zznd_ml ) * ( 1.0_wp - zznd_ml**2 ) 2142 END DO 2143 ! 2144 IF ( pdhdt(ji,jj) > 0.0_wp ) THEN 2145 pdiffut(ji,jj,nbld(ji,jj)) = MAX( pdhdt(ji,jj), 1.0e-6_wp) * e3w(ji, jj, nbld(ji,jj), Kmm) 2146 pviscos(ji,jj,nbld(ji,jj)) = pdiffut(ji,jj,nbld(ji,jj)) 2147 ENDIF 2148 ENDIF ! End if ( l_conv ) 2149 ! 2150 END_2D 2151 CALL zdf_osm_iomput( "pb_coup", tmask(A2D(0),1) * zb_coup(A2D(0)) ) ! BBL-coupling velocity scale 2152 ! 2153 END SUBROUTINE zdf_osm_diffusivity_viscosity 2154 2155 SUBROUTINE zdf_osm_fgr_terms( Kmm, kp_ext, phbl, phml, pdh, & 2156 & pdhdt, pshear, pdtdz_bl_ext, pdsdz_bl_ext, pdbdz_bl_ext, & 2157 & pdiffut, pviscos ) 2158 !!--------------------------------------------------------------------- 2159 !! *** ROUTINE zdf_osm_fgr_terms *** 2160 !! 2161 !! ** Purpose : Compute non-gradient terms in flux-gradient relationship 2162 !! 2163 !! ** Method : 2164 !! 2165 !!---------------------------------------------------------------------- 2166 INTEGER, INTENT(in ) :: Kmm ! Time-level index 2167 INTEGER, DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: kp_ext ! Offset for external level 2168 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 2169 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phml ! ML depth 2170 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdh ! Pycnocline depth 2171 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdhdt ! BL depth tendency 2172 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pshear ! Shear production 2173 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdtdz_bl_ext ! External temperature gradients 2174 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdsdz_bl_ext ! External salinity gradients 2175 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdbdz_bl_ext ! External buoyancy gradients 2176 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk), INTENT(in ) :: pdiffut ! t-diffusivity 2177 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk), INTENT(in ) :: pviscos ! Viscosity 2178 !! 2179 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zalpha_pyc ! 2180 REAL(wp), DIMENSION(A2D(nn_hls-1),jpk) :: zdbdz_pyc ! Parametrised gradient of buoyancy in the pycnocline 2181 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: z3ddz_pyc_1, z3ddz_pyc_2 ! Pycnocline gradient/shear profiles 2182 !! 2183 INTEGER :: ji, jj, jk, jkm_bld, jkf_mld, jkm_mld ! Loop indices 2184 INTEGER :: istat ! Memory allocation status 2185 REAL(wp) :: zznd_d, zznd_ml, zznd_pyc, znd ! Temporary non-dimensional depths 2186 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zsc_wth_1,zsc_ws_1 ! Temporary scales 2187 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zsc_uw_1, zsc_uw_2 ! Temporary scales 2188 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zsc_vw_1, zsc_vw_2 ! Temporary scales 2189 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: ztau_sc_u ! Dissipation timescale at base of WML 2190 REAL(wp) :: zbuoy_pyc_sc, zdelta_pyc ! 2191 REAL(wp) :: zl_c,zl_l,zl_eps ! Used to calculate turbulence length scale 2192 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: za_cubic, zb_cubic ! Coefficients in cubic polynomial specifying 2193 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zc_cubic, zd_cubic ! diffusivity in pycnocline 2194 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwt_pyc_sc_1, zws_pyc_sc_1 ! 2195 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zzeta_pyc ! 2196 REAL(wp) :: zomega, zvw_max ! 2197 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zuw_bse,zvw_bse ! Momentum, heat, and salinity fluxes 2198 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zwth_ent,zws_ent ! at the top of the pycnocline 2199 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: zsc_wth_pyc, zsc_ws_pyc ! Scales for pycnocline transport term 2200 REAL(wp) :: ztmp ! 2201 REAL(wp) :: ztgrad, zsgrad, zbgrad ! Variables used to calculate pycnocline 2202 !! ! gradients 2203 REAL(wp) :: zugrad, zvgrad ! Variables for calculating pycnocline shear 2204 REAL(wp) :: zdtdz_pyc ! Parametrized gradient of temperature in 2205 !! ! pycnocline 2206 REAL(wp) :: zdsdz_pyc ! Parametrised gradient of salinity in 2207 !! ! pycnocline 2208 REAL(wp) :: zdudz_pyc ! u-shear across the pycnocline 2209 REAL(wp) :: zdvdz_pyc ! v-shear across the pycnocline 2210 !!---------------------------------------------------------------------- 2211 ! 2212 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 2213 ! Pycnocline gradients for scalars and velocity 2214 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 2215 CALL zdf_osm_pycnocline_buoyancy_profiles( Kmm, kp_ext, zdbdz_pyc, zalpha_pyc, pdh, & 2216 & phbl, pdbdz_bl_ext, phml, pdhdt ) 2217 ! 2218 ! Auxiliary indices 2219 ! ----------------- 2220 jkm_bld = 0 2221 jkf_mld = jpk 2222 jkm_mld = 0 2223 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2224 IF ( nbld(ji,jj) > jkm_bld ) jkm_bld = nbld(ji,jj) 2225 IF ( nmld(ji,jj) < jkf_mld ) jkf_mld = nmld(ji,jj) 2226 IF ( nmld(ji,jj) > jkm_mld ) jkm_mld = nmld(ji,jj) 2227 END_2D 2228 ! 2229 ! Stokes term in scalar flux, flux-gradient relationship 2230 ! ------------------------------------------------------ 2231 WHERE ( l_conv(A2D(nn_hls-1)) ) 2232 zsc_wth_1(:,:) = swstrl(A2D(nn_hls-1))**3 * swth0(A2D(nn_hls-1)) / & 2233 & ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 + epsln ) 2234 zsc_ws_1(:,:) = swstrl(A2D(nn_hls-1))**3 * sws0(A2D(nn_hls-1)) / & 2235 & ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 + epsln ) 2236 ELSEWHERE 2237 zsc_wth_1(:,:) = 2.0_wp * swthav(A2D(nn_hls-1)) 2238 zsc_ws_1(:,:) = 2.0_wp * swsav(A2D(nn_hls-1)) 2239 ENDWHERE 2240 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, MAX( jkm_mld, jkm_bld ) ) 2241 IF ( l_conv(ji,jj) ) THEN 2242 IF ( jk <= nmld(ji,jj) ) THEN 2243 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2244 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 1.35_wp * EXP( -1.0_wp * zznd_d ) * & 2245 & ( 1.0_wp - EXP( -2.0_wp * zznd_d ) ) * zsc_wth_1(ji,jj) 2246 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 1.35_wp * EXP( -1.0_wp * zznd_d ) * & 2247 & ( 1.0_wp - EXP( -2.0_wp * zznd_d ) ) * zsc_ws_1(ji,jj) 2248 END IF 2249 ELSE ! Stable conditions 2250 IF ( jk <= nbld(ji,jj) ) THEN 2251 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2252 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 2.15_wp * EXP( -0.85_wp * zznd_d ) * & 2253 & ( 1.0_wp - EXP( -4.0_wp * zznd_d ) ) * zsc_wth_1(ji,jj) 2254 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 2.15_wp * EXP( -0.85_wp * zznd_d ) * & 2255 & ( 1.0_wp - EXP( -4.0_wp * zznd_d ) ) * zsc_ws_1(ji,jj) 2256 END IF 2257 END IF ! Check on l_conv 2258 END_3D 2259 ! 2260 IF ( ln_dia_osm ) THEN 2261 CALL zdf_osm_iomput( "ghamu_00", wmask(A2D(0),:) * ghamu(A2D(0),:) ) 2262 CALL zdf_osm_iomput( "ghamv_00", wmask(A2D(0),:) * ghamv(A2D(0),:) ) 2263 END IF 2264 ! 2265 ! Stokes term in flux-gradient relationship (note in zsc_uw_n don't use 2266 ! svstr since term needs to go to zero as swstrl goes to zero) 2267 ! --------------------------------------------------------------------- 2268 WHERE ( l_conv(A2D(nn_hls-1)) ) 2269 zsc_uw_1(:,:) = ( swstrl(A2D(nn_hls-1))**3 + & 2270 & 0.5_wp * swstrc(A2D(nn_hls-1))**3 )**pthird * sustke(A2D(nn_hls-1)) / & 2271 & MAX( ( 1.0_wp - 1.0_wp * 6.5_wp * sla(A2D(nn_hls-1))**( 8.0_wp / 3.0_wp ) ), 0.2_wp ) 2272 zsc_uw_2(:,:) = ( swstrl(A2D(nn_hls-1))**3 + & 2273 & 0.5_wp * swstrc(A2D(nn_hls-1))**3 )**pthird * sustke(A2D(nn_hls-1)) / & 2274 & MIN( sla(A2D(nn_hls-1))**( 8.0_wp / 3.0_wp ) + epsln, 0.12_wp ) 2275 zsc_vw_1(:,:) = ff_t(A2D(nn_hls-1)) * phml(A2D(nn_hls-1)) * sustke(A2D(nn_hls-1))**3 * & 2276 & MIN( sla(A2D(nn_hls-1))**( 8.0_wp / 3.0_wp ), 0.12_wp ) / & 2277 & ( ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 )**( 2.0_wp / 3.0_wp ) + epsln ) 2278 ELSEWHERE 2279 zsc_uw_1(:,:) = sustar(A2D(nn_hls-1))**2 2280 zsc_vw_1(:,:) = ff_t(A2D(nn_hls-1)) * phbl(A2D(nn_hls-1)) * sustke(A2D(nn_hls-1))**3 * & 2281 & MIN( sla(A2D(nn_hls-1))**( 8.0_wp / 3.0_wp ), 0.12_wp ) / ( svstr(A2D(nn_hls-1))**2 + epsln ) 2282 ENDWHERE 2283 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, MAX( jkm_mld, jkm_bld ) ) 2284 IF ( l_conv(ji,jj) ) THEN 2285 IF ( jk <= nmld(ji,jj) ) THEN 2286 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2287 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + ( -0.05_wp * EXP( -0.4_wp * zznd_d ) * zsc_uw_1(ji,jj) + & 2288 & 0.00125_wp * EXP( -1.0_wp * zznd_d ) * zsc_uw_2(ji,jj) ) * & 2289 & ( 1.0_wp - EXP( -2.0_wp * zznd_d ) ) 2290 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) - 0.65_wp * 0.15_wp * EXP( -1.0_wp * zznd_d ) * & 2291 & ( 1.0_wp - EXP( -2.0_wp * zznd_d ) ) * zsc_vw_1(ji,jj) 2292 END IF 2293 ELSE ! Stable conditions 2294 IF ( jk <= nbld(ji,jj) ) THEN ! Corrected to nbld 2295 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2296 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) - 0.75_wp * 1.3_wp * EXP( -0.5_wp * zznd_d ) * & 2297 & ( 1.0_wp - EXP( -4.0_wp * zznd_d ) ) * zsc_uw_1(ji,jj) 2298 END IF 2299 END IF 2300 END_3D 2301 ! 2302 ! Buoyancy term in flux-gradient relationship [note : includes ROI ratio 2303 ! (X0.3) and pressure (X0.5)] 2304 ! ---------------------------------------------------------------------- 2305 WHERE ( l_conv(A2D(nn_hls-1)) ) 2306 zsc_wth_1(:,:) = swbav(A2D(nn_hls-1)) * swth0(A2D(nn_hls-1)) * ( 1.0_wp + EXP( 0.2_wp * shol(A2D(nn_hls-1)) ) ) * & 2307 & phml(A2D(nn_hls-1)) / ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 + epsln ) 2308 zsc_ws_1(:,:) = swbav(A2D(nn_hls-1)) * sws0(A2D(nn_hls-1)) * ( 1.0_wp + EXP( 0.2_wp * shol(A2D(nn_hls-1)) ) ) * & 2309 & phml(A2D(nn_hls-1)) / ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 + epsln ) 2310 ELSEWHERE 2311 zsc_wth_1(:,:) = 0.0_wp 2312 zsc_ws_1(:,:) = 0.0_wp 2313 ENDWHERE 2314 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, MAX( jkm_mld, jkm_bld ) ) 2315 IF ( l_conv(ji,jj) ) THEN 2316 IF ( jk <= nmld(ji,jj) ) THEN 2317 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2318 ! Calculate turbulent time scale 2319 zl_c = 0.9_wp * ( 1.0_wp - EXP( -5.0_wp * ( zznd_ml + zznd_ml**3 / 3.0_wp ) ) ) * & 2320 & ( 1.0_wp - EXP( -15.0_wp * ( 1.2_wp - zznd_ml ) ) ) 2321 zl_l = 2.0_wp * ( 1.0_wp - EXP( -2.0_wp * ( zznd_ml + zznd_ml**3 / 3.0_wp ) ) ) * & 2322 & ( 1.0_wp - EXP( -8.0_wp * ( 1.15_wp - zznd_ml ) ) ) * ( 1.0_wp + dstokes(ji,jj) / phml (ji,jj) ) 2323 zl_eps = zl_l + ( zl_c - zl_l ) / ( 1.0_wp + EXP( -3.0_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) )**( 3.0_wp / 2.0_wp ) 2324 ! Non-gradient buoyancy terms 2325 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3_wp * 0.4_wp * zsc_wth_1(ji,jj) * zl_eps / ( 0.15_wp + zznd_ml ) 2326 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.3_wp * 0.4_wp * zsc_ws_1(ji,jj) * zl_eps / ( 0.15_wp + zznd_ml ) 2327 END IF 2328 ELSE ! Stable conditions 2329 IF ( jk <= nbld(ji,jj) ) THEN 2330 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + zsc_wth_1(ji,jj) 2331 ghams(ji,jj,jk) = ghams(ji,jj,jk) + zsc_ws_1(ji,jj) 2332 END IF 2333 END IF 2334 END_3D 2335 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2336 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) ) THEN 2337 ztau_sc_u(ji,jj) = phml(ji,jj) / ( svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird * & 2338 & ( 1.4_wp - 0.4_wp / ( 1.0_wp + EXP( -3.5_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) )**1.5_wp ) 2339 zwth_ent(ji,jj) = -0.003_wp * ( 0.15_wp * svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird * & 2340 & ( 1.0_wp - pdh(ji,jj) / phbl(ji,jj) ) * av_dt_ml(ji,jj) 2341 zws_ent(ji,jj) = -0.003_wp * ( 0.15_wp * svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird * & 2342 & ( 1.0_wp - pdh(ji,jj) / phbl(ji,jj) ) * av_ds_ml(ji,jj) 2343 IF ( dh(ji,jj) < 0.2_wp * hbl(ji,jj) ) THEN 2344 zbuoy_pyc_sc = 2.0_wp * MAX( av_db_ml(ji,jj), 0.0_wp ) / pdh(ji,jj) 2345 zdelta_pyc = ( svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird / & 2346 & SQRT( MAX( zbuoy_pyc_sc, ( svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**p2third / pdh(ji,jj)**2 ) ) 2347 zwt_pyc_sc_1(ji,jj) = 0.325_wp * ( zalpha_pyc(ji,jj) * av_dt_ml(ji,jj) / pdh(ji,jj) + pdtdz_bl_ext(ji,jj) ) * & 2348 & zdelta_pyc**2 / pdh(ji,jj) 2349 zws_pyc_sc_1(ji,jj) = 0.325_wp * ( zalpha_pyc(ji,jj) * av_ds_ml(ji,jj) / pdh(ji,jj) + pdsdz_bl_ext(ji,jj) ) * & 2350 & zdelta_pyc**2 / pdh(ji,jj) 2351 zzeta_pyc(ji,jj) = 0.15_wp - 0.175_wp / ( 1.0_wp + EXP( -3.5_wp * LOG10( -1.0_wp * shol(ji,jj) ) ) ) 2352 END IF 2353 END IF 2354 END_2D 2355 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jkm_bld ) 2356 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2357 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2358 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) - & 2359 & 0.045_wp * ( ( zwth_ent(ji,jj) * zdbdz_pyc(ji,jj,jk) ) * ztau_sc_u(ji,jj)**2 ) * & 2360 & MAX( ( 1.75_wp * zznd_pyc -0.15_wp * zznd_pyc**2 - 0.2_wp * zznd_pyc**3 ), 0.0_wp ) 2361 ghams(ji,jj,jk) = ghams(ji,jj,jk) - & 2362 & 0.045_wp * ( ( zws_ent(ji,jj) * zdbdz_pyc(ji,jj,jk) ) * ztau_sc_u(ji,jj)**2 ) * & 2363 & MAX( ( 1.75_wp * zznd_pyc -0.15_wp * zznd_pyc**2 - 0.2_wp * zznd_pyc**3 ), 0.0_wp ) 2364 IF ( dh(ji,jj) < 0.2_wp * hbl(ji,jj) .AND. nbld(ji,jj) - nmld(ji,jj) > 3 ) THEN 2365 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.05_wp * zwt_pyc_sc_1(ji,jj) * & 2366 & EXP( -0.25_wp * ( zznd_pyc / zzeta_pyc(ji,jj) )**2 ) * & 2367 & pdh(ji,jj) / ( svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird 2368 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.05_wp * zws_pyc_sc_1(ji,jj) * & 2369 & EXP( -0.25_wp * ( zznd_pyc / zzeta_pyc(ji,jj) )**2 ) * & 2370 & pdh(ji,jj) / ( svstr(ji,jj)**3 + swstrc(ji,jj)**3 )**pthird 2371 END IF 2372 END IF ! End of pycnocline 2373 END_3D 2374 ! 2375 IF ( ln_dia_osm ) THEN 2376 CALL zdf_osm_iomput( "zwth_ent", tmask(A2D(0),1) * zwth_ent(A2D(0)) ) ! Upward turb. temperature entrainment flux 2377 CALL zdf_osm_iomput( "zws_ent", tmask(A2D(0),1) * zws_ent(A2D(0)) ) ! Upward turb. salinity entrainment flux 2378 END IF 2379 ! 2380 zsc_vw_1(:,:) = 0.0_wp 2381 WHERE ( l_conv(A2D(nn_hls-1)) ) 2382 zsc_uw_1(:,:) = -1.0_wp * swb0(A2D(nn_hls-1)) * sustar(A2D(nn_hls-1))**2 * phml(A2D(nn_hls-1)) / & 2383 & ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 + epsln ) 2384 zsc_uw_2(:,:) = swb0(A2D(nn_hls-1)) * sustke(A2D(nn_hls-1)) * phml(A2D(nn_hls-1)) / & 2385 & ( svstr(A2D(nn_hls-1))**3 + 0.5_wp * swstrc(A2D(nn_hls-1))**3 + epsln )**( 2.0_wp / 3.0_wp ) 2386 ELSEWHERE 2387 zsc_uw_1(:,:) = 0.0_wp 2388 ENDWHERE 2389 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, MAX( jkm_mld, jkm_bld ) ) 2390 IF ( l_conv(ji,jj) ) THEN 2391 IF ( jk <= nmld(ji,jj) ) THEN 2392 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2393 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + 0.3_wp * 0.5_wp * & 2394 & ( zsc_uw_1(ji,jj) + 0.125_wp * EXP( -0.5_wp * zznd_d ) * & 2395 & ( 1.0_wp - EXP( -0.5_wp * zznd_d ) ) * zsc_uw_2(ji,jj) ) 2396 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + zsc_vw_1(ji,jj) 2397 END IF 2398 ELSE ! Stable conditions 2399 IF ( jk <= nbld(ji,jj) ) THEN 2400 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + zsc_uw_1(ji,jj) 2401 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + zsc_vw_1(ji,jj) 2402 END IF 2217 2403 ENDIF 2218 2219 ELSE ! lshear 2220 ! for lshear = .FALSE. calculate ddhdt here 2221 2222 IF ( lconv(ji,jj) ) THEN 2223 2224 IF( ln_osm_mle ) THEN 2225 IF ( ( zwb_ent(ji,jj) + 2.0 * zwb_fk_b(ji,jj) ) < 0._wp ) THEN 2226 ! OSBL is deepening. Note wb_fk_b is zero if ln_osm_mle=F 2227 IF ( zdb_bl(ji,jj) > 0._wp .and. zdbdz_bl_ext(ji,jj) > 0._wp)THEN 2228 IF ( ( zwstrc(ji,jj) / MAX(zvstr(ji,jj), epsln) )**3 <= 0.5 ) THEN ! near neutral stability 2229 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zvstr(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 2230 ELSE ! unstable 2231 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zwstrc(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 2232 ENDIF 2233 ztau = 0.2 * hbl(ji,jj) / MAX(epsln, (zvstr(ji,jj)**3 + 0.5 *zwstrc(ji,jj)**3)**pthird) 2234 zdh_ref = zari * hbl(ji,jj) 2404 END_3D 2405 ! 2406 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2407 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) ) THEN 2408 IF ( n_ddh(ji,jj) == 0 ) THEN 2409 ! Place holding code. Parametrization needs checking for these conditions. 2410 zomega = ( 0.15_wp * swstrl(ji,jj)**3 + swstrc(ji,jj)**3 + 4.75_wp * ( pshear(ji,jj) * phbl(ji,jj) ) )**pthird 2411 zuw_bse(ji,jj) = -0.0035_wp * zomega * ( 1.0_wp - pdh(ji,jj) / phbl(ji,jj) ) * av_du_ml(ji,jj) 2412 zvw_bse(ji,jj) = -0.0075_wp * zomega * ( 1.0_wp - pdh(ji,jj) / phbl(ji,jj) ) * av_dv_ml(ji,jj) 2413 ELSE 2414 zomega = ( 0.15_wp * swstrl(ji,jj)**3 + swstrc(ji,jj)**3 + 4.75_wp * ( pshear(ji,jj) * phbl(ji,jj) ) )**pthird 2415 zuw_bse(ji,jj) = -0.0035_wp * zomega * ( 1.0_wp - pdh(ji,jj) / phbl(ji,jj) ) * av_du_ml(ji,jj) 2416 zvw_bse(ji,jj) = -0.0075_wp * zomega * ( 1.0_wp - pdh(ji,jj) / phbl(ji,jj) ) * av_dv_ml(ji,jj) 2417 ENDIF 2418 zb_cubic(ji,jj) = pdh(ji,jj) / phbl(ji,jj) * suw0(ji,jj) - ( 2.0_wp + pdh(ji,jj) / phml(ji,jj) ) * zuw_bse(ji,jj) 2419 za_cubic(ji,jj) = zuw_bse(ji,jj) - zb_cubic(ji,jj) 2420 zvw_max = 0.7_wp * ff_t(ji,jj) * ( sustke(ji,jj) * dstokes(ji,jj) + 0.7_wp * sustar(ji,jj) * phml(ji,jj) ) 2421 zd_cubic(ji,jj) = zvw_max * pdh(ji,jj) / phml(ji,jj) - ( 2.0_wp + pdh(ji,jj) / phml(ji,jj) ) * zvw_bse(ji,jj) 2422 zc_cubic(ji,jj) = zvw_bse(ji,jj) - zd_cubic(ji,jj) 2423 END IF 2424 END_2D 2425 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jkf_mld, jkm_bld ) ! Need ztau_sc_u to be available. Change to array. 2426 IF ( l_conv(ji,jj) .AND. l_pyc(ji,jj) .AND. ( jk >= nmld(ji,jj) ) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2427 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2428 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) - 0.045_wp * ( ztau_sc_u(ji,jj)**2 ) * zuw_bse(ji,jj) * & 2429 & ( za_cubic(ji,jj) * zznd_pyc**2 + zb_cubic(ji,jj) * zznd_pyc**3 ) * & 2430 & ( 0.75_wp + 0.25_wp * zznd_pyc )**2 * zdbdz_pyc(ji,jj,jk) 2431 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) - 0.045_wp * ( ztau_sc_u(ji,jj)**2 ) * zvw_bse(ji,jj) * & 2432 & ( zc_cubic(ji,jj) * zznd_pyc**2 + zd_cubic(ji,jj) * zznd_pyc**3 ) * & 2433 & ( 0.75_wp + 0.25_wp * zznd_pyc )**2 * zdbdz_pyc(ji,jj,jk) 2434 END IF ! l_conv .AND. l_pyc 2435 END_3D 2436 ! 2437 IF ( ln_dia_osm ) THEN 2438 CALL zdf_osm_iomput( "ghamu_0", wmask(A2D(0),:) * ghamu(A2D(0),:) ) 2439 CALL zdf_osm_iomput( "zsc_uw_1_0", tmask(A2D(0),1) * zsc_uw_1(A2D(0)) ) 2440 END IF 2441 ! 2442 ! Transport term in flux-gradient relationship [note : includes ROI ratio 2443 ! (X0.3) ] 2444 ! ----------------------------------------------------------------------- 2445 WHERE ( l_conv(A2D(nn_hls-1)) ) 2446 zsc_wth_1(:,:) = swth0(A2D(nn_hls-1)) / ( 1.0_wp - 0.56_wp * EXP( shol(A2D(nn_hls-1)) ) ) 2447 zsc_ws_1(:,:) = sws0(A2D(nn_hls-1)) / ( 1.0_wp - 0.56_wp * EXP( shol(A2D(nn_hls-1)) ) ) 2448 WHERE ( l_pyc(A2D(nn_hls-1)) ) ! Pycnocline scales 2449 zsc_wth_pyc(:,:) = -0.003_wp * swstrc(A2D(nn_hls-1)) * ( 1.0_wp - pdh(A2D(nn_hls-1)) / phbl(A2D(nn_hls-1)) ) * & 2450 & av_dt_ml(A2D(nn_hls-1)) 2451 zsc_ws_pyc(:,:) = -0.003_wp * swstrc(A2D(nn_hls-1)) * ( 1.0_wp - pdh(A2D(nn_hls-1)) / phbl(A2D(nn_hls-1)) ) * & 2452 & av_ds_ml(A2D(nn_hls-1)) 2453 END WHERE 2454 ELSEWHERE 2455 zsc_wth_1(:,:) = 2.0_wp * swthav(A2D(nn_hls-1)) 2456 zsc_ws_1(:,:) = sws0(A2D(nn_hls-1)) 2457 END WHERE 2458 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, MAX( jkm_mld, jkm_bld ) ) 2459 IF ( l_conv(ji,jj) ) THEN 2460 IF ( ( jk > 1 ) .AND. ( jk <= nmld(ji,jj) ) ) THEN 2461 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2462 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3_wp * zsc_wth_1(ji,jj) * & 2463 & ( -2.0_wp + 2.75_wp * ( ( 1.0_wp + 0.6_wp * zznd_ml**4 ) - & 2464 & EXP( -6.0_wp * zznd_ml ) ) ) * & 2465 & ( 1.0_wp - EXP( -15.0_wp * ( 1.0_wp - zznd_ml ) ) ) 2466 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.3_wp * zsc_ws_1(ji,jj) * & 2467 & ( -2.0_wp + 2.75_wp * ( ( 1.0_wp + 0.6_wp * zznd_ml**4 ) - & 2468 & EXP( -6.0_wp * zznd_ml ) ) ) * ( 1.0_wp - EXP( -15.0_wp * ( 1.0_wp - zznd_ml ) ) ) 2469 END IF 2470 ! 2471 ! may need to comment out lpyc block 2472 IF ( l_pyc(ji,jj) .AND. ( jk >= nmld(ji,jj) ) .AND. ( jk <= nbld(ji,jj) ) ) THEN ! Pycnocline 2473 zznd_pyc = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / pdh(ji,jj) 2474 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 4.0_wp * zsc_wth_pyc(ji,jj) * & 2475 & ( 0.48_wp - EXP( -1.5_wp * ( zznd_pyc - 0.3_wp )**2 ) ) 2476 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 4.0_wp * zsc_ws_pyc(ji,jj) * & 2477 & ( 0.48_wp - EXP( -1.5_wp * ( zznd_pyc - 0.3_wp )**2 ) ) 2478 END IF 2479 ELSE 2480 IF( pdhdt(ji,jj) > 0. ) THEN 2481 IF ( ( jk > 1 ) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2482 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2483 znd = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 2484 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + 0.3_wp * ( -4.06_wp * EXP( -2.0_wp * zznd_d ) * ( 1.0_wp - EXP( -4.0_wp * zznd_d ) ) + & 2485 7.5_wp * EXP ( -10.0_wp * ( 0.95_wp - znd )**2 ) * ( 1.0_wp - znd ) ) * zsc_wth_1(ji,jj) 2486 ghams(ji,jj,jk) = ghams(ji,jj,jk) + 0.3_wp * ( -4.06_wp * EXP( -2.0_wp * zznd_d ) * ( 1.0_wp - EXP( -4.0_wp * zznd_d ) ) + & 2487 7.5_wp * EXP ( -10.0_wp * ( 0.95_wp - znd )**2 ) * ( 1.0_wp - znd ) ) * zsc_ws_1(ji,jj) 2488 END IF 2489 ENDIF 2490 ENDIF 2491 END_3D 2492 ! 2493 WHERE ( l_conv(A2D(nn_hls-1)) ) 2494 zsc_uw_1(:,:) = sustar(A2D(nn_hls-1))**2 2495 zsc_vw_1(:,:) = ff_t(A2D(nn_hls-1)) * sustke(A2D(nn_hls-1)) * phml(A2D(nn_hls-1)) 2496 ELSEWHERE 2497 zsc_uw_1(:,:) = sustar(A2D(nn_hls-1))**2 2498 zsc_uw_2(:,:) = ( 2.25_wp - 3.0_wp * ( 1.0_wp - EXP( -1.25_wp * 2.0_wp ) ) ) * ( 1.0_wp - EXP( -4.0_wp * 2.0_wp ) ) * & 2499 & zsc_uw_1(:,:) 2500 zsc_vw_1(:,:) = ff_t(A2D(nn_hls-1)) * sustke(A2D(nn_hls-1)) * phbl(A2D(nn_hls-1)) 2501 zsc_vw_2(:,:) = -0.11_wp * SIN( 3.14159_wp * ( 2.0_wp + 0.4_wp ) ) * EXP( -1.0_wp * ( 1.5_wp + 2.0_wp )**2 ) * & 2502 & zsc_vw_1(:,:) 2503 ENDWHERE 2504 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, MAX( jkm_mld, jkm_bld ) ) 2505 IF ( l_conv(ji,jj) ) THEN 2506 IF ( jk <= nmld(ji,jj) ) THEN 2507 zznd_ml = gdepw(ji,jj,jk,Kmm) / phml(ji,jj) 2508 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2509 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + & 2510 & 0.3_wp * ( -2.0_wp + 2.5_wp * ( 1.0_wp + 0.1_wp * zznd_ml**4 ) - EXP( -8.0_wp * zznd_ml ) ) * & 2511 & zsc_uw_1(ji,jj) 2512 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + & 2513 & 0.3_wp * 0.1_wp * ( EXP( -1.0_wp * zznd_d ) + EXP( -5.0_wp * ( 1.0_wp - zznd_ml ) ) ) * & 2514 & zsc_vw_1(ji,jj) 2515 END IF 2516 ELSE 2517 IF ( jk <= nbld(ji,jj) ) THEN 2518 znd = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 2519 zznd_d = gdepw(ji,jj,jk,Kmm) / dstokes(ji,jj) 2520 IF ( zznd_d <= 2.0_wp ) THEN 2521 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + 0.5_wp * 0.3_wp * & 2522 & ( 2.25_wp - 3.0_wp * ( 1.0_wp - EXP( -1.25_wp * zznd_d ) ) * & 2523 & ( 1.0_wp - EXP( -2.0_wp * zznd_d ) ) ) * zsc_uw_1(ji,jj) 2524 ELSE 2525 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + 0.5_wp * 0.3_wp * & 2526 & ( 1.0_wp - EXP( -5.0_wp * ( 1.0_wp - znd ) ) ) * zsc_uw_2(ji,jj) 2527 ENDIF 2528 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + 0.3_wp * 0.15_wp * SIN( 3.14159_wp * ( 0.65_wp * zznd_d ) ) * & 2529 & EXP( -0.25_wp * zznd_d**2 ) * zsc_vw_1(ji,jj) 2530 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + 0.3_wp * 0.15_wp * EXP( -5.0 * ( 1.0 - znd ) ) * & 2531 & ( 1.0 - EXP( -20.0 * ( 1.0 - znd ) ) ) * zsc_vw_2(ji,jj) 2532 END IF 2533 END IF 2534 END_3D 2535 ! 2536 IF ( ln_dia_osm ) THEN 2537 CALL zdf_osm_iomput( "ghamu_f", wmask(A2D(0),:) * ghamu(A2D(0),:) ) 2538 CALL zdf_osm_iomput( "ghamv_f", wmask(A2D(0),:) * ghamv(A2D(0),:) ) 2539 CALL zdf_osm_iomput( "zsc_uw_1_f", tmask(A2D(0),1) * zsc_uw_1(A2D(0)) ) 2540 CALL zdf_osm_iomput( "zsc_vw_1_f", tmask(A2D(0),1) * zsc_vw_1(A2D(0)) ) 2541 CALL zdf_osm_iomput( "zsc_uw_2_f", tmask(A2D(0),1) * zsc_uw_2(A2D(0)) ) 2542 CALL zdf_osm_iomput( "zsc_vw_2_f", tmask(A2D(0),1) * zsc_vw_2(A2D(0)) ) 2543 END IF 2544 ! 2545 ! Make surface forced velocity non-gradient terms go to zero at the base 2546 ! of the mixed layer. 2547 ! 2548 ! Make surface forced velocity non-gradient terms go to zero at the base 2549 ! of the boundary layer. 2550 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jkm_bld ) 2551 IF ( ( .NOT. l_conv(ji,jj) ) .AND. ( jk <= nbld(ji,jj) ) ) THEN 2552 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) / phbl(ji,jj) ! ALMG to think about 2553 IF ( znd >= 0.0_wp ) THEN 2554 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) * ( 1.0_wp - EXP( -10.0_wp * znd**2 ) ) 2555 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) * ( 1.0_wp - EXP( -10.0_wp * znd**2 ) ) 2556 ELSE 2557 ghamu(ji,jj,jk) = 0.0_wp 2558 ghamv(ji,jj,jk) = 0.0_wp 2559 ENDIF 2560 END IF 2561 END_3D 2562 ! 2563 ! Pynocline contributions 2564 ! 2565 IF ( ln_dia_pyc_scl .OR. ln_dia_pyc_shr ) THEN ! Allocate arrays for output of pycnocline gradient/shear profiles 2566 ALLOCATE( z3ddz_pyc_1(A2D(nn_hls),jpk), z3ddz_pyc_2(A2D(nn_hls),jpk), STAT=istat ) 2567 IF ( istat /= 0 ) CALL ctl_stop( 'zdf_osm: failed to allocate temporary arrays' ) 2568 z3ddz_pyc_1(:,:,:) = 0.0_wp 2569 z3ddz_pyc_2(:,:,:) = 0.0_wp 2570 END IF 2571 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jkm_bld ) 2572 IF ( l_conv (ji,jj) ) THEN 2573 ! Unstable conditions. Shouldn;t be needed with no pycnocline code. 2574 ! zugrad = 0.7 * av_du_ml(ji,jj) / zdh(ji,jj) + 0.3 * zustar(ji,jj)*zustar(ji,jj) / & 2575 ! & ( ( ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird * zhml(ji,jj) ) * & 2576 ! & MIN(zla(ji,jj)**(8.0/3.0) + epsln, 0.12 )) 2577 !Alan is this right? 2578 ! zvgrad = ( 0.7 * av_dv_ml(ji,jj) + & 2579 ! & 2.0 * ff_t(ji,jj) * zustke(ji,jj) * dstokes(ji,jj) / & 2580 ! & ( ( zvstr(ji,jj)**3 + 0.5 * zwstrc(ji,jj)**3 )**pthird + epsln ) & 2581 ! & )/ (zdh(ji,jj) + epsln ) 2582 ! DO jk = 2, nbld(ji,jj) - 1 + ibld_ext 2583 ! znd = -( gdepw(ji,jj,jk,Kmm) - zhbl(ji,jj) ) / (zdh(ji,jj) + epsln ) - zzeta_v 2584 ! IF ( znd <= 0.0 ) THEN 2585 ! zdudz(ji,jj,jk) = 1.25 * zugrad * EXP( 3.0 * znd ) 2586 ! zdvdz(ji,jj,jk) = 1.25 * zvgrad * EXP( 3.0 * znd ) 2587 ! ELSE 2588 ! zdudz(ji,jj,jk) = 1.25 * zugrad * EXP( -2.0 * znd ) 2589 ! zdvdz(ji,jj,jk) = 1.25 * zvgrad * EXP( -2.0 * znd ) 2590 ! ENDIF 2591 ! END DO 2592 ELSE ! Stable conditions 2593 IF ( nbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN 2594 ! Pycnocline profile only defined when depth steady of increasing. 2595 IF ( pdhdt(ji,jj) > 0.0_wp ) THEN ! Depth increasing, or steady. 2596 IF ( av_db_bl(ji,jj) > 0.0_wp ) THEN 2597 IF ( shol(ji,jj) >= 0.5_wp ) THEN ! Very stable - 'thick' pycnocline 2598 ztmp = 1.0_wp / MAX( phbl(ji,jj), epsln ) 2599 ztgrad = av_dt_bl(ji,jj) * ztmp 2600 zsgrad = av_ds_bl(ji,jj) * ztmp 2601 zbgrad = av_db_bl(ji,jj) * ztmp 2602 IF ( jk <= nbld(ji,jj) ) THEN 2603 znd = gdepw(ji,jj,jk,Kmm) * ztmp 2604 zdtdz_pyc = ztgrad * EXP( -15.0_wp * ( znd - 0.9_wp )**2 ) 2605 zdsdz_pyc = zsgrad * EXP( -15.0_wp * ( znd - 0.9_wp )**2 ) 2606 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + pdiffut(ji,jj,jk) * zdtdz_pyc 2607 ghams(ji,jj,jk) = ghams(ji,jj,jk) + pdiffut(ji,jj,jk) * zdsdz_pyc 2608 IF ( ln_dia_pyc_scl ) THEN 2609 z3ddz_pyc_1(ji,jj,jk) = zdtdz_pyc 2610 z3ddz_pyc_2(ji,jj,jk) = zdsdz_pyc 2611 END IF 2612 END IF 2613 ELSE ! Slightly stable - 'thin' pycnoline - needed when stable layer begins to form. 2614 ztmp = 1.0_wp / MAX( pdh(ji,jj), epsln ) 2615 ztgrad = av_dt_bl(ji,jj) * ztmp 2616 zsgrad = av_ds_bl(ji,jj) * ztmp 2617 zbgrad = av_db_bl(ji,jj) * ztmp 2618 IF ( jk <= nbld(ji,jj) ) THEN 2619 znd = -1.0_wp * ( gdepw(ji,jj,jk,Kmm) - phml(ji,jj) ) * ztmp 2620 zdtdz_pyc = ztgrad * EXP( -1.75_wp * ( znd + 0.75_wp )**2 ) 2621 zdsdz_pyc = zsgrad * EXP( -1.75_wp * ( znd + 0.75_wp )**2 ) 2622 ghamt(ji,jj,jk) = ghamt(ji,jj,jk) + pdiffut(ji,jj,jk) * zdtdz_pyc 2623 ghams(ji,jj,jk) = ghams(ji,jj,jk) + pdiffut(ji,jj,jk) * zdsdz_pyc 2624 IF ( ln_dia_pyc_scl ) THEN 2625 z3ddz_pyc_1(ji,jj,jk) = zdtdz_pyc 2626 z3ddz_pyc_2(ji,jj,jk) = zdsdz_pyc 2627 END IF 2628 END IF 2629 ENDIF ! IF (shol >=0.5) 2630 ENDIF ! IF (av_db_bl> 0.) 2631 ENDIF ! IF (zdhdt >= 0) zdhdt < 0 not considered since pycnocline profile is zero and profile arrays are 2632 ! ! intialized to zero 2633 END IF 2634 END IF 2635 END_3D 2636 IF ( ln_dia_pyc_scl ) THEN ! Output of pycnocline gradient profiles 2637 CALL zdf_osm_iomput( "zdtdz_pyc", wmask(A2D(0),:) * z3ddz_pyc_1(A2D(0),:) ) 2638 CALL zdf_osm_iomput( "zdsdz_pyc", wmask(A2D(0),:) * z3ddz_pyc_2(A2D(0),:) ) 2639 END IF 2640 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jkm_bld ) 2641 IF ( .NOT. l_conv (ji,jj) ) THEN 2642 IF ( nbld(ji,jj) + kp_ext(ji,jj) < mbkt(ji,jj) ) THEN 2643 zugrad = 3.25_wp * av_du_bl(ji,jj) / phbl(ji,jj) 2644 zvgrad = 2.75_wp * av_dv_bl(ji,jj) / phbl(ji,jj) 2645 IF ( jk <= nbld(ji,jj) ) THEN 2646 znd = gdepw(ji,jj,jk,Kmm) / phbl(ji,jj) 2647 IF ( znd < 1.0 ) THEN 2648 zdudz_pyc = zugrad * EXP( -40.0_wp * ( znd - 1.0_wp )**2 ) 2235 2649 ELSE 2236 ztau = 0.2 * hbl(ji,jj) / MAX(epsln, (zvstr(ji,jj)**3 + 0.5 *zwstrc(ji,jj)**3)**pthird) 2237 zdh_ref = 0.2 * hbl(ji,jj) 2650 zdudz_pyc = zugrad * EXP( -20.0_wp * ( znd - 1.0_wp )**2 ) 2238 2651 ENDIF 2239 ELSE 2240 ztau = 0.2 * hbl(ji,jj) / MAX(epsln, (zvstr(ji,jj)**3 + 0.5 *zwstrc(ji,jj)**3)**pthird) 2241 zdh_ref = 0.2 * hbl(ji,jj) 2242 ENDIF 2243 ELSE ! ln_osm_mle 2244 IF ( zdb_bl(ji,jj) > 0._wp .and. zdbdz_bl_ext(ji,jj) > 0._wp)THEN 2245 IF ( ( zwstrc(ji,jj) / MAX(zvstr(ji,jj), epsln) )**3 <= 0.5 ) THEN ! near neutral stability 2246 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zvstr(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 2247 ELSE ! unstable 2248 zari = MIN( 1.5 * zdb_bl(ji,jj) / ( zhbl(ji,jj) * ( MAX(zdbdz_bl_ext(ji,jj),0._wp) + zdb_bl(ji,jj)**2 / MAX(4.5 * zwstrc(ji,jj)**2 , 1.e-12 )) ), 0.2d0 ) 2249 ENDIF 2250 ztau = hbl(ji,jj) / MAX(epsln, (zvstr(ji,jj)**3 + 0.5 *zwstrc(ji,jj)**3)**pthird) 2251 zdh_ref = zari * hbl(ji,jj) 2252 ELSE 2253 ztau = hbl(ji,jj) / MAX(epsln, (zvstr(ji,jj)**3 + 0.5 *zwstrc(ji,jj)**3)**pthird) 2254 zdh_ref = 0.2 * hbl(ji,jj) 2255 ENDIF 2256 2257 END IF ! ln_osm_mle 2258 2259 dh(ji,jj) = dh(ji,jj) * EXP( -rn_Dt / ztau ) + zdh_ref * ( 1.0 - EXP( -rn_Dt / ztau ) ) 2260 ! IF ( zdhdt(ji,jj) < 0._wp .and. dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref 2261 IF ( dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref 2262 ! Alan: this hml is never defined or used 2263 ELSE ! IF (lconv) 2264 ztau = hbl(ji,jj) / MAX(zvstr(ji,jj), epsln) 2265 IF ( zdhdt(ji,jj) >= 0.0 ) THEN ! probably shouldn't include wm here 2266 ! boundary layer deepening 2267 IF ( zdb_bl(ji,jj) > 0._wp ) THEN 2268 ! pycnocline thickness set by stratification - use same relationship as for neutral conditions. 2269 zari = MIN( 4.5 * ( zvstr(ji,jj)**2 ) & 2270 & / MAX(zdb_bl(ji,jj) * zhbl(ji,jj), epsln ) + 0.01 , 0.2 ) 2271 zdh_ref = MIN( zari, 0.2 ) * hbl(ji,jj) 2272 ELSE 2273 zdh_ref = 0.2 * hbl(ji,jj) 2274 ENDIF 2275 ELSE ! IF(dhdt < 0) 2276 zdh_ref = 0.2 * hbl(ji,jj) 2277 ENDIF ! IF (dhdt >= 0) 2278 dh(ji,jj) = dh(ji,jj) * EXP( -rn_Dt / ztau )+ zdh_ref * ( 1.0 - EXP( -rn_Dt / ztau ) ) 2279 IF ( zdhdt(ji,jj) < 0._wp .and. dh(ji,jj) >= hbl(ji,jj) ) dh(ji,jj) = zdh_ref ! can be a problem with dh>hbl for rapid collapse 2280 ENDIF ! IF (lconv) 2281 ENDIF ! lshear 2282 2283 hml(ji,jj) = hbl(ji,jj) - dh(ji,jj) 2284 inhml = MAX( INT( dh(ji,jj) / MAX(e3t(ji,jj,ibld(ji,jj),Kmm), 1.e-3) ) , 1 ) 2285 imld(ji,jj) = MAX( ibld(ji,jj) - inhml, 3) 2286 zhml(ji,jj) = gdepw(ji,jj,imld(ji,jj),Kmm) 2287 zdh(ji,jj) = zhbl(ji,jj) - zhml(ji,jj) 2288 END_2D 2289 2290 END SUBROUTINE zdf_osm_pycnocline_thickness 2291 2292 2293 SUBROUTINE zdf_osm_zmld_horizontal_gradients( zmld, zdtdx, zdtdy, zdsdx, zdsdy, dbdx_mle, dbdy_mle, zdbds_mle ) 2294 !!---------------------------------------------------------------------- 2295 !! *** ROUTINE zdf_osm_horizontal_gradients *** 2296 !! 2297 !! ** Purpose : Calculates horizontal gradients of buoyancy for use with Fox-Kemper parametrization. 2652 zdvdz_pyc = zvgrad * EXP( -20.0_wp * ( znd - 0.85_wp )**2 ) 2653 ghamu(ji,jj,jk) = ghamu(ji,jj,jk) + pviscos(ji,jj,jk) * zdudz_pyc 2654 ghamv(ji,jj,jk) = ghamv(ji,jj,jk) + pviscos(ji,jj,jk) * zdvdz_pyc 2655 IF ( ln_dia_pyc_shr ) THEN 2656 z3ddz_pyc_1(ji,jj,jk) = zdudz_pyc 2657 z3ddz_pyc_2(ji,jj,jk) = zdvdz_pyc 2658 END IF 2659 END IF 2660 END IF 2661 END IF 2662 END_3D 2663 IF ( ln_dia_pyc_shr ) THEN ! Output of pycnocline shear profiles 2664 CALL zdf_osm_iomput( "zdudz_pyc", wmask(A2D(0),:) * z3ddz_pyc_1(A2D(0),:) ) 2665 CALL zdf_osm_iomput( "zdvdz_pyc", wmask(A2D(0),:) * z3ddz_pyc_2(A2D(0),:) ) 2666 END IF 2667 IF ( ln_dia_osm ) THEN 2668 CALL zdf_osm_iomput( "ghamu_b", wmask(A2D(0),:) * ghamu(A2D(0),:) ) 2669 CALL zdf_osm_iomput( "ghamv_b", wmask(A2D(0),:) * ghamv(A2D(0),:) ) 2670 END IF 2671 IF ( ln_dia_pyc_scl .OR. ln_dia_pyc_shr ) THEN ! Deallocate arrays used for output of pycnocline gradient/shear profiles 2672 DEALLOCATE( z3ddz_pyc_1, z3ddz_pyc_2 ) 2673 END IF 2674 ! 2675 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2676 ghamt(ji,jj,nbld(ji,jj)) = 0.0_wp 2677 ghams(ji,jj,nbld(ji,jj)) = 0.0_wp 2678 ghamu(ji,jj,nbld(ji,jj)) = 0.0_wp 2679 ghamv(ji,jj,nbld(ji,jj)) = 0.0_wp 2680 END_2D 2681 ! 2682 IF ( ln_dia_osm ) THEN 2683 CALL zdf_osm_iomput( "ghamu_1", wmask(A2D(0),:) * ghamu(A2D(0),:) ) 2684 CALL zdf_osm_iomput( "ghamv_1", wmask(A2D(0),:) * ghamv(A2D(0),:) ) 2685 CALL zdf_osm_iomput( "zviscos", wmask(A2D(0),:) * pviscos(A2D(0),:) ) 2686 END IF 2687 ! 2688 END SUBROUTINE zdf_osm_fgr_terms 2689 2690 SUBROUTINE zdf_osm_zmld_horizontal_gradients( Kmm, pmld, pdtdx, pdtdy, pdsdx, & 2691 & pdsdy, pdbds_mle ) 2692 !!---------------------------------------------------------------------- 2693 !! *** ROUTINE zdf_osm_zmld_horizontal_gradients *** 2694 !! 2695 !! ** Purpose : Calculates horizontal gradients of buoyancy for use with 2696 !! Fox-Kemper parametrization 2298 2697 !! 2299 2698 !! ** Method : … … 2301 2700 !! References: Fox-Kemper et al., JPO, 38, 1145-1165, 2008 2302 2701 !! Fox-Kemper and Ferrari, JPO, 38, 1166-1179, 2008 2303 2304 2305 REAL(wp), DIMENSION(jpi,jpj) :: dbdx_mle, dbdy_mle ! MLE horiz gradients at u & v points 2306 REAL(wp), DIMENSION(jpi,jpj) :: zdbds_mle ! Magnitude of horizontal buoyancy gradient. 2307 REAL(wp), DIMENSION(jpi,jpj) :: zmld ! == estimated FK BLD used for MLE horiz gradients == ! 2308 REAL(wp), DIMENSION(jpi,jpj) :: zdtdx, zdtdy, zdsdx, zdsdy 2309 2310 INTEGER :: ji, jj, jk ! dummy loop indices 2311 INTEGER :: ii, ij, ik, ikmax ! local integers 2312 REAL(wp) :: zc 2313 REAL(wp) :: zN2_c ! local buoyancy difference from 10m value 2314 REAL(wp), DIMENSION(jpi,jpj) :: ztm, zsm, zLf_NH, zLf_MH 2315 REAL(wp), DIMENSION(jpi,jpj,jpts):: ztsm_midu, ztsm_midv, zabu, zabv 2316 REAL(wp), DIMENSION(jpi,jpj) :: zmld_midu, zmld_midv 2317 !!---------------------------------------------------------------------- 2318 ! 2319 ! !== MLD used for MLE ==! 2320 2321 mld_prof(:,:) = nlb10 ! Initialization to the number of w ocean point 2322 zmld(:,:) = 0._wp ! here hmlp used as a dummy variable, integrating vertically N^2 2323 zN2_c = grav * rn_osm_mle_rho_c * r1_rho0 ! convert density criteria into N^2 criteria 2324 DO_3D( 1, 1, 1, 1, nlb10, jpkm1 ) 2702 !! 2703 !!---------------------------------------------------------------------- 2704 INTEGER, INTENT(in ) :: Kmm ! Time-level index 2705 REAL(wp), DIMENSION(A2D(nn_hls)), INTENT( out) :: pmld ! == Estimated FK BLD used for MLE horizontal gradients == ! 2706 REAL(wp), DIMENSION(A2D(nn_hls)), INTENT(inout) :: pdtdx ! Horizontal gradient for Fox-Kemper parametrization 2707 REAL(wp), DIMENSION(A2D(nn_hls)), INTENT(inout) :: pdtdy ! Horizontal gradient for Fox-Kemper parametrization 2708 REAL(wp), DIMENSION(A2D(nn_hls)), INTENT(inout) :: pdsdx ! Horizontal gradient for Fox-Kemper parametrization 2709 REAL(wp), DIMENSION(A2D(nn_hls)), INTENT(inout) :: pdsdy ! Horizontal gradient for Fox-Kemper parametrization 2710 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: pdbds_mle ! Magnitude of horizontal buoyancy gradient 2711 !! 2712 INTEGER :: ji, jj, jk ! Dummy loop indices 2713 INTEGER, DIMENSION(A2D(nn_hls)) :: jk_mld_prof ! Base level of MLE layer 2714 INTEGER :: ikt, ikmax ! Local integers 2715 REAL(wp) :: zc 2716 REAL(wp) :: zN2_c ! Local buoyancy difference from 10m value 2717 REAL(wp), DIMENSION(A2D(nn_hls)) :: ztm 2718 REAL(wp), DIMENSION(A2D(nn_hls)) :: zsm 2719 REAL(wp), DIMENSION(A2D(nn_hls),jpts) :: ztsm_midu 2720 REAL(wp), DIMENSION(A2D(nn_hls),jpts) :: ztsm_midv 2721 REAL(wp), DIMENSION(A2D(nn_hls),jpts) :: zabu 2722 REAL(wp), DIMENSION(A2D(nn_hls),jpts) :: zabv 2723 REAL(wp), DIMENSION(A2D(nn_hls)) :: zmld_midu 2724 REAL(wp), DIMENSION(A2D(nn_hls)) :: zmld_midv 2725 !!---------------------------------------------------------------------- 2726 ! 2727 ! == MLD used for MLE ==! 2728 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 2729 jk_mld_prof(ji,jj) = nlb10 ! Initialization to the number of w ocean point 2730 pmld(ji,jj) = 0.0_wp ! Here hmlp used as a dummy variable, integrating vertically N^2 2731 END_2D 2732 zN2_c = grav * rn_osm_mle_rho_c * r1_rho0 ! Convert density criteria into N^2 criteria 2733 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, nlb10, jpkm1 ) 2325 2734 ikt = mbkt(ji,jj) 2326 zmld(ji,jj) = zmld(ji,jj) + MAX( rn2b(ji,jj,jk) , 0._wp ) * e3w(ji,jj,jk,Kmm)2327 IF( zmld(ji,jj) < zN2_c )mld_prof(ji,jj) = MIN( jk , ikt ) + 1 ! Mixed layer level2735 pmld(ji,jj) = pmld(ji,jj) + MAX( rn2b(ji,jj,jk), 0.0_wp ) * e3w(ji,jj,jk,Kmm) 2736 IF( pmld(ji,jj) < zN2_c ) jk_mld_prof(ji,jj) = MIN( jk , ikt ) + 1 ! Mixed layer level 2328 2737 END_3D 2329 DO_2D( 1, 1, 1, 1 ) 2330 mld_prof(ji,jj) = MAX(mld_prof(ji,jj),ibld(ji,jj)) 2331 zmld(ji,jj) = gdepw(ji,jj,mld_prof(ji,jj),Kmm) 2332 END_2D 2333 ! ensure mld_prof .ge. ibld 2334 ! 2335 ikmax = MIN( MAXVAL( mld_prof(:,:) ), jpkm1 ) ! max level of the computation 2336 ! 2337 ztm(:,:) = 0._wp 2338 zsm(:,:) = 0._wp 2339 DO_3D( 1, 1, 1, 1, 1, ikmax ) 2340 zc = e3t(ji,jj,jk,Kmm) * REAL( MIN( MAX( 0, mld_prof(ji,jj)-jk ) , 1 ) ) ! zc being 0 outside the ML t-points 2738 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 2739 jk_mld_prof(ji,jj) = MAX( jk_mld_prof(ji,jj), nbld(ji,jj) ) ! Ensure jk_mld_prof .ge. nbld 2740 pmld(ji,jj) = gdepw(ji,jj,jk_mld_prof(ji,jj),Kmm) 2741 END_2D 2742 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2743 mld_prof(ji,jj) = jk_mld_prof(ji,jj) 2744 END_2D 2745 ! 2746 ikmax = MIN( MAXVAL( jk_mld_prof(A2D(nn_hls)) ), jpkm1 ) ! Max level of the computation 2747 ztm(:,:) = 0.0_wp 2748 zsm(:,:) = 0.0_wp 2749 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, ikmax ) 2750 zc = e3t(ji,jj,jk,Kmm) * REAL( MIN( MAX( 0, jk_mld_prof(ji,jj) - jk ), 1 ), KIND=wp ) ! zc being 0 outside the ML 2751 ! ! t-points 2341 2752 ztm(ji,jj) = ztm(ji,jj) + zc * ts(ji,jj,jk,jp_tem,Kmm) 2342 2753 zsm(ji,jj) = zsm(ji,jj) + zc * ts(ji,jj,jk,jp_sal,Kmm) 2343 2754 END_3D 2344 ! average temperature and salinity. 2345 ztm(:,:) = ztm(:,:) / MAX( e3t(:,:,1,Kmm), zmld(:,:) ) 2346 zsm(:,:) = zsm(:,:) / MAX( e3t(:,:,1,Kmm), zmld(:,:) ) 2347 ! calculate horizontal gradients at u & v points 2348 2349 DO_2D( 1, 0, 0, 0 ) 2350 zdtdx(ji,jj) = ( ztm(ji+1,jj) - ztm( ji,jj) ) * umask(ji,jj,1) / e1u(ji,jj) 2351 zdsdx(ji,jj) = ( zsm(ji+1,jj) - zsm( ji,jj) ) * umask(ji,jj,1) / e1u(ji,jj) 2352 zmld_midu(ji,jj) = 0.25_wp * (zmld(ji+1,jj) + zmld( ji,jj)) 2353 ztsm_midu(ji,jj,jp_tem) = 0.5_wp * ( ztm(ji+1,jj) + ztm( ji,jj) ) 2354 ztsm_midu(ji,jj,jp_sal) = 0.5_wp * ( zsm(ji+1,jj) + zsm( ji,jj) ) 2355 END_2D 2356 2357 DO_2D( 0, 0, 1, 0 ) 2358 zdtdy(ji,jj) = ( ztm(ji,jj+1) - ztm( ji,jj) ) * vmask(ji,jj,1) / e1v(ji,jj) 2359 zdsdy(ji,jj) = ( zsm(ji,jj+1) - zsm( ji,jj) ) * vmask(ji,jj,1) / e1v(ji,jj) 2360 zmld_midv(ji,jj) = 0.25_wp * (zmld(ji,jj+1) + zmld( ji,jj)) 2361 ztsm_midv(ji,jj,jp_tem) = 0.5_wp * ( ztm(ji,jj+1) + ztm( ji,jj) ) 2362 ztsm_midv(ji,jj,jp_sal) = 0.5_wp * ( zsm(ji,jj+1) + zsm( ji,jj) ) 2363 END_2D 2364 2365 CALL eos_rab(ztsm_midu, zmld_midu, zabu, Kmm) 2366 CALL eos_rab(ztsm_midv, zmld_midv, zabv, Kmm) 2367 2368 DO_2D( 1, 0, 0, 0 ) 2369 dbdx_mle(ji,jj) = grav*(zdtdx(ji,jj)*zabu(ji,jj,jp_tem) - zdsdx(ji,jj)*zabu(ji,jj,jp_sal)) 2370 END_2D 2371 DO_2D( 0, 0, 1, 0 ) 2372 dbdy_mle(ji,jj) = grav*(zdtdy(ji,jj)*zabv(ji,jj,jp_tem) - zdsdy(ji,jj)*zabv(ji,jj,jp_sal)) 2373 END_2D 2374 2375 DO_2D( 0, 0, 0, 0 ) 2376 ztmp = r1_ft(ji,jj) * MIN( 111.e3_wp , e1u(ji,jj) ) / rn_osm_mle_lf 2377 zdbds_mle(ji,jj) = SQRT( 0.5_wp * ( dbdx_mle(ji,jj) * dbdx_mle(ji,jj) + dbdy_mle(ji,jj) * dbdy_mle(ji,jj) & 2378 & + dbdx_mle(ji-1,jj) * dbdx_mle(ji-1,jj) + dbdy_mle(ji,jj-1) * dbdy_mle(ji,jj-1) ) ) 2379 END_2D 2380 2381 END SUBROUTINE zdf_osm_zmld_horizontal_gradients 2382 SUBROUTINE zdf_osm_mle_parameters( mld_prof, hmle, zhmle, zvel_mle, zdiff_mle ) 2383 !!---------------------------------------------------------------------- 2384 !! *** ROUTINE zdf_osm_mle_parameters *** 2385 !! 2386 !! ** Purpose : Timesteps the mixed layer eddy depth, hmle and calculates the mixed layer eddy fluxes for buoyancy, heat and salinity. 2755 ! Average temperature and salinity 2756 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 2757 ztm(ji,jj) = ztm(ji,jj) / MAX( e3t(ji,jj,1,Kmm), pmld(ji,jj) ) 2758 zsm(ji,jj) = zsm(ji,jj) / MAX( e3t(ji,jj,1,Kmm), pmld(ji,jj) ) 2759 END_2D 2760 ! Calculate horizontal gradients at u & v points 2761 zmld_midu(:,:) = 0.0_wp 2762 ztsm_midu(:,:,:) = 10.0_wp 2763 DO_2D( nn_hls, nn_hls-1, nn_hls-1, nn_hls-1 ) 2764 pdtdx(ji,jj) = ( ztm(ji+1,jj) - ztm(ji,jj) ) * umask(ji,jj,1) / e1u(ji,jj) 2765 pdsdx(ji,jj) = ( zsm(ji+1,jj) - zsm(ji,jj) ) * umask(ji,jj,1) / e1u(ji,jj) 2766 zmld_midu(ji,jj) = 0.25_wp * ( pmld(ji+1,jj) + pmld(ji,jj)) 2767 ztsm_midu(ji,jj,jp_tem) = 0.5_wp * ( ztm( ji+1,jj) + ztm( ji,jj) ) 2768 ztsm_midu(ji,jj,jp_sal) = 0.5_wp * ( zsm( ji+1,jj) + zsm( ji,jj) ) 2769 END_2D 2770 zmld_midv(:,:) = 0.0_wp 2771 ztsm_midv(:,:,:) = 10.0_wp 2772 DO_2D( nn_hls-1, nn_hls-1, nn_hls, nn_hls-1 ) 2773 pdtdy(ji,jj) = ( ztm(ji,jj+1) - ztm(ji,jj) ) * vmask(ji,jj,1) / e1v(ji,jj) 2774 pdsdy(ji,jj) = ( zsm(ji,jj+1) - zsm(ji,jj) ) * vmask(ji,jj,1) / e1v(ji,jj) 2775 zmld_midv(ji,jj) = 0.25_wp * ( pmld(ji,jj+1) + pmld( ji,jj) ) 2776 ztsm_midv(ji,jj,jp_tem) = 0.5_wp * ( ztm( ji,jj+1) + ztm( ji,jj) ) 2777 ztsm_midv(ji,jj,jp_sal) = 0.5_wp * ( zsm( ji,jj+1) + zsm( ji,jj) ) 2778 END_2D 2779 CALL eos_rab( ztsm_midu, zmld_midu, zabu, Kmm ) 2780 CALL eos_rab( ztsm_midv, zmld_midv, zabv, Kmm ) 2781 DO_2D_OVR( nn_hls, nn_hls-1, nn_hls-1, nn_hls-1 ) 2782 dbdx_mle(ji,jj) = grav * ( pdtdx(ji,jj) * zabu(ji,jj,jp_tem) - pdsdx(ji,jj) * zabu(ji,jj,jp_sal) ) 2783 END_2D 2784 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls, nn_hls-1 ) 2785 dbdy_mle(ji,jj) = grav * ( pdtdy(ji,jj) * zabv(ji,jj,jp_tem) - pdsdy(ji,jj) * zabv(ji,jj,jp_sal) ) 2786 END_2D 2787 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2788 pdbds_mle(ji,jj) = SQRT( 0.5_wp * ( dbdx_mle(ji, jj) * dbdx_mle(ji, jj) + dbdy_mle(ji,jj ) * dbdy_mle(ji,jj ) + & 2789 & dbdx_mle(ji-1,jj) * dbdx_mle(ji-1,jj) + dbdy_mle(ji,jj-1) * dbdy_mle(ji,jj-1) ) ) 2790 END_2D 2791 ! 2792 END SUBROUTINE zdf_osm_zmld_horizontal_gradients 2793 2794 SUBROUTINE zdf_osm_osbl_state_fk( Kmm, pwb_fk, phbl, phmle, pwb_ent, & 2795 & pdbds_mle ) 2796 !!--------------------------------------------------------------------- 2797 !! *** ROUTINE zdf_osm_osbl_state_fk *** 2798 !! 2799 !! ** Purpose : Determines the state of the OSBL and MLE layer. Info is 2800 !! returned in the logicals l_pyc, l_flux and ldmle. Used 2801 !! with Fox-Kemper scheme. 2802 !! l_pyc :: determines whether pycnocline flux-grad 2803 !! relationship needs to be determined 2804 !! l_flux :: determines whether effects of surface flux 2805 !! extend below the base of the OSBL 2806 !! ldmle :: determines whether the layer with MLE is 2807 !! increasing with time or if base is relaxing 2808 !! towards hbl 2809 !! 2810 !! ** Method : 2811 !! 2812 !!---------------------------------------------------------------------- 2813 INTEGER, INTENT(in ) :: Kmm ! Time-level index 2814 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: pwb_fk 2815 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 2816 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phmle ! MLE depth 2817 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb_ent ! Buoyancy entrainment flux 2818 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdbds_mle ! Magnitude of horizontal buoyancy gradient 2819 !! 2820 INTEGER :: ji, jj, jk ! Dummy loop indices 2821 REAL(wp), DIMENSION(A2D(nn_hls-1)) :: znd_param 2822 REAL(wp) :: zthermal, zbeta 2823 REAL(wp) :: zbuoy 2824 REAL(wp) :: ztmp 2825 REAL(wp) :: zpe_mle_layer 2826 REAL(wp) :: zpe_mle_ref 2827 REAL(wp) :: zdbdz_mle_int 2828 !!---------------------------------------------------------------------- 2829 ! 2830 znd_param(:,:) = 0.0_wp 2831 ! 2832 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2833 ztmp = r1_ft(ji,jj) * MIN( 111.e3_wp , e1u(ji,jj) ) / rn_osm_mle_lf 2834 pwb_fk(ji,jj) = rn_osm_mle_ce * hmle(ji,jj) * hmle(ji,jj) * ztmp * pdbds_mle(ji,jj) * pdbds_mle(ji,jj) 2835 END_2D 2836 ! 2837 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2838 ! 2839 IF ( l_conv(ji,jj) ) THEN 2840 IF ( phmle(ji,jj) > 1.2_wp * phbl(ji,jj) ) THEN 2841 av_t_mle(ji,jj) = ( av_t_mle(ji,jj) * phmle(ji,jj) - av_t_bl(ji,jj) * phbl(ji,jj) ) / ( phmle(ji,jj) - phbl(ji,jj) ) 2842 av_s_mle(ji,jj) = ( av_s_mle(ji,jj) * phmle(ji,jj) - av_s_bl(ji,jj) * phbl(ji,jj) ) / ( phmle(ji,jj) - phbl(ji,jj) ) 2843 av_b_mle(ji,jj) = ( av_b_mle(ji,jj) * phmle(ji,jj) - av_b_bl(ji,jj) * phbl(ji,jj) ) / ( phmle(ji,jj) - phbl(ji,jj) ) 2844 zdbdz_mle_int = ( av_b_bl(ji,jj) - ( 2.0_wp * av_b_mle(ji,jj) - av_b_bl(ji,jj) ) ) / ( phmle(ji,jj) - phbl(ji,jj) ) 2845 ! Calculate potential energies of actual profile and reference profile 2846 zpe_mle_layer = 0.0_wp 2847 zpe_mle_ref = 0.0_wp 2848 zthermal = rab_n(ji,jj,1,jp_tem) 2849 zbeta = rab_n(ji,jj,1,jp_sal) 2850 DO jk = nbld(ji,jj), mld_prof(ji,jj) 2851 zbuoy = grav * ( zthermal * ts(ji,jj,jk,jp_tem,Kmm) - zbeta * ts(ji,jj,jk,jp_sal,Kmm) ) 2852 zpe_mle_layer = zpe_mle_layer + zbuoy * gdepw(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 2853 zpe_mle_ref = zpe_mle_ref + ( av_b_bl(ji,jj) - zdbdz_mle_int * ( gdepw(ji,jj,jk,Kmm) - phbl(ji,jj) ) ) * & 2854 & gdepw(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 2855 END DO 2856 ! Non-dimensional parameter to diagnose the presence of thermocline 2857 znd_param(ji,jj) = ( zpe_mle_layer - zpe_mle_ref ) * ABS( ff_t(ji,jj) ) / & 2858 & ( MAX( pwb_fk(ji,jj), 1e-10 ) * phmle(ji,jj) ) 2859 END IF 2860 END IF 2861 ! 2862 END_2D 2863 ! 2864 ! Diagnosis 2865 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2866 ! 2867 IF ( l_conv(ji,jj) ) THEN 2868 IF ( -2.0_wp * pwb_fk(ji,jj) / pwb_ent(ji,jj) > 0.5_wp ) THEN 2869 IF ( phmle(ji,jj) > 1.2_wp * phbl(ji,jj) ) THEN ! MLE layer growing 2870 IF ( znd_param (ji,jj) > 100.0_wp ) THEN ! Thermocline present 2871 l_flux(ji,jj) = .FALSE. 2872 l_mle(ji,jj) = .FALSE. 2873 ELSE ! Thermocline not present 2874 l_flux(ji,jj) = .TRUE. 2875 l_mle(ji,jj) = .TRUE. 2876 ENDIF ! znd_param > 100 2877 ! 2878 IF ( av_db_bl(ji,jj) < rn_osm_bl_thresh ) THEN 2879 l_pyc(ji,jj) = .FALSE. 2880 ELSE 2881 l_pyc(ji,jj) = .TRUE. 2882 ENDIF 2883 ELSE ! MLE layer restricted to OSBL or just below 2884 IF ( av_db_bl(ji,jj) < rn_osm_bl_thresh ) THEN ! Weak stratification MLE layer can grow 2885 l_pyc(ji,jj) = .FALSE. 2886 l_flux(ji,jj) = .TRUE. 2887 l_mle(ji,jj) = .TRUE. 2888 ELSE ! Strong stratification 2889 l_pyc(ji,jj) = .TRUE. 2890 l_flux(ji,jj) = .FALSE. 2891 l_mle(ji,jj) = .FALSE. 2892 END IF ! av_db_bl < rn_mle_thresh_bl and 2893 END IF ! phmle > 1.2 phbl 2894 ELSE 2895 l_pyc(ji,jj) = .TRUE. 2896 l_flux(ji,jj) = .FALSE. 2897 l_mle(ji,jj) = .FALSE. 2898 IF ( av_db_bl(ji,jj) < rn_osm_bl_thresh ) l_pyc(ji,jj) = .FALSE. 2899 END IF ! -2.0 * pwb_fk(ji,jj) / pwb_ent > 0.5 2900 ELSE ! Stable Boundary Layer 2901 l_pyc(ji,jj) = .FALSE. 2902 l_flux(ji,jj) = .FALSE. 2903 l_mle(ji,jj) = .FALSE. 2904 END IF ! l_conv 2905 ! 2906 END_2D 2907 ! 2908 END SUBROUTINE zdf_osm_osbl_state_fk 2909 2910 SUBROUTINE zdf_osm_mle_parameters( Kmm, pmld, phmle, pvel_mle, pdiff_mle, & 2911 & pdbds_mle, phbl, pwb0tot ) 2912 !!---------------------------------------------------------------------- 2913 !! *** ROUTINE zdf_osm_mle_parameters *** 2914 !! 2915 !! ** Purpose : Timesteps the mixed layer eddy depth, hmle and calculates 2916 !! the mixed layer eddy fluxes for buoyancy, heat and 2917 !! salinity. 2387 2918 !! 2388 2919 !! ** Method : … … 2390 2921 !! References: Fox-Kemper et al., JPO, 38, 1145-1165, 2008 2391 2922 !! Fox-Kemper and Ferrari, JPO, 38, 1166-1179, 2008 2392 2393 INTEGER, DIMENSION(jpi,jpj) :: mld_prof 2394 REAL(wp), DIMENSION(jpi,jpj) :: hmle, zhmle, zwb_fk, zvel_mle, zdiff_mle 2395 INTEGER :: ji, jj, jk ! dummy loop indices 2396 INTEGER :: ii, ij, ik, jkb, jkb1 ! local integers 2397 INTEGER , DIMENSION(jpi,jpj) :: inml_mle 2398 REAL(wp) :: ztmp, zdbdz, zdtdz, zdsdz, zthermal,zbeta, zbuoy, zdb_mle 2399 2400 ! Calculate vertical buoyancy, heat and salinity fluxes due to MLE. 2401 2402 DO_2D( 0, 0, 0, 0 ) 2403 IF ( lconv(ji,jj) ) THEN 2404 ztmp = r1_ft(ji,jj) * MIN( 111.e3_wp , e1u(ji,jj) ) / rn_osm_mle_lf 2405 ! This velocity scale, defined in Fox-Kemper et al (2008), is needed for calculating dhdt. 2406 zvel_mle(ji,jj) = zdbds_mle(ji,jj) * ztmp * hmle(ji,jj) * tmask(ji,jj,1) 2407 zdiff_mle(ji,jj) = 5.e-4_wp * rn_osm_mle_ce * ztmp * zdbds_mle(ji,jj) * zhmle(ji,jj)**2 2408 ENDIF 2409 END_2D 2410 ! Timestep mixed layer eddy depth. 2411 DO_2D( 0, 0, 0, 0 ) 2412 IF ( lmle(ji,jj) ) THEN ! MLE layer growing. 2413 ! Buoyancy gradient at base of MLE layer. 2414 zthermal = rab_n(ji,jj,1,jp_tem) 2415 zbeta = rab_n(ji,jj,1,jp_sal) 2416 jkb = mld_prof(ji,jj) 2417 jkb1 = MIN(jkb + 1, mbkt(ji,jj)) 2418 ! 2419 zbuoy = grav * ( zthermal * ts(ji,jj,mld_prof(ji,jj)+2,jp_tem,Kmm) - zbeta * ts(ji,jj,mld_prof(ji,jj)+2,jp_sal,Kmm) ) 2420 zdb_mle = zb_bl(ji,jj) - zbuoy 2421 ! Timestep hmle. 2422 hmle(ji,jj) = hmle(ji,jj) + zwb0(ji,jj) * rn_Dt / zdb_mle 2423 ELSE 2424 IF ( zhmle(ji,jj) > zhbl(ji,jj) ) THEN 2425 hmle(ji,jj) = hmle(ji,jj) - ( hmle(ji,jj) - hbl(ji,jj) ) * rn_Dt / rn_osm_mle_tau 2426 ELSE 2427 hmle(ji,jj) = hmle(ji,jj) - 10.0 * ( hmle(ji,jj) - hbl(ji,jj) ) * rn_Dt /rn_osm_mle_tau 2428 ENDIF 2429 ENDIF 2430 hmle(ji,jj) = MIN(hmle(ji,jj), ht(ji,jj)) 2431 IF(ln_osm_hmle_limit) hmle(ji,jj) = MIN(hmle(ji,jj), MAX(rn_osm_hmle_limit,1.2*hbl(ji,jj)) ) 2432 END_2D 2433 2434 mld_prof = 4 2435 DO_3D( 0, 0, 0, 0, 5, jpkm1 ) 2436 IF ( hmle(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) mld_prof(ji,jj) = MIN(mbkt(ji,jj), jk) 2923 !! 2924 !!---------------------------------------------------------------------- 2925 INTEGER, INTENT(in ) :: Kmm ! Time-level index 2926 REAL(wp), DIMENSION(A2D(nn_hls)), INTENT(in ) :: pmld ! == Estimated FK BLD used for MLE horiz gradients == ! 2927 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: phmle ! MLE depth 2928 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: pvel_mle ! Velocity scale for dhdt with stable ML and FK 2929 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(inout) :: pdiff_mle ! Extra MLE vertical diff 2930 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pdbds_mle ! Magnitude of horizontal buoyancy gradient 2931 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: phbl ! BL depth 2932 REAL(wp), DIMENSION(A2D(nn_hls-1)), INTENT(in ) :: pwb0tot ! Total surface buoyancy flux including insolation 2933 !! 2934 INTEGER :: ji, jj, jk ! Dummy loop indices 2935 REAL(wp) :: ztmp 2936 REAL(wp) :: zdbdz 2937 REAL(wp) :: zdtdz 2938 REAL(wp) :: zdsdz 2939 REAL(wp) :: zthermal 2940 REAL(wp) :: zbeta 2941 REAL(wp) :: zbuoy 2942 REAL(wp) :: zdb_mle 2943 !!---------------------------------------------------------------------- 2944 ! 2945 ! Calculate vertical buoyancy, heat and salinity fluxes due to MLE 2946 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2947 IF ( l_conv(ji,jj) ) THEN 2948 ztmp = r1_ft(ji,jj) * MIN( 111e3_wp, e1u(ji,jj) ) / rn_osm_mle_lf 2949 ! This velocity scale, defined in Fox-Kemper et al (2008), is needed for calculating dhdt 2950 pvel_mle(ji,jj) = pdbds_mle(ji,jj) * ztmp * hmle(ji,jj) * tmask(ji,jj,1) 2951 pdiff_mle(ji,jj) = 5e-4_wp * rn_osm_mle_ce * ztmp * pdbds_mle(ji,jj) * phmle(ji,jj)**2 2952 END IF 2953 END_2D 2954 ! Timestep mixed layer eddy depth 2955 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2956 IF ( l_mle(ji,jj) ) THEN ! MLE layer growing 2957 ! Buoyancy gradient at base of MLE layer 2958 zthermal = rab_n(ji,jj,1,jp_tem) 2959 zbeta = rab_n(ji,jj,1,jp_sal) 2960 zbuoy = grav * ( zthermal * ts(ji,jj,mld_prof(ji,jj)+2,jp_tem,Kmm) - & 2961 & zbeta * ts(ji,jj,mld_prof(ji,jj)+2,jp_sal,Kmm) ) 2962 zdb_mle = av_b_bl(ji,jj) - zbuoy 2963 ! Timestep hmle 2964 hmle(ji,jj) = hmle(ji,jj) + pwb0tot(ji,jj) * rn_Dt / zdb_mle 2965 ELSE 2966 IF ( phmle(ji,jj) > phbl(ji,jj) ) THEN 2967 hmle(ji,jj) = hmle(ji,jj) - ( hmle(ji,jj) - hbl(ji,jj) ) * rn_Dt / rn_osm_mle_tau 2968 ELSE 2969 hmle(ji,jj) = hmle(ji,jj) - 10.0_wp * ( hmle(ji,jj) - hbl(ji,jj) ) * rn_Dt / rn_osm_mle_tau 2970 END IF 2971 END IF 2972 hmle(ji,jj) = MAX( MIN( hmle(ji,jj), ht(ji,jj) ), gdepw(ji,jj,4,Kmm) ) 2973 IF ( ln_osm_hmle_limit ) hmle(ji,jj) = MIN( hmle(ji,jj), rn_osm_hmle_limit*hbl(ji,jj) ) 2974 hmle(ji,jj) = pmld(ji,jj) ! For now try just set hmle to pmld 2975 END_2D 2976 ! 2977 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 5, jpkm1 ) 2978 IF ( hmle(ji,jj) >= gdepw(ji,jj,jk,Kmm) ) mld_prof(ji,jj) = MIN( mbkt(ji,jj), jk ) 2437 2979 END_3D 2438 DO_2D( 0, 0, 0, 0 ) 2439 zhmle(ji,jj) = gdepw(ji,jj, mld_prof(ji,jj),Kmm) 2440 END_2D 2441 END SUBROUTINE zdf_osm_mle_parameters 2442 2443 END SUBROUTINE zdf_osm 2444 2980 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 2981 phmle(ji,jj) = gdepw(ji,jj,mld_prof(ji,jj),Kmm) 2982 END_2D 2983 ! 2984 END SUBROUTINE zdf_osm_mle_parameters 2445 2985 2446 2986 SUBROUTINE zdf_osm_init( Kmm ) 2447 !!---------------------------------------------------------------------- 2448 !! *** ROUTINE zdf_osm_init *** 2449 !! 2450 !! ** Purpose : Initialization of the vertical eddy diffivity and 2451 !! viscosity when using a osm turbulent closure scheme 2452 !! 2453 !! ** Method : Read the namosm namelist and check the parameters 2454 !! called at the first timestep (nit000) 2455 !! 2456 !! ** input : Namlist namosm 2457 !!---------------------------------------------------------------------- 2458 INTEGER, INTENT(in) :: Kmm ! time level 2459 INTEGER :: ios ! local integer 2460 INTEGER :: ji, jj, jk ! dummy loop indices 2461 REAL z1_t2 2462 !! 2463 NAMELIST/namzdf_osm/ ln_use_osm_la, rn_osm_la, rn_osm_dstokes, nn_ave & 2464 & ,nn_osm_wave, ln_dia_osm, rn_osm_hbl0, rn_zdfosm_adjust_sd & 2465 & ,ln_kpprimix, rn_riinfty, rn_difri, ln_convmix, rn_difconv, nn_osm_wave & 2466 & ,nn_osm_SD_reduce, ln_osm_mle, rn_osm_hblfrac, rn_osm_bl_thresh, ln_zdfosm_ice_shelter 2467 ! Namelist for Fox-Kemper parametrization. 2468 NAMELIST/namosm_mle/ nn_osm_mle, rn_osm_mle_ce, rn_osm_mle_lf, rn_osm_mle_time, rn_osm_mle_lat,& 2469 & rn_osm_mle_rho_c, rn_osm_mle_thresh, rn_osm_mle_tau, ln_osm_hmle_limit, rn_osm_hmle_limit 2470 2471 !!---------------------------------------------------------------------- 2472 ! 2473 READ ( numnam_ref, namzdf_osm, IOSTAT = ios, ERR = 901) 2474 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_osm in reference namelist' ) 2475 2476 READ ( numnam_cfg, namzdf_osm, IOSTAT = ios, ERR = 902 ) 2477 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namzdf_osm in configuration namelist' ) 2478 IF(lwm) WRITE ( numond, namzdf_osm ) 2479 2480 IF(lwp) THEN ! Control print 2481 WRITE(numout,*) 2482 WRITE(numout,*) 'zdf_osm_init : OSMOSIS Parameterisation' 2483 WRITE(numout,*) '~~~~~~~~~~~~' 2484 WRITE(numout,*) ' Namelist namzdf_osm : set osm mixing parameters' 2485 WRITE(numout,*) ' Use rn_osm_la ln_use_osm_la = ', ln_use_osm_la 2486 WRITE(numout,*) ' Use MLE in OBL, i.e. Fox-Kemper param ln_osm_mle = ', ln_osm_mle 2487 WRITE(numout,*) ' Turbulent Langmuir number rn_osm_la = ', rn_osm_la 2488 WRITE(numout,*) ' Stokes drift reduction factor rn_zdfosm_adjust_sd = ', rn_zdfosm_adjust_sd 2489 WRITE(numout,*) ' Initial hbl for 1D runs rn_osm_hbl0 = ', rn_osm_hbl0 2490 WRITE(numout,*) ' Depth scale of Stokes drift rn_osm_dstokes = ', rn_osm_dstokes 2491 WRITE(numout,*) ' horizontal average flag nn_ave = ', nn_ave 2492 WRITE(numout,*) ' Stokes drift nn_osm_wave = ', nn_osm_wave 2493 SELECT CASE (nn_osm_wave) 2494 CASE(0) 2495 WRITE(numout,*) ' calculated assuming constant La#=0.3' 2496 CASE(1) 2497 WRITE(numout,*) ' calculated from Pierson Moskowitz wind-waves' 2498 CASE(2) 2499 WRITE(numout,*) ' calculated from ECMWF wave fields' 2987 !!---------------------------------------------------------------------- 2988 !! *** ROUTINE zdf_osm_init *** 2989 !! 2990 !! ** Purpose : Initialization of the vertical eddy diffivity and 2991 !! viscosity when using a osm turbulent closure scheme 2992 !! 2993 !! ** Method : Read the namosm namelist and check the parameters 2994 !! called at the first timestep (nit000) 2995 !! 2996 !! ** input : Namlists namzdf_osm and namosm_mle 2997 !! 2998 !!---------------------------------------------------------------------- 2999 INTEGER, INTENT(in ) :: Kmm ! Time level 3000 !! 3001 INTEGER :: ios ! Local integer 3002 INTEGER :: ji, jj, jk ! Dummy loop indices 3003 REAL(wp) :: z1_t2 3004 !! 3005 REAL(wp), PARAMETER :: pp_large = -1e10_wp 3006 !! 3007 NAMELIST/namzdf_osm/ ln_use_osm_la, rn_osm_la, rn_osm_dstokes, nn_ave, nn_osm_wave, & 3008 & ln_dia_osm, rn_osm_hbl0, rn_zdfosm_adjust_sd, ln_kpprimix, rn_riinfty, & 3009 & rn_difri, ln_convmix, rn_difconv, nn_osm_wave, nn_osm_SD_reduce, & 3010 & ln_osm_mle, rn_osm_hblfrac, rn_osm_bl_thresh, ln_zdfosm_ice_shelter 3011 !! Namelist for Fox-Kemper parametrization 3012 NAMELIST/namosm_mle/ nn_osm_mle, rn_osm_mle_ce, rn_osm_mle_lf, rn_osm_mle_time, rn_osm_mle_lat, & 3013 & rn_osm_mle_rho_c, rn_osm_mle_thresh, rn_osm_mle_tau, ln_osm_hmle_limit, rn_osm_hmle_limit 3014 !!---------------------------------------------------------------------- 3015 ! 3016 READ ( numnam_ref, namzdf_osm, IOSTAT = ios, ERR = 901) 3017 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_osm in reference namelist' ) 3018 3019 READ ( numnam_cfg, namzdf_osm, IOSTAT = ios, ERR = 902 ) 3020 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namzdf_osm in configuration namelist' ) 3021 IF(lwm) WRITE ( numond, namzdf_osm ) 3022 3023 IF(lwp) THEN ! Control print 3024 WRITE(numout,*) 3025 WRITE(numout,*) 'zdf_osm_init : OSMOSIS Parameterisation' 3026 WRITE(numout,*) '~~~~~~~~~~~~' 3027 WRITE(numout,*) ' Namelist namzdf_osm : set osm mixing parameters' 3028 WRITE(numout,*) ' Use rn_osm_la ln_use_osm_la = ', ln_use_osm_la 3029 WRITE(numout,*) ' Use MLE in OBL, i.e. Fox-Kemper param ln_osm_mle = ', ln_osm_mle 3030 WRITE(numout,*) ' Turbulent Langmuir number rn_osm_la = ', rn_osm_la 3031 WRITE(numout,*) ' Stokes drift reduction factor rn_zdfosm_adjust_sd = ', rn_zdfosm_adjust_sd 3032 WRITE(numout,*) ' Initial hbl for 1D runs rn_osm_hbl0 = ', rn_osm_hbl0 3033 WRITE(numout,*) ' Depth scale of Stokes drift rn_osm_dstokes = ', rn_osm_dstokes 3034 WRITE(numout,*) ' Horizontal average flag nn_ave = ', nn_ave 3035 WRITE(numout,*) ' Stokes drift nn_osm_wave = ', nn_osm_wave 3036 SELECT CASE (nn_osm_wave) 3037 CASE(0) 3038 WRITE(numout,*) ' Calculated assuming constant La#=0.3' 3039 CASE(1) 3040 WRITE(numout,*) ' Calculated from Pierson Moskowitz wind-waves' 3041 CASE(2) 3042 WRITE(numout,*) ' Calculated from ECMWF wave fields' 2500 3043 END SELECT 2501 WRITE(numout,*) ' Stokes drift reduction nn_osm_SD_reduce', nn_osm_SD_reduce 2502 WRITE(numout,*) ' fraction of hbl to average SD over/fit' 2503 WRITE(numout,*) ' exponential with nn_osm_SD_reduce = 1 or 2 rn_osm_hblfrac = ', rn_osm_hblfrac 2504 SELECT CASE (nn_osm_SD_reduce) 2505 CASE(0) 2506 WRITE(numout,*) ' No reduction' 2507 CASE(1) 2508 WRITE(numout,*) ' Average SD over upper rn_osm_hblfrac of BL' 2509 CASE(2) 2510 WRITE(numout,*) ' Fit exponential to slope rn_osm_hblfrac of BL' 2511 END SELECT 2512 WRITE(numout,*) ' reduce surface SD and depth scale under ice ln_zdfosm_ice_shelter=', ln_zdfosm_ice_shelter 2513 WRITE(numout,*) ' Output osm diagnostics ln_dia_osm = ', ln_dia_osm 2514 WRITE(numout,*) ' Threshold used to define BL rn_osm_bl_thresh = ', rn_osm_bl_thresh, 'm^2/s' 2515 WRITE(numout,*) ' Use KPP-style shear instability mixing ln_kpprimix = ', ln_kpprimix 2516 WRITE(numout,*) ' local Richardson Number limit for shear instability rn_riinfty = ', rn_riinfty 2517 WRITE(numout,*) ' maximum shear diffusivity at Rig = 0 (m2/s) rn_difri = ', rn_difri 2518 WRITE(numout,*) ' Use large mixing below BL when unstable ln_convmix = ', ln_convmix 2519 WRITE(numout,*) ' diffusivity when unstable below BL (m2/s) rn_difconv = ', rn_difconv 2520 ENDIF 2521 2522 2523 ! ! Check wave coupling settings ! 2524 ! ! Further work needed - see ticket #2447 ! 2525 IF( nn_osm_wave == 2 ) THEN 2526 IF (.NOT. ( ln_wave .AND. ln_sdw )) & 2527 & CALL ctl_stop( 'zdf_osm_init : ln_zdfosm and nn_osm_wave=2, ln_wave and ln_sdw must be true' ) 2528 END IF 2529 2530 ! ! allocate zdfosm arrays 2531 IF( zdf_osm_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'zdf_osm_init : unable to allocate arrays' ) 2532 2533 2534 IF( ln_osm_mle ) THEN 2535 ! Initialise Fox-Kemper parametrization 3044 WRITE(numout,*) ' Stokes drift reduction nn_osm_SD_reduce = ', nn_osm_SD_reduce 3045 WRITE(numout,*) ' Fraction of hbl to average SD over/fit' 3046 WRITE(numout,*) ' Exponential with nn_osm_SD_reduce = 1 or 2 rn_osm_hblfrac = ', rn_osm_hblfrac 3047 SELECT CASE (nn_osm_SD_reduce) 3048 CASE(0) 3049 WRITE(numout,*) ' No reduction' 3050 CASE(1) 3051 WRITE(numout,*) ' Average SD over upper rn_osm_hblfrac of BL' 3052 CASE(2) 3053 WRITE(numout,*) ' Fit exponential to slope rn_osm_hblfrac of BL' 3054 END SELECT 3055 WRITE(numout,*) ' Reduce surface SD and depth scale under ice ln_zdfosm_ice_shelter = ', ln_zdfosm_ice_shelter 3056 WRITE(numout,*) ' Output osm diagnostics ln_dia_osm = ', ln_dia_osm 3057 WRITE(numout,*) ' Threshold used to define BL rn_osm_bl_thresh = ', rn_osm_bl_thresh, & 3058 & 'm^2/s' 3059 WRITE(numout,*) ' Use KPP-style shear instability mixing ln_kpprimix = ', ln_kpprimix 3060 WRITE(numout,*) ' Local Richardson Number limit for shear instability rn_riinfty = ', rn_riinfty 3061 WRITE(numout,*) ' Maximum shear diffusivity at Rig = 0 (m2/s) rn_difri = ', rn_difri 3062 WRITE(numout,*) ' Use large mixing below BL when unstable ln_convmix = ', ln_convmix 3063 WRITE(numout,*) ' Diffusivity when unstable below BL (m2/s) rn_difconv = ', rn_difconv 3064 ENDIF 3065 ! 3066 ! ! Check wave coupling settings ! 3067 ! ! Further work needed - see ticket #2447 ! 3068 IF ( nn_osm_wave == 2 ) THEN 3069 IF (.NOT. ( ln_wave .AND. ln_sdw )) & 3070 & CALL ctl_stop( 'zdf_osm_init : ln_zdfosm and nn_osm_wave=2, ln_wave and ln_sdw must be true' ) 3071 END IF 3072 ! 3073 ! Flags associated with diagnostic output 3074 IF ( ln_dia_osm .AND. ( iom_use("zdudz_pyc") .OR. iom_use("zdvdz_pyc") ) ) ln_dia_pyc_shr = .TRUE. 3075 IF ( ln_dia_osm .AND. ( iom_use("zdtdz_pyc") .OR. iom_use("zdsdz_pyc") .OR. iom_use("zdbdz_pyc" ) ) ) ln_dia_pyc_scl = .TRUE. 3076 ! 3077 ! Allocate zdfosm arrays 3078 IF( zdf_osm_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'zdf_osm_init : unable to allocate arrays' ) 3079 ! 3080 IF( ln_osm_mle ) THEN ! Initialise Fox-Kemper parametrization 2536 3081 READ ( numnam_ref, namosm_mle, IOSTAT = ios, ERR = 903) 2537 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namosm_mle in reference namelist') 2538 3082 903 IF( ios /= 0 ) CALL ctl_nam( ios, 'namosm_mle in reference namelist' ) 2539 3083 READ ( numnam_cfg, namosm_mle, IOSTAT = ios, ERR = 904 ) 2540 904 IF( ios > 0 ) CALL ctl_nam ( ios , 'namosm_mle in configuration namelist')3084 904 IF( ios > 0 ) CALL ctl_nam( ios, 'namosm_mle in configuration namelist' ) 2541 3085 IF(lwm) WRITE ( numond, namosm_mle ) 2542 2543 IF(lwp) THEN 3086 ! 3087 IF(lwp) THEN ! Namelist print 2544 3088 WRITE(numout,*) 2545 3089 WRITE(numout,*) 'zdf_osm_init : initialise mixed layer eddy (MLE)' 2546 3090 WRITE(numout,*) '~~~~~~~~~~~~~' 2547 3091 WRITE(numout,*) ' Namelist namosm_mle : ' 2548 WRITE(numout,*) ' MLE type: =0 standard Fox-Kemper ; =1 new formulation nn_osm_mle = ', nn_osm_mle 2549 WRITE(numout,*) ' magnitude of the MLE (typical value: 0.06 to 0.08) rn_osm_mle_ce = ', rn_osm_mle_ce 2550 WRITE(numout,*) ' scale of ML front (ML radius of deformation) (nn_osm_mle=0) rn_osm_mle_lf = ', rn_osm_mle_lf, 'm' 2551 WRITE(numout,*) ' maximum time scale of MLE (nn_osm_mle=0) rn_osm_mle_time = ', rn_osm_mle_time, 's' 2552 WRITE(numout,*) ' reference latitude (degrees) of MLE coef. (nn_osm_mle=1) rn_osm_mle_lat = ', rn_osm_mle_lat, 'deg' 2553 WRITE(numout,*) ' Density difference used to define ML for FK rn_osm_mle_rho_c = ', rn_osm_mle_rho_c 2554 WRITE(numout,*) ' Threshold used to define MLE for FK rn_osm_mle_thresh = ', rn_osm_mle_thresh, 'm^2/s' 2555 WRITE(numout,*) ' Timescale for OSM-FK rn_osm_mle_tau = ', rn_osm_mle_tau, 's' 2556 WRITE(numout,*) ' switch to limit hmle ln_osm_hmle_limit = ', ln_osm_hmle_limit 2557 WRITE(numout,*) ' fraction of zmld to limit hmle to if ln_osm_hmle_limit =.T. rn_osm_hmle_limit = ', rn_osm_hmle_limit 2558 ENDIF ! 2559 ENDIF 3092 WRITE(numout,*) ' MLE type: =0 standard Fox-Kemper ; =1 new formulation nn_osm_mle = ', nn_osm_mle 3093 WRITE(numout,*) ' Magnitude of the MLE (typical value: 0.06 to 0.08) rn_osm_mle_ce = ', rn_osm_mle_ce 3094 WRITE(numout,*) ' Scale of ML front (ML radius of deform.) (nn_osm_mle=0) rn_osm_mle_lf = ', rn_osm_mle_lf, & 3095 & 'm' 3096 WRITE(numout,*) ' Maximum time scale of MLE (nn_osm_mle=0) rn_osm_mle_time = ', & 3097 & rn_osm_mle_time, 's' 3098 WRITE(numout,*) ' Reference latitude (deg) of MLE coef. (nn_osm_mle=1) rn_osm_mle_lat = ', rn_osm_mle_lat, & 3099 & 'deg' 3100 WRITE(numout,*) ' Density difference used to define ML for FK rn_osm_mle_rho_c = ', rn_osm_mle_rho_c 3101 WRITE(numout,*) ' Threshold used to define MLE for FK rn_osm_mle_thresh = ', & 3102 & rn_osm_mle_thresh, 'm^2/s' 3103 WRITE(numout,*) ' Timescale for OSM-FK rn_osm_mle_tau = ', rn_osm_mle_tau, 's' 3104 WRITE(numout,*) ' Switch to limit hmle ln_osm_hmle_limit = ', ln_osm_hmle_limit 3105 WRITE(numout,*) ' hmle limit (fraction of zmld) (ln_osm_hmle_limit = .T.) rn_osm_hmle_limit = ', rn_osm_hmle_limit 3106 END IF 3107 END IF 2560 3108 ! 2561 3109 IF(lwp) THEN 2562 3110 WRITE(numout,*) 2563 IF ( ln_osm_mle ) THEN3111 IF ( ln_osm_mle ) THEN 2564 3112 WRITE(numout,*) ' ==>>> Mixed Layer Eddy induced transport added to OSMOSIS BL calculation' 2565 3113 IF( nn_osm_mle == 0 ) WRITE(numout,*) ' Fox-Kemper et al 2010 formulation' … … 2567 3115 ELSE 2568 3116 WRITE(numout,*) ' ==>>> Mixed Layer induced transport NOT added to OSMOSIS BL calculation' 2569 END IF2570 END IF2571 ! 2572 IF( ln_osm_mle ) THEN 3117 END IF 3118 END IF 3119 ! 3120 IF( ln_osm_mle ) THEN ! MLE initialisation 2573 3121 ! 2574 rb_c = grav * rn_osm_mle_rho_c / rho0! Mixed Layer buoyancy criteria3122 rb_c = grav * rn_osm_mle_rho_c / rho0 ! Mixed Layer buoyancy criteria 2575 3123 IF(lwp) WRITE(numout,*) 2576 3124 IF(lwp) WRITE(numout,*) ' ML buoyancy criteria = ', rb_c, ' m/s2 ' 2577 3125 IF(lwp) WRITE(numout,*) ' associated ML density criteria defined in zdfmxl = ', rn_osm_mle_rho_c, 'kg/m3' 2578 3126 ! 2579 IF( nn_osm_mle == 0 ) THEN ! MLE array allocation & initialisation ! 2580 ! 2581 ELSEIF( nn_osm_mle == 1 ) THEN ! MLE array allocation & initialisation 2582 rc_f = rn_osm_mle_ce/ ( 5.e3_wp * 2._wp * omega * SIN( rad * rn_osm_mle_lat ) ) 2583 ! 2584 ENDIF 2585 ! ! 1/(f^2+tau^2)^1/2 at t-point (needed in both nn_osm_mle case) 2586 z1_t2 = 2.e-5 2587 DO_2D( 1, 1, 1, 1 ) 2588 r1_ft(ji,jj) = MIN(1./( ABS(ff_t(ji,jj)) + epsln ), ABS(ff_t(ji,jj))/z1_t2**2) 3127 IF( nn_osm_mle == 1 ) THEN 3128 rc_f = rn_osm_mle_ce / ( 5e3_wp * 2.0_wp * omega * SIN( rad * rn_osm_mle_lat ) ) 3129 END IF 3130 ! 1/(f^2+tau^2)^1/2 at t-point (needed in both nn_osm_mle case) 3131 z1_t2 = 2e-5_wp 3132 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 3133 r1_ft(ji,jj) = MIN( 1.0_wp / ( ABS( ff_t(ji,jj)) + epsln ), ABS( ff_t(ji,jj) ) / z1_t2**2 ) 2589 3134 END_2D 2590 3135 ! z1_t2 = 1._wp / ( rn_osm_mle_time * rn_osm_mle_timeji,jj ) 2591 3136 ! r1_ft(:,:) = 1._wp / SQRT( ff_t(:,:) * ff_t(:,:) + z1_t2 ) 2592 3137 ! 2593 ENDIF 2594 2595 call osm_rst( nit000, Kmm, 'READ' ) !* read or initialize hbl, dh, hmle 2596 2597 2598 IF( ln_zdfddm) THEN 2599 IF(lwp) THEN 2600 WRITE(numout,*) 2601 WRITE(numout,*) ' Double diffusion mixing on temperature and salinity ' 2602 WRITE(numout,*) ' CAUTION : done in routine zdfosm, not in routine zdfddm ' 2603 ENDIF 2604 ENDIF 2605 2606 2607 !set constants not in namelist 2608 !----------------------------- 2609 2610 IF(lwp) THEN 2611 WRITE(numout,*) 2612 ENDIF 2613 2614 IF (nn_osm_wave == 0) THEN 2615 dstokes(:,:) = rn_osm_dstokes 2616 END IF 2617 2618 ! Horizontal average : initialization of weighting arrays 2619 ! ------------------- 2620 2621 SELECT CASE ( nn_ave ) 2622 2623 CASE ( 0 ) ! no horizontal average 2624 IF(lwp) WRITE(numout,*) ' no horizontal average on avt' 2625 IF(lwp) WRITE(numout,*) ' only in very high horizontal resolution !' 2626 ! weighting mean arrays etmean 2627 ! ( 1 1 ) 2628 ! avt = 1/4 ( 1 1 ) 2629 ! 2630 etmean(:,:,:) = 0.e0 2631 2632 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 2633 etmean(ji,jj,jk) = tmask(ji,jj,jk) & 2634 & / MAX( 1., umask(ji-1,jj ,jk) + umask(ji,jj,jk) & 2635 & + vmask(ji ,jj-1,jk) + vmask(ji,jj,jk) ) 2636 END_3D 2637 2638 CASE ( 1 ) ! horizontal average 2639 IF(lwp) WRITE(numout,*) ' horizontal average on avt' 2640 ! weighting mean arrays etmean 2641 ! ( 1/2 1 1/2 ) 2642 ! avt = 1/8 ( 1 2 1 ) 2643 ! ( 1/2 1 1/2 ) 2644 etmean(:,:,:) = 0.e0 2645 2646 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 2647 etmean(ji,jj,jk) = tmask(ji, jj,jk) & 2648 & / MAX( 1., 2.* tmask(ji,jj,jk) & 2649 & +.5 * ( tmask(ji-1,jj+1,jk) + tmask(ji-1,jj-1,jk) & 2650 & +tmask(ji+1,jj+1,jk) + tmask(ji+1,jj-1,jk) ) & 2651 & +1. * ( tmask(ji-1,jj ,jk) + tmask(ji ,jj+1,jk) & 2652 & +tmask(ji ,jj-1,jk) + tmask(ji+1,jj ,jk) ) ) 2653 END_3D 2654 2655 CASE DEFAULT 2656 WRITE(ctmp1,*) ' bad flag value for nn_ave = ', nn_ave 2657 CALL ctl_stop( ctmp1 ) 2658 2659 END SELECT 2660 2661 ! Initialization of vertical eddy coef. to the background value 2662 ! ------------------------------------------------------------- 2663 DO jk = 1, jpk 2664 avt (:,:,jk) = avtb(jk) * tmask(:,:,jk) 2665 END DO 2666 2667 ! zero the surface flux for non local term and osm mixed layer depth 2668 ! ------------------------------------------------------------------ 2669 ghamt(:,:,:) = 0. 2670 ghams(:,:,:) = 0. 2671 ghamu(:,:,:) = 0. 2672 ghamv(:,:,:) = 0. 2673 ! 3138 END IF 3139 ! 3140 CALL osm_rst( nit000, Kmm, 'READ' ) ! Read or initialize hbl, dh, hmle 3141 ! 3142 IF ( ln_zdfddm ) THEN 3143 IF(lwp) THEN 3144 WRITE(numout,*) 3145 WRITE(numout,*) ' Double diffusion mixing on temperature and salinity ' 3146 WRITE(numout,*) ' CAUTION : done in routine zdfosm, not in routine zdfddm ' 3147 END IF 3148 END IF 3149 ! 3150 ! Set constants not in namelist 3151 ! ----------------------------- 3152 IF(lwp) THEN 3153 WRITE(numout,*) 3154 END IF 3155 ! 3156 dstokes(:,:) = pp_large 3157 IF (nn_osm_wave == 0) THEN 3158 dstokes(:,:) = rn_osm_dstokes 3159 END IF 3160 ! 3161 ! Horizontal average : initialization of weighting arrays 3162 ! ------------------- 3163 SELECT CASE ( nn_ave ) 3164 CASE ( 0 ) ! no horizontal average 3165 IF(lwp) WRITE(numout,*) ' no horizontal average on avt' 3166 IF(lwp) WRITE(numout,*) ' only in very high horizontal resolution !' 3167 ! Weighting mean arrays etmean 3168 ! ( 1 1 ) 3169 ! avt = 1/4 ( 1 1 ) 3170 ! 3171 etmean(:,:,:) = 0.0_wp 3172 ! 3173 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 3174 etmean(ji,jj,jk) = tmask(ji,jj,jk) / MAX( 1.0_wp, umask(ji-1,jj, jk) + umask(ji,jj,jk) + & 3175 & vmask(ji, jj-1,jk) + vmask(ji,jj,jk) ) 3176 END_3D 3177 CASE ( 1 ) ! horizontal average 3178 IF(lwp) WRITE(numout,*) ' horizontal average on avt' 3179 ! Weighting mean arrays etmean 3180 ! ( 1/2 1 1/2 ) 3181 ! avt = 1/8 ( 1 2 1 ) 3182 ! ( 1/2 1 1/2 ) 3183 etmean(:,:,:) = 0.0_wp 3184 ! 3185 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 3186 etmean(ji,jj,jk) = tmask(ji, jj,jk) / MAX( 1.0_wp, 2.0_wp * tmask(ji,jj,jk) + & 3187 & 0.5_wp * ( tmask(ji-1,jj+1,jk) + tmask(ji-1,jj-1,jk) + & 3188 & tmask(ji+1,jj+1,jk) + tmask(ji+1,jj-1,jk) ) + & 3189 & 1.0_wp * ( tmask(ji-1,jj, jk) + tmask(ji, jj+1,jk) + & 3190 & tmask(ji, jj-1,jk) + tmask(ji+1,jj, jk) ) ) 3191 END_3D 3192 CASE DEFAULT 3193 WRITE(ctmp1,*) ' bad flag value for nn_ave = ', nn_ave 3194 CALL ctl_stop( ctmp1 ) 3195 END SELECT 3196 ! 3197 ! Initialization of vertical eddy coef. to the background value 3198 ! ------------------------------------------------------------- 3199 DO jk = 1, jpk 3200 avt(:,:,jk) = avtb(jk) * tmask(:,:,jk) 3201 END DO 3202 ! 3203 ! Zero the surface flux for non local term and osm mixed layer depth 3204 ! ------------------------------------------------------------------ 3205 ghamt(:,:,:) = 0.0_wp 3206 ghams(:,:,:) = 0.0_wp 3207 ghamu(:,:,:) = 0.0_wp 3208 ghamv(:,:,:) = 0.0_wp 3209 ! 3210 IF ( ln_dia_osm ) THEN ! Initialise auxiliary arrays for diagnostic output 3211 osmdia2d(:,:) = 0.0_wp 3212 osmdia3d(:,:,:) = 0.0_wp 3213 END IF 3214 ! 2674 3215 END SUBROUTINE zdf_osm_init 2675 3216 2676 2677 3217 SUBROUTINE osm_rst( kt, Kmm, cdrw ) 2678 !!--------------------------------------------------------------------- 2679 !! *** ROUTINE osm_rst *** 2680 !! 2681 !! ** Purpose : Read or write BL fields in restart file 2682 !! 2683 !! ** Method : use of IOM library. If the restart does not contain 2684 !! required fields, they are recomputed from stratification 2685 !!---------------------------------------------------------------------- 2686 2687 INTEGER , INTENT(in) :: kt ! ocean time step index 2688 INTEGER , INTENT(in) :: Kmm ! ocean time level index (middle) 2689 CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag 2690 2691 INTEGER :: id1, id2, id3 ! iom enquiry index 2692 INTEGER :: ji, jj, jk ! dummy loop indices 2693 INTEGER :: iiki, ikt ! local integer 2694 REAL(wp) :: zhbf ! tempory scalars 2695 REAL(wp) :: zN2_c ! local scalar 2696 REAL(wp) :: rho_c = 0.01_wp !: density criterion for mixed layer depth 2697 INTEGER, DIMENSION(jpi,jpj) :: imld_rst ! level of mixed-layer depth (pycnocline top) 2698 !!---------------------------------------------------------------------- 2699 ! 2700 !!----------------------------------------------------------------------------- 2701 ! If READ/WRITE Flag is 'READ', try to get hbl from restart file. If successful then return 2702 !!----------------------------------------------------------------------------- 2703 IF( TRIM(cdrw) == 'READ'.AND. ln_rstart) THEN 2704 id1 = iom_varid( numror, 'wn' , ldstop = .FALSE. ) 2705 IF( id1 > 0 ) THEN ! 'wn' exists; read 2706 CALL iom_get( numror, jpdom_auto, 'wn', ww ) 2707 WRITE(numout,*) ' ===>>>> : wn read from restart file' 2708 ELSE 2709 ww(:,:,:) = 0._wp 2710 WRITE(numout,*) ' ===>>>> : wn not in restart file, set to zero initially' 2711 END IF 2712 2713 id1 = iom_varid( numror, 'hbl' , ldstop = .FALSE. ) 2714 id2 = iom_varid( numror, 'dh' , ldstop = .FALSE. ) 2715 IF( id1 > 0 .AND. id2 > 0) THEN ! 'hbl' exists; read and return 2716 CALL iom_get( numror, jpdom_auto, 'hbl' , hbl ) 2717 CALL iom_get( numror, jpdom_auto, 'dh', dh ) 2718 WRITE(numout,*) ' ===>>>> : hbl & dh read from restart file' 2719 IF( ln_osm_mle ) THEN 2720 id3 = iom_varid( numror, 'hmle' , ldstop = .FALSE. ) 2721 IF( id3 > 0) THEN 2722 CALL iom_get( numror, jpdom_auto, 'hmle' , hmle ) 2723 WRITE(numout,*) ' ===>>>> : hmle read from restart file' 2724 ELSE 2725 WRITE(numout,*) ' ===>>>> : hmle not found, set to hbl' 2726 hmle(:,:) = hbl(:,:) ! Initialise MLE depth. 2727 END IF 2728 END IF 2729 RETURN 2730 ELSE ! 'hbl' & 'dh' not in restart file, recalculate 2731 WRITE(numout,*) ' ===>>>> : previous run without osmosis scheme, hbl computed from stratification' 2732 END IF 2733 END IF 2734 2735 !!----------------------------------------------------------------------------- 2736 ! If READ/WRITE Flag is 'WRITE', write hbl into the restart file, then return 2737 !!----------------------------------------------------------------------------- 2738 IF( TRIM(cdrw) == 'WRITE') THEN !* Write hbl into the restart file, then return 2739 IF(lwp) WRITE(numout,*) '---- osm-rst ----' 2740 CALL iom_rstput( kt, nitrst, numrow, 'wn' , ww ) 2741 CALL iom_rstput( kt, nitrst, numrow, 'hbl' , hbl ) 2742 CALL iom_rstput( kt, nitrst, numrow, 'dh' , dh ) 2743 IF( ln_osm_mle ) THEN 3218 !!--------------------------------------------------------------------- 3219 !! *** ROUTINE osm_rst *** 3220 !! 3221 !! ** Purpose : Read or write BL fields in restart file 3222 !! 3223 !! ** Method : use of IOM library. If the restart does not contain 3224 !! required fields, they are recomputed from stratification 3225 !! 3226 !!---------------------------------------------------------------------- 3227 INTEGER , INTENT(in ) :: kt ! Ocean time step index 3228 INTEGER , INTENT(in ) :: Kmm ! Ocean time level index (middle) 3229 CHARACTER(len=*), INTENT(in ) :: cdrw ! "READ"/"WRITE" flag 3230 !! 3231 INTEGER :: id1, id2, id3 ! iom enquiry index 3232 INTEGER :: ji, jj, jk ! Dummy loop indices 3233 INTEGER :: iiki, ikt ! Local integer 3234 REAL(wp) :: zhbf ! Tempory scalars 3235 REAL(wp) :: zN2_c ! Local scalar 3236 REAL(wp) :: rho_c = 0.01_wp ! Density criterion for mixed layer depth 3237 INTEGER, DIMENSION(jpi,jpj) :: imld_rst ! Level of mixed-layer depth (pycnocline top) 3238 !!---------------------------------------------------------------------- 3239 ! 3240 !!----------------------------------------------------------------------------- 3241 ! If READ/WRITE Flag is 'READ', try to get hbl from restart file. If successful then return 3242 !!----------------------------------------------------------------------------- 3243 IF( TRIM(cdrw) == 'READ' .AND. ln_rstart) THEN 3244 id1 = iom_varid( numror, 'wn', ldstop = .FALSE. ) 3245 IF( id1 > 0 ) THEN ! 'wn' exists; read 3246 CALL iom_get( numror, jpdom_auto, 'wn', ww ) 3247 WRITE(numout,*) ' ===>>>> : wn read from restart file' 3248 ELSE 3249 ww(:,:,:) = 0.0_wp 3250 WRITE(numout,*) ' ===>>>> : wn not in restart file, set to zero initially' 3251 END IF 3252 ! 3253 id1 = iom_varid( numror, 'hbl', ldstop = .FALSE. ) 3254 id2 = iom_varid( numror, 'dh', ldstop = .FALSE. ) 3255 IF( id1 > 0 .AND. id2 > 0 ) THEN ! 'hbl' exists; read and return 3256 CALL iom_get( numror, jpdom_auto, 'hbl', hbl ) 3257 CALL iom_get( numror, jpdom_auto, 'dh', dh ) 3258 hml(:,:) = hbl(:,:) - dh(:,:) ! Initialise ML depth 3259 WRITE(numout,*) ' ===>>>> : hbl & dh read from restart file' 3260 IF( ln_osm_mle ) THEN 3261 id3 = iom_varid( numror, 'hmle', ldstop = .FALSE. ) 3262 IF( id3 > 0 ) THEN 3263 CALL iom_get( numror, jpdom_auto, 'hmle', hmle ) 3264 WRITE(numout,*) ' ===>>>> : hmle read from restart file' 3265 ELSE 3266 WRITE(numout,*) ' ===>>>> : hmle not found, set to hbl' 3267 hmle(:,:) = hbl(:,:) ! Initialise MLE depth 3268 END IF 3269 END IF 3270 RETURN 3271 ELSE ! 'hbl' & 'dh' not in restart file, recalculate 3272 WRITE(numout,*) ' ===>>>> : previous run without osmosis scheme, hbl computed from stratification' 3273 END IF 3274 END IF 3275 ! 3276 !!----------------------------------------------------------------------------- 3277 ! If READ/WRITE Flag is 'WRITE', write hbl into the restart file, then return 3278 !!----------------------------------------------------------------------------- 3279 IF ( TRIM(cdrw) == 'WRITE' ) THEN 3280 IF(lwp) WRITE(numout,*) '---- osm-rst ----' 3281 CALL iom_rstput( kt, nitrst, numrow, 'wn', ww ) 3282 CALL iom_rstput( kt, nitrst, numrow, 'hbl', hbl ) 3283 CALL iom_rstput( kt, nitrst, numrow, 'dh', dh ) 3284 IF ( ln_osm_mle ) THEN 2744 3285 CALL iom_rstput( kt, nitrst, numrow, 'hmle', hmle ) 2745 3286 END IF 2746 RETURN 2747 END IF 2748 2749 !!----------------------------------------------------------------------------- 2750 ! Getting hbl, no restart file with hbl, so calculate from surface stratification 2751 !!----------------------------------------------------------------------------- 2752 IF( lwp ) WRITE(numout,*) ' ===>>>> : calculating hbl computed from stratification' 2753 ! w-level of the mixing and mixed layers 2754 CALL eos_rab( ts(:,:,:,:,Kmm), rab_n, Kmm ) 2755 CALL bn2(ts(:,:,:,:,Kmm), rab_n, rn2, Kmm) 2756 imld_rst(:,:) = nlb10 ! Initialization to the number of w ocean point 2757 hbl(:,:) = 0._wp ! here hbl used as a dummy variable, integrating vertically N^2 2758 zN2_c = grav * rho_c * r1_rho0 ! convert density criteria into N^2 criteria 2759 ! 2760 hbl(:,:) = 0._wp ! here hbl used as a dummy variable, integrating vertically N^2 2761 DO_3D( 1, 1, 1, 1, 1, jpkm1 ) 2762 ikt = mbkt(ji,jj) 2763 hbl(ji,jj) = hbl(ji,jj) + MAX( rn2(ji,jj,jk) , 0._wp ) * e3w(ji,jj,jk,Kmm) 2764 IF( hbl(ji,jj) < zN2_c ) imld_rst(ji,jj) = MIN( jk , ikt ) + 1 ! Mixed layer level 2765 END_3D 2766 ! 2767 DO_2D( 1, 1, 1, 1 ) 2768 iiki = MAX(4,imld_rst(ji,jj)) 2769 hbl (ji,jj) = gdepw(ji,jj,iiki,Kmm ) ! Turbocline depth 2770 dh (ji,jj) = e3t(ji,jj,iiki-1,Kmm ) ! Turbocline depth 2771 END_2D 2772 2773 WRITE(numout,*) ' ===>>>> : hbl computed from stratification' 2774 2775 IF( ln_osm_mle ) THEN 2776 hmle(:,:) = hbl(:,:) ! Initialise MLE depth. 2777 WRITE(numout,*) ' ===>>>> : hmle set = to hbl' 2778 END IF 2779 2780 ww(:,:,:) = 0._wp 2781 WRITE(numout,*) ' ===>>>> : wn not in restart file, set to zero initially' 3287 RETURN 3288 END IF 3289 ! 3290 !!----------------------------------------------------------------------------- 3291 ! Getting hbl, no restart file with hbl, so calculate from surface stratification 3292 !!----------------------------------------------------------------------------- 3293 IF( lwp ) WRITE(numout,*) ' ===>>>> : calculating hbl computed from stratification' 3294 ! w-level of the mixing and mixed layers 3295 CALL eos_rab( ts(:,:,:,:,Kmm), rab_n, Kmm ) 3296 CALL bn2( ts(:,:,:,:,Kmm), rab_n, rn2, Kmm ) 3297 imld_rst(:,:) = nlb10 ! Initialization to the number of w ocean point 3298 hbl(:,:) = 0.0_wp ! Here hbl used as a dummy variable, integrating vertically N^2 3299 zN2_c = grav * rho_c * r1_rho0 ! Convert density criteria into N^2 criteria 3300 ! 3301 hbl(:,:) = 0.0_wp ! Here hbl used as a dummy variable, integrating vertically N^2 3302 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 3303 ikt = mbkt(ji,jj) 3304 hbl(ji,jj) = hbl(ji,jj) + MAX( rn2(ji,jj,jk) , 0.0_wp ) * e3w(ji,jj,jk,Kmm) 3305 IF ( hbl(ji,jj) < zN2_c ) imld_rst(ji,jj) = MIN( jk , ikt ) + 1 ! Mixed layer level 3306 END_3D 3307 ! 3308 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 3309 iiki = MAX( 4, imld_rst(ji,jj) ) 3310 hbl(ji,jj) = gdepw(ji,jj,iiki,Kmm ) ! Turbocline depth 3311 dh(ji,jj) = e3t(ji,jj,iiki-1,Kmm ) ! Turbocline depth 3312 hml(ji,jj) = hbl(ji,jj) - dh(ji,jj) 3313 END_2D 3314 ! 3315 WRITE(numout,*) ' ===>>>> : hbl computed from stratification' 3316 ! 3317 IF( ln_osm_mle ) THEN 3318 hmle(:,:) = hbl(:,:) ! Initialise MLE depth. 3319 WRITE(numout,*) ' ===>>>> : hmle set = to hbl' 3320 END IF 3321 ! 3322 ww(:,:,:) = 0.0_wp 3323 WRITE(numout,*) ' ===>>>> : wn not in restart file, set to zero initially' 3324 ! 2782 3325 END SUBROUTINE osm_rst 2783 3326 2784 2785 3327 SUBROUTINE tra_osm( kt, Kmm, pts, Krhs ) 2786 3328 !!---------------------------------------------------------------------- … … 2790 3332 !! 2791 3333 !! ** Method : ??? 2792 !!---------------------------------------------------------------------- 3334 !! 3335 !!---------------------------------------------------------------------- 3336 INTEGER , INTENT(in ) :: kt ! Time step index 3337 INTEGER , INTENT(in ) :: Kmm, Krhs ! Time level indices 3338 REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts ! Active tracers and RHS of tracer equation 3339 !! 3340 INTEGER :: ji, jj, jk 2793 3341 REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: ztrdt, ztrds ! 3D workspace 2794 3342 !!---------------------------------------------------------------------- 2795 INTEGER , INTENT(in) :: kt ! time step index 2796 INTEGER , INTENT(in) :: Kmm, Krhs ! time level indices 2797 REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts ! active tracers and RHS of tracer equation 2798 ! 2799 INTEGER :: ji, jj, jk 2800 ! 2801 IF( kt == nit000 ) THEN 2802 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile 3343 ! 3344 IF ( kt == nit000 ) THEN 3345 IF ( ntile == 0 .OR. ntile == 1 ) THEN ! Do only on the first tile 2803 3346 IF(lwp) WRITE(numout,*) 2804 3347 IF(lwp) WRITE(numout,*) 'tra_osm : OSM non-local tracer fluxes' 2805 3348 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 2806 ENDIF 2807 ENDIF 2808 2809 IF( l_trdtra ) THEN !* Save ta and sa trends 2810 ALLOCATE( ztrdt(jpi,jpj,jpk) ) ; ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) 2811 ALLOCATE( ztrds(jpi,jpj,jpk) ) ; ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) 2812 ENDIF 2813 3349 END IF 3350 END IF 3351 ! 3352 IF ( l_trdtra ) THEN ! Save ta and sa trends 3353 ALLOCATE( ztrdt(jpi,jpj,jpk), ztrds(jpi,jpj,jpk) ) 3354 ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) 3355 ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) 3356 END IF 3357 ! 2814 3358 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) 2815 3359 pts(ji,jj,jk,jp_tem,Krhs) = pts(ji,jj,jk,jp_tem,Krhs) & … … 2820 3364 & - ghams(ji,jj,jk+1) ) / e3t(ji,jj,jk,Kmm) 2821 3365 END_3D 2822 2823 ! save the non-local tracer flux trends for diagnostics 2824 IF( l_trdtra ) THEN 3366 ! 3367 IF ( l_trdtra ) THEN ! Save the non-local tracer flux trends for diagnostics 2825 3368 ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:) 2826 3369 ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) - ztrds(:,:,:) 2827 2828 3370 CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_osm, ztrdt ) 2829 3371 CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_osm, ztrds ) 2830 DEALLOCATE( ztrdt ) ; DEALLOCATE(ztrds )2831 END IF2832 2833 IF (sn_cfctl%l_prtctl) THEN3372 DEALLOCATE( ztrdt, ztrds ) 3373 END IF 3374 ! 3375 IF ( sn_cfctl%l_prtctl ) THEN 2834 3376 CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' osm - Ta: ', mask1=tmask, & 2835 &tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2= ' Sa: ', mask2=tmask, clinfo3='tra' )2836 END IF3377 & tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2= ' Sa: ', mask2=tmask, clinfo3='tra' ) 3378 END IF 2837 3379 ! 2838 3380 END SUBROUTINE tra_osm 2839 3381 2840 2841 SUBROUTINE trc_osm( kt ) ! Dummy routine 3382 SUBROUTINE trc_osm( kt ) ! Dummy routine 2842 3383 !!---------------------------------------------------------------------- 2843 3384 !! *** ROUTINE trc_osm *** … … 2848 3389 !! 2849 3390 !! ** Method : ??? 2850 !!---------------------------------------------------------------------- 2851 ! 3391 !! 2852 3392 !!---------------------------------------------------------------------- 2853 3393 INTEGER, INTENT(in) :: kt 3394 !!---------------------------------------------------------------------- 3395 ! 2854 3396 WRITE(*,*) 'trc_osm: Not written yet', kt 3397 ! 2855 3398 END SUBROUTINE trc_osm 2856 2857 3399 2858 3400 SUBROUTINE dyn_osm( kt, Kmm, puu, pvv, Krhs ) … … 2864 3406 !! 2865 3407 !! ** Method : ??? 2866 !!---------------------------------------------------------------------- 2867 INTEGER , INTENT( in ) :: kt ! ocean time step index 2868 INTEGER , INTENT( in ) :: Kmm, Krhs ! ocean time level indices 2869 REAL(wp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) :: puu, pvv ! ocean velocities and RHS of momentum equation 2870 ! 3408 !! 3409 !!---------------------------------------------------------------------- 3410 INTEGER , INTENT(in ) :: kt ! Ocean time step index 3411 INTEGER , INTENT(in ) :: Kmm, Krhs ! Ocean time level indices 3412 REAL(wp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) :: puu, pvv ! Ocean velocities and RHS of momentum equation 3413 !! 2871 3414 INTEGER :: ji, jj, jk ! dummy loop indices 2872 3415 !!---------------------------------------------------------------------- 2873 3416 ! 2874 IF ( kt == nit000 ) THEN3417 IF ( kt == nit000 ) THEN 2875 3418 IF(lwp) WRITE(numout,*) 2876 3419 IF(lwp) WRITE(numout,*) 'dyn_osm : OSM non-local velocity' 2877 3420 IF(lwp) WRITE(numout,*) '~~~~~~~ ' 2878 ENDIF 2879 !code saving tracer trends removed, replace with trdmxl_oce 2880 2881 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) ! add non-local u and v fluxes 2882 puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) & 2883 & - ( ghamu(ji,jj,jk ) & 2884 & - ghamu(ji,jj,jk+1) ) / e3u(ji,jj,jk,Kmm) 2885 pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) & 2886 & - ( ghamv(ji,jj,jk ) & 2887 & - ghamv(ji,jj,jk+1) ) / e3v(ji,jj,jk,Kmm) 3421 END IF 3422 ! 3423 ! Code saving tracer trends removed, replace with trdmxl_oce 3424 ! 3425 DO_3D( 0, 0, 0, 0, 1, jpkm1 ) ! Add non-local u and v fluxes 3426 puu(ji,jj,jk,Krhs) = puu(ji,jj,jk,Krhs) - ( ghamu(ji,jj,jk ) - & 3427 & ghamu(ji,jj,jk+1) ) / e3u(ji,jj,jk,Kmm) 3428 pvv(ji,jj,jk,Krhs) = pvv(ji,jj,jk,Krhs) - ( ghamv(ji,jj,jk ) - & 3429 & ghamv(ji,jj,jk+1) ) / e3v(ji,jj,jk,Kmm) 2888 3430 END_3D 2889 3431 ! 2890 ! code for saving tracer trends removed3432 ! Code for saving tracer trends removed 2891 3433 ! 2892 3434 END SUBROUTINE dyn_osm 2893 3435 3436 SUBROUTINE zdf_osm_iomput_2d( cdname, posmdia2d ) 3437 !!---------------------------------------------------------------------- 3438 !! *** ROUTINE zdf_osm_iomput_2d *** 3439 !! 3440 !! ** Purpose : Wrapper for subroutine iom_put that accepts 2D arrays 3441 !! with and without halo 3442 !! 3443 !!---------------------------------------------------------------------- 3444 CHARACTER(LEN=*), INTENT(in ) :: cdname 3445 REAL(wp), DIMENSION(:,:), INTENT(in ) :: posmdia2d 3446 !!---------------------------------------------------------------------- 3447 ! 3448 IF ( ln_dia_osm .AND. iom_use( cdname ) ) THEN 3449 IF ( SIZE( posmdia2d, 1 ) == ntei-ntsi+1 .AND. SIZE( posmdia2d, 2 ) == ntej-ntsj+1 ) THEN ! Halo absent 3450 osmdia2d(A2D(0)) = posmdia2d(:,:) 3451 CALL iom_put( cdname, osmdia2d(A2D(nn_hls)) ) 3452 ELSE ! Halo present 3453 CALL iom_put( cdname, osmdia2d ) 3454 END IF 3455 END IF 3456 ! 3457 END SUBROUTINE zdf_osm_iomput_2d 3458 3459 SUBROUTINE zdf_osm_iomput_3d( cdname, posmdia3d ) 3460 !!---------------------------------------------------------------------- 3461 !! *** ROUTINE zdf_osm_iomput_3d *** 3462 !! 3463 !! ** Purpose : Wrapper for subroutine iom_put that accepts 3D arrays 3464 !! with and without halo 3465 !! 3466 !!---------------------------------------------------------------------- 3467 CHARACTER(LEN=*), INTENT(in ) :: cdname 3468 REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: posmdia3d 3469 !!---------------------------------------------------------------------- 3470 ! 3471 IF ( ln_dia_osm .AND. iom_use( cdname ) ) THEN 3472 IF ( SIZE( posmdia3d, 1 ) == ntei-ntsi+1 .AND. SIZE( posmdia3d, 2 ) == ntej-ntsj+1 ) THEN ! Halo absent 3473 osmdia3d(A2D(0),:) = posmdia3d(:,:,:) 3474 CALL iom_put( cdname, osmdia3d(A2D(nn_hls),:) ) 3475 ELSE ! Halo present 3476 CALL iom_put( cdname, osmdia3d ) 3477 END IF 3478 END IF 3479 ! 3480 END SUBROUTINE zdf_osm_iomput_3d 3481 2894 3482 !!====================================================================== 2895 3483 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfphy.F90
r14433 r14958 12 12 !!---------------------------------------------------------------------- 13 13 USE oce ! ocean dynamics and tracers variables 14 ! TEMP: [tiling] This change not necessary after finalisation of zdf_osm (not yet tiled) 15 USE domtile 14 16 USE zdf_oce ! vertical physics: shared variables 15 17 USE zdfdrg ! vertical physics: top/bottom drag coef. … … 54 56 INTEGER, PARAMETER :: np_OSM = 5 ! OSMOSIS-OBL closure scheme for Kz 55 57 56 LOGICAL :: l_zdfsh2 ! shear production term flag (=F for CST, =T otherwise (i.e. TKE, GLS, RIC)) 57 58 LOGICAL, PUBLIC :: l_zdfsh2 ! shear production term flag (=F for CST, =T otherwise (i.e. TKE, GLS, RIC)) 59 60 REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:,:) :: avm_k_n !: "Now" avm_k used for calculation of zsh2 with tiling 61 62 !! * Substitutions 63 # include "do_loop_substitute.h90" 58 64 !!---------------------------------------------------------------------- 59 65 !! NEMO/OCE 4.0 , NEMO Consortium (2018) … … 210 216 ENDIF 211 217 ! ! shear production term flag 212 IF( ln_zdfcst ) THEN ; l_zdfsh2 = .FALSE. 213 ELSE ; l_zdfsh2 = .TRUE. 214 ENDIF 218 IF( ln_zdfcst .OR. ln_zdfosm ) THEN ; l_zdfsh2 = .FALSE. 219 ELSE ; l_zdfsh2 = .TRUE. 220 ENDIF 221 IF( ln_tile .AND. l_zdfsh2 ) ALLOCATE( avm_k_n(jpi,jpj,jpk) ) 215 222 ! !== Mass Flux Convectiive algorithm ==! 216 223 IF( ln_zdfmfc ) CALL zdf_mfc_init ! Convection computed with eddy diffusivity mass flux … … 246 253 ! 247 254 INTEGER :: ji, jj, jk ! dummy loop indice 248 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zsh2 ! shear production255 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zsh2 ! shear production 249 256 !! --------------------------------------------------------------------- 250 257 ! … … 267 274 IF ( ln_drgice_imp) THEN 268 275 IF ( ln_isfcav ) THEN 269 rCdU_top(:,:) = rCdU_top(:,:) + ssmask(:,:) * tmask(:,:,1) * rCdU_ice(:,:) 276 DO_2D_OVR( 1, 1, 1, 1 ) 277 rCdU_top(ji,jj) = rCdU_top(ji,jj) + ssmask(ji,jj) * tmask(ji,jj,1) * rCdU_ice(ji,jj) 278 END_2D 270 279 ELSE 271 rCdU_top(:,:) = rCdU_ice(:,:) 280 DO_2D_OVR( 1, 1, 1, 1 ) 281 rCdU_top(ji,jj) = rCdU_ice(ji,jj) 282 END_2D 272 283 ENDIF 273 284 ENDIF 274 285 #endif 275 286 ! 287 CALL zdf_mxl( kt, Kmm ) !* mixed layer depth, and level 288 ! 276 289 ! !== Kz from chosen turbulent closure ==! (avm_k, avt_k) 277 290 ! 278 IF( l_zdfsh2 ) & !* shear production at w-points (energy conserving form) 279 CALL zdf_sh2( Kbb, Kmm, avm_k, & ! <<== in 280 & zsh2 ) ! ==>> out : shear production 291 ! NOTE: [tiling] the closure schemes (zdf_tke etc) will update avm_k. With tiling, the calculation of zsh2 on adjacent tiles then uses both updated (next timestep) and non-updated (current timestep) values of avm_k. To preserve results, we save a read-only copy of the "now" avm_k to use in the calculation of zsh2. 292 IF( l_zdfsh2 ) THEN !* shear production at w-points (energy conserving form) 293 IF( ln_tile ) THEN 294 IF( ntile == 1 ) avm_k_n(:,:,:) = avm_k(:,:,:) ! Preserve "now" avm_k for calculation of zsh2 295 CALL zdf_sh2( Kbb, Kmm, avm_k_n, & ! <<== in 296 & zsh2 ) ! ==>> out : shear production 297 ELSE 298 CALL zdf_sh2( Kbb, Kmm, avm_k, & ! <<== in 299 & zsh2 ) ! ==>> out : shear production 300 ENDIF 301 ENDIF 281 302 ! 282 303 SELECT CASE ( nzdf_phy ) !* Vertical eddy viscosity and diffusivity coefficients at w-points … … 285 306 CASE( np_GLS ) ; CALL zdf_gls( kt, Kbb, Kmm, zsh2, avm_k, avt_k ) ! GLS closure scheme for Kz 286 307 CASE( np_OSM ) ; CALL zdf_osm( kt, Kbb, Kmm, Krhs, avm_k, avt_k ) ! OSMOSIS closure scheme for Kz 287 ! CASE( np_CST ) ! Constant Kz (reset avt, avm to the background value)288 ! ! avt_k and avm_k set one for all at initialisation phase308 ! CASE( np_CST ) ! Constant Kz (reset avt, avm to the background value) 309 ! ! avt_k and avm_k set one for all at initialisation phase 289 310 !!gm avt(2:jpim1,2:jpjm1,1:jpkm1) = rn_avt0 * wmask(2:jpim1,2:jpjm1,1:jpkm1) 290 311 !!gm avm(2:jpim1,2:jpjm1,1:jpkm1) = rn_avm0 * wmask(2:jpim1,2:jpjm1,1:jpkm1) … … 294 315 ! 295 316 ! !* start from turbulent closure values 296 avt(:,:,2:jpkm1) = avt_k(:,:,2:jpkm1) 297 avm(:,:,2:jpkm1) = avm_k(:,:,2:jpkm1) 317 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 318 avt(ji,jj,jk) = avt_k(ji,jj,jk) 319 avm(ji,jj,jk) = avm_k(ji,jj,jk) 320 END_3D 298 321 ! 299 322 IF( ln_rnf_mouth ) THEN !* increase diffusivity at rivers mouths 300 DO jk = 2, nkrnf301 avt( :,:,jk) = avt(:,:,jk) + 2._wp * rn_avt_rnf * rnfmsk(:,:) * wmask(:,:,jk)302 END DO323 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, nkrnf ) 324 avt(ji,jj,jk) = avt(ji,jj,jk) + 2._wp * rn_avt_rnf * rnfmsk(ji,jj) * wmask(ji,jj,jk) 325 END_3D 303 326 ENDIF 304 327 ! … … 309 332 CALL zdf_ddm( kt, Kmm, avm, avt, avs ) 310 333 ELSE ! same mixing on all tracers 311 avs(2:jpim1,2:jpjm1,1:jpkm1) = avt(2:jpim1,2:jpjm1,1:jpkm1) 334 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) 335 avs(ji,jj,jk) = avt(ji,jj,jk) 336 END_3D 312 337 ENDIF 313 338 ! … … 318 343 #if defined key_agrif 319 344 ! interpolation parent grid => child grid for avm_k ( ex : at west border: update column 1 and 2) 320 IF( l_zdfsh2 ) CALL Agrif_avm 345 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 346 IF( l_zdfsh2 ) CALL Agrif_avm 347 ENDIF 321 348 #endif 322 349 323 350 ! !* Lateral boundary conditions (sign unchanged) 324 IF( l_zdfsh2 ) THEN 325 CALL lbc_lnk( 'zdfphy', avm_k, 'W', 1.0_wp , avt_k, 'W', 1.0_wp, & 326 & avm , 'W', 1.0_wp , avt , 'W', 1.0_wp , avs , 'W', 1.0_wp ) 327 ELSE 328 CALL lbc_lnk( 'zdfphy', avm , 'W', 1.0_wp , avt , 'W', 1.0_wp , avs , 'W', 1.0_wp ) 329 ENDIF 330 ! 331 IF( l_zdfdrg ) THEN ! drag have been updated (non-linear cases) 332 IF( ln_isfcav ) THEN ; CALL lbc_lnk( 'zdfphy', rCdU_top, 'T', 1.0_wp , rCdU_bot, 'T', 1.0_wp ) ! top & bot drag 333 ELSE ; CALL lbc_lnk( 'zdfphy', rCdU_bot, 'T', 1.0_wp ) ! bottom drag only 334 ENDIF 335 ENDIF 336 ! 337 CALL zdf_mxl( kt, Kmm ) !* mixed layer depth, and level 338 ! 339 IF( lrst_oce ) THEN !* write TKE, GLS or RIC fields in the restart file 340 IF( ln_zdftke ) CALL tke_rst( kt, 'WRITE' ) 341 IF( ln_zdfgls ) CALL gls_rst( kt, 'WRITE' ) 342 IF( ln_zdfric ) CALL ric_rst( kt, 'WRITE' ) 343 ! NB. OSMOSIS restart (osm_rst) will be called in step.F90 after ww has been updated 351 IF(nn_hls==1) THEN 352 IF( l_zdfsh2 ) THEN 353 CALL lbc_lnk( 'zdfphy', avm_k, 'W', 1.0_wp , avt_k, 'W', 1.0_wp, & 354 & avm , 'W', 1.0_wp , avt , 'W', 1.0_wp , avs , 'W', 1.0_wp ) 355 ELSE 356 CALL lbc_lnk( 'zdfphy', avm , 'W', 1.0_wp , avt , 'W', 1.0_wp , avs , 'W', 1.0_wp ) 357 ENDIF 358 ! 359 IF( l_zdfdrg ) THEN ! drag have been updated (non-linear cases) 360 IF( ln_isfcav ) THEN ; CALL lbc_lnk( 'zdfphy', rCdU_top, 'T', 1.0_wp , rCdU_bot, 'T', 1.0_wp ) ! top & bot drag 361 ELSE ; CALL lbc_lnk( 'zdfphy', rCdU_bot, 'T', 1.0_wp ) ! bottom drag only 362 ENDIF 363 ENDIF 364 ENDIF 365 ! 366 CALL zdf_mxl_turb( kt, Kmm ) !* turbocline depth 367 ! 368 IF( .NOT. l_istiled .OR. ntile == nijtile ) THEN ! Do only on the last tile 369 IF( lrst_oce ) THEN !* write TKE, GLS or RIC fields in the restart file 370 IF( ln_zdftke ) CALL tke_rst( kt, 'WRITE' ) 371 IF( ln_zdfgls ) CALL gls_rst( kt, 'WRITE' ) 372 IF( ln_zdfric ) CALL ric_rst( kt, 'WRITE' ) 373 ! NB. OSMOSIS restart (osm_rst) will be called in step.F90 after ww has been updated 374 ENDIF 344 375 ENDIF 345 376 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfric.F90
r14072 r14958 145 145 !! PFJ Lermusiaux 2001. 146 146 !!---------------------------------------------------------------------- 147 INTEGER , INTENT(in ) :: kt ! ocean time-step148 INTEGER , INTENT(in ) :: Kmm ! ocean time level index149 REAL(wp), DIMENSION( :,:,:), INTENT(in ) :: p_sh2 ! shear production term150 REAL(wp), DIMENSION(:,:,:) , INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points)147 INTEGER , INTENT(in ) :: kt ! ocean time-step 148 INTEGER , INTENT(in ) :: Kmm ! ocean time level index 149 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: p_sh2 ! shear production term 150 REAL(wp), DIMENSION(:,:,:) , INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points) 151 151 !! 152 152 INTEGER :: ji, jj, jk ! dummy loop indices 153 153 REAL(wp) :: zcfRi, zav, zustar, zhek ! local scalars 154 REAL(wp), DIMENSION( jpi,jpj) :: zh_ekm ! 2D workspace154 REAL(wp), DIMENSION(A2D(nn_hls)) :: zh_ekm ! 2D workspace 155 155 !!---------------------------------------------------------------------- 156 156 ! 157 157 ! !== avm and avt = F(Richardson number) ==! 158 DO_3D ( 1, 0, 1, 0, 2, jpkm1 ) ! coefficient = F(richardson number) (avm-weighted Ri)158 DO_3D_OVR( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 2, jpkm1 ) ! coefficient = F(richardson number) (avm-weighted Ri) 159 159 zcfRi = 1._wp / ( 1._wp + rn_alp * MAX( 0._wp , avm(ji,jj,jk) * rn2(ji,jj,jk) / ( p_sh2(ji,jj,jk) + 1.e-20 ) ) ) 160 160 zav = rn_avmri * zcfRi**nn_ric … … 169 169 IF( ln_mldw ) THEN !== set a minimum value in the Ekman layer ==! 170 170 ! 171 DO_2D( 0, 0, 0, 0 ) !* Ekman depth171 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 172 172 zustar = SQRT( taum(ji,jj) * r1_rho0 ) 173 173 zhek = rn_ekmfc * zustar / ( ABS( ff_t(ji,jj) ) + rsmall ) ! Ekman depth 174 174 zh_ekm(ji,jj) = MAX( rn_mldmin , MIN( zhek , rn_mldmax ) ) ! set allowed range 175 175 END_2D 176 DO_3D ( 0, 0, 0, 0, 2, jpkm1 ) !* minimum mixing coeff. within the Ekman layer176 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) !* minimum mixing coeff. within the Ekman layer 177 177 IF( gdept(ji,jj,jk,Kmm) < zh_ekm(ji,jj) ) THEN 178 178 p_avm(ji,jj,jk) = MAX( p_avm(ji,jj,jk), rn_wvmix ) * wmask(ji,jj,jk) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfsh2.F90
r14072 r14958 55 55 !! References : Bruchard, OM 2002 56 56 !! --------------------------------------------------------------------- 57 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices58 REAL(wp), DIMENSION(:,:,:) , INTENT(in ) :: p_avm ! vertical eddy viscosity (w-points)59 REAL(wp), DIMENSION( :,:,:) , INTENT( out) :: p_sh2 ! shear production of TKE (w-points)57 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 58 REAL(wp), DIMENSION(:,:,:) , INTENT(in ) :: p_avm ! vertical eddy viscosity (w-points) 59 REAL(wp), DIMENSION(A2D(nn_hls),jpk) , INTENT( out) :: p_sh2 ! shear production of TKE (w-points) 60 60 ! 61 61 INTEGER :: ji, jj, jk ! dummy loop arguments 62 REAL(wp), DIMENSION( jpi,jpj) :: zsh2u, zsh2v ! 2D workspace62 REAL(wp), DIMENSION(A2D(nn_hls)) :: zsh2u, zsh2v ! 2D workspace 63 63 !!-------------------------------------------------------------------- 64 64 ! 65 65 DO jk = 2, jpkm1 !* Shear production at uw- and vw-points (energy conserving form) 66 66 IF ( cpl_sdrftx .AND. ln_stshear ) THEN ! Surface Stokes Drift available ===>>> shear + stokes drift contibution 67 DO_2D( 1, 0, 1, 0)67 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) 68 68 zsh2u(ji,jj) = ( p_avm(ji+1,jj,jk) + p_avm(ji,jj,jk) ) & 69 69 & * ( uu (ji,jj,jk-1,Kmm) - uu (ji,jj,jk,Kmm) & … … 78 78 END_2D 79 79 ELSE 80 DO_2D( 1, 0, 1, 0) !* 2 x shear production at uw- and vw-points (energy conserving form)80 DO_2D( nn_hls, nn_hls-1, nn_hls, nn_hls-1 ) !* 2 x shear production at uw- and vw-points (energy conserving form) 81 81 zsh2u(ji,jj) = ( p_avm(ji+1,jj,jk) + p_avm(ji,jj,jk) ) & 82 82 & * ( uu(ji,jj,jk-1,Kmm) - uu(ji,jj,jk,Kmm) ) & … … 91 91 END_2D 92 92 ENDIF 93 DO_2D( 0, 0, 0, 0) !* shear production at w-point ! coast mask: =2 at the coast ; =1 otherwise (NB: wmask useless as zsh2 are masked)93 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) !* shear production at w-point ! coast mask: =2 at the coast ; =1 otherwise (NB: wmask useless as zsh2 are masked) 94 94 p_sh2(ji,jj,jk) = 0.25 * ( ( zsh2u(ji-1,jj) + zsh2u(ji,jj) ) * ( 2. - umask(ji-1,jj,jk) * umask(ji,jj,jk) ) & 95 95 & + ( zsh2v(ji,jj-1) + zsh2v(ji,jj) ) * ( 2. - vmask(ji,jj-1,jk) * vmask(ji,jj,jk) ) ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdfswm.F90
r13295 r14958 63 63 ! 64 64 zcoef = 1._wp * 0.353553_wp 65 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )65 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 66 66 zqb = zcoef * hsw(ji,jj) * tsd2d(ji,jj) * EXP( -3. * wnum(ji,jj) * gdepw(ji,jj,jk,Kmm) ) * wmask(ji,jj,jk) 67 67 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/ZDF/zdftke.F90
r14072 r14958 168 168 !! Bruchard OM 2002 169 169 !!---------------------------------------------------------------------- 170 INTEGER , INTENT(in ) :: kt ! ocean time step171 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices172 REAL(wp), DIMENSION( :,:,:), INTENT(in ) :: p_sh2 ! shear production term173 REAL(wp), DIMENSION(:,:,:) , INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points)170 INTEGER , INTENT(in ) :: kt ! ocean time step 171 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 172 REAL(wp), DIMENSION(A2D(nn_hls),jpk), INTENT(in ) :: p_sh2 ! shear production term 173 REAL(wp), DIMENSION(:,:,:) , INTENT(inout) :: p_avm, p_avt ! momentum and tracer Kz (w-points) 174 174 !!---------------------------------------------------------------------- 175 175 ! … … 201 201 USE zdf_oce , ONLY : en ! ocean vertical physics 202 202 !! 203 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices204 REAL(wp), DIMENSION( :,:,:) , INTENT(in ) :: p_sh2 ! shear production term205 REAL(wp), DIMENSION(:,:,:) , INTENT(in ) :: p_avm, p_avt ! vertical eddy viscosity & diffusivity (w-points)203 INTEGER , INTENT(in ) :: Kbb, Kmm ! ocean time level indices 204 REAL(wp), DIMENSION(A2D(nn_hls),jpk) , INTENT(in ) :: p_sh2 ! shear production term 205 REAL(wp), DIMENSION(:,:,:) , INTENT(in ) :: p_avm, p_avt ! vertical eddy viscosity & diffusivity (w-points) 206 206 ! 207 207 INTEGER :: ji, jj, jk ! dummy loop arguments … … 216 216 REAL(wp) :: zzd_up, zzd_lw ! - - 217 217 REAL(wp) :: ztaui, ztauj, z1_norm 218 INTEGER , DIMENSION( jpi,jpj) :: imlc219 REAL(wp), DIMENSION( jpi,jpj) :: zice_fra, zhlc, zus3, zWlc2220 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zpelc, zdiag, zd_up, zd_lw218 INTEGER , DIMENSION(A2D(nn_hls)) :: imlc 219 REAL(wp), DIMENSION(A2D(nn_hls)) :: zice_fra, zhlc, zus3, zWlc2 220 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zpelc, zdiag, zd_up, zd_lw 221 221 !!-------------------------------------------------------------------- 222 222 ! … … 232 232 SELECT CASE ( nn_eice ) 233 233 CASE( 0 ) ; zice_fra(:,:) = 0._wp 234 CASE( 1 ) ; zice_fra(:,:) = TANH( fr_i( :,:) * 10._wp )235 CASE( 2 ) ; zice_fra(:,:) = fr_i( :,:)236 CASE( 3 ) ; zice_fra(:,:) = MIN( 4._wp * fr_i( :,:) , 1._wp )234 CASE( 1 ) ; zice_fra(:,:) = TANH( fr_i(A2D(nn_hls)) * 10._wp ) 235 CASE( 2 ) ; zice_fra(:,:) = fr_i(A2D(nn_hls)) 236 CASE( 3 ) ; zice_fra(:,:) = MIN( 4._wp * fr_i(A2D(nn_hls)) , 1._wp ) 237 237 END SELECT 238 238 ! … … 241 241 ! !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 242 242 ! 243 DO_2D ( 0, 0, 0, 0)243 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 244 244 en(ji,jj,1) = MAX( rn_emin0, zbbrau * taum(ji,jj) ) 245 245 zdiag(ji,jj,1) = 1._wp/en(ji,jj,1) … … 258 258 IF( .NOT.ln_drg_OFF ) THEN !== friction used as top/bottom boundary condition on TKE 259 259 ! 260 DO_2D ( 0, 0, 0, 0) ! bottom friction260 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! bottom friction 261 261 zmsku = ( 2. - umask(ji-1,jj,mbkt(ji,jj)) * umask(ji,jj,mbkt(ji,jj)) ) 262 262 zmskv = ( 2. - vmask(ji,jj-1,mbkt(ji,jj)) * vmask(ji,jj,mbkt(ji,jj)) ) … … 267 267 END_2D 268 268 IF( ln_isfcav ) THEN 269 DO_2D ( 0, 0, 0, 0) ! top friction269 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! top friction 270 270 zmsku = ( 2. - umask(ji-1,jj,mikt(ji,jj)) * umask(ji,jj,mikt(ji,jj)) ) 271 271 zmskv = ( 2. - vmask(ji,jj-1,mikt(ji,jj)) * vmask(ji,jj,mikt(ji,jj)) ) … … 294 294 !!gm ! PS: currently we don't have neither the 2 stress components at t-point !nor the angle between u* and u_s 295 295 !!gm ! so we will overestimate the LC velocity.... !!gm I will do the work if !LC have an effect ! 296 DO_2D( 0, 0, 0, 0)296 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 297 297 !!XC zWlc2(ji,jj) = 0.5_wp * SQRT( taum(ji,jj) * r1_rho0 * ( ut0sd(ji,jj)**2 +vt0sd(ji,jj)**2 ) ) 298 298 zWlc2(ji,jj) = 0.5_wp * ( ut0sd(ji,jj)**2 +vt0sd(ji,jj)**2 ) … … 301 301 ! Projection of Stokes drift in the wind stress direction 302 302 ! 303 DO_2D( 0, 0, 0, 0)303 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 304 304 ztaui = 0.5_wp * ( utau(ji,jj) + utau(ji-1,jj) ) 305 305 ztauj = 0.5_wp * ( vtau(ji,jj) + vtau(ji,jj-1) ) … … 307 307 zWlc2(ji,jj) = 0.5_wp * z1_norm * ( MAX( ut0sd(ji,jj)*ztaui + vt0sd(ji,jj)*ztauj, 0._wp ) )**2 308 308 END_2D 309 CALL lbc_lnk ( 'zdftke', zWlc2, 'T', 1. )310 !311 309 ELSE ! Surface Stokes drift deduced from surface stress 312 310 ! ! Wlc = u_s with u_s = 0.016*U_10m, the surface stokes drift (Axell 2002, Eq.44) … … 315 313 ! ! 1/2 Wlc^2 = 0.5 * 0.016 * 0.016 |tau| /( rho_air Cdrag ) 316 314 zcof = 0.5 * 0.016 * 0.016 / ( zrhoa * zcdrag ) ! to convert stress in 10m wind using a constant drag 317 DO_2D( 1, 1, 1,1 )315 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 318 316 zWlc2(ji,jj) = zcof * taum(ji,jj) 319 317 END_2D … … 323 321 ! !* Depth of the LC circulation (Axell 2002, Eq.47) 324 322 ! !- LHS of Eq.47 325 zpelc(:,:,1) = MAX( rn2b(:,:,1), 0._wp ) * gdepw(:,:,1,Kmm) * e3w(:,:,1,Kmm) 326 DO jk = 2, jpk 327 zpelc(:,:,jk) = zpelc(:,:,jk-1) + & 328 & MAX( rn2b(:,:,jk), 0._wp ) * gdepw(:,:,jk,Kmm) * e3w(:,:,jk,Kmm) 329 END DO 323 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 324 zpelc(ji,jj,1) = MAX( rn2b(ji,jj,1), 0._wp ) * gdepw(ji,jj,1,Kmm) * e3w(ji,jj,1,Kmm) 325 END_2D 326 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpk ) 327 zpelc(ji,jj,jk) = zpelc(ji,jj,jk-1) + & 328 & MAX( rn2b(ji,jj,jk), 0._wp ) * gdepw(ji,jj,jk,Kmm) * e3w(ji,jj,jk,Kmm) 329 END_3D 330 330 ! 331 331 ! !- compare LHS to RHS of Eq.47 332 imlc(:,:) = mbkt( :,:) + 1 ! Initialization to the number of w ocean point (=2 over land)333 DO_3DS( 1, 1, 1,1, jpkm1, 2, -1 )332 imlc(:,:) = mbkt(A2D(nn_hls)) + 1 ! Initialization to the number of w ocean point (=2 over land) 333 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpkm1, 2, -1 ) 334 334 IF( zpelc(ji,jj,jk) > zWlc2(ji,jj) ) imlc(ji,jj) = jk 335 335 END_3D 336 336 ! ! finite LC depth 337 DO_2D( 1, 1, 1,1 )337 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 338 338 zhlc(ji,jj) = gdepw(ji,jj,imlc(ji,jj),Kmm) 339 339 END_2D 340 340 ! 341 341 zcof = 0.016 / SQRT( zrhoa * zcdrag ) 342 DO_2D( 0, 0, 0, 0)342 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 343 343 zus = SQRT( 2. * zWlc2(ji,jj) ) ! Stokes drift 344 344 zus3(ji,jj) = MAX( 0._wp, 1._wp - zice_fra(ji,jj) ) * zus * zus * zus * tmask(ji,jj,1) ! zus > 0. ok 345 345 END_2D 346 DO_3D ( 0, 0, 0, 0, 2, jpkm1 ) !* TKE Langmuir circulation source term added to en346 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) !* TKE Langmuir circulation source term added to en 347 347 IF ( zus3(ji,jj) /= 0._wp ) THEN 348 348 IF ( gdepw(ji,jj,jk,Kmm) - zhlc(ji,jj) < 0 .AND. wmask(ji,jj,jk) /= 0. ) THEN … … 365 365 ! 366 366 IF( nn_pdl == 1 ) THEN !* Prandtl number = F( Ri ) 367 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )367 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 368 368 ! ! local Richardson number 369 369 IF (rn2b(ji,jj,jk) <= 0.0_wp) then … … 377 377 ENDIF 378 378 ! 379 DO_3D ( 0, 0, 0, 0, 2, jpkm1 ) !* Matrix and right hand side in en379 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) !* Matrix and right hand side in en 380 380 zcof = zfact1 * tmask(ji,jj,jk) 381 381 ! ! A minimum of 2.e-5 m2/s is imposed on TKE vertical … … 406 406 407 407 CASE ( 0 ) ! Dirichlet BC 408 DO_2D ( 0, 0, 0, 0) ! en(1) = rn_ebb taum / rho0 (min value rn_emin0)408 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! en(1) = rn_ebb taum / rho0 (min value rn_emin0) 409 409 IF ( phioc(ji,jj) < 0 ) phioc(ji,jj) = 0._wp 410 410 en(ji,jj,1) = MAX( rn_emin0, .5 * ( 15.8 * phioc(ji,jj) / rho0 )**(2./3.) ) * tmask(ji,jj,1) … … 413 413 414 414 CASE ( 1 ) ! Neumann BC 415 DO_2D ( 0, 0, 0, 0)415 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 416 416 IF ( phioc(ji,jj) < 0 ) phioc(ji,jj) = 0._wp 417 417 en(ji,jj,2) = en(ji,jj,2) + ( rn_Dt * phioc(ji,jj) / rho0 ) /e3w(ji,jj,2,Kmm) … … 427 427 ! 428 428 ! !* Matrix inversion from level 2 (tke prescribed at level 1) 429 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1429 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1 430 430 zdiag(ji,jj,jk) = zdiag(ji,jj,jk) - zd_lw(ji,jj,jk) * zd_up(ji,jj,jk-1) / zdiag(ji,jj,jk-1) 431 431 END_3D … … 434 434 ! zd_lw(ji,jj,2) = en(ji,jj,2) - zd_lw(ji,jj,2) * en(ji,jj,1) ! Surface boudary conditions on tke 435 435 ! END_2D 436 DO_3D( 0, 0, 0, 0, 2, jpkm1 )436 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 437 437 zd_lw(ji,jj,jk) = en(ji,jj,jk) - zd_lw(ji,jj,jk) / zdiag(ji,jj,jk-1) *zd_lw(ji,jj,jk-1) 438 438 END_3D 439 DO_2D ( 0, 0, 0, 0) ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk439 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk 440 440 en(ji,jj,jpkm1) = zd_lw(ji,jj,jpkm1) / zdiag(ji,jj,jpkm1) 441 441 END_2D 442 DO_3DS ( 0, 0, 0, 0, jpk-2, 2, -1 )442 DO_3DS_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpk-2, 2, -1 ) 443 443 en(ji,jj,jk) = ( zd_lw(ji,jj,jk) - zd_up(ji,jj,jk) * en(ji,jj,jk+1) ) / zdiag(ji,jj,jk) 444 444 END_3D 445 DO_3D ( 0, 0, 0, 0, 2, jpkm1 ) ! set the minimum value of tke445 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! set the minimum value of tke 446 446 en(ji,jj,jk) = MAX( en(ji,jj,jk), rn_emin ) * wmask(ji,jj,jk) 447 447 END_3D … … 456 456 ! 457 457 IF( nn_etau == 1 ) THEN !* penetration below the mixed layer (rn_efr fraction) 458 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )458 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 459 459 en(ji,jj,jk) = en(ji,jj,jk) + rn_efr * en(ji,jj,1) * EXP( -gdepw(ji,jj,jk,Kmm) / htau(ji,jj) ) & 460 460 & * MAX( 0._wp, 1._wp - zice_fra(ji,jj) ) * wmask(ji,jj,jk) * tmask(ji,jj,1) 461 461 END_3D 462 462 ELSEIF( nn_etau == 2 ) THEN !* act only at the base of the mixed layer (jk=nmln) (rn_efr fraction) 463 DO_2D ( 0, 0, 0, 0)463 DO_2D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 464 464 jk = nmln(ji,jj) 465 465 en(ji,jj,jk) = en(ji,jj,jk) + rn_efr * en(ji,jj,1) * EXP( -gdepw(ji,jj,jk,Kmm) / htau(ji,jj) ) & … … 467 467 END_2D 468 468 ELSEIF( nn_etau == 3 ) THEN !* penetration belox the mixed layer (HF variability) 469 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )469 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 470 470 ztx2 = utau(ji-1,jj ) + utau(ji,jj) 471 471 zty2 = vtau(ji ,jj-1) + vtau(ji,jj) … … 524 524 REAL(wp) :: zdku, zdkv, zsqen ! - - 525 525 REAL(wp) :: zemxl, zemlm, zemlp, zmaxice ! - - 526 REAL(wp), DIMENSION( jpi,jpj,jpk) :: zmxlm, zmxld ! 3D workspace526 REAL(wp), DIMENSION(A2D(nn_hls),jpk) :: zmxlm, zmxld ! 3D workspace 527 527 !!-------------------------------------------------------------------- 528 528 ! … … 548 548 zraug = vkarmn * 2.e5_wp / ( rho0 * grav ) 549 549 #if ! defined key_si3 && ! defined key_cice 550 DO_2D( 0, 0, 0, 0) ! No sea-ice550 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) ! No sea-ice 551 551 zmxlm(ji,jj,1) = zraug * taum(ji,jj) * tmask(ji,jj,1) 552 552 END_2D … … 555 555 ! 556 556 CASE( 0 ) ! No scaling under sea-ice 557 DO_2D( 0, 0, 0, 0)557 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 558 558 zmxlm(ji,jj,1) = zraug * taum(ji,jj) * tmask(ji,jj,1) 559 559 END_2D 560 560 ! 561 561 CASE( 1 ) ! scaling with constant sea-ice thickness 562 DO_2D( 0, 0, 0, 0)562 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 563 563 zmxlm(ji,jj,1) = ( ( 1._wp - fr_i(ji,jj) ) * zraug * taum(ji,jj) + & 564 564 & fr_i(ji,jj) * rn_mxlice ) * tmask(ji,jj,1) … … 566 566 ! 567 567 CASE( 2 ) ! scaling with mean sea-ice thickness 568 DO_2D( 0, 0, 0, 0)568 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 569 569 #if defined key_si3 570 570 zmxlm(ji,jj,1) = ( ( 1._wp - fr_i(ji,jj) ) * zraug * taum(ji,jj) + & … … 578 578 ! 579 579 CASE( 3 ) ! scaling with max sea-ice thickness 580 DO_2D( 0, 0, 0, 0)580 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 581 581 zmaxice = MAXVAL( h_i(ji,jj,:) ) 582 582 zmxlm(ji,jj,1) = ( ( 1._wp - fr_i(ji,jj) ) * zraug * taum(ji,jj) + & … … 587 587 #endif 588 588 ! 589 DO_2D( 0, 0, 0, 0)589 DO_2D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1 ) 590 590 zmxlm(ji,jj,1) = MAX( rn_mxl0, zmxlm(ji,jj,1) ) 591 591 END_2D … … 596 596 ENDIF 597 597 ! 598 DO_3D( 0, 0, 0, 0, 2, jpkm1 )598 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 599 599 zrn2 = MAX( rn2(ji,jj,jk), rsmall ) 600 600 zmxlm(ji,jj,jk) = MAX( rmxl_min, SQRT( 2._wp * en(ji,jj,jk) / zrn2 ) ) … … 611 611 ! where wmask = 0 set zmxlm == e3w(:,:,:,Kmm) 612 612 CASE ( 0 ) ! bounded by the distance to surface and bottom 613 DO_3D( 0, 0, 0, 0, 2, jpkm1 )613 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 614 614 zemxl = MIN( gdepw(ji,jj,jk,Kmm) - gdepw(ji,jj,mikt(ji,jj),Kmm), zmxlm(ji,jj,jk), & 615 615 & gdepw(ji,jj,mbkt(ji,jj)+1,Kmm) - gdepw(ji,jj,jk,Kmm) ) … … 622 622 ! 623 623 CASE ( 1 ) ! bounded by the vertical scale factor 624 DO_3D( 0, 0, 0, 0, 2, jpkm1 )624 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 625 625 zemxl = MIN( e3w(ji,jj,jk,Kmm), zmxlm(ji,jj,jk) ) 626 626 zmxlm(ji,jj,jk) = zemxl … … 629 629 ! 630 630 CASE ( 2 ) ! |dk[xml]| bounded by e3t : 631 DO_3D( 0, 0, 0, 0, 2, jpkm1 )! from the surface to the bottom :631 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! from the surface to the bottom : 632 632 zmxlm(ji,jj,jk) = & 633 633 & MIN( zmxlm(ji,jj,jk-1) + e3t(ji,jj,jk-1,Kmm), zmxlm(ji,jj,jk) ) 634 634 END_3D 635 DO_3DS( 0, 0, 0, 0, jpkm1, 2, -1 ) ! from the bottom to the surface :635 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpkm1, 2, -1 ) ! from the bottom to the surface : 636 636 zemxl = MIN( zmxlm(ji,jj,jk+1) + e3t(ji,jj,jk+1,Kmm), zmxlm(ji,jj,jk) ) 637 637 zmxlm(ji,jj,jk) = zemxl … … 640 640 ! 641 641 CASE ( 3 ) ! lup and ldown, |dk[xml]| bounded by e3t : 642 DO_3D( 0, 0, 0, 0, 2, jpkm1 ) ! from the surface to the bottom : lup642 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) ! from the surface to the bottom : lup 643 643 zmxld(ji,jj,jk) = & 644 644 & MIN( zmxld(ji,jj,jk-1) + e3t(ji,jj,jk-1,Kmm), zmxlm(ji,jj,jk) ) 645 645 END_3D 646 DO_3DS( 0, 0, 0, 0, jpkm1, 2, -1 ) ! from the bottom to the surface : ldown646 DO_3DS( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, jpkm1, 2, -1 ) ! from the bottom to the surface : ldown 647 647 zmxlm(ji,jj,jk) = & 648 648 & MIN( zmxlm(ji,jj,jk+1) + e3t(ji,jj,jk+1,Kmm), zmxlm(ji,jj,jk) ) 649 649 END_3D 650 DO_3D( 0, 0, 0, 0, 2, jpkm1 )650 DO_3D( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 651 651 zemlm = MIN ( zmxld(ji,jj,jk), zmxlm(ji,jj,jk) ) 652 652 zemlp = SQRT( zmxld(ji,jj,jk) * zmxlm(ji,jj,jk) ) … … 660 660 ! ! Vertical eddy viscosity and diffusivity (avm and avt) 661 661 ! !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 662 DO_3D ( 0, 0, 0, 0, 1, jpkm1 ) !* vertical eddy viscosity & diffivity at w-points662 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 1, jpkm1 ) !* vertical eddy viscosity & diffivity at w-points 663 663 zsqen = SQRT( en(ji,jj,jk) ) 664 664 zav = rn_ediff * zmxlm(ji,jj,jk) * zsqen … … 670 670 ! 671 671 IF( nn_pdl == 1 ) THEN !* Prandtl number case: update avt 672 DO_3D ( 0, 0, 0, 0, 2, jpkm1 )672 DO_3D_OVR( nn_hls-1, nn_hls-1, nn_hls-1, nn_hls-1, 2, jpkm1 ) 673 673 p_avt(ji,jj,jk) = MAX( apdlr(ji,jj,jk) * p_avt(ji,jj,jk), avtb_2d(ji,jj) * avtb(jk) ) * wmask(ji,jj,jk) 674 674 END_3D … … 786 786 ! 787 787 ! !* Check of some namelist values 788 IF( nn_mxl < 0 .OR. nn_mxl > 3 ) CALL ctl_stop( 'bad flag: nn_mxl is 0, 1 or 2' )789 IF( nn_pdl < 0 .OR. nn_pdl > 1 ) CALL ctl_stop( 'bad flag: nn_pdl is 0 or 1 790 IF( nn_htau < 0 .OR. nn_htau > 1 ) CALL ctl_stop( 'bad flag: nn_htau is 0 , 1 or 2' )788 IF( nn_mxl < 0 .OR. nn_mxl > 3 ) CALL ctl_stop( 'bad flag: nn_mxl is 0, 1, 2 or 3' ) 789 IF( nn_pdl < 0 .OR. nn_pdl > 1 ) CALL ctl_stop( 'bad flag: nn_pdl is 0 or 1' ) 790 IF( nn_htau < 0 .OR. nn_htau > 1 ) CALL ctl_stop( 'bad flag: nn_htau is 0 or 1' ) 791 791 IF( nn_etau == 3 .AND. .NOT. ln_cpl ) CALL ctl_stop( 'nn_etau == 3 : HF taum only known in coupled mode' ) 792 792 ! … … 796 796 rn_mxl0 = rmxl_min 797 797 ENDIF 798 799 IF( nn_etau == 2 ) CALL zdf_mxl( nit000, Kmm ) ! Initialization of nmln800 801 798 ! !* depth of penetration of surface tke 802 799 IF( nn_etau /= 0 ) THEN -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/do_loop_substitute.h90
r14215 r14958 59 59 #endif 60 60 61 #define DO_2D(L, R, B, T) DO jj = ntsj-(B), ntej+(T) ; DO ji = ntsi-(L), ntei+(R) 62 #define A1Di(H) ntsi-H:ntei+H 63 #define A1Dj(H) ntsj-H:ntej+H 61 #define DO_2D(L, R, B, T) DO jj = ntsj-(B), ntej+(T) ; DO ji = ntsi-(L), ntei+(R) 62 #define DO_2D_OVR(L, R, B, T) DO_2D(L-(L+R)*nthl, R-(R+L)*nthr, B-(B+T)*nthb, T-(T+B)*ntht) 63 #define A1Di(H) ntsi-(H):ntei+(H) 64 #define A1Dj(H) ntsj-(H):ntej+(H) 64 65 #define A2D(H) A1Di(H),A1Dj(H) 65 66 #define A1Di_T(T) (ntsi-nn_hls-1)*T+1: … … 70 71 #define KJPT : 71 72 72 #define DO_3D(L, R, B, T, ks, ke) DO jk = ks, ke ; DO_2D(L, R, B, T) 73 #define DO_3D(L, R, B, T, ks, ke) DO jk = ks, ke ; DO_2D(L, R, B, T) 74 #define DO_3D_OVR(L, R, B, T, ks, ke) DO jk = ks, ke ; DO_2D_OVR(L, R, B, T) 73 75 74 #define DO_3DS(L, R, B, T, ks, ke, ki) DO jk = ks, ke, ki ; DO_2D(L, R, B, T) 76 #define DO_3DS(L, R, B, T, ks, ke, ki) DO jk = ks, ke, ki ; DO_2D(L, R, B, T) 77 #define DO_3DS_OVR(L, R, B, T, ks, ke, ki) DO jk = ks, ke, ki ; DO_2D_OVR(L, R, B, T) 75 78 76 79 #define END_2D END DO ; END DO -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/module_example.F90
r14433 r14958 102 102 !!-------------------------------------------------------------------- 103 103 ! 104 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile104 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 105 105 IF( kt == nit000 ) CALL exa_mpl_init ! Initialization (first time-step only) 106 106 … … 175 175 IF( exa_mpl_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'exa_mpl_init : unable to allocate arrays' ) 176 176 ! ! Parameter control 177 IF( ln_tile .AND. ntile > 0) CALL ctl_stop( 'exa_mpl_init: tiling is not supported in this module by default, see manual for how to adapt your code' )177 IF( ln_tile ) CALL ctl_stop( 'exa_mpl_init: tiling is not supported in this module by default, see manual for how to adapt your code' ) 178 178 IF( ln_opt ) CALL ctl_stop( 'exa_mpl_init: this work and option xxx are incompatible' ) 179 179 IF( nn_opt == 2 ) CALL ctl_stop( 'STOP', 'exa_mpl_init: this work and option yyy may cause problems' ) … … 187 187 CONTAINS 188 188 SUBROUTINE exa_mpl( kt, pvar1, pvar2, ptab ) ! Empty routine 189 REAL:: ptab(:,:) 189 INTEGER :: kt 190 REAL:: pvar1, pvar2, ptab(:,:) 190 191 WRITE(*,*) 'exa_mpl: You should not have seen this print! error?', kt, pvar1, pvar2, ptab(1,1) 191 192 END SUBROUTINE exa_mpl -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/nemogcm.F90
r14433 r14958 390 390 CALL mpp_init 391 391 392 #if defined key_loop_fusion 393 IF( nn_hls == 1 ) THEN 394 CALL ctl_stop( 'STOP', 'nemogcm : Loop fusion can be used only with extra-halo' ) 395 ENDIF 396 #endif 397 392 398 CALL halo_mng_init() 393 399 ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/par_oce.F90
r14688 r14958 72 72 INTEGER, PUBLIC :: ntei !: end of internal part of tile domain 73 73 INTEGER, PUBLIC :: ntej ! 74 INTEGER, PUBLIC :: nthl, nthr !: Modifier on DO loop macro bound offset (left, right) 75 INTEGER, PUBLIC :: nthb, ntht !: " " (bottom, top) 74 76 75 77 !!--------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/step.F90
r14553 r14958 174 174 175 175 ! VERTICAL PHYSICS 176 ! lbc_lnk needed for zdf_sh2 when using nn_hls = 2, moved here to allow tiling in zdf_phy 177 IF( nn_hls == 2 .AND. l_zdfsh2 ) CALL lbc_lnk( 'stp', avm_k, 'W', 1.0_wp ) 178 179 IF( ln_tile ) CALL dom_tile_start ! [tiling] ZDF tiling loop 180 DO jtile = 1, nijtile 181 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 182 176 183 CALL zdf_phy( kstp, Nbb, Nnn, Nrhs ) ! vertical physics update (top/bot drag, avt, avs, avm + MLD) 184 END DO 185 IF( ln_tile ) CALL dom_tile_stop 177 186 178 187 ! LATERAL PHYSICS … … 181 190 CALL eos( ts(:,:,:,:,Nbb), rhd, gdept_0(:,:,:) ) ! before in situ density 182 191 183 192 IF( ln_zps .AND. .NOT. ln_isfcav) & 184 193 & CALL zps_hde ( kstp, Nnn, jpts, ts(:,:,:,:,Nbb), gtsu, gtsv, & ! Partial steps: before horizontal gradient 185 194 & rhd, gru , grv ) ! of t, s, rd at the last ocean level 186 195 187 196 IF( ln_zps .AND. ln_isfcav) & 188 197 & CALL zps_hde_isf( kstp, Nnn, jpts, ts(:,:,:,:,Nbb), gtsu, gtsv, gtui, gtvi, & ! Partial steps for top cell (ISF) 189 198 & rhd, gru , grv , grui, grvi ) ! of t, s, rd at the first ocean level … … 213 222 vv(:,:,:,Nrhs) = 0._wp 214 223 215 IF( lk_asminc .AND. ln_asmiau .AND. ln_dyninc ) & 216 & CALL dyn_asm_inc ( kstp, Nbb, Nnn, uu, vv, Nrhs ) ! apply dynamics assimilation increment 217 IF( ln_bdy ) CALL bdy_dyn3d_dmp ( kstp, Nbb, uu, vv, Nrhs ) ! bdy damping trends 218 #if defined key_agrif 224 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (1) 225 DO jtile = 1, nijtile 226 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 227 228 IF( lk_asminc .AND. ln_asmiau .AND. ln_dyninc ) & 229 & CALL dyn_asm_inc ( kstp, Nbb, Nnn, uu, vv, Nrhs ) ! apply dynamics assimilation increment 230 IF( ln_bdy ) CALL bdy_dyn3d_dmp ( kstp, Nbb, uu, vv, Nrhs ) ! bdy damping trends 231 #if defined key_agrif 232 END DO 233 IF( ln_tile ) CALL dom_tile_stop 234 219 235 IF(.NOT. Agrif_Root()) & 220 236 & CALL Agrif_Sponge_dyn ! momentum sponge 221 #endif 222 CALL dyn_adv( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! advection (VF or FF) ==> RHS 223 CALL dyn_vor( kstp, Nnn , uu, vv, Nrhs ) ! vorticity ==> RHS 224 CALL dyn_ldf( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! lateral mixing 225 IF( ln_zdfosm ) CALL dyn_osm( kstp, Nnn , uu, vv, Nrhs ) ! OSMOSIS non-local velocity fluxes ==> RHS 226 CALL dyn_hpg( kstp, Nnn , uu, vv, Nrhs ) ! horizontal gradient of Hydrostatic pressure 227 CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa ) ! surface pressure gradient 237 238 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (1, continued) 239 DO jtile = 1, nijtile 240 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 241 #endif 242 CALL dyn_adv( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! advection (VF or FF) ==> RHS 243 CALL dyn_vor( kstp, Nnn , uu, vv, Nrhs ) ! vorticity ==> RHS 244 CALL dyn_ldf( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! lateral mixing 245 IF( ln_zdfosm ) CALL dyn_osm( kstp, Nnn , uu, vv, Nrhs ) ! OSMOSIS non-local velocity fluxes ==> RHS 246 CALL dyn_hpg( kstp, Nnn , uu, vv, Nrhs ) ! horizontal gradient of Hydrostatic pressure 247 END DO 248 IF( ln_tile ) CALL dom_tile_stop 249 250 CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa ) ! surface pressure gradient 228 251 229 252 ! With split-explicit free surface, since now transports have been updated and ssh(:,:,Nrhs) as well 230 253 IF( ln_dynspg_ts ) THEN ! vertical scale factors and vertical velocity need to be updated 231 CALL div_hor ( kstp, Nbb, Nnn ) ! Horizontal divergence (2nd call in time-split case) 232 IF(.NOT.ln_linssh) CALL dom_vvl_sf_nxt( kstp, Nbb, Nnn, Naa, kcall=2 ) ! after vertical scale factors (update depth average component) 233 ENDIF 234 CALL dyn_zdf ( kstp, Nbb, Nnn, Nrhs, uu, vv, Naa ) ! vertical diffusion 254 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (2- div_hor only) 255 DO jtile = 1, nijtile 256 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 257 258 CALL div_hor ( kstp, Nbb, Nnn ) ! Horizontal divergence (2nd call in time-split case) 259 END DO 260 IF( ln_tile ) CALL dom_tile_stop 261 262 IF(.NOT. ln_linssh) CALL dom_vvl_sf_nxt( kstp, Nbb, Nnn, Naa, kcall=2 ) ! after vertical scale factors (update depth average component) 263 ENDIF 264 265 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (3- dyn_zdf only) 266 DO jtile = 1, nijtile 267 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 268 269 CALL dyn_zdf ( kstp, Nbb, Nnn, Nrhs, uu, vv, Naa ) ! vertical diffusion 270 END DO 271 IF( ln_tile ) CALL dom_tile_stop 272 235 273 IF( ln_dynspg_ts ) THEN ! vertical scale factors and vertical velocity need to be updated 236 274 CALL wzv ( kstp, Nbb, Nnn, Naa, ww ) ! Nnn cross-level velocity … … 268 306 ! Active tracers 269 307 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 270 ! Loop over tile domains 271 DO jtile = 1, nijtile 272 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 273 274 DO_3D( 0, 0, 0, 0, 1, jpk ) 275 ts(ji,jj,jk,:,Nrhs) = 0._wp ! set tracer trends to zero 276 END_3D 308 ts(:,:,:,:,Nrhs) = 0._wp ! set tracer trends to zero 309 310 IF( ln_tile ) CALL dom_tile_start ! [tiling] TRA tiling loop (1) 311 DO jtile = 1, nijtile 312 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 277 313 278 314 IF( lk_asminc .AND. ln_asmiau .AND. & … … 286 322 IF( ln_bdy ) CALL bdy_tra_dmp( kstp, Nbb, ts, Nrhs ) ! bdy damping trends 287 323 END DO 324 IF( ln_tile ) CALL dom_tile_stop 288 325 289 326 #if defined key_agrif 290 327 IF(.NOT. Agrif_Root() ) THEN 291 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )292 328 CALL Agrif_Sponge_tra ! tracers sponge 293 329 ENDIF … … 295 331 296 332 ! TEMP: [tiling] Separate loop over tile domains (due to tra_adv workarounds for tiling) 297 DO jtile = 1, nijtile 298 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 333 IF( ln_tile ) CALL dom_tile_start ! [tiling] TRA tiling loop (2) 334 DO jtile = 1, nijtile 335 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 299 336 300 337 CALL tra_adv ( kstp, Nbb, Nnn, ts, Nrhs ) ! hor. + vert. advection ==> RHS … … 309 346 IF( ln_zdfnpc ) CALL tra_npc ( kstp, Nnn, Nrhs, ts, Naa ) ! update after fields by non-penetrative convection 310 347 END DO 311 312 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Revert to tile over full domain 348 IF( ln_tile ) CALL dom_tile_stop 349 313 350 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 314 351 ! Set boundary conditions, time filter and swap time levels -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/stpmlf.F90
r14553 r14958 62 62 # include "do_loop_substitute.h90" 63 63 # include "domzgr_substitute.h90" 64 # include "do_loop_substitute.h90"65 64 !!---------------------------------------------------------------------- 66 65 !! NEMO/OCE 4.0 , NEMO Consortium (2018) … … 182 181 183 182 ! VERTICAL PHYSICS 183 IF( ln_tile ) CALL dom_tile_start ! [tiling] ZDF tiling loop 184 DO jtile = 1, nijtile 185 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 184 186 CALL zdf_phy( kstp, Nbb, Nnn, Nrhs ) ! vertical physics update (top/bot drag, avt, avs, avm + MLD) 187 END DO 188 IF( ln_tile ) CALL dom_tile_stop 185 189 186 190 ! LATERAL PHYSICS … … 189 193 CALL eos( ts(:,:,:,:,Nbb), rhd, gdept_0(:,:,:) ) ! before in situ density 190 194 191 195 IF( ln_zps .AND. .NOT. ln_isfcav) & 192 196 & CALL zps_hde ( kstp, Nnn, jpts, ts(:,:,:,:,Nbb), gtsu, gtsv, & ! Partial steps: before horizontal gradient 193 197 & rhd, gru , grv ) ! of t, s, rd at the last ocean level 194 198 195 199 IF( ln_zps .AND. ln_isfcav) & 196 200 & CALL zps_hde_isf( kstp, Nnn, jpts, ts(:,:,:,:,Nbb), gtsu, gtsv, gtui, gtvi, & ! Partial steps for top cell (ISF) 197 201 & rhd, gru , grv , grui, grvi ) ! of t, s, rd at the first ocean level … … 228 232 vv(:,:,:,Nrhs) = 0._wp 229 233 230 IF( lk_asminc .AND. ln_asmiau .AND. ln_dyninc ) & 231 & CALL dyn_asm_inc ( kstp, Nbb, Nnn, uu, vv, Nrhs ) ! apply dynamics assimilation increment 232 IF( ln_bdy ) CALL bdy_dyn3d_dmp ( kstp, Nbb, uu, vv, Nrhs ) ! bdy damping trends 233 #if defined key_agrif 234 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (1) 235 DO jtile = 1, nijtile 236 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 237 238 IF( lk_asminc .AND. ln_asmiau .AND. ln_dyninc ) & 239 & CALL dyn_asm_inc ( kstp, Nbb, Nnn, uu, vv, Nrhs ) ! apply dynamics assimilation increment 240 IF( ln_bdy ) CALL bdy_dyn3d_dmp ( kstp, Nbb, uu, vv, Nrhs ) ! bdy damping trends 241 #if defined key_agrif 242 END DO 243 IF( ln_tile ) CALL dom_tile_stop 244 234 245 IF(.NOT. Agrif_Root()) & 235 246 & CALL Agrif_Sponge_dyn ! momentum sponge 236 #endif 237 CALL dyn_adv( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! advection (VF or FF) ==> RHS 238 CALL dyn_vor( kstp, Nnn , uu, vv, Nrhs ) ! vorticity ==> RHS 239 CALL dyn_ldf( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! lateral mixing 240 IF( ln_zdfosm ) CALL dyn_osm( kstp, Nnn , uu, vv, Nrhs ) ! OSMOSIS non-local velocity fluxes ==> RHS 241 CALL dyn_hpg( kstp, Nnn , uu, vv, Nrhs ) ! horizontal gradient of Hydrostatic pressure 242 CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa ) ! surface pressure gradient 243 244 IF( ln_dynspg_ts ) THEN ! With split-explicit free surface, since now transports have been updated and ssh(:,:,Nrhs) 245 ! as well as vertical scale factors and vertical velocity need to be updated 246 CALL div_hor ( kstp, Nbb, Nnn ) ! Horizontal divergence (2nd call in time-split case) 247 IF(.NOT.lk_linssh) CALL dom_qco_r3c( ssh(:,:,Naa), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa), r3f(:,:) ) ! update ssh/h_0 ratio at t,u,v,f pts 248 ENDIF 247 248 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (1, continued) 249 DO jtile = 1, nijtile 250 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 251 #endif 252 CALL dyn_adv( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! advection (VF or FF) ==> RHS 253 CALL dyn_vor( kstp, Nnn , uu, vv, Nrhs ) ! vorticity ==> RHS 254 CALL dyn_ldf( kstp, Nbb, Nnn , uu, vv, Nrhs ) ! lateral mixing 255 IF( ln_zdfosm ) CALL dyn_osm( kstp, Nnn , uu, vv, Nrhs ) ! OSMOSIS non-local velocity fluxes ==> RHS 256 CALL dyn_hpg( kstp, Nnn , uu, vv, Nrhs ) ! horizontal gradient of Hydrostatic pressure 257 END DO 258 IF( ln_tile ) CALL dom_tile_stop 259 260 CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa ) ! surface pressure gradient 261 262 IF( ln_tile ) CALL dom_tile_start ! [tiling] DYN tiling loop (2) 263 DO jtile = 1, nijtile 264 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 265 266 IF( ln_dynspg_ts ) THEN ! With split-explicit free surface, since now transports have been updated and ssh(:,:,Nrhs) 267 ! as well as vertical scale factors and vertical velocity need to be updated 268 CALL div_hor ( kstp, Nbb, Nnn ) ! Horizontal divergence (2nd call in time-split case) 269 IF(.NOT.lk_linssh) CALL dom_qco_r3c( ssh(:,:,Naa), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa), r3f(:,:) ) ! update ssh/h_0 ratio at t,u,v,f pts 270 ENDIF 249 271 CALL dyn_zdf ( kstp, Nbb, Nnn, Nrhs, uu, vv, Naa ) ! vertical diffusion 272 END DO 273 IF( ln_tile ) CALL dom_tile_stop 274 250 275 IF( ln_dynspg_ts ) THEN ! vertical scale factors and vertical velocity need to be updated 251 276 CALL wzv ( kstp, Nbb, Nnn, Naa, ww ) ! Nnn cross-level velocity … … 288 313 ! Active tracers 289 314 !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 290 ! Loop over tile domains 315 ts(:,:,:,:,Nrhs) = 0._wp ! set tracer trends to zero 316 317 IF( ln_tile ) CALL dom_tile_start ! [tiling] TRA tiling loop (1) 291 318 DO jtile = 1, nijtile 292 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 293 294 DO_3D( 0, 0, 0, 0, 1, jpk ) 295 ts(ji,jj,jk,:,Nrhs) = 0._wp ! set tracer trends to zero 296 END_3D 319 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 297 320 298 321 IF( lk_asminc .AND. ln_asmiau .AND. & … … 306 329 IF( ln_bdy ) CALL bdy_tra_dmp( kstp, Nbb, ts, Nrhs ) ! bdy damping trends 307 330 END DO 331 IF( ln_tile ) CALL dom_tile_stop 308 332 309 333 #if defined key_agrif 310 334 IF(.NOT. Agrif_Root() ) THEN 311 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )312 335 CALL Agrif_Sponge_tra ! tracers sponge 313 336 ENDIF … … 315 338 316 339 ! TEMP: [tiling] Separate loop over tile domains (due to tra_adv workarounds for tiling) 340 IF( ln_tile ) CALL dom_tile_start ! [tiling] TRA tiling loop (2) 317 341 DO jtile = 1, nijtile 318 IF( ln_tile )CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )342 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile ) 319 343 320 344 CALL tra_adv ( kstp, Nbb, Nnn, ts, Nrhs ) ! hor. + vert. advection ==> RHS … … 329 353 IF( ln_zdfnpc ) CALL tra_npc ( kstp, Nnn, Nrhs, ts, Naa ) ! update after fields by non-penetrative convection 330 354 END DO 331 332 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Revert to tile over full domain 355 IF( ln_tile ) CALL dom_tile_stop 356 333 357 !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 334 358 ! Set boundary conditions, time filter and swap time levels … … 516 540 & , pts(:,:,:,jp_tem,Kaa), 'T', 1., pts(:,:,:,jp_sal,Kaa), 'T', 1. ) 517 541 ! 542 ! lbc_lnk needed for zdf_sh2 when using nn_hls = 2, moved here to allow tiling in zdf_phy 543 IF( nn_hls == 2 .AND. l_zdfsh2 ) CALL lbc_lnk( 'stp', avm_k, 'W', 1.0_wp ) 544 545 ! dom_qco_r3c defines over [nn_hls, nn_hls-1, nn_hls, nn_hls-1] 546 IF( nn_hls == 2 .AND. .NOT. lk_linssh ) THEN 547 CALL lbc_lnk( 'finalize_lbc', r3u(:,:,Kaa), 'U', 1._wp, r3v(:,:,Kaa), 'V', 1._wp, & 548 & r3u_f(:,:), 'U', 1._wp, r3v_f(:,:), 'V', 1._wp ) 549 ENDIF 518 550 ! !* BDY open boundaries 519 551 IF( ln_bdy ) THEN -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OCE/timing.F90
r14229 r14958 109 109 110 110 s_timer%l_tdone = .FALSE. 111 IF( ntile == 0.OR. ntile == 1 ) s_timer%niter = s_timer%niter + 1 ! All tiles count as one iteration111 IF( .NOT. l_istiled .OR. ntile == 1 ) s_timer%niter = s_timer%niter + 1 ! All tiles count as one iteration 112 112 s_timer%t_cpu = 0. 113 113 s_timer%t_clock = 0. -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/OFF/nemogcm.F90
r14433 r14958 323 323 CALL mpp_init 324 324 325 #if defined key_loop_fusion 326 IF( nn_hls == 1 ) THEN 327 CALL ctl_stop( 'STOP', 'nemogcm : Loop fusion can be used only with extra-halo' ) 328 ENDIF 329 #endif 330 325 331 CALL halo_mng_init() 326 332 ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/SAS/nemogcm.F90
r14433 r14958 352 352 CALL mpp_init 353 353 354 #if defined key_loop_fusion 355 IF( nn_hls == 1 ) THEN 356 CALL ctl_stop( 'STOP', 'nemogcm : Loop fusion can be used only with extra-halo' ) 357 ENDIF 358 #endif 359 354 360 CALL halo_mng_init() 355 361 ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/SWE/nemogcm.F90
r14433 r14958 273 273 CALL mpp_init 274 274 275 #if defined key_loop_fusion 276 IF( nn_hls == 1 ) THEN 277 CALL ctl_stop( 'STOP', 'nemogcm : Loop fusion can be used only with extra-halo' ) 278 ENDIF 279 #endif 280 275 281 CALL halo_mng_init() 276 282 ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/SWE/stprk3.F90
r14433 r14958 172 172 ! 173 173 CALL lbc_lnk( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. ) 174 IF (nn_hls==2) CALL lbc_lnk( 'stp_MLF', r3u(:,:,Naa), 'U', 1., r3v(:,:,Naa), 'U', 1.) 174 175 ! 175 176 ! !== Swap time levels ==! … … 237 238 ! 238 239 CALL lbc_lnk( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. ) 240 IF (nn_hls==2) CALL lbc_lnk( 'stp_MLF', r3u(:,:,Naa), 'U', 1., r3v(:,:,Naa), 'U', 1.) 239 241 ! 240 242 ! !== Swap time levels ==! … … 300 302 ! 301 303 CALL lbc_lnk( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. ) 304 IF (nn_hls==2) CALL lbc_lnk( 'stp_MLF', r3u(:,:,Naa), 'U', 1., r3v(:,:,Naa), 'U', 1.) 302 305 ! 303 306 ! !== Swap time levels ==! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/TOP/AGE/trcnam_age.F90
r12377 r14958 53 53 ln_trc_cbc(jp_age) = .false. 54 54 ln_trc_obc(jp_age) = .false. 55 ln_trc_ais(jp_age) = .false. 55 56 ! 56 57 READ ( numnat_ref, namage, IOSTAT = ios, ERR = 901) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/TOP/C14/trcnam_c14.F90
r12377 r14958 60 60 ln_trc_cbc(jp_c14) = .false. 61 61 ln_trc_obc(jp_c14) = .false. 62 ln_trc_ais(jp_c14) = .false. 62 63 ! 63 64 READ ( numtrc_ref, namc14_typ, IOSTAT = ios, ERR = 901) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/TOP/CFC/trcnam_cfc.F90
r12377 r14958 77 77 ln_trc_cbc(jn) = .false. 78 78 ln_trc_obc(jn) = .false. 79 ln_trc_ais(jn) = .false. 79 80 ENDIF 80 81 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/TOP/TRP/trcadv.F90
r14544 r14958 23 23 USE traadv_cen ! centered scheme (tra_adv_cen routine) 24 24 USE traadv_fct ! FCT scheme (tra_adv_fct routine) 25 USE traadv_fct_lf ! FCT scheme (tra_adv_fct routine - loop fusion version)26 25 USE traadv_mus ! MUSCL scheme (tra_adv_mus routine) 27 USE traadv_mus_lf ! MUSCL scheme (tra_adv_mus routine - loop fusion version)28 26 USE traadv_ubs ! UBS scheme (tra_adv_ubs routine) 29 27 USE traadv_qck ! QUICKEST scheme (tra_adv_qck routine) … … 127 125 ! 128 126 CASE ( np_CEN ) ! Centered : 2nd / 4th order 129 IF (nn_hls.EQ.2) CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kmm), 'T', 1.)130 127 CALL tra_adv_cen( kt, nittrc000,'TRC', zuu, zvv, zww, Kmm, ptr, jptra, Krhs, nn_cen_h, nn_cen_v ) 131 128 CASE ( np_FCT ) ! FCT : 2nd / 4th order 132 IF (nn_hls.EQ.2) THEN133 CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1., ptr(:,:,:,:,Kmm), 'T', 1.)134 CALL lbc_lnk( 'traadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1., zww(:,:,:), 'W', 1.)135 #if defined key_loop_fusion136 CALL tra_adv_fct_lf( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_fct_h, nn_fct_v )137 #else138 129 CALL tra_adv_fct( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_fct_h, nn_fct_v ) 139 #endif140 ELSE141 CALL tra_adv_fct( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_fct_h, nn_fct_v )142 END IF143 130 CASE ( np_MUS ) ! MUSCL 144 IF (nn_hls.EQ.2) THEN 145 CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1.) 146 #if defined key_loop_fusion 147 CALL tra_adv_mus_lf( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups ) 148 #else 149 CALL tra_adv_mus( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups ) 150 #endif 151 ELSE 152 CALL tra_adv_mus( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups ) 153 END IF 131 CALL tra_adv_mus( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups ) 154 132 CASE ( np_UBS ) ! UBS 155 IF (nn_hls.EQ.2) CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1.)156 133 CALL tra_adv_ubs( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_ubs_v ) 157 134 CASE ( np_QCK ) ! QUICKEST 158 IF (nn_hls.EQ.2) THEN159 CALL lbc_lnk( 'trcadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1.)160 CALL lbc_lnk( 'traadv', ptr(:,:,:,:,Kbb), 'T', 1.)161 END IF162 135 CALL tra_adv_qck( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs ) 163 136 ! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/TOP/TRP/trcldf.F90
r14086 r14958 83 83 zahv(:,:,:) = rldf * ahtv(:,:,:) 84 84 ! !* Enhanced zonal diffusivity coefficent in the equatorial domain 85 DO_3D( 1, 1, 1, 1, 1, jpk )85 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpk ) 86 86 IF( gdept(ji,jj,jk,Kmm) > 200. .AND. gphit(ji,jj) < 5. .AND. gphit(ji,jj) > -5. ) THEN 87 87 zdep = MAX( gdept(ji,jj,jk,Kmm) - 1000., 0. ) / 1000. … … 102 102 & ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Kbb), ptr(:,:,:,:,Krhs), jptra, 1 ) 103 103 CASE ( np_blp , np_blp_i , np_blp_it ) ! bilaplacian: all operator (iso-level, -neutral) 104 IF(nn_hls.EQ.2) CALL lbc_lnk( 'trc_ldf', ptr(:,:,:,:,Kbb), 'T',1.)105 104 CALL tra_ldf_blp ( kt, Kmm, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, & 106 105 & ptr(:,:,:,:,Kbb) , ptr(:,:,:,:,Krhs), jptra, nldf_trc ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/src/TOP/trcdta.F90
r14086 r14958 195 195 WRITE(numout,*) 'trc_dta: interpolates passive tracer data onto the s- or mixed s-z-coordinate mesh' 196 196 ENDIF 197 DO_2D( 1, 1, 1, 1) ! vertical interpolation of T & S197 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! vertical interpolation of T & S 198 198 DO jk = 1, jpk ! determines the intepolated T-S profiles at each (i,j) points 199 199 zl = gdept_0(ji,jj,jk) … … 220 220 ! zps-coordinate (partial steps) interpolation at the last ocean level 221 221 IF( ln_zps ) THEN 222 DO_2D( 1, 1, 1, 1 )222 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 223 223 ik = mbkt(ji,jj) 224 224 IF( ik > 1 ) THEN -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/CANAL/EXPREF/namelist_cfg
r14433 r14958 76 76 cn_domcfg_out = "domain_cfg" ! newly created domain configuration filename 77 77 / 78 !----------------------------------------------------------------------- 79 &namtile ! parameters of the tiling 80 !----------------------------------------------------------------------- 81 / 78 82 !!====================================================================== 79 83 !! *** Surface Boundary Condition namelists *** !! -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/CPL_OASIS/EXPREF/namelist_cfg
r14229 r14958 38 38 ln_closea = .false. ! F => suppress closed seas (defined by closea_mask field) 39 39 ! ! from the bathymetry at runtime. 40 / 41 !----------------------------------------------------------------------- 42 &namtile ! parameters of the tiling 43 !----------------------------------------------------------------------- 40 44 / 41 45 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/DOME/EXPREF/1_namelist_cfg
r14254 r14958 42 42 cn_domcfg = "DOME_domcfg" ! domain configuration filename 43 43 ! 44 / 45 !----------------------------------------------------------------------- 46 &namtile ! parameters of the tiling 47 !----------------------------------------------------------------------- 44 48 / 45 49 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/DOME/EXPREF/namelist_cfg
r14254 r14958 30 30 cn_domcfg = "DOME_domcfg" ! domain configuration filename 31 31 ! 32 / 33 !----------------------------------------------------------------------- 34 &namtile ! parameters of the tiling 35 !----------------------------------------------------------------------- 32 36 / 33 37 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/DONUT/EXPREF/namelist_cfg
r14226 r14958 27 27 ! ! (=F) user defined configuration (F => create/check namusr_def) 28 28 cn_domcfg = "donut_cfg" ! domain configuration filename 29 / 30 !----------------------------------------------------------------------- 31 &namtile ! parameters of the tiling 32 !----------------------------------------------------------------------- 29 33 / 30 34 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ICB/EXPREF/namelist_cfg
r14229 r14958 48 48 !----------------------------------------------------------------------- 49 49 &namcfg ! parameters of the configuration (default: use namusr_def in namelist_cfg) 50 !----------------------------------------------------------------------- 51 / 52 !----------------------------------------------------------------------- 53 &namtile ! parameters of the tiling 50 54 !----------------------------------------------------------------------- 51 55 / -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ICE_ADV1D/EXPREF/namelist_cfg
r14229 r14958 49 49 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 50 50 cn_domcfg = "ICE_ADV1D_domcfg" ! domain configuration filename 51 / 52 !----------------------------------------------------------------------- 53 &namtile ! parameters of the tiling 54 !----------------------------------------------------------------------- 51 55 / 52 56 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ICE_ADV2D/EXPREF/namelist_cfg
r14229 r14958 49 49 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 50 50 cn_domcfg = "ICE_ADV2D_domcfg" ! domain configuration filename 51 / 52 !----------------------------------------------------------------------- 53 &namtile ! parameters of the tiling 54 !----------------------------------------------------------------------- 51 55 / 52 56 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ICE_AGRIF/EXPREF/1_namelist_cfg
r14229 r14958 49 49 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 50 50 cn_domcfg = "ICE_AGRIF_domcfg" ! domain configuration filename 51 / 52 !----------------------------------------------------------------------- 53 &namtile ! parameters of the tiling 54 !----------------------------------------------------------------------- 51 55 / 52 56 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ICE_AGRIF/EXPREF/namelist_cfg
r14229 r14958 49 49 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 50 50 cn_domcfg = "ICE_AGRIF_domcfg" ! domain configuration filename 51 / 52 !----------------------------------------------------------------------- 53 &namtile ! parameters of the tiling 54 !----------------------------------------------------------------------- 51 55 / 52 56 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ICE_RHEO/EXPREF/namelist_cfg
r14229 r14958 48 48 ln_read_cfg = .false. ! (=T) read the domain configuration file 49 49 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 50 / 51 !----------------------------------------------------------------------- 52 &namtile ! parameters of the tiling 53 !----------------------------------------------------------------------- 50 54 / 51 55 !!====================================================================== -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ISOMIP+/EXPREF/namelist_cfg
r14229 r14958 50 50 !----------------------------------------------------------------------- 51 51 ln_read_cfg = .true. ! (=T) read the domain configuration file 52 / 53 !----------------------------------------------------------------------- 54 &namtile ! parameters of the tiling 55 !----------------------------------------------------------------------- 52 56 / 53 57 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ISOMIP+/MY_SRC/dtatsd.F90
r14090 r14958 168 168 INTEGER :: ji, jj, jk, jl, jkk ! dummy loop indicies 169 169 INTEGER :: ik, il0, il1, ii0, ii1, ij0, ij1 ! local integers 170 INTEGER :: itile171 170 REAL(wp):: zl, zi ! local scalars 172 171 REAL(wp), DIMENSION(jpk) :: ztp, zsp ! 1D workspace 173 172 !!---------------------------------------------------------------------- 174 173 ! 175 IF( ntile == 0 .OR. ntile == 1 ) THEN ! Do only for the full domain 176 itile = ntile 177 IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Use full domain 174 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only for the full domain 175 IF( ln_tile ) CALL dom_tile_stop( ldhold=.TRUE. ) ! Use full domain 178 176 179 177 SELECT CASE(cddta) … … 186 184 END SELECT 187 185 188 IF( ln_tile ) CALL dom_tile ( ntsi, ntsj, ntei, ntej, ktile = itile) ! Revert to tile domain186 IF( ln_tile ) CALL dom_tile_start( ldhold=.TRUE. ) ! Revert to tile domain 189 187 ENDIF 190 188 ! … … 206 204 IF( ln_sco ) THEN !== s- or mixed s-zps-coordinate ==! 207 205 ! 208 IF( ntile == 0.OR. ntile == 1 ) THEN ! Do only on the first tile206 IF( .NOT. l_istiled .OR. ntile == 1 ) THEN ! Do only on the first tile 209 207 IF( kt == nit000 .AND. lwp )THEN 210 208 WRITE(numout,*) … … 213 211 ENDIF 214 212 ! 215 DO_2D( 1, 1, 1, 1) ! vertical interpolation of T & S213 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! vertical interpolation of T & S 216 214 DO jk = 1, jpk ! determines the intepolated T-S profiles at each (i,j) points 217 215 zl = gdept_0(ji,jj,jk) … … 248 246 ! 249 247 IF( ln_zps ) THEN ! zps-coordinate (partial steps) interpolation at the last ocean level 250 DO_2D( 1, 1, 1, 1)248 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 251 249 ik = mbkt(ji,jj) 252 250 IF( ik > 1 ) THEN -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ISOMIP+/MY_SRC/eosbn2.F90
r14135 r14958 256 256 CASE( np_teos10, np_eos80 ) !== polynomial TEOS-10 / EOS-80 ==! 257 257 ! 258 DO_3D( 1, 1, 1, 1, 1, jpkm1 )258 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 259 259 ! 260 260 zh = pdep(ji,jj,jk) * r1_Z0 ! depth … … 292 292 CASE( np_seos ) !== simplified EOS ==! 293 293 ! 294 DO_3D( 1, 1, 1, 1, 1, jpkm1 )294 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 295 295 zt = pts (ji,jj,jk,jp_tem) - 10._wp 296 296 zs = pts (ji,jj,jk,jp_sal) - 35._wp … … 307 307 CASE( np_leos ) !== linear ISOMIP EOS ==! 308 308 ! 309 DO_3D( 1, 1, 1, 1, 1, jpkm1 )309 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 310 310 zt = pts (ji,jj,jk,jp_tem) - (-1._wp) 311 311 zs = pts (ji,jj,jk,jp_sal) - 34.2_wp … … 382 382 END DO 383 383 ! 384 DO_3D( 1, 1, 1, 1, 1, jpkm1 )384 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 385 385 ! 386 386 ! compute density (2*nn_sto_eos) times: … … 432 432 ! Non-stochastic equation of state 433 433 ELSE 434 DO_3D( 1, 1, 1, 1, 1, jpkm1 )434 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 435 435 ! 436 436 zh = pdep(ji,jj,jk) * r1_Z0 ! depth … … 470 470 CASE( np_seos ) !== simplified EOS ==! 471 471 ! 472 DO_3D( 1, 1, 1, 1, 1, jpkm1 )472 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 473 473 zt = pts (ji,jj,jk,jp_tem) - 10._wp 474 474 zs = pts (ji,jj,jk,jp_sal) - 35._wp … … 488 488 CASE( np_leos ) !== linear ISOMIP EOS ==! 489 489 ! 490 DO_3D( 1, 1, 1, 1, 1, jpkm1 )490 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 491 491 zt = pts (ji,jj,jk,jp_tem) - (-1._wp) 492 492 zs = pts (ji,jj,jk,jp_sal) - 34.2_wp … … 551 551 CASE( np_teos10, np_eos80 ) !== polynomial TEOS-10 / EOS-80 ==! 552 552 ! 553 DO_2D( 1, 1, 1, 1)553 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 554 554 ! 555 555 zh = pdep(ji,jj) * r1_Z0 ! depth … … 586 586 CASE( np_seos ) !== simplified EOS ==! 587 587 ! 588 DO_2D( 1, 1, 1, 1)588 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 589 589 ! 590 590 zt = pts (ji,jj,jp_tem) - 10._wp … … 602 602 CASE( np_leos ) !== ISOMIP EOS ==! 603 603 ! 604 DO_2D( 1, 1, 1, 1)604 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 605 605 ! 606 606 zt = pts (ji,jj,jp_tem) - (-1._wp) … … 625 625 626 626 SUBROUTINE eos_insitu_pot_2d( pts, prhop ) 627 !! 628 REAL(wp), DIMENSION(:,:,:), INTENT(in ) :: pts ! 1 : potential temperature [Celsius] 629 ! ! 2 : salinity [psu] 630 REAL(wp), DIMENSION(:,:) , INTENT( out) :: prhop ! potential density (surface referenced) 631 !! 632 CALL eos_insitu_pot_2d_t( pts, is_tile(pts), prhop, is_tile(prhop) ) 633 END SUBROUTINE eos_insitu_pot_2d 634 635 636 SUBROUTINE eos_insitu_pot_2d_t( pts, ktts, prhop, ktrhop ) 627 637 !!---------------------------------------------------------------------- 628 638 !! *** ROUTINE eos_insitu_pot *** … … 637 647 !! 638 648 !!---------------------------------------------------------------------- 639 REAL(wp), DIMENSION(jpi,jpj,jpts), INTENT(in ) :: pts ! 1 : potential temperature [Celsius] 649 INTEGER , INTENT(in ) :: ktts, ktrhop 650 REAL(wp), DIMENSION(A2D_T(ktts),JPTS), INTENT(in ) :: pts ! 1 : potential temperature [Celsius] 640 651 ! ! 2 : salinity [psu] 641 REAL(wp), DIMENSION( jpi,jpj), INTENT( out) :: prhop ! potential density (surface referenced)652 REAL(wp), DIMENSION(A2D_T(ktrhop) ), INTENT( out) :: prhop ! potential density (surface referenced) 642 653 ! 643 654 INTEGER :: ji, jj, jk, jsmp ! dummy loop indices … … 654 665 CASE( np_teos10, np_eos80 ) !== polynomial TEOS-10 / EOS-80 ==! 655 666 ! 656 DO_2D( 1, 1, 1, 1)667 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 657 668 ! 658 669 zt = pts (ji,jj,jp_tem) * r1_T0 ! temperature … … 675 686 CASE( np_seos ) !== simplified EOS ==! 676 687 ! 677 DO_2D( 1, 1, 1, 1)688 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 678 689 zt = pts (ji,jj,jp_tem) - 10._wp 679 690 zs = pts (ji,jj,jp_sal) - 35._wp … … 689 700 CASE( np_leos ) !== ISOMIP EOS ==! 690 701 ! 691 DO_2D( 1, 1, 1, 1)702 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 692 703 ! 693 704 zt = pts (ji,jj,jp_tem) - (-1._wp) … … 707 718 IF( ln_timing ) CALL timing_stop('eos-pot') 708 719 ! 709 END SUBROUTINE eos_insitu_pot_2d 720 END SUBROUTINE eos_insitu_pot_2d_t 710 721 711 722 … … 746 757 CASE( np_teos10, np_eos80 ) !== polynomial TEOS-10 / EOS-80 ==! 747 758 ! 748 DO_3D( 1, 1, 1, 1, 1, jpkm1 )759 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 749 760 ! 750 761 zh = gdept(ji,jj,jk,Kmm) * r1_Z0 ! depth … … 799 810 CASE( np_seos ) !== simplified EOS ==! 800 811 ! 801 DO_3D( 1, 1, 1, 1, 1, jpkm1 )812 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 802 813 zt = pts (ji,jj,jk,jp_tem) - 10._wp ! pot. temperature anomaly (t-T0) 803 814 zs = pts (ji,jj,jk,jp_sal) - 35._wp ! abs. salinity anomaly (s-S0) … … 815 826 CASE( np_leos ) !== linear ISOMIP EOS ==! 816 827 ! 817 DO_3D( 1, 1, 1, 1, 1, jpkm1 )828 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 818 829 zt = pts (ji,jj,jk,jp_tem) - (-1._wp) 819 830 zs = pts (ji,jj,jk,jp_sal) - 34.2_wp ! abs. salinity anomaly (s-S0) … … 881 892 CASE( np_teos10, np_eos80 ) !== polynomial TEOS-10 / EOS-80 ==! 882 893 ! 883 DO_2D( 1, 1, 1, 1)894 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 884 895 ! 885 896 zh = pdep(ji,jj) * r1_Z0 ! depth … … 934 945 CASE( np_seos ) !== simplified EOS ==! 935 946 ! 936 DO_2D( 1, 1, 1, 1)947 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 937 948 ! 938 949 zt = pts (ji,jj,jp_tem) - 10._wp ! pot. temperature anomaly (t-T0) … … 950 961 CASE( np_leos ) !== linear ISOMIP EOS ==! 951 962 ! 952 DO_2D( 1, 1, 1, 1)963 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 953 964 ! 954 965 zt = pts (ji,jj,jp_tem) - (-1._wp) ! pot. temperature anomaly (t-T0) … … 1124 1135 IF( ln_timing ) CALL timing_start('bn2') 1125 1136 ! 1126 DO_3D( 1, 1, 1, 1, 2, jpkm1 ) ! interior points only (2=< jk =< jpkm1 ); surface and bottom value set to zero one for all in istate.F901137 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 2, jpkm1 ) ! interior points only (2=< jk =< jpkm1 ); surface and bottom value set to zero one for all in istate.F90 1127 1138 zrw = ( gdepw(ji,jj,jk ,Kmm) - gdept(ji,jj,jk,Kmm) ) & 1128 1139 & / ( gdept(ji,jj,jk-1,Kmm) - gdept(ji,jj,jk,Kmm) ) … … 1418 1429 CASE( np_leos ) !== linear ISOMIP EOS ==! 1419 1430 ! 1420 DO_3D( 1, 1, 1, 1, 1, jpkm1 )1431 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 1421 1432 zt = pts(ji,jj,jk,jp_tem) - (-1._wp) ! temperature anomaly (t-T0) 1422 1433 zs = pts (ji,jj,jk,jp_sal) - 34.2_wp ! abs. salinity anomaly (s-S0) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ISOMIP+/MY_SRC/istate.F90
r14053 r14958 167 167 ! 168 168 !!gm the use of umsak & vmask is not necessary below as uu(:,:,:,Kmm), vv(:,:,:,Kmm), uu(:,:,:,Kbb), vv(:,:,:,Kbb) are always masked 169 DO_3D( 1, 1, 1, 1, 1, jpkm1 )169 DO_3D( nn_hls, nn_hls, nn_hls, nn_hls, 1, jpkm1 ) 170 170 uu_b(ji,jj,Kmm) = uu_b(ji,jj,Kmm) + e3u(ji,jj,jk,Kmm) * uu(ji,jj,jk,Kmm) * umask(ji,jj,jk) 171 171 vv_b(ji,jj,Kmm) = vv_b(ji,jj,Kmm) + e3v(ji,jj,jk,Kmm) * vv(ji,jj,jk,Kmm) * vmask(ji,jj,jk) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/ISOMIP/EXPREF/namelist_cfg
r14229 r14958 48 48 !----------------------------------------------------------------------- 49 49 &namcfg ! parameters of the configuration (default: use namusr_def in namelist_cfg) 50 !----------------------------------------------------------------------- 51 / 52 !----------------------------------------------------------------------- 53 &namtile ! parameters of the tiling 50 54 !----------------------------------------------------------------------- 51 55 / -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg
r14229 r14958 41 41 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 42 42 ln_write_cfg = .false. ! (=T) create the domain configuration file 43 / 44 !----------------------------------------------------------------------- 45 &namtile ! parameters of the tiling 46 !----------------------------------------------------------------------- 43 47 / 44 48 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/OVERFLOW/EXPREF/AGRIF/1_namelist_cfg
r14568 r14958 38 38 cn_domcfg = "OVF_domcfg" ! domain configuration filename 39 39 ! 40 / 41 !----------------------------------------------------------------------- 42 &namtile ! parameters of the tiling 43 !----------------------------------------------------------------------- 40 44 / 41 45 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/OVERFLOW/EXPREF/AGRIF/namelist_cfg
r14568 r14958 32 32 cn_domcfg = "OVF_domcfg" ! domain configuration filename 33 33 ! 34 / 35 !----------------------------------------------------------------------- 36 &namtile ! parameters of the tiling 37 !----------------------------------------------------------------------- 34 38 / 35 39 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg
r14229 r14958 41 41 !----------------------------------------------------------------------- 42 42 &namcfg ! parameters of the configuration 43 !----------------------------------------------------------------------- 44 / 45 !----------------------------------------------------------------------- 46 &namtile ! parameters of the tiling 43 47 !----------------------------------------------------------------------- 44 48 / -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90
r14433 r14958 184 184 pe3vw(:,:,jk) = pe3w_1d (jk) 185 185 END DO 186 DO_2D( 1, 1, 1, 1)186 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 187 187 ik = k_bot(ji,jj) 188 188 pdepw(ji,jj,ik+1) = MIN( zht(ji,jj) , pdepw_1d(ik+1) ) -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/README.rst
r14446 r14958 224 224 a coupled configuration through OASIS. See CPL_OASIS/README.md for more information. 225 225 226 DIA_GPU 227 --------- 228 | This is a demonstrator of diagnostic DIAHSB ported to GPU using CUDA Fortran. 229 Memory communications between host and device are asynchronous given the device has that capability. 230 This experiment is target for ORCA2_ICE_PISCES 231 226 232 TSUNAMI 227 233 --------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/SWG/EXPREF/namelist_cfg
r14229 r14958 32 32 !----------------------------------------------------------------------- 33 33 ln_read_cfg = .false. ! (=F) user defined configuration (F => create/check namusr_def) 34 / 35 !----------------------------------------------------------------------- 36 &namtile ! parameters of the tiling 37 !----------------------------------------------------------------------- 34 38 / 35 39 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/SWG/MY_SRC/usrdef_hgr.F90
r13752 r14958 113 113 DO jj = 1, jpj 114 114 DO ji = 1, jpi 115 zim1 = REAL( ji + nimpp - 1 ) ; zim05 = REAL( ji + nimpp - 1 ) - 0.5116 zjm1 = REAL( jj + njmpp - 1 ) ; zjm05 = REAL( jj + njmpp - 1 ) - 0.5115 zim1 = REAL( ji + nimpp - nn_hls ) ; zim05 = REAL( ji + nimpp - nn_hls ) - 0.5 116 zjm1 = REAL( jj + njmpp - nn_hls ) ; zjm05 = REAL( jj + njmpp - nn_hls ) - 0.5 117 117 ! 118 118 !glamt(i,j) position (meters) at T-point -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/TSUNAMI/EXPREF/namelist_cfg
r14433 r14958 31 31 ln_Iperio = .true. ! i-periodicity 32 32 ln_Jperio = .true. ! j-periodicity 33 / 34 !----------------------------------------------------------------------- 35 &namtile ! parameters of the tiling 36 !----------------------------------------------------------------------- 33 37 / 34 38 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/VORTEX/EXPREF/1_namelist_cfg
r14229 r14958 45 45 !----------------------------------------------------------------------- 46 46 &namcfg ! parameters of the configuration (default: user defined GYRE) 47 !----------------------------------------------------------------------- 48 / 49 !----------------------------------------------------------------------- 50 &namtile ! parameters of the tiling 47 51 !----------------------------------------------------------------------- 48 52 / -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/VORTEX/EXPREF/namelist_cfg
r14229 r14958 45 45 !----------------------------------------------------------------------- 46 46 &namcfg ! parameters of the configuration (default: use namusr_def in namelist_cfg) 47 !----------------------------------------------------------------------- 48 / 49 !----------------------------------------------------------------------- 50 &namtile ! parameters of the tiling 47 51 !----------------------------------------------------------------------- 48 52 / -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/VORTEX/MY_SRC/usrdef_istate.F90
r14433 r14958 76 76 ! 77 77 ! temperature: 78 DO_2D( 1, 1, 1, 1)78 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 79 79 zx = glamt(ji,jj) * 1.e3 80 80 zy = gphit(ji,jj) * 1.e3 … … 160 160 ! Sea level: 161 161 za = -zP0 * (1._wp-EXP(-zH)) / (grav*(zH-1._wp + EXP(-zH))) 162 DO_2D( 1, 1, 1, 1)162 DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) 163 163 zx = glamt(ji,jj) * 1.e3 164 164 zy = gphit(ji,jj) * 1.e3 -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/WAD/EXPREF/namelist_cfg
r14229 r14958 51 51 ! ! (=F) user defined configuration ==>>> see usrdef(_...) modules 52 52 ln_write_cfg = .true. ! (=T) create the domain configuration file 53 / 54 !----------------------------------------------------------------------- 55 &namtile ! parameters of the tiling 56 !----------------------------------------------------------------------- 53 57 / 54 58 !----------------------------------------------------------------------- -
NEMO/branches/2021/dev_r14608_AGRIF_domcfg/tests/demo_cfgs.txt
r14226 r14958 12 12 STATION_ASF OCE ICE 13 13 CPL_OASIS OCE TOP ICE NST 14 DIA_GPU OCE ICE 14 15 SWG OCE SWE 15 16 C1D_ASICS OCE
Note: See TracChangeset
for help on using the changeset viewer.