-
Notifications
You must be signed in to change notification settings - Fork 11
Stop and print #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rouson
wants to merge
48
commits into
BerkeleyLab:main
Choose a base branch
from
rouson:stop-and-print
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Stop and print #191
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
78bfc18
feat(stop_and_print): print string_t in pure procs
rouson c5c1cb6
feat: mk stop_and_print generic
rouson 8aebfba
test(character_stop_code): 1D integer array passes
rouson 1cadca4
test(character_stop_code): check comma count
rouson 9de5f3b
fix(character_stop_code): rm extraneous commas
rouson b2250ca
test(character_stop_code): 2D integer array passes
rouson 059a4f4
test(character_stop_code): 2D/3D real/integer arrays
rouson 6f67167
test(character_stop_code): 1D complex array
rouson f9496df
test(character_stop_code): {1,2,3}D dble prec arrays
rouson 985890b
build/test(print_and_stop): gfortran workarounds
rouson f675425
feat(stop_and_print): support 1D string_t arrays
rouson 258ee18
feat(file_t): add from_character_lines constructor
rouson 700a690
feat(character_stop_code): support file_t
rouson e34d6a5
refac(julienne_m): rm character_stop_code
rouson 65e61d9
feat(character_stop_code): support derived types
rouson c158baf
fix: skip 3 tests that crash with gfortran
rouson a91a5e2
refac(stop_and_print): split {sub,}module
rouson 44ed48b
doc(README): describe output in pure procedures
rouson a3e5768
feat(command_line): mk argument_present generic
rouson ad1376b
feat(command_line): mk flag_value generic
rouson 0a70b1b
doc(example): add pure-stop-and-print.F90
rouson 59648a5
doc(example): describe the use of stop_and_print
rouson a04f05f
build(gfortran): work around compiler issues
rouson 9997991
fix(stop_and_print): call internal_error_stop
rouson fcf9de6
fix(error stop): replace with internal_error_stop
rouson 482bb71
build(ifx): work around compiler issue
rouson 78ce9bf
feat(example): mv stop_and_print calls to pure sub
rouson 492a874
doc(README): fix typo
rouson b6100f1
chore(stop_and_print): rm redundant use statement
rouson ffd6586
fix(write_formatted): set iostat to 0
rouson 3b2e358
test(stop_and_print): work around gfortran bug
rouson 9a40781
chore(command_line_s): .f90 -> .F90 to preprocess
rouson 5b08072
doc(README): fix typo
rouson 7f4baf2
chore: fix/redo 5358e
rouson c1117f3
fix(stop_and_print): import internal_error_stop
rouson 817c3a3
test(stop_and_print): work around gfortran associate issue
rouson 17977b5
fix(string_argument_present): work around gfortran 13
rouson dc77c1e
test(stop_and_print): skip tests with flang 19
rouson d56344f
chore: refactor compiler macro version logic
rouson b034c93
test(stop_and_print): skip with flang 19
rouson ae5f00d
build(stop_and_print): HAVE_STOP_AND_PRINT_SUPPORT
rouson aed94de
Add missing preprocessor directives for HAVE_STOP_AND_PRINT_SUPPORT
bonachea 7fda683
Add more missing preprocessor conditionals for HAVE_STOP_AND_PRINT_SU…
bonachea 5c83a22
Disable HAVE_STOP_AND_PRINT_SUPPORT for Intel 2026.0
bonachea 7a3d443
test_stop_and_print: Fix copy pasta that made a confusing message
bonachea fe9abbb
command_line_t: Remove uses of generic interface for now
bonachea cd52fbe
workaround some gfortran bugs
bonachea e71c86e
CI: Add coverage for stop-and-print examples
bonachea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| Pure Printing | ||
| ============= | ||
|
|
||
| This directory contains a program and a supporting module/submodule | ||
| pair that collectively demonstrate the use of Julienne's | ||
| `stop_and_print` subroutine designed for use inside `pure` procedures. | ||
| Specifically, the program shows how to print the following entities: | ||
|
|
||
| - a text file, | ||
| - a two-dimensional (2D) integer array, or | ||
| - an object of derived type. | ||
|
|
||
| ``` | ||
| 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. | ||
|
|
||
| Getting help | ||
| ------------ | ||
| The following command prints the above usage text: | ||
|
|
||
| ``` | ||
| fpm run --example pure-stop-and-print --compiler flang -- --help | ||
| ``` | ||
|
|
||
| Examples | ||
| -------- | ||
| ### Printing a 2D integer array | ||
| The following command prints a 2D integer array defined in the example program: | ||
|
|
||
| ``` | ||
| fpm run --example pure-stop-and-print --compiler flang -- --array | ||
| ``` | ||
|
|
||
| ### Printing a derived type | ||
| The following command prints the derived type defined in this directory's | ||
| [write_stuff_m](./write_stuff_m.F90)) module: | ||
|
|
||
| ``` | ||
| fpm run --example pure-stop-and-print --compiler flang -- --derived-type | ||
| ``` | ||
|
|
||
| using the derived-type output procedure in the [write_stuff_s](./write_stuff_s.F90)) | ||
| submodule. | ||
|
|
||
| ### Printing a text file | ||
|
|
||
| The following command prints this repository's `fpm` manifest: `fpm.toml`. | ||
|
|
||
| ``` | ||
| fpm run --example pure-stop-and-print --compiler flang -- --file fpm.toml | ||
| ``` |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| ! Copyright (c) 2024-2026, The Regents of the University of California and Sourcery Institute | ||
| ! Terms of use are as specified in LICENSE.txt | ||
|
|
||
| #include "language-support.F90" | ||
|
|
||
| program pure_stop_and_print | ||
| #if HAVE_STOP_AND_PRINT_SUPPORT | ||
| !! Demonstrate Julienne's support for printing during error termination inside pure procedures | ||
| use julienne_m, only : & | ||
| command_line_t & | ||
| ,file_t & | ||
| ,stop_and_print & | ||
| ,string_t | ||
| use write_stuff_m, only : write_stuff_t | ||
| implicit none | ||
|
|
||
| type(command_line_t) command_line | ||
| character(len=:), allocatable :: stop_code, file_name | ||
|
|
||
| stop_code = usage_info() | ||
| if ( command_line%string_argument_present( [string_t("--help"), string_t("-h") ] )) stop stop_code | ||
| if (.not. command_line%string_argument_present( [string_t("--file"), string_t("--array"), string_t("--derived-type")] )) error stop stop_code | ||
|
|
||
| file_name = command_line%flag_value("--file") | ||
| if (len(file_name) > 0) then | ||
| call pure_subroutine(.false., .false., file_t(file_name)) | ||
| end if | ||
| call pure_subroutine(command_line%argument_present(["--array"]), command_line%argument_present(["--derived-type"])) | ||
|
|
||
| contains | ||
|
|
||
| pure subroutine pure_subroutine(print_array, print_derived_type, file) | ||
| logical, intent(in) :: print_array, print_derived_type | ||
| type(file_t), intent(in), optional :: file | ||
| if (present(file)) call stop_and_print(header = "______________", data = file, footer = "______________") | ||
| if (print_array) call stop_and_print(reshape([111,211,121,221, 112,212,122,222], [2,2,2])) | ||
| if (print_derived_type) call stop_and_print(write_stuff_t()) | ||
| end subroutine | ||
|
|
||
| pure function usage_info() result(message) | ||
| character(len=:), allocatable :: message | ||
| message = new_line('') // new_line('') & | ||
| // 'Usage:' // new_line('') // new_line('') & | ||
| // ' fpm run \' // new_line('') & | ||
| // ' --example pure-stop-and-print \' // new_line('') & | ||
| // ' --compiler flang --profile release \' // new_line('') & | ||
| // ' -- [-h|--help] | [--file <name>] | [--array] | [--derived-type]' // new_line('') // new_line('') & | ||
| // 'where pipes (|) separate alternatives, square brackets ([]) delimit' // new_line('') & | ||
| // 'optional arguments, and angular brackets (<>) delimit user input.' // new_line('') | ||
| end function | ||
|
|
||
| #else | ||
| error stop "Julienne's stop_and_print feature is not supported on this compiler" | ||
| #endif | ||
| end program pure_stop_and_print |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ! Copyright (c) 2024-2026, The Regents of the University of California and Sourcery Institute | ||
| ! Terms of use are as specified in LICENSE.txt | ||
|
|
||
| #include "language-support.F90" | ||
|
|
||
| #if HAVE_STOP_AND_PRINT_SUPPORT | ||
| module write_stuff_m | ||
| !! Demonstrate a derived type that is writable to a stop via Julienne's stop_and_print utility | ||
| use julienne_m, only : writable_t | ||
| implicit none | ||
|
|
||
| type, extends(writable_t) :: write_stuff_t | ||
| integer :: answer_ = 42 | ||
| contains | ||
| procedure :: write_formatted | ||
| end type | ||
|
|
||
| interface | ||
|
|
||
| module subroutine write_formatted(self, unit, edit_descriptor, v_list, iostat, iomsg) | ||
| class(write_stuff_t), intent(in) :: self | ||
| integer, intent(in) :: unit | ||
| character(len=*), intent(in) :: edit_descriptor | ||
| integer, intent(in) :: v_list(:) | ||
| integer, intent(out) :: iostat | ||
| character(len=*), intent(inout) :: iomsg | ||
|
rouson marked this conversation as resolved.
|
||
| end subroutine | ||
|
|
||
| end interface | ||
|
|
||
| end module | ||
| #endif | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ! Copyright (c) 2024-2026, The Regents of the University of California and Sourcery Institute | ||
| ! Terms of use are as specified in LICENSE.txt | ||
|
|
||
| #include "language-support.F90" | ||
|
|
||
| #if HAVE_STOP_AND_PRINT_SUPPORT | ||
| submodule(write_stuff_m) write_stuff_s | ||
| implicit none | ||
|
|
||
| contains | ||
|
|
||
| module procedure write_formatted | ||
| write(unit,'(a)' ) new_line('') | ||
| write(unit,'(a)' ) "write_stuff_t {" // new_line('') | ||
| write(unit,'(a,i2,a)') " answer = ", self%answer_, new_line('') | ||
| write(unit,'(a)' ) "}" // new_line('') | ||
| iostat = 0 | ||
| end procedure | ||
|
|
||
| end submodule | ||
| #endif |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.