Skip to content

Aug2024#2

Open
chzhangudel wants to merge 4665 commits intobreichl:dev/gfdlfrom
chzhangudel:AUG2024
Open

Aug2024#2
chzhangudel wants to merge 4665 commits intobreichl:dev/gfdlfrom
chzhangudel:AUG2024

Conversation

@chzhangudel
Copy link
Copy Markdown

update all submodules to the version in Joseph's SHiEMOM

alex-huth and others added 30 commits October 13, 2023 00:09
* Added ice shelf Coulomb friction law (Schoof 2005, Gagliardini et al 2007) needed for MISMIP+ experiments (Asay-Davis et al 2016).
* +REMAP_AUX needs at least one more halo update.

- This one is for CS%u_av, CS%v_av, which need to be updated coming
  into step_MOM_dyn_split_RK2.

* +Next stab at fixing REMAP_AUX fallout.

- This fixes the Bering ORLANSKI OBCs for differing processor counts.
- This is either the wrong way to do group_pass for OBLIQUE OBC's or
  there is more wrong with them.

* Adding a group pass, still not solving the problem

- Problem is in tangential_vel at tile boundaries. It matches
  right at the boundary, but needs some halo points to match too.

* +Fixing oblique OBCs

- Without this, u_av and v_av don't update a wide enough halo to
  get answers to reproduce across different processor counts with
  oblique OBCs.

* Fixed an oopsie with OBC

