-
Notifications
You must be signed in to change notification settings - Fork 361
Add module for designating patch/col/etc. as "debug" #4018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
samsrabin
wants to merge
7
commits into
ESCOMP:b4b-dev
Choose a base branch
from
samsrabin:add-debugmod
base: b4b-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+314
−5
Draft
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea4a368
Add debugMod.
samsrabin db92e6e
Set debug_c to -999.
samsrabin 43e989d
Uncomment all do_debug_* function publications.
samsrabin 6e22851
debugMod: Remove unused stuff.
samsrabin 97d16bc
Debug indices are now namelist params.
samsrabin ae195c2
Move debugMod.F90 to src/utils/.
samsrabin 182ee74
debugMod: Set index to 0 to always debug.
samsrabin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| module debugMod | ||
|
|
||
| !----------------------------------------------------------------------- | ||
| ! !DESCRIPTION: | ||
| ! Provides a place to define gridcells, landunits, columns, and/or patches that we want debug | ||
| ! output for, as well as functions for checking whether a given g/l/c/p is being debugged. | ||
| ! | ||
| ! !USES: | ||
| #include "shr_assert.h" | ||
| use shr_kind_mod , only : r8 => shr_kind_r8, CL=>shr_kind_CL | ||
| use decompMod , only : bounds_type, get_proc_clumps, get_clump_bounds | ||
| use decompMod , only : bounds_level_proc | ||
| use decompMod , only : subgrid_level_gridcell, subgrid_level_landunit | ||
| use decompMod , only : subgrid_level_column, subgrid_level_patch | ||
| use decompMod , only : get_global_index | ||
| use spmdMod , only : masterproc, mpicom | ||
| use abortutils , only : endrun | ||
| 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 | ||
| ! | ||
| ! !PUBLIC TYPES: | ||
| implicit none | ||
| private | ||
| ! | ||
| ! !PUBLIC MEMBER FUNCTIONS: | ||
| ! public :: do_debug_patch | ||
| public :: do_debug_column | ||
| ! public :: do_debug_landunit | ||
| ! public :: do_debug_gridcell | ||
|
samsrabin marked this conversation as resolved.
Outdated
|
||
| ! | ||
| ! !PRIVATE TYPES: | ||
|
|
||
| ! 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 | ||
|
samsrabin marked this conversation as resolved.
Outdated
|
||
| integer, parameter :: debug_l = -999 | ||
| integer, parameter :: debug_g = -999 | ||
|
|
||
| character(len=*), parameter, private :: sourcefile = __FILE__ | ||
| !----------------------------------------------------------------------- | ||
|
|
||
| contains | ||
|
|
||
| !----------------------------------------------------------------------- | ||
| function do_debug_patch(i_local, i_global) result(do_debug) | ||
| ! | ||
| ! !DESCRIPTION: | ||
| ! Return .true. if the given global patch index is the one we're debugging; .false. otherwise. | ||
| ! Provide only i_local or i_global. | ||
| ! | ||
| ! !ARGUMENTS: | ||
| integer, optional :: i_local ! Local patch index | ||
| integer, optional :: i_global ! Global patch index | ||
| ! | ||
| ! !RESULT: | ||
| logical :: do_debug | ||
| integer :: i ! Global patch index | ||
| !----------------------------------------------------------------------- | ||
|
|
||
| ! This makes it so that compilers should build this function as a simple boolean if we haven't | ||
| ! requested any patch to be debugged, which reduces performance cost in production runs. | ||
| if (debug_p < 1) then | ||
| do_debug = .false. | ||
| return | ||
| end if | ||
|
|
||
| if (present(i_global)) then | ||
| call shr_assert(.not. present(i_local), file=sourcefile, line=__LINE__) | ||
| call shr_assert(i_global >= 1, file=sourcefile, line=__LINE__) | ||
| i = i_global | ||
| else | ||
| call shr_assert(present(i_local), file=sourcefile, line=__LINE__) | ||
| i = get_global_index(subgrid_index=i_local, subgrid_level=subgrid_level_patch, & | ||
| donot_abort_on_badindex=.false.) | ||
| end if | ||
|
|
||
| do_debug = i == debug_p | ||
| return | ||
|
|
||
| end function do_debug_patch | ||
|
|
||
| !----------------------------------------------------------------------- | ||
| function do_debug_column(i_local, i_global) result(do_debug) | ||
| ! | ||
| ! !DESCRIPTION: | ||
| ! Return .true. if the given global column index is the one we're debugging; .false. otherwise. | ||
| ! Provide only i_local or i_global. | ||
| ! | ||
| ! !ARGUMENTS: | ||
| integer, optional :: i_local ! Local column index | ||
| integer, optional :: i_global ! Global column index | ||
| ! | ||
| ! !RESULT: | ||
| logical :: do_debug | ||
| integer :: i ! Global column index | ||
| !----------------------------------------------------------------------- | ||
|
|
||
| ! This makes it so that compilers should build this function as a simple boolean if we haven't | ||
| ! requested any column to be debugged, which reduces performance cost in production runs. | ||
| if (debug_c < 1) then | ||
| do_debug = .false. | ||
| return | ||
| end if | ||
|
|
||
| if (present(i_global)) then | ||
| call shr_assert(.not. present(i_local), file=sourcefile, line=__LINE__) | ||
| call shr_assert(i_global >= 1, file=sourcefile, line=__LINE__) | ||
| i = i_global | ||
| else | ||
| call shr_assert(present(i_local), file=sourcefile, line=__LINE__) | ||
| i = get_global_index(subgrid_index=i_local, subgrid_level=subgrid_level_column, & | ||
| donot_abort_on_badindex=.false.) | ||
| end if | ||
|
|
||
| do_debug = i == debug_c | ||
| return | ||
|
|
||
| end function do_debug_column | ||
|
|
||
| !----------------------------------------------------------------------- | ||
| function do_debug_landunit(i_local, i_global) result(do_debug) | ||
| ! | ||
| ! !DESCRIPTION: | ||
| ! Return .true. if the given global landunit index is the one we're debugging; .false. otherwise. | ||
| ! Provide only i_local or i_global. | ||
| ! | ||
| ! !ARGUMENTS: | ||
| integer, optional :: i_local ! Local landunit index | ||
| integer, optional :: i_global ! Global landunit index | ||
| ! | ||
| ! !RESULT: | ||
| logical :: do_debug | ||
| integer :: i ! Global landunit index | ||
| !----------------------------------------------------------------------- | ||
|
|
||
| ! This makes it so that compilers should build this function as a simple boolean if we haven't | ||
| ! requested any landunit to be debugged, which reduces performance cost in production runs. | ||
| if (debug_l < 1) then | ||
| do_debug = .false. | ||
| return | ||
| end if | ||
|
|
||
| if (present(i_global)) then | ||
| call shr_assert(.not. present(i_local), file=sourcefile, line=__LINE__) | ||
| call shr_assert(i_global >= 1, file=sourcefile, line=__LINE__) | ||
| i = i_global | ||
| else | ||
| call shr_assert(present(i_local), file=sourcefile, line=__LINE__) | ||
| i = get_global_index(subgrid_index=i_local, subgrid_level=subgrid_level_landunit, & | ||
| donot_abort_on_badindex=.false.) | ||
| end if | ||
|
|
||
| do_debug = i == debug_l | ||
| return | ||
|
|
||
| end function do_debug_landunit | ||
|
|
||
| !----------------------------------------------------------------------- | ||
| function do_debug_gridcell(i_local, i_global) result(do_debug) | ||
| ! | ||
| ! !DESCRIPTION: | ||
| ! Return .true. if the given global gridcell index is the one we're debugging; .false. otherwise. | ||
| ! Provide only i_local or i_global. | ||
| ! | ||
| ! !ARGUMENTS: | ||
| integer, optional :: i_local ! Local gridcell index | ||
| integer, optional :: i_global ! Global gridcell index | ||
| ! | ||
| ! !RESULT: | ||
| logical :: do_debug | ||
| integer :: i ! Global gridcell index | ||
| !----------------------------------------------------------------------- | ||
|
|
||
| ! This makes it so that compilers should build this function as a simple boolean if we haven't | ||
| ! requested any gridcell to be debugged, which reduces performance cost in production runs. | ||
| if (debug_g < 1) then | ||
| do_debug = .false. | ||
| return | ||
| end if | ||
|
|
||
| if (present(i_global)) then | ||
| call shr_assert(.not. present(i_local), file=sourcefile, line=__LINE__) | ||
| call shr_assert(i_global >= 1, file=sourcefile, line=__LINE__) | ||
| i = i_global | ||
| else | ||
| call shr_assert(present(i_local), file=sourcefile, line=__LINE__) | ||
| i = get_global_index(subgrid_index=i_local, subgrid_level=subgrid_level_gridcell, & | ||
| donot_abort_on_badindex=.false.) | ||
| end if | ||
|
|
||
| do_debug = i == debug_g | ||
| return | ||
|
|
||
| end function do_debug_gridcell | ||
|
|
||
| end module debugMod | ||
|
|
||
|
|
||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.