286e4e93 by Nathan Lighthart

Add ability to read all programs from single file

- Add programsFilePath parameter
- Add programs.xml file for arti_catch
- Adjust arti_catch simulation files to use all programs file
1 parent ddbae661
......@@ -19,6 +19,7 @@ import geoprocessing.CalcLatLongAdapter;
import gov.usda.jcf.core.Context;
import gov.usda.jcf.core.Program;
import gov.usda.jcf.core.ProgramLayout;
import gov.usda.jcf.core.ProgramListLayout;
import gov.usda.jcf.core.contexts.AlterableContext;
import gov.usda.jcf.core.contexts.CombinedContext;
import gov.usda.jcf.core.contexts.FieldContext;
......@@ -639,9 +640,34 @@ public class AgESModel {
private void createPrograms() throws IOException {
System.out.println("--> Creating programs ...");
Program initProgram = createInitProgram();
// read programs from specific files
Program surfaceProgram = createSurfaceProgram();
Program subSurfaceProgram = createSubSurfaceProgram();
// read all programs if some programs were not found in specific files
if (parameters.programsFilePath != null) {
if (surfaceProgram == null || subSurfaceProgram == null) {
XMLLayoutReader reader = new XMLLayoutReader(parameters.programsFilePath);
ProgramListLayout pll = (ProgramListLayout) reader.read(XMLLayoutReader.LayoutType.PROGRAM_LIST);
if (surfaceProgram == null) {
surfaceProgram = pll.createProgram("surface");
}
if (subSurfaceProgram == null) {
subSurfaceProgram = pll.createProgram("subsurface");
}
}
}
// if programs are still not found use default
if (surfaceProgram == null) {
surfaceProgram = createDefaultSurfaceProgram();
}
if (subSurfaceProgram == null) {
subSurfaceProgram = createDefaultSubSurfaceProgram();
}
emulateHRUPrograms(initProgram, surfaceProgram, subSurfaceProgram);
hruProgramSets = new LinkedHashMap<>();
......@@ -697,7 +723,7 @@ public class AgESModel {
private Program createSurfaceProgram() throws IOException {
if (parameters.surfaceProgramFilePath == null) {
return createDefaultSurfaceProgram();
return null;
}
XMLLayoutReader reader = new XMLLayoutReader(parameters.surfaceProgramFilePath);
ProgramLayout pl;
......@@ -732,7 +758,7 @@ public class AgESModel {
private Program createSubSurfaceProgram() throws IOException {
if (parameters.subSurfaceProgramFilePath == null) {
return createDefaultSubSurfaceProgram();
return null;
}
XMLLayoutReader reader = new XMLLayoutReader(parameters.subSurfaceProgramFilePath);
ProgramLayout pl;
......
......@@ -85,6 +85,9 @@ public class AgESParameters {
@Description("Sub-Surface program file path")
public final Path subSurfaceProgramFilePath;
@Description("All programs file path")
public final Path programsFilePath;
@Description("HRU additional parameters file path")
public final Path hruAdditionalFilePath;
......@@ -693,6 +696,7 @@ public class AgESParameters {
surfaceProgramFilePath = builder.surfaceProgramFilePath;
subSurfaceProgramFilePath = builder.subSurfaceProgramFilePath;
programsFilePath = builder.programsFilePath;
hruAdditionalFilePath = builder.hruAdditionalFilePath;
reachAdditionalFilePath = builder.reachAdditionalFilePath;
......@@ -922,6 +926,7 @@ public class AgESParameters {
private Path surfaceProgramFilePath;
private Path subSurfaceProgramFilePath;
private Path programsFilePath;
private Path hruAdditionalFilePath;
private Path reachAdditionalFilePath;
......@@ -1315,6 +1320,11 @@ public class AgESParameters {
return this;
}
public Builder programsFilePath(Path programsFilePath) {
this.programsFilePath = programsFilePath;
return this;
}
public Builder hruAdditionalFilePath(Path hruAdditionalFilePath) {
this.hruAdditionalFilePath = hruAdditionalFilePath;
return this;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!