-
Notifications
You must be signed in to change notification settings - Fork 185
stdlib_io: add print_array
function to print arrays to output units
#981
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This pull request adds a new subroutine specification, print_array, to the stdlib_io module for printing 2D arrays to an output unit.
- Introduces detailed documentation covering the subroutine’s syntax, argument descriptions, and an example.
- Specifies default behaviors for output unit, delimiter, format, and brief mode.
Files not reviewed (7)
- example/io/CMakeLists.txt: Language not supported
- example/io/example_print_array.f90: Language not supported
- src/CMakeLists.txt: Language not supported
- src/stdlib_io.fypp: Language not supported
- src/stdlib_io_print_array.fypp: Language not supported
- test/io/CMakeLists.txt: Language not supported
- test/io/test_print_array.f90: Language not supported
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.
Thank you @zoziha . Here are some minor comments.
doc/specs/stdlib_io.md
Outdated
|
||
`delimiter`: Shall be a character string of length 1 containing the delimiter between array elements. It is an `intent(in)` argument. The default is a `" "` (space). | ||
|
||
`brief`: Shall be a logical flag. If `.true.`, the array is printed in a brief format. The default is `.true.`. |
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.
what is a "brief" format? Could you maybe provide a short definition?
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.
Okay. Details of the "brief" format were added, and an example was deliberately provided to illustrate the usage of the "brief" format.
@@ -305,3 +305,38 @@ Exceptions trigger an `error stop` unless the optional `err` argument is provide | |||
{!example/io/example_get_file.f90!} | |||
``` | |||
|
|||
## `print_array` - Print an array to an output unit |
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.
Minor comment: the name could be discussed with the community. Personally, I would prefer disp
.
Description
Add
print_array
subroutine, which is used to print two-dimensional arrays of integer and floating-point types. These two types are more commonly used in Fortran. It supports arguments such as delimiter, output unit, output format, and whether to print briefly.In the non-brief output mode, the print_array function can produce an output result style similar to that of
savetxt
in stdlib_io. The print_array function is mainly convenient for users to output to the screen (standard output) and is likely to be mostly used for code debugging.Prior Art:
This PR will replace #520, and is related to #40, but is not sufficient to close #40.
Remaining to be discussed
print_array
, it also includes thesavetxt
routine in stdlib_io.