Skip to content

Commit f7b3b28

Browse files
committed
Removed repeating (*(...)) and 1x from format and refactored save_txt and load_txt to compensate.
1 parent 0b81872 commit f7b3b28

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/stdlib_io.fypp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ module stdlib_io
2323

2424
! Format strings with edit descriptors for each type and kind
2525
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))'
26+
FMT_INT = '(i0)', &
27+
FMT_REAL_SP = '(es15.8e2)', &
28+
FMT_REAL_DP = '(es24.16e3)', &
29+
FMT_REAL_XDP = '(es26.18e3)', &
30+
FMT_REAL_QP = '(es44.35e4)', &
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)'
3535

3636
public :: FMT_INT, FMT_REAL_SP, FMT_REAL_DP, FMT_REAL_XDP, FMT_REAL_QP
3737
public :: FMT_COMPLEX_SP, FMT_COMPLEX_DP, FMT_COMPLEX_XDP, FMT_COMPLEX_QP
@@ -115,9 +115,9 @@ contains
115115
allocate(d(nrow, ncol))
116116
do i = 1, nrow
117117
#:if 'real' in t1
118-
read(s, FMT_REAL_${k1}$) d(i, :)
118+
read(s, "(*"//FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",1x))") d(i, :)
119119
#:elif 'complex' in t1
120-
read(s, FMT_COMPLEX_${k1}$) d(i, :)
120+
read(s, "(*"//FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",1x))") d(i, :)
121121
#:else
122122
read(s, *) d(i, :)
123123
#:endif
@@ -153,11 +153,11 @@ contains
153153
s = open(filename, "w")
154154
do i = 1, size(d, 1)
155155
#:if 'real' in t1
156-
write(s, FMT_REAL_${k1}$) d(i, :)
156+
write(s, "(*"//FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",1x))") d(i, :)
157157
#:elif 'complex' in t1
158-
write(s, FMT_COMPLEX_${k1}$) d(i, :)
158+
write(s, "(*"//FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",1x))") d(i, :)
159159
#:elif 'integer' in t1
160-
write(s, FMT_INT) d(i, :)
160+
write(s, "(*"//FMT_INT(1:len(FMT_INT)-1)//",1x))") d(i, :)
161161
#:else
162162
write(s, *) d(i, :)
163163
#:endif

0 commit comments

Comments
 (0)