Skip to content

Updates in the OMD GFS PBL and Convection models with 3D TTE-based EDMF Turbulent Mixing Scheme, Cold Pool Parameterization, and Mixed Scheme for Subgrid-Scale Convective Fluxes in Convective Clouds + #405 + #408 + #414 - #403

Open
ChristianBoyer-NOAA wants to merge 17 commits into
ufs-community:ufs/devfrom
ChristianBoyer-NOAA:CP-LEO-3D_TTE_EDMF-Merged

Conversation

@ChristianBoyer-NOAA

@ChristianBoyer-NOAA ChristianBoyer-NOAA commented Oct 22, 2026 •

Copy link
Copy Markdown

Description of Changes:

PR submitted on behalf of @JongilHan66

  1. The current GFS 1D scale-aware (SA) TTE-EDMF scheme is extended to the 3D-SA TTE-EDMF scheme by replacing 3D TKE with 3D TTE. The horizontal turbulent diffusion is modified: the horizontal mixing length is now scaled directly to the vertical mixing length, replacing the previous formulation based on horizontal grid size. In addition, horizontal turbulent eddy diffusion—previously restricted to momentum and TKE—now applies across all scalar prognostic variables, including temperature, moisture, hydrometeors, passive tracers, momentum, and TTE. To have scalar field conservation after horizontal diffusion, mass-weighted diffusion computation is applied for scalar fields (temperature, moisture, cloud condensate, tracers, etc.). Ideally, horizontal diffusion should be applied on the height surface. In this PR, however, it is applied in the terrain-following sigma surface and so can be somewhat erroneous especially over steep mountain. Horizontal diffusion for the scalar fields is set to be optional.

  2. Properly representing cold pools (CPs; dense, cold air masses formed by the downdrafts of precipitating cumulus clouds) within numerical weather prediction models has long been a challenge. By spreading horizontally, the cold pool's leading edge, known as the gust front, acts as a local lifting mechanism, forcing warm, moist air upward to generate secondary convective cells and organize larger systems. Neglecting the thermodynamic and momentum effects of these features, particularly their interaction with the boundary layer structure and the free atmosphere, can lead to significant systematic biases in the simulation of organized mesoscale convection and the diurnal cycle of precipitation. We integrate the CP parameterization developed by Freitas et al. (2024) into the NCEP Global Forecast System (GFS) with a modification. This implementation is coupled with the GFS deep convection and PBL schemes. The CP depth far behind the leading edge (D), used to compute gust front horizontal speed, was reduced from 2 km to 500 m. Concurrently, the density current head depth used for calculating vertical velocity at the CP leading edge was increased to approximately 2D. The modified scheme restricts the CP influence strictly to enhanced convection triggering. It removes convection intensity enhancement, eliminating additional source terms for buoyancy, moisture, and updraft velocity. This is an initial implementation intended for further development and evaluation, and that additional work (potentially through subsequent PRs) will be needed to demonstrate improvements in the forecast applications mentioned here, particularly for the MJO and hurricanes. The CP parameterization and the Cellular Automata (CA) scheme may interfere with one another in their current formulations as both attempt to promote secondary cell generation and larger system organization. Currently, one or the other (not both) are set to be activated. We plan to combine the two in the future.

  3. A mixed subgrid-scale turbulent flux scheme is introduced into the GFS based on Moeng et al. (2010), incorporating an auxiliary subgrid vertical flux known as the "Leonard term" (Leonard 1974; Moeng et al. 2010). The Leonard term accounts for subgrid-scale turbulent fluxes originating from near-grid-scale unresolved eddies—the largest subgrid eddies with scales comparable to the model's horizontal grid resolution. Applied primarily to mitigate subgrid flux underestimation, this formulation is most effective at kilometer-scale, convection-permitting, or cloud-resolving resolutions (Moeng et al. 2010; Verrelle et al. 2017; Hanley et al. 2019). In the current implementation, the Leonard term calculation is embedded directly within the convection schemes rather than the Planetary Boundary Layer (PBL) scheme.

  4. The changes from the PR#405, PR#408, and PR#414 submitted by Ash Pera are included into this PR. Also, totflg is removed from the SAMF convection schemes.

Tests Conducted:

Regression test suite was run on Ursa.

Dependencies:

Issue (optional):

Fixes issue: ufs-community/ufs-weather-model#3401
Fixes issue: #401

Contributors (optional):

@JongilHan66

@pera-noaa

Copy link
Copy Markdown

We checked conservation of the new horizontal diffusion in a C96 control_p8 run (24 h, sa3dtke and sa3dtke_dyco on), at this PR's head with NOAA-EMC/ufsatm#1154 and NOAA-GFDL/GFDL_atmos_cubed_sphere#429. The diff3d tendencies cancel exactly per unit area: the area-weighted global sum is about 1e-17 of the gross. But satmedmfvdifq adds them to temperature and mixing ratios, where only a mass-weighted sum cancels, and delp differs between neighbouring columns. So part of each tendency leaks:

mass-weighted net / gross net over 24 h
T −2.7 % −1.5e-3 W/m²
sphum −1.0 % −1.3e-5 kg/m²
o3mr +0.95 % +6.8e-9 of its mass
other tracers 0.05–0.9 %

The amounts are small, but a diffusion term should conserve exactly. Building the face fluxes from q·delp and dividing each cell's net flux by its own delp would make the sum telescope in mass. We can test that if useful.

@JongilHan66

Copy link
Copy Markdown
Collaborator

We checked conservation of the new horizontal diffusion in a C96 control_p8 run (24 h, sa3dtke and sa3dtke_dyco on), at this PR's head with NOAA-EMC/ufsatm#1154 and NOAA-GFDL/GFDL_atmos_cubed_sphere#429. The diff3d tendencies cancel exactly per unit area: the area-weighted global sum is about 1e-17 of the gross. But satmedmfvdifq adds them to temperature and mixing ratios, where only a mass-weighted sum cancels, and delp differs between neighbouring columns. So part of each tendency leaks:

mass-weighted net / gross net over 24 h
T −2.7 % −1.5e-3 W/m²
sphum −1.0 % −1.3e-5 kg/m²
o3mr +0.95 % +6.8e-9 of its mass
other tracers 0.05–0.9 %
The amounts are small, but a diffusion term should conserve exactly. Building the face fluxes from q·delp and dividing each cell's net flux by its own delp would make the sum telescope in mass. We can test that if useful.

@pera-noaa The original code for 3D TKE developed by Ping Zhu et al. (2025) applied horizontal turbulent diffusion only to momentum and TKE. In this PR, we extended the horizontal turbulent diffusion to temperature, moisture, and all the tracers. Ideally, horizontal diffusion should be applied on the same height (z) surface. But in this PR, it is applied in the terrain-following sigma surface and so would be somewhat erroneous especially over steep mountain. This could cause the conservation issue you've found. Currently, we don't know how to apply it on z-surface. If the conservation issue is serious, we had better remove the horizontal turbulent diffusion for the scalar variables. For the time being, we will modify it as an optional.

@lisa-bengtsson

Copy link
Copy Markdown
Collaborator

Thank you for this work! I have two concerns regarding the decision to automatically disable the CA scheme when the alternative cold-pool parameterization is activated.

Namelist configuration: I would prefer that we do not overwrite a user-specified namelist option within the Fortran code. If coldpool and do_ca are currently considered mutually exclusive, I suggest adding a check that aborts with an informative error message when both are enabled, asking the user to select one or the other. This would make the configuration requirements explicit rather than silently changing the user's settings.

Scientific justification: The CA scheme has previously demonstrated improvements in MJO prediction, whereas, from my understanding, the current cold-pool implementation has not yet demonstrated comparable improvements in overall forecast skill. It therefore seems somewhat counterintuitive to automatically disable CA in favor of a parameterization that is still under development. I recognize that the two schemes may interfere with one another in their current formulations, but I think we should be careful not to imply that the cold-pool parameterization is necessarily a replacement for CA cold pool representation. As we discussed, future work could combine the two.

Perhaps the PR description could more explicitly state that this is an initial implementation intended for further development and evaluation, and that additional work (potentially through subsequent PRs) will be needed to demonstrate improvements in the forecast applications mentioned here, particularly for the MJO and hurricanes.

I am supportive of introducing new capabilities for exploring convective organization, but I think it is important to distinguish between adding a research capability and establishing that it improves forecast performance.

@JongilHan66

Copy link
Copy Markdown
Collaborator

Thank you for this work! I have two concerns regarding the decision to automatically disable the CA scheme when the alternative cold-pool parameterization is activated.

Namelist configuration: I would prefer that we do not overwrite a user-specified namelist option within the Fortran code. If coldpool and do_ca are currently considered mutually exclusive, I suggest adding a check that aborts with an informative error message when both are enabled, asking the user to select one or the other. This would make the configuration requirements explicit rather than silently changing the user's settings.

Scientific justification: The CA scheme has previously demonstrated improvements in MJO prediction, whereas, from my understanding, the current cold-pool implementation has not yet demonstrated comparable improvements in overall forecast skill. It therefore seems somewhat counterintuitive to automatically disable CA in favor of a parameterization that is still under development. I recognize that the two schemes may interfere with one another in their current formulations, but I think we should be careful not to imply that the cold-pool parameterization is necessarily a replacement for CA cold pool representation. As we discussed, future work could combine the two.

Perhaps the PR description could more explicitly state that this is an initial implementation intended for further development and evaluation, and that additional work (potentially through subsequent PRs) will be needed to demonstrate improvements in the forecast applications mentioned here, particularly for the MJO and hurricanes.

I am supportive of introducing new capabilities for exploring convective organization, but I think it is important to distinguish between adding a research capability and establishing that it improves forecast performance.

@lisa-bengtsson Following your suggestion, we will modify the code and the PR description

@pera-noaa

Copy link
Copy Markdown

Thanks @JongilHan66. The leak isn't from using sigma surfaces, and diffusing on z surfaces would leak the same way. It comes from applying the fluxes to mixing ratios: neighbouring columns hold different air mass (delp), so equal and opposite changes in q don't move equal amounts of tracer. A flux-form diffusion conserves on any surface if its face fluxes are mass-weighted (q·delp, with each cell's net flux divided by its own delp); sigma versus z affects accuracy over steep terrain, not conservation. So it can be fixed on sigma surfaces. It's small, so making it optional is fine for us; if you keep it on, we can test the mass-weighted form.

@JongilHan66

Copy link
Copy Markdown
Collaborator

Thanks @JongilHan66. The leak isn't from using sigma surfaces, and diffusing on z surfaces would leak the same way. It comes from applying the fluxes to mixing ratios: neighbouring columns hold different air mass (delp), so equal and opposite changes in q don't move equal amounts of tracer. A flux-form diffusion conserves on any surface if its face fluxes are mass-weighted (q·delp, with each cell's net flux divided by its own delp); sigma versus z affects accuracy over steep terrain, not conservation. So it can be fixed on sigma surfaces. It's small, so making it optional is fine for us; if you keep it on, we can test the mass-weighted form.

@pera-noaa Currently, horizontal diffusion of q (d(K dq/dx)/dx, where K is eddy diffusivity) is computed as (1/dx(i)) [K(i+.5) (q(i+1)-q(i))/dx(i+.5) - K(i-.5) (q(i)-q(i-1))/dx(i-.5)]. Do you mean "mass-weighted" diffusion by d (K/dp d (q dp)/dx)/dx where dp is delp (layer pressure thickness)? Then it would be computed as (1/dx(i)) [K/dp(i+.5) (q(i+1) dp(i+1)-q(i) dp(i))/dx(i+.5) - K/dp(i-.5) (q(i) dp(i)-q(i-1) dp(i-1))/dx(i-.5)].

@pera-noaa

Copy link
Copy Markdown

@JongilHan66 Not quite, my wording was unclear. Keep your form and change two things: multiply K at each face by dp there, and divide by dp(i):

current:  dq/dt(i) = 1/dx(i)         [K(i+.5)          (q(i+1)-q(i))/dx(i+.5) - K(i-.5)          (q(i)-q(i-1))/dx(i-.5)]
proposed: dq/dt(i) = 1/(dp(i) dx(i)) [K(i+.5) dp(i+.5) (q(i+1)-q(i))/dx(i+.5) - K(i-.5) dp(i-.5) (q(i)-q(i-1))/dx(i-.5)]

with dp(i+.5) = (dp(i)+dp(i+1))/2. Multiplying by dp(i) dx(i) and summing over i, each face term appears once with each sign, so Σ q dp dx is conserved exactly; a uniform q still gets zero. Diffusing q dp would give a uniform q a tendency where dp varies. The same applies to T.

@JongilHan66

Copy link
Copy Markdown
Collaborator

@JongilHan66 Not quite, my wording was unclear. Keep your form and change two things: multiply K at each face by dp there, and divide by dp(i):

current:  dq/dt(i) = 1/dx(i)         [K(i+.5)          (q(i+1)-q(i))/dx(i+.5) - K(i-.5)          (q(i)-q(i-1))/dx(i-.5)]
proposed: dq/dt(i) = 1/(dp(i) dx(i)) [K(i+.5) dp(i+.5) (q(i+1)-q(i))/dx(i+.5) - K(i-.5) dp(i-.5) (q(i)-q(i-1))/dx(i-.5)]

with dp(i+.5) = (dp(i)+dp(i+1))/2. Multiplying by dp(i) dx(i) and summing over i, each face term appears once with each sign, so Σ q dp dx is conserved exactly; a uniform q still gets zero. Diffusing q dp would give a uniform q a tendency where dp varies. The same applies to T.

@pera-noaa Yes, your proposal makes more sense and I've already modified them in your proposed way.

…h mass-weighting to conserve the scalar field after horizontal diffusion. Also, includes changes from ccpp PRs 405, 408 and 414
@JongilHan66

Copy link
Copy Markdown
Collaborator

@JongilHan66 Not quite, my wording was unclear. Keep your form and change two things: multiply K at each face by dp there, and divide by dp(i):

current:  dq/dt(i) = 1/dx(i)         [K(i+.5)          (q(i+1)-q(i))/dx(i+.5) - K(i-.5)          (q(i)-q(i-1))/dx(i-.5)]
proposed: dq/dt(i) = 1/(dp(i) dx(i)) [K(i+.5) dp(i+.5) (q(i+1)-q(i))/dx(i+.5) - K(i-.5) dp(i-.5) (q(i)-q(i-1))/dx(i-.5)]

with dp(i+.5) = (dp(i)+dp(i+1))/2. Multiplying by dp(i) dx(i) and summing over i, each face term appears once with each sign, so Σ q dp dx is conserved exactly; a uniform q still gets zero. Diffusing q dp would give a uniform q a tendency where dp varies. The same applies to T.

@pera-noaa Yes, your proposal makes more sense and I've already modified them in your proposed way.

@pera-noaa This PR(#403) has been updated along with mass-weighted horizontal eddy diffusion discretization for scalar fields. Could you check if the leak from conservation is significantly reduced when you have a chance?

& crtlame, crtlamd
!
! real(kind=kind_phys) detad
! real(kind=conv_wp) detad

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was curious why this, and other lines with real(kind_phys), weren't already changed to real(conv_wp) - but it looks like that is all commented code that is not used. Maybe it would be better to just clean out? @rhaesung ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agreed! If they're not being used, let's just clean them out. Thanks, @lisa-bengtsson!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was curious why this, and other lines with real(kind_phys), weren't already changed to real(conv_wp) - but it looks like that is all commented code that is not used. Maybe it would be better to just clean out? @rhaesung ?

@lisa-bengtsson While detad is not used, I'd like to keep them with commented out for future consideration.

& ' select one or the other'
errflg = 1
return
endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When trying to compile this code - I get an error here. It seems that the compiler doesn't like (*(a)) as the format in a .f file?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When trying to compile this code - I get an error here. It seems that the compiler doesn't like (*(a)) as the format in a .f file?

@lisa-bengtsson In the update, write(errmsg,'((a))') => print,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The earlier compile error was likely caused by exceeding column 72, not (*(a)) (which is already used earlier in this file).

To follow CCPP logging standards instead of print*, we can format it within 72 columns:

      if (coldpool .and. do_ca) then
        write(errmsg, '(*(a))')
     &    'Currently both are not allowed to be enabled;',
     &    ' select one or the other'
        errflg = 1
        return
      endif

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
dp = 1000.0_conv_wp * del(i,k+1)
dellaq(i,k+1) = dellaq(i,k+1) - edto(i)
& * etad(i,k) * tem1 * real(grav, kind=conv_wp)/dp
& * etad(i,k) * qo(i,k) * real(grav, kind=conv_wp)/dp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The compiler also fails here:
I think you need to split the expression across additional continuation lines to comply with the 72-column limit for fixed-form Fortran. The " /dp" extended beyond column 72 and is ignored by the compiler.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The compiler also fails here: I think you need to split the expression across additional continuation lines to comply with the 72-column limit for fixed-form Fortran. The " /dp" extended beyond column 72 and is ignored by the compiler.

@lisa-bengtsson Corrected that line not to extend beyond column 72

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
Comment on lines +555 to +556
ucp(i) = 0._conv_wp
vcp(i) = 0._conv_wp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ucp(i) = 0._conv_wp
vcp(i) = 0._conv_wp
ucp(i) = 0._kind_phys
vcp(i) = 0._kind_phys

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
if (tem > 0._conv_wp) then
ptem1 = ptem - ukdcp(i)
ptem1 = max(ptem1, 0._conv_wp)
ucp(i) = min(tem, ptem1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ucp(i) = min(tem, ptem1)
ucp(i) = real(min(tem, ptem1), kind=kind_phys)

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
else
ptem1 = -ptem - ukdcp(i)
ptem1 = min(ptem1, 0._conv_wp)
ucp(i) = max(tem, ptem1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ucp(i) = max(tem, ptem1)
ucp(i) = real(max(tem, ptem1), kind=kind_phys)

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
if (tem1 > 0._conv_wp) then
ptem1 = ptem - vkdcp(i)
ptem1 = max(ptem1, 0._conv_wp)
vcp(i) = min(tem1, ptem1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
vcp(i) = min(tem1, ptem1)
vcp(i) = real(min(tem1, ptem1), kind=kind_phys)

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
else
ptem1 = -ptem - vkdcp(i)
ptem1 = min(ptem1, 0._conv_wp)
vcp(i) = max(tem1, ptem1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
vcp(i) = max(tem1, ptem1)
vcp(i) = real(max(tem1, ptem1), kind=kind_phys)

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
!> - Calculate additional trigger condition of the convective inhibition (CIN) according to Han et al.'s (2017) \cite han_et_al_2017 equation 13.
do i = 1, im
if(cnvflg(i)) then
cina(i) = 0.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
cina(i) = 0.
cina(i) = 0._conv_wp

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
do i = 1, im
tem = real(buoyexcs(i,k), kind=conv_wp)
& + dellabu(i,k) * dt2
ptem = 1. + dt2 / taucp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
ptem = 1. + dt2 / taucp
ptem = 1._conv_wp + dt2 / taucp

Comment thread physics/CONV/SAMF/samfshalcnv.f Outdated
! & (k > kb(i) .and. k < ktcon(i))) then
! if(k > kb(i) .and. k < ktcon(i)) then
! if(k >= kbcon(i) .and. k < ktcon(i)) then
dz = zo(i,k+1) - zi(i,k-1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typo, zi-> zo

Comment thread physics/CONV/SAMF/samfshalcnv.meta Outdated
name = samfshalcnv
type = scheme
dependencies = ../../tools/funcphys.f90,../../hooks/machine.F,samfaerosols.F,../progsigma_calc.f90,../progomega_calc.f90,mo_conv_kind.F90
dependencies = ../../tools/funcphys.f90,../../hooks/machine.F,samfaerosols.F,../progsigma_calc.f90,../progomega_calc.f90

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please revert this. This is needed for 32-bit precision builds.

Comment on lines +164 to +165
def4q(i,k,1) = def_4(i,k,ntqv)
def4q(i,k,1) = def_4(i,k,ntqv)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Duplicate line here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@rhaesung Thanks!! We are correcting them following your comments.

@rhaesung rhaesung changed the title Updates in the OMD GFS PBL and Convection models with 3D Total Turbulent Energy (TTE)-based Eddy-Diffusivity Mass-Flux (EDMF) Turbulent Mixing Scheme, Cold Pool Parameterization, and Mixed Scheme for Subgrid-Scale Convective Fluxes in Convective Clouds Updates in the OMD GFS PBL and Convection models with 3D TTE-based EDMF Turbulent Mixing Scheme, Cold Pool Parameterization, and Mixed Scheme for Subgrid-Scale Convective Fluxes in Convective Clouds + #405 + #408 + #414 Nov 3, 2026

@rhaesung rhaesung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@lisa-bengtsson

Copy link
Copy Markdown
Collaborator

Hi Christian,

I've been testing your PR in a global coupled configuration (C1152), but I'm encountering segmentation faults in RRTMG radiation, even with coldpool = .false..

Would you mind syncing your branch with the latest upstream develop? I'd like to check out the updated PR and rebuild to see whether that resolves the issue.

Thanks!
Lisa

@ChristianBoyer-NOAA

Copy link
Copy Markdown
Author

Hi Christian,

I've been testing your PR in a global coupled configuration (C1152), but I'm encountering segmentation faults in RRTMG radiation, even with coldpool = .false..

Would you mind syncing your branch with the latest upstream develop? I'd like to check out the updated PR and rebuild to see whether that resolves the issue.

Thanks! Lisa

Hi Lisa,

The branch should be synced with the latest upstream develop now. Hopefully that will help with the RRTMG segmentation fault.

Thanks,
Christian

@lisa-bengtsson

Copy link
Copy Markdown
Collaborator

Thank you! I will give it a try!

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
& clam,c0s,c1,betal,betas,evef,pgcon,asolfac,cscale, &
& do_ca, ca_closure, ca_entr, ca_trigger, nthresh,ca_deep, &
& rainevap,sigmain,sigmaout,omegain,omegaout,betadcu,betamcu, &
& betascu,lbb1,lbb2,lbb3,dt_decay,maxMF,do_mynnedmf, &

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Christian, I think when you synced updstream, the dt_decay that was cleaned out in a previous PR was accidentally re-introduced here. You can remove it here and in samfdeepcnv.meta. It is not declared after this so the compile fails.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, Lisa! I just pushed the fixes removing dt_decay and adding shallow_veto(im) back in.

Comment thread physics/CONV/SAMF/samfdeepcnv.f Outdated
real(kind=conv_wp) gravinv,invdelt,sigmind,sigminm,sigmins,
& wc_min, wc_eff
logical flag_shallow, flag_mid, shallow_veto(im)
logical flag_shallow, flag_mid

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shallow_veto(im) should still be included here. (I think this also got accidentally removed in the merge)

@pera-noaa

Copy link
Copy Markdown

@JongilHan66 Sorry for the slow reply. We put your updated diff3d (NOAA-GFDL/GFDL_atmos_cubed_sphere#429 @8460b55b) through the same meter. It cuts the leak about 17-fold but does not close it, because it divides by FV3's delp, while the physics applies the tendency to a different mass: delp minus the condensates, its del. My 29 Oct comment should have said that.

C96 control_p8, 24 h, sa3dtke and sa3dtke_dyco on. Net horizontal-diffusion tendency as satmedmfvdifq applies it, mass-weighted with del, relative to its gross:

T sphum worst tracer PBL water residual, 24 h (kg/m²)
original operator −2.8e-2 −9.8e-3 9.8e-3 −1.3e-5
your update (÷ FV3 delp) +1.6e-3 −5.7e-4 4.8e-3 −8.2e-7
your update, ÷ the physics' del −1.5e-17 +4.8e-18 7.5e-16 −1.7e-16

So one change closes it. Drop the three divisions by delp in diff3d (dyn_core.F90 L2565, L2640, L2703), and divide by del where satmedmfvdifq uses def_3 and def4q (L2276 for TKE; L2946–L3062). For example, once before they are used:

hdt(i,k)   = def_3(i,k)/del(i,k)
hdq(i,k,n) = def4q(i,k,n)/del(i,k)

then hdt and hdq in place of def_3 and def4q.

A smaller point: your stencil differences q·dx across a face rather than q, so a uniform tracer still gets a tendency wherever the grid spacing varies, up to 3.7e-9 /s, the same as the original operator. It nets to zero, so it does not affect conservation. Differencing q itself gives exactly zero. The form we tested (then ÷ del in the physics):

fx(i,j)  = 0.25*(dku3d_e(i-1,j,k)+dku3d_e(i,j,k))*(delp(i-1,j,k)+delp(i,j,k))*(q(i,j)-q(i-1,j))*dy(i,j)/dxc(i,j)
fy(i,j)  = 0.25*(dku3d_e(i,j-1,k)+dku3d_e(i,j,k))*(delp(i,j-1,k)+delp(i,j,k))*(q(i,j)-q(i,j-1))*dx(i,j)/dyc(i,j)
div(i,j) = rarea(i,j)*(fx(i+1,j)-fx(i,j)+fy(i,j+1)-fy(i,j))

These ran in our build (ufs-weather-model 3d2331e with #403 as of 23 Oct), with your diff3d copied in; we have not built your full updated branches.

@JongilHan66

Copy link
Copy Markdown
Collaborator

@JongilHan66 Sorry for the slow reply. We put your updated diff3d (NOAA-GFDL/GFDL_atmos_cubed_sphere#429 @8460b55b) through the same meter. It cuts the leak about 17-fold but does not close it, because it divides by FV3's delp, while the physics applies the tendency to a different mass: delp minus the condensates, its del. My 29 Oct comment should have said that.

C96 control_p8, 24 h, sa3dtke and sa3dtke_dyco on. Net horizontal-diffusion tendency as satmedmfvdifq applies it, mass-weighted with del, relative to its gross:

T sphum worst tracer PBL water residual, 24 h (kg/m²)
original operator −2.8e-2 −9.8e-3 9.8e-3 −1.3e-5
your update (÷ FV3 delp) +1.6e-3 −5.7e-4 4.8e-3 −8.2e-7
your update, ÷ the physics' del −1.5e-17 +4.8e-18 7.5e-16 −1.7e-16
So one change closes it. Drop the three divisions by delp in diff3d (dyn_core.F90 L2565, L2640, L2703), and divide by del where satmedmfvdifq uses def_3 and def4q (L2276 for TKE; L2946–L3062). For example, once before they are used:

hdt(i,k)   = def_3(i,k)/del(i,k)
hdq(i,k,n) = def4q(i,k,n)/del(i,k)

then hdt and hdq in place of def_3 and def4q.

A smaller point: your stencil differences q·dx across a face rather than q, so a uniform tracer still gets a tendency wherever the grid spacing varies, up to 3.7e-9 /s, the same as the original operator. It nets to zero, so it does not affect conservation. Differencing q itself gives exactly zero. The form we tested (then ÷ del in the physics):

fx(i,j)  = 0.25*(dku3d_e(i-1,j,k)+dku3d_e(i,j,k))*(delp(i-1,j,k)+delp(i,j,k))*(q(i,j)-q(i-1,j))*dy(i,j)/dxc(i,j)
fy(i,j)  = 0.25*(dku3d_e(i,j-1,k)+dku3d_e(i,j,k))*(delp(i,j-1,k)+delp(i,j,k))*(q(i,j)-q(i,j-1))*dx(i,j)/dyc(i,j)
div(i,j) = rarea(i,j)*(fx(i+1,j)-fx(i,j)+fy(i,j+1)-fy(i,j))

These ran in our build (ufs-weather-model 3d2331e with #403 as of 23 Oct), with your diff3d copied in; we have not built your full updated branches.

@pera-noaa What are dxc(i,j) and dyc(i,j)? 1/dxc(i,j)=1/dyc(i,j)=rarea(i,j)?

@pera-noaa

Copy link
Copy Markdown

@JongilHan66 Not quite. dxc(i,j) is the distance between the centres of cells (i−1,j) and (i,j), so it sits on the west face; dyc(i,j) is the distance between (i,j−1) and (i,j). dy(i,j) and dx(i,j) are the lengths of those two faces, and rarea(i,j) is 1/(cell area). So fx is face-mean K × face-mean delp × face length × (difference in q ÷ distance between centres), and rarea × the net face flux is the divergence.

All four are in gridstruct (gridstruct%dxc, gridstruct%dyc, or rdxc and rdyc for the inverses). FV3's tracer del-2 (deln_flux in tp_core.F90) uses the same face form, (mass(i−1,j)+mass(i,j))·del6_v·Δq with del6_v = sina_u·dy/dxc; sina_u corrects for the non-orthogonal cube and doesn't affect conservation.

Whichever metric you use, the face-flux form conserves; what closes the leak is dividing by del.

@JongilHan66

Copy link
Copy Markdown
Collaborator

@pera-noaa Thanks!! In the update, following your suggestion we will drop the divisions by delp in diff3d, and divide by del in satmedmfvdifq. We will keep stencil differences q·dx as their impact would be very small.

! tem=2.0*def_3(i,k)
tem=def_3(i,k)
! tem=min(tem,1.0)
tem=hdq(i,k,ntke)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@JongilHan66 Found by reading the code, not in a run: this adds hdq(i,k,ntke) whenever sa3dtke is on, but hdq is a local array that is only filled when sa3dtke .and. hdiffq (L535–547), so with hdiffq off the TKE gets uninitialised memory. Guarding it as the other hdq uses are would fix it (zeroing hdq at entry would too):

Suggested change
tem=hdq(i,k,ntke)
tem = 0.
if(hdiffq) tem=hdq(i,k,ntke)

@JongilHan66

Copy link
Copy Markdown
Collaborator

@pera-noaa Thanks!! fixed.

@JongilHan66

Copy link
Copy Markdown
Collaborator

@pera-noaa Since we want to have horizontal diffusion even when hdiffq=.false., while we keep tem=hdq(i,k,ntke) we modified initial assignment of hdq in satmedmfdifq.F as
if(sa3dtke .and. hdiffq) then
do k=1,km
do i=1,im
hdt(i,k) = def_3(i,k) / del(i,k)
enddo
enddo
do n=1,ntrac
do k=1,km
do i=1,im
hdq(i,k,n) = def4q(i,k,n) / del(i,k)
enddo
enddo
enddo
endif
=>
if(sa3dtke) then
if(hdiffq) then
do k=1,km
do i=1,im
hdt(i,k) = def_3(i,k) / del(i,k)
enddo
enddo
do n=1,ntrac
do k=1,km
do i=1,im
hdq(i,k,n) = def4q(i,k,n) / del(i,k)
enddo
enddo
enddo
else
do k=1,km
do i=1,im
hdq(i,k,ntke) = def4q(i,k,ntke) / del(i,k)
enddo
enddo
endif
endif

@JongilHan66

Copy link
Copy Markdown
Collaborator

@pera-noaa Since we want to have horizontal diffusion even when hdiffq=.false., while we keep tem=hdq(i,k,ntke) we modified initial assignment of hdq in satmedmfdifq.F as if(sa3dtke .and. hdiffq) then do k=1,km do i=1,im hdt(i,k) = def_3(i,k) / del(i,k) enddo enddo do n=1,ntrac do k=1,km do i=1,im hdq(i,k,n) = def4q(i,k,n) / del(i,k) enddo enddo enddo endif => if(sa3dtke) then if(hdiffq) then do k=1,km do i=1,im hdt(i,k) = def_3(i,k) / del(i,k) enddo enddo do n=1,ntrac do k=1,km do i=1,im hdq(i,k,n) = def4q(i,k,n) / del(i,k) enddo enddo enddo else do k=1,km do i=1,im hdq(i,k,ntke) = def4q(i,k,ntke) / del(i,k) enddo enddo endif endif

@pera-noaa Correction: Since we want to have horizontal diffusion even when hdiffq=.false. => Since we want to have horizontal diffusion for the TKE even when hdiffq=.false.

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.

5 participants