Skip to content

Option to add effects of Lam2 into MLE restratification.#389

Merged
alperaltuntas merged 24 commits intoNCAR:dev/ncarfrom
gustavo-marques:lam2_mle
Sep 29, 2025
Merged

Option to add effects of Lam2 into MLE restratification.#389
alperaltuntas merged 24 commits intoNCAR:dev/ncarfrom
gustavo-marques:lam2_mle

Conversation

@gustavo-marques
Copy link
Collaborator

@gustavo-marques gustavo-marques commented Sep 12, 2025

This PR should be evaluated after merging #379

  • Introduced Lam2 as an optional pointer field in vertvisc_type and restart registry.

  • Extended mixedlayer_restrat and mixedlayer_restrat_Bodner to accept/use Lam2 when
    available, with fallback to equilibrium value.

  • Added KPP_get_Lam2 routine to expose Lam2 from KPP control structure.

  • Connected Lam2 into diabatic_ALE_legacy and diabatic_ALE and copied into
    visc%Lam2 when allocated.

  • Enabled allocation and restart registration of Lam2 when STOKES_MOST
    and Bodner MLE are used.

  • Updated MOM.F90 call sites to conditionally pass Lam2.

This commit introduces an alternative method for computing the boundary layer depth
(BLD) in KPP, based on the entrainment rule. This method is activated when the
non-solar surface buoyancy flux (surfBuoy_NS) is negative and STOKES_MOST = True.
In all other cases, the standard Richardson Number-based method is used.

The non-solar surface buoyancy flux is estimated internally using an exponential
attenuation function, since only the total surface buoyancy flux (solar + non-solar)
is currently available to the module. Ideally, the non-solar component should be
provided explicitly.

Several new diagnostics have been added, and some of the existing ones have been
updated. Specifically, the parameterized shear, buoyancy, and Stokes TKE production
terms are calculated. We conducted multiple tests where these terms are passed to
the MLE module and used in the denominator of the Bodner streamfunction.
However, because of the small Cr value we adopted (0.01), this had minimal effect
on the solutions, so we decided to keep the original simpler implementation
and not pursue this option for now.

This commit should be evaluated together with CVMix/CVMix-src#106.
Include new entreinment rule depth changes.
- Removed unused `ustar` array from KPP_CS type.
- Restricted registration, allocation, and posting of StokesMOST
  diagnostics (`StokesXI`, `Lam2`, `BEdE_ER`, `ERdepth`, `RNdepth`,
  `PU_TKE`, `PS_TKE`, `PB_TKE`) to cases when `CS%StokesMOST` is enabled.
- Moved allocations of related arrays inside StokesMOST conditional block.
- Updated condition for calculating `surfBuoy_NS` to avoid division
  by zero in alog(buoyFlux(i,j,2)/buoyFlux(i,j,3)).
- Wrapped diagnostic and debug checks in `if (CS%StokesMOST)` conditions.
- Minor cleanup of comments and diagnostic labeling.
- Introduced `Lam2` as an optional pointer field in `vertvisc_type` and restart registry.

- Extended `mixedlayer_restrat` and `mixedlayer_restrat_Bodner` to accept/use `Lam2` when
  available, with fallback to equilibrium value.

- Added `KPP_get_Lam2` routine to expose Lam2 from KPP control structure.

- Connected `Lam2` into `diabatic_ALE_legacy` and `diabatic_ALE` and copied into
  `visc%Lam2` when allocated.

- Enabled allocation and restart registration of `Lam2` when STOKES_MOST
  and Bodner MLE are used.

- Updated MOM.F90 call sites to conditionally pass `Lam2`.

This integrates Langmuir turbulence effects via Lam2 into MLE restratification.
@gustavo-marques gustavo-marques changed the title Add option to integrate Langmuir turbulence effects via Lam2 into MLE restratification. Option to add effects of Lam2 into MLE restratification. Sep 12, 2025
Wrapped the mixedlayer_restrat call with an outer check on
`associated(CS%visc)` to ensure the derived type is valid before
testing `CS%visc%Lam2`. This prevents invalid memory references
when `CS%visc` is unassociated.
Read `StokesMOST` and `wave_enhanced_ustar` to determine whether
Lam2 should be passed to the `mixedlayer_restrat` subroutine.
Added local logical flag `haveLam2` to ensure Lam2 is only used
when both present and associated. This avoids potential segfaults
from evaluating `associated(Lam2)` when Lam2 is not passed.
@gustavo-marques
Copy link
Collaborator Author

As expected, this PR changes answers compared to alpha07c, but all other tests in pr_mom are passing. @alperaltuntas will compare it against the latest dev/ncar to verify if the answers are preserved, which is expected.

/glade/derecho/scratch/gmarques/cesm.tests/pr_mom/cesm3_0_alpha07c_cesm3--lam2_mle.intel

  DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods (Overall: DIFF) details:
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods CREATE_NEWCASE
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods XML
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods SETUP
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods SHAREDLIB_BUILD time=76
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods NLCOMP
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods MODEL_BUILD time=351
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods SUBMIT
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods RUN time=4365
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods COMPARE_dimscale_1_Tp_base
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods COMPARE_dimscale_2_Lp_base
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods COMPARE_dimscale_3_Hp_base
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods COMPARE_dimscale_4_Zp_base
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods COMPARE_dimscale_5_Rp_base
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods COMPARE_dimscale_6_Qp_base
    FAIL DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods BASELINE alpha07c_dev_ncar--dev_ncar: DIFF
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods TPUTCOMP
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods MEMLEAK insufficient data for memleak test
    PASS DIMCSL_Ld1.TL319_t232.G_JRA.derecho_intel.mom-cfc_mods SHORT_TERM_ARCHIVER
  ERI.TL319_t232.G_JRA.derecho_intel.mom-debug (Overall: DIFF) details:
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug CREATE_NEWCASE
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug XML
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug SETUP
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug SHAREDLIB_BUILD time=12
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug NLCOMP
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug MODEL_BUILD time=322
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug SUBMIT
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug RUN time=2681
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug COMPARE_base_hybrid
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug COMPARE_base_rest
    FAIL ERI.TL319_t232.G_JRA.derecho_intel.mom-debug BASELINE alpha07c_dev_ncar--dev_ncar: DIFF
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug TPUTCOMP
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug MEMLEAK insufficient data for memleak test
    PASS ERI.TL319_t232.G_JRA.derecho_intel.mom-debug SHORT_TERM_ARCHIVER
  ERS.TL319_t232_wg37.GW_JRA.derecho_intel (Overall: DIFF) details:
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel CREATE_NEWCASE
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel XML
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel SETUP
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel SHAREDLIB_BUILD time=316
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel NLCOMP
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel MODEL_BUILD time=329
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel SUBMIT
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel RUN time=987
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel COMPARE_base_rest
    FAIL ERS.TL319_t232_wg37.GW_JRA.derecho_intel BASELINE alpha07c_dev_ncar--dev_ncar: DIFF
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel MEMCOMP
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel TPUTCOMP
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel MEMLEAK
    PASS ERS.TL319_t232_wg37.GW_JRA.derecho_intel SHORT_TERM_ARCHIVER
  SMS_D.TL319_t232.G_JRA_RYF.derecho_intel (Overall: DIFF) details:
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel CREATE_NEWCASE
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel XML
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel SETUP
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel SHAREDLIB_BUILD time=154
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel NLCOMP
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel MODEL_BUILD time=116
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel SUBMIT
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel RUN time=1039
    FAIL SMS_D.TL319_t232.G_JRA_RYF.derecho_intel BASELINE alpha07c_dev_ncar--dev_ncar: DIFF
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel MEMCOMP
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel TPUTCOMP
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel MEMLEAK
    PASS SMS_D.TL319_t232.G_JRA_RYF.derecho_intel SHORT_TERM_ARCHIVER
  SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel (Overall: DIFF) details:
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel CREATE_NEWCASE
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel XML
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel SETUP
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel SHAREDLIB_BUILD time=167
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel NLCOMP
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel MODEL_BUILD time=336
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel SUBMIT
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel RUN time=414
    FAIL SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel BASELINE alpha07c_dev_ncar--dev_ncar: DIFF
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel TPUTCOMP
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel MEMLEAK insufficient data for memleak test
    PASS SMS_Ld2.ne30pg3_t232.B1850C_LTso.derecho_intel SHORT_TERM_ARCHIVER

@gustavo-marques gustavo-marques marked this pull request as ready for review September 23, 2025 20:18
@alperaltuntas alperaltuntas merged commit cc24bff into NCAR:dev/ncar Sep 29, 2025
52 checks passed
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.

2 participants