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

Update glc coupler budgets for active Greenland ice sheet #6634

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

Conversation

stephenprice
Copy link
Contributor

@stephenprice stephenprice commented Sep 20, 2024

This PR adds functionality to coupler budget code so that x2g_ and l2x_ fields associated with Greenland ice sheet surface mass balance are accounted for in the coupler budget tables. Also added, but currently passing fields of zeroes, is support for g2x_ fields associated with iceberg fluxes when running with a dynamic Greenland ice sheet. Additional information for testing this PR is included in the notes below.

[BFB]

Update various bits of code needed for completing and testing of glc
coupler budgets. Still very much in the testing and debugging phase.
Code additions and debugging for addition of Greenland surface
mass balance terms to glc budget code, including temporary lines
for debugging and validation.
… component

Given known number of time steps smb flux is accumulated over, x2g_ smb
flux term in budget table now agrees with value calculated from mali and
cpl hist files (still need to add support for automatically determining
number of averaging steps).

Similar support on l2x_ side is close (summing product of accumulation
fluxes in different MECs w/ area fractions and cell areas) but off in
budget tables from cpl calculated values by ~5%.
Checkpointing changes to coupler budget code that accounts for
l2x_ and g2x_ Greenland surface mass balance fluxes, with various
lines supporting debugging outputs included. Cleaned up code
without debug lines to follow.
Clean up commenting and debugging lines, leaving bare minimum
needed to make draft PR understandable.
@stephenprice
Copy link
Contributor Author

Status summary and instructions for testing:
For fluxes related to surface mass balance and for simulations of 1 day duration only, l2x_ and x2g_ fields in the coupler budget tables "close" to within approx. 5-10%. A hypothesis is that the remaining 5-10% difference is due to the fact that fluxes on a sphere (from lnd / clm) are being mapped to a planer mesh (to glc / mali). Below is an example from a 1 day BG test case (details for recreating this included below):

Screen grab of budget table for net water budget with Greenland SMB-related fluxes in the "wgsmb" row:
Screenshot 2024-09-20 at 1 12 31 PM

The values in the table can be compared with values collated from the mali and coupler history files. The grab below shows output when applying an NCO script to do that (see below) to the cpl hist files from this 1 day BG case. This script pulls out the relevant coupler hist. vector, multiplies it by the relevant areas, sums the product, and then normalizes by earth surface area (approximately) to provide a value that can be compared to budget table values.

Output from NCO script to sum relevant fields from coupler history files:
Screenshot 2024-09-20 at 1 12 49 PM

The first three values are on the x2g_ side and represent (in order) 1) the summed flux from mali history files, 2) the summed flux from cpl hist files for x2g_Flgl using "model areas" and 3) the summed flux from cpl hist files for x2g_Flgl using "mapping file areas".

The last two values are on the l2x_ side and represent (in order) 1) the summed flux from l2x_Flgl using "model areas" and 2) the summed flux from l2x_Flgl using "mapping file areas" (identical).

Note that the latter two, when multiplied by the SMB renomalization factor listed in the coupler budget table (here, 0.8823), give a value (0.0125e-6) very close to the value provided in the wgsmb row and lnd column of the coupler budget table (0.0129e-6).

Remaining issues

  1. Currently, the x2g_ values in the coupler history file only work correctly for a run of 1 day. This is because the local coupler vector these fluxes are collected in represent an average value rather than a summed value (even though the 'acc' in the vector name, x2gacc_Flgl, implies 'accumulation' or summation). Thus, to recover the summed value, this vector must be multiplied by some number of time steps (here, the no. of lnd model steps in a day, 48). This value can be recovered using a counter (hack in current code) but something more robust is needed to account for runs of multiple days or longer. Similar sections of the budget code don't appear to have this problem and/or it is accounted for automatically.
  2. The discrepancy between the l2x_ (from lnd to coupler) and x2g_ (from cpl to glc) values in the table may be due to the spherical vs. planer mapping issue noted above. This may be treatable by the use of a specially generated mapping file (?) or something other correction factor applied within the code. This requires more discussion to decide on a solution.

Scripts to recreate run and cpl hist file analysis
A copy of the script to set up the relevant 1 day BG case can be found here:
/home/ac.sprice/e3sm_cases/BGelm.chrys.bash

It requires updating of a few shell / path variables at the top.

A copy of the script to sum and normalize fluxes from mali and cpl history files can be found here:
/lcrc/group/e3sm/ac.sprice/scratch/chrys/20240920.BGWCYCL1850.ne30pg2_r05_EC30to60E2r2_gis20.chrysalis.gnu.CplBudgetDevel/run/calcBudgetsFromHistFiles.sh

If placed in the relevant "run" directory, it requires only that the name of the relevant 1 day mali and cpl hist files be updated at the top of the script.

@rljacob
Copy link
Member

rljacob commented Oct 31, 2024

Notes: Jon has been meeting with Steve about this. Will test more for impact when no glc.

Copy link
Contributor Author

@stephenprice stephenprice left a comment

Choose a reason for hiding this comment

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

@jonbob -- This all looks great to me. Thanks for figuring out how to get it working properly.

One somewhat unrelated question - in line 4800, are we leaving "do_g2x=.true." unspecified because we are (currently) not sending any glc to coupler fields? But, once we start sending calving flux to coupler (for example) this would be explicitly included and set to true?

@jonbob
Copy link
Contributor

jonbob commented Nov 25, 2024

That's right -- we actually already have some fields in that part of the budget calculation, even if they are 0

@stephenprice
Copy link
Contributor Author

That's right -- we actually already have some fields in that part of the budget calculation, even if they are 0

... but because they are currently 0 we are just avoiding that part of the subroutine call for now (?).

@stephenprice stephenprice changed the title Update glc coupler budgets for active Greenland ice sheet [DRAFT] Update glc coupler budgets for active Greenland ice sheet Nov 26, 2024
@stephenprice stephenprice marked this pull request as ready for review November 26, 2024 17:10
@jonbob jonbob added the BFB PR leaves answers BFB label Nov 26, 2024
@jonbob
Copy link
Contributor

jonbob commented Nov 26, 2024

test merge passes:

  • SMS_D_Ld1.ne30pg2_r05_IcoswISC30E3r5.WCYCL1850.chrysalis_intel.allactive-wcprod
  • e3sm_landice_developer using gnu on chrysalis

verified the new budget lines are all 0 when smb values are not being passed

@jonbob jonbob requested a review from rljacob November 26, 2024 22:07
@jonbob
Copy link
Contributor

jonbob commented Dec 5, 2024

@stephenprice -- I pushed some commits to your branch to get the budget balanced. This is what I get now after a month from a SMS.ne30pg2_r05_IcoswISC30E3r5_gis20.BGWCYCL1850.chrysalis_gnu.allactive-gis20km run:

(seq_diag_print_mct) NET WATER BUDGET (kg/m2s*1e6): period = all_time: date =     10201     0
                           atm            lnd            rof            ocn         ice nh         ice sh            glc        *SUM*
         wfreeze     0.00000000     0.00000000     0.00000000    -0.18610602     0.18322969     0.00287633     0.00000000    -0.00000000
           wmelt     0.00000000     0.00000000     0.00000000    13.43122439     1.59396420   -15.03046056     0.00000000    -0.00527197
           wrain   -31.13715598     5.35477771     0.00000000    25.56288221     0.00394081     0.21047538     0.00000000    -0.00507987
           wsnow    -2.47463165     1.12544865     0.00000000     0.76868060     0.16655182     0.41349834     0.00000000    -0.00045224
          wpolar     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000
           wgsmb     0.00000000    -0.01882795     0.00000000     0.00000000     0.00000000     0.00000000     0.01882795     0.00000000
           wevap    33.37446619    -2.81504334     0.00000000   -30.46925396    -0.00902799    -0.08131534     0.00000000    -0.00017445
         wrunoff     0.00000000    -0.34837619     0.18919146     0.15878451     0.00000000     0.00000000     0.00000000    -0.00040021
         wfrzrof     0.00000000    -0.09188720     0.00000000     0.09168766     0.00000000     0.00000000     0.00000000    -0.00019954
          wirrig     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000
           *SUM*    -0.23732144     3.20609168     0.18919146     9.35789939     1.93865853   -14.48492585     0.01882795    -0.01157828

@stephenprice
Copy link
Contributor Author

@jonbob -- This branch has now been synched with master (as of ~5pm, 12-5-24). Let me know if you need anything else from me, and thanks again for finishing this off.

@jonbob
Copy link
Contributor

jonbob commented Dec 6, 2024

@rljacob - I think this is ready for you to look at. I'll test again, but I did make sure there is no impact when glc is not in the configuration other than a couple of new lines in the budget that are populated with 0's

@@ -1493,7 +1493,8 @@ subroutine glc_export_mct(g2x_g, errorCode)
!call route_ice_runoff(0.0_RKIND, & !Recuperate runoff routing switch code (originally in glc_route_ice_runoff module in earlier code), and attach to ice calving flux once present...
! rofi_to_ocn=Fogg_rofi, &
! rofi_to_ice=Figg_rofi)
g2x_g % rAttr(index_g2x_Fogg_rofi,n)=0.0 !...and remove these placeholders
g2x_g % rAttr(index_g2x_Fogg_rofi,n)=0.0!...and remove these placeholders
!g2x_g % rAttr(index_g2x_Fogg_rofi,n)=0.0001d0 ! dummy value to allow tracking through coupler
Copy link
Member

Choose a reason for hiding this comment

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

please remove commented out code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done(ish). Note that I left the commented out "call route_ice_runoff" in because that is something we are likely going to need to activate with further work on this section of the budgets.

Copy link
Member

@rljacob rljacob left a comment

Choose a reason for hiding this comment

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

Approving but not I have not carefully checked the logic. In my exploration of land ice coupling I didn't look at the budget diags.

