Skip to content

Stop and print#191

Open
rouson wants to merge 28 commits into
BerkeleyLab:mainfrom
rouson:stop-and-print
Open

Stop and print#191
rouson wants to merge 28 commits into
BerkeleyLab:mainfrom
rouson:stop-and-print

Conversation

@rouson

@rouson rouson commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

No description provided.

rouson added 18 commits June 22, 2026 09:02
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] ) )
This commit works around several build-time and runtime gfortran
conpiler bugs.
The character_stop_code subroutine is public only for purposes of
calling it from thetest suite so there's no need to have it in the
public interface (julienne_m).
This commit supports using user-defined derived-type output (UDDTO)
to create stop codes for derived types that extend the new writable_t
abstract type, which has

- A write_formatted deferred binding that obligates child types to
  support UDDTO,
- A private maxlen_ component that sets the maximum stop-code length,
- A maxlen type-bound function that returns maxlen_, and
- A set_maxlen type-bound subroutine that sets maxlen_.

This commit also includes a corresponding unit test.

@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.

@rouson This PR needs to be rebased and conflicts resolved before CI will run.

I don't have time for an in-depth review today, but here's a few things I noticed on a quick skim

Comment thread test/test_stop_and_print.F90 Outdated
Comment thread src/julienne/julienne_stop_and_print_s.F90
rouson and others added 9 commits June 29, 2026 17:06
This commit makes the command_line_t argument_present type-bound
function's name a generic interface with two corresponding specific
procedures:

1. character_argument_present (renamed from argument_present)
2. string_argument_present (new)

The first function still has a character-array dummy argument with
fixed-length elements as required by the standard.  The second
function allows for ragged-edged arrays of character variables by
accepting a string_t array dummy argument.
This commit makes the command_line_t flag_value type-bound
function's name a generic binding with two corresponding specific
procedures:

1. character_flag_value (renamed from flag_value)
2. string_flag_value (new)

The first function still has a character-array dummy argument.
The second function accepts a string_t dummy argument.
This commit introduces the pure-stop-and-print.F90 example program,
which deonstrates the printing of a 2D integeray array, a derived
type, or a text file.

Usage:

  fpm run \
     --example pure-stop-and-print \
     --compiler flang --profile release \
     -- [-h|--help] | [--file <name>] | [--array] | [--derived-type]

where pipes (|) separate alternatives, square brackets ([]) delimit
optional arguments, and angular brackets (<>) delimit user input.
This commit updates

1. `example/README.md`
2. `pure-printing/README.md`

with descriptions of the use of Julienne's `stop_and_print`
utility.
Gfortran rejects valid code containing a function invocation as
a stop code.  This has been reported as GCC issue 126018 at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126018.
Replace `error stop` with  `internal_error_stop`
@rouson

rouson commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@bonachea it appears the all lfortran builds fail, older ifx builds fail, and gfortran 13 fails along. I can't figure out the pattern to the rest of the failures, but I think we'll need to drop support for some of these compiler versions. Let's discuss.

@bonachea

Copy link
Copy Markdown
Member

@bonachea it appears the all lfortran builds fail, older ifx builds fail, and gfortran 13 fails along. I can't figure out the pattern to the rest of the failures, but I think we'll need to drop support for some of these compiler versions. Let's discuss.

I agree with your assessment of the symptoms, but I strongly disagree that we should jump straight to amputation as the only possible treatment. Let's discuss later today.

submodule(julienne_stop_and_print_m) julienne_stop_and_print_s
use julienne_string_m, only : operator(.csv.), operator(.separatedBy.)
use julienne_file_m, only : file_t
use julienne_multi_image_m, only : internal_error_stop

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.

At least some of the failures appear to be caused by importing this symbol in a submodule after it has already been imported in the enclosing module. This is unnecessary and an anti-pattern that is known to break some older some compilers, so please remove the redundant use statements.

Suggested change
use julienne_multi_image_m, only : internal_error_stop

Comment thread README.md
specific subroutines:

1. One with a Julienne `string_t` dummy argument and
2. Another with `character` and unlimited-polymorphic/assumed-rank dummy arugments.

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.

Suggested change
2. Another with `character` and unlimited-polymorphic/assumed-rank dummy arugments.
2. Another with `character` and unlimited-polymorphic/assumed-rank dummy arguments.


### Printing a text file

The following command prints this repository's `fpm` mannifest: `fpm.toml`.

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.

Suggested change
The following command prints this repository's `fpm` mannifest: `fpm.toml`.
The following command prints this repository's `fpm` manifest: `fpm.toml`.

@bonachea bonachea Jun 30, 2026

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.

Given the complexity of the new example, I think we should look into getting it into CI.

This doesn't necessarily block this PR, but it makes me nervous to have over 250 lines of example code with zero automated coverage to detect regressions and bit-rot.

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.

2 participants