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

bugfix: static h_new shape remaining_transport_sum #82

Merged

Conversation

marshallward
Copy link
Member

@marshallward marshallward commented Mar 8, 2022

This patch redefines h_new to match the shape of a center-point rather
than a v-face point.

Dynamic memory builds would have been unaffected by this, and older GCC
(~7.3.0) compilers appear to have not objected to the shape mismatch,
but this raised an error in newer GCCs (~9.3.0).

This should not affect answers, since the loops never strayed into these
redundant undefined regions.

@codecov
Copy link

codecov bot commented Mar 8, 2022

Codecov Report

Merging #82 (efa503b) into dev/gfdl (4640461) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           dev/gfdl      #82   +/-   ##
=========================================
  Coverage     29.05%   29.05%           
=========================================
  Files           244      244           
  Lines         71905    71905           
=========================================
  Hits          20892    20892           
  Misses        51013    51013           
Impacted Files Coverage Δ
src/tracer/MOM_offline_main.F90 0.00% <ø> (ø)

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 4640461...efa503b. Read the comment docs.

Copy link
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 with this correction.

@klindsay28
Copy link

I'm not so sure about the assertion

This should not affect answers, since the loops never strayed into these
redundant undefined regions.

h_new is declared in offline_advection_ale with dimensions (SZI_(G),SZJ_(G),SZK_(GV)) and is being passed into remaining_transport_sum where the argument's dimensions are (SZI_(G),SZJB_(G),SZK_(GV)). If SZJB_(G) and SZJ_(G) differ, then it seems like this mismatch will alter the mapping of indices to array locations in memory, whether you are in the halo regions or not.

@marshallward
Copy link
Member Author

marshallward commented Mar 9, 2022

@klindsay28 I think you are right, it will change it from a zero-indexed field to a 1-indexed field (in symmetric mode), and may change answers. Thanks for catching that.

Do you have any tests which can check this? It doesn't seem to have been detected in our regression suite.

@klindsay28
Copy link

The NCAR specific test suite doesn't have any tests with OFFLINE_TRACER_MODE = True, so I wouldn't expect our tests to catch this.

h_new is used in remaining_transport_sum in the block https://github.com/NCAR/MOM6/blob/8106f48fcd224c70475095e4f9301f0f99e95413/src/tracer/MOM_offline_main.F90#L617-L623

For a test to catch this change, you would need to have h_new values such that sampling it at the wrong location would lead to a change in the conditional on line 621. I'm not familiar with this code at all, so I'm not sure how you could arrange for that to occur in a test.

This patch redefines `h_new` to match the shape of a center-point rather
than a v-face point.

Dynamic memory builds would have been unaffected by this, and older GCC
(~7.3.0) compilers appear to have not objected to the shape mismatch,
but this raised an error in newer GCCs (~9.3.0).

Since this redefines `h_new` from zero-based to 1-based indexing in the
y-axis, answer changes are very possible.
@marshallward marshallward force-pushed the offline_static_bugfix branch from db7fa0f to efa503b Compare March 9, 2022 14:10
@Hallberg-NOAA
Copy link
Member

I am very confident that this PR will not impact any existing solutions. Until we accepted #37 near the end of 2021, this code would not have worked at all due to a segmentation fault, and had not worked since at least July 2019. No one appears to have noticed, which means that no one was using this part of the code.

The offline tracer mode is a useful idea, but it was never fully implemented, and never had been incorporated into any regression tests, primarily because the postdoc who was working on it accepted a well-deserved new position abroad (working with a different ocean modeling system) before it was fully complete. As of this year, it is now compiling, running, reproducing across layouts, and passing dimensional consistency tests, but this bug suggests that it is not being fully tested in all modes (e.g., symmetric or non-symmetric memory).

@marshallward
Copy link
Member Author

I've updated the commit log to indicate that answer changes are likely (assuming anyone used this, at least).

@Hallberg-NOAA
Copy link
Member

This has passed TC testing and pipeline testing at https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/14928.

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.

3 participants