NCAR / MOM6

NCAR/CESM fork of the Modular Ocean Model v.6 (MOM6)
Other
2 stars 19 forks source link

Changes needed for introducing 3D tracer diffusivities #253

Closed gustavo-marques closed 1 year ago

gustavo-marques commented 1 year ago

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 (36c1e266b38414b89a759b68952144123d8968dd) 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 (a588033727ea2e366d3893fe7670b1cda16cb03e). 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 (27518f750f83697c97b4caee718314856cae259f). 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.

codecov-commenter commented 1 year ago

Codecov Report

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

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

:exclamation: 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 ```diff @@ 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](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR) | Coverage Δ | | |---|---|---| | [...g\_src/drivers/solo\_driver/MESO\_surface\_forcing.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-Y29uZmlnX3NyYy9kcml2ZXJzL3NvbG9fZHJpdmVyL01FU09fc3VyZmFjZV9mb3JjaW5nLkY5MA==) | `0.00% <0.00%> (ø)` | | | [...g\_src/drivers/solo\_driver/user\_surface\_forcing.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-Y29uZmlnX3NyYy9kcml2ZXJzL3NvbG9fZHJpdmVyL3VzZXJfc3VyZmFjZV9mb3JjaW5nLkY5MA==) | `0.00% <0.00%> (ø)` | | | [config\_src/infra/FMS1/MOM\_coms\_infra.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-Y29uZmlnX3NyYy9pbmZyYS9GTVMxL01PTV9jb21zX2luZnJhLkY5MA==) | `59.47% <0.00%> (-2.86%)` | :arrow_down: | | [config\_src/infra/FMS1/MOM\_io\_infra.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-Y29uZmlnX3NyYy9pbmZyYS9GTVMxL01PTV9pb19pbmZyYS5GOTA=) | `22.00% <0.00%> (-1.72%)` | :arrow_down: | | [src/ALE/MOM\_hybgen\_regrid.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-c3JjL0FMRS9NT01faHliZ2VuX3JlZ3JpZC5GOTA=) | `0.00% <0.00%> (ø)` | | | [src/ALE/regrid\_interp.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-c3JjL0FMRS9yZWdyaWRfaW50ZXJwLkY5MA==) | `1.47% <0.00%> (-0.03%)` | :arrow_down: | | [src/core/MOM\_PressureForce\_FV.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-c3JjL2NvcmUvTU9NX1ByZXNzdXJlRm9yY2VfRlYuRjkw) | `40.69% <ø> (-0.26%)` | :arrow_down: | | [src/core/MOM\_density\_integrals.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-c3JjL2NvcmUvTU9NX2RlbnNpdHlfaW50ZWdyYWxzLkY5MA==) | `16.92% <0.00%> (-0.19%)` | :arrow_down: | | [src/core/MOM\_unit\_tests.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-c3JjL2NvcmUvTU9NX3VuaXRfdGVzdHMuRjkw) | `15.00% <0.00%> (-3.75%)` | :arrow_down: | | [src/core/MOM\_variables.F90](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR#diff-c3JjL2NvcmUvTU9NX3ZhcmlhYmxlcy5GOTA=) | `48.41% <ø> (ø)` | | | ... and [80 more](https://app.codecov.io/gh/NCAR/MOM6/pull/253?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR) | | ... and [19 files with indirect coverage changes](https://app.codecov.io/gh/NCAR/MOM6/pull/253/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NCAR)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

gustavo-marques commented 1 year ago

@alperaltuntas, please merge https://github.com/NCAR/MOM6/pull/248 before this PR.