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

Bug fix for reading First_direction from restart #18

Merged

Conversation

herrwang0
Copy link

This PR address issue mom-ocean#1546 .

  1. The primary purpose of this PR is to fix the bug that First_direction is not correctly read from restart files. Previously, the code was only added in an if-block that rotate_index is true.
  2. Some minor changes are introduced for clarification purposes. When index rotation is turned on, the meaning of the first direction can be ambiguous. It makes more sense to me that the integer parameter FIRST_DIRECTION from MOM_input and float field First_direction written to and read from the restart files have a physical meaning, i.e. their meanings and values should be independent from index rotation.
    • Local variable first_direction in subroutine initialize_MOM is slightly repurposed. Now it is only used to store parameter FIRST_DIRECTION read from MOM_input. In this way, the modification of "turns" to G%first_direction is more explicit.
    • Initialization of CS%first_dir_restart is moved after state initialization to increase readability.
  3. Per discussion in the aforementioned issue, a FATAL error is now raised when both ROTATE_INDEX and ALTERNATE_FIRST_DIRECTION are true. This is mainly to avoid the potential ambiguous meaning of first_direction. It is probably not ideal but can be changed in the future if needed. (e.g. One can add turns parameter to the control structure and use it to update CS%first_dir_restart every dynamical time step.)

* A bug on reading parameter First_direction from the restart is fixed.
Previously, it only works when rotate_index is .true.
* A FATAL error is now issued when both ROTATE_INDEX and
ALTERNATE_FIRST_DIRECTION are .true. This should only be treated as a
temporary patch.
* Local variable first_direction in initialize_MOM is slightly
repurposed to exclude any modication by rotate_index turns.
This helps clarify the meaning of First_direction in restart files,
making it independent from index rotation.
@codecov
Copy link

codecov bot commented Nov 30, 2021

Codecov Report

Merging #18 (264fc20) into dev/gfdl (a44e460) will increase coverage by 0.00%.
The diff coverage is 36.36%.

Impacted file tree graph

@@            Coverage Diff            @@
##           dev/gfdl      #18   +/-   ##
=========================================
  Coverage     29.17%   29.17%           
=========================================
  Files           240      240           
  Lines         71488    71493    +5     
=========================================
+ Hits          20854    20856    +2     
- Misses        50634    50637    +3     
Impacted Files Coverage Δ
src/core/MOM.F90 58.91% <36.36%> (-0.07%) ⬇️

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 a44e460...264fc20. 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 have carefully examined this PR, and I agree that these changes do properly correct a bug and adds an appropriate error for cases that are not yet being handled. This PR has passed TC testing and it passed pipeline testing at https://gitlab.gfdl.noaa.gov/ogrp/MOM6/-/pipelines/14277.

@Hallberg-NOAA Hallberg-NOAA merged commit ad35e4a into NOAA-GFDL:dev/gfdl Dec 6, 2021
@Hallberg-NOAA Hallberg-NOAA added the bug Something isn't working label Feb 1, 2022
marshallward pushed a commit that referenced this pull request Jul 2, 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 <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

* 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 (#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 (#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 <[email protected]>

* 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 (#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 <[email protected]>
Co-authored-by: Philip Pegion <[email protected]>
Co-authored-by: Jessica Kenigson <[email protected]>
Co-authored-by: Jessica Kenigson <[email protected]>
Co-authored-by: jkenigson <[email protected]>
Co-authored-by: jskenigson <[email protected]>
Co-authored-by: Jessica Kenigson <[email protected]>
Co-authored-by: Jessica Kenigson <[email protected]>
Co-authored-by: Philip Pegion <[email protected]>
Co-authored-by: Jessica Kenigson <[email protected]>
@herrwang0 herrwang0 deleted the bugfix_alternate_first_dir branch September 18, 2023 02:25
theresa-cordero added a commit to theresa-cordero/MOM6 that referenced this pull request Nov 18, 2024
Remove eqn_of_state from generic tracer interfaces because the
photoacclimation mixed layer depth is now calculated in MOM6 and
passed to MOM6.

Co-authored-by: Theresa Morrison <[email protected]>
theresa-cordero added a commit to theresa-cordero/MOM6 that referenced this pull request Nov 18, 2024
Remove eqn_of_state from generic tracer interfaces because the
photoacclimation mixed layer depth is now calculated in MOM6 and
passed to MOM6.

Co-authored-by: Theresa Morrison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants