Repository navigation
Conversation
In gravity_wave_drag_ridge, ocean and flat-terrain chunks run all n_rdg ridge orientations (10 in CESM3 B1850CM) even when surface displacement is below orohmin or source stress tau vanishes before gw_drag_prof. Skip those inactive iterations. In gw_common and gw_diffusion, scan gwut before vertical diffusion, skip diffusion when no level breaks, and otherwise restrict gw_ediff and gw_diff_tend to [ktop_diff, kbot_diff]. An earlier, slightly broader version saved 1.87% total run time (893.0 to 876.3 s; 2.15% ATM) across 2 interleaved 3-hour CESM3 B1850CM pairs (32 MPI tasks, gfortran 13.4.0 -O2, measured with other local optimization patches active in both arms); this narrower commit was not re-timed alone. Answer impact: Bit-for-bit identical whenever the original produces finite results. Checked with 0 differing cprnc fields in CESM3 2-day and 3-hour B1850CM on this commit (gfortran 13.4.0 -O2, in a multi-patch build; earlier revisions also passed 8x4 OpenMP, restart, F2000climo, and QPC6), and verified bit-for-bit in a standalone real-module A/B check across gfortran, ifx 2025.0.4, and nvfortran 24.11-0. Assisted-by: Google Gemini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tag name (The PR title should also include the tag name):
Originator(s): g8j39
Description (include issue title and the keyword ['closes', 'fixes', 'resolves'] and issue number):
Fixes #482 (gravity_wave_drag: skip inactive ridge orientations and bound constituent vertical diffusion to breaking levels).
In 141-constituent coupled runs (
B1850CM), gravity-wave drag spends avoidable time over ocean and flat terrain where no sub-grid ridge is active, and solves vertical constituent diffusion across all 93 levels even when wave breaking is absent or confined to a few levels (~2.4% of CPU samples in a 3-hour profile with the companion atmosphere patches active).gravity_wave_drag_ridge.F90: Skip a ridge orientation whenband_oro%ngwv == 0and all columns havemxdis < orohmin, and skipgw_drag_profwhenall(tau == 0._kind_phys).gw_common.F90,gw_diffusion.F90: Scangwutbefore vertical diffusion. Zeroegwdffiand skip diffusion when no level breaks; otherwise solve only over[ktop_diff, kbot_diff](one level wider on each side than breaking levels, where zero interfaced_coefsetssprandsubinlinear_1d_operators.F90to zero and decouples the tridiagonal solve bit-for-bit).Timing: On an earlier, slightly broader revision with other local optimization patches active in both arms (3-hour
B1850CM, 32 MPI tasks, 2 interleaved pairs,gfortran 13.4.0 -O2oncesm3_0_beta10; stock ~937 s), total time fell from 893.03 to 876.30 s (1.87% less total, 2.15% less atmosphere). This narrower commit has not been re-timed alone.Validation:
main(this commit): compiles and matches unpatchedmainbit-for-bit (1,254,768 values, 0 diffs) acrossgfortran(13.4.0, 15.2.0),ifx 2025.0.4, andnvfortran 24.11-0.cprncchecks (gfortran 13.4.0,cesm3_0_beta10, multi-patch CESM3 build): 0 diffs in 2-dayB1850CM(6 pairs, 17 files / 4,263 fields) and 3-hourB1850CM(16 files / 4,183 fields); earlier checks also passed8x4OpenMP, restart,F2000climo, andQPC6. Full atmosphere-series setup and combined numbers are in the overview comment on SE: skip tendency-diagnostic buffers when the fields are not on a history tape CAM#1762.Prepared with AI assistance (Google Gemini).
List all namelist files that were added or changed:
None.
List all files eliminated and why:
None.
List all files added and what they do:
None.
List all existing files that have been modified, and describe the changes:
schemes/gravity_wave_drag/gravity_wave_drag_ridge.F90: Skip inactive ridge orientations (band_oro%ngwv == 0andall(mxdis(:ncol, nn) < orohmin)) and zero-stressgw_drag_profcalls.schemes/gravity_wave_drag/gw_common.F90: Scangwutfor breaking levels; skip diffusion when none break, else pass[ktop_diff, kbot_diff]togw_ediffandgw_diff_tend.schemes/gravity_wave_drag/gw_diffusion.F90: Skip zero-gwutwave levels ingw_ediffand restrictgw_diff_tendqnewwork toq(:, ktop:kbot).List all automated tests that failed, as well as an explanation for why they weren't fixed:
CAM regression tests and CAM-SIMA snapshot tests have not been run (no NCAR machine access); the runs listed above are the only testing.
Is this an answer-changing PR? If so, is it a new physics package, algorithm change, tuning change, etc?
No. Bit-for-bit identical for finite inputs (
cprncongfortranand standalone real-module A/B checks acrossgfortran,ifx, andnvfortran).If yes to the above question, describe how this code was validated with the new/modified features:
N/A (bit-for-bit).