* Getting rid of extra exchange (that didn't help)
  Refactored diapyc_energy_req_test and diapyc_energy_req_calc to remove the
dependence on the Boussinesq reference density when in non-Boussinesq mode.
This includes changes to the scaled units of the Kd_int argument to
diapyc_energy_req_calc and the Kd argument to diapyc_energy_req_calc and the
addition of a new argument to diapyc_energy_req_calc.  A call to thickness_to_dz
is used for the thickness unit conversions.  There are 5 new internal variables,
and changes to the units of several others.

  These routines are not actively used in MOM6 solutions, but instead they are
used for testing and debugging new code, so there are no changes to solutions,
but the results of these routines can differ in fully non-Boussinesq mode.
  Modified the MOM_diapyc_energy_req.F90 version of find_PE_chg to align more
closely with the version in MOM_energetic_PBL.F90, including making PE_chg into
a mandatory argument, changing the name of the ColHt_cor argument to
PE_ColHt_cor, and modifying some variable descriptions in units.  Also removed
find_PE_chg_orig from MOM_diapyc_energy_req.F90 and the old_PE_calc code that
calls it.  Extra values were also added to Te, Te_a and Te_b and the equivalent
salinity variables so that the logical branches at (K==2) and (K=nz) could be
simplied out of diapyc_energy_req_calc.  Because old_PE_calc had been hard-coded
to .false., all answers are bitwise identical.
…equired for NW2 (NOAA-GFDL#484)

* Update of Zanna-Bolton-2020 closure: code optimization and features required in NW2 configuration

* Resolving compilation errors and doxygen by Alistair

* Remove force sync for clock

* Change naming of functions according to MOM_Zanna_bolton module
- Several edits to the ice shelf solo driver so that it works with the rest of the current MOM6

- Added capability to initialize a surface mass balance (SMB) that is held contstant over time when running from the ice-shelf solo driver (see new subroutine initialize_ice_SMB). This is required for MISMIP+. A constant SMB can also be used from the MOM driver for coupled ice-shelf/ocean experiments (e.g. MISOMIP).

- The new, constant SMB is passed into solo_step_ice_shelf, where change_thickness_using_precip is called

- Added capability to save both non-time-stamped and time-stamped restart files when using the ice shelf solo driver. This is useful for debugging.

- slight reorganization to when ice shelf post_data calls are made

- Added safety checks to diag_mediator_end() so that it works with the ice shelf solo-driver, which now calls it instead of (now removed) solo_ice_shelf_diag_mediator_end() routine. Removed the runtime parameter SAVE_BOTH_RESTARTS from the ice shelf solo-driver, which is no longer needed.
-fixed a bug in change_thickness_using_precip (was missing a division by ice density)
-optimized ice shelf pass_var calls with optional complete arguments
-corrected the grid area to multiply with ice shelf driving stress before its post_data call
-changed some order of operations by adding parentheses, with the hope that it would improve symmetry of the ice shelf solution during MISMIP+. There was no effect, but this version of the code was used for MISMIP+ and MISOMIP.
…candidate-2023-09-13

NCAR to main (2023-09-14)
* allow for assigned ice shelf thickness where hmask==3, but still solve for ice sheet velocity
Newest Read the Docs configuration file requires explicit specification
of the environment (using `build:`).  This patch includes this section.

Upgrading to newer Python environments has also forced us to specify an
older Jinja2 that works with our legacy Sphinx module.
… a partially-filled cell, add the reference thickness contribution from a neighboring filled cell proportionate to its flux into the partially-filled cell. This is more accurate than simply taking the average thickness of all neighboring filled cells. Also fixed incorrect bounds. (NOAA-GFDL#475)
The directory, time and timestamp variables are needed by the particle code in order to write better restart files. I have changed the particles_save_restart interface to add these variables. I have also removed the option to pass temperature and salinity to particles_save_restart, because these variables are not useful for restart.
the module in now able to read in tidal velocities for different
tidal harmonics and distribute the energy and distribute TKE input over
the different vertical modes. This involves upsizing dimensions of
several arrays and mofiying some API. internal_tide_input_CS is
promoted to public to facilitate the passing of energy input to
MOM_internal_tides
  Removed the unused (and unusable) routine build_grid_arbitrary.  This routine
could not have been used because it had a hard-coded STOP call, and comments in
it indicated that it should have been deleted in July, 2013.  The run-time
parameter setting that would have triggered a call to this routine has been
retained for now, but with a fatal error message explaining that this routine
has not been implemented.   All answers are bitwise identical in any cases that
ran before.
  Removed the unused routine rescale_grid_bathymetry.  This routine was added in
August 2018 as a part of the development of the depth unit conversion and
dimensional consistency testing, but it is no longer being called now that this
conversion is essentially complete (and it has not been called by the code in
several years).  For the original commit that first added this code, see
github.com/mom-ocean/MOM6/commit/ddc9ed1c33a1b7357b213929118ecaa19ae63f9f.  All
answers are bitwise identical.
  Corrected dimensional rescaling bugs in the spherical harmonics SAL code.  An
issue with horizontal length scaling was corrected by using G%Rad_Earth_L in
place of G%Rad_Earth in spherical_harmonics_init.  There are new optional
tmp_scale arguments to calc_SAL and spherical_harmonics_forward to allow the
rescaling to be undone before calling the reproducing sums.

  This commit also modifies the call to the reproducing sums in
spherical_harmonics_forward so that all real or imaginary components are
calculated with a single call, which reduces the cost of the SAL calculation
reproducing sums from about 6.7 times the cost with non-reproducing sums to just
5.5 times as much in testing with the tides_025 test case.

  There is also code added to avoid NaNs arising from a square root operating
on a negative argument from a 32-bit integer roll-over when a very large
number of harmonics components (more than 1024 x 1024) are unadvisedly being
used.

  While this commit corrects the dimensional scaling when HARMONICS_SAL is true,
all answers are bitwise identical when no rescaling is used or when the
spherical harmonics SAL is not used.  There are new optional arguments to two
publicly visible interfaces.
`FMS_cap`: extract c-grid staggered currents
  Added standard-format unit descriptions for 31 real variables in comments
scattered across 14 modules in the core, tracer, and both parameterizations
directories.  Only comments are changed and all answers are bitwise identical.
  Save tv%p_surf in the restart file when USE_PSURF_IN_EOS is true so that the
diagnosed potential energy written to the ocean.stats files after a restart
matches the energy written at the end of the previous run-segment in certain
non-Boussinesq configurations, including the Baltic test case.  Because
p_surf_EOS is a non-mandatory restart field, there is no problem restarting the
run from a restart file created by an older version of the model. The solutions
themselves are bitwise identical. This change requires that tv%p_surf is treated
as an allocatable pointer to its own array rather than being used as a pointer
to the p_surf element of the fluxes or forces structures so that it can be
registered as a restart field.  At some point tv%p_surf could be converted into
an allocatable array instead of a pointer, but this would require more extensive
code refactoring.  All answers are bitwise identical.
…ename specified by new parameter ICE_SHELF_ENERGYFILE). Currently, this file outputs the kinetic energy and mass of the ice sheet according to the smae parameters used to write the ocean.stats file (TIMEUNIT, ENERGYSAVEDAYS, and ENERGYSAVEDAYS_GEOMETRIC).
A few bug fixes so that the GL_couple=.true. option works correctly. Setting GL_couple=.true. will determine the grounding based on ocean column thickness rather than the typical the hydrostatic equilibrium condition. This has the advantage of accounting for changes in sea level, tides, etc. However, it has the disadvantage of not working with the same thoroughly-tested sub-element grounding line parameterization used for the hydrostatic condition. Instead, it accounts for sub-element grounding line movement by, during the SSA solution, using a grounding mask averaged over all ocean (sub)steps that completed since the last SSA solve. Unlike the hydrostatic sub-element parameterization, the dependence of the GL_couple=.true. scheme on grid resolution has not yet been determined. Qualitatively similar grounding line retreat/advance behavior is achieved with both approaches for MISOMIP IceOcean1 on a 2km grid, but GL_couple=.true. results in a rougher grounding line position with less retreat. Note that this commit also fixed a bug in applying the hydrostatic grounding line approach without its sub-element parameterization (though the sub-element parameterization should also be used anyway).
Update .readthedocs.yml configuration
* This commit fixes a bug where restarts were not bitwise identical for coupled ice sheet/ocean runs. This required adding visc%taux and visc%taux (stress on the ocean under ice shelves) to the ocean restart file. Furthermore, ice shelf geometry-related variables needed to be updated and their halo cells filled (within subroutine update_ice_shelf) before (rather than after) calculating shelf fluxes and pressure to the ocean (subroutine add_shelf_flux). Also fixed a bug to calculate ISS%mass_shelf properly in ice-shelf cells that are only partially-filled (ice-shelf area < cell area) due to advection of the ice-shelf front.

* Modified the scheme that attempts to enforce a constant sea level in coupled ice-sheet/ocean runs, where balancing fluxes are applied to part/all of the open ocean to offset the sea level effects caused by changes in ice sheet mass on the ocean. The old scheme assumes the entire ice sheet is floating, and is retained here for the case where CS$override_shelf_movement==.true. and CS%mass_from_file (this approach is used for the MISOMIP tests without a dynamic ice sheet). The new scheme (which is needed for the MISOMIP tests with a dynamic ice sheet, e.g. IceOcean1r and IceOcean1a), accounts for the more general case where some of the ice sheet is grounded. In either case, the ocean balancing fluxes are applied over the entirety of the ice-sheet-free ocean by default. However, if the new parameter CONST_SEA_LEVEL_MISOMIP==.true., the balancing flux is only applied where x>=790 km, which is the sponge region for the MISOMIP tests.

The new scheme also requires calculation of ice sheet dHdT, which is now calculated and optionally saved as a useful diagnositc field for any ice sheet simulation.

* Eliminated array syntax and added inverse dt variables where needed
herrwang0 and others added 28 commits June 5, 2024 23:33
Add an option to use `dt` instead of `dt_pred` in the calculation of
vertvisc_remnant() at the end of predictor stage. The change affects
the following `continuity`() call and `btstep`() call in corrector step.

Combined with the changes from the previous commit, the new options
should solve the issue of inconsistent barotropic velocities from
barotropic solver and baroclinic step.

A runtime flag VISC_REM_TIMESTEP_FIX is added to control the behavior of
 this commit. The current default is false (not applying the fix).
This commit is the third fix related to visc_rem in split mode. h_[uv]
from `zonal_flux_thickness`() and `meridional_flux_thickness`() is
currently multiplied by `visc_rem_[uv]`. This seems to be
double-counting as `visc_rem_[uv]` is accounted for in the barotropic
solver vertical weights. Moreover, for options other than BT_cont, the
velocity point thickness does not include visc_rem. The fix removes the
visc_rem factor from h_[uv] when BT_cont is used.

A runtime flag VISC_REM_CONT_HVEL_FIX is added to control the behavior
 of this commit. The current default is false (not applying the fix).

Other small changes:
* Write out explicitly all keyword arguments in `continuity`() calls
in MOM_dynamics_split_RK2.
* Rename a runtime parameter BAROTROPIC_VERTICAL_WEIGHT_FIX from a
previous commit to  VISC_REM_BT_WEIGHT_FIX, to be consistent with the
style of the other two flags.
* Add VISC_REM_TIMESTEP_FIX parameter to MOM_dynamics_split_RK2b
* Correct a bug using dimensional h_neglect in calculating
non-dimensional Iwt_[uv]_tot, by replacing the division with
an Adcroft_reciprocal style division.

* Add a parameter VISC_REM_BUG to control the defaults of all three
viscous remnant bug related parameters. The individual parameters should
 be removed in the future.
  Refactored PressureForce_FV_nonBouss and PressureForce_FV_Bouss to use more
3-dimensional arrays in preparation for the changes that we are expecting from
Claire Yung to reduce the pressure gradient errors in ice shelf cavities.  These
anticipated changes will involve selecting an internal interface at which to
define the shape of the interfaces with depth when there is an ice shelf, rather
than assuming that the top surface pressure varies linearly with depth between
the two top corners.  In PressureForce_FV_nonBouss, this refactoring includes
turning za, intx_za and inty_za into 3-d arrays and moving the code setting
these arrays outside of the k-loop setting the pressure gradient forces.
Changes in PressureForce_FV_Bouss are analogous but involve turning 7 arrays
(pa, dpa, intz_dpa, intx_pa, intx_dpa, inty_pa and inty_dpa) into 3-d arrays.
In both cases, the code for a reduced gravity model is consolidated into a
single block toward the end of the routines.  These changes to use more 3-d
arrays could increase the computational time for the pressure gradient
calculations, but in short regression tests any such increase in computational
time appears to be small.  No external interfaces are changed, and all answers
are bitwise identical.
  It was noted in NOAA-GFDL/issues/491 that the call to
initialize_regridding() for diagnostics gives a segmentation fault when the
maximum depth of the ocean is greater than 9250 m unless DIAG_COORD_DEF_Z is
explicitly set.  This commit fixes this problem by (1) adding an extra layer to
the bottom of the hard-coded WOA09 list of diagnostic depths when the ocean is
deeper than the 9250 m maximum depth in that file, and (2) changing the default
behavior for diagnostic grids to be be uniform when the maximum ocean depth is
deeper than 9250 m, for which WOA09 is no longer likely to be a convenient
choice.  With this change, MOM6 no longer has segmentation faults for the
configuration described in issues/491.  All solutions are bitwise identical, but
some z-space diagnostic grids will be modified in cases that previously had
segmentation faults.
  Added the new runtime parameter BACKSCATTER_UNDERBOUND that can be set to
false to avoid a potential source of numerical instabilities from excessively
large biharmonic viscosities due to overly generous bounds where there are
negative Laplacian viscosities due to backscatter parameterizations.  Setting
this to true reproduces the previous solutions, while setting it to false treats
negative and zero Laplacian viscosities the same way when bounding the
biharmonic viscosity.  When the Laplacian viscosities are all non-negative, the
value of BACKSCATTER_UNDERBOUND makes no difference.  The default is true for
historical reasons, but this option probably should be set to false to avoid
certain numerical instabilities from the horizontal viscosities.  By default,
all answers are bitwise identical, but there are new entries in
MOM_parameter_doc files for cases that set both BETTER_BOUND_KH and
BETTER_BOUND_AH to true.
Add FRICTWORK_BUG parameter (default is true). If FRICTWORK_BUG is false, use the new way to compute FrictWork using the thickness flux. The previous version (realized by setting FRICTWORK_BUG as true) uses the velocity to compute FrictWork, which overestimates the total energy dissipation rate compared with the domain integral of KE_horvisc computed in MOM_diagnostics.
Bracket counter for <..> was correct but (..) was broken, it was
counting ( but not ).  I can only presume that such cases were very
rare.

This patch fixes the closed parenthesis count.
- 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,
  - INTWAVE_REMAPPING_USE_OM4_SUBCELLS, and
  - REMAPPING_USE_OM4_SUBCELLS
  all of which default to True.
- No answer changes.
This patch replaces references to kind=8 with the corresponding Fortran
kind identifiers as defined in iso_fortran_env.

Although these are widely equal to 8, there are a number of compilers
(notably NAG, also others) which set it to a different value.

This improves the portability of the code (albeit in a rather minor
way).
  Revise MOM_generic_tracer_min_max and array_global_min_max to fix several
problems that had previously been noted, and to make the location arguments
optional, reflecting that they are optional in the calling routine.  This
requires a revision to the order of arguments to MOM_generic_tracer_min_max.
The interface to array_global_min_max was extensively revised and simplified to
replace several previous arguments with a single new ocean_grid_type argument,
to make the location arguments optional, and add an optional unscale argument.

  This commit fixes a number of problems that had previously been noted with
array_global_min_max, including that:
 (1) It actually returns the global minimum and maximum values of the tracer;
 (2) It gives a position that is independent of the domain decomposition
     and grid rotation;
 (3) For all-zero arrays it correctly reports 0 for the minimum and maximum;
 (4) It properly handles unscaling of the input array;
 (5) It does not use a 3-d mask array that is actually just a 2-d mask array;
 (6) It is more efficient by grouping the global minimum and maximum calls.

  This commit also adds or revises comments to document the units and purpose
of the remaining undocumented real variables in MOM_generic_tracer.F90.

  These changes were tested and verified to be correct by calling
array_global_min_max for temperatures and salinities from write_energy, but
those changes were not included in this commit.

  This commit also adds an optional verbosity argument to g_tracer_flux_init in
config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90, reflecting a change
to ocean_BGC/generic_tracers/generic_tracer_utils.F90 that was adopted in August
of 2020, and is uses this new verbosity argument in the call from
MOM_generic_flux_init.

  While all solutions are bitwise identical, there are changes (corrections) in
some diagnostic output, and there are changes to the arguments of publicly
visible routines.
Certain compilers would expect values passed to ld which cannot be
passed to the C compiler.  This caused the autoconf C configuration to
fail, since it uses to CC for linking rather than LD.

Since we never use the C compiler for linking, this is not something we
need to be concerned about, and the LDFLAGS is disabled when testing the
C compiler.

This is only a concern when using certain GPU-related flags in the
Nvidia compiler, and is only a problem for libraries with a significant
amount of C code, such as FMS.
  Corrected a bug in rotate_ALE_sponge that incorrectly set the starting number
of sponge fields that prevented any cases with fixed ALE sponges from working
when ROTATE_INDEX is true, even if INDEX_TURNS is 0.  With this correction, the
code is now working (and giving identical answers) with rotation enabled for
cases with fixed ALE_sponges.  All answers are bitwise identical in cases that
worked before, but some cases that did not work at all are now working both
with and without grid rotation.
  Renamed the optional scale argument to myStats to unscale, mirroring the
recent additions of unscale arguments to the various chksum routines.  This
included changes to 6 calls to myStats in the two horiz_interp_and_extrap_tracer
routines.  Although myStats is public, it really is only used in
MOM_horizontal_regridding in the main version of MOM6, apart from a single call
in MOM_initialize_tracer_from_Z that does not use the optional unscale argument,
so rather than adding a second optional argument, this case seemed to be safe
enough to rename the argument in place.  If there were any unanticipated
problems with this argument name change, they would be manifest in code that
does not compile.  All answers are bitwise identical, but an optional argument
(scale) to a publicly visible diagnostic routine (myStats) was renamed.
  Added a refactored version of add_LOTW_BBL_diffusivity that is more accurate
by avoiding a subtraction of two large numbers to determine the distance from
the surface and more reproducible by avoiding the use of the Fortran sum
function.  This new version of the code is mathematically equivalent to the
original, and it is selected by setting the new runtime parameter
LOTW_BBL_ANSWER_DATE to be greater than 20240630.  This probably could have been
done reusing the existing parameter SET_DIFF_ANSWER_DATE, but this would have
meant answer changes for some cases that set this to a high value.  By default
the original code is used, but the default should be changed later to follow the
value of DEFAULT_ANSWER_DATE.  By default, all answers are bitwise identical but
there is a new runtime parameter in some cases.
breichl pushed a commit that referenced this pull request Dec 23, 2024
breichl pushed a commit that referenced this pull request Dec 18, 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 (mom-ocean#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>
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.