Remove placeholder / commmented out code in glc_comp_mct

Correct revision history comment in glc section of seq_diag_mct
@jonbob
Copy link
Contributor

jonbob commented Dec 10, 2024

verified the budget is not impacted by this PR for non-MALI runs other than adding water and heat rows for smb that are populated with 0's, by running ne30pg2_r05_IcoswISC30E3r5 WCYCL1850 configurations for a month

@jonbob
Copy link
Contributor

jonbob commented Dec 10, 2024

A one-month run of SMS.ne30pg2_r05_IcoswISC30E3r5_gis20.BGWCYCL1850.chrysalis_gnu.allactive-gis20km has this for the one-month all_time budget:

(seq_diag_print_mct) NET AREA BUDGET (m2/m2): period = all_time: date =     10201     0
                           atm            lnd            ocn         ice nh         ice sh        *SUM*
            area    -1.00000000     0.29340918     0.64585715     0.02727751     0.03345216    -0.00000401

(seq_diag_print_mct) NET HEAT BUDGET (W/m2): period = all_time: date =     10201     0
                           atm            lnd            rof            ocn         ice nh         ice sh            glc        *SUM*
         hfreeze     0.00000000     0.00000000     0.00000000     0.06210358    -0.06114375    -0.00095983     0.00000000    -0.00000000
           hmelt     0.00000000     0.00000000     0.00000000    -5.34931396     0.79747421     4.55405801     0.00000000     0.00221825
          hnetsw  -166.28141845    35.04787271     0.00000000   129.02308230     0.03069174     2.15035241     0.00000000    -0.02941929
           hlwdn  -333.66523522    81.36596963     0.00000000   238.20803346     4.51562084     9.58010606     0.00000000     0.00449475
           hlwup   388.27658736   -99.48369701     0.00000000  -272.84638414    -5.65989063   -10.28543284     0.00000000     0.00118275
         hlatvap    83.51294851    -7.05493404     0.00000000   -76.20360416    -0.02520697    -0.22963963     0.00000000    -0.00043629
         hlatfus     0.82578458    -0.37556221     0.00000000    -0.25650872    -0.05557834    -0.13798440     0.00000000     0.00015091
          hiroff     0.00000000     0.03066276     0.00000000    -0.03059617     0.00000000     0.00000000     0.00000000     0.00006659
            hsen    19.75596745    -8.09200998     0.00000000   -11.78016796     0.01281887     0.10244754     0.00000000    -0.00094408
          hpolar     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000
        hh2otemp     0.58867312     0.00000000     0.00000000    -0.58904713     0.00000000     0.00000000     0.00000000    -0.00037401
           hgsmb     0.00000000    -0.00628289     0.00000000     0.00000000     0.00000000     0.00000000     0.00628289     0.00000000
           *SUM*    -6.98669265     1.43201896     0.00000000     0.23759709    -0.44521404     5.73294732     0.00628289    -0.02306042

(seq_diag_print_mct) NET WATER BUDGET (kg/m2s*1e6): period = all_time: date =     10201     0
                           atm            lnd            rof            ocn         ice nh         ice sh            glc        *SUM*
         wfreeze     0.00000000     0.00000000     0.00000000    -0.18610602     0.18322969     0.00287633     0.00000000    -0.00000000
           wmelt     0.00000000     0.00000000     0.00000000    13.43122439     1.59396420   -15.03046056     0.00000000    -0.00527197
           wrain   -31.13715598     5.35477771     0.00000000    25.56288221     0.00394081     0.21047538     0.00000000    -0.00507987
           wsnow    -2.47463165     1.12544865     0.00000000     0.76868060     0.16655182     0.41349834     0.00000000    -0.00045224
          wpolar     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000
           wgsmb     0.00000000    -0.01882795     0.00000000     0.00000000     0.00000000     0.00000000     0.01882795     0.00000000
           wevap    33.37446619    -2.81504334     0.00000000   -30.46925396    -0.00902799    -0.08131534     0.00000000    -0.00017445
         wrunoff     0.00000000    -0.34837619     0.18919146     0.15878451     0.00000000     0.00000000     0.00000000    -0.00040021
         wfrzrof     0.00000000    -0.09188720     0.00000000     0.09168766     0.00000000     0.00000000     0.00000000    -0.00019954
          wirrig     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000     0.00000000
           *SUM*    -0.23732144     3.20609168     0.18919146     9.35789939     1.93865853   -14.48492585     0.01882795    -0.01157828

@jonbob
Copy link
Contributor

jonbob commented Dec 10, 2024

passes:

  • SMS_D_Ld1.ne30pg2_r05_IcoswISC30E3r5.WCYCL1850.chrysalis_intel.allactive-wcprod

but shows DIFFs running e3sm_landice_developer. @stephenprice -- the change I made to the renormalization to use lfrin instead of lfrac will change the results. Do you or @chloewhicker want to make a longer run to make sure this impact s OK before merging this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants