@@ -144,53 +144,28 @@ contains
144
144
do i = 1, skiprows_
145
145
read(s, *)
146
146
end do
147
-
148
- #:if 'real' in t1
147
+
149
148
! Default to format used for savetxt if fmt not specified.
150
- fmt_ = optval(fmt, "(*"//FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",1x))")
151
-
152
- if ( fmt_ == '*' ) then
153
- ! Use list directed read if user has specified fmt='*'
154
- do i = 1, max_rows_
155
- read (s,*) d(i, :)
156
- enddo
157
- else
158
- ! Otherwise pass default or user specified fmt string.
159
- do i = 1, max_rows_
160
- read (s,fmt_) d(i, :)
161
- enddo
162
- endif
149
+ #:if 'real' in t1
150
+ fmt_ = optval(fmt, "(*"//FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",:,1x))")
163
151
#:elif 'complex' in t1
164
- ! Default to format used for savetxt if fmt not specified.
165
- fmt_ = optval(fmt, "(*"//FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",1x))")
166
- if ( fmt_ == '*' ) then
167
- ! Use list directed read if user has specified fmt='*'
168
- do i = 1, max_rows_
169
- read (s,*) d(i, :)
170
- enddo
171
- else
172
- ! Otherwise pass default or user specified fmt string.
173
- do i = 1, max_rows_
174
- read (s,fmt_) d(i, :)
175
- enddo
176
- endif
152
+ fmt_ = optval(fmt, "(*"//FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",:,1x))")
177
153
#:else
178
- ! Default to list directed for integer
179
154
fmt_ = optval(fmt, "*")
180
- ! Use list directed read if user has specified fmt='*'
155
+ #:endif
156
+
181
157
if ( fmt_ == '*' ) then
158
+ ! Use list directed read if user has specified fmt='*'
182
159
do i = 1, max_rows_
183
160
read (s,*) d(i, :)
184
161
enddo
185
162
else
186
- ! Otherwise pass default user specified fmt string.
163
+ ! Otherwise pass default or user specified fmt string.
187
164
do i = 1, max_rows_
188
165
read (s,fmt_) d(i, :)
189
166
enddo
190
167
endif
191
168
192
- #:endif
193
-
194
169
close(s)
195
170
196
171
end subroutine loadtxt_${t1[0]}$${k1}$
@@ -222,11 +197,11 @@ contains
222
197
s = open(filename, "w")
223
198
do i = 1, size(d, 1)
224
199
#:if 'real' in t1
225
- write(s, "(*"//FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",1x))") d(i, :)
200
+ write(s, "(*"//FMT_REAL_${k1}$(1:len(FMT_REAL_${k1}$)-1)//",:, 1x))") d(i, :)
226
201
#:elif 'complex' in t1
227
- write(s, "(*"//FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",1x))") d(i, :)
202
+ write(s, "(*"//FMT_COMPLEX_${k1}$(1:len(FMT_COMPLEX_${k1}$)-1)//",:, 1x))") d(i, :)
228
203
#:elif 'integer' in t1
229
- write(s, "(*"//FMT_INT(1:len(FMT_INT)-1)//",1x))") d(i, :)
204
+ write(s, "(*"//FMT_INT(1:len(FMT_INT)-1)//",:, 1x))") d(i, :)
230
205
#:else
231
206
write(s, *) d(i, :)
232
207
#:endif
0 commit comments