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

Changes needed for introducing 3D tracer diffusivities #253

Merged
merged 10 commits into from
Aug 24, 2023

Conversation

gustavo-marques
Copy link
Collaborator

@gustavo-marques gustavo-marques commented Jul 31, 2023

This PR adds all the changes needed to convert tracer diffusivities from 2D to 3D (adding vertical dimension).
Code changes were needed in the following modules: MOM_tracer_hor_diff, MOM_neutral_diffusion, and MOM_hor_bnd_diffusion.

The first step (36c1e26) was to add a vertical dimension to the tracer diffusivities (Kh_u and Kh_v) and associated coefficients (coef_x and coef_y). Diagnostics KhTr_u, KhTr_v, and KhTr_h were changed from 2D (lat/lon) to 3D (lat/lon/depth). To preserve old answers, the values of all modified arrays are depth independent by default. The option to apply the equivalent barotropic structure as the vertical structure of the tracer diffusivity is also introduced. This can be controlled via a new parameter: KHTR_USE_EBT_STRUCT (default is false).

Following up on the above commit, module MOM_hor_bnd_diffusion was modified to work with 3D tracer diffusivities (a588033). Parameter khtr_u (diffusivity times the time step) is now calculated at cell centers and then remapped onto the HBD vertical grid. All unit tests in this module were updated to conform with this change.

Lastly, module MOM_neutral_diffusion was also modified to work with 3D tracer diffusivities (27518f7). When the diffusivities are depth dependent (KHTR_USE_EBT_STRUCT=True), a new array (Coef_h, with values at tracer points and vertical interfaces) with a four-point average between Coef_x and Coef_y is introduced. This array is then used to calculate zonal and meridional neutral fluxes via optional arguments and using an existing four-point average (vertical interfaces of two tracer cells) inside subroutine neutral_surface_flux. The same approach is already used when tapering the neutral diffusive fluxes. In this case,
however, the unit of the output from neutral_surface_flux (Flx) is modified because the flux of the tracer between pairs of neutral layers is multiplied by the average of Coef_h. To avoid double counting Coef_h, the code block for updating the tracer concentration from divergence of neutral diffusive flux components also had to be modified for when KHTR_USE_EBT_STRUCT=True. Similarly for diagnostics trans_x_2d and trans_y_2d.

By default (KHTR_USE_EBT_STRUCT = False) all answers are bitwise identical.

Testing: pr_mom fails because KhTr_u, KhTr_v, and KhTr_h were changed from 2D (lat/lon) to 3D (lat/lon/depth). ocean.stats remains bit-wise identical.

This commit adds the option to apply a linear decay in the
neutral diffusion fluxes within a transition zone defined
by the boundary layer depths of adjacent columns. This option
is controlled by a new parameter NDIFF_TAPERING, which is only
available when NDIFF_INTERIOR_ONLY=True. By default
NDIFF_TAPERING=False and answers are bitwise identical.
Simplifies and reduces the code by adding hbd to the neutral
diffusion contril structure. This avoid the need to "extract"
hbl multiple times. Answers are bitwise indenticals.
This commit adds a vertical dimension to the tracer diffusivities
(Kh_u and Kh_v) and associated coefficiets (coef_x and coef_y).
The following diagnostics were changed from 2D (lat/lon) to 3D
(lat/lon/depth): KhTr_u, KhTr_v, and KhTr_h.

To preserve old answers, the values of all modified arrays are
depth independent by default. The option to apply the equivalent
barotropic structure as the vertical structure of the tracer
diffusivity is also introduced and this can be controlled
via a new parameter: KHTR_USE_EBT_STRUCT (default is false).
Following up on the previous commit, where a vertical dimension
was added to the tracer diffusivities, this commit modifies the
HBD module to work with this change. To do so, parameter khtr_u
(diffusivity times the time step) is calculated at cell centers
and then remapped onto the HBD vertical grid. All unit tests
in this module were updated to conform with this change.

This commit also makes the default value of HBD_DEBUG equal to
the value set for DEBUG.
This commit modifies the neutral diffusion module to work with
3D diffusivities. When the diffusivities are depth dependent
(KHTR_USE_EBT_STRUCT=True), a new array (Coef_h, with values at
tracer points and at vertical interfaces) with a four-point average
between Coef_x and Coef_y is introduced. This array is then used to
calculate zonal and meridional neutral fluxes via optional arguments
and using an existing four-point average (vertical interfaces of two
tracer cells) inside subroutine neutral_surface_flux. The same approach
is already used when tapering the neutral diffusive fluxes. In this case,
however, the unit of the output from neutral_surface_flux (Flx) is
modified because the flux of the tracer between pairs of neutral layers is
multiplied by the average of Coef_h. To avoid double counting Coef_h,
the code block for updating the tracer concentration from divergence
of neutral diffusive flux components also had to be modified
for when KHTR_USE_EBT_STRUCT=True. Similar for
diagnostics trans_x_2d and trans_y_2d.

This commit also makes the default value of NDIFF_DEBUG equal to
the value set for DEBUG.
Follow Marshall Ward suggestion and rearrange the code
to be closer to what the compilers will do (or we hope
they would do).
This commit aims to potentially enhance performance.
Answers are bit-wise identical.
@gustavo-marques gustavo-marques marked this pull request as ready for review August 22, 2023 21:19
@codecov-commenter
Copy link

codecov-commenter commented Aug 22, 2023

Codecov Report

Patch coverage: 39.86% and project coverage change: +1.02% 🎉

Comparison is base (47f737f) 37.06% compared to head (eedb892) 38.09%.
Report is 1 commits behind head on dev/ncar.

❗ Current head eedb892 differs from pull request most recent head c57789f. Consider uploading reports for the commit c57789f to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##           dev/ncar     #253      +/-   ##
============================================
+ Coverage     37.06%   38.09%   +1.02%     
============================================
  Files           264      269       +5     
  Lines         74436    76728    +2292     
  Branches      13781    14092     +311     
============================================
+ Hits          27592    29230    +1638     
- Misses        41754    42239     +485     
- Partials       5090     5259     +169     
Files Changed Coverage Δ
...g_src/drivers/solo_driver/MESO_surface_forcing.F90 0.00% <0.00%> (ø)
...g_src/drivers/solo_driver/user_surface_forcing.F90 0.00% <0.00%> (ø)
config_src/infra/FMS1/MOM_coms_infra.F90 59.47% <0.00%> (-2.86%) ⬇️
config_src/infra/FMS1/MOM_io_infra.F90 22.00% <0.00%> (-1.72%) ⬇️
src/ALE/MOM_hybgen_regrid.F90 0.00% <0.00%> (ø)
src/ALE/regrid_interp.F90 1.47% <0.00%> (-0.03%) ⬇️
src/core/MOM_PressureForce_FV.F90 40.69% <ø> (-0.26%) ⬇️
src/core/MOM_density_integrals.F90 16.92% <0.00%> (-0.19%) ⬇️
src/core/MOM_unit_tests.F90 15.00% <0.00%> (-3.75%) ⬇️
src/core/MOM_variables.F90 48.41% <ø> (ø)
... and 80 more

... and 19 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gustavo-marques
Copy link
Collaborator Author

@alperaltuntas, please merge #248 before this PR.

@alperaltuntas alperaltuntas merged commit 700502d into NCAR:dev/ncar Aug 24, 2023
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants