Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GFDL to main (2024-05-31) #1631

Merged
merged 139 commits into from
Jul 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
d8579d2
Use a class to deliver elemental procedures for EOS
adcroft Oct 2, 2023
7cc191a
Add rule and workflow to compare results of micro-timing tests
adcroft Nov 15, 2023
34b880f
Add units to comments in MOM_neutral_diffusion
Hallberg-NOAA Nov 16, 2023
11759d6
Fix unpaired parentheses in a formatting string
Hallberg-NOAA Nov 19, 2023
b898297
+(*)Add continuity_fluxes & continuity_adjust_vel
Hallberg-NOAA Nov 7, 2023
fc0bef1
+Pass-through from continuity_PPM via continuity
Hallberg-NOAA Nov 14, 2023
6b86ab8
+Create zonal_edge_thickness in MOM_continuity_PPM
Hallberg-NOAA Nov 15, 2023
d3496fe
+Call zonal_edge_thickness outside of zonal_mass_flux
Hallberg-NOAA Nov 16, 2023
bbda30f
+Add zonal_BT_mass_flux & meridional_BT_mass_flux
Hallberg-NOAA Nov 16, 2023
a70482c
+Add continuity_zonal_convergence
Hallberg-NOAA Nov 18, 2023
6b6f8dc
Move continuity_fluxes to MOM_continuity_PPM.F90
Hallberg-NOAA Nov 19, 2023
7877292
+Add optional argument du_cor to continuity_PPM
Hallberg-NOAA Dec 12, 2023
7d334f8
Makedep: Include support for CPP condition blocks
marshallward Dec 13, 2023
4e8fbe1
+Standardize input salinity units as "ppt"
Hallberg-NOAA Aug 16, 2023
8395404
Merge branch 'main' into dev/gfdl
marshallward Dec 18, 2023
a28443b
Fix for an OBC issue with mask_tables
kshedstrom Dec 6, 2023
5c14668
+FIX_USTAR_GUSTLESS_BUG is now USTAR_GUSTLESS_BUG
Hallberg-NOAA Dec 15, 2023
7ddc727
This commit guarantees consistency of the ice sheet code under rotate…
alex-huth Nov 27, 2023
b0ff6bd
fixed documentation of inputs to subroutine sum_square_matrix
alex-huth Nov 27, 2023
f7233e0
Optimized sub-cell grounding subroutines, increasing computational ef…
alex-huth Nov 30, 2023
d7096bd
fixed documented units of fN and fN_scale for ice shelf coulomb frict…
alex-huth Dec 19, 2023
90de5de
Rename u arg to step_MOM_dyn_split_RK2 as u_inst
Hallberg-NOAA Dec 15, 2023
eac3bb3
+FIX_UNSPLIT_DT_VISC_BUG is now UNSPLIT_DT_VISC_BUG
Hallberg-NOAA Dec 15, 2023
2ea0ac3
+Add MOM_dynamics_split_RK2b enabled by SPLIT_RK2B
Hallberg-NOAA Nov 12, 2023
8b98bd0
*+Revise algorithm in step_MOM_dyn_split_RK2b
Hallberg-NOAA Dec 12, 2023
9d57c15
Regroup MOM_dynamics_split_RK2b halo updates
Hallberg-NOAA Dec 17, 2023
5137442
+Correct description of SPLIT_RK2B
Hallberg-NOAA Dec 20, 2023
a03bb95
+Add cuberoot function
Hallberg-NOAA Dec 20, 2023
d7d126a
Update Gaea F5 datasets path
marshallward Jan 18, 2024
4813b17
*Use Halley method iterations in cuberoot function
Hallberg-NOAA Jan 19, 2024
17f1c40
Cuberoot: Apply first iteration explicitly (#11)
marshallward Jan 26, 2024
435ccaa
Data table documentation (#551)
ashjbarnes Jan 29, 2024
f1e0f01
Params: Add do_not_log to param block open/close
marshallward Jan 28, 2024
5ca70ba
Open parameter block before querying BODNER23
kshedstrom Jan 9, 2024
541c2f4
(*)Oil_tracer_column_physics unit conversion fix
Hallberg-NOAA Jan 19, 2024
76f0668
(*)Avoid using RHO_0 in non-Boussinesq averaging
Hallberg-NOAA Jan 20, 2024
60cb551
Intrinsics: Faster cuberoot scaling functions
marshallward Jan 28, 2024
5edba9b
Cuberoot: Refactor (re|de)scale functions
marshallward Jan 30, 2024
736ef16
Cuberoot: Break **3 into explicit integer cubes
marshallward Jan 30, 2024
671c85d
(*)Use cuberoot in ePBL_column
Hallberg-NOAA Jan 10, 2024
07bace6
*Fix two bugs in convert_temp_salt_for_TEOS10
Hallberg-NOAA Jan 30, 2024
915cfe2
+ALE_remap_scalar with arbitrary thickness units
Hallberg-NOAA Jan 26, 2024
e7a7a82
(*)MOM_temp_salt_init_from_Z Z-unit tracer remap
Hallberg-NOAA Jan 27, 2024
9a6ddee
*+non-Boussinesq revisions to MOM_generic_tracer
Hallberg-NOAA Jan 28, 2024
ea12532
Fix issue with restart filenames when using ensembles.
wfcooke Feb 1, 2024
9282cd1
+(*)Bodner param with cuberoot and non-Boussinesq
Hallberg-NOAA Jan 19, 2024
4757bcb
Remove some unused calculations if non-Boussinesq
Hallberg-NOAA Jan 21, 2024
de7e5b7
Document MOM_regridding and coord variable units
Hallberg-NOAA Feb 1, 2024
c37a2f0
Document core and linear EOS variable units
Hallberg-NOAA Jan 29, 2024
0fb905f
+(*)non-Boussinesq ALE_sponges work in Z units
Hallberg-NOAA Jan 23, 2024
f14a681
(*)Use thickness_to_dz with BRYAN_LEWIS_DIFFUSIVITY
Hallberg-NOAA Jan 24, 2024
3f7465a
+tracer_Z_init can rescale tracers
Hallberg-NOAA Jan 28, 2024
f92e4ac
Update MOM_mixed_layer_restrat.F90 (#568)
marshallward Feb 25, 2024
e69d771
Merge branch 'main' into dev/gfdl
marshallward Feb 28, 2024
f2e7abf
MLE: Use default answer date outside of block (#570)
marshallward Feb 28, 2024
86c5ed9
(*)Fix bug in h_neglect used to remap diags to rho
Hallberg-NOAA Feb 27, 2024
8f7df08
(*)non-Boussinesq Z unit update_OBC_segment_data
Hallberg-NOAA Jan 24, 2024
d0e9c25
*Corrected CFC diagnostics and non-Bous CFC fluxes
Hallberg-NOAA Jan 24, 2024
fd5696b
Pinning package requirements for readthedocs
adcroft Feb 29, 2024
f9da673
Create BUILD and WORK directory macros
marshallward Jan 16, 2024
2ae6385
Refactor set_viscous_BBL channel drag calculations
Hallberg-NOAA Dec 22, 2023
da02ffc
+Add find_L_open_concave_iterative
Hallberg-NOAA Dec 30, 2023
e1ea758
Add the debugging routine test_L_open_concave
Hallberg-NOAA Jan 15, 2024
714d2da
Minor refactoring in set_viscous_BBL
Hallberg-NOAA Mar 5, 2024
6153d97
Compute dz in the halo for OBC segments
kshedstrom Mar 9, 2024
0ff03ae
+Fix myStats global indexing segmentation faults
Hallberg-NOAA Feb 6, 2024
0bd4c16
(*)Fix apply_topography_edits_from_file indexing
Hallberg-NOAA Feb 8, 2024
9e78615
Earlier initialization thickness halo updates
Hallberg-NOAA Feb 4, 2024
1ae2a3a
+(*)Refactor MOM_diag_remap for global indices
Hallberg-NOAA Feb 5, 2024
d311b1d
+(*)Use z-space remapping for some diagnostics
Hallberg-NOAA Feb 5, 2024
611f575
+(*)Fix downsample_mask indexing bugs
Hallberg-NOAA Feb 6, 2024
2bc04bd
(*)Eliminate IIm1 and JJm1 in Update_Stokes_Drift
Hallberg-NOAA Feb 29, 2024
744dbcc
Document remapping function variable units
Hallberg-NOAA Feb 14, 2024
a23c7d8
fix gtracer restart repro issue with OBC
yichengt900 Mar 12, 2024
4fd0162
Rotation bugfixes
marshallward Mar 14, 2024
32f6316
+Rotationally symmetric neutral diffusion option
Hallberg-NOAA Feb 29, 2024
812510b
Add an option in hor_visc to use cont thickness
herrwang0 Mar 4, 2024
37ff301
fix opemmp parallel
herrwang0 Mar 4, 2024
2b59089
Set up auxiliary domain for unrotated grid
Hallberg-NOAA Mar 5, 2024
5e34f48
Set flags properly for rotated tripolar grids
Hallberg-NOAA Mar 6, 2024
f9372f3
+Add get_netcdf_filename for a get_field_nc error
Hallberg-NOAA Mar 11, 2024
a3fd1f3
+Rotationally symmetric epipycnal diffusion option
Hallberg-NOAA Mar 18, 2024
a71fbce
Merge branch 'main' into main_to_dev_20240405
marshallward Apr 5, 2024
2d121dc
(*)Pass dz to user initialize_ALE_sponge calls
Hallberg-NOAA Jan 24, 2024
c86358b
(*)Avoiding using RHO_0 in non-Boussinesq debugging
Hallberg-NOAA Jan 20, 2024
43b2a43
Add units to the descriptions of 141 variables
Hallberg-NOAA Apr 1, 2024
b98acd8
Add units to the descriptions of 115 variables
Hallberg-NOAA Mar 19, 2024
5b9ae52
Disable codecov upload requirement
marshallward Apr 12, 2024
6f1c79e
CPP expression parser for makedep
marshallward Apr 2, 2024
3a3baf1
(*)Fix Stokes drift spectrum rescaling
Hallberg-NOAA Apr 2, 2024
6c44c5f
Fix for using tidal amplitude in determining the BBL thickness
adcroft Apr 4, 2024
f7a4491
Perf: Better error report for failed parsing
marshallward Apr 5, 2024
1c4d0dc
Better document variable units in 3 user modules
Hallberg-NOAA Apr 5, 2024
0efe83d
Proto-type cricital latitude modification of Henyey
adcroft Jul 14, 2023
01b2ea9
Document units of 34 real variables in vertFPmix
Hallberg-NOAA Oct 26, 2023
4058462
Refactoring density integrals for efficiency
Hallberg-NOAA Mar 31, 2024
25989ad
Allow ALE boundary extrapolation behaviour to differ at initialisatio…
claireyung May 2, 2024
46fd6e6
+Rotationally symmetric KPP_smooth_BLD option
Hallberg-NOAA Apr 20, 2024
a3e9e1c
(*)Revise 13 diagnostics for rotational symmetry
Hallberg-NOAA Apr 20, 2024
efe1b4a
+Fix multiple bugs when MEKE_GM_SRC_ALT is True
Hallberg-NOAA May 5, 2024
a200f5f
Added missing values for vector u2_bg(:) within set_viscous_ML
alex-huth May 3, 2024
1829b7f
Makedep: Better handling of parentheses
marshallward May 7, 2024
93d9bb8
+(*)Fix USE_QG_LEITH_VISC = True reproducibility
Hallberg-NOAA Jan 28, 2023
bb8a653
Add diags for east, north velocity components.
kshedstrom Apr 29, 2024
0c790f2
SAL: Explicitly allocate sht variable in SAL_CS
marshallward May 10, 2024
e253883
Merge branch 'main' into dev/gfdl
marshallward May 14, 2024
6272bbc
Testing: Correct perf parsing of C++ output
marshallward May 14, 2024
7a2a33b
Use FMS1 for MacOS builds
adcroft May 18, 2024
83bc4a6
GitLab CI: Direct build directory to $HOME
marshallward May 20, 2024
758b5a3
Add maximum number of iterations in find_depth_of_pressure_in_cell
claireyung Apr 24, 2024
9f3da0b
Fix minor issues
claireyung May 16, 2024
93f2aee
Fix error in diagnostic axis registration for grid space axes
MJHarrison-GFDL May 6, 2024
c1c32d2
Replace USE_GRID_SPACE_DIAGNOSTIC_AXES with USE_INDEX_DIAGNOSTIC_AXES
MJHarrison-GFDL May 20, 2024
1cf20b3
Better variables for updated masks in fill_miss_2d
Hallberg-NOAA Mar 5, 2024
2b69f1e
Bugfix for tracer advection diagnostic in symmetric memory mode
breichl May 23, 2024
7384dba
Autoconf: Detect FMS IO implementation
marshallward May 23, 2024
c7d3268
.testing: Target build uses its own Makefile
marshallward May 24, 2024
8ecb260
CI: Fix FMS_COMMIT, remove FRAMEWORK
marshallward May 28, 2024
59e3a8f
Merge branch 'main' into dev/gfdl
marshallward May 29, 2024
f21ec03
*Fix ALE_remap_scalar call with h_in_Z_units
Hallberg-NOAA May 24, 2024
705a384
Add diag send complete calls to MOM
Apr 1, 2024
7305528
Add diag_manager_set_time_end calls to the solo drivers
May 14, 2024
d90ff6b
(*)Refactor and document soliton_initialization
Hallberg-NOAA Apr 19, 2024
3c87d98
(*)Correct rescaling of KPP pseudo-salt flux
Hallberg-NOAA May 11, 2024
506d186
+Eliminate fluxes%KPP_salt_flux
Hallberg-NOAA May 11, 2024
c121215
Fix TEOS10 argument descriptions
Hallberg-NOAA May 24, 2024
836e696
+Add convert_MLD_to_ML_thickness
Hallberg-NOAA Apr 23, 2024
2035af3
+*Use thickness in ideal_age_tracer_column_physics
Hallberg-NOAA Apr 23, 2024
912c568
+Pass h_MLD to mixedlayer_restrat
Hallberg-NOAA Apr 23, 2024
c300208
+*Convert MLD to ML_thickness in diabatic
Hallberg-NOAA Apr 24, 2024
d3cb7ee
+*Use visc%h_ML in tracer diffusion routines
Hallberg-NOAA Apr 24, 2024
d66adff
+*Pass visc%h_ML to call_tracer_column_fns
Hallberg-NOAA Apr 25, 2024
0578393
Remove diag_send_complete from disable_averaging
marshallward Jun 8, 2024
b4ae2b7
Disable nonrepro FMAs in convex BBL solver
marshallward Jun 17, 2024
ac2b642
Re-initialize fields within KPP
marshallward Jul 2, 2024
3fac1c5
Allow incorrect PPM:H3 tracer advection stencil
marshallward Jul 3, 2024
00f7d23
(*)+Restore USE_WRIGHT_2ND_DERIV_BUG functionality
Hallberg-NOAA Jul 14, 2024
40f4721
*Possibly initialize h_ML from MLD in restart file
Hallberg-NOAA Jul 19, 2024
ee686c8
Improve MOM_surface_chksum
Hallberg-NOAA Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
+*Use thickness in ideal_age_tracer_column_physics
  Pass mixed layer thickness, rather than mixed layer depth, to
ideal_age_tracer_column_physics, and determine the number of layers within
the mixed layer in count_BL_layers in thickness units rather than depth units.
To accommodate these changes there is now a call to convert_MLD_to_ML_thickness
inside of call_tracer_column_fns.  The thermo_var_ptrs type argument (tv) to
ideal_age_tracer_column_physics and count_BL_layers are no longer used and
have been removed.  All answers are bitwise identical in Boussinesq mode, but
in non-Boussinesq mode there are changes in the passive ideal age tracers at
the level of roundoff.  There are also changes in the units of arguments and
the number of arguments to a public interface.
Hallberg-NOAA authored and marshallward committed May 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2035af3d2d12e3cbc4885f893d91c9fabdc5a5ba
27 changes: 17 additions & 10 deletions src/tracer/MOM_tracer_flow_control.F90
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ module MOM_tracer_flow_control
use MOM_get_input, only : Get_MOM_input
use MOM_grid, only : ocean_grid_type
use MOM_hor_index, only : hor_index_type
use MOM_interface_heights, only : convert_MLD_to_ML_thickness
use MOM_CVMix_KPP, only : KPP_CS
use MOM_open_boundary, only : ocean_OBC_type
use MOM_restart, only : MOM_restart_CS
@@ -427,7 +428,7 @@ subroutine call_tracer_set_forcing(sfc_state, fluxes, day_start, day_interval, G
end subroutine call_tracer_set_forcing

!> This subroutine calls all registered tracer column physics subroutines.
subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV, US, tv, optics, CS, &
subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, mld, dt, G, GV, US, tv, optics, CS, &
debug, KPP_CSp, nonLocalTrans, evap_CFL_limit, minimum_forcing_depth)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure.
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
@@ -444,7 +445,7 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
type(forcing), intent(in) :: fluxes !< A structure containing pointers to
!! any possible forcing fields.
!! Unused fields have NULL ptrs.
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: Hml !< Mixed layer depth [Z ~> m]
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: mld !< Mixed layer depth [Z ~> m]
real, intent(in) :: dt !< The amount of time covered by this
!! call [T ~> s]
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
@@ -464,6 +465,9 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
real, optional, intent(in) :: minimum_forcing_depth !< The smallest depth over
!! which fluxes can be applied [H ~> m or kg m-2]

! Local variables
real :: Hbl(SZI_(G),SZJ_(G)) !< Boundary layer thickness [H ~> m or kg m-2]

if (.not. associated(CS)) call MOM_error(FATAL, "call_tracer_column_fns: "// &
"Module must be initialized via call_tracer_register before it is used.")

@@ -488,12 +492,13 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
G, GV, US, CS%RGC_tracer_CSp, &
evap_CFL_limit=evap_CFL_limit, &
minimum_forcing_depth=minimum_forcing_depth)
if (CS%use_ideal_age) &
if (CS%use_ideal_age) then
call convert_MLD_to_ML_thickness(mld, h_new, Hbl, tv, G, GV)
call ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, tv, CS%ideal_age_tracer_CSp, &
G, GV, US, CS%ideal_age_tracer_CSp, &
evap_CFL_limit=evap_CFL_limit, &
minimum_forcing_depth=minimum_forcing_depth, &
Hbl=Hml)
minimum_forcing_depth=minimum_forcing_depth, Hbl=Hbl)
endif
if (CS%use_regional_dyes) &
call dye_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, tv, CS%dye_tracer_CSp, &
@@ -526,7 +531,7 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
if (US%QRZ_T_to_W_m2 /= 1.0) call MOM_error(FATAL, "MOM_generic_tracer_column_physics "//&
"has not been written to permit dimensionsal rescaling. Set all 4 of the "//&
"[QRZT]_RESCALE_POWER parameters to 0.")
call MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml, dt, &
call MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, mld, dt, &
G, GV, US, CS%MOM_generic_tracer_CSp, tv, optics, &
evap_CFL_limit=evap_CFL_limit, &
minimum_forcing_depth=minimum_forcing_depth)
@@ -567,9 +572,11 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
if (CS%use_RGC_tracer) &
call RGC_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, CS%RGC_tracer_CSp)
if (CS%use_ideal_age) &
if (CS%use_ideal_age) then
call convert_MLD_to_ML_thickness(mld, h_new, Hbl, tv, G, GV)
call ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, tv, CS%ideal_age_tracer_CSp, Hbl=Hml)
G, GV, US, CS%ideal_age_tracer_CSp, Hbl=Hbl)
endif
if (CS%use_regional_dyes) &
call dye_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, &
G, GV, US, tv, CS%dye_tracer_CSp)
@@ -591,7 +598,7 @@ subroutine call_tracer_column_fns(h_old, h_new, ea, eb, fluxes, Hml, dt, G, GV,
if (US%QRZ_T_to_W_m2 /= 1.0) call MOM_error(FATAL, "MOM_generic_tracer_column_physics "//&
"has not been written to permit dimensionsal rescaling. Set all 4 of the "//&
"[QRZT]_RESCALE_POWER parameters to 0.")
call MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml, dt, &
call MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, mld, dt, &
G, GV, US, CS%MOM_generic_tracer_CSp, tv, optics)
endif
if (CS%use_pseudo_salt_tracer) &
29 changes: 12 additions & 17 deletions src/tracer/ideal_age_example.F90
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ module ideal_age_example
use MOM_grid, only : ocean_grid_type
use MOM_hor_index, only : hor_index_type
use MOM_io, only : file_exists, MOM_read_data, slasher, vardesc, var_desc, query_vardesc
use MOM_interface_heights, only : thickness_to_dz
use MOM_open_boundary, only : ocean_OBC_type
use MOM_restart, only : query_initialized, set_initialized, MOM_restart_CS
use MOM_spatial_means, only : global_mass_int_EFP
@@ -22,7 +21,7 @@ module ideal_age_example
use MOM_tracer_diabatic, only : tracer_vertdiff, applyTracerBoundaryFluxesInOut
use MOM_tracer_Z_init, only : tracer_Z_init
use MOM_unit_scaling, only : unit_scale_type
use MOM_variables, only : surface, thermo_var_ptrs
use MOM_variables, only : surface
use MOM_verticalGrid, only : verticalGrid_type

implicit none ; private
@@ -297,7 +296,7 @@ subroutine initialize_ideal_age_tracer(restart, day, G, GV, US, h, diag, OBC, CS
end subroutine initialize_ideal_age_tracer

!> Applies diapycnal diffusion, aging and regeneration at the surface to the ideal age tracers
subroutine ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, US, tv, CS, &
subroutine ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G, GV, US, CS, &
evap_CFL_limit, minimum_forcing_depth, Hbl)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
@@ -317,14 +316,13 @@ subroutine ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G,
!! and tracer forcing fields. Unused fields have NULL ptrs.
real, intent(in) :: dt !< The amount of time covered by this call [T ~> s]
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
type(ideal_age_tracer_CS), pointer :: CS !< The control structure returned by a previous
!! call to register_ideal_age_tracer.
real, optional, intent(in) :: evap_CFL_limit !< Limit on the fraction of the water that can
!! be fluxed out of the top layer in a timestep [nondim]
real, optional, intent(in) :: minimum_forcing_depth !< The smallest depth over which
!! fluxes can be applied [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G)), optional, intent(in) :: Hbl !< Boundary layer depth [Z ~> m]
real, dimension(SZI_(G),SZJ_(G)), optional, intent(in) :: Hbl !< Boundary layer thickness [H ~> m or kg m-2]

