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

Ice shelf dynamic sfc accum #5

Conversation

MJHarrison-GFDL
Copy link

No description provided.

Hallberg-NOAA and others added 30 commits December 10, 2021 10:09
  Return the diabatic_aux_CSp from extract_diabatic_member it is present as an
optional argument.  Somehow this was omitted when this routine was created, but
without this correction the offline tracer mode returns a segmentation fault.
Also, added the proper conversion factor in the register_diag_field call for
e_predia, and internally calculate the interface heights in units of [Z ~> m]
for dimensional consistency testing.  All answers are bitwise identical in
cases that ran before.
  Issue a warning with a helpful message if opacity_from_chl is called with no
shortwave fluxes, and added logical tests to avoid a segmentation fault later in
this routine.  This should not happen, as it makes no sense, but it was
occurring with the offline tracer code, and can be avoided by setting
PEN_SW_NBANDS=0 if there are no shortwave fluxes to penetrate.  Also turned the
real dimensional parameter op_diag_len into a variable and set it immediately
before where it is used.  Many spelling errors were also corrected in
MOM_opacity.F90.  All answers are identical in cases that ran before.
  Corrected the comments describing the optional arguments to advect_tracer and
fixed a few spelling errors in comments.  All answers are bitwise identical.
  Corrected bugs in the offline tracer code that were preventing it from
reproducing across processor counts (and perhaps working sensibly at all). All
answers and output in the MOM6-examples regression suite are bitwise identical.
Although answers with the offline tracer code will change because of the bug
fix, because of some bugs that were fixed in another recent commit, it was
previously impossible to have run the offline tracer cases at all.
  Substantially refactored the offline tracer code.  This refactoring includes
adding grid and unit_scale_type arguments to several routines related to the
offline tracer code.  An offline tracer advection test case is now consistent
across processor layouts and pass the dimensional rescaling tests (including the
chksums in debug mode), and there are comments describing all the real variables
and their dimensions in the offline tracer routines.  All answers and output are
bitwise identical.
  Minorly revised the algorithms used for offline tracer advection for
rotational consistency, and for exact reproducibility across PE layouts by using
reproducing sums to detect convergence.  This also includes some changes to use
roundoff to detect convergence instead of fixed values.   Also replaced some
divisions with multiplication by a reciprocal.  In addition, some of the
optional arguments to advect_tracer that are only used for offline tracer
advection were renamed or revised for clarity and reordered for the convenience
of the non-offline-tracer code.

  Although answers with the offline tracer code will change slightly because of
this refactoring, because of some bugs that were fixed in another recent commit,
it was previously impossible to have run the offline tracer cases at all.  All
answers and output in the MOM6-examples regression suite are bitwise identical.
  Corrected the reported unit conversions in two comments describing variables
in MOM_offline_aux.F90.  All answers and output are bitwise identical.
  Rescaled the units of optics%opacity_band from [m-1] to [Z-1 ~> m-1], with the
opacity values returned from extract_optics_slice also rescaled by the same
factor, which can be offset by compensating changes to the opacity_scale
argument.  Also rescaled 4 other internal variables and documented the units on
3 more.  One uncommon parameter (SW_1ST_EXP_RATIO) listed the wrong units in its
get_param call, and this was corrected, but turned out not to have been logged
for any of the MOM6-examples test cases.  Some compensating changes were also
made in the MOM_generic_tracer module, which directly accesses the contents of
the optics_type (thereby preventing it from being opaque).  All answers and
output in the MOM6-examples test suite are bitwise identical.
  Modified three routines in MOM_opacity to avoid segmentation faults if
PEN_SW_NBANDS = 0, and hence if the optics type is not being allocated.  In the
case of optics_nbands(), this involved formally changing an optics_type argument
into a pointer to an optics_type.  (Pointers to an optics_type were already been
used as the argument in all calls to optics_nbands(), but it was not always
associated.)  In two other routines, the change is simply to add a return call
if there are 0 bands of shortwave radiation.  With these changes, the single
column test cases with no penetrating shortwave radiation now successfully run
if PEN_SW_NBANDS = 0 and give answers that are identical to those obtained with
PEN_SW_NBANDS = 1.  All answers and output in cases that ran previously are
bitwise identical, but there is a subtle change in a public interface.
* In MOM_ice_shelf_dynamics.F90 changes are  made to calc_shelf_visc() and calc_shelf_driving_stress() to account for an irregular quadrilateral grid. In MOM_ice_shelf_initialize.F90 changes are made to initialize_ice_thickness_from_file() to correct masks at initialization.

* Changed indentation

* Changes are made to 'calc_shelf_visc()` to make computations of the velocity derivatives rotation-invariant. Changes in `update_ice_shelf()` utilize G%IareaT(:,:) instead of 1/G%areaT(:,:).
* Adding temperature restore capability for SPEAR.

Added parameter SPEAR_ECDA_SST_RESTORE_TFREEZE to allow activation of
sea surface salinity based modification of restoring of temperature.
The formula used is different from the Millero (default in SPEAR runs)
scheme.

* removed spaces on blank line.

* (*)Changed hard wired value to parameter defined in MOM_override

The freezing temperature came from SIS2 code. Changing the default value here to be consistent with that. (-0.054 vs -0.0539)
The salinity restoring code used the -0.0539 value also so answers may change if using that code (RESTORE_SALINITY=T)

* (*)Changed hard wired value to parameter defined in MOM_override

The freezing temperature came from SIS2 code. Changing the default value here to be consistent with that. (-0.054 vs -0.0539)
The salinity restoring code used the -0.0539 value also so answers may change if using that code (RESTORE_SALINITY=T)

* Forgot to replace the salinity masking mulitplier with the override
parameter
  Added unit_scaling_type arguments to various routines that had previously used
a unit scaling type, but did so via the G%US pointer, to make the type
dependencies more explicit and to avoid unnecessary pointer use.  It had been
the intention to make these arguments explicit from the time they were
introduced via a pointer in the ocean_grid_type as a temporary convenience.
The construct G%US%... was replaced with US%... wherever it was possible.

  Also rescaled some local variables or corrected comments in oil_tracer.F90,
nw2_tracers.F90, and boundary_impulse_tracer.F90, and rescaled the units of
the dt argument to MOM_generic_tracer_column_physics from [s] to [T ~> s].

  All answers are bitwise identical, although there are multiple changes to
public interfaces.
The stochastic physics feature has been added in MOM6. The following are from Phil Pegion:

The ocean stochastic physics has been re-coded such that there is a wrapper in config_src/external/OCEAN_stochastic_phyiscs that contains the calls to the external stochastic_physics repository. This has been added to support non-UFS applications of MOM6 where the stochastic_physics repository is not part of the build. The init and run procedures are called from src/core/MOM.F90. I have also created a new control structure stochastic_CS, which contains the logical variables, and random patterns which are then passed into src/parameterizations/vertical/MOM_diabadic_driver.F90 and src/parameterizations/vertical/MOM_energetic-PBL.F90.

The writing of the ocean stochastic restarts sit in config_src/nuopc_cap/mom_cap.F90

Co-authored-by: pjpegion <[email protected]>
  Corrected the documentation of the units for 31 variables in various modules.
All answers and output are bitwise identical.
  Rescaled the dimensions of the tidal amplitudes and frequencies used
internally in calc_tidal_forcing() and ramp-up times used by update_OBC_ramp()
and updateCFLtruncationValue() for nearly complete dimensional consistency
testing.  New unit_scale_type arguments were added to 5 routines, in the case of
calc_tidal_forcing() replacing a previous optional argument that was always
being used.  One overly short internal variable, "N", was renamed "nodelon" to
make its purpose clearer and easier to search for.  All answers are bitwise
identical, but there are changes to the argument lists of 5 routines.
  Commented out the problematic lines that Andrew Shao flagged in his review of
