You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_io.md
+127
Original file line number
Diff line number
Diff line change
@@ -131,3 +131,130 @@ program demo_savetxt
131
131
call savetxt('example.dat', x)
132
132
end program demo_savetxt
133
133
```
134
+
135
+
## `disp` - display your data
136
+
137
+
### Status
138
+
139
+
Experimental
140
+
141
+
### Class
142
+
143
+
Impure subroutine.
144
+
145
+
### Description
146
+
147
+
Outputs a `logical/integer/real/complex/character/string_type` scalar or `logical/integer/real/complex` and rank-1/rank-2 array to the screen or a file `unit`.
148
+
149
+
#### More details
150
+
151
+
```fortran
152
+
call disp( A(i, j, 2, :, 1:10) [, header, unit, brief] ) !! `i, j, ...` can be determined by `do` loop.
153
+
```
154
+
155
+
For `complex` type, the output format is `*(A25, 1X)`;
156
+
For other types, the output format is `*(A12, 1X)`.
157
+
158
+
To prevent users from accidentally passing large-length arrays to `disp`, causing unnecessary io blockage:
159
+
1. If the `brief` argument is not specified, `disp` will print **the brief array content with a length of `10*50` by default**.
160
+
2. Specify `brief=.true.`, `disp` will print **the brief array content with a length of `5*5`**;
161
+
3. Specify `brief=.false.`, `disp` will print **`all` the contents of the array**.
162
+
163
+
### Syntax
164
+
165
+
`call [[stdlib_io(module):disp(interface)]]([x, header, unit, brief])`
166
+
167
+
### Arguments
168
+
169
+
`x`: Shall be a `logical/integer/real/complex/string_type` scalar or `logical/integer/real/complex` and rank-1/rank-2 array.
170
+
This argument is `intent(in)` and `optional`.
171
+
172
+
`header`: Shall be a `character(len=*)` scalar.
173
+
This argument is `intent(in)` and `optional`.
174
+
175
+
`unit`: Shall be an `integer` scalar linked to an IO stream.
176
+
This argument is `intent(in)` and `optional`.
177
+
178
+
`brief`: Shall be a `logical` scalar.
179
+
This argument is `intent(in)` and `optional`.
180
+
Controls an abridged version of the `x` object is printed.
181
+
182
+
### Output
183
+
184
+
The result is to print `header` and `x` on the screen (or another output `unit/file`) in this order.
185
+
If `x` is a rank-1/rank-2 `array` type, the dimension length information of the `array` will also be outputted.
186
+
187
+
If `disp` is not passed any arguments, a blank line is printed.
188
+
189
+
If the `x` is present and of `real/complex` type, the data will retain four significant decimal places, like `(g0.4)`.
0 commit comments