Skip to content

Update MOM_oda_incupd.F90#5

Merged
jiandewang merged 1 commit intojiandewang:EMC-IAU-candidate-20210727from
pjpegion:patch-1
Aug 5, 2021
Merged

Update MOM_oda_incupd.F90#5
jiandewang merged 1 commit intojiandewang:EMC-IAU-candidate-20210727from
pjpegion:patch-1

Conversation

@pjpegion
Copy link
Copy Markdown

@pjpegion pjpegion commented Aug 5, 2021

remove unused index bounds, and fix sum_h2 loop.

remove unused index bounds, and fix sum_h2 loop.
@jiandewang jiandewang merged commit 3fb3a4c into jiandewang:EMC-IAU-candidate-20210727 Aug 5, 2021
jiandewang pushed a commit that referenced this pull request Feb 1, 2022
  Added a new variable, initialized, to the control structures of modules that
had been testing for an allocated control structure to verify that it had been
initialized before it was going to be used, and then duplicated the tests using
this new variable.  This was done to enable us to go ahead with MOM6 PR #5,
which eliminated many of these checks when converting the control structures
from pointers in the parent modules to elements that are always there, and then
passing them as simple types instead of as pointers.  If we decide that we do
not need these tests after all, we can easily delete them, but until this is
discussed, this commit avoids losing the messages, as it was easier to do it
this way instead of trying to recreate them after they had been removed.  All
answers and output are bitwise identical.
jiandewang pushed a commit that referenced this pull request Feb 1, 2022
Redefine ~500 pointers as local or stack variables
jiandewang pushed a commit that referenced this pull request Jun 6, 2022
* initial hooks for stochastic EOS modifications

* remove debug statements

* add documentation

* Change ampltiude from 0.39 to sqrt(.39)

* remove global_indexing logic from stoch_eos_init

* switch to using MOM_random and add restart capability

* update random sequence to update each each time-step

* remove tseed0 from MOM_random (leftover from debugging)

* Added necessary submodules and S^2, T^2 diagnostics to MOM_diagnostics

* Added diagnostics for outputting variables related to the stochastic parameterization.

* Diagnostics in MOM_PressureForce_FV updated for stochastic (rather than deterministic) Stanley SGS T variance parameterization.

* Added parentheses for reproducibility.

* Changed diagnostics to account for possible absence of stoch_eos_pattern in MOM_PressureForce_FV,
when deterministic parameterization is on.

* remove mom6_da_hooks and geoKdTree from pkg

* add stochastic compoment to MOM_thickness_diffuse

* fix array size declaration and post_data

* Corrected indexing of loops in MOM_calc_varT

* Changed how parameterization of SGS T variance (deterministic and stochastic) is switched on in PGF and thickness diffusion codes

* Corrected a few typos

* Cleaned up indices, redundant diagnostic, printing

* Fixed diagnostic IDs

* Fixed diagnostics typo

* Corrected indices in calculation of tv%varT

* Minor index fix

* Corrected bug in pressure in Stanley diagnostics

* Fixed whitespace error

* Stoch eos clock (#5)

*Added a clock for the Stanley parameterization

Co-authored-by: jkenigson <jkenigso@gmail.com>

* add halo update to random pattern

* Update MOM_stoch_eos.F90

Fix bug for looping over compute domain (is -> isc etc.)

* Avoid unnessary computations on halo (MOM_stoch_eos) and code clean-up (MOM_thickness_diffuse)

* Removed halo updates before determ param calc

* Update MOM_stoch_eos.F90

Removed unnecessary code

* Bug - indices are transposed

* Changed Stanley stochastic coefficient from exp(X) to exp(aX) (#9)

* Changed Stanley stochastic coefficient from exp(X) to exp(aX)

* Extra spaces removed

* Stoch eos init fix (#10)

* Don't bother calculating tv%varT if stanley_coeff<0

* Missing then added

* Merge Ian Grooms Tvar Discretization (#11)

* Update MOM_stoch_eos.F90

In progress updating stencil for$ | dx \times \nabla T|^2$ calculation

* New discretization of |dx\circ\nablaT|^2

Co-authored-by: Ian Grooms <ian.grooms@colorado.edu>

* Multiplied tvar%SGS by grid cell thickness ratio

* Added limiter for tv%varT

* Stoch eos ncar linear disc (#12)

* Update MOM_stoch_eos.F90

In progress updating stencil for$ | dx \times \nabla T|^2$ calculation

* New discretization of |dx\circ\nablaT|^2

* AR1 timescale land mask

Adds land mask to the computation of the AR1 decorrelation time

* Update dt in call to MOM_stoch_eos_run

The call to `MOM_stoch_eos_run` (which time steps the noise) is from within `step_MOM_dynamics`. `step_MOM_dynamics` advances on time step `dt` (per line 957), but the noise is updated using `dt_thermo`. It seems more appropriate to update the noise using `dt`, since it gets called from within `step_MOM_dynamics`.

* Fixed the units for r_sm_H

* Remove vestigial declarations

The variables `hl`, `Tl`, `mn_T`, `mn_T2`, and `r_sm_H` are no longer used, so I removed their declarations and an OMP private clause

Co-authored-by: Ian Grooms <ian.grooms@colorado.edu>

* Update MOM_thickness_diffuse.F90

Changed index for soft convention

* Update CVMix-src

* Ensure use_varT, etc., initialized

* Don't register stanley diagnostics if scheme is off

* Stanley density second derivs at h pts (#15)

* Change discretization of Stanley correction (drho_dT_dT at h points)

* Limit Stanley noise, shrink limiting value

* Revert t variance discretization

* Reverted variable declarations

* Stanley scheme in mixed_layer_restrat, vert_fill in stoch_eos, code cleanup (NOAA-EMC#19)

* Test Stanley EOS param in mixed_layer_restrat

* Fix size of TS cov, S var in Stanley calculate_density calls

* Test move stanley scheme initialization

* Added missing openMP directives

* Revert Stanley tvar discretization (NOAA-EMC#18)

* Perform vertical filling in calculation of T variance

* Variable declaration syntax error, remove scaling from get_param

* Fix call to vert_fill_TS

* Code cleanup, whitespace cleanup

Co-authored-by: Jessica Kenigson <jessicak@cheyenne1.cheyenne.ucar.edu>

* Use Stanley (2020) variance; scheme off at coast

* Comment clean-up

* Remove factor of 0.5 in Tvar

* Don't calculate Stanley diagnostics on halo

* Change start indices in stanley_density_1d

* Stanley param in MOM_isopycnal_slopes (NOAA-EMC#22)

Stanley param in MOM_isopycnal_slopes and thickness diffuse index fix

* Set eady flag to true if use_stored_slopes is true

* Cleanup, docs, whitespace

* Docs and whitespace

* Docs and whitespace

* Docs and whitespace

* Whitespace cleanup

* Whitespace cleanup

* Clean up whitespace

* Docs cleanup

* use_stanley

* Update MOM_lateral_mixing_coeffs.F90

* Adds link to another TEOS10 module

* Set Stanley off for testing

* Line continuation

Co-authored-by: Phil Pegion <38869668+pjpegion@users.noreply.github.com>
Co-authored-by: Philip Pegion <Philip.Pegion@noaa.gov>
Co-authored-by: Jessica Kenigson <jessicak@cheyenne6.cheyenne.ucar.edu>
Co-authored-by: Jessica Kenigson <jessicak@cheyenne3.cheyenne.ucar.edu>
Co-authored-by: jkenigson <jkenigso@gmail.com>
Co-authored-by: jskenigson <jessica.kenigson@colorado.edu>
Co-authored-by: Jessica Kenigson <jessicak@cheyenne1.cheyenne.ucar.edu>
Co-authored-by: Jessica Kenigson <jessicak@cheyenne5.cheyenne.ucar.edu>
Co-authored-by: Philip Pegion <ppegion@Philips-MacBook-Pro.local>
Co-authored-by: Jessica Kenigson <jessicak@cheyenne4.cheyenne.ucar.edu>
jiandewang pushed a commit that referenced this pull request Jul 23, 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 mom-ocean#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
jiandewang pushed a commit that referenced this pull request Sep 27, 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>
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.

2 participants