Skip to content

Commit

Permalink
Merge branch 'master' into addFluid+implDiv2DFlow
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-c committed Nov 30, 2024
2 parents 48bb0e0 + 7bb5a8a commit e7cba02
Show file tree
Hide file tree
Showing 97 changed files with 3,896 additions and 2,289 deletions.
8 changes: 0 additions & 8 deletions doc/getting_started/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1495,14 +1495,6 @@ somewhat obscure, so newer users of the MITgcm are encouraged to jump to
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`SOLVE_DIAGONAL_KINNER` | #undef | choice for implicit solver routines solve_*diagonal.F suitable for AD |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`COSINEMETH_III` | #define | selects implementation form of :math:`\cos{\varphi}` scaling of bi-harmonic term for viscosity |
| | | (note, CPP option for tracer diffusivity set independently in |
| | | :filelink:`GAD_OPTIONS.h <pkg/generic_advdiff/GAD_OPTIONS.h>`) |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`ISOTROPIC_COS_SCALING` | #undef | selects isotropic scaling of harmonic and bi-harmonic viscous terms when using the :math:`\cos{\varphi}` scaling |
| | | (note, CPP option for tracer diffusivity set independently in |
| | | :filelink:`GAD_OPTIONS.h <pkg/generic_advdiff/GAD_OPTIONS.h>`) |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+

.. _default_pkg_list:

Expand Down
17 changes: 3 additions & 14 deletions doc/phys_pkgs/generic_advdiff.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Generic Advection/Diffusion
---------------------------


The generic_advdiff package contains high-level subroutines to solve
the advection-diffusion equation of any tracer, either active (potential
temperature, salinity or water vapor) or passive (see :ref:`pkg/ptracer <sub_phys_pkg_ptracers>`).
Expand Down Expand Up @@ -38,20 +37,14 @@ There are two high-level routines:
non-linear schemes and can not be used in conjuction with
Adams–Bashforth time stepping.


.. tabularcolumns:: |\Y{.4}|L|L|


+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| CPP Flag Name | Default | Description |
+===============================================+=========+======================================================================================================================+
| :varlink:`COSINEMETH_III` | #define | sets the implementation form of :math:`\cos{\varphi}` scaling of bi-harmonic terms for tracer diffusivity |
| | | (note, in :filelink:`pkg/generic_advdiff` routines the definition set here overrides whether this is defined in |
| | | :filelink:`model/inc/CPP_OPTIONS.h`, where the setting affects viscous term calculations) |
| :varlink:`COSINEMETH_III` | #define | sets the form of :math:`\cos{\varphi}` scaling of horizontal bi-harmonic terms for tracer diffusivity |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`ISOTROPIC_COS_SCALING` | #undef | selects isotropic scaling of harmonic and bi-harmonic terms when using the :math:`\cos{\varphi}` scaling |
| | | (note, in :filelink:`pkg/generic_advdiff` routines the definition set here overrides whether this is defined in |
| | | :filelink:`model/inc/CPP_OPTIONS.h`, where the setting affects viscous term calculations) |
| :varlink:`ISOTROPIC_COS_SCALING` | #undef | selects isotropic scaling of horizontal harmonic and bi-harmonic terms when using the :math:`\cos{\varphi}` scaling |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`DISABLE_MULTIDIM_ADVECTION` | #undef | disables compilation of multi-dim. advection code |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
Expand All @@ -65,18 +58,15 @@ There are two high-level routines:
| | | (for ptracers, except temp and salinity) |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+



.. _gad_diagnostics:

GAD Diagnostics
+++++++++++++++

::


------------------------------------------------------------------------
<-Name->|Levs|<-parsing code->|<-- Units -->|<- Tile (max=80c)
<-Name->|Levs|<-parsing code->|<-- Units -->|<- Tile (max=80c)
------------------------------------------------------------------------
ADVr_TH | 15 |WM LR |degC.m^3/s |Vertical Advective Flux of Pot.Temperature
ADVx_TH | 15 |UU 087MR |degC.m^3/s |Zonal Advective Flux of Pot.Temperature
Expand All @@ -102,4 +92,3 @@ Experiments and tutorials that use GAD
- Tracer Sensitivity tutorial, in :filelink:`tutorial\_tracer\_adjsens <verification/tutorial_tracer_adjsens>`
verification directory.


4 changes: 4 additions & 0 deletions doc/phys_pkgs/mom_packages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Momentum Packages
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| CPP Flag Name | Default | Description |
+===============================================+=========+======================================================================================================================+
| :varlink:`COSINEMETH_III` | #define | sets the form of :math:`\cos{\varphi}` scaling of horizontal bi-harmonic terms for viscosity |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`ISOTROPIC_COS_SCALING` | #undef | selects isotropic scaling of horiz. harmonic and bi-harmonic viscosity when using the :math:`\cos{\varphi}` scaling |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`ALLOW_SMAG_3D` | #undef | allow isotropic 3D Smagorinsky viscosity (:filelink:`MOM_COMMON_OPTIONS.h <pkg/mom_common/MOM_COMMON_OPTIONS.h>`) |
+-----------------------------------------------+---------+----------------------------------------------------------------------------------------------------------------------+
| :varlink:`ALLOW_3D_VISCAH` | #undef | allow full 3D specification of horizontal Laplacian viscosity |
Expand Down
8 changes: 8 additions & 0 deletions doc/tag-index
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Notes on tags used in MITgcmUV
==============================

o pkg/mom_common,fluxform,vecinv:
- remove ISOTROPIC_COS_SCALING code from pkg/mom_vecinv/mom_vi_hdissip.F (was
not right); add warning (or stop if side-drag) if used with pkg/mom_vecinv.
- move 2 Cos-Scaling CPP options from CPP_OPTIONS.h to MOM_COMMON_OPTIONS.h
to be used in horizontal viscosity formulation; more consistent use of
GAD_OPTIONS.h where these 2 CPP options are used for horizontal diffusion.
- update all verification exp. customized version of CPP_OPTIONS.h,
GAD_OPTIONS.h and MOM_COMMON_OPTIONS.h.
o verification/atm_gray:
- gray atmosphere test exp moved from "verification_other".
o model/src:
Expand Down
38 changes: 5 additions & 33 deletions model/inc/CPP_OPTIONS.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ C CPP flags controlling particular source code features

C-- Forcing code options:

C o Shortwave heating as extra term in external_forcing.F
C Note: this should be a run-time option
C o Shortwave heating as extra term in APPLY_FORCING_T (apply_forcing.F)
#undef SHORTWAVE_HEATING

C o Include/exclude Geothermal Heat Flux at the bottom of the ocean
Expand Down Expand Up @@ -141,28 +140,9 @@ C Implementation alternative (might be faster on some platforms ?)

C-- Retired code options:

C o ALLOW isotropic scaling of harmonic and bi-harmonic terms when
C using an locally isotropic spherical grid with (dlambda) x (dphi*cos(phi))
C *only for use on a lat-lon grid*
C Setting this flag here affects both momentum and tracer equation unless
C it is set/unset again in other header fields (e.g., GAD_OPTIONS.h).
C The definition of the flag is commented to avoid interference with
C such other header files.
C The preferred method is specifying a value for viscAhGrid or viscA4Grid
C in data which is then automatically scaled by the grid size;
C the old method of specifying viscAh/viscA4 and this flag is provided
C for completeness only (and for use with the adjoint).
c#define ISOTROPIC_COS_SCALING

C o This flag selects the form of COSINE(lat) scaling of bi-harmonic term.
C *only for use on a lat-lon grid*
C Has no effect if ISOTROPIC_COS_SCALING is undefined.
C Has no effect on vector invariant momentum equations.
C Setting this flag here affects both momentum and tracer equation unless
C it is set/unset again in other header fields (e.g., GAD_OPTIONS.h).
C The definition of the flag is commented to avoid interference with
C such other header files.
c#define COSINEMETH_III
C- These 2 flags: ISOTROPIC_COS_SCALING & COSINEMETH_III have no effect
C here as they are reset in GAD_OPTIONS.h and in MOM_COMMON_OPTIONS.h
C for tracer diffusivity and momentum viscosity respectively

C o Use "OLD" UV discretisation near boundaries (*not* recommended)
C Note - only works with pkg/mom_fluxform and "no_slip_sides=.FALSE."
Expand All @@ -182,14 +162,6 @@ C-- Other option files:
C o Execution environment support options
#include "CPP_EEOPTIONS.h"

C o Include/exclude single header file containing multiple packages options
C (AUTODIFF, COST, CTRL, ECCO, EXF ...) instead of the standard way where
C each of the above pkg get its own options from its specific option file.
C Although this method, inherited from ECCO setup, has been traditionally
C used for all adjoint built, work is in progress to allow to use the
C standard method also for adjoint built.
c#ifdef PACKAGES_CONFIG_H
c# include "ECCO_CPPOPTIONS.h"
c#endif
C- Place where multi-pkg header file ECCO_CPPOPTIONS.h used to be included

#endif /* CPP_OPTIONS_H */
34 changes: 34 additions & 0 deletions model/src/config_check.F
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ SUBROUTINE CONFIG_CHECK( myThid )
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#ifdef ALLOW_MOM_COMMON
# include "MOM_VISC.h"
#endif

C !INPUT/OUTPUT PARAMETERS:
C === Routine arguments ===
Expand Down Expand Up @@ -961,6 +964,37 @@ SUBROUTINE CONFIG_CHECK( myThid )
errCount = errCount + 1
ENDIF
ENDIF
#ifdef ALLOW_MOM_COMMON
IF ( vectorInvariantMomentum .AND. momViscosity .AND.
& usingSphericalPolarGrid .AND. cosPower.NE.zeroRL ) THEN
#ifdef ISOTROPIC_COS_SCALING
IF ( no_slip_sides ) THEN
WRITE(msgBuf,'(2A)') 'CONFIG_CHECK: inconsistent ',
& 'no_slip_sides & ISOTROPIC_COS_SCALING in mom_vecinv'
CALL PRINT_ERROR( msgBuf, myThid )
errCount = errCount + 1
ELSE
WRITE(msgBuf,'(2A)') '** WARNING ** CONFIG_CHECK: ',
& 'ISOTROPIC_COS_SCALING not implemented in mom_vecinv'
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
& SQUEEZE_RIGHT, myThid )
ENDIF
#endif /* ISOTROPIC_COS_SCALING */
#ifdef COSINEMETH_III
IF ( useBiharmonicVisc .AND. no_slip_sides ) THEN
WRITE(msgBuf,'(2A)') 'CONFIG_CHECK: inconsistent ',
& 'no_slip_sides & COSINEMETH_III in mom_vecinv'
CALL PRINT_ERROR( msgBuf, myThid )
errCount = errCount + 1
ELSEIF ( useBiharmonicVisc ) THEN
WRITE(msgBuf,'(2A)') '** WARNING ** CONFIG_CHECK: ',
& 'COSINEMETH_III not implemented in mom_vecinv'
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
& SQUEEZE_RIGHT, myThid )
ENDIF
#endif /* COSINEMETH_III */
ENDIF
#endif /* ALLOW_MOM_COMMON */
IF ( .NOT.vectorInvariantMomentum .AND. momAdvection ) THEN
IF ( usingCurvilinearGrid ) THEN
WRITE(msgBuf,'(2A)') '** WARNING ** CONFIG_CHECK: ',
Expand Down
18 changes: 8 additions & 10 deletions pkg/generic_advdiff/GAD_OPTIONS.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ C Use this file for selecting options within the GAD package
#ifdef ALLOW_GENERIC_ADVDIFF
C Package-specific Options & Macros go here

C This flag selects the form of COSINE(lat) scaling of bi-harmonic term.
C *only for use on a lat-lon grid*
C Setting this flag here only affects the bi-harmonic tracer terms; to
C use COSINEMETH_III in the momentum equations set it CPP_OPTIONS.h
C This flag selects the form of COSINE(lat) scaling of horizontal
C bi-harmonic diffusivity -- only on lat-lon grid.
C Setting this flag here only affects tracer diffusivity; to use it
C in the momentum equations it needs to be set in MOM_COMMON_OPTIONS.h
#define COSINEMETH_III

C This selects isotropic scaling of harmonic and bi-harmonic term when
C using the COSINE(lat) scaling.
C Setting this flag here only affects the tracer diffusion terms; to
C use ISOTROPIC_COS_SCALING of the horizontal viscosity terms in the
C momentum equations set it CPP_OPTIONS.h; the following line
C even overrides setting the flag in CPP_OPTIONS.h
C This selects isotropic scaling of horizontal harmonic and bi-harmonic
C diffusivity when using the COSINE(lat) scaling -- only on lat-lon grid.
C Setting this flag here only affects tracer diffusivity; to use it
C in the momentum equations it needs to be set in MOM_COMMON_OPTIONS.h
#undef ISOTROPIC_COS_SCALING

C As of checkpoint41, the inclusion of multi-dimensional advection
Expand Down
3 changes: 3 additions & 0 deletions pkg/ggl90/ggl90_calc.F
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "GGL90_OPTIONS.h"
#ifdef ALLOW_GENERIC_ADVDIFF
# include "GAD_OPTIONS.h"
#endif
#ifdef ALLOW_AUTODIFF
# include "AUTODIFF_OPTIONS.h"
#endif
Expand Down
3 changes: 3 additions & 0 deletions pkg/gmredi/gmredi_calc_geom.F
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "GMREDI_OPTIONS.h"
#ifdef ALLOW_GENERIC_ADVDIFF
# include "GAD_OPTIONS.h"
#endif

CBOP
C !ROUTINE: GMREDI_CALC_GEOM
Expand Down
12 changes: 12 additions & 0 deletions pkg/mom_common/MOM_COMMON_OPTIONS.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ C Use this file for selecting CPP options within the mom_common package
#ifdef ALLOW_MOM_COMMON
C Package-specific options go here

C This flag selects the form of COSINE(lat) scaling of horizontal
C bi-harmonic viscosity -- only on lat-lon grid.
C Setting this flag here only affects momentum viscosity; to use it
C in the tracer equations it needs to be set in GAD_OPTIONS.h
#define COSINEMETH_III

C This selects isotropic scaling of horizontal harmonic and bi-harmonic
C viscosity when using the COSINE(lat) scaling -- only on lat-lon grid.
C Setting this flag here only affects momentum viscosity; to use it
C in the tracer equations it needs to be set in GAD_OPTIONS.h
#undef ISOTROPIC_COS_SCALING

C allow LeithQG coefficient to be calculated
#undef ALLOW_LEITH_QG

Expand Down
9 changes: 6 additions & 3 deletions pkg/mom_fluxform/mom_u_del2u.F
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "MOM_FLUXFORM_OPTIONS.h"
#ifdef ALLOW_MOM_COMMON
# include "MOM_COMMON_OPTIONS.h"
#endif

CBOP
C !ROUTINE: MOM_U_DEL2U
Expand Down Expand Up @@ -40,7 +43,7 @@ SUBROUTINE MOM_U_DEL2U(

C !LOCAL VARIABLES: ====================================================
C i,j :: loop indices
INTEGER I,J
INTEGER i,j
_RL fZon(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RL fMer(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
_RS hFacZClosedS, hFacZClosedN
Expand All @@ -54,7 +57,7 @@ SUBROUTINE MOM_U_DEL2U(
& *_recip_dxF(i,j,bi,bj)
& *(uFld(i+1,j)-uFld(i,j))
#ifdef COSINEMETH_III
& *sqCosFacU(J,bi,bj)
& *sqCosFacU(j,bi,bj)
#endif
#ifdef ALLOW_OBCS
& *maskInC(i,j,bi,bj)
Expand All @@ -72,7 +75,7 @@ SUBROUTINE MOM_U_DEL2U(
& *_recip_dyU(i,j,bi,bj)
& *(uFld(i,j)-uFld(i,j-1))
#if (defined (ISOTROPIC_COS_SCALING) && defined (COSINEMETH_III))
& *sqCosFacV(J,bi,bj)
& *sqCosFacV(j,bi,bj)
#endif
c & *deepFacC(k) ! dxV scaling factor
c & *recip_deepFacC(k) ! recip_dyU scaling factor
Expand Down
15 changes: 9 additions & 6 deletions pkg/mom_fluxform/mom_u_xviscflux.F
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "MOM_FLUXFORM_OPTIONS.h"
#ifdef ALLOW_MOM_COMMON
# include "MOM_COMMON_OPTIONS.h"
#endif

CBOP
C !ROUTINE: MOM_U_XVISCFLUX
Expand Down Expand Up @@ -44,22 +47,22 @@ SUBROUTINE MOM_U_XVISCFLUX(

C !LOCAL VARIABLES: ====================================================
C i,j :: loop indices
INTEGER I,J
INTEGER i,j
CEOP

C - Laplacian and bi-harmonic terms
DO j=1-Oly,sNy+Oly-1
DO i=1-Olx,sNx+Olx-1
DO j=1-OLy,sNy+OLy-1
DO i=1-OLx,sNx+OLx-1
xViscFluxU(i,j) =
& _dyF(i,j,bi,bj)*drF(k)*_hFacC(i,j,k,bi,bj)
& *(
& -viscAh_D(i,j)*( uFld(i+1,j)-uFld(i,j) )
& *cosFacU(J,bi,bj)
& *cosFacU(j,bi,bj)
& +viscA4_D(i,j)*(del2u(i+1,j)-del2u(i,j))
#ifdef COSINEMETH_III
& *sqCosFacU(J,bi,bj)
& *sqCosFacU(j,bi,bj)
#else
& *cosFacU(J,bi,bj)
& *cosFacU(j,bi,bj)
#endif
& )*_recip_dxF(i,j,bi,bj)
c & *deepFacC(k) ! dyF scaling factor
Expand Down
15 changes: 9 additions & 6 deletions pkg/mom_fluxform/mom_u_yviscflux.F
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "MOM_FLUXFORM_OPTIONS.h"
#ifdef ALLOW_MOM_COMMON
# include "MOM_COMMON_OPTIONS.h"
#endif

CBOP
C !ROUTINE: MOM_U_YVISCFLUX
Expand Down Expand Up @@ -45,25 +48,25 @@ SUBROUTINE MOM_U_YVISCFLUX(

C !LOCAL VARIABLES: ====================================================
C i,j :: loop indices
INTEGER I,J
INTEGER i,j
CEOP

C - Laplacian and bi-harmonic terms
DO j=1-Oly+1,sNy+Oly
DO i=1-Olx,sNx+Olx
DO j=1-OLy+1,sNy+OLy
DO i=1-OLx,sNx+OLx
yViscFluxU(i,j) =
& _dxV(i,j,bi,bj)*drF(k)*hFacZ(i,j)
& *(
& -viscAh_Z(i,j)*( uFld(i,j)-uFld(i,j-1) )
#ifdef ISOTROPIC_COS_SCALING
& *cosFacV(J,bi,bj)
& *cosFacV(j,bi,bj)
#endif
& +viscA4_Z(i,j)*(del2u(i,j)-del2u(i,j-1))
#ifdef ISOTROPIC_COS_SCALING
#ifdef COSINEMETH_III
& *sqCosFacV(J,bi,bj)
& *sqCosFacV(j,bi,bj)
#else
& *cosFacV(J,bi,bj)
& *cosFacV(j,bi,bj)
#endif
#endif
& )*_recip_dyU(i,j,bi,bj)
Expand Down
Loading

0 comments on commit e7cba02

Please sign in to comment.