Skip to content

Feature: pure stop_and_print subroutine #188

Merged
rouson merged 8 commits into
BerkeleyLab:mainfrom
rouson:stop-and-print
Jun 23, 2026
Merged

Feature: pure stop_and_print subroutine #188
rouson merged 8 commits into
BerkeleyLab:mainfrom
rouson:stop-and-print

Conversation

@rouson

@rouson rouson commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

New in this PR

  1. A pure stop_and_print subroutine and
  2. A corresponding unit test.

The new subroutine facilitates printing string_t objects, including the results of string_t expressions, 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:

call_jullienne_assert( .expect. .false. // (.csv. ("array = " // string_t( [1,2,3,4] ) ))

This approach is cumbersome and non-obvious for new users. The new stop_and_print offers a simpler, more obvious alternative:

call stop_and_print( .csv. ("array = " // string_t( [1,2,3,4] ) ))

The new alternative is most useful during debugging sessions when one wants to temporarily insert a print statement deep in a sequence of pure procedure invocations, where printing is precluded and temporarily removing the pure attribute from each procedure in the sequence is time-consuming and tedious.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_m module providing pure subroutine stop_and_print(message).
  • Exported stop_and_print from the aggregate julienne_m module.
  • Added a conditional test program that exercises stop_and_print from inside a pure subroutine (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.

Comment thread test/test_stop_and_print.F90 Outdated
Comment thread test/test_stop_and_print.F90
Comment thread src/julienne/julienne_stop_and_print_m.F90
Comment thread src/julienne/julienne_stop_and_print_m.F90 Outdated
rouson and others added 2 commits June 23, 2026 12:40
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>
@bonachea

Copy link
Copy Markdown
Member

Base branch was very outdated, just rebased onto the current tip of main without changes

Comment thread test/test_stop_and_print.F90 Outdated

@bonachea bonachea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread src/julienne/julienne_stop_and_print_m.F90 Outdated
Comment thread src/julienne/julienne_stop_and_print_m.F90
Comment thread test/test_stop_and_print.F90
Comment thread test/test_stop_and_print.F90 Outdated
rouson and others added 6 commits June 23, 2026 13:36
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
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 bonachea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, with the caveat this will be a breaking change for clients using JULIENNE_PARALLEL_CALLBACKS (probably only Caffeine)

@rouson rouson removed the request for review from ktras June 23, 2026 20:36
@rouson rouson merged commit 9adbfba into BerkeleyLab:main Jun 23, 2026
46 checks passed
@rouson rouson deleted the stop-and-print branch June 23, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants