-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ASSERT_PARALLEL_CALLBACKS define
By default, assert uses `THIS_IMAGE()` in multi-image mode while composing assertion output, and invokes `ERROR STOP` to print the assertion and terminate execution. The ASSERT_PARALLEL_CALLBACKS preprocessor flag enables the client to replace the default use of these two Fortran features with client-provided callbacks. To use this feature, the client must build the library with `-DASSERT_PARALLEL_CALLBACKS`, and then at startup set the `assert_this_image` and `assert_error_stop` procedure pointers to reference the desired callbacks.
- Loading branch information
Showing
4 changed files
with
74 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,40 @@ | ||
program false_assertion | ||
use assert_m, only : assert | ||
use assert_m | ||
implicit none | ||
|
||
#if ASSERT_PARALLEL_CALLBACKS | ||
assert_this_image => assert_callback_this_image | ||
assert_error_stop => assert_callback_error_stop | ||
#endif | ||
|
||
call assert(.false., "false-assertion: unconditionally failing test") | ||
|
||
#if ASSERT_PARALLEL_CALLBACKS | ||
! By default, assert uses `THIS_IMAGE()` in multi-image mode while | ||
! composing assertion output, and invokes `ERROR STOP` to print the | ||
! assertion and terminate execution. | ||
! | ||
! The ASSERT_PARALLEL_CALLBACKS preprocessor flag enables the client to replace | ||
! the default use of these two Fortran features with client-provided callbacks. | ||
! To use this feature, the client must build the library with `-DASSERT_PARALLEL_CALLBACKS`, | ||
! and then at startup set the `assert_this_image` and `assert_error_stop` | ||
! procedure pointers to reference the desired callbacks. | ||
contains | ||
|
||
pure function assert_callback_this_image() result(this_image_id) | ||
implicit none | ||
integer :: this_image_id | ||
|
||
this_image_id = 42 | ||
end function | ||
|
||
pure subroutine assert_callback_error_stop(stop_code_char) | ||
implicit none | ||
character(len=*), intent(in) :: stop_code_char | ||
|
||
error stop "Hello from assert_callback_error_stop!" // NEW_LINE('a') // & | ||
"Your assertion: " // NEW_LINE('a') // stop_code_char | ||
end subroutine | ||
#endif | ||
|
||
end program |
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