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

MOM6: +(*)Rescale pressures #1089

Merged
merged 62 commits into from
Apr 21, 2020

Conversation

Hallberg-NOAA
Copy link
Collaborator

This PR includes a set of changes that introduce rescaling of pressures and
related variables for dimensional consistency testing. These changes include
extensive extensions to the interfaces for the equation of state and the
introduction of new arguments to several routines. The new interfaces are
widely used throughout the MOM6 code. There are no changes to solutions,
diagnostics, or output files, but answers could change in cases that were trying
to use ALE remapping and a RHO coordinate with a reference pressure other than
the previously hard-coded value of 2000 dbar, as the reference pressure will now
be properly set at run-time. The commits in this PR include:

  Added optional pres_scale arguments to various MOM_EOS.F90 routines to allow
pressures to be passed with in various units for flexibility and streamlined
dimensional consistency testing.  Also added optional rho_scale arguments to the
various int_density_dz subroutines.  All answers are bitwise identical, but
there are new optional arguments to public interfaces.
  Rescaled the pressures in Boussinesq pressure force calculations, including
changing the units of the densities passed to set_pbce_Bouss and using the new
rho_scale and pres_scale arguments to the equation of state routines.  All
answers are bitwise identical.
  Optionally rescale the units of the specific volume integrals. Added new
optional SV_scale and pres_scale arguments to int_specific_vol_dp,
int_spec_vol_dp_generic, and int_spec_vol_dp_Wright.  All answers are bitwise
identical, but there are new optional arguments to public interfaces.
  Rescaled the pressures and specific volumes in the non-Boussinesq pressure
force calculations, including changing the units of the pressures passed to
set_pbce_nonBouss and using the new SV_scale and pres_scale arguments to the
equation of state routines.  All answers are bitwise identical.
  Rescaled the pressure used to calculate density integrals in find_eta_3d and
find_eta_2d to [R L2 T-2] and used the new pres_scale and SV_scale arguments to
int_specific_vol_dp.  All answers are bitwise identical.
  Rescaled the pressure used in calls to calculate_density_derivs to [R L2 T-2]
in calculate_density_derivs.  All answers are bitwise identical.
  Rescaled pressures to [R L2 T-2] in calculate_vertical_integrals for improved
dimensional consistency testing.  All answers are bitwise identical.
  Added new RL2_T2_to_Pa and W_m2_to_RZ3_T3 elements to the unit_scale_type
for code simplification and clarity.  Also corrected spelling errors in the
get_param descriptions of 5 scaling factors, which will change comments in the
MOM_parameter_doc.debugging files.  All answers are bitwise identical.
  Replaced products of scaling factors (like US%R_to_kg_m3*US%L_T_to_m_s**2)
with combined scaling factors (like US%RL2_T2_to_Pa) to simplfy and clarify the
code.  All answers are bitwise idenical.
  Rescaled the units of forces%p_surf, fluxes%p_surf, forces%p_surf_full and
fluxes%p_surf_full and related surface pressure variables to [R L2 T-2 ~> Pa]
for expanded dimensional consistency testing.  All answers are bitwise identical,
although there are changes to the rescaled units of elements to two transparent
data types.
  Revised the dimensional rescaling of ice_shelf_CS%g_Earth to match GV%g_Earth
and ice_shelf_dyn_CS%g_Earth to minimize confusion when examining different parts
of the code.  Also cancelled out pairs of unit conversion factors when setting
the ice shelf contributions to fluxes%p_surf and forces%p_surf.  All answers are
bitwise identical.
  Added a new optional pres_scale argument to the calculate_TFreeze interfaces
to rescale pressures for dimensional consistency testing.  All answers are
bitwise identical.
  Use the new pres_scale argument to TFreeze and pass rescaled pressures to
calculate_TFreeze and several instances of calculate_density.  All answers are
bitwise identical.
  Added variants of calculate_density routines that use a hor_index_type to
specify array extents and unit_scale_types for dimensional consistency testing,
further overloading existing interfaces.  Also replaced the recently added
rho_scale and pres_scale arguments to int_density_dz with an optional
unit_scale_type argument, and modified calls to use this new argument.  All
answers are bitwise identical, but there are changes to external interfaces.
  Revised numerous calls to calculate_density and calculate_density_derivs to
use the new form with domain extents indicated by a hor_index_type argument.
Internal density variables were also rescaled in a few cases.  All answers are
bitwise identical.
  Rescaled the units of tv%P_Ref to [R L2 T-2] for expanded dimensional
consistency testing.  In some cases, other pressure variables were also
rescaled and calls to calculate_density are recast into the simpler G%HI forms.
All answers are bitwise identical, but the scaled units of an element of a
transparent type were rescaled.
  Rescaled the reference pressure arguments to 3 set_coord routines, 5
initialization routines, and kappa_shear_column.  Also removed the unused pres
argument to convert_temp_salt_for_TEOS10 and replaced its ocean_grid_type
argument with a hor_index_type.  All answers are bitwise identical.
  Replaced the remaining pres_scale arguments the various calculate_density
and calc_spec_vol routines in MOM_EOS.F90 with new optional unit_scale_type
arguments.  When the scale and US arguments are present, density is scaled
by the product of the indicated scaling factors.  Calls to these routines
in 11 files were modified accordingly.  All answers are bitwise identical.
  Corrected pressure unit documentation in comments in 5 files.  Also fixed
punctuation in comments in MOM_EOS.F90.  All answers are bitwise identical.
  Rescaled internal pressure, specific volume and energy variables in
MOM_diapyc_energy_req.F90.  This file is mostly used for testing, and all
answers are bitwise identical.
  Rescaled pressures in 17 calculate_density or related calls and internal
pressure variables in MOM_diabatic_aux.  All answers are bitwise identical.
  Corrected a rescaling bug in calculate_spec_vol_derivs_H1_1d, but as this code
was not yet being exercised, there are no answer changes.  Also modified
applyBoundaryFluxesInOut to use this fixed routine.  All answers are bitwise
identical.
  Redirected complicated equation of state routines to all work via the same 1-d
array versions of the code.  This shortens the MOM_EOS.F90 code even as new
routines are added under the same overloaded interfaces.  All answers are
bitwise identical.
  Rescaled the units of the pressure, density, and gravitational acceleration
arguments to find_depth_of_pressure_in_cell, frac_dp_at_pos, trim_for_ice and
cut_off_column_top for dimensional consistency testing and code simplification.
One change corrected an omitted scaling factor when the optional z_tol argument
is omitted, but this does not impact any solutions as this argument is present
in all active cases.  Also cleaned up some bizarre error messages starting with
'Blurgh!', which is apparently an artificial expletive invented to circumvent
censors, but has now been censored and replaced with a more informative message.
All answers are bitwise identical, but the units of some arguments have changed
and there are new unit_scale_type arguments to some routines.
  Made both arguments to unit_scaling_init optional to enable the use of this
routine to initialize unscaled unit_scale_types for certain types of unit
testing.  All answers are bitwise identical.
  Rescaled pressure and density variables in MOM_neutral_diffusion and added
numerous comments describing internal variables and their units.  Some unused
variables were deleted, including unused pressure arguments to
find_neutral_pos_linear.  In addition unit_scale_type arguments were added to 8
subroutines, including neutral_diffusion_init and tracer_hor_diff_init.  All
answers are bitwise identical, but there are changes to public interfaces.
  Use the US form of calculate_density calls in ISOMIP_initialization.  All
answers are bitwise identical.
  Nullified a pointer used in neutral diffusion unit tests.  Without this
correction of a problem introduced two commits ago, these unit tests would
sometimes fail, but all solutions are bitwise identical.
  Rescaled 3 diagnosed densities and the pressures used to calculate them.  All
answers are bitwise identical.
@adcroft
Copy link
Collaborator

adcroft commented Apr 16, 2020

It appears you did not enable the option that "allows maintainers to make edits" so you alone can make the changes.

Hallberg-NOAA and others added 18 commits April 17, 2020 11:05
  Removed the interfaces using G%HI to calculate_density and related routines
and added a new variant with a new optional argument 'dom' specifying a two-
element integer array with the start and end values of the domain to compute
on for 1-d arrays starting at 1.  If this array is not present in this new
variant, calculations are done over the entire output array extent.  All calls
to the interfaces from before the rescale_pressure pull request will still work.
Also added the new function EOS_domain that sets this two-element domain array
from a horiz_index_type.  This new interface is used throughout the code where
the old, removed form was in use.  All answers are bitwise identical.
- As part of the process of disconnected EOS from the unit_scaling_type
  this adds the necessary unit conversions to the EOS_type.
- Initialization is currently donne by passing US to MOM_init() but
  ultimately it seems passing p_scaling, etc., to MOM_init() would
  remove all dependency on US.
- No APIs other than EOS_init() have been changed yet.
  Use the new variant of calculate_density with the 'dom' argument or no array
extent argument in calls in 15 files.  All answers are bitwise identical.
- Removes US as an argument wherever it was optional since the
  unit conversion factors are not stored in the EOS type.
  Applied dimensional rescaling to many of the internal calculations in the 4
MOM_CVMix files, although calls to external CVMix routines still use the
original MKS units.  These changes include rescaling of the input and output
variables associated with the calculate_density routines.  All answers are
bitwise identical.
  Rescaled internal density and pressure variables in coord_adapt, as well as
some input parameters.  These changes include rescaling of the input and output
variables associated with the calculate_density routines.  One variable that was
being reused with different units has been split into two, and there are new
arguments to build_grid_adaptive, build_adapt_column, and init_coord_adapt.  All
answers in the MOM6-examples test suite are bitwise identical.
  Changed to the new interfaces for calculate_density and related calls in 22
places.  All answers are bitwise identical.
… Adcroft_rescale_pressure

  Merge branch 'rescale_pressure' of git://github.com/adcroft/MOM6.  This merge
compiles, but it fails the dimensional consistency testing and will be fixed
shortly.
  Corrected problems with dimensional consistency testing in MOM_EOS.F90 that
had been introduced with a recent merge.  All answers are bitwise identical and
are once again passing dimesional consistency testing.
  Eliminated the US argument to find_depth_of_pressure_in_cell, which was no
longer being used.  Also stored EOS_domain values in MOM_state_initialization
for reduced overhead.  All answers are bitwise identical.
  Store the return values from EOS_domain for computational efficiency.  Also
cleaned up unneeded 'dom=' declarations in compute_density calls.  All answers
are bitwise identical.
  Corrected a diagnostic halo extent in a recently added EOS_domain call and
added new variables to two openMP directives. All answers are bitwise identical.
  Eliminated the use GV%mks_g_Earth throughout the MOM6 code.  This variable is
being retained and is still set to avoid breaking any user code that might be
using it.  All answers are bitwise identical.
@Hallberg-NOAA
Copy link
Collaborator Author

The 22 recent commits added to this PR address all of the concerns raised in reviews of the earlier version of his PR. The additional commits that were added to this PR to address these issues include:

This revised PR is being tested with https://gitlab.gfdl.noaa.gov/ogrp/MOM6/pipelines/10226.

  Corrected compile time errors, related to an incomplete implementation of the
pressure rescaling in mom_surface_forcing_mct.F90.  With this fix, the changes
relative to dev/gfdl are now similar between mom_surface_forcing_mct.F90 and
the equivalent files for the other couplers.  All answers in the MOM6-examples
test cases are bitwise identical.
Copy link
Collaborator

@adcroft adcroft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically ready to go except @Hallberg-NOAA nad I just discussed a small cleanup in neutral diffusion. Needs to be handed manually due to parameter doc changes.

src/ALE/coord_rho.F90 Show resolved Hide resolved
  Removed unused US arguments to routines in MOM_neutral_diffusion.F90.  All
answers are bitwise identical, but some internal interfaces have one fewer
argument, and have been returned to their form in the dev/gfdl version.
Copy link
Collaborator

@adcroft adcroft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marshallward Can you take this from here? MOM6-examples will have new doc files (.debugging) so needs a manual merge.

@marshallward
Copy link
Collaborator

marshallward commented Apr 21, 2020

Updated Gaea regression test: https://gitlab.gfdl.noaa.gov/ogrp/MOM6/pipelines/10234

Passed with no regressions (up to parameter docs), I will merge this now.

@marshallward marshallward merged commit c745c5b into mom-ocean:dev/gfdl Apr 21, 2020
@Hallberg-NOAA Hallberg-NOAA deleted the rescale_pressure branch July 30, 2021 18:49
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.

4 participants