DSL Element output
Optional to a simulation, the output element can be used to capture and store output field values in an CSV output file. This is an alternative to a component-based solution, where the a dedicated output component is a integrated part of the model. Both approaches do have pro and cons.
Model output component
...Pros - Can write to any data store; essential model feature, hight performance.
...Cons - No ad-hoc change of output variables, change needs model recompilation.
Simulation output element
...Pros - Output variables can be changed or disabled altogether without model recompilation, very flexible. Well suited for component output ad-hoc inspection.
...Cons - Slower in performance that dedicated output component. Only CSV data file output supported for the output element.
Note that both types of output definition can co-exist in one simulation.
The examples below show the use of the output element within a simulation.
sim(name:"Efcarson") {
...
model(classname:"prms2008.PrmsDdJh") {
...
}
output(time:"date", vars:"basin_gwflow_cfs,basin_cfs,runoff[0]", fformat="7.3f", file:"out1.csv")
...
}
The output is driven by date, an out field in the model. The variables to be captured in an output file called 'out1.csv' are listed in vars. Note that an array element runoff is a part of this. The numerical output format for floating point variables is "7.3f" (7 digits total, 3 decimal rounding). The output file gets stored to the output folder as defined in outputstrategy. For the configuration above it will have the following content:
@T, "Efcarson"
Created, "Tue Sep 15 14:31:36 MDT 2009"
@H, date, basin_gwflow_cfs, basin_cfs, runoff[0]
Type, Date, Double, Double, Double
,1980-10-01 12:00:00, 116.453, 116.453, 84.000
,1980-10-02 12:00:00, 114.974, 117.640, 82.000
,1980-10-03 12:00:00, 113.514, 113.514, 80.000
,1980-10-04 12:00:00, 112.072, 112.072, 80.000
,1980-10-05 12:00:00, 110.649, 110.649, 80.000
...
Note: The name of the simulation will be used as table name (EFcarson).
Element output
Specification
Name |
output - simulation defined output |
Properties | Description | Type | Required |
time | the time field to be used to trigger output on a time change | string | yes |
vars | a list of output fields that provides the values on each time step | string, (field names separated by ',', ';', or ':' | yes, at least one field name |
fformat | format for floating point values | string | no, default '10.3' |
dformat | format for integer values | string | no, default '10' |
file | the output file | string | no, if missing output goes to the console, otherwise to the specified file located in the output folder |
Note
- If multiple output elements are used, each should have its own unique file name. It is also recommended to use a file for output when specifying multiple outputs in a simulation.