-
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
18
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
18 commits
Select commit
Hold shift + click to select a range
b643a0a
feat(stop_and_print): print string_t in pure procs
rouson 274bfd6
feat: mk stop_and_print generic
rouson 7d77843
test(character_stop_code): 1D integer array passes
rouson 57806be
test(character_stop_code): check comma count
rouson cc07246
fix(character_stop_code): rm extraneous commas
rouson 480acf7
test(character_stop_code): 2D integer array passes
rouson 9b32f8c
test(character_stop_code): 2D/3D real/integer arrays
rouson ff9102d
test(character_stop_code): 1D complex array
rouson 0683491
test(character_stop_code): {1,2,3}D dble prec arrays
rouson aed7e2b
build/test(print_and_stop): gfortran workarounds
rouson 4f1a41f
feat(stop_and_print): support 1D string_t arrays
rouson dd3c815
feat(file_t): add from_character_lines constructor
rouson 404da03
feat(character_stop_code): support file_t
rouson 79afcc2
refac(julienne_m): rm character_stop_code
rouson a08eec3
feat(character_stop_code): support derived types
rouson b053b88
fix: skip 3 tests that crash with gfortran
rouson b6a7f80
refac(stop_and_print): split {sub,}module
rouson ba844c9
doc(README): describe output in pure procedures
rouson 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,75 @@ | ||
| ! Copyright (c), The Regents of the University of California and Sourcery Institute | ||
| ! Terms of use are as specified in LICENSE.txt | ||
|
|
||
| module julienne_stop_and_print_m | ||
| !! Define a pure subroutine that formats and prints various data types during error termination | ||
| use julienne_string_m, only : string_t | ||
| implicit none | ||
|
|
||
| private | ||
| public :: stop_and_print | ||
| public :: writable_t | ||
| public :: character_stop_code | ||
|
|
||
| type, abstract :: writable_t | ||
| private | ||
| integer :: maxlen_ = 16384 | ||
| contains | ||
| generic :: write(formatted) => write_formatted | ||
| procedure(write_formatted_i), deferred :: write_formatted | ||
| procedure :: set_maxlen | ||
| procedure :: maxlen | ||
| end type | ||
|
|
||
| abstract interface | ||
|
|
||
| subroutine write_formatted_i(self, unit, edit_descriptor, v_list, iostat, iomsg) | ||
| import writable_t | ||
| class(writable_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 | ||
| end subroutine | ||
|
|
||
| end interface | ||
|
|
||
| interface stop_and_print | ||
|
|
||
| pure module subroutine stop_and_print_string(message) | ||
| implicit none | ||
| type(string_t), intent(in) :: message | ||
| end subroutine | ||
|
|
||
| pure module subroutine stop_and_print_header_and_data(header, data) | ||
| implicit none | ||
| character(len=*), intent(in) :: header | ||
| class(*), intent(in) :: data | ||
| end subroutine | ||
|
|
||
| end interface | ||
|
|
||
| interface | ||
|
|
||
| pure module subroutine set_maxlen(self, length) | ||
| implicit none | ||
| class(writable_t), intent(inout) :: self | ||
| integer, intent(in) :: length | ||
| end subroutine | ||
|
|
||
| pure module function maxlen(self) result(length) | ||
| implicit none | ||
| class(writable_t), intent(in) :: self | ||
| integer length | ||
| end function | ||
|
|
||
| pure module function character_stop_code(stuff) result(stop_code) | ||
| implicit none | ||
| class(*), intent(in) :: stuff(..) | ||
| character(len=:), allocatable :: stop_code | ||
| end function | ||
|
|
||
| end interface | ||
|
|
||
| end module julienne_stop_and_print_m |
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,142 @@ | ||
| ! Copyright (c), The Regents of the University of California and Sourcery Institute | ||
| ! Terms of use are as specified in LICENSE.txt | ||
|
|
||
| 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 | ||
| implicit none | ||
|
|
||
| contains | ||
|
|
||
| module procedure stop_and_print_string | ||
| error stop message%string() | ||
| end procedure | ||
|
|
||
| module procedure set_maxlen | ||
| self%maxlen_ = length | ||
| end procedure | ||
|
|
||
| module procedure maxlen | ||
| length = self%maxlen_ | ||
| end procedure | ||
|
|
||
| module procedure stop_and_print_header_and_data | ||
| #ifndef __GFORTRAN__ | ||
| error stop new_line('') // header // new_line('') // character_stop_code(data) | ||
| #else | ||
| block | ||
| character(len=:), allocatable :: code | ||
| code = new_line('') // header // new_line('') // character_stop_code(data) | ||
| error stop code | ||
| end block | ||
| #endif | ||
| end procedure | ||
|
|
||
| module procedure character_stop_code | ||
|
|
||
| type(string_t) stringy_stuff | ||
| integer row, page | ||
|
|
||
| select rank(stuff) | ||
| rank(0) | ||
| select type(stuff) | ||
| type is(character(len=*)) | ||
| stringy_stuff = stuff | ||
| type is(complex) | ||
| stringy_stuff = string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(double precision) | ||
| stringy_stuff = string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(file_t) | ||
| stringy_stuff = stuff%lines() .separatedBy. new_line('') | ||
| stop_code = stringy_stuff%string() | ||
| type is(integer) | ||
| stringy_stuff = string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(real) | ||
| stringy_stuff = string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| class is(string_t) | ||
| stop_code = stuff%string() | ||
| class is(writable_t) | ||
| allocate(character(len=stuff%maxlen()) :: stop_code) | ||
| block | ||
| integer io_status | ||
| write(stop_code,*,iostat=io_status) stuff | ||
| associate(code_maxlen => string_t(stuff%maxlen())) | ||
| if (io_status /= 0) error stop "Call writable_t's set_maxlen procedure to increase stop_code maximum size above " // code_maxlen%string() | ||
| end associate | ||
| end block | ||
| stop_code = trim(stop_code) | ||
| class default | ||
| error stop "character_stop_code (in print_and_stop_s): unsupported stop-code type for scalar" | ||
| end select | ||
| rank(1) | ||
| select type(stuff) | ||
| type is(character(len=*)) | ||
| stringy_stuff = .csv. string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(complex) | ||
| stringy_stuff = .csv. string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(double precision) | ||
| stringy_stuff = .csv. string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(integer) | ||
| stringy_stuff = .csv. string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| type is(real) | ||
| stringy_stuff = .csv. string_t(stuff) | ||
| stop_code = stringy_stuff%string() | ||
| class is(string_t) | ||
| stringy_stuff = .csv. stuff | ||
| stop_code = stringy_stuff%string() | ||
| class default | ||
| error stop "character_stop_code (in print_and_stop_s): unsupported stop-code type for rank-1 array" | ||
| end select | ||
| rank(2) | ||
| select type(stuff) | ||
| type is(character(len=*)) | ||
| stringy_stuff = [(.csv. string_t(stuff(row,:)) , row=1,size(stuff,1))] .separatedBy. new_line('') | ||
| stop_code = stringy_stuff%string() | ||
| type is(complex) | ||
| stringy_stuff = [(.csv. string_t(stuff(row,:)) , row=1,size(stuff,1))] .separatedBy. new_line('') | ||
| stop_code = stringy_stuff%string() | ||
| type is(double precision) | ||
| stringy_stuff = [(.csv. string_t(stuff(row,:)) , row=1,size(stuff,1))] .separatedBy. new_line('') | ||
| stop_code = stringy_stuff%string() | ||
| type is(integer) | ||
| stringy_stuff = [(.csv. string_t(stuff(row,:)) , row=1,size(stuff,1))] .separatedBy. new_line('') | ||
| stop_code = stringy_stuff%string() | ||
| type is(real) | ||
| stringy_stuff = [(.csv. string_t(stuff(row,:)) , row=1,size(stuff,1))] .separatedBy. new_line('') | ||
| stop_code = stringy_stuff%string() | ||
| class default | ||
| error stop "character_stop_code (in print_and_stop_s): unsupported stop-code type for rank-2 array" | ||
| end select | ||
| rank(3) | ||
| select type(stuff) | ||
| type is(complex) | ||
| stringy_stuff = [( [(.csv. string_t(stuff(row,:,page)) , row=1,size(stuff,1))] .separatedBy. new_line(''), page = 1,size(stuff,3) )] .separatedBy. (new_line('') // new_line('')) | ||
| stop_code = stringy_stuff%string() | ||
| type is(double precision) | ||
| stringy_stuff = [( [(.csv. string_t(stuff(row,:,page)) , row=1,size(stuff,1))] .separatedBy. new_line(''), page = 1,size(stuff,3) )] .separatedBy. (new_line('') // new_line('')) | ||
| stop_code = stringy_stuff%string() | ||
| type is(integer) | ||
| stringy_stuff = [( [(.csv. string_t(stuff(row,:,page)) , row=1,size(stuff,1))] .separatedBy. new_line(''), page = 1,size(stuff,3) )] .separatedBy. (new_line('') // new_line('')) | ||
| stop_code = stringy_stuff%string() | ||
| type is(real) | ||
| stringy_stuff = [( [(.csv. string_t(stuff(row,:,page)) , row=1,size(stuff,1))] .separatedBy. new_line(''), page = 1,size(stuff,3) )] .separatedBy. (new_line('') // new_line('')) | ||
| stop_code = stringy_stuff%string() | ||
| class default | ||
| error stop "character_stop_code (in print_and_stop_s): unsupported stop-code type for rank-3 array" | ||
| end select | ||
| rank default | ||
| associate(stop_code_rank => string_t(stop_code)) | ||
| error stop "character_stop_code (in print_and_stop_s): unsupported stop-code rank: " // stop_code_rank%string() | ||
| end associate | ||
| end select | ||
| end procedure | ||
|
|
||
| end submodule julienne_stop_and_print_s |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Julienne library code should never call
error stopdirectly.Every new
error stopin this file should please be replaced withinternal_error_stop