Skip to content

Consolidate reproducible sum with unit tests#902

Merged
Hallberg-NOAA merged 1 commit into
NOAA-GFDL:dev/gfdlfrom
adcroft:consolidate-reproducible-sum-with-unit-tests
May 21, 2025
Merged

Consolidate reproducible sum with unit tests#902
Hallberg-NOAA merged 1 commit into
NOAA-GFDL:dev/gfdlfrom
adcroft:consolidate-reproducible-sum-with-unit-tests

Conversation

@adcroft
Copy link
Copy Markdown
Member

@adcroft adcroft commented May 16, 2025

This simplifies and expands the timing/testing of reproducing sums that were in .../unit_drivers and would not work without some
setup of the environment (input files). The refactored drivers are stand alone and (mostly) fit within the pattern of the other unit tests and timing tests.

  • Moves config_src/drivers/unit_drivers/MOM_sum_driver.F90 to config_src/drivers/timing/time_reproducing_sum.F90
  • Cleaned up time_reproducing_sum to not use unnecessary infrastructure (like grids, parameter files, etc.)
  • Added config_src/drivers/unit_tests/test_reproducing_sum.F90 to perform property tests removed from timing test.
  • Added trivial unit test that reproducing_sum() gives correct analytic sum for array of prescribed values
  • Added new tests that reproducing_sum() results are invariant to order of values in arrays
  • Made MOM_define_layout() public
  • Initialized MOM_dom%nonblocking_updates and MOM_dom%thin_halo_updates when optional arguments are missing (bug fix)
  • Hacked .testing/tools/disp_timing.py to not fail on the FMS tail sheet which inevitably is generated when using FMS :(

Note: this contains two commits from #899 that should be merged before this PR, so I'm marking it as draft until then at which time I'll rebase this down to the one commit.

@adcroft adcroft requested a review from Hallberg-NOAA May 16, 2025 22:59
@adcroft adcroft added bug Something isn't working enhancement New feature or request refactor Code cleanup with no changes in functionality or results labels May 16, 2025
@Hallberg-NOAA
Copy link
Copy Markdown
Member

I have examined the F90 code changes, and they do look correct to me.

I would note that there is a fair amount of code duplication between test_reproducing_sum.F90 and time_reproducing_sum.F90. We generally allow for two (small) duplicated copies of a block of code (as is the case here), but if we were going to use this 3 or more times, we would want to refactor this to avoid the duplication!

If someone else could vouch for the .yml and .py code changes, I will be happy to approve this after PR #899 is resolved.

@adcroft adcroft force-pushed the consolidate-reproducible-sum-with-unit-tests branch from 386b2a3 to ef0eed2 Compare May 19, 2025 15:09
@adcroft adcroft marked this pull request as ready for review May 19, 2025 16:03
@adcroft adcroft force-pushed the consolidate-reproducible-sum-with-unit-tests branch from ef0eed2 to c4b78bd Compare May 19, 2025 20:23
@Hallberg-NOAA Hallberg-NOAA force-pushed the consolidate-reproducible-sum-with-unit-tests branch from c4b78bd to 221f93f Compare May 19, 2025 22:27
Copy link
Copy Markdown
Member

@Hallberg-NOAA Hallberg-NOAA left a comment

Choose a reason for hiding this comment

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

I agree that these changes are correctly implementing an improved unit testing capability.

@adcroft adcroft force-pushed the consolidate-reproducible-sum-with-unit-tests branch from 221f93f to 5403def Compare May 21, 2025 15:54
This simplifies and expands the timing/testing of reproducing sums
that were in .../unit_drivers and would not work without some
setup of the environment (input files). The refactored drivers
are stand alone and (mostly) fit within the pattern of the other
unit tests and timing tests.

- Moves config_src/drivers/unit_drivers/MOM_sum_driver.F90 to
  config_src/drivers/timing/time_reproducing_sum.F90
- Cleaned up time_reproducing_sum to not use unnecessary
  infrastructure (like grids, parameter files, etc.)
- Added config_src/drivers/unit_tests/test_reproducing_sum.F90
  to perform property tests removed from timing test.
- Added trivial unit test that reproducing_sum() gives correct
  analytic sum for array of precsribed values
- Added new tests that reproducing_sum() results are invariant
  to order of values in arrays
- Made MOM_define_layout() public
- Initialized MOM_dom%nonblocking_updates and MOM_dom%thin_halo_updates
  when optional arguments are missing (bug fix)
- Hacked .testing/tools/disp_timing.py to not fail on the FMS
  tail sheet which inevitably is generated when using FMS :(
@Hallberg-NOAA Hallberg-NOAA force-pushed the consolidate-reproducible-sum-with-unit-tests branch from 5403def to 6511cc8 Compare May 21, 2025 18:45
@Hallberg-NOAA
Copy link
Copy Markdown
Member

This PR has passed pipeline testing at https://gitlab.gfdl.noaa.gov/ogrp/mom6ci/MOM6/-/pipelines/27517.

@Hallberg-NOAA Hallberg-NOAA merged commit 7334c8c into NOAA-GFDL:dev/gfdl May 21, 2025
52 checks passed
@adcroft adcroft deleted the consolidate-reproducible-sum-with-unit-tests branch September 18, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request refactor Code cleanup with no changes in functionality or results

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants