@@ -21,17 +21,32 @@ module stdlib_io
21
21
! Private API that is exposed so that we can test it in tests
22
22
public :: parse_mode
23
23
24
- ! Format strings with edit descriptors for each type and kind
24
+ !> Version: experimental
25
+ !>
26
+ !> Format strings with edit descriptors for each type and kind
27
+ !> ([Specification](../page/specs/stdlib_io.html))
25
28
character(*), parameter :: &
26
- FMT_INT = '(*(i0,1x))', &
27
- FMT_REAL_SP = '(*(es15.8e2,1x))', &
28
- FMT_REAL_DP = '(*(es24.16e3,1x))', &
29
- FMT_REAL_XDP = '(*(es26.18e3,1x))', &
30
- FMT_REAL_QP = '(*(es44.35e4,1x))', &
31
- FMT_COMPLEX_SP = '(*(es15.8e2,1x,es15.8e2))', &
32
- FMT_COMPLEX_DP = '(*(es24.16e3,1x,es24.16e3))', &
33
- FMT_COMPLEX_XDP = '(*(es26.18e3,1x,es26.18e3))', &
34
- FMT_COMPLEX_QP = '(*(es44.35e4,1x,es44.35e4))'
29
+ !> Format string for integers
30
+ FMT_INT = '(i0)', &
31
+ !> Format string for single precision real numbers
32
+ FMT_REAL_SP = '(es15.8e2)', &
33
+ !> Format string for souble precision real numbers
34
+ FMT_REAL_DP = '(es24.16e3)', &
35
+ !> Format string for extended double precision real numbers
36
+ FMT_REAL_XDP = '(es26.18e3)', &
37
+ !> Format string for quadruple precision real numbers
38
+ FMT_REAL_QP = '(es44.35e4)', &
39
+ !> Format string for single precision complex numbers
40
+ FMT_COMPLEX_SP = '(es15.8e2,1x,es15.8e2)', &
41
+ !> Format string for double precision complex numbers
42
+ FMT_COMPLEX_DP = '(es24.16e3,1x,es24.16e3)', &
43
+ !> Format string for extended double precision complex numbers
44
+ FMT_COMPLEX_XDP = '(es26.18e3,1x,es26.18e3)', &
45
+ !> Format string for quadruple precision complex numbers
46
+ FMT_COMPLEX_QP = '(es44.35e4,1x,es44.35e4)'
47
+
48
+ public :: FMT_INT, FMT_REAL_SP, FMT_REAL_DP, FMT_REAL_XDP, FMT_REAL_QP
49
+ public :: FMT_COMPLEX_SP, FMT_COMPLEX_DP, FMT_COMPLEX_XDP, FMT_COMPLEX_QP
35
50
36
51
!> Version: experimental
37
52
!>
@@ -112,9 +127,9 @@ contains
112
127
allocate(d(nrow, ncol))
113
128
do i = 1, nrow
114
129
#:if 'real' in t1
115
- read(s, FMT_REAL_${k1}$) d(i, :)
130
+ read(s, "(*"// FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",1x))" ) d(i, :)
116
131
#:elif 'complex' in t1
117
- read(s, FMT_COMPLEX_${k1}$) d(i, :)
132
+ read(s, "(*"// FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",1x))" ) d(i, :)
118
133
#:else
119
134
read(s, *) d(i, :)
120
135
#:endif
@@ -150,11 +165,11 @@ contains
150
165
s = open(filename, "w")
151
166
do i = 1, size(d, 1)
152
167
#:if 'real' in t1
153
- write(s, FMT_REAL_${k1}$) d(i, :)
168
+ write(s, "(*"// FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",1x))" ) d(i, :)
154
169
#:elif 'complex' in t1
155
- write(s, FMT_COMPLEX_${k1}$) d(i, :)
170
+ write(s, "(*"// FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",1x))" ) d(i, :)
156
171
#:elif 'integer' in t1
157
- write(s, FMT_INT) d(i, :)
172
+ write(s, "(*"// FMT_INT(1:len(FMT_INT)-1)//",1x))" ) d(i, :)
158
173
#:else
159
174
write(s, *) d(i, :)
160
175
#:endif
0 commit comments