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

Option to provide enthalpy fluxes via NUOPC coupler #214

Merged
merged 8 commits into from
Apr 21, 2022

Conversation

gustavo-marques
Copy link
Collaborator

@gustavo-marques gustavo-marques commented Mar 29, 2022

This PR must be evaluated in conjunction with ESCOMP/CMEPS#278

These changes allow MOM6 to receive enthalpy fluxes via coupler, instead of having them being computed inside the model. This option is only implemented in the NUOPC cap. To control how enthalpy fluxes are provided, a new MOM_input parameter is introduced ENTHALPY_FROM_COUPLER. Currently, by default, this parameter is set to False (MOM6 will compute the enthalpy terms), but this can be changed in a future PR or via MOM_interface.

When cesm_coupled=True and ENTHALPY_FROM_COUPLER=True, the NUOPC cap allocates fluxes%heat_content_evap. The latter is then used to control if MOM6 needs to compute the enthalpy fluxes and how/which diagnostics should be calculated or accounted for. The heat contribution from mass entering/leaving the ocean is considered using the following six terms provided by the coupler:

  • heat_content_evap
  • heat_content_cond
  • heat_content_fprec
  • heat_content_lprec
  • heat_content_lrunoff
  • heat_content_frunoff

Fields heat_content_massout and heat_content_massin are no longer used/allocated when ENTHALPY_FROM_COUPLER=True. This is because MOM6 can no longer determine if the corresponding heat content is from mass being added/removed into/from the ocean.

Consistency/Conservation checks

This notebook documents consistency checks for heat, mass, and salt, where global changes are within truncation error of the corresponding forcing applied ✔️

This notebook provides a comparison between a yearly-average MOM6 history file against the heat and water budget tables generated by the coupler for the second year of a BMOM simulation ✔️

Diagnostics

  • Diagnostics heat_content_icemelt and total_heat_content_icemelt were removed. This explains why the regression tests are failing;
  • When ENTHALPY_FROM_COUPLER=True, two new diagnostics become available: heat_content_evap and total_heat_content_evap; and the following diagnostics are no longer available: heat_content_massout, heat_content_massin, total_heat_content_massout, and total_heat_content_massin.

Summary of additional commits:

  • Remove lrunoff_hflx and frunoff_hflx and mean_runoff_heat_flx and mean_calving_heat_flx from the NUOPC cap. These were never used;
  • Deletes all entries associated with heat_content_icemelt. The enthalpy associated with the mass from sea ice formation/melting is already accounted for in seaice_melt_heat. A note explaining this has been added to the code;
  • Modify forcing_diagnostics so that diagnostics are properly computed whether enthalpy terms are provided via coupler or computed by MOM6. This is done by introducing a logical variable mom_enthalpy (default = true, meaning diagnostics are computed in the default way, using heat_content_massout). When the optional argument (enthalpy) is present and true, mom_enthalpy = false. In this case, diagnostics are computed using heat_content_evap instead of heat_content_massout.
  • Introduces a new constant (EnthalpyConst = 1.0, by default) which is set to 0.0 when fluxes%heat_content_evap is associated. This constant is used in the expression that accounts for the temperature of the mass exchange (dTemp) to avoid double-counting for the enthalpy terms when they are provided via coupler.

Change in answers

  • This PR will change answers for the aux_mom test suit because heat_content_icemelt has been removed. As mentioned before, the enthalpy associated with the mass from sea ice formation/melting is already accounted for in seaice_melt_heat. Answers will also change once ENTHALPY_FROM_COUPLER=True;
  • All answers and output are bitwise identical in the MOM6-examples test suite.

* Remove lrunoff_hflx and frunoff_hflx from the IOB type. These
are never used;

* mean_runoff_heat_flx and mean_calving_heat_flx are are never
advertized, so these have been deleted;

* If cesm_coupled=true, six new fields are imported:
  - heat_content_lprec
  - heat_content_fprec
  - heat_content_evap
  - heat_content_cond
  - heat_content_rofl
  - heat_content_rofi

* Add a new parameter (ENTHALPY_FROM_COUPLER) to control if the
enthalpy associated with mass entering/leaving the ocean is provided
via the coupler or calculated in MOM6.
* If fluxes%heat_content_evap is associated, which will only happens in CESM
and when ENTHALPY_FROM_COUPLER=True, the heat contribution from mass
entering/leaving the ocean is accounted for using the six enthalpy terms
provided by the coupler: heat_content_evap, heat_content_lprec,
heat_content_fprec, heat_content_cond, heat_content_lrunoff, and
heat_content_frunoff. If fluxes%heat_content_evap is not associated,
these terms are accounted for via tv%TempxPmE;

* TODO: check that these changes do not change answers for GFDL.
This commit change the description of parameter ENTHALPY_FROM_COUPLER,
and it changes the call so that ENTHALPY_FROM_COUPLER is now logged
at this point.
* Introduces a new constant (EnthalpyConst = 1.0, by default) which
is set to 0.0 when fluxes%heat_content_evap is associated. This
constant is used in the expression that accounts for the temperature
 of the mass exchange (dTemp) to avoid double-couting for the enthalpy
terms when they are provided via coupler.

* Use heat_content_evap to determine if the diagostics heat_content_massin,
heat_content_massout, and TempxPmE should be calculated.
* Modify allocate_forcing_by_group so that heat_content_evap is allocated
and heat_content_massin and heat_content_massout *are not* allocated
when enthlapy terms are provided via coupler. This is done via optional
argument (hevap);

* Apply all modifications needed to include a new field in the
flux type (heat_content_evap): rotate_array, deallocate, fluxes_accumulate,
hchksum, and new diagnostics;

