OHDFewsadapter is a java class used by all OHD models in CHPS. It is the initial point of interaction between all OHD models and FEWS. FEWS is configured to use the OHDFewsadpater through FEWS workflows.
Below is part of a workflow used to run SNOW-17 in FEWS.
<?xml version="1.0" encoding="UTF-8"?>
<argument>run_info_file = %ROOT_DIR%/run_info.xml</argument>
The <executeActivity> workflow process (highlighted in blue above) executes the OHDFewsAdapter.main() java method with 1 argument
OHDFewsAdapter’s argument is specified in a FEWS workflow using the “property = value” construct. The only required property is:
1. an xml file with model run information (run info file)
This argument is a fully qualified path and filename to the run info file.
The OHDFewsadapter run info xml file contains information needed to run all OHD models. An excerpt is shown below.
<startDateTime date="2007-10-22" time="12:00:00"/>
<endDateTime date="2007-10-31" time="12:00:00"/>
<time0 date="2007-10-25" time="12:00:00"/>
<lastObservationDateTime date="2007-10-25" time="12:00:00"/>
<string key="legacyLocation" value="/awips/CHPS0810/home/grijzea/ohdrfc_sa/Modules/ohd/bin"/>
<string key="outputLocationId" value="SELWE"/>
<int key="printDebugInfo" value="0"/>
The file is separated into two parts. The first part consists of at least 6 required elements (highlighted in yellow). Note: Although inputParameterFile, inputStateDescriptionFile, inputTimeSeriesFile, and outputTimeSeriesFile are not required by the xml schema., all OHD models require these elements1. The second part is a properties element with 1 or more sub-elements.
1The one exception is the BASEFLOW model, which in some cases does not need an inputTimeSeries element.
The second part is a properties element with 1 or more properties defined.
The OHDFewsadpater properties element has 1 required property and several more optional ones.
o printDebugInfo (valid values are 0 to 5; the default is 0)
The printDebugInfo property is used to set the level for debug output. A higher number represents more debug output.
When the default is used (i.e. “0”). Only ERROR, WARNING, and INFO messages are written for OHD models. This logging is included in the same log file FEWS uses (i.e. log.txt, and also appears in the GUI’s bottom panel)
When printDebugInfo is > 0, additional logging is written to an xml file specific to the OHD model. This file is included in the “dump” of files generated when running an OHD model in debug mode. The file is located in the output/ directory and is named diag.xml.
o outputLocationId (a string identifying the output location)
The outputLocationId property is used to explicitly identify the locationId for model output time series. When not defined the location id for one of the inputs is used for all output time series.
NOTE: for models whose input is from an upstream basin (e.g. channel routing models), the outputLocationId should most likely be set.
o legacyLocation (a directory name)
The legacy location is used to set the location for the binary executable for OHD models not ported to Java
o startLocalHourOfDay (an integer to set the starting local hour (0-24) of the day)
o startHourOfDay (an integer to set the starting hour (0-24 in GMT) of the day)
NOTE: OHDFewsadapter calculations are done internally in GMT and by default the starting hour of the day is assumed to be 12GMT. In some cases (ESP and Calibration) this is assumption is not valid.
Input Time Series Mods
A few OHD models (sac, sacht, apicont, snow, ssarresv, and ressngl) are capable of receiving mods as separate input time series. In these cases 2 or 3 <inputTimeSeriesFile> elements will appear in the runInfo.xml file. Below is an example for SNOW17, which can have up to 3 elements (one for input time series, one for equidistant mod time series, and one for non-equidistant mod time series).
The following diagram shows the recommended directory structure for CHPS models in FEWS. Some things to note are:
The OHDFewsAdapter java class is the initial point of interaction between FEWS and the OHD models (C/FORTRAN and Java based). In addition to instantiating the appropriate model driver, OHDFewsAdapter is where the processes to parse and load the input time series, parameters, and states into the appropriate objects are initiated. After the data is loaded, OHDFewsAdapter calls the model driver’s execute method.
In the case of non-java legacy models the model driver’s execute method is responsible for instantiating a LegacyModelAdapter which creates input time series flat files from objects stored in the model driver class, invokes the legacy model, and converts output flat file time series data into an output time series data object. Finally OHDFewsAdapter takes the data object returned by the legacy adapter and initiates the process used to convert the output data object into an output FEWS xml time series file.
The figure above shows the flow of data between FEWS and OHDFewsadapter.
Input data as xml files (params.xml, inputs.xml, states.xml, run_info.xml) and 1 text file (initial state values) are exported from FEWS and passed to the OHDFewsadapter for each model. For Java models, the xml files are used directly, while for non-Java models the xml files are converted to native-format text files.
Output data as xml files (outputs.xml, states.xml and diag.xml) and 1 text file (output states) are passed from the OHDFewsadapter back to FEWS. For non-Java models output text files (output.txt and diag.txt) are converted to xml files before sending back to FEWS.