MOM6 dev/gfdl PR mom-ocean#37.  The model runs perfectly well in short offline-tracer
test runs, and even gives bitwise identical output, perhaps because no layers
were being abruptly flooded to 10^13 times their previous values.  These omitted
lines could change answers in some cases, so the lines in question have been
retained in case the offline tracer code needs to be debugged layer and these
mysterious (and seemingly unhelpful) lines turn out to have been necessary.  All
answers in the non-offline-tracer runs are bitwise identical.
Replace `.gt.` with `>`
  Corrected uninformative comments describing the some of the arguments to the
stub routines in config_src/external/GFDL_ocean_BGC/generic_tracer.F90.  The
updated comments are consistent with how they are used in calls to these
routines and with the underlying actual generic_tracer code if they are actually
documented there.  The previous comments had been added to existing undocumented
code to satisfy the MOM6 requirement that there be a doxygen comment describing
every argument to every routine, in the hopes that someone with familiarity with
the generic tracer could work amend them to something more appropriate.
However, "Unknown" is neither an accurate nor an informative description, and
current MOM6 standards would demand that we reject any new code contributions
with such poor interface documentation.  All answers are bitwise identical, and
only comments have changed.
- A do_not_log depends on a logical that is only set
  conditionally. This initializes that logical when
  the corresponding parameter is not being read.
- Unfortunately, this change MOM_parameter_doc.all for
  the coupled models. The .all pipeline uses the gnu compiler
  which was initializing this logical as .true. and thus
  logging the new parameter when it should not have been. Intel
  and PGI were initializing with .false.
  Eliminated 4 unnecessary 3-d allocatable arrays and 8 2-d diagnostic arrays
in CorAdCalc, and simplified the code calculating these diagnostics by using the
post_product_[uv] and post_product_sum_[uv] routines.  Also grouped the calls
that allocate the memory that is still needed for diagnostics.

  This commit also includes a few other minor changes to clean up the
documentation of variable intents and unit documentation in a handful of other
places in the code:

- Add intent declarations to the arguments to chksum2d() and chksum3d()

- Corrected incorrect scale arguments for two (untested) checksum calls.

- Corrected the documented units in several comments.

  All answers and output are bitwise identical.
+(*)Rescale opacity and avoid segmentation faults
Hallberg-NOAA and others added 11 commits December 29, 2021 07:55
  Deleted four lines in the offline tracer code that had recently been commented
out, along with the comments describing them.  Further conversations had led to
a consensus that these lines served no useful purpose, and are not worth keeping
in the code, even in comments.  Several excess spaces were also eliminated in
MOM_offline_aux.F90.  All answers and output are bitwise identical.
  Use the por_face_area[UV] in the effective thickness calculations in
