Feature: pure stop_and_print subroutine #188
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new stop_and_print routine (exported via julienne_m) intended to allow emitting string_t-based diagnostics via ERROR STOP, even when called from within pure procedure call chains.
Changes:
- Added
julienne_stop_and_print_mmodule providingpure subroutine stop_and_print(message). - Exported
stop_and_printfrom the aggregatejulienne_mmodule. - Added a conditional test program that exercises
stop_and_printfrom inside apuresubroutine (only when intentional-failure flags are enabled).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| test/test_stop_and_print.F90 | New conditional test program for stop_and_print in a pure context. |
| src/julienne/julienne_stop_and_print_m.F90 | New module implementing stop_and_print via error stop message%string(). |
| src/julienne_m.F90 | Re-exports stop_and_print from the new module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This commit adds a pure stop_and_print subroutine and a corresponding unit test. The new subroutine facilitates printing string_t objects, including the results of string_t expressions, during error termination. Example Usage: call stop_and_print( "array = " // string_t( [1,2,3,4] ) )
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Base branch was very outdated, just rebased onto the current tip of main without changes |
bonachea
left a comment
There was a problem hiding this comment.
Looks good overall, in particular I agree it's a useful feature.
I have one minor quibble with the implementation that I'd like resolved before merge.
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
… flang 22 -pedantic
This is a *breaking change* for clients using JULIENNE_PARALLEL_CALLBACKS
…zed type F2023 7.5.4.6 'Default initialization for components' states: > A type has default initialization if component-initialization is specified > for any direct component of the type. An object has default initialization if > it is of a type that has default initialization.
bonachea
left a comment
There was a problem hiding this comment.
LGTM, with the caveat this will be a breaking change for clients using JULIENNE_PARALLEL_CALLBACKS (probably only Caffeine)
New in this PR
stop_and_printsubroutine andThe new subroutine facilitates printing
string_tobjects, including the results ofstring_texpressions, during error termination.Use Case
Julienne currently provides diagnostic information when assertions are enabled and an assertion fails. An assertion effectively states an expectation about values or relationships between values. When such an expectation is not readily at hand, one can force a print with an assertion hardwired for failure:
This approach is cumbersome and non-obvious for new users. The new
stop_and_printoffers a simpler, more obvious alternative:The new alternative is most useful during debugging sessions when one wants to temporarily insert a print statement deep in a sequence of
pureprocedure invocations, where printing is precluded and temporarily removing thepureattribute from each procedure in the sequence is time-consuming and tedious.