Repository navigation
Conversation
samsrabin
force-pushed
the
fix-matrix-threaded-race
branch
from
November 13, 2026 22:45
4b98e82 to
e061b45
Compare
By forcing each thread to set or reset the sparse_matrix_type metadata, we can avoid threads seeing partially-filled metadata from other in-progress threads. Tested using ERP_D_P64x2_Ld3.f10_f10_mt201.I2000Clm50BgcCru.derecho_intel.clm-noFUN_flexCN--clm-matrixcnOn_ignore_warnings: - 5/10 runs failed at ctsm5.4.069 - 0/10 runs failed on this commit
samsrabin
force-pushed
the
fix-matrix-threaded-race
branch
from
November 13, 2026 22:46
e061b45 to
22d5176
Compare
This branch has not been deployed
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.
Description of changes
There were four instances of blocks like this in
CNSoilMatrix()(one each for C, C13, C14, and N):CTSM/src/soilbiogeochem/CNSoilMatrixMod.F90
Lines 613 to 618 in 2ba8531
Those four blocks were where we saw the "line 973" error from #3360. This was the bad result of a race condition that happens when:
IsValuesSetSM(), gets.false.and thus callsSetValueCopySM(), which ends by callingSetValueSM(), which starts to fill (in this order) the metadataNEthenRI+CI.IsValuesSetSM()call after Thread A has filledNEbut before it's finishedRIandCI. It entersIsValuesSetSM(), sees thatNEisn'tempty_int, and returns.true.. Thread B then takes the other path of the aboveifstatement, callingSPMP_B_ACC, which fails at line 973: an assertion involvingRI, which Thread A hadn't finished filling.By forcing each thread to set or reset the
sparse_matrix_typemetadata, we can avoid threads seeing partially-filled metadata from other in-progress threads.Specific notes
Contributors other than yourself, if any:
CTSM issues resolved or otherwise addressed, if any:
Any user interface changes (namelist or namelist defaults changes)? No
Testing planned or performed, if any:
ERP_D_P64x2_Ld3.f10_f10_mt201.I2000Clm50BgcCru.derecho_intel.clm-noFUN_flexCN--clm-matrixcnOn_ignore_warnings. 5/10 runs failed at ctsm5.4.069; 0/10 runs failed on this commit.aux_clmRequirements before merge:
ERP_D_P64x2_Ld3.f10_f10_mt201.I2000Clm50BgcCru.derecho_intel.clm-noFUN_flexCN--clm-matrixcnOn_ignore_warnings