* Modify forcing_diagnostics so that diagnostics are properly computed
whether enthalpy terms are provided via coupler or computed by MOM6. This is
done by introducing a logical variable mom_enthalpy (default = true, meaning
dianostics are computed in the default way, using heat_content_massout). When
then optional argument (enthalpy) is present and true, mom_enthalpy = false.
In this case, diagnositcs are computed using heat_content_evap instead of
heat_content_massout.

* Deletes all entries associated with heat_content_icemelt. The enthalpy
associated with the mass from sea ice formation/melting is already accounted
for in field seaice_melt_heat. A note explaining this is also added.

Subroutine extractFluxes1d:

* When enthalpy terms are computed by MOM6, their contribution to the heat budget
is accounted for in subroutine applyBoundaryFluxesInOut. On the other hand, when
enthalpy terms are provided via coupler, they are included in net_heat in
this subroutine;

* By default the heat content from mass entering and leaving the ocean (enthalpy)
is diagnosed in this subroutine. When heat_content_evap is associated,
the enthalpy terms are provided via coupler and, therefore, they do not need
to be computed again. A logical variable (do_enthalpy, deault = true) is
introduced for this purposes. If luxes%heat_content_evap, do_enthalpy = false.
@gustavo-marques gustavo-marques marked this pull request as ready for review April 5, 2022 21:15
@gustavo-marques
Copy link
Collaborator Author

@alperaltuntas, I have not tested these changes when driver = mct. There might be an issue because heat_content_icemelt has been deleted from the fluxes type. Please let me know if that's the case and I will make the changes needed in the MCT cap.

@mvertens
Copy link

mvertens commented Apr 5, 2022

@gustavo-marques - is this good time to depracate the mct cap funcitonality? With cice6 coming in and not having an mct cap all simulations with cice6 and testing will only be with nuopc.

@gustavo-marques
Copy link
Collaborator Author

@mvertens: yes, I think so but we need to make sure that others using CESM/MOM6 are okay with that. @klindsay28 and @mnlevy1981, are you still using MCT for the MARBL tests?

@mnlevy1981
Copy link
Collaborator

@mvertens: yes, I think so but we need to make sure that others using CESM/MOM6 are okay with that. @klindsay28 and @mnlevy1981, are you still using MCT for the MARBL tests?

My MARBL branch is based off of cesm2_3_alpha05b, and still relies on MCT. I haven't had a chance to work on the driver in a month, and the first thing I want to do when I come back to it is merge in the latest dev/ncar / update to a more recent CESM tag. I'd really like to have MCT available in that update so I can do some side-by-side comparisons and make sure we are receiving all the necessary fluxes correctly. It might be a couple of weeks before I get a chance to do that, tthough.

fluxes%heat_content_fprec(i,j) = US%W_m2_to_QRZ_T * IOB%hsnow(i-i0,j-j0) * G%mask2dT(i,j)

if (associated(IOB%hevap)) &
fluxes%heat_content_evap(i,j) = US%W_m2_to_QRZ_T * IOB%hevap(i-i0,j-j0) * G%mask2dT(i,j)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am following the code correctly, IOB%hevap is allocated at all times when cesm_coupled is True. However, fluxes%heat_content_evap gets allocated only if ENTHALPY_FROM_COUPLER is set to True, which is problematic. I think IOB%hevap should also be allocated only when ENTHALPY_FROM_COUPLER is set to True. This may apply to other heat_content components too. @gustavo-marques ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I could not find an easy way to control the allocation of the enthalpy terms in the IOB type. Instead, I added a conditional statement for setting fluxes%heat_content_* in this subroutine. I tested this modification by running a BMOM case with ENTHALPY_FROM_COUPLER = False and there were no issues.

* only writes fluxes%heat_content_* when ENTHALPY_FROM_COUPLER = True.
@codecov-commenter
Copy link

Codecov Report

Merging #214 (89bb058) into dev/ncar (6963b22) will decrease coverage by 0.00%.
The diff coverage is 33.98%.

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

@@             Coverage Diff              @@
##           dev/ncar     #214      +/-   ##
============================================
- Coverage     28.87%   28.87%   -0.01%     
============================================
  Files           243      243              
  Lines         71875    71899      +24     
============================================
+ Hits          20756    20760       +4     
- Misses        51119    51139      +20     
Impacted Files Coverage Δ
src/diagnostics/MOM_sum_output.F90 62.13% <28.57%> (-0.50%) ⬇️
src/core/MOM_forcing_type.F90 42.65% <32.87%> (-0.41%) ⬇️
...rc/parameterizations/vertical/MOM_diabatic_aux.F90 34.98% <39.13%> (+0.31%) ⬆️
src/framework/MOM_restart.F90 25.68% <0.00%> (-0.27%) ⬇️
config_src/drivers/solo_driver/MOM_driver.F90 67.88% <0.00%> (-0.14%) ⬇️
src/ocean_data_assim/MOM_oda_driver.F90 0.00% <0.00%> (ø)
src/user/baroclinic_zone_initialization.F90 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6963b22...fd1728b. Read the comment docs.

Copy link
Member

@alperaltuntas alperaltuntas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All aux_mom tests pass. Answer changes due to changed field list.

@alperaltuntas
Copy link
Member

@gustavo-marques, could you confirm the github actions test failure is expected?

@gustavo-marques
Copy link
Collaborator Author

@alperaltuntas, thanks. Diagnostics heat_content_icemelt and total_heat_content_icemelt were removed and this explains why the regression tests are failing.

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.

5 participants