-
Notifications
You must be signed in to change notification settings - Fork 173
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
[stdlib_io] add disp
(display variable values formatted).
#520
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.
Thank you for this PR. Here are some comments on the specs.
doc/specs/stdlib_io.md
Outdated
|
||
### Arguments | ||
|
||
`x`: Shall be a `logical/integer/real/complex/string_type` scalar or `logical/integer/real/complex` and rank-1/rank-2 array. |
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.
Why not array of characters or of string_type?
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.
The character length of array of string_type
is often uncertain, and it is difficult to print them uniformly.
And we already have stringlist
, its internal elements are private, and the outside is inaccessible.
(see stdlib_stringlist_type.f90#L52~L54)
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.
Support for string_type
type is added: string_type
scalar, rank-1/rank-2 array.
Only character(*)
scalar is supported, string_type
array should be more easy to use than character(*)
array.
:)
disp
(display your data).disp
(display variable values formatted).
I redesigned and updated the internal implementation of Questions
Thank you :) |
brief_ = optval(brief, .false.) | ||
format_ = optval(format, "g0.4") | ||
|
||
#! width have to be greater than or equal 80 by default |
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.
#! width have to be greater than or equal 80 by default | |
#! width have to be greater than or equal to 80 by default |
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 for this proposition. Here are some comments.
Regarding the tests, I guess that they should be moved to support the test-drive
features, introduced recently in stdlib. However, since this PR is open since a while, I would understand that you would prefer to not do it.
- `x`: Shall be a `logical/integer/real/complex/character(len=*)/string_type` scalar or `logical/integer/real/complex/string_type` and rank-1/rank-2 array. | ||
This argument is `intent(in)` and `optional`. | ||
|
||
- `header`: Shall be a `character(len=*)` scalar. |
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.
- `header`: Shall be a `character(len=*)` scalar. | |
- `header`: Shall be a `character` scalar. |
This argument is `intent(in)` and `optional`. | ||
|
||
- `unit`: Shall be an `integer` scalar, linked to an IO stream. | ||
This argument is `intent(in)` and `optional`.<br> |
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.
This argument is `intent(in)` and `optional`.<br> | |
This argument is `intent(in)` and `optional`. |
The default value is `output_unit` from `iso_fortran_env` module. | ||
|
||
- `brief`: Shall be a `logical` scalar, controls an abridged version of the `x` array to be outputted. | ||
This argument is `intent(in)` and `optional`.<br> |
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.
This argument is `intent(in)` and `optional`.<br> | |
This argument is `intent(in)` and `optional`. |
This argument is `intent(in)` and `optional`.<br> | ||
The default value is `.false.` | ||
|
||
- `format`: Shall be a `character(len=*)` scalar. |
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.
- `format`: Shall be a `character(len=*)` scalar. | |
- `format`: Shall be a `character` scalar. |
The default value is `.false.` | ||
|
||
- `format`: Shall be a `character(len=*)` scalar. | ||
This argument is `intent(in)` and `optional`.<br> |
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.
This argument is `intent(in)` and `optional`.<br> | |
This argument is `intent(in)` and `optional`. |
|
||
- `sep`: Shall be a `character(len=*)` scalar, separator. | ||
This argument is `intent(in)` and `optional`.<br> | ||
The default value is "  ", two spaces. |
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 do you mean by two spaces
?
|
||
### Output | ||
|
||
The result is to print `header` and `x` on the screen (or another output `unit/file`) in this order.<br> |
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.
The result is to print `header` and `x` on the screen (or another output `unit/file`) in this order.<br> | |
The result is to print `header` and `x` on the screen (or another output `unit/file`) in this order. |
|
||
### Example | ||
|
||
```fortran |
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.
I suggest to reduce the example. One or two disp
should be enough for the reader to understand its aim.
!> version: experimental | ||
!> | ||
!> Display a scalar, vector or matrix formatted. | ||
!> ([Specification](../page/specs/stdlib_io.html#display-the-value-of-the-variable)) |
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.
!> ([Specification](../page/specs/stdlib_io.html#display-the-value-of-the-variable)) | |
!> ([Specification](../page/specs/stdlib_io.html#disp-display-the-value-of-the-variable)) |
width_ = optval(width, 80) | ||
width_ = merge(width_, 80, width_ > 80) | ||
|
||
sep_ = optval(sep, " ") |
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.
Why "two spaces" instead of "one space"?
disp
.Note: Because
disp
is a very important IO routine, I hope it will be discussed and approved more widely before it is adopted.Description
Print your data to a output
unit
with aheader
. (more detail)Example:
Prior Art
Notes
disp
is the first routine I submitted tostdlib
, because the original PR discussion became very long and not suitable for review (see #445).And I resubmitted this PR now.