zonal_face_thickness and merid_face_thickness, so that they are more consistent
with their use elsewhere in the code for the relative weights in calculating the
barotropic accelerations.  Because these por_face_area arrays are still 1 in all
test cases, the answers are unchanged in any test cases from before a few weeks
ago, but there could be answer changes in cases that are using the very recently
added capability (in PR #3) to set fractional face areas.  This change was
discussed with Sam Ditkovsky, and agreed that there is no reason to keep the
ability to recover the previous answers in any cases that use the recently added
partial face width option.

  This commit also expanded the comments describing the h_u and h_v arguments to
btcalc(), zonal_face_thickness(), and merid_face_thickness() routines, the
diag_h[uv] elements of the accel_diag_ptrs type and the h_u and h_v elements of
the BT_cont_type.

  All answers and output are bitwise identical in the MOM6-examples test suite
and TC tests, but answer changes are possible in cases using a very recently
added code option.
+(*)Get the offline tracer mode working again
* Adds option to homogenize forces and fluxes fields

- Adds functions to do global averages on U and V grids in MOM_spatial_means
- Adds functionality to average all forcing and fluxes fields in MOM_forcing_types
- Adds flag to average all forcing and fluxes in MOM.F90
- This new feature is primarily for running in single column like configurations with the coupler, which requires perfectly equal forcing across all cells.

* Fixing ustar calculation in homogenize_mech_forcing

- Adds in irho0 and sqrt that were missing in homogenize mech forcing.

* Updates to homogenize_forcings options.

- Correct issues in global_area_mean_u and global_area_mean_v to work with symmetric and rotated grids.
- Add options to compute mean ustar or compute ustar from mean tau.
- Add subroutines to replace averaging blocks in MOM_forcing_type.

* Minor formatting updates

- Move a division and reformat alignment in MOM_spatial_means.F90.
- Remove a unused parameter in MOM_forcing_type.F90
- Reformat misalignment of an "if-block" in MOM_forcing_type.F90

* Remove obsolete netSalt flux homogenization

- netSalt has been removed so no longer needs homogenized in the fluxes.

* Fix 2d mean on U grid to use U mask

* Remove whitespacace

* Add do_not_log option to UPDATE_USTAR get_param
* Hydrostatic initialization in ice cavities

    - Iteratively solve for the initial ice shelf displacement
      in cavities by calculating the pressure at the current
      displacement depth using the unperturbed profile.
    - This change should obsolete TRIM_IC_FOR_PSURF and DEPRESS_INITIAL_SURFACE for
      ice shelf applications and should work for arbitrary equations of state.
    - Existing implementations (e.g. ISOMIP) should turn off the above options
      in order to exercise this feature.
    - This code change should not impact non ice-shelf configurations
      or those with either of the above two options.

* Addresses a number of issues identified in code review.

* add appropriate intent to ice_shelf_query

* fix unit scaling comments

Co-authored-by: Marshall Ward <[email protected]>
…ean#48)

* Refresh attempt to get rid of NetCDF calls

* Fix comments

* Set netCDF attrs in MOM_horizontal_regridding

This patch sets the following netCDF attributes in the function
`horiz_interp_and_extrap_tracer_record` via `read_attribute`.

* `missing_value` (as `_FillValue`)
* `scale_factor`
* `add_offset`

This resolves some issues related to uninitialized values.

* read_variable_2d in horizontal remapping

This patch extends the `read_variable` interface to include 2d array
support, in order to facilitate domainless I/O via netCDF calls.

This is far from the best implementation (e.g. read_variable_2d
introduces another `broadcast` alongside the original one in the
horizontal regridding) but it addresses the immediate issues with
`MOM_read_data()`.

* set default scale factor to 1

* add missing start/count arguments

* Update MOM_io.F90

* Manage optional args in read_variable_2d

This patch modifies read_variable_2d so that the size() tests of the
optional arguments are applied before the call to nf90_get_var.

The tests are also wrapped inside present() flags to avoid checking
unassigned variables.

Thanks to Robert Hallberg for the suggestions.

Co-authored-by: Matthew Harrison <[email protected]>
  Eliminated a number of instances of non-standard syntax from that described in
https://github.com/NOAA-GFDL/MOM6/wiki/Code-style-guide.  The changes include
enforcing the MOM6-standard 2-point indentation convention, replacing 'if(A)'
with 'if (A)', and changing logical comparison syntax like '.gt.' to '>' or
'.eq.' to '=='.  An old commented out block of code for debugging (detected by
its use of non-standard syntax) was also eliminated.  All answers and output are
bitwise identical.
  Slightly modified the recently added subroutine calc_sfc_displacement to
document the units of its variables and to follow the MOM6 code standards from
https://github.com/NOAA-GFDL/MOM6/wiki/Code-style-guide.  The changes include
white-space corrections, changing logical comparison syntax like '.gt.' to '>',
and explicitly identifying where array syntax is used.  All answers and output
are bitwise identical.
@OlgaSergienko OlgaSergienko merged commit c1358f2 into OlgaSergienko:ice_dynamics Jan 14, 2022
OlgaSergienko pushed a commit that referenced this pull request Nov 1, 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 (mom-ocean#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 (mom-ocean#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 (mom-ocean#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 (mom-ocean#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 (mom-ocean#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]>
OlgaSergienko pushed a commit that referenced this pull request Nov 15, 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.
OlgaSergienko pushed a commit that referenced this pull request Nov 15, 2022
Redefine ~500 pointers as local or stack variables
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.

8 participants