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

+Add MOM_check_scaling.F90 and MOM_scaling_check.F90 #49

Merged
merged 5 commits into from
Feb 15, 2022

Conversation

Hallberg-NOAA
Copy link
Member

Added two new modules, the MOM6-specific MOM_check_scaling.F90 and the generic
framework module MOM_scaling_check.F90, to assess the uniqueness of the unit
scaling factors for all of the variables used by MOM6. If there are overlaps in
scaling factors for different units, this also identifies and suggests alternate
scaling factors with less overlaps. This commit includes the introduction of
the new publicly visible routines check_scaling_factors(), scales_to_powers()
and check_MOM6_scaling_factors. This new capability does not do anything for
sufficiently low levels of model verbosity, and it is silent if the scaling
factors are unique, or if less than 2 dimensions are being rescaled. All
answers and output files are bitwise identical, but there can be additional
messages to stdout.

  Added two new modules, the MOM6-specific MOM_check_scaling.F90 and the generic
framework module MOM_scaling_check.F90, to assess the uniqueness of the unit
scaling factors for all of the variables used by MOM6.  If there are overlaps in
scaling factors for different units, this also identifies and suggests alternate
scaling factors with less overlaps.  This commit includes the introduction of
the new publicly visible routines check_scaling_factors(), scales_to_powers()
and check_MOM6_scaling_factors.  This new capability does not do anything for
sufficiently low levels of model verbosity, and it is silent if the scaling
factors are unique, or if less than 2 dimensions are being rescaled.  All
answers and output files are bitwise identical, but there can be additional
messages to stdout.
@codecov
Copy link

codecov bot commented Dec 22, 2021

Codecov Report

Merging #49 (4b8645f) into dev/gfdl (65998cd) will increase coverage by 0.07%.
The diff coverage is 47.13%.

Impacted file tree graph

@@             Coverage Diff              @@
##           dev/gfdl      #49      +/-   ##
============================================
+ Coverage     28.94%   29.02%   +0.07%     
============================================
  Files           242      244       +2     
  Lines         71553    71850     +297     
============================================
+ Hits          20714    20854     +140     
- Misses        50839    50996     +157     
Impacted Files Coverage Δ
src/framework/MOM_unique_scales.F90 7.14% <7.14%> (ø)
src/core/MOM_check_scaling.F90 99.21% <99.21%> (ø)
src/core/MOM.F90 58.44% <100.00%> (+0.02%) ⬆️

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 65998cd...4b8645f. Read the comment docs.

Copy link
Member

@adcroft adcroft left a comment

Choose a reason for hiding this comment

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

This is a nice innovation, and as usual, properly working code. However:

  1. I don't understand the use of two modules here. These could easily be one module and not change the functionality currently coded. The naming MOM_check_scaling and MOM_scaling_check do not help me know which level I'm looking at. I note the module descriptions are identical which must be corrected. Some of subroutine descriptions are so similar one would think the modules duplicate each other when infact one does the work and the other does the set up. One module seems to make sense, or if there's a real reason to not join them, a clearer description of the two levels.
  2. Please change the verbosity in one of the TCs so that this code gets 100% coverage.
  3. The regular comments about how units work have very useful information (e.g. L13-17 of the new modules) but this will not be found or referenceable. I suggest moving this into a dedicated .dox about units and scaling so we can refer to this documentation.

@Hallberg-NOAA
Copy link
Member Author

Thank you for the review @adcroft

  1. There are two modules because one (the smaller one) is specific to the physical parts of MOM6, while the other one (in the framework directory) is a set of model-agnostic tools and checks that can be used by MOM6, SIS2, various biogeochemical packages (like COBALT, TOPAZ, etc.) or anything else. However, I see that having such similar names will be very confusing. I could rename the latter to framework/MOM_scaling_check_framework.F90, but that seems rather long. Any suggestions for a better name?

  2. Triggering this code requires the simultaneous rescaling of 2 or more dimensions, whereas the TC testing (by design) only tests one dimension at a time. One possibility that this opens up is that we could test all of the rescaled dimensions in the TCs at once, and then only trigger the tests of each individual dimension if that fails. However, that would add complexity to the driver for the TCs. Curiously, running a test that gets us to ~100% coverage would require this not use the settings that actually uniquely rescale all of the dimensions used in MOM6, as otherwise the code does not need to seek a set of values that do uniquely rescale all of the dimensions!

  3. Improving this documentation is a good idea. I will prepare a .dox file describing the units as a separate PR. I am also preparing a proper manuscript about this for submission to the peer reviewed literature.

@adcroft
Copy link
Member

adcroft commented Jan 11, 2022

  1. Understood.
  2. tc0 does not run as far as a the call to call check_MOM6_scaling_factors(CS%GV, US) but if you add a unit test s/r that sets up GV and US, then we could trivially update tc0 to test multiple dimensions always and thus exercise the code. Let's discuss...
  3. And we must remember to add the link to the paper in the .dox file when it's available

  Renamed the framework module MOM_scaling_check.F90 to MOM_unique_scales.F90 to
help differentiate it from MOM_check_scaling.F90, and renamed the subroutine
check_scaling_factors() as check_scaling_uniqueness().  Also added
_Dimensional_consistency.dox to describe the dimensional consistency testing.
This commit should address the issues raised in the review of MOM6 PR mom-ocean#49.  All
answers and output are bitwise identical.
@Hallberg-NOAA
Copy link
Member Author

I have renamed one of the two new modules for help differentiate them, and I have added a new .dox file describing the unit scaling. However, I think that changes to the overall structure of the TC testing to exercise this new code goes beyond the scope of this PR. I now believe that this PR is ready to be reevaluated.

@adcroft adcroft added the enhancement New feature or request label Jan 31, 2022
@marshallward
Copy link
Member

Gaea regression: https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/14676 ✔️

@marshallward
Copy link
Member

Will merge after approval from @adcroft

@marshallward marshallward merged commit 75bf521 into NOAA-GFDL:dev/gfdl Feb 15, 2022
marshallward pushed a commit that referenced this pull request Feb 18, 2022
  Renamed the framework module MOM_scaling_check.F90 to MOM_unique_scales.F90 to
help differentiate it from MOM_check_scaling.F90, and renamed the subroutine
check_scaling_factors() as check_scaling_uniqueness().  Also added
_Dimensional_consistency.dox to describe the dimensional consistency testing.
This commit should address the issues raised in the review of MOM6 PR #49.  All
answers and output are bitwise identical.
@Hallberg-NOAA Hallberg-NOAA deleted the add_check_scaling branch March 25, 2022 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants