Repository navigation
Conversation
bld_hash_table_indices overwrote colliding hash slots, so thujone_b got cubebene_b's emission factors, class and molecular weight. Use linear probing with stored-name comparison, endrun on duplicates or a full table, and allocate hash_table_indices from 0 (gen_hashkey can return 0). Fixes ESCOMP#4345 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…q. 7) The shaded-leaf Cp used instantaneous par_sha_in; par24_sha_in was passed but never used. Fixes ESCOMP#4346 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
During rapid leaf-out 2*elai240 - elai < 0, giving fnew > 1 and fmat < 0, negative isoprene gamma_A and inflated gamma_A for other classes. Fixes ESCOMP#4347 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quicktest results (EMIS-002, EMIS-003, EMIS-004)Will ran this fix in an 80 year test against an unmodified baseline (case
Below is Claude's summary of the results for this PR.
Expected: thujone_b getting its own emission factors instead of sharing cubebene_b's, and isoprene changes from the shaded-leaf PAR and leaf-age fixes. Found: MEGAN emissions change as expected. thujone_b falls −42.4%; in the baseline it was identical to cubebene_b (0.0951 Tg/yr each). Isoprene changes by −3.1% (396 → 384 Tg/yr) and methanol by −2.0%. Regionally, thujone_b falls 57–61% in tropical source regions but rises in the Southeast US (+37%) and Siberia (+189%), consistent with it now using its own emission factors. MEGAN fluxes don't feed back on the land in an I case, so none of this affects the land climate here. In CAM-chem runs the isoprene and BVOC changes would.
Key figures
Setup80-year land-only runs: Analysis scripts: |
pSASU spin-up results (EMIS-002, EMIS-003, EMIS-004)Follow-up to the quicktest results above. Will also ran this fix through a full cold-start spin-up (AD → SASU → pSASU; case
Below is Claude's summary of the results for this PR.
Found: The MEGAN changes after a full spin-up are the same as in the quicktest: thujone_b −42.4%, isoprene −3.1% (404 → 391 Tg/yr), methanol −2.0%. Regionally, thujone_b falls 57–61% in the tropics but rises in the Southeast US and Siberia. MEGAN fluxes don't feed back on the land in an I case, so this does not affect the land climate here. In CAM-chem runs the isoprene and BVOC changes would.
Key figures
SetupEach case is a cold-start spin-up with its fix in place: Analysis scripts: |
Quicktest and pSASU results split by audit finding (EMIS-002, EMIS-003, EMIS-004)Will asked Claude to break the MEGAN results down by the three audit findings this PR fixes. All three were tested together in the combined
EMIS-002: hash collision (#4345)Only thujone_b responds strongly: global emission falls 42.4% in both the quicktest and the pSASU spin-up. cubebene_b, its former collision partner, changes by only −0.8%, the same small amount as the other compounds, so it was not affected by the collision itself. The thujone_b change is a redistribution rather than a uniform cut, which is what its own emission factors (instead of cubebene_b's) should produce:
The EMIS-003: shaded-leaf
|
Implications (EMIS-002–004)Short summary of what the full cold-start spin-up (AD → SASU → pSASU, f19 BGC-Crop, 1850) means for this fix. EMIS-002 (MEGAN hash collision: 'thujone_b' silently gets 'cubebene_b' factors in the default setup): No climate signal. Tested in the audit-easy bundle, with EMIS-003 and EMIS-004 in #4348. Now that thujone_b has its own emission factors, its emission falls 42% globally: 57–61% lower in the tropics, 34% higher in the Southeast US and almost three times higher in Siberia. MEGAN does not feed back on the land in an I case, but atmospheric-chemistry users should be told. Merge as is. EMIS-003 (gamma_P: shaded-leaf Cp uses instantaneous PAR where the 24-h mean is required): No climate signal. Tested in the audit-easy bundle. Together with the other MEGAN fixes in #4348, isoprene falls 3.1% (404 → 391 Tg/yr; 2–4% across the source regions) and methanol 2.0%; the spin-ups cannot separate EMIS-003 from EMIS-004. MEGAN does not feed back on the land in an I case. Merge as is and tell chemistry users. EMIS-004 (gamma_A: leaf-age fractions can go outside [0,1] during leaf-out (fnew > 1, fmat < 0)): No climate signal. Tested in the audit-easy bundle. Together with the other MEGAN fixes in #4348, isoprene falls 3.1% and methanol 2.0%; the spin-ups cannot separate EMIS-004 from EMIS-003. MEGAN does not feed back on the land in an I case. Merge as is and tell chemistry users. Details: full pSASU results above Prepared with AI assistance (Claude) from the pSASU analysis in |
|
@tilmes and @lkemmons, I'm wondering what you think of this PR that address three 'critical' bugs that were identified by Brian's bug investigation. High level summary:
Would these changes be acceptable to the CAM-Chem group? let me know if you want to discuss further. |
Test resultsBranch System tests
The ERP namelist comparison reports only a Leaf onset at NEON HARV (
|
gamma_A range, whole run |
Steps outside [0.05, 1.0] | gamma_A written as fill value |
Midday isoprene during leaf-out (10–16 h local) | |
|---|---|---|---|---|
| base | 0.0003 – 0.9999 | 53 (2000-05-16 to 2000-05-30) | 636 steps, all in May–early June | zero in 157 of 269 steps; median 0 |
| this PR | 0.0500 – 0.9999 | 0 | 0 | nonzero in all 269 steps; median 2.6e-11, min 7.1e-13 |
- On the base,
gamma_Adrops belowAnew(0.05) during leaf-out. For 636 timesteps it isn't written at all, and isoprene emission is zero for most of the leaf-out middays. This fits the description in this PR: a negativegamma_Ais dropped by thegamma >= 0filter. - With this PR,
gamma_Astays within [min(A*), max(A*)] = [0.05, 1.0] at every step. During leaf-out it runs from 0.05 to 0.32, and isoprene is never zero.
Class and molecular weight lookup
I added the same temporary write (not committed) after meg_cmp%molec_weight is set in VOCEmissionMod.F90, in both runs:
thujone_b class / MW |
cubebene_b class / MW |
isoprene class / MW |
|
|---|---|---|---|
| base | 12 / 204.342 (collision: takes cubebene_b's values) |
12 / 204.342 | 1 / 68.114 |
| this PR | 9 / 152.227 | 12 / 204.342 | 1 / 68.114 |
Not run
- aux_clm against baselines.
Tests set up and run, and this summary written, with AI assistance (Claude Code).
Hi Will, |
|
I feel these changes are not anything to worry about. I cannot imagine
noticing any impact on ozone or SOA.
|
|
Thanks for these assessments. @tilmes are you suggesting running an F or B case to assess SOA? If so, can you suggest a compset, configuration, or run length that would be helpful for this evaluation (I've never run CAM...) |
|
@wwieder as Louisa said, it is probably very small and not needed by itself.. but when we have a new tag we should make sure to check the Isoprene emissions and to make sure it does not change much more, |
|
OK, we'll try to get this into a CESM tag as soon as possible, Simone |





Description of changes
This PR fixes three independent bugs in the MEGAN biogenic VOC emissions, each found in the CTSM correctness audit and each filed as its own issue. Each fix is a separate commit, so they can be reviewed or reverted on their own.
1. Hash collision in
MEGANFactorsMod.F90(#4345, commit b09862e).bld_hash_table_indicesoverwrote colliding hash slots without checking. In the default factors file,thujone_bandcubebene_bshare a hash key (23025), sothujone_bsilently got cubebene_b's emission factors, class (12 instead of 9) and molecular weight (204.3 instead of 152.2). Changes:endrunon a duplicate compound name or a full table.get_table_index(name)follows the same probe sequence and compares the stored name, ignoring trailing blanks and netCDF null padding.megan_factors_getandenter_hash_databoth use it, andenter_hash_datanow callsendrunif a name is not found.hash_table_indicesis allocated0:tbl_hash_sz-1, matching the range ofgen_hashkey. Before, a key of 0 would have indexed out of bounds.2. Shaded-leaf
Cpinget_gamma_P(#4346, commit 3ab4810). The shaded branch used the instantaneous shaded PAR (par_sha_in) inside exp(0.0005·(P24 − P0)), where Guenther et al. (2006) eq. 7 and the sunlit branch use the 24-hour mean. It now usespar24_sha_in, which was previously passed in but never used. This removes a roughly ±10% spurious diurnal modulation of shaded-leaf emission activity.3. Leaf-age fractions in
get_gamma_A(#4347, commit 0008127). During rapid leaf-out,elai_prev = 2*elai240 - elaiwent negative, givingfnew > 1andfmat < 0. As a result, isoprenegamma_Abecame negative (and the flux was dropped by thegamma >= 0filter), whilegamma_Afor other classes was inflated.elai_previs now bounded at zero, so the fractions stay in [0, 1] andgamma_A = Anewwhen all leaves are new. This adds no new divide-by-zero: theelai_prev < elai_inbranch divides only byelai_in, which is positive there.Only
src/biogeochem/MEGANFactorsMod.F90andsrc/biogeochem/VOCEmissionMod.F90change.Status: tested; see the test results.
Specific notes
Contributors other than yourself, if any:
CTSM issues resolved or otherwise addressed, if any:
If answers are expected to change, describe (delete this line otherwise):
megan = .true.(the default), and for the VOC fluxes sent to the coupler, which affects CAM-chem coupled runs. MEGAN does not feed back on the land state, so land prognostic variables should be bit-for-bit.MEG_thujone_band the BIGALK flux change.Any user interface changes (namelist or namelist defaults changes)?
Testing planned or performed, if any:
SMS_D.1x1_brazil.I2000Clm60FatesSpCrujraRsGs.derecho_intel.clm-FatesColdMeganSatPhen(debug, MEGAN on). Fails at SETUP on master too: MEGAN is not allowed with FATES. A non-FATES SP debug test with MEGAN was run instead; see the test results.ERP_D_Ld5.f10_f10_mg37.IHistClm60Sp.derecho_intel.clm-default--clm-nofireemis: expect DIFFs only inMEG_*and the VOC coupler fieldsgamma_Astays within [min(A*), max(A*)] and that isoprene is nonzero during onsetthujone_bnow gets class 9 and MW 152.227 (e.g. by temporary write statements, or a unit test of the lookup)Questions for reviewers
get_gamma_A: the non-evergreen testivt_in >= nbrdlf_dcd_trp_treealso catches PFT 9 (broadleaf evergreen temperate shrub), although the routine's comment lists only PFTs 1, 2, 4 and 5 as evergreen. This PR doesn't change that. Should PFT 9 be excluded here or in a follow-up?FireEmisFactorsModuses the same unguarded hash pattern. The audit found no collision in the default fire emission factors file. Should the same guard go into this PR, or into a separate one?