@@ -21,17 +21,32 @@ module stdlib_io
2121 ! Private API that is exposed so that we can test it in tests
2222 public :: parse_mode
2323
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))
2528 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
3550
3651 !> Version: experimental
3752 !>
@@ -112,9 +127,9 @@ contains
112127 allocate(d(nrow, ncol))
113128 do i = 1, nrow
114129 #: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, :)
116131 #: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, :)
118133 #:else
119134 read(s, *) d(i, :)
120135 #:endif
@@ -150,11 +165,11 @@ contains
150165 s = open(filename, "w")
151166 do i = 1, size(d, 1)
152167 #: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, :)
154169 #: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, :)
156171 #:elif 'integer' in t1
157- write(s, FMT_INT) d(i, :)
172+ write(s, "(*"// FMT_INT(1:len(FMT_INT)-1)//",1x))" ) d(i, :)
158173 #:else
159174 write(s, *) d(i, :)
160175 #:endif
0 commit comments