! This subroutine applies diapycnal diffusion and any other column
! tracer physics or chemistry to the tracers from this file.
@@ -349,7 +347,7 @@ subroutine ideal_age_tracer_column_physics(h_old, h_new, ea, eb, fluxes, dt, G,
endif

if (CS%use_real_BL_depth .and. present(Hbl)) then
call count_BL_layers(G, GV, h_old, Hbl, tv, BL_layers)
call count_BL_layers(G, GV, h_old, Hbl, BL_layers)
endif

if (.not.associated(CS)) return
@@ -578,30 +576,27 @@ subroutine ideal_age_example_end(CS)
endif
end subroutine ideal_age_example_end

subroutine count_BL_layers(G, GV, h, Hbl, tv, BL_layers)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
subroutine count_BL_layers(G, GV, h, Hbl, BL_layers)
type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure
real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2].
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: Hbl !< Boundary layer depth [Z ~> m]
type(thermo_var_ptrs), intent(in) :: tv !< A structure pointing to various thermodynamic variables
intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2].
real, dimension(SZI_(G),SZJ_(G)), intent(in) :: Hbl !< Boundary layer thickness [H ~> m or kg m-2]
real, dimension(SZI_(G),SZJ_(G)), intent(out) :: BL_layers !< Number of model layers in the boundary layer [nondim]

real :: dz(SZI_(G),SZK_(GV)) ! Height change across layers [Z ~> m]
real :: current_depth ! Distance from the free surface [Z ~> m]
real :: current_depth ! Distance from the free surface [H ~> m or kg m-2]
integer :: i, j, k, is, ie, js, je, nz, m, nk
character(len=255) :: msg
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec ; nz = GV%ke

BL_layers(:,:) = 0.
do j=js,je
call thickness_to_dz(h, tv, dz, j, G, GV)
do i=is,ie
current_depth = 0.
do k=1,nz
current_depth = current_depth + dz(i,k)
current_depth = current_depth + h(i,j,k)
if (Hbl(i,j) <= current_depth) then
BL_layers(i,j) = BL_layers(i,j) + (1.0 - (current_depth - Hbl(i,j)) / dz(i,k))
BL_layers(i,j) = BL_layers(i,j) + (1.0 - (current_depth - Hbl(i,j)) / h(i,j,k))
exit
else
BL_layers(i,j) = BL_layers(i,j) + 1.0