1 | package PIANOS.generator; |
2 | |
3 | import PIANOS.datastructures.*; |
4 | import PIANOS.io.*; |
5 | import PIANOS.*; |
6 | |
7 | import java.util.*; |
8 | import java.io.*; |
9 | |
10 | /** |
11 | * This class is used to generate the Fortran module "output". |
12 | */ |
13 | public class Output { |
14 | public static final String realfmt = "F15.4"; |
15 | public static final String integerfmt = "I10"; |
16 | /** |
17 | * Generates and writes the Fortran module output.f90. |
18 | * |
19 | * @param callParameters The correct parameter order to be used in subroutine headers |
20 | * @param model The model this simulation is related to |
21 | */ |
22 | public static void generateOutput(String callParameters, ComputationalModel model) |
23 | throws IOException { |
24 | |
25 | FortranWriter out = new FortranWriter("output.f90"); |
26 | ArrayList <String> result = new ArrayList<String>(); |
27 | |
28 | result.add("MODULE output"); |
29 | result.add("USE definitions"); |
30 | result.add("IMPLICIT NONE"); |
31 | result.add(""); |
32 | result.add("CONTAINS"); |
33 | result.addAll(generateWriteOutput(model, callParameters)); |
34 | result.add(""); |
35 | result.addAll(generateWriteSummary(model, callParameters)); |
36 | result.add(""); |
37 | result.addAll(generateWriteLastValues(model, callParameters)); |
38 | result.add("END MODULE output"); |
39 | out.write(result); |
40 | } |
41 | |
42 | private static ArrayList<String> generateWriteOutput(ComputationalModel model, |
43 | String callParameters) { |
44 | |
45 | ArrayList<Variable> allVariables = new ArrayList<Variable>(model.getVariableList()); |
46 | for (Entity e : model.getEntityList()) { |
47 | allVariables.addAll(e.getVariableList()); |
48 | } |
49 | |
50 | ArrayList<String> result = new ArrayList<String>(); |
51 | |
52 | result.add("SUBROUTINE write_output(" + callParameters + ")"); |
53 | result.add("IMPLICIT NONE"); |
54 | result.addAll(Generator.generateIntroduction()); |
55 | result.add("INTEGER :: i, j"); |
56 | result.add("INTEGER :: iostatus"); |
57 | result.add("CHARACTER (LEN=*), PARAMETER:: filename = '" + model.getOutputFileName() + "'"); |
58 | result.add("CHARACTER (LEN=30) :: ich, jch, temp"); |
59 | result.add("LOGICAL, SAVE :: written = .FALSE."); |
60 | |
61 | String explanation = ""; |
62 | |
63 | // We assume that the wanted format for REALs is F15.4 and for INTEGERs I10 |
64 | |
65 | result.add("IF(.NOT. written) THEN"); |
66 | result.add("WRITE(15, FMT = *, IOSTAT = iostatus) '# Model: " + model.getModelFileName() + "'"); |
67 | result.addAll(generateCouldNotWrite()); |
68 | |
69 | if (model.getUpdateStrategy().equals("sequential")) { |
70 | result.add("WRITE(15, FMT = *, IOSTAT = iostatus) '# Update strategy: sequential, iterations: ', " + |
71 | model.getIterations()); |
72 | result.addAll(generateCouldNotWrite()); |
73 | } |
74 | else { |
75 | result.add("WRITE(15, FMT = *, IOSTAT = iostatus) '# Update strategy: random'"); |
76 | result.addAll(generateCouldNotWrite()); |
77 | } |
78 | result.add("WRITE(15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) '# '"); |
79 | for (Variable v : allVariables) { |
80 | if (v.isPrinted() == false) continue; |
81 | |
82 | if (v.getEntity() == null) { |
83 | |
84 | //explanation = explanation + v.getName() + " "; |
85 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) '" |
86 | + v.getName() + " '"); |
87 | result.addAll(generateCouldNotWrite()); |
88 | } |
89 | else if (v.getEntity().isMatrix() == false) { |
90 | result.add("DO i = 1, " + v.getEntity().getSize()); |
91 | result.add("WRITE (ich, FMT='(I10)') i"); |
92 | result.add("ich = ADJUSTL(ich)"); |
93 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) '"+ v.getName() +"_'"); |
94 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) TRIM(ich)"); |
95 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) ' '"); |
96 | result.addAll(generateCouldNotWrite()); |
97 | result.add("END DO"); |
98 | |
99 | } |
100 | else { |
101 | |
102 | result.add("DO j = 1, " + v.getEntity().getXCoordinate().getSize()); |
103 | result.add("DO i = 1, " + v.getEntity().getYCoordinate().getSize()); |
104 | result.add("WRITE (ich, FMT='(I10)') i"); |
105 | result.add("ich = ADJUSTL(ich)"); |
106 | result.add("WRITE (jch, FMT='(I10)') j"); |
107 | result.add("jch = ADJUSTL(jch)"); |
108 | |
109 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) '"+ v.getName() +"_'"); |
110 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) TRIM(ich)"); |
111 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) '_'"); |
112 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) TRIM(jch)"); |
113 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) ' '"); |
114 | result.addAll(generateCouldNotWrite()); |
115 | result.add("END DO"); |
116 | result.add("END DO"); |
117 | } |
118 | } |
119 | // to get the "advance = no" off |
120 | result.add("WRITE(15, FMT = *, IOSTAT = iostatus) ' '"); |
121 | result.addAll(generateCouldNotWrite()); |
122 | |
123 | // This is what we want: WRITE(15, FMT = *, IOSTAT = iostatus) |
124 | // '# alpha x_1_1 x_2_1 x_3_1 x_4_1 x_5_1 ... ' |
125 | // result.add("WRITE(15, FMT = *, IOSTAT = iostatus) '# " + explanation + "'"); |
126 | // result.addAll(generateCouldNotWrite()); |
127 | |
128 | result.add("written = .TRUE."); |
129 | result.add("END IF"); |
130 | |
131 | // This is what we want: WRITE(15, FMT='(F6.2, 84(I2))', IOSTAT = iostatus) |
132 | // alpha % one_dim(1) % value, x % two_dim(:, :) % value |
133 | |
134 | for (Variable v : allVariables) { |
135 | if (v.isPrinted() == false) continue; |
136 | |
137 | String fmt = null; |
138 | |
139 | if (v.isInteger()) |
140 | fmt = integerfmt; |
141 | else |
142 | fmt = realfmt; |
143 | |
144 | if (v.getEntity() == null) { |
145 | result.add("WRITE (temp, FMT='("+ fmt +")') "+ v.getName() +" % one_dim(1) % value"); |
146 | result.add("temp = ADJUSTL(temp)"); |
147 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) TRIM(temp)"); |
148 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) ' '"); |
149 | result.addAll(generateCouldNotWrite()); |
150 | } |
151 | else if (v.getEntity().isMatrix() == false) { |
152 | result.add("DO i = 1, " + v.getEntity().getSize()); |
153 | result.add("WRITE (temp, FMT='("+ fmt +")') "+ v.getName() +" % one_dim(i) % value"); |
154 | result.add("temp = ADJUSTL(temp)"); |
155 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) TRIM(temp)"); |
156 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) ' '"); |
157 | result.addAll(generateCouldNotWrite()); |
158 | result.add("END DO"); |
159 | } |
160 | else { |
161 | result.add("DO j = 1, " + v.getEntity().getXCoordinate().getSize()); |
162 | result.add("DO i = 1, " + v.getEntity().getYCoordinate().getSize()); |
163 | result.add("WRITE (temp, FMT='("+ fmt +")') "+ v.getName() +" % two_dim(i, j) % value"); |
164 | result.add("temp = ADJUSTL(temp)"); |
165 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) TRIM(temp)"); |
166 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'NO', IOSTAT = iostatus) ' '"); |
167 | result.addAll(generateCouldNotWrite()); |
168 | result.add("END DO"); |
169 | result.add("END DO"); |
170 | } |
171 | |
172 | } |
173 | result.add("WRITE (15, FMT='(A)', ADVANCE = 'YES', IOSTAT = iostatus) ' '"); |
174 | result.addAll(generateCouldNotWrite()); |
175 | |
176 | result.add("END SUBROUTINE write_output"); |
177 | return result; |
178 | } |
179 | |
180 | |
181 | private static ArrayList<String> generateWriteSummary(ComputationalModel model, |
182 | String callParameters) { |
183 | |
184 | ArrayList<Variable> allVariables = new ArrayList<Variable>(model.getVariableList()); |
185 | for (Entity e : model.getEntityList()) { |
186 | allVariables.addAll(e.getVariableList()); |
187 | } |
188 | |
189 | ArrayList<String> result = new ArrayList<String>(); |
190 | |
191 | result.add("SUBROUTINE write_summary(" + callParameters + ")"); |
192 | result.add("IMPLICIT NONE"); |
193 | result.addAll(Generator.generateIntroduction()); |
194 | result.add("INTEGER :: iostatus, i, j"); |
195 | result.add("CHARACTER(LEN=*), PARAMETER :: filename = '"+ model.getSummaryFileName() |
196 | + "'"); |
197 | result.add("CHARACTER(LEN=30) :: ich, jch, temp, tempcount"); |
198 | result.add("OPEN(UNIT=21, FILE=filename, IOSTAT = iostatus)"); |
199 | result.addAll(generateCouldNotOpen()); |
200 | |
201 | result.add("WRITE(21, '(A)', IOSTAT = iostatus) '?? simulation summary'"); |
202 | result.addAll(generateCouldNotWrite()); |
203 | |
204 | for (Variable variable : allVariables) { |
205 | |
206 | if (variable.isPrinted() == false) continue; |
207 | |
208 | String name = variable.getName(); |
209 | result.add("WRITE(21, '(A)', IOSTAT = iostatus) '? " + name + "'"); |
210 | result.addAll(generateCouldNotWrite()); |
211 | |
212 | if (model.getUpdateStrategy().equals("sequential")) { |
213 | |
214 | int iterations = model.getIterations(); |
215 | if (variable.getEntity() == null) { |
216 | result.add("WRITE(temp, FMT = '("+realfmt+")', IOSTAT = iostatus) REAL(" + |
217 | name +" % one_dim(1) % successful_changes)/" + iterations); |
218 | result.add("temp = ADJUSTL(temp)"); |
219 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) '" + iterations +"'"); |
220 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) ' '"); |
221 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='YES', IOSTAT = iostatus) TRIM(temp)"); |
222 | result.addAll(generateCouldNotWrite()); |
223 | } |
224 | else if (variable.getEntity().isMatrix() == false) { |
225 | result.add("DO i=1, " + variable.getEntity().getSize()); |
226 | result.add("WRITE (ich, FMT='(I10)') i"); |
227 | result.add("ich = ADJUSTL(ich)"); |
228 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) '? " + name + "_'"); |
229 | result.add("WRITE(21, FMT = '(A)', ADVANCE='YES', IOSTAT = iostatus) TRIM(ich)"); |
230 | result.addAll(generateCouldNotWrite()); |
231 | |
232 | result.add("WRITE(temp, FMT = '("+realfmt+")', IOSTAT = iostatus) REAL(" + |
233 | name +" % one_dim(i) % successful_changes)/" + iterations); |
234 | result.add("temp = ADJUSTL(temp)"); |
235 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) '" + iterations +"'"); |
236 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) ' '"); |
237 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='YES', IOSTAT = iostatus) TRIM(temp)"); |
238 | result.addAll(generateCouldNotWrite()); |
239 | result.add("END DO"); |
240 | } |
241 | else { |
242 | result.add("DO j=1, " + variable.getEntity().getXCoordinate().getSize()); |
243 | result.add("DO i=1, " + variable.getEntity().getYCoordinate().getSize()); |
244 | result.add("WRITE (ich, FMT='(I10)') i"); |
245 | result.add("ich = ADJUSTL(ich)"); |
246 | result.add("WRITE (jch, FMT='(I10)') j"); |
247 | result.add("jch = ADJUSTL(jch)"); |
248 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) '? " + name + "_'"); |
249 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) TRIM(ich)"); |
250 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) '_'"); |
251 | result.add("WRITE(21, FMT = '(A)', ADVANCE='YES', IOSTAT = iostatus) TRIM(jch)"); |
252 | result.addAll(generateCouldNotWrite()); |
253 | result.add("WRITE(temp, FMT = '("+realfmt+")', IOSTAT = iostatus) REAL(" + |
254 | name +" % two_dim(i, j) % successful_changes)/" + iterations); |
255 | result.add("temp = ADJUSTL(temp)"); |
256 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) '" + iterations +"'"); |
257 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) ' '"); |
258 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='YES', IOSTAT = iostatus) TRIM(temp)"); |
259 | result.addAll(generateCouldNotWrite()); |
260 | result.add("END DO"); |
261 | result.add("END DO"); |
262 | } |
263 | } |
264 | else { |
265 | |
266 | if (variable.getEntity() == null) { |
267 | result.add("WRITE(tempcount, FMT = '(I10)', IOSTAT = iostatus) " + name + " % one_dim(1) % update_count"); |
268 | result.add("tempcount = ADJUSTL(tempcount)"); |
269 | result.add("WRITE(temp, FMT = '("+realfmt+")', IOSTAT = iostatus) REAL(" + |
270 | name +" % one_dim(1) % successful_changes)/ " + name + " % one_dim(1) % update_count"); |
271 | result.add("temp = ADJUSTL(temp)"); |
272 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) TRIM(tempcount)"); |
273 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) ' '"); |
274 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='YES', IOSTAT = iostatus) TRIM(temp)"); |
275 | result.addAll(generateCouldNotWrite()); |
276 | } |
277 | else if (variable.getEntity().isMatrix() == false) { |
278 | result.add("DO i=1, " + variable.getEntity().getSize()); |
279 | result.add("WRITE (ich, FMT='(I10)') i"); |
280 | result.add("ich = ADJUSTL(ich)"); |
281 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) '? " + name + "_'"); |
282 | result.add("WRITE(21, FMT = '(A)', ADVANCE='YES', IOSTAT = iostatus) TRIM(ich)"); |
283 | result.addAll(generateCouldNotWrite()); |
284 | |
285 | result.add("WRITE(tempcount, FMT = '(I10)', IOSTAT = iostatus) " + name + " % one_dim(i) % update_count"); |
286 | result.add("tempcount = ADJUSTL(tempcount)"); |
287 | result.add("WRITE(temp, FMT = '("+realfmt+")', IOSTAT = iostatus) REAL(" + |
288 | name +" % one_dim(i) % successful_changes)/ " + name + " % one_dim(i) % update_count"); |
289 | result.add("temp = ADJUSTL(temp)"); |
290 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) TRIM(tempcount)"); |
291 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) ' '"); |
292 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='YES', IOSTAT = iostatus) TRIM(temp)"); |
293 | result.addAll(generateCouldNotWrite()); |
294 | result.add("END DO"); |
295 | } |
296 | else { |
297 | result.add("DO j=1, " + variable.getEntity().getXCoordinate().getSize()); |
298 | result.add("DO i=1, " + variable.getEntity().getYCoordinate().getSize()); |
299 | result.add("WRITE (ich, FMT='(I10)') i"); |
300 | result.add("ich = ADJUSTL(ich)"); |
301 | result.add("WRITE (jch, FMT='(I10)') j"); |
302 | result.add("jch = ADJUSTL(jch)"); |
303 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) '? " + name + "_'"); |
304 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) TRIM(ich)"); |
305 | result.add("WRITE(21, FMT = '(A)', ADVANCE='NO', IOSTAT = iostatus) '_'"); |
306 | result.add("WRITE(21, FMT = '(A)', ADVANCE='YES', IOSTAT = iostatus) TRIM(jch)"); |
307 | result.addAll(generateCouldNotWrite()); |
308 | |
309 | result.add("WRITE(tempcount, FMT = '(I10)', IOSTAT = iostatus) " + name + " % two_dim(i, j) % update_count"); |
310 | result.add("tempcount = ADJUSTL(tempcount)"); |
311 | result.add("WRITE(temp, FMT = '("+realfmt+")', IOSTAT = iostatus) REAL(" + |
312 | name +" % two_dim(i, j) % successful_changes)/ " + name + " % two_dim(i, j) % update_count"); |
313 | result.add("temp = ADJUSTL(temp)"); |
314 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) TRIM(tempcount)"); |
315 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='NO', IOSTAT = iostatus) ' '"); |
316 | result.add("WRITE(21, FMT = '(A)', ADVANCE ='YES', IOSTAT = iostatus) TRIM(temp)"); |
317 | |
318 | result.addAll(generateCouldNotWrite()); |
319 | result.add("END DO"); |
320 | result.add("END DO"); |
321 | } |
322 | } |
323 | } |
324 | |
325 | result.add("CLOSE(21)"); |
326 | result.add("END SUBROUTINE write_summary"); |
327 | |
328 | return result; |
329 | } |
330 | |
331 | private static ArrayList<String> generateCouldNotWrite() { |
332 | |
333 | ArrayList<String> result = new ArrayList<String>(); |
334 | result.add("IF (iostatus /= 0) THEN"); |
335 | result.add("WRITE (*, *) 'Could not write to ', filename, '. Exiting program.'"); |
336 | result.add("STOP"); |
337 | result.add("END IF"); |
338 | return result; |
339 | } |
340 | |
341 | private static ArrayList<String> generateCouldNotOpen() { |
342 | |
343 | ArrayList<String> result = new ArrayList<String>(); |
344 | result.add("IF (iostatus /= 0) THEN"); |
345 | result.add("WRITE (*, *) 'Could not open ', filename, '. Exiting program.'"); |
346 | result.add("STOP"); |
347 | result.add("END IF"); |
348 | return result; |
349 | } |
350 | |
351 | private static ArrayList<String> generateWriteLastValues(ComputationalModel model, String callParameters) { |
352 | // the string parameters tells the correct order of the parameters |
353 | // the initializations can be generated based on Variables. |
354 | ArrayList<Variable> allVariables = new ArrayList<Variable>(model.getVariableList()); |
355 | for (Entity e : model.getEntityList()) { |
356 | allVariables.addAll(e.getVariableList()); |
357 | } |
358 | |
359 | ArrayList<String> result = new ArrayList<String>(); |
360 | |
361 | result.add("SUBROUTINE write_last_values(" + callParameters + ")"); |
362 | result.add("IMPLICIT NONE"); |
363 | |
364 | result.addAll(Generator.generateIntroduction()); |
365 | |
366 | result.add("INTEGER :: iostatus, i, j"); |
367 | result.add("CHARACTER (LEN=*), PARAMETER :: filename = '" + model.getLastValuesFileName() + "'"); |
368 | result.add("CHARACTER (LEN=30) :: temp"); |
369 | result.add("OPEN(UNIT=20, FILE=filename, IOSTAT = iostatus)"); |
370 | result.addAll(generateCouldNotOpen()); |
371 | |
372 | for (Variable variable : allVariables) { |
373 | |
374 | //System.out.println("GENERATOR DEBUG: Variable name : " + variable.getName() |
375 | // + ", functional: " + variable.isFunctional()); |
376 | |
377 | if (variable.isFunctional()) continue; |
378 | if (variable.isData() && variable.getMissingValueCount() == 0) continue; |
379 | String fmt = null; |
380 | if (variable.isInteger()) |
381 | fmt = integerfmt; |
382 | else |
383 | fmt = realfmt; |
384 | |
385 | String name = variable.getName(); |
386 | if (variable.getEntity() == null) { |
387 | result.add("WRITE(20, '(A)', IOSTAT = iostatus) '? " + name + "'"); |
388 | result.addAll(generateCouldNotWrite()); |
389 | result.add("WRITE(temp, FMT='("+ fmt +")', IOSTAT = iostatus)" + name +" % one_dim(1) % value"); |
390 | result.add("temp = ADJUSTL(temp)"); |
391 | result.add("WRITE(20, '(A)', IOSTAT = iostatus) TRIM(temp)"); |
392 | result.addAll(generateCouldNotWrite()); |
393 | } |
394 | else if (variable.getEntity().isMatrix() == false) { |
395 | int size = variable.getEntity().getSize(); |
396 | result.add("WRITE(20, '(A)', IOSTAT = iostatus) '? " + name + " 1: " + |
397 | size + "'"); |
398 | result.addAll(generateCouldNotWrite()); |
399 | result.add("DO i = 1, " + size); |
400 | result.add("WRITE(temp, FMT='("+ fmt +")', IOSTAT = iostatus)" + name +" % one_dim(i) % value"); |
401 | result.add("temp = ADJUSTL(temp)"); |
402 | result.add("WRITE(20, '(A)', IOSTAT = iostatus) TRIM(temp)"); |
403 | result.addAll(generateCouldNotWrite()); |
404 | result.add("END DO"); |
405 | } |
406 | else { |
407 | int ysize = variable.getEntity().getYCoordinate().getSize(); |
408 | int xsize = variable.getEntity().getXCoordinate().getSize(); |
409 | result.add("WRITE(20, '(A)', IOSTAT = iostatus) '? " + name + " 1:" + ysize + " 1:" + xsize + "'"); |
410 | result.addAll(generateCouldNotWrite()); |
411 | |
412 | result.add("DO i = 1, " + ysize); |
413 | result.add("DO j = 1, " + xsize); |
414 | result.add("WRITE(temp, FMT='("+ fmt +")', IOSTAT = iostatus)" + name +" % two_dim(i, j) % value"); |
415 | result.add("temp = ADJUSTL(temp)"); |
416 | result.add("WRITE(20, '(A)', IOSTAT = iostatus, ADVANCE='NO') TRIM(temp)"); |
417 | result.add("WRITE(20, '(A)', IOSTAT = iostatus, ADVANCE='NO') ' '"); |
418 | result.addAll(generateCouldNotWrite()); |
419 | result.add("END DO"); |
420 | result.add("WRITE(20, '(A)', IOSTAT = iostatus, ADVANCE='YES') ' '"); |
421 | result.add("END DO"); |
422 | } |
423 | } |
424 | |
425 | result.add("CLOSE(20)"); |
426 | result.add("END SUBROUTINE write_last_values"); |
427 | return result; |
428 | } |
429 | |
430 | } |