Skip to content

Stoch eos#5

Closed
pjpegion wants to merge 672 commits intodev/emcfrom
stoch_eos
Closed

Stoch eos#5
pjpegion wants to merge 672 commits intodev/emcfrom
stoch_eos

Conversation

@pjpegion
Copy link
Copy Markdown
Owner

This PR adds in a stochastic component to the density correction to the equation of date described in Stanley et al. 2020.
There is a new module (src/core/MOM_stoch_eos.F90 which creates random gaussian noise that has a decorrelation timescale dependent on the Kinetic energy of the surface layer.
MOM_stoch_eos_init is called by MOM.F90
and
MOM_stoch_eos_run is called by either
MOM_dynamics_unsplit.F90, src/core/MOM_dynamics_split_RK2.F90, or
src/core/MOM_dynamics_unsplit_RK2.F90

The random pattern is then passed down into MOM_density integrals, where it is used to modify the temperature variance estimate that is used for the density correction.

adcroft and others added 30 commits May 26, 2020 11:31
Codecov: Set base as parent (target) branch
  Modified ePBL_column to calculate Te and Se when EPBL_ORIGINAL_PE_CALC is
False and there are no temperature change diagnostics being requested, and to
return dPEc_dKd from one of the calls to find_PE_chg.  This avoids the use of
uninitialized values in EPBL_ORIGINAL_PE_CALC is false, and some solutions
appear to be similar, but others give large qualitative changes, so there are
probably still problems with EPBL_ORIGINAL_PE_CALC = False.  When this was
originally developed, it was verified to be mathematically equivalent, but in
the years that this code was not tested, problems have crept it.  All answers
in the MOM6-examples test cases are bitwise identical.
  Added an explicit MOM6 interface for cpu_clock_id, rather than simply passing
the call through to mpp_clock_id, both to explicitly document the interface and
arguments and to use the FMS run-time defaults for clock synchronization.  This
will enable SIS2 to use the MOM_cpu_clock module with the same behavior.  All
answers and output are bitwise identical.
  Added code to handle discrepancies between compliers in how "\t" is handled in
strings, so that the MOM6 documentation files are identical across compilers.
All answers are bitwise identical.
  Added an H_subroundoff term to the denominator of an expression in
calculate_bkgnd_mixing for the inverse of the mixed layer thickness, so that
NaNs will not be created when taking this inverse if CS%HMix is set to 0.  All
answers are bitwise identical in the MOM6-examples test cases.
  Minor correction to avoid scanning past the end of a string.  With sensitive
settings, this bug was causing sensitive models to abort, but if the model ran
it was giving bitwise identical answers.
  Slight revision to writeMessageAndDesc to handle the case when a change in tab
spacing will cause a line to exactly the maximum line length.  All answers are
bitwise identical answers.
- Modules, routines and labels in code changed from Neverland to
  Neverworld.
- Add aliases for parameters so that existing configurations still
  work (given that Neverworld was published but the runs used
  Neverland).
- was operating on segments not on core, oh no.
(*)Improve ePBL when EPBL_ORIGINAL_PE_CALC=False
MOM6: +Minor improvements in framework code
- The single subroutine that defined the wind stresses for Neverworld
  (renamed from Neverland) has been moved into MOM_surface_forcing.F90
  since an entire module for a single function that had no runtime
  parameters was overkill.
# Conflicts:
#	src/initialization/MOM_fixed_initialization.F90
- Allows a piecewise scurve (cubics with zero gradients at nodes)
  to be defined to construct a zonal wind stress profile
- Enabled with WIND_CONFIG="scurves"
- Requires mandatory parameters WIND_SCURVES_LATS and WIND_SCURVES_TAUX
  that define the nodal positions and values.
- Used in Neverworld2
- This topography is working but still likely to evolve.
- The code will be superseded by a more general approach.
  Added the new runtime parameter Z_INIT_SEPARATE_MIXED_LAYER and eliminated the
extra get_param calls for NKML and NKBL in MOM_temp_salt_initilaize_from_Z with
default values that are inconsistent with the defaults in MOM.F90.  Also revised
tracer_z_init_array and find_interfaces to eliminate unused arguments and added
grid type arguments so that these routines follow the rest of the MOM6 code in
how it deals with memory and indexing.  There are interface changes, and unless
Z_INIT_SEPARATE_MIXED_LAYER is explicitly set to true, some non-ALE cases that
explicitly set NKML (and do not just take the default value) will have changed
answers.  However, a preceeding PR to MOM6-examples will avoid these answer
changes and this PR fixes the problem that was in MOM6 with conflicting default
values for NKML and NKBL.  Reusing MOM_parameter_doc.short for MOM_input will
once again give the same answers (perhaps with added layout parameters to set
a non-default halo size in memory) in the MOM6-examples test suite.
- Allows run-time construction of topography defined by a list of
  functions with parameters, e.g.
```
BBUILDER_007_FUNC = "circ_conic_ridge" !
         ! The basin builder function to apply with parameters BBUILDER_007_PARS. Choices
         ! are: NS_COAST, EW_COAST, CIRC_CONIC_RIDGE, NS_CONIC_RIDGE.
BBUILDER_007_PARS = 0.0, -50.0, 10.0, 2.0, 200. !   [degrees_E,degrees_N,degrees,degrees,m]
         ! CIRC_CONIC_RIDGE parameters: center longitude, center latitude, ring radius,
         ! footprint radius, ridge height.

```
- The hard-coded implementation of the Neverworld2 topography
  has been replaced by the basin_builder approach so I'm deleting
  to avoid more unused code. This was added on the branch so the
  this minimizes net changes from dev/gfdl.
- CPT discussion suggest a smoother profile for the mid-atlantic
  ridge which I've implemented as an scurve.
  Obsoleted the runtime parameters SALT_REJECT_BELOW_ML, MLE_USE_MLD_AVE_BUG and
KG_BG_2D_BUG, and deleted the unused subroutine insert_brine.  Also deleted 68
variables that have been obsolete for several years.  All answers in the
MOM6-examples test cases are bitwise identical, but there are changes in the
MOM_parameter_doc files.
  Changed the default value of GILL_EQUATORIAL_LD to True.  This could change
answers in some test cases where GILL_EQUATORIAL_LD is not set explicitly, and
there are changes to the MOM_parameter_doc files.
  Removed the runtime parameter KELVIN_WAVE_2018_ANSWERS, which is no longer
used for anything.  All answers are bitwise identical, but there are changes
to the MOM_parameter_doc files.
adcroft and others added 22 commits July 23, 2020 15:47
MOM6: (*?)Revised ice_shelf_driver.F90 so it compiles
The "for" loop at L510 should be to nz instead of nz+1.  Due to array allocation sizes, this loop was extending beyond the shope of the argument arrays.
Squash merge of following commits:

* Testing: tc4 installs python-netCDF4 via venv

Currently, users are expected to have numpy and netcdf4 python modules
in order to generate the necessary netCDF input files.  This fails in
environments where these modules are unavailable.

This patch now installs the modules into a virtual environment which are
accessible when generating the tc4 inputs.

This solution is local to tc4 but could be extended to other tests as
needed.

* Testing: remove Python numpy and netCDF4 modules

The numpy and netCDF4 packages are no longer needed since tc4 now
installs these locally.

* Test: Install virtualenv for Python2

tc4 was using the venv module which appears to be python3-specific, and
Travis Ubuntu defaults to python2.  Also virtualenv was not installed in
either case.

This patch adds python-virtualenv to the install packages and uses the
virtualenv module.

* Test: Add python-dev for ARM64 numpy

Travis ARM nodes need to build numpy natively when installed by pip, and
thus require Python headers.  These are provided by the python-dev
package.

* Test: Revert to Py3 for tc4 generation scripts

Reverting the python 2 support (default for Travis) to use Python 3
syntax.

The main reason is that Python 3 includes venv (equivalent to
virtualenv) as its standard library, and is therefore guaranteed to
exist if Python 3 exists.

Python 3's virtualenv must be independently installed, which cannot be
confirmed.

This will cause problems for people without Python 3, but this is
probably the best solution, or at least the starting point for a more
general solution.

* Test: Adding python3-venv to Travis

Ubuntu apparently requires an explicit install of python3-venv despite
it being part of the standard library.  Go figure...

* Test: Arm64 tc4 Configuration support

Arm64 Ubuntu environments require explicit installations which are
otherwise provided on x86 Ubuntu:

* Python 3 Pip must be installed (python3-pip)
* Wheel installation must be explicitly installed
* Cython is required for numpy
* Numpy must be explicitly built before installing python-netCDF4

* Test: tc4 common Python local-env

Build times for setting up the virtual environments can be very
expensive on the Arm64 Ubuntu nodes, so we now create a shared directory
for launching the environments.

* Test: Use '.' in place of 'source' for Make

* Test: Test for required Python modules in tc4

We have reworked the Makefile to conditionally test for required Python
modules in tc4.  If unavailable, we install these in a virtual
environment.

This does not address many scenarios, such as if Python 3 is missing,
venv is missing (as in Ubuntu), or handle the situation if they do not
exist.  It assumes that either the modules exist, or that they can be
installed by venv.

This should be seen as an iterative step to get things working on Travis
x86 and Arm64, as well as GFDL's Gaea and most user Linux platforms.

* Test: Explicit python execs for tc4 input build

This resolves some issues with python2/3 resolution and limited support
of various platforms for module support.

Specifically, older platform with basic Python 3 support may not also
have numpy support.  In this case, we can defer back to Python 2 (or
whatever the system Python may be).

* Test: Setup Python venv at build time

This patch moves the Python virtual environment configuration to the
main Makefile, which is setup at build time, rather than in the model
configuration Makefile, which will typically not have internet access if
run on a compute node.

As before, the venv will only be setup when the numpy and netCDF4
modules are unavailable.  A minor bug in the logic of the check has
also been fixed.
…ureForce

Fixing loop bound error in MOM_PressureForce_Montgomery.F90
…-ocean#1163)

Squash merge:

* New diagnostics for barotropic momentum budget calculations are created. In these, different budget terms multiplied by fractional layer thicknesses are saved. Thus, these terms can be added over the whole to obtain the barotropic momentum budget. 'btstep' subroutine in MOM_barotropic module is modified to return fractional thicknesses. Pressure force acceleration multiplied by fractional thickness as diagnostics are added in this commit.

* More thickness weighted diagnostics

* Implemented Andrew Shao's suggestions

* More fractional thickness multiplied diagnostics

* Some barotropic diagnostics obtained from fractional thickness multiplied momentum budget terms

* Removed trailing spaces

* All fractional-thickness multiplied diagnostics implemented

* define diagnostic variables as pointers

* Shorter initialization of 2D arrays

* Modifications in vertical friction diagnostics

* Diagnostics initialization as pointers to save memory allocation

* Vertical friction module

* Removed commented lines and trailing spaces

* Diagnostic description change

* Fractional thickness-weighted diagnostics for acceleration due to relative vorticity and gradient of kinetic energy

* Modifications in vertical friction diagnostics (fractional thickness-weighted)

* Modifications in diag_hfrac_u and diag_hfrac_v calls

* Made allocation of hfrac at u/v points optional. These arrays are only allocated if any of the relevant diagnostics are called.

* Fractional-thickness weighted 3D diagnostics are now commented out as we do not the proper grid remapping option.

* Initialization of 2D diagnostic arrays changed from pointer type to allocatable array style.

* Trailing spaces removed and line lengths reduced to be under 120 characters

* Comment modified

Reviewed by Robert Hallberg <Robert.Hallberg@noaa.gov>
This patch fixes three dimensionality errors in the OBC segments.

- We add a missing GV%m_to_H conversion for time-dependent eta segments.

- The `adjustSegmentEtaToFitBathymetry` function depends on the
  `segment%Htot` field when computing the dz_src cell spacings.

  While the calculation primarily assumes that all quantities scale as
  Z, the segment%Htot field scales as H, which was causing
  dimensionality errors.

  We resolve this by converting Htot from Z to H whenever it is used in
  the calculation.

- Segment barotropic velocitys based on transports were limited to a
  hard-coded thickness of 1e-12, which was not scaled.  We have added
  H-dimensional scaling to these constants.
The current OBC segment list includes a "segment zero" which corresponds
to when the segment maps (segnum_u, segnum_v) point to OBC_NONE, which
is set to zero.

The purpose of this "segment zero" seems to be for avoiding invalid
references, so that OBC%segment(OBC%segnum_[uv](i,j)) always returns a
valid result, included when set to OBC_NONE.  This results in reading
and setting values which are unused or unneeded.

This patch replaces these redundant accesses to segment zero with
various conditional blocks for avoiding these accesses.
There were a few remaining segnum_[uv] references in MOM_open_boundary
which could reference segment zero.  This patch fixes those references.
- Adds a diagnostic of the parameterized SGS T variance used in the
  Brankart correction to the PGF
- The SGS T variance is measure from the grid-scale variance. It should
  be a horizontal difference but is approximated as along coordinate.
  This adds thickness weighting to avoid large values near topography.
@pjpegion pjpegion closed this Aug 24, 2020
pjpegion pushed a commit that referenced this pull request Feb 1, 2021
pjpegion pushed a commit that referenced this pull request Jun 11, 2021
*Added a clock for the Stanley parameterization

Co-authored-by: jkenigson <jkenigso@gmail.com>
pjpegion pushed a commit that referenced this pull request Jul 28, 2021
Explicit domain decomposition of horizontal axes
pjpegion pushed a commit that referenced this pull request Sep 21, 2021
Update MOM_oda_incupd.F90
pjpegion pushed a commit that referenced this pull request Jun 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.
pjpegion pushed a commit that referenced this pull request Jun 15, 2022
Redefine ~500 pointers as local or stack variables
pjpegion added a commit that referenced this pull request Aug 25, 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 (NOAA-EMC#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>
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.

10 participants