Skip to content

Add subgrid scale correction scheme and init mode test cases#6288

Merged
jonbob merged 12 commits into
E3SM-Project:masterfrom
sbrus89:ocn/subgrid
May 7, 2024
Merged

Add subgrid scale correction scheme and init mode test cases#6288
jonbob merged 12 commits into
E3SM-Project:masterfrom
sbrus89:ocn/subgrid

Conversation

@sbrus89
Copy link
Copy Markdown
Contributor

@sbrus89 sbrus89 commented Mar 8, 2024

This pull request adds a subgrid scale correction scheme into MPAS-Ocean. This capability has been developed under the ESMD area of the ICoM project in collaboration with Dam Wirasaet at U. of Notre Dame. It is currently meant only for single-layer, barotropic coastal flooding applications and is implemented as a default-off stealth feature.

The subgrid corrections introduced here account for the nonlinear relationship between ssh and grid-averaged wet volume per unit area in partially wet cells. These relationships are calculated as lookup tables from high-resolution (subgrid scale) bathymetry data. This lookup table calculation is done as a pre-processing step implemented in MPAS-Ocean init mode. Using the subgrid correction scheme increases the accuracy of the wetting/drying transition. It is especially advantageous at coarser resolutions, where it can increase model efficiency by reducing the level of resolution required to represent the effects of small-scale conveyances.

The design document for this feature can be found here: MPAS_O_SGS_design_doc.pdf

Two test cases have been used to 1) verify the accuracy/convergence of the subgrid capability and 2) demonstrate its effectiveness in a realistic coastal domain. These test cases are:

  1. A subgrid version of the existing parabolic bowl wetting and drying test case

  2. A simulation of Buttermilk Bay, MA with idealized tidal boundary forcing

These test cases have been implemented in compass in this pull request: MPAS-Dev/compass#785. See images there for testing results.

More information on the subgrid correction methodology can be found in Kennedy et al. 2019. This paper also discusses the Buttermilk Bay test case.

This PR also includes a new (optional) update to the existing wetting and drying algorithm that takes into account the ssh gradient between cells that share a previously limited edge. This treatment of limited edges works both independent of and with the subgrid corrections. The update helps improves the wetting and drying convergence for the parabolic bowl test case. However, this approach is currently limited to a single layer configuration. A big thanks goes out to Dam for contributing this improvement to the standard wetting and drying scheme.

[NML]
[BFB] (for all standard E3SM tests)

@sbrus89 sbrus89 added MPAS-ocean Concerning the MPAS-ocean model coupled to E3SM. Stealth PR has feature which, if turned on, could change climate. fka FCC labels Mar 8, 2024
@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Mar 8, 2024

With the subgrid corrections off, I have verified this PR is BFB with v3.0.0 for the compass nightly test suite on Anvil (intel-mpi).

@mark-petersen
Copy link
Copy Markdown
Contributor

mark-petersen commented Mar 15, 2024

Compiled MPAS-O standalone with intel on chrysalis and gnu on perlmutter. This branch compares BFB against the master branchpoint with the nightly test suite on both, using all default flags (subgrid scale correction scheme off).

@sbrus89 sbrus89 added MPAS-Ocean standalone Issues and features for standalone MPAS-Ocean code that dont impact E3SM. BFB PR leaves answers BFB and removed Stealth PR has feature which, if turned on, could change climate. fka FCC labels Mar 15, 2024
@mark-petersen
Copy link
Copy Markdown
Contributor

@sbrus89, these simple tests both fail for me right now, on chrysalis and perlmutter, after I git submodule update --init and cd cime/scripts

Both pass for the master branch point. On this branch, they fail during build. On chrysalis:

./create_test SMS_Ln9.T62_oQU240.GMPAS-IAF.chrysalis_gnu
...
Starting MODEL_BUILD for test SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel with 7 procs
Finished MODEL_BUILD for test SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel in 355.692790 seconds (FAIL). [COMPLETED 1 of 1]
    Case dir: /pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq
    Errors were:
        Building test for SMS in directory /pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq
        ERROR: BUILD FAIL: build e3sm failed, cat /pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq/bld/e3sm.bldlog.240315-111731

on perlmutter:

./create_test SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel -p e3sm -q debug --walltime 00:30:00

Starting MODEL_BUILD for test SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel with 7 procs
Finished MODEL_BUILD for test SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel in 355.692790 seconds (FAIL). [COMPLETED 1 of 1]
    Case dir: /pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq
    Errors were:
        Building test for SMS in directory /pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq
        ERROR: BUILD FAIL: build e3sm failed, cat /pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq/bld/e3sm.bldlog.240315-111731

It looks like we are just not compiling your subgrid module in E3SM, and it is missing in the cmake file:

f90(43): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [OCN_SUBGRID]
   use ocn_subgrid
-------^
/pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq/bld/cmake-bld/core_ocean/shared/mpas_ocn_tidal_forcing.f90(263): error #6404: This name does not have a type, and must have an explicit type.   [SUBGRIDSSHCELLTABLERANGE]
            tidalHeight = max(tidalHeight, subgridSShCellTableRange(3,iCell) ) ;
-------------------------------------------^
/pscratch/sd/m/mpeterse/e3sm_scratch/pm-cpu/SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel.20240315_111539_kuorhq/bld/cmake-bld/core_ocean/shared/mpas_ocn_tidal_forcing.f90(263): error #6363: The intrinsic data types of the arguments must be the same.   [MAX]
            tidalHeight = max(tidalHeight, subgridSShCellTableRange(3,iCell) ) ;
-------------------------------------------^

Check this file: components/mpas-ocean/src/ocean.cmake
and try the tests above. Thanks!

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Mar 15, 2024

@mark-petersen, thanks for catching this. ./create_test SMS_Ln9.T62_oQU240.GMPAS-IAF.chrysalis_gnu now builds successfully.

@mark-petersen
Copy link
Copy Markdown
Contributor

Now passes:

./create_test SMS_Ln9.T62_oQU240.GMPAS-IAF.chrysalis_gnu
./create_test SMS_Ln9.T62_oQU240.GMPAS-IAF.pm-cpu_intel -p e3sm -q debug --walltime 00:30:00

Copy link
Copy Markdown
Contributor

@mark-petersen mark-petersen left a comment

Choose a reason for hiding this comment

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

Tested standalone with this feature on using MPAS-Dev/compass#785. Passes all tests using intel on chrysalis and gnu on perlmutter, both debug and optimized. Tests commands are reported at MPAS-Dev/compass#785 (comment)

@rljacob
Copy link
Copy Markdown
Member

rljacob commented Mar 21, 2024

@cbegeman please review.

@cbegeman
Copy link
Copy Markdown
Contributor

@sbrus89 Thanks for your patience! I'll get to this by the end of this week.

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Mar 21, 2024

@cbegeman, no problem. Thanks!

Copy link
Copy Markdown
Contributor

@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.

@sbrus89 Fantastic work here! This is a really exciting feature to have. I ran just the buttermilk bay case on chrys with intel, openmpi. I just have a few suggestions, mostly regarding config option checks. I look forward to playing around with these features more in the future!

Comment thread components/mpas-ocean/src/Registry.xml Outdated
Comment thread components/mpas-ocean/src/Registry.xml Outdated
Comment thread components/mpas-ocean/src/mode_forward/mpas_ocn_time_integration_rk4.F Outdated
Comment thread components/mpas-ocean/src/mode_init/Registry_parabolic_bowl.xml Outdated
Comment thread components/mpas-ocean/src/mode_init/mpas_ocn_init_subgrid.F
Comment thread components/mpas-ocean/src/shared/mpas_ocn_mesh.F Outdated
Comment thread components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F Outdated
Comment thread components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F Outdated
Comment thread components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F Outdated
Copy link
Copy Markdown
Contributor

@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.

Thanks, @sbrus89! Great work!

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Apr 1, 2024

Thanks for all your testing and suggestions, @cbegeman!

@cbegeman
Copy link
Copy Markdown
Contributor

cbegeman commented Apr 5, 2024

@sbrus89 Let me know what you think of my changes. Feel free to revert if you like! These changes are BFB for the parabolic bowl test on chrys.

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Apr 5, 2024

@cbegeman, I like the changes you made. Thanks for pushing those!

Comment thread components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F Outdated
@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Apr 9, 2024

@jonbob, this PR is ready to go whenever time allows. I did not do any of the namelist modifications for E3SM, since I know you have a script that takes care of that.

@jonbob
Copy link
Copy Markdown
Contributor

jonbob commented Apr 9, 2024

Thanks @sbrus89 -- I'll run the scripts right now and see how far we can get

@jonbob
Copy link
Copy Markdown
Contributor

jonbob commented Apr 9, 2024

@sbrus89 -- do we want the init_mode_subgrid namelist record exposed in E3SM?

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented Apr 9, 2024

@jonbob, no I don't think so. I added a commit that specifies it as mode=init. Thanks for pointing this out.

@mark-petersen
Copy link
Copy Markdown
Contributor

Thanks, I looked at this carefully. config_subgrid_table_levels works exactly like config_vert_levels. It is read from the namelist if the number is specified (only during init). Otherwise it has an entry of -1 and is ready from the dimensions of the netcdf input file.

In order for it to work, you will need to do the following:

  1. Remove mode="init" from
1606   <nml_record name="init_mode_subgrid" mode="init">

otherwise, it can't read the -1 for the dimension on a forward run.

  1. Now that this flag is visible in forward mode, you will need to add init_mode_subgrid and config_subgrid_table_levels to the E3SM namelist script files, similar to these:
components/mpas-ocean/bld/build-namelist:997:add_default($nl, 'config_vert_levels');
components/mpas-ocean/bld/build-namelist-section:514:add_default($nl, 'config_vert_levels');
components/mpas-ocean/bld/namelist_files/namelist_defaults_mpaso.xml:560:<config_vert_levels>-1</config_vert_levels>
components/mpas-ocean/bld/namelist_files/namelist_definition_mpaso.xml:2599:<entry id="config_vert_levels" type="integer"

and then test it with subgrid on for both init and forward, plus a standard E3SM run. I think you need to make these changes even though all the subgrid variables with the dimension nSubgridTableLevels are in packages="subgridWetDryPKG", because it defines every dimension regardless of whether the packages are on or off.

@jonbob
Copy link
Copy Markdown
Contributor

jonbob commented May 1, 2024

@sbrus89 -- I ran the scripts to make the bld files consistent with Registry and pushed them back to this PR. It all looks good to me, but there are some "To do" comments that were in the namelist_defaults file that get lost here. I'm not sure where they came from?

@cbegeman
Copy link
Copy Markdown
Contributor

cbegeman commented May 2, 2024

@sbrus89 Polaris is having trouble parsing your init mode registry additions on perlmutter. I've noticed that there are several places where spaces are used instead of tabs, but the error seems to be indicating a missing quotation. The line number indicated in the error message does not map onto the line numbers in Registry_processed.xml. I confirmed it was these options by manually removing them from Registry_processed.xml and then the parsing is successful.

Setting up tasks:
  ocean/planar/baroclinic_channel/10km/default
Traceback (most recent call last):
  File "/global/homes/c/cbegeman/miniconda3/envs/polaris_main/bin/polaris", line 33, in <module>
    sys.exit(load_entry_point('polaris', 'console_scripts', 'polaris')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/__main__.py", line 62, in main
    commands[args.command]()
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/setup.py", line 293, in main
    setup_tasks(task_list=args.tasks, numbers=args.task_num,
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/setup.py", line 118, in setup_tasks
    setup_task(path, task, machine, work_dir,
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/setup.py", line 194, in setup_task
    _setup_step(task, step, work_dir, baseline_dir, task_dir)
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/setup.py", line 642, in _setup_step
    step.process_inputs_and_outputs()
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/model_step.py", line 414, in process_inputs_and_outputs
    self._process_streams(quiet=quiet, remove_unrequested=True)
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/model_step.py", line 610, in _process_streams
    new_tree = yaml_to_mpas_streams(processed_registry_filename,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/pscratch/sd/c/cbegeman/polaris-repos/main/polaris/yaml.py", line 226, in yaml_to_mpas_streams
    registry = etree.fromstring(registry_string)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/lxml/etree.pyx", line 3287, in lxml.etree.fromstring
  File "src/lxml/parser.pxi", line 1989, in lxml.etree._parseMemoryDocument
  File "src/lxml/parser.pxi", line 1869, in lxml.etree._parseDoc
  File "src/lxml/parser.pxi", line 1105, in lxml.etree._BaseParser._parseUnicodeDoc
  File "src/lxml/parser.pxi", line 633, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 743, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 672, in lxml.etree._raiseParseError
  File "<string>", line 16302
lxml.etree.XMLSyntaxError: AttValue: " or ' expected, line 16302, column 62

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented May 2, 2024

@cbegeman, thanks for noticing this. I'll look into it and push a fix.

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented May 3, 2024

@cbegeman, that parsing issue should be fixed now. Thanks again!

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented May 6, 2024

@jonbob, I believe this is ready whenever you get a chance.

jonbob added a commit that referenced this pull request May 6, 2024
Add subgrid scale correction scheme and init mode test cases

This pull request adds a subgrid scale correction scheme into
MPAS-Ocean. It is currently meant only for single-layer, barotropic
coastal flooding applications and is implemented as an mpaso standalone
feature.

The subgrid corrections introduced here account for the nonlinear
relationship between ssh and grid-averaged wet volume per unit area in
partially wet cells. These relationships are calculated as lookup tables
from high-resolution (subgrid scale) bathymetry data. This lookup table
calculation is done as a pre-processing step implemented in MPAS-Ocean
init mode. Using the subgrid correction scheme increases the accuracy of
the wetting/drying transition. It is especially advantageous at coarser
resolutions, where it can increase model efficiency by reducing the
level of resolution required to represent the effects of small-scale
conveyances.

Two test cases are also added:
1. A subgrid version of the existing parabolic bowl wetting and drying
   test case
2. A simulation of Buttermilk Bay, MA with idealized tidal boundary
   forcing

[NML]
[BFB] for all standard E3SM tests, mpaso standalone only
@jonbob
Copy link
Copy Markdown
Contributor

jonbob commented May 6, 2024

Passes:

  • ERS.ne4pg2_oQU480.WCYCL1850NS.chrysalis_intel
  • ERP_Ld3.ne30pg2_r05_IcoswISC30E3r5.WCYCL1850.chrysalis_intel.allactive-pioroot1

with expected NML DIFFs. merged to next

@jonbob jonbob merged commit 5aaaac0 into E3SM-Project:master May 7, 2024
@jonbob
Copy link
Copy Markdown
Contributor

jonbob commented May 7, 2024

merged to master and expected NML DIFFs blessed

@sbrus89
Copy link
Copy Markdown
Contributor Author

sbrus89 commented May 7, 2024

Thank you, @jonbob!

xylar added a commit to xylar/compass that referenced this pull request May 8, 2024
This merge updates the E3SM-Project submodule from [93e511d](https://github.com/E3SM-Project/E3SM/tree/93e511d) to [31e0924](https://github.com/E3SM-Project/E3SM/tree/31e0924).

This update includes the following MPAS-Ocean and MPAS-Frameworks PRs (check mark indicates bit-for-bit with previous PR in the list):
- [ ]  (ocn) E3SM-Project/E3SM#6256
- [ ]  (ocn) E3SM-Project/E3SM#6224
- [ ]  (ocn) E3SM-Project/E3SM#6270
- [ ]  (ocn) E3SM-Project/E3SM#6293
- [ ]  (ocn) E3SM-Project/E3SM#6321
- [ ]  (ocn) E3SM-Project/E3SM#6262
- [ ]  (ocn) E3SM-Project/E3SM#6300
- [ ]  (ocn) E3SM-Project/E3SM#6334
- [ ]  (ocn) E3SM-Project/E3SM#6371
- [ ]  (ocn) E3SM-Project/E3SM#6288
@rljacob rljacob added the fromES PR from an E3SM ecosystem project or other external effort label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BFB PR leaves answers BFB fromES PR from an E3SM ecosystem project or other external effort MPAS-Ocean standalone Issues and features for standalone MPAS-Ocean code that dont impact E3SM. MPAS-ocean Concerning the MPAS-ocean model coupled to E3SM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants