ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_io::getErrTableRead Interface Reference

Generate and return the iostat code resulting from reading the contents of the specified file or unit into an output table.
More...

Detailed Description

Generate and return the iostat code resulting from reading the contents of the specified file or unit into an output table.

Parameters
[in]file: The input scalar character of default kind SK representing the path to the external file to which the table must be read.
If the specified file does not exist, it will be created.
If it exists or is already connected, it will repositioned before the beginning of its first record.
(optional. It can be present only if the input argument unit is missing.)
[in]unit: The input scalar integer of default kind IK representing the preconnected (opened) file unit to which the table must be read.
The writing will begin from the current file position plus the input roff.
(optional. It can be present only if the input argument file is missing.)
[out]table: The output allocatable array of shape (:) or (:,:) of either
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of predefined length type parameter (not deferred-length), or
  2. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64), or
  3. type logical of kind any supported by the processor (e.g., LK), or
  4. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128), or
  5. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
representing the data table to be read from the specified input.
By default a table of rank 1 is considered to be a single column unless the input optional argument operation is set to trans in which case table is considered as a row of fields.
See the tips in the note below for reading tables of complex values written in the Fortran list-directed format.
By default, if the input argument operation is missing, each column of table corresponds to each column of data in the file.
[in]operation: The input scalar constant that can be:
  1. the scalar constant trans or a scalar object of type trans_type, implying that the input table must be transposed before being written to the output file.
    This option is particularly useful for inputting rows of table in Fortran column-major storage mode, that is, rows of table occupy the first dimension of the matrix table such that rows of data in the output file are stored contiguously in memory.
    Use this option if you intend to work with rows more so than with individual columns.
(optional, default = nothing, implying that the table must be output as is.)
[out]header: The output allocatable scalar character of default kind SK of arbitrary length type parameter containing the table header.
The output table header can be subsequently split into fields by passing header and sep to the generic interface setSplit.
If the table in file contains a header, but header argument is missing, then roff must be set to at least 1 to gracefully skip the header line.
(optional, If missing, no header will be read from the specified input.
The generic interface getStr() can be used to readily join a list of header fields with the appropriate separator.)
[in]sep: The input scalar character of default kind SK of arbitrary length type parameter containing the separator of the fields of each of row of the table in the input file.
An empty input sep implies that there is only a single column in the file.
(optional, default = , or (blank).)
[in]roff: The input scalar integer of default kind IK representing the row offset, that is, the number of rows in the external file or unit to skip before beginning to read the output variables header and table.
(optional. default = 0)
[in,out]iomsg: The input/output scalar character of default kind SK containing the error message, if any error occurs.
A length type parameter value of LEN_IOMSG is generally sufficient for iomsg to contain the output error messages.
(optional. If missing, no information other than the output error code err will be returned.)
Returns
err : The output scalar integer of default kind IK containing the iostat error code returned by the Fortran intrinsic write() statement.
On return, err is set to 0 if and only if the table is successfully read from the input.
See the Fortran standard and specific compiler documentations for the possible meanings of the output err.


Possible calling interfaces

use pm_kind, only: IK
integer(IK) :: err
err = getErrTableRead(unit, table, header = header, sep = sep, roff = roff, iomsg = iomsg)
err = getErrTableRead(file, table, header = header, sep = sep, roff = roff, iomsg = iomsg)
err = getErrTableRead(unit, table, operation, header = header, sep = sep, roff = roff, iomsg = iomsg)
err = getErrTableRead(file, table, operation, header = header, sep = sep, roff = roff, iomsg = iomsg)
!
Generate and return the iostat code resulting from reading the contents of the specified file or unit...
Definition: pm_io.F90:2390
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
Remarks
The procedures under discussion are impure.
Note
For table of type complex, it is best to either
  1. have the complex table fields in the file in Fortran list-directed format (.,.) and drop the sep input argument to activate the default intrinsic [Fortran list-directed parser, or
  2. have the complex table fields in the file written as if real and imaginary components are independent table fields and specify the sep argument to activate the customized parser to read the table.
Otherwise,
  1. if the file is in Fortran list-directed format and sep is present or,
  2. if the file is in csv format or similar and sep is missing,
The table read action will fail.
If so, the algorithm will try to read the table again by reading it with the alternative parser before completely failing and returning a non-zero code.
Developer Remark:
The naming choice sep over delim or similar is deliberate.
While many resources consider separator and delimiter identical, it is more sensible to consider delimiter as a character set that determines what belong to a field, and separator as a character set that separates different fields from each other.
This convention is also consistent with the Fortran standard terminology where delimiters are referred to as delimiters.
See also
getRecordFrom
setRecordFrom
getContentsFrom
setContentsFrom
getErrTableRead
getErrTableWrite


Example usage

1program example
2
3 use iso_fortran_env, only: output_unit, input_unit, error_unit
4 use pm_kind, only: SK, IK, LK
5 use pm_io, only: display_type
6 use pm_io, only: LEN_IOMSG, trans
7 use pm_io, only: getErrTableWrite
8 use pm_io, only: getErrTableRead
9 use pm_io, only: getContentsFrom
10 use pm_distUnif, only: getUnifRand
11
12 implicit none
13
14 character(LEN_IOMSG, SK) :: iomsg
15 character(:, SK), allocatable :: file, header
16 type(display_type) :: disp
17
18 disp = display_type(file = "main.out.F90")
19
20 block
21 use pm_kind, only: SKG => SK
22 character(2,SKG), allocatable :: table(:,:)
23 call disp%skip
24 call disp%show("table = getUnifRand('aa', 'zz', 3_IK, 6_IK)")
25 table = getUnifRand('aa', 'zz', 3_IK, 6_IK)
26 call disp%show("table")
27 call disp%show( table , deliml = SK_"""" )
28 call disp%show("file = 'temp.temp'")
29 file = 'temp.temp'
30 call disp%show("if (0 /= getErrTableWrite(file, table, deliml = SKG_'''')) error stop 'table write failed.'")
31 if (0 /= getErrTableWrite(file, table, deliml = SKG_'''')) error stop 'table write failed.'
32 call disp%show("deallocate(table)")
33 deallocate(table)
34 call disp%show("if (0 /= getErrTableRead(file, table)) error stop 'table write failed.'")
35 if (0 /= getErrTableRead(file, table)) error stop 'table write failed.'
36 call disp%show("table")
37 call disp%show( table , deliml = SK_"""" )
38 call disp%skip
39 end block
40
41 block
42 use pm_kind, only: IKG => IK
43 integer(IKG), allocatable :: table(:,:)
44 call disp%skip
45 call disp%show("table = getUnifRand(-1, 1, 4_IK, 2_IK)")
46 table = getUnifRand(-1, 1, 4_IK, 2_IK)
47 call disp%show("table")
48 call disp%show( table )
49 call disp%show("file = 'temp.temp'")
50 file = 'temp.temp'
51 call disp%show("if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'")
52 if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
53 call disp%show("deallocate(table)")
54 deallocate(table)
55 call disp%show("if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'")
56 if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
57 call disp%show("header")
58 call disp%show( header , deliml = SK_"""" )
59 call disp%show("table")
60 call disp%show( table )
61 call disp%show("deallocate(table)")
62 deallocate(table)
63 call disp%show("if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'")
64 if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
65 call disp%show("header")
66 call disp%show( header , deliml = SK_"""" )
67 call disp%show("table")
68 call disp%show( table )
69 call disp%skip
70 call disp%show("if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'")
71 if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
72 call disp%show("deallocate(table)")
73 deallocate(table)
74 call disp%show("if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK, iomsg = iomsg)) error stop trim(iomsg)")
75 if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK, iomsg = iomsg)) error stop trim(iomsg)
76 call disp%show("table")
77 call disp%show( table )
78 call disp%show("deallocate(table)")
79 deallocate(table)
80 call disp%show("if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'")
81 if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
82 call disp%show("header")
83 call disp%show( header , deliml = SK_"""" )
84 call disp%show("table")
85 call disp%show( table )
86 call disp%skip
87 end block
88
89 block
90 use pm_kind, only: LKG => LK
91 logical(LKG), allocatable :: table(:,:)
92 call disp%skip
93 call disp%show("table = getUnifRand(.false., .true., 4_IK, 2_IK)")
94 table = getUnifRand(.false., .true., 4_IK, 2_IK)
95 call disp%show("table")
96 call disp%show( table )
97 call disp%show("file = 'temp.temp'")
98 file = 'temp.temp'
99 call disp%show("if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'")
100 if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
101 call disp%show("deallocate(table)")
102 deallocate(table)
103 call disp%show("if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'")
104 if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
105 call disp%show("header")
106 call disp%show( header , deliml = SK_"""" )
107 call disp%show("table")
108 call disp%show( table )
109 call disp%show("deallocate(table)")
110 deallocate(table)
111 call disp%show("if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'")
112 if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
113 call disp%show("header")
114 call disp%show( header , deliml = SK_"""" )
115 call disp%show("table")
116 call disp%show( table )
117 call disp%skip
118 call disp%show("if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'")
119 if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
120 call disp%show("deallocate(table)")
121 deallocate(table)
122 call disp%show("if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'")
123 if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
124 call disp%show("table")
125 call disp%show( table )
126 call disp%show("deallocate(table)")
127 deallocate(table)
128 call disp%show("if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'")
129 if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
130 call disp%show("header")
131 call disp%show( header , deliml = SK_"""" )
132 call disp%show("table")
133 call disp%show( table )
134 call disp%skip
135 end block
136
137 block
138 use pm_kind, only: CKG => CKS
139 complex(CKG), allocatable :: table(:,:)
140 call disp%skip
141 call disp%show("table = getUnifRand((-1., -1.), (+1., +1.), 4_IK, 2_IK)")
142 table = getUnifRand((-1., -1.), (+1., +1.), 4_IK, 2_IK)
143 call disp%show("table")
144 call disp%show( table )
145 call disp%show("file = 'temp.temp'")
146 file = 'temp.temp'
147 call disp%show("if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'")
148 if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
149 call disp%show("deallocate(table)")
150 deallocate(table)
151 call disp%show("if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'")
152 if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
153 call disp%show("header")
154 call disp%show( header , deliml = SK_"""" )
155 call disp%show("table")
156 call disp%show( table )
157 call disp%show("deallocate(table)")
158 deallocate(table)
159 call disp%show("if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'")
160 if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
161 call disp%show("header")
162 call disp%show( header , deliml = SK_"""" )
163 call disp%show("table")
164 call disp%show( table )
165 call disp%skip
166 call disp%show("if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'")
167 if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
168 call disp%show("deallocate(table)")
169 deallocate(table)
170 call disp%show("if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK, iomsg = iomsg)) error stop trim(iomsg)")
171 if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK, iomsg = iomsg)) error stop trim(iomsg)
172 call disp%show("table")
173 call disp%show( table )
174 call disp%show("deallocate(table)")
175 deallocate(table)
176 call disp%show("if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'")
177 if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
178 call disp%show("header")
179 call disp%show( header , deliml = SK_"""" )
180 call disp%show("table")
181 call disp%show( table )
182 call disp%skip
183 end block
184
185 block
186 use pm_kind, only: RKG => RKS
187 real(RKG), allocatable :: table(:,:)
188 call disp%skip
189 call disp%show("table = getUnifRand(-1, 1, 4_IK, 2_IK)")
190 table = getUnifRand(-1, 1, 4_IK, 2_IK)
191 call disp%show("table")
192 call disp%show( table )
193 call disp%show("file = 'temp.temp'")
194 file = 'temp.temp'
195 call disp%show("if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'")
196 if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
197 call disp%show("deallocate(table)")
198 deallocate(table)
199 call disp%show("if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'")
200 if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
201 call disp%show("header")
202 call disp%show( header , deliml = SK_"""" )
203 call disp%show("table")
204 call disp%show( table )
205 call disp%show("deallocate(table)")
206 deallocate(table)
207 call disp%show("if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'")
208 if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
209 call disp%show("header")
210 call disp%show( header , deliml = SK_"""" )
211 call disp%show("table")
212 call disp%show( table )
213 call disp%skip
214 call disp%show("if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'")
215 if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
216 call disp%show("deallocate(table)")
217 deallocate(table)
218 call disp%show("if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'")
219 if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
220 call disp%show("table")
221 call disp%show( table )
222 call disp%show("deallocate(table)")
223 deallocate(table)
224 call disp%show("if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'")
225 if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
226 call disp%show("header")
227 call disp%show( header , deliml = SK_"""" )
228 call disp%show("table")
229 call disp%show( table )
230 call disp%skip
231 end block
232
233end program example
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
Generate and return the entire contents of the input unconnected file or the (remaining) contents of ...
Definition: pm_io.F90:1586
Generate and return the iostat code resulting from writing the input table of rank 1 or 2 to the spec...
Definition: pm_io.F90:5940
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for computing various statistical quantities related to t...
integer(IK), parameter LEN_IOMSG
The scalar integer of default kind IK representing the maximum length of an IO error message returned...
Definition: pm_io.F90:401
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter CKS
The single-precision complex kind in Fortran mode. On most platforms, this is a 32-bit real kind.
Definition: pm_kind.F90:570
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Definition: pm_kind.F90:567
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2table = getUnifRand('aa', 'zz', 3_IK, 6_IK)
3table
4"te", "qy", "tj", "cn", "ys", "nr"
5"ic", "tq", "hf", "jh", "eu", "ya"
6"cg", "hk", "ns", "kg", "rd", "aq"
7file = 'temp.temp'
8if (0 /= getErrTableWrite(file, table, deliml = SKG_'''')) error stop 'table write failed.'
9deallocate(table)
10if (0 /= getErrTableRead(file, table)) error stop 'table write failed.'
11table
12"te", "qy", "tj", "cn", "ys", "nr"
13"ic", "tq", "hf", "jh", "eu", "ya"
14"cg", "hk", "ns", "kg", "rd", "aq"
15
16
17table = getUnifRand(-1, 1, 4_IK, 2_IK)
18table
19+0, -1
20+0, -1
21+0, +0
22+1, -1
23file = 'temp.temp'
24if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
25deallocate(table)
26if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
27header
28"col1 col2"
29table
30+0, -1
31+0, -1
32+0, +0
33+1, -1
34deallocate(table)
35if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
36header
37"col1 col2"
38table
39+0, -1
40+0, -1
41+0, +0
42+1, -1
43
44if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
45deallocate(table)
46if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK, iomsg = iomsg)) error stop trim(iomsg)
47table
48+0, +0, +0, +1
49-1, -1, +0, -1
50deallocate(table)
51if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
52header
53"col1 col2"
54table
55+0, -1
56+0, -1
57+0, +0
58+1, -1
59
60
61table = getUnifRand(.false., .true., 4_IK, 2_IK)
62table
63T, T
64F, T
65T, F
66F, F
67file = 'temp.temp'
68if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
69deallocate(table)
70if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
71header
72"col1 col2"
73table
74T, T
75F, T
76T, F
77F, F
78deallocate(table)
79if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
80header
81"col1 col2"
82table
83T, T
84F, T
85T, F
86F, F
87
88if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
89deallocate(table)
90if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
91table
92T, F, T, F
93T, T, F, F
94deallocate(table)
95if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
96header
97"col1 col2"
98table
99T, T
100F, T
101T, F
102F, F
103
104
105table = getUnifRand((-1., -1.), (+1., +1.), 4_IK, 2_IK)
106table
107(-0.474730849, -0.317758083), (-0.527266741, +0.346982002)
108(-0.197264433, +0.233856916), (+0.618423343, -0.320258260)
109(+0.301645637, -0.283429146), (+0.774007797, -0.624973297)
110(+0.313587785, +0.538685322E-1), (+0.938739896, -0.417438745)
111file = 'temp.temp'
112if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
113deallocate(table)
114if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
115header
116"col1 col2"
117table
118(-0.474730849, -0.317758083), (-0.527266741, +0.346982002), (-0.197264433, +0.233856916), (+0.618423343, -0.320258260)
119(+0.301645637, -0.283429146), (+0.774007797, -0.624973297), (+0.313587785, +0.538685322E-1), (+0.938739896, -0.417438745)
120deallocate(table)
121if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
122header
123"col1 col2"
124table
125(-0.474730849, -0.317758083), (-0.527266741, +0.346982002), (-0.197264433, +0.233856916), (+0.618423343, -0.320258260)
126(+0.301645637, -0.283429146), (+0.774007797, -0.624973297), (+0.313587785, +0.538685322E-1), (+0.938739896, -0.417438745)
127
128if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
129deallocate(table)
130if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK, iomsg = iomsg)) error stop trim(iomsg)
131table
132(-0.474730849, -0.317758083), (+0.301645637, -0.283429146)
133(-0.527266741, +0.346982002), (+0.774007797, -0.624973297)
134(-0.197264433, +0.233856916), (+0.313587785, +0.538685322E-1)
135(+0.618423343, -0.320258260), (+0.938739896, -0.417438745)
136deallocate(table)
137if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
138header
139"col1 col2"
140table
141(-0.474730849, -0.317758083), (-0.527266741, +0.346982002), (-0.197264433, +0.233856916), (+0.618423343, -0.320258260)
142(+0.301645637, -0.283429146), (+0.774007797, -0.624973297), (+0.313587785, +0.538685322E-1), (+0.938739896, -0.417438745)
143
144
145table = getUnifRand(-1, 1, 4_IK, 2_IK)
146table
147+0.00000000, +1.00000000
148+0.00000000, +0.00000000
149-1.00000000, +1.00000000
150+1.00000000, +1.00000000
151file = 'temp.temp'
152if (0 /= getErrTableWrite(file, table, header = 'col1 col2', sep = SK_' ')) error stop 'table write failed.'
153deallocate(table)
154if (0 /= getErrTableRead(file, table, header = header)) error stop 'table read failed.'
155header
156"col1 col2"
157table
158+0.00000000, +1.00000000
159+0.00000000, +0.00000000
160-1.00000000, +1.00000000
161+1.00000000, +1.00000000
162deallocate(table)
163if (0 /= getErrTableRead(file, table, header = header, sep = SK_' ')) error stop 'table read failed.'
164header
165"col1 col2"
166table
167+0.00000000, +1.00000000
168+0.00000000, +0.00000000
169-1.00000000, +1.00000000
170+1.00000000, +1.00000000
171
172if (0 /= getErrTableWrite(file, table, trans, sep = '|', roff = 2_IK)) error stop 'table write failed.'
173deallocate(table)
174if (0 /= getErrTableRead(file, table, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
175table
176+0.00000000, +0.00000000, -1.00000000, +1.00000000
177+1.00000000, +0.00000000, +1.00000000, +1.00000000
178deallocate(table)
179if (0 /= getErrTableRead(file, table, trans, sep = SK_'|', roff = 2_IK)) error stop 'table read failed.'
180header
181"col1 col2"
182table
183+0.00000000, +1.00000000
184+0.00000000, +0.00000000
185-1.00000000, +1.00000000
186+1.00000000, +1.00000000
187
188
Test:
test_pm_io
Todo:
High Priority: When the user-specified sep contains a value other than " " or ,, the current implementation cannot handle the presence of new line characters within string single or double quote delimited fields in output tables of type character.
This limitation can be fixed by tracking the delimiters while reading the contents of table.
Todo:
High Priority: The optional input arguments deliml delimr must be added to allow parsing arbitrarily-delimited fields.
Todo:
Normal Priority: The behavior of this generic interface for empty tables is currently undefined, although the err code is non-zero.
This should be fixed.
Todo:
Normal Priority: The non-intrinsic values for the output error code err must be standardized.
Currently, the err is set to -1 if an error occurs other than what is diagnosed by the compiler.
Todo:
Normal Priority: An optional input argument del must be added to optionally delete the input file or unit upon successful reading of the table.
Todo:
Critical Priority: In the current implementation, the behavior under an empty sep with trans option present is vague and untested.
This must be clarified via testing and further improvements.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 2390 of file pm_io.F90.


The documentation for this interface was generated from the following file: