-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1183 from billsacks/assert_file_line
Allow passing file and line to shr_assert Up until now, many calls to shr_assert (often done through the SHR_ASSERT macro) gave file and line information via a call to shr_log_errMsg. However, the shr_log_errMsg function is terrible for performance for some reason. This PR adds optional arguments to the shr_assert interface (and related macros) so that you can pass the file and line directly into that function. Then the cost of building an error message is only borne if you actually abort. So, for example, you can replace SHR_ASSERT(condition, shr_log_errMsg(__FILE__, __LINE__)) with SHR_ASSERT_FL(condition, __FILE__, __LINE__) (where 'FL' stands for FileLine). I have done this replacement for all relevant cime Fortran code. Test suite: cime Fortran unit tests and ./create_test cime_developer on yellowstone; also ran debug tests on yellowstone-intel, yellowstone-pgi, yellowstone-gnu and hobart-nag in a version rebased onto cime5.2.0-alpha.9 Test baseline: N/A Test namelist changes: none Test status: bit for bit User interface changes?: none Code review: @jedwards4b
- Loading branch information
Showing
16 changed files
with
183 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
#ifdef NDEBUG | ||
#define SHR_ASSERT(assert, msg) | ||
#define SHR_ASSERT_FL(assert, file, line) | ||
#define SHR_ASSERT_MFL(assert, msg, file, line) | ||
#define SHR_ASSERT_ALL(assert, msg) | ||
#define SHR_ASSERT_ALL_FL(assert, file, line) | ||
#define SHR_ASSERT_ALL_MFL(assert, msg, file, line) | ||
#define SHR_ASSERT_ANY(assert, msg) | ||
#define SHR_ASSERT_ANY_FL(assert, file, line) | ||
#define SHR_ASSERT_ANY_MFL(assert, msg, file, line) | ||
#else | ||
#define SHR_ASSERT(assert, msg) call shr_assert(assert, msg) | ||
#define SHR_ASSERT_ALL(assert, msg) call shr_assert_all(assert, msg) | ||
#define SHR_ASSERT_ANY(assert, msg) call shr_assert_any(assert, msg) | ||
#define SHR_ASSERT(assert, my_msg) call shr_assert(assert, msg=my_msg) | ||
#define SHR_ASSERT_FL(assert, my_file, my_line) call shr_assert(assert, file=my_file, line=my_line) | ||
#define SHR_ASSERT_MFL(assert, my_msg, my_file, my_line) call shr_assert(assert, msg=my_msg, file=my_file, line=my_line) | ||
#define SHR_ASSERT_ALL(assert, my_msg) call shr_assert_all(assert, msg=my_msg) | ||
#define SHR_ASSERT_ALL_FL(assert, my_file, my_line) call shr_assert_all(assert, file=my_file, line=my_line) | ||
#define SHR_ASSERT_ALL_MFL(assert, my_msg, my_file, my_line) call shr_assert_all(assert, msg=my_msg, file=my_file, line=my_line) | ||
#define SHR_ASSERT_ANY(assert, my_msg) call shr_assert_any(assert, msg=my_msg) | ||
#define SHR_ASSERT_ANY_FL(assert, my_file, my_line) call shr_assert_any(assert, file=my_file, line=my_line) | ||
#define SHR_ASSERT_ANY_MFL(assert, my_msg, my_file, my_line) call shr_assert_any(assert, msg=my_msg, file=my_file, line=my_line) | ||
#endif | ||
use shr_assert_mod |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.