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

OCN to GLC thermal forcing coupling #94

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

matthewhoffman
Copy link
Collaborator

@matthewhoffman matthewhoffman commented Apr 24, 2024

This pull request introduces coupling from OCN to GLC to pass thermal forcing at a prescribed ocean depth (300 m) from MPAS-Ocean to MALI, where MALI uses it to calculate grounded marine melting through an existing 'facemelting' parameterization. Facemelting as a function of ocean thermal state is a critical OCN/GLC coupling for Greenland, but it is relevant to Antarctica as well. This OCN-GLC thermal forcing coupling is activated whenever OCN is present and GLC is active.

This PR has pieces in MPAS-Ocean, the coupler, and MALI:

  • In MPAS-Ocean, a new avgThermalForcingAtCritDepth field is added and calculated. The depth at which to calculate the thermal forcing is namelist configurable. The default is 300 m.
  • In MALI, the field passed from the coupler is collected in ismip6_2dThermalForcing and used in the existing facemelting parameterization. Namelist and streams are updated to use facemelting in all simulations and output relevant variables. For compsets where TF is not being coupled, it will have values of 0 and result in no facemelting being applied; it is safe to have this option generally turned on.
  • In the coupler, a new remapping object is created that handles the TF mapping independently of any other fields passed from OCN to GLC. New mapping files are added. Any coupling variables related to the existing ice-shelf coupling now include the 'shelf' suffix and all coupling variables related to this new thermal-forcing coupling have the 'tf' suffix.
  • A new compset is created that is a standard G-case but with active MALI. New mapping files are added between the relevant grids for the new mapper.
  • The new OCN2GLC_TF_SMAPNAME mapping should be a nearest source to destination mapping with the MPAS-Ocean source mesh masked to only include grid cells that are deeper than the critical depth to avoid extrapolating undefined values. A tool to generate that map file is here: Add script for adding map of sufficiently deep ocean bathymetry to a scrip file MPAS-Dev/MPAS-Tools#578
  • Two new model_grids are added that are compatible with this feature and include the special mapping file required: TL319_IcoswISC30E3r5_gis1to10kmR2 and TL319_oQU240wLI_gis20
  • The new coupling is controlled by a new namelist option in MPAS-Ocean: config_glc_thermal_forcing_coupling_mode. It defaults to 'off' and there are no compsets that explicitly set it for now, making this a stealth feature.

@matthewhoffman
Copy link
Collaborator Author

@cbegeman & @jonbob , I tagged you both on this PR, though we may want to bring in some other people to review/contribute, as well. The PR functions so in some sense is complete, but we may want to discuss some of the implementation choices and revise. I opened the PR now so you have some concrete to look at as we discuss.

Copy link
Collaborator

@cbegeman cbegeman left a comment

Choose a reason for hiding this comment

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

The 300m thermal forcing field seems right on the ocean side. Given my limited coupler development experience, I think this looks good. Would it be helpful for me to look over some of the cpl and output files from your recent test? Or run this test on another machine TL319_IcoswISC30E3r5_gis20?

@matthewhoffman matthewhoffman force-pushed the matthewhoffman/mali/gis_ocn_to_glc_coupling branch from 439ebbd to a91868e Compare May 13, 2024 19:07
@matthewhoffman
Copy link
Collaborator Author

Testing

Set up and ran case with the following. Note that a custom mapping file is required that is not yet on the inputdata server.

export CASE_ROOT=/home/$USER/e3sm-gis/e3sm_cases
export COMPSET=GMPAS-JRA1p5-MALI
export GRID=TL319_IcoswISC30E3r5_gis20
export COMPILER=gnu
export E3SM_CASE=`date +"%Y%m%d"`.${COMPSET}.${GRID}.GIS-ocn-TFcpl-test.${MACHINE}

cd $E3SM_ROOT/cime/scripts
./create_newcase \
-case $CASE_ROOT/$E3SM_CASE \
-mach $MACHINE \
-compset $COMPSET \
-res $GRID \
--compiler $COMPILER

cd $CASE_ROOT/$E3SM_CASE
./case.setup
./xmlchange OCN2GLC_TF_SMAPNAME="/home/ac.mhoffman/e3sm-gis/mapping_files/map_IcoswISC30E3r5_to_gis20km_esmfneareststod.20240422.deeperThan300m.nc"
./case.build

./xmlchange STOP_OPTION=nmonths
./xmlchange STOP_N=1
./xmlchange REST_OPTION=nmonths
./xmlchange REST_N=1
./xmlchange JOB_QUEUE=compute
./xmlchange JOB_WALLCLOCK_TIME="01:00:00"

./case.submit

This panel on the left shows the thermal forcing on the MALI mesh after nearest neighbor remapping from MPAS-Ocean. IThe panel on the right shows the time-series of thermal forcing for an arbitrary grid point, showing that it is indeed changing in time (x-axis units are days, which is the coupling interval).
image

This figure shows the resulting facemelting thickness calculated in MALI based off of the thermal forcing from MPAS-Ocean. Blue are ocean cells and white contour is ice-sheet margin. You can see that we are only getting facemelting in a small number of cells. This is because the 20 km mesh is too coarse to resolve fjords and there are not a lot of cells where the ice-sheet margin terminates against the ocean.
image

@matthewhoffman matthewhoffman requested a review from xylar May 13, 2024 20:32
@matthewhoffman
Copy link
Collaborator Author

@cbegeman , thank for your initial review. I went ahead and made the depth at which to calculate thermal forcing a namelist option and added information to the option description that a custom mapping file needs to be generated to be consistent with that depth. I also did some additional cleanup to better differentiate the coupling variables for this TF coupling from the existing ice-shelf coupling. If you want to try running this on Perlmutter, that would be good. We are restricted to machines where Albany exists, so Perlmutter (with gnu) would be the best place to try. You will also need the custom mapping file that is currently in my home directory on Chrysalis. Once we are happy with the branch, I'll coordinate with Jon about the best way to name it.

@matthewhoffman
Copy link
Collaborator Author

@jonbob and @xylar , everything is working as I would like and this is ready for review. Once the two of you and Carolyn are happy with it, I can open a formal PR on the main E3SM repo and ask Rob to review it. I'm leaving for two weeks of vacation at the end of next week, so if we're able to get it to that stage before I leave, that would be great, but it's ok if not.

It would be good to get #95 merged so we can use it to confirm that this PR doesn't break any of the shelf coupling. (Or I can test that with a temporary merge of the two branches)

@cbegeman
Copy link
Collaborator

@matthewhoffman Great! I can test it on perlmutter. I'll get in touch with you to get that path when I'm ready to set it up (in the next day or two).

@matthewhoffman
Copy link
Collaborator Author

@cbegeman , sounds good! (That path is buried in my notes above for setting up the case: /home/ac.mhoffman/e3sm-gis/mapping_files/map_IcoswISC30E3r5_to_gis20km_esmfneareststod.20240422.deeperThan300m.nc)

@matthewhoffman
Copy link
Collaborator Author

Testing with Icos ocean mesh coupled to 1km GIS mesh yields expected results. Here is a zoom-in on Humboldt Glacier, the widest marine-terminating glacier in Greenland:
image

and here is the northwest region of Greenland, which contains many small marine outlet glaciers:
image

Copy link
Collaborator

@cbegeman cbegeman left a comment

Choose a reason for hiding this comment

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

These changes look good to me! I ran the test on perlmutter cpu at /pscratch/sd/c/cbegeman/e3sm_scratch/pm-cpu/20240529.GMPAS-JRA1p5-MALI.TL319_IcoswISC30E3r5_gis20.GIS-ocn-TFcpl-test.pm-cpu and verified that it ran and produced non-zero faceMeltingThickness.

Copy link
Collaborator

@xylar xylar left a comment

Choose a reason for hiding this comment

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

A few comments for now.

cime_config/config_grids.xml Show resolved Hide resolved
@matthewhoffman
Copy link
Collaborator Author

@xylar and @jonbob , I've addressed the two comments from Xylar's first pass of this PR, and it's ready for further review when you both have time. I'd be happy to meet and walk you through the implementation if that would help.

@xylar
Copy link
Collaborator

xylar commented Sep 4, 2024

@matthewhoffman, I think this looks good and is ready to go to E3SM once @jonbob agrees.

The one question that came to mind when I looked through the code was whether we want a flag and/or package for these changes. Right now as it's written, we'll be computing the thermal forcing at the given depth in all E3SM simulations with active ocean regardless of whether we're coupling to MALI or not. I think that's okay but wanted to make sure that's the approach we want to take. I don't believe the TF will be written out to any stream by default so the information is just being lost if it doesn't go to MALI. There's some complexity in figuring out if we're coupling to glc in order to set a namelist option to turn this feature on or off, so we may not want to go down that road. I just want us to have weighed the pros and cons.

@matthewhoffman
Copy link
Collaborator Author

matthewhoffman commented Sep 6, 2024

@xylar , that's a good point. We could so something analogous to the ice-shelf basal melting in the coupler, which is activated when config_land_ice_flux_mode = 'coupled' in the ocean namelist. We would eventually want a compset that enables this feature, but for now we could put it in a testmod usernl like we do here: https://github.com/E3SM-Project/E3SM/blob/master/components/mpas-ocean/cime_config/testdefs/testmods_dirs/mpaso/ocn_glcshelf/user_nl_mpaso

What do you think? That might be better than leaving it fully exposed as it is now.

Looking closer at what I had done, the coupler operations for the TF coupling are only activated when ocean is present and glc is prognostic:

@@ -1768,6 +1771,7 @@ subroutine cime_init()
    if (ocn_present) then
       if (atm_prognostic) ocn_c2_atm = .true.
       if (atm_present   ) ocn_c2_atm = .true. ! needed for aoflux calc if aoflux=atm
       if (glc_prognostic) ocn_c2_glctf = .true.

So it would be nice to have the ocean calculations also only occur when these conditions are met. I'm not sure offhand if it's possible for the information to flow that direction. @jonbob might know or I will take a closer look.

@xylar
Copy link
Collaborator

xylar commented Sep 6, 2024

Yes, I think that would be my preference. For now, this would be a stealth feature only activated manually with a user namelist option.

@jonbob
Copy link
Collaborator

jonbob commented Sep 19, 2024

@matthewhoffman, @xylar -- it certainly is easy for the ocean to know when the GLC component is MALI, and change the default for config_glc_thermal_forcing_coupling_mode based on that. Do you anticipate we would always want that to be true if MALI is coupled to mpas-o? Also, I'm happy to make the files to support the oQU240wLI configuration, if that makes sense.

@matthewhoffman
Copy link
Collaborator Author

@jonbob , I'm comfortable with the current implementation of this being controlled by a namelist option. I think we will need to further evaluation of how this interacts with the glcshelf coupling and may eventually have a Greenland and an Antarctica mode, so making this a stealth feature that has to be explicitly activated for now seems appropriate.

Do you think we should move this test to the ocean stealth features suite? If so, does the extra cost of keeping this on the v3 LR ocean mesh matter?

@jonbob
Copy link
Collaborator

jonbob commented Sep 19, 2024

Thanks @matthewhoffman -- we'll leave it as a namelist-controlled stealth feature then. It probably does belong in the e3sm_ocnice_stealth_features suite then -- but that gets run on glc12 (a google cloud platform) so we have to be careful about the amount of new data it requires and the runtime. It may be worth getting it working with the smaller oQU240wLI grid?

@matthewhoffman
Copy link
Collaborator Author

Ok, yes, let's add that grid. I'm sure it'll be useful in other contexts as we get these features running more regularly so might as well take care of it now. Let me know if I can do anything to help.

This adds compsets and new output variables to facilitate the E3SM and E3SM-MMF
contributions to phase 1 & 2 of the radiative-convective equilibrium model inter-comparison project (RCEMIP).

NOTE: in the original RCE compsets there was a slight error in the value of constant_zenith_deg being off by 1/100. This difference is inconsequential, but I wanted to fix it here to ensure consistency with the other RCEMIP models.

[non-BFB] - only for RCE cases because of updated constant_zenith_deg value
@matthewhoffman matthewhoffman force-pushed the matthewhoffman/mali/gis_ocn_to_glc_coupling branch from 38733f0 to 8e6e892 Compare September 20, 2024 18:06
matthewhoffman and others added 17 commits September 20, 2024 13:24
This commits adds a new field to MPAS-Ocean called
avgThermalForcing300m.  It is calculated as the thermal forcing
(difference between ocean temperature local freezing temperature) at 300
m depth.  It uses the temperature of the layer shallower than 300 m.
This could be replaced with vertical interpolation to get the value
exactly at 300 m.  The TF at 300 m is time averaged over the ocean coupling
interval.
This commit adds the So_tf300 coupler field for passing thermal forcing
at 300m through the coupler.  It also passes the avgThermalForcing300m
added to MPAS-Ocean in the previous commit to this coupler field, and
send it to the ismip6_2dThermalForcing field in MALI as the destination.

Note that a new list of coupler fields called x2g_tf_states_from_ocn
has been added to seq_flds_mod to differentiate this coupling field from
the iceshelf OCN/GLC coupling, which is handled differently.
This commit enables facemelting in MALI so that the new TF field will be
used to calculate a melt rate.  This is safe to enable in general,
because for situations where thermal forcing is not calculated  or not
applicable, it will be zero and facemelting will in turn be zero.  This
commit also updates the MALI output stream to write out the TF and
facemelting fields.

Note that this commit also changes the MALI output stream interval to
daily.  While that might not be the ideal long-term production solution,
it is likely the desired frequency for model development for the
forseeable future.
This commits defines the mapping for thermal forcing from ocean to glc.
It defines a special mapper for thermal forcing state (ocn2glc_tf_smap)
in CIME and MCT xml files.  It also declares and allocates mapper_So2g_tf
in prep_glc_mod but does not initialize or use it yet.

The mapping file requires some special treatment:
* it needs to use nearest neighbor mapping (which differs from most
  state remapping)
* it needs to include grid_imask in the ocean scrip file to only consider
  ocean cells valid if they are deeper than 300m
1. Differnetiate new ocn2glc TF coupling from existing ocn2glcshelf coupling
Create ocn_c2_glc logical in cime_comp_mod.  This controls the new
ocn2glc TF (thermal forcing) coupling separately from the existing
ocn2glcshelf coupling, which has its own ocn_c2_glcshelf flag already.
The new TF coupling will be active whenever ocn is present and glc is
prognostic.  These flags are used to initialize different mappers
independent of each other in prep_glc_init.  Those flags are also now
passed to prep_glc_calc_o2x_gx to control which mapping actually occurs.

2. Implement prep_glc_mrg_ocn
The existing ocn2glcshelf coupling handled a number of operations in
unusual ways because the fluxes themselves are calculated in the
coupler, so it was missing some of the standard operations for simply
passing fields between components.  As such, adding the new TF coupling
requires creating a prep_glc_mrg_ocn routine, which is responsible for
transferring fields from o2x_g to x2g_g arrays.  This routine was copied
closely from the existing prep_glc_mrg_lnd routine.

With this commit, the ocean TF field is successfully passed to MALI.
The entirety of existing ocn->glc coupling was for the ice-shelf
coupling.  To better differentiate the coupling in this branch based on
thermal forcing, this commit ensures there is either a 'shelf' or 'tf'
suffix on all ocn-glc coupling variables.
This allows testing with a MALI mesh where fjords are resolved.
The facemelting parameterization requires a subglacial runoff field as
an input.  Eventually, we may have this calculated prognostically in
E3SM from MALI and/or ELM, but that is not planned for the near-term.
Until then, a reasonable approximation is to use a constant historical
climatological field.

This commit updates the mpas.gis1to10kmR2 input file to include a
ismip6Runoff field provided by ISMIP6.  The field used is a 1995-2014
mean from the MIROC5 model, which was bias-corrected to match MAR over
that period.  See www.the-cryosphere.net/14/985/2020/ Fig. 2 and related
text for details.
This uses the layer that the desired depth is in, rather than the layer
above it.

Co-authored-by: Xylar Asay-Davis <[email protected]>
This commit adds an MPAS-Ocean namelist option for activating the
OCN-GLC TF coupling.  This option controls if E3SM should enable the
OCN-GLC TF coupling and also makes the associated TF calculations
conditional on the option being active.  The option defaults to false
and there currently are not any compsets that activate it, so it can
only be enabled with a namelist usermod at present.
Eventually, when we have compsets that require this mode, it should be
controlled analogously to MPASO_ISMF.
@matthewhoffman
Copy link
Collaborator Author

PR moved to main E3SM repo at: E3SM-Project#6632

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.

6 participants