[stdlib_io] add disp(display variable values formatted).#520
[stdlib_io] add disp(display variable values formatted).#520zoziha wants to merge 8 commits intofortran-lang:masterfrom
disp(display variable values formatted).#520Conversation
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.
Why not array of characters or of string_type?
There was a problem hiding this comment.
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.
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.
| #! width have to be greater than or equal 80 by default | |
| #! width have to be greater than or equal to 80 by default |
jvdp1
left a comment
There was a problem hiding this comment.
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.
| - `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.
| 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.
| 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.
| - `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.
| 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. |
|
|
||
| ### 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.
| 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.
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.
| !> ([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.
Why "two spaces" instead of "one space"?
|
Looking back at the content of this PR, it is rather complex and cumbersome. Now it will be migrated to #981 to continue, and this PR will be closed. |
disp.Note: Because
dispis 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
unitwith aheader. (more detail)Example:
Prior Art
Notes
dispis 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.