Skip to content

Add module for designating patch/col/etc. as "debug"#4018

Open
samsrabin wants to merge 1 commit into
ESCOMP:b4b-devfrom
samsrabin:add-debugmod
Open

Add module for designating patch/col/etc. as "debug"#4018
samsrabin wants to merge 1 commit into
ESCOMP:b4b-devfrom
samsrabin:add-debugmod

Conversation

@samsrabin
Copy link
Copy Markdown
Member

@samsrabin samsrabin commented May 13, 2026

Description of changes

Often we want to add write statements as part of debugging model behavior, but this can quickly become hard to parse if we don't limit the scope of the messaging. If we're debugging just one patch, column, gridcell, or landunit, we can make the messaging conditional on the object having the correct index. This PR adds a new module, debugMod, that facilitates this.

debugMod allows the user to hard-code a global index for patch, column, landunit, and/or gridcell to debug. It then provides functions where the user can give either a local or global index and get back a boolean that's true if it's the debugged one and false otherwise.

Specific notes

Contributors other than yourself, if any:

  • None

CTSM issues resolved or otherwise addressed, if any:

  • None

Any user interface changes (namelist or namelist defaults changes)? No

Testing planned or performed, if any:

  • Tested during some column-level troubleshooting
  • Add unit tests. Tricky because we don't want to hard-code any debug index.

Requirements before merge:

  • The code in this PR branch builds with no errors.
  • The code in this PR branch runs with no errors. Column-level troubleshooting
  • This either (a) does not change answers, (b) it only changes answers at roundoff level, or (c) I have performed a scientific evaluation of the answer changes. Which?: A
  • I have reviewed relevant parts of the CLM documentation Tech Note or User's Guide to determine if anything needs to be changed or added. If it does, describe: Should add a bit in the Troubleshooting section of the User's Guide
  • This PR either (a) does not create a need to update the documentation or (b) includes required documentation updates (see guidelines for contributing documentation). Which?: Will include updates, but I haven't made them yet.

@samsrabin samsrabin changed the title Add module for designating patch/col/etc. as "debug Add module for designating patch/col/etc. as "debug" May 13, 2026
@samsrabin samsrabin self-assigned this May 13, 2026
@samsrabin samsrabin added b4b bit-for-bit size: small next this should get some attention in the next week or two. Normally each Thursday SE meeting. labels May 13, 2026
Comment thread src/main/debugMod.F90
use shr_log_mod , only : errMsg => shr_log_errMsg
use clm_time_manager , only : timemgr_restart_io, get_nstep, get_curr_date
use clm_varctl , only : iulog
use clm_varcon , only : nameg, namel, namec, namep
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Need to remove a bunch of unused things.

Comment thread src/main/debugMod.F90
! public :: do_debug_patch
public :: do_debug_column
! public :: do_debug_landunit
! public :: do_debug_gridcell
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Need to uncomment all these.

Comment thread src/main/debugMod.F90
! Global indices for objects to debug.
! When merging to a CTSM branch, these must always be < 1!!
integer, parameter :: debug_p = -999
integer, parameter :: debug_c = 2787
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Set this to -999.

@samsrabin
Copy link
Copy Markdown
Member Author

Good idea from @mvdebolskiy: Add an option to the functions that would have them return true if any parent is debug. So for instance, you could set a column, landunit, or gridcell to debug, then do do_debug_patch(..., include_parent=.true.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

b4b bit-for-bit next this should get some attention in the next week or two. Normally each Thursday SE meeting. size: small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant