Conversation
- Addressed compiler warnings about unused variables and
argument intent.
- Note there is one dummy argument that was unused and the best way
to address the warnings was to remove the argument, i.e. and API change.
This was only in a debugging/utility function so does not impact the
rest of the model.
- Address warnings about unused/uninitialized variables in MOM_remapping.F90
- Sets values that appear to the compiler to be potentially unset, but
always are in practice
- Added new driver, time_MOM_remapping, to config_src/timing_tests/ that exercises the remapping_core_h() function with PCM and PLM. - We should add other reconstruction schemes too, but the main reason for adding this now is to monitor the impact of refactoring the function remapping_core_h() which is mostly independent of the reconstruction schemes. - Fixed .testing/Makefile to not fail with `make build.timing -j`
Added a simple driver for the remapping unit tests.
- Added a simple class within MOM_remapping.F90 to greatly abbreviate the lines comparing values of arrays. - Translated the existing remapping unit tests to use the testing class.
- The first block of remap_via_sub_cells() computes the intersection between
two columns (grids). I've split out this block into a stand alone function
so that we can re-use it in a to-be-written analog of remap_via_sub_cells()
that will remap integrated quantities.
- Added some in-line documentation of algorithm used by remap_via_sub_cells()
- Added new column-wise function intersect_src_tgt_grids()
- Added tests of intersect_src_tgt_grids() that check against known results
- Had to add a new helper function to MOM_remapping to report state of
integer arrays.
- This second phase of remap_via_sub_cells() maps the values from the source
grid to the sub-grid using the pre-calculated arrays/indices from
intersect_src_tgt_grids().
This phase as-is is only used for remapping of intensive variables but
it does implicitly calculate intermediate extensive quantities which are
analogous to what we need when remapping momentum. Splitting this phase
out primarily allows us to test this bit of code and it has indeed revealed
an edge case that fails.
- Added new column-wise function remap_src_to_sub_grid()
- Added tests of remap_src_to_sub_grid() that check against known results
- One test is commented out corresponding to an edge case that reveals
the current code is wrong. Will enable this test after checking how
many experiments are impacted but the associated bug fix.
- We had debugging left over from development a decade ago that was retained "just in case" but has been obsoleted by the unit testing. - Also cleaned up unused variables.
- Added remap_sub_to_tgt_grid() to handle remapping of intermediate state on sub-layers to the target grid. This function will be reused by alternate remap_via_subcells() analogs for extensive quantities. - Added unit tests for remap_sub_to_tgt_grid().
- The original remap_via_subcells() assumed that the first and last sub-layers would be vanished and thus needed to only assign the edge values of the source reconstructions to the sub-layers. However, this is only a valid assumption (and correct) if the total column thickness of source/target are the same. That is generally true doing the main loop. However, when initializing from WOA, the ocean model depth and source-data depth often differ, and this assumption that we can ignore the top/bottom reconstructions breaks. - The original fix was developed with @claireyung and took the form claireyung@924b7ac In this patch, I have unrolled the loop inside remap_src_to_sub_grid() to avoid adding an additional `if` test on the loop index. - The fix is implemented in remap_src_to_sub_grid() and the original method is reached by setting a logical inside the remapping_CS. Default is to use the OM4 alorithm (original method with bug). - New runtime parameters are added in to recover original algorithm selectively: - OBC_REMAPPING_USE_OM4_SUBCELLS, - Z_INIT_REMAPPING_USE_OM4_SUBCELLS, - EBT_REMAPPING_USE_OM4_SUBCELLS, - SPONGE_REMAPPING_USE_OM4_SUBCELLS, - SPONGE_REMAPPING_USE_OM4_SUBCELLS, - DIAG_REMAPPING_USE_OM4_SUBCELLS, - NDIFF_REMAPPING_USE_OM4_SUBCELLS, - HBD_REMAPPING_USE_OM4_SUBCELLS, and - REMAPPING_USE_OM4_SUBCELLS all of which default to True. - No answer changes. Testing defaults More defaults EBT flag
adcroft
pushed a commit
that referenced
this pull request
May 9, 2025
* Try again at fix_obc_maskingdepth patch - "git rebase" made a conflicted mess * Fix for even number of OBC turns. - not that turns other than 0, 1 is supported elsewhere for OBCs. This still has issue #5 from a comment in NOAA-GFDL#752: Some experimentation with the rotate_OBC subroutines. Dr Neumann's test uses boundary data of the value=const type. Copying the buffer_dst from OBC_in to CS%OBC gets some of these across, also the tracer reservoir values. However, the tracer reservoir values get overwritten by an interior tracer value between the first call to step_MOM_dynamics and the second. * Trying to fix internal OBC rotations, not sure * Fixing next round of rotated OBC issues * Fix up some logic for turns = 2 or 3. - Note that this is still not supported, as specificed in MOM.F90. * Adding back in the deallocate on some OBC arrays
adcroft
added a commit
that referenced
this pull request
Sep 29, 2025
* Add MOM_ANN module * Mesoscale momentum parameterization with ANN - Computes subgrid stress using ANN in MOM_Zanna_Bolton - Uses MOM_ANN module for ANN inference Equivalent MOM_override for defaults ``` USE_ZB2020 = True ZB2020_USE_ANN = True USE_CIRCULATION_IN_HORVISC = True ZB2020_ANN_FILE_TALL = /path/to/ocean3d/subfilter/FGR3/EXP1/model/Tall.nc ``` * Mesoscale momentum parameterization with ANN (#2) Blank commit after squash/rebase was handled on command line * Moved MOM_ANN.F90 to src/framework/ * Minor refactor of MOM_ANN - Removed unused modules - Removed unused MOM_memory.h - Added input and output means which default to 0 and do not need to be present in the weights file - Gave defaults to means, norms, tests so that they do no need to be present in file - Added missing array notation "(:)" - Minor formatting * Adds unit tests and timing test to MOM_ANN - Added ANN_allocate, set_layer, set_input_normalization, and set_output_normalization methods to allow reconfiguration during unit tests - Added ANN_unit_tests with some simple constructed-by-code networks with known solutions - Added config_src/drivers/unit_tests/test_MOM_ANN.F90 to drive unit tests - Added config_src/drivers/timing_tests/time_MOM_ANN.F90 as rudimentary for timing inference * Adding multiple forms of inference - Adds inference operating on array (instead of single vector of features) - Implements several different versions of inference with various loop orders - Involves storing the transpose of A in the type - Tested by checking inference on same inputs is identical between variants - Added randomizers to assist in unit testing - Adds timing of variants to config_src/drivers/timing/time_MOM_ANN.F90 - Adds an interface (MOM_apply) to select preferred version of inference subroutine - Added command line args to time_MOM_ANN.F90 to allow more rapid evaluation of performance Variants explored, timed with gfortran (13.2) -O3 on Xeon: - vector_v1: - original inference from Pavel - vector_v2: - allocate work arrays just once, using widest layer - loop over layers in 2's to avoid pointer calculations and copies - speed up, x0.8 relative to v1 - vector_v3: - transpose loops - slow down, x1.54 relative to v1 - vector_v4: - transpose weights with same loop order as v1 - slow down, x1.03 relative to v1 - array_v1: - same structure as v2, working on x(space,feature) input/outputs - speed up, x0.41 relative to v1 - array_v2: - as for array_v1 but with transposed loop order - apply activation function on vector of first index while in cache - speed up, x0.35 relative to v1 - array_v3: - same structure as v2, working on x(feature,space) input/outputs - speed up, x0.58 relative to v1 * Renamed ANN variants and added some module documentation - Added module dox - Renamed _v1, _v2 etc to labels - Added ANN_apply_array_sio to ANN_apply interface - Replaced "flops" with "MBps" in timing output * Removed alternative variants of ANN in favor of optimized - Deleted variants of ANN that did not perform as well as the two versions that remain. * Apply array_sio function in ANN inference for momentum fluxes (#5) * Apply array_sio ANN inference for computation of momentum fluxes * remove trailing space * Initial commit * address Robert Hallberg code review * Restore deafult value of ZB_SCALING coefficient --------- Co-authored-by: Alistair Adcroft <Alistair.Adcroft@noaa.gov> Co-authored-by: Alistair Adcroft <adcroft@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Debugging MacOS regression