Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are verified correctness issues in diagnostics/logging and potential out-of-bounds writes due to unguarded optional coupler indices.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR updates MPAS-Ocean ↔ MPAS-Seaice frazil coupling to avoid double-counting ocean heat flux by splitting melt potential (Fioo_q) from frazil-formation heat (Fioo_frazilh) and adding explicit frazil salt/heat coupling fields through the drivers and registries.
Changes:
- Add/rename ocean→ice frazil coupling flux fields (mass/salt/heat) and route them into MPAS-Seaice Icepack thermodynamics.
- Add
config_use_accumulated_frazil_heatto optionally couple accumulated frazil energy rather than latent-heat-from-mass. - Update MCT diagnostics/budget accounting to incorporate the new frazil salt/heat fields.
File summaries
| File | Description |
|---|---|
| driver-moab/shr/seq_flds_mod.F90 | Update frazil salt field metadata from “production” to “flux”. |
| driver-mct/shr/seq_flds_mod.F90 | Add/rename frazil salt/heat flux metadata for MCT coupler field lists. |
| driver-mct/main/seq_diag_mct.F90 | Extend diagnostic budgets to include frazil salt/heat fields and indices. |
| components/mpas-seaice/src/shared/mpas_seaice_initialize.F | Allow config_frazil_coupling_type='omega-fluxes'. |
| components/mpas-seaice/src/shared/mpas_seaice_icepack.F | Plumb frazil mass/salt/heat flux arrays into Icepack thermodynamics call. |
| components/mpas-seaice/src/Registry.xml | Register new ocean-coupling vars (frazilMassFlux/SaltFlux/HeatFlux) and allow omega-fluxes option. |
| components/mpas-seaice/driver/mpassi_cpl_indices.F | Clarify comments for frazil coupling indices. |
| components/mpas-seaice/driver/ice_comp_mct.F | Combine melt potential and frazil heat into freezingMeltingPotential; conditionally use omega-fluxes fields. |
| components/mpas-seaice/cime_config/buildnml | Add new frazil coupling vars to namelist-generated stream/var lists. |
| components/mpas-seaice/bld/namelist_files/namelist_definition_mpassi.xml | Document omega-fluxes as a valid frazil coupling type. |
| components/mpas-ocean/src/shared/mpas_ocn_frazil_forcing.F | Accumulate frazil latent energy (accumulatedFrazilIceEnergy) alongside mass/salt. |
| components/mpas-ocean/src/Registry.xml | Add config_use_accumulated_frazil_heat and register accumulatedFrazilIceEnergy. |
| components/mpas-ocean/src/analysis_members/Registry_conservation_check.xml | Minor description fix for conservation-check frazil heat flux variable. |
| components/mpas-ocean/src/analysis_members/mpas_ocn_conservation_check.F | Switch conservation-check frazil heat computation to use accumulated frazil energy. |
| components/mpas-ocean/driver/ocn_comp_mct.F | Export separate frazil heat flux vs melt potential and reset accumulated frazil energy each coupling interval. |
| components/mpas-ocean/bld/namelist_files/namelist_definition_mpaso.xml | Document new config_use_accumulated_frazil_heat namelist entry. |
| components/mpas-ocean/bld/namelist_files/namelist_defaults_mpaso.xml | Provide default .false. for config_use_accumulated_frazil_heat. |
| components/mpas-ocean/bld/build-namelist-section | Add new namelist option to generated defaults list. |
| components/mpas-ocean/bld/build-namelist | Add new namelist option to generated defaults list. |
Review details
- Files reviewed: 19/19 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cbegeman
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround on this. Your G-case comparison looks promising! Most of the code changes were clear to me, I just have one question below about the frazil mass/salt adjust term.
| freezingMeltingPotential, & | ||
| frazilMassFlux, & | ||
| frazilSaltFlux, & | ||
| frazilHeatFlux , & |
There was a problem hiding this comment.
| frazilHeatFlux , & | |
| frazilHeatFlux, & |
| i2x_i(index_i2x_Fioi_melth ,n) = oceanHeatFlux(i) | ||
| i2x_i(index_i2x_Fioi_swpen ,n) = oceanShortwaveFlux(i) | ||
| i2x_i(index_i2x_Fioi_meltw ,n) = oceanFreshWaterFlux(i) | ||
| i2x_i(index_i2x_Fioi_meltw ,n) = oceanFreshWaterFlux(i) + frazilMassAdjust(i)/ailohi |
There was a problem hiding this comment.
Can you help me understand this addition? Is Fioi_frazil one of the coupling fields that is never used by the ocean model? So, prior to this change, were we neglecting to include the frazil mass adjustment?
There was a problem hiding this comment.
Using Fioi_frazil would be a cleaner way to separate the sources of fresh water fluxes. For now, it's not being used and that term is included in meltw.
| i2x_i(index_i2x_Fioi_melth ,n) = oceanHeatFlux(i) | ||
| i2x_i(index_i2x_Fioi_swpen ,n) = oceanShortwaveFlux(i) | ||
| i2x_i(index_i2x_Fioi_meltw ,n) = oceanFreshWaterFlux(i) | ||
| i2x_i(index_i2x_Fioi_meltw ,n) = oceanFreshWaterFlux(i) + frazilMassAdjust(i)/ailohi |
There was a problem hiding this comment.
Has meltw always failed to include the frazil mass adjustment? Or is there a change to where (through which variable) frazil mass adjustment is applied? Similar questions apply to the frazil salt adjustment below
There was a problem hiding this comment.
No. Since defined, it's been included in meltw. That term was dropped at some point along this effort, I think when Fioi_frazil was added.
There was a problem hiding this comment.
I think I initially made the change to move frazilMassAdjust to Fioi_frazil when the field was first added, but it required more changes to ocn_comp_mct. The current configuration is what was done originally, as @njeffery said. The same is true for the salt flux from the frazil mass adjustment, which is added to Fioi_salt.
There was a problem hiding this comment.
Thank you for clarifying. Sounds good.
There was a problem hiding this comment.
🟡 Changes recommended
MPAS-Ocean exports Fioo_frazils without guarding against a zero (missing) coupler-field index, which can cause out-of-bounds writes at runtime.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
components/mpas-ocean/driver/ocn_comp_mct.F:3427
- index_o2x_Fioo_frazils can be 0 (perrWith='quiet' lookup), but this keepFrazil=.false. path still writes o2x_o(index_o2x_Fioo_frazils, n) whenever index_o2x_Fioo_frazil /= 0. Guard the frazils assignment separately to avoid out-of-bounds indexing.
if (index_o2x_Fioo_frazil /= 0) then
o2x_o(index_o2x_Fioo_frazil, n) = 0.0_RKIND
o2x_o(index_o2x_Fioo_frazils, n) = 0.0_RKIND
endif
- Files reviewed: 19/19 changed files
- Comments generated: 2
- Review effort level: Lite
| if (index_o2x_Fioo_frazil /= 0) then | ||
| o2x_o(index_o2x_Fioo_frazil, n) = accumulatedFrazilIceMass(i) / ocn_cpl_dt | ||
| o2x_o(index_o2x_Fioo_frazils, n) = accumulatedFrazilIceMass(i)/ 1000.0_RKIND * & | ||
| config_frazil_sea_ice_reference_salinity / ocn_cpl_dt | ||
| endif |
There was a problem hiding this comment.
Will work with just the one check. Fioo_frazil and Fioo_frazils are used together. If one is defined, then the other needs to be. This is not true for Fioo_q and Fioo_frazilh.
| <nml_option name="config_use_accumulated_frazil_energy" type="logical" default_value=".false." | ||
| description="If true, send the total energy accumulated from frazil ice formation to the sea ice model, otherwise use the latent heat." | ||
| possible_values=".true. or .false." | ||
| /> |
|
Have looked at the changes here and they look good to me. Was trying to get the Moab diagnostics working, but have had some bugs. Am rebuilding and rerunning now and will attach a diff once I confirm things are working correctly. |
|
Attached is patch with Moab coupler changes consistent with the mct changes. This will probably be needed as it seems that Moab is becoming the default coupler. @njeffery let me know if you'd like to add this here or if I should create a different PR. The changes were tested in a G-case with this PR. |
|
Thanks @karapeterson ! I'll implement those now. |
|
@karapeterson : How do I turn on MOAB to test? |
|
Use --driver moab in create_newcase. Or remove "Vmct" from the testname. |
|
You'll also have to merge #523 in to your local clone. |
…i_cpl_indices.F,seq_flds_mod.F90
add index_x2i_Fioo_frazilh (frazil heat flux from ocean) add index_x2i_Fioi_frazil (frazil mass flux from sea ice) add index_x2i_Fioi_frazils (frazil salt flux from sea ice) add index_x2i_Fioi_frazilh (frazil heat flux from sea ice) All added to mpassi_cpl_indices.F and seq_flds_mod.F90. Fioi_frazil and Fioi_frazils added to ice_comp_mct.F
Updates Icepack submodule to frazil coupling branch Adds ocean-ice coupling fields: frazil salt flux (Fioo_frazils) frazil enthalpy flux (Fioo_frazilh) defined consistent with freezingMeltPotential To use, set config_frazil_coupling_type to ‘omega-fluxes’ Backwards compatible with mpas-ocean for config_frazil_coupling_type = ‘external’ Stealth
Sea ice initialize now allows for the config_frazil_coupling_type option: "omega-fluxes"
Sea ice initialize NOW allows for config_frazil_coupling_type option: “omega-fluxes”
Removes double counting of frazil energy in coupler budget. Corrects possible but in temperature tendency of frazil melt. nBFB
Adds optional formulation in frazil.
Revert to original formulation with comments.
1. Initialized frazilMassFlux to 0 for SOM 2. Corrected indexing of component-level salt budget sum 3. Type in comment 4. Corrected definition of Fioo_frazils in MOAB to be consistent with mct
Also removes redundant write in coupler diagnostics Clean up confusing comments in ocean conservation member
Co-authored-by: Carolyn Begeman <cbegeman@lanl.gov>
Makes the following changes to be consistent with salt/energy flux name convention: 1. Fioi_frazil to Fioi_frazilm 2. Fioo_frazil to Fioo_frazilm
a735fde to
69b15d1
Compare
f1c42f8 to
d02fe6f
Compare
|
Thanks @njeffery for the rebase - I just rebased the |
|
Also, diff --git a/components/omega/src/drivers/coupled/omega_cpl_indices.F90 b/components/omega/src/drivers/coupled/omega_cpl_indices.F90
index 3c762a1e44..abe632731a 100644
--- a/components/omega/src/drivers/coupled/omega_cpl_indices.F90
+++ b/components/omega/src/drivers/coupled/omega_cpl_indices.F90
@@ -81,7 +81,7 @@ contains
export_field_names(7) = "So_dhdy"
export_field_names(8) = "Faoo_h2otemp"
export_field_names(9) = "Fioo_q"
- export_field_names(10) = "Fioo_frazil"
+ export_field_names(10) = "Fioo_frazilm"
! get mct_avect_index value for each export field name
call get_indices_from_names( &I can get Since that file hasn't been changes as part of this PR I can comment there directly and/or suggest changes. |
Flagged in gnu compilation
Fioo_frazil to Fioo_frazilm in omega. Needed for SMS_Vmct_Ln9.TL319_EC30to60E2r2.GOMEGA-JRA1p5.chrysalis_intel to pass.
|
@andrewdnolan and @darincomeau : I fixed the formatting issue in seq_diag_mct and pushed the frazil to frazilm change in omega. |
Updated version of #535
Fixes double counting of ocean heat flux during frazil ice formation.
For the ocean to ice coupler fields, Fioo_q now only contains the melt potential while Fioo_frazilh contains the heat from frazil ice formation. frazilh and q are combined in ice_comp_mct to reproduce the sea ice freezingMeltingPotential
Fioo_q is removed from driver-mct as it is no longer a heat flux.
A new flag, config_use_accumulated_frazil_energy default false, is added to the ocean model. Default retains the latent heat definition of frazil energy.
config_use_accumulated_frazil_energy = true uses the accumulatedFrazilHeat variable from frazil formation.
Tested in XS_2x5 GMPAS runs in 2 configurations:
Both completed successfully.
Test 1 was compared with darin's codebase from the previous PR (darincomeau@ea24e0f). Restart files at the end of day 11 showed differences in only 4 fields: o2x_ox_Fioo_frazilh, budg_dataG, o2x_ox_Fioo_q, and freezingMeltingPotential.
Differences in o2x_ox_Fioo_frazilh and freezingMeltingPotential were round off level only.
Differences in o2x_ox_Fioo_q, were all negative, as expected.
Differences in budg_dataG, also expected, were significant in regions of frazil ice formation.
Part of the frazil implementation documentation (sections 1.3-1.5). Currently here: https://www.overleaf.com/project/68896a760125362ca62587d1