Skip to content

Commit 76956f7

Browse files
committed
fixes & log
1 parent 460f709 commit 76956f7

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/main/java/org/funz/Telemac/TelemacCPlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public TelemacOutReader(TelemacLauncher l) {
4545
protected int runCommand() throws Exception {
4646
int ret = super.runCommand();
4747
if (ret != 0) {
48+
System.err.println("Failed to run Telemac !");
4849
return ret;
4950
}
5051

@@ -76,7 +77,8 @@ protected int runCommand() throws Exception {
7677
if (pois.isEmpty()) {
7778
System.err.println("Could not find .poi file !");
7879
return ret;
79-
}
80+
} else
81+
System.err.println("Will read poi: "+pois);
8082

8183
if (TelemacHelper.writeCSVfromCASRES(cas, pois)) {
8284
File resfile = new File(cas.getAbsoluteFile().getParentFile(), TelemacHelper.readFichiersDe(cas, "RESULT")[0]);

src/main/java/org/funz/Telemac/TelemacHelper.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.io.FileReader;
55
import java.io.IOException;
6+
import java.io.StringWriter;
67
import java.util.HashMap;
78
import java.util.LinkedList;
89
import java.util.List;
@@ -45,6 +46,7 @@ public class TelemacHelper {
4546
RES_VAR.put("BOTTOM", "B");
4647
RES_VAR.put("FROUDE", "F");
4748
RES_VAR.put("DEBIT SCALAIRE", "Q");
49+
RES_VAR.put("SCALAR FLOWRATE", "Q");
4850
RES_VAR.put("DEBIT SUIVANT X", "I");
4951
RES_VAR.put("DEBIT SUIVANT Y", "J");
5052
RES_VAR.put("FROTTEMENT", "W");
@@ -144,9 +146,10 @@ static Map<String, double[][]> extractPOIfromRES(File res, Properties poi) throw
144146

145147
for (int vi = 0; vi < s.getVariables().length; vi++) {
146148
String v = s.getVariables()[vi];
147-
//System.err.println("Reading " + v + " at:");
149+
//System.err.println("> Reading " + v + " at:");
148150
for (String p : poi.stringPropertyNames()) {
149-
//System.err.println(p);
151+
try {
152+
//System.err.println("> "+p);
150153
if (poi.getProperty(p).contains(",") && poi.getProperty(p).contains(":")) { // so, this is a x0,y0:nx,ny:x1,y1 zone poi
151154
String cs = poi.get(p).toString();
152155
String cs0 = cs.substring(0, cs.indexOf(":"));
@@ -186,7 +189,7 @@ static Map<String, double[][]> extractPOIfromRES(File res, Properties poi) throw
186189
}
187190
}
188191
dat.put(RES_VAR.get(v) + "_" + p, d);
189-
dat.put(p+"_xy", xy);
192+
dat.put("xy_" + p, xy);
190193

191194
} else if (poi.getProperty(p).contains(",")) { // so, this is a x,y poi, to get containing cell results
192195
double[] d = new double[s.getPasDeTemps().length];
@@ -216,6 +219,11 @@ static Map<String, double[][]> extractPOIfromRES(File res, Properties poi) throw
216219
}
217220
dat.put(RES_VAR.get(v) + "_" + p, new double[][]{d});
218221
}
222+
}catch (Exception e) {
223+
System.err.println("Failed to read " + v + " at: "+p+" :");
224+
e.printStackTrace();
225+
dat.put(RES_VAR.get(v) + "_" + p, new double[][]{});
226+
}
219227
}
220228
}
221229

@@ -309,6 +317,7 @@ static void write(File f, String s) {
309317
}*/
310318

311319
static String printDoubleArray2D(double[][] d) {
320+
if (d==null || d.length==0) return null;
312321
Object[] o = new Object[d[0].length];
313322
for (int i = 0; i < o.length; i++) {
314323
Object[] oi = new Object[d.length];

src/main/java/org/funz/Telemac/TelemacIOPlugin.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import java.io.FileFilter;
55
import java.io.FileInputStream;
66
import java.io.IOException;
7+
import java.io.PrintWriter;
8+
import java.io.StringWriter;
79
import java.util.HashMap;
810
import java.util.LinkedList;
911
import java.util.List;
@@ -140,7 +142,10 @@ public boolean accept(File pathname) {
140142

141143
pois.putAll(m);
142144
} catch (Exception ex) {
143-
ex.printStackTrace();
145+
StringWriter sw = new StringWriter();
146+
PrintWriter pw = new PrintWriter(sw);
147+
ex.printStackTrace(pw);
148+
lout.put("error","Could not read poi file "+file.getName()+" : "+sw.toString());
144149
}
145150
}
146151
}
@@ -157,15 +162,21 @@ public boolean accept(File pathname) {
157162

158163
lout.putAll(TelemacHelper.extractPOIfromCASRES(cas, pois));
159164
} catch (Exception e) {
160-
lout.put("error","Could not read coord "+pois+" in results of cas "+cas.getName()+" : "+e.getMessage());
165+
StringWriter sw = new StringWriter();
166+
PrintWriter pw = new PrintWriter(sw);
167+
e.printStackTrace(pw);
168+
lout.put("error","Could not read coord "+pois+" in results of cas "+cas.getName()+" : "+sw.toString());
161169
}
162170
}
163171

164172
for (File f : csvfiles) {
165173
try {
166174
lout.put(f.getName().substring(0, f.getName().indexOf(".csv")), readDoubleArray2D(FileUtils.readFileToString(f)));
167175
} catch (IOException ex) {
168-
lout.put("error","Could not read file "+f.getName()+" : "+ex.getMessage());
176+
StringWriter sw = new StringWriter();
177+
PrintWriter pw = new PrintWriter(sw);
178+
ex.printStackTrace(pw);
179+
lout.put("error","Could not read csv file "+f.getName()+" : "+sw.toString());
169180
}
170181
}
171182

0 commit comments

Comments
 (0)