Skip to content
Snippets Groups Projects
Commit b6c0e1b1 authored by Peter Alexander's avatar Peter Alexander
Browse files

Output error marker file

parent a5d40c44
No related branches found
No related tags found
No related merge requests found
......@@ -65,8 +65,15 @@ public class ModelMain {
/* run the model */
private void run() {
for (int i = ModelConfig.START_TIMESTEP; i <= ModelConfig.END_TIMESTEP; i++)
doTimestep(i);
for (int i = ModelConfig.START_TIMESTEP; i <= ModelConfig.END_TIMESTEP; i++) {
try {
doTimestep(i);
}
catch (Exception e) {
LpjgOutputer.writeMarkerFile(ModelConfig.BASE_YEAR + i, true);
throw new RuntimeException(e);
}
}
}
private void doTimestep(int timestep) {
......
......@@ -33,22 +33,29 @@ public class LpjgOutputer {
}
public void writeOutput() {
String outputDirName = ModelConfig.OUTPUT_DIR + File.separator + year;
File outputDir = getOutputDir(year);
writeLandCoverAndCrop(outputDir);
writeIntensity(outputDir);
writeMarkerFile(year, false);
}
private static File getOutputDir(int yr) {
String outputDirName = ModelConfig.OUTPUT_DIR + File.separator + yr;
File outputDir = new File(outputDirName);
outputDir.mkdirs();
writeLandCoverAndCrop(outputDirName);
writeIntensity(outputDirName);
writeMarkerFile(outputDirName, false);
return outputDir;
}
private void writeIntensity(String outputDirName) {
private void writeIntensity(File outputDir) {
// TODO Auto-generated method stub
}
private void writeMarkerFile(String outputDirName, boolean errorStatus) {
File markerFile = new File(outputDirName + File.separator + (errorStatus ? "error" : "done"));
public static void writeMarkerFile(int year, boolean errorStatus) {
File outputDir = getOutputDir(year);
File markerFile = new File(outputDir.getPath() + File.separator + (errorStatus ? "error" : "done"));
try {
if (!markerFile.exists())
......@@ -60,17 +67,17 @@ public class LpjgOutputer {
}
}
public void writeLandCoverAndCrop(String outputDir) {
public void writeLandCoverAndCrop(File outputDir) {
BufferedWriter landCoverWriter = null;
BufferedWriter cropFractWriter = null;
try {
String landCoverFileName = outputDir + File.separator + "LandCoverFract.txt";
String landCoverFileName = outputDir.getPath() + File.separator + "LandCoverFract.txt";
landCoverWriter = new BufferedWriter(new FileWriter(landCoverFileName, false));
landCoverWriter.write("Lon Lat CROPLAND PASTURE NATURAL BARREN");
landCoverWriter.newLine();
String cropFractionFileName = outputDir + File.separator + "CropFract.txt";
String cropFractionFileName = outputDir.getPath() + File.separator + "CropFract.txt";
cropFractWriter = new BufferedWriter(new FileWriter(cropFractionFileName, false));
cropFractWriter.write("Lon Lat TeWWirr TeSWirr TeCoirr TrRiirr");
cropFractWriter.newLine();
......
......@@ -40,7 +40,6 @@ public abstract class AbstractTabularRasterReader<D extends RasterItem> {
return headertokens;
}
public RasterSet<D> getRasterDataFromFile(String filename) {
long startTime = System.currentTimeMillis();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment