RPL Predefined Functions
RiverWare Policy Language (RPL)
RPL Predefined Functions
This section describes the predefined RiverWare functions which are available for use in any RiverWare Policy Language (RPL) set.
Predefined functions perform a wide range of calculations common to water management policy and its expression in a rule context. Some predefined functions provide rules with access to the same algorithms used in RiverWare simulation for mass balance calculations, flow/volume conversions, and table lookups. Other predefined functions are available for common mathematical operations, date/time manipulations, topographical evaluations, and some specialized river basin management calculations.
Predefined functions are used in RPL sets in the same way as user-defined custom functions. They are selected from the palette, and inserted into a rule, internal function, or other expression. Each predefined function is an expression that evaluates to one of the seven rules data types:
• NUMERIC
• BOOLEAN
• DATETIME
• OBJECT
• SLOT
• STRING
• LIST
Predefined functions may or may not have arguments. The computational algorithms and arguments to predefined functions may not be modified.
RPL Predefined Functions Reference
This section provides details about the RPL predefined functions. See “Hypothetical Simulations” for additional information about predefined functions used specifically for hypothetical simulations.
Abs
This function evaluates to the absolute value of its single numeric argument.

 Description Absolute value operator Type NUMERIC Arguments Type Meaning 1 NUMERIC value to evaluate Evaluation Determines the absolute value of the numeric argument Comments none
Syntax Example
Abs(-11 "cfs") returns 11 "cfs"
Use Example
IF(Abs(res.Inflow[] - res.Inflow[@"Next Timestep"]) < 1 "cms") THEN TRUE
AccountAttributes

 Description Given a string representing an account’s full name (object^account), returns a list containing the account’s attributes, i.e., the account’s water type, water owner, and account type. Type LIST {STRING, STRING, STRING} Arguments Type Meaning 1 STRING The name of the account. Evaluation Comments
Syntax Example
AccountAttributes("ResA^GoodWater")
Return Example
{"Intra-basin Transfer", "Big City", "StorageAccount"}
AccountNameFromPriorityDate
This function evaluates to the name of the account having the specified priority date.

 Description This function returns the name of the account having the specified priority date. Type STRING Arguments Type Meaning 1 DATETIME The priority date. Evaluation The Accounts in the system are examined; the Account having the indicated priority date is returned. Comments Priority dates are a property of Accounts.It’s an error if no account has the specified priority date.
Syntax Example
AccountNameFromPriorityDate (@"12:00:00 August 12, 2004")
Return Example
"Account1"
AccountNamesByAccountType
This function evaluates to the list of names of Accounts on the specified Object having the indicated Account type.

 Description This function returns a list of names of Accounts on a specified Object having the indicated Account type, sorted in ascending Account priority date order. Accounts which don’t have a priority date are at the end of the list, sorted in ascending name order. Type LIST {STRING} Arguments Type Meaning 1 OBJECT The Object. 2 STRING Account type name (currently, one of Diversion, Storage, or PassThrough) or ALL. Evaluation The set of Accounts on the Object are examined. The names of the Accounts having the specified account type are added to the returned list.If the Account type argument is ALL, then that attribute is ignored. The returned list will contain the names of ALL Accounts on the Object.The list is sorted as described above. Comments Priority dates are properties of Accounts.
Syntax Example
AccountNamesByAccountType (%"Heron Reservior", "Storage")
Return Example
{"Account1", "Account2"}
AccountNamesByWaterOwner
This function evaluates to the list of names of Accounts on the specified Object having the indicated WaterOwner.

 Description This function returns a list of names of Accounts on a specified Object having the indicated WaterOwner, sorted in ascending Account priority date order. Accounts which don’t have a priority date are at the end of the list, sorted in ascending name order. Type LIST {STRING} Arguments Type Meaning 1 OBJECT The Object. 2 STRING WaterOwner name or NONE or ALL Evaluation The set of Accounts on the Object are examined. The names of the Accounts having the specified WaterOwner are added to the returned list.If the WaterOwner argument is NONE, then only Accounts having the default (unassigned) WaterOwner are included in the returned list.If the WaterOwner argument is ALL, then that attribute is ignored. The returned list will contain the names of ALL Accounts on the Object.The list is sorted as described above. Comments WaterOwners and priority dates are properties of Accounts.
Syntax Example
AccountNamesByWaterOwner (%"Heron Reservior", "Contractor2")
Return Example
{"Account1","Account2"}
AccountNamesByWaterType
This function evaluates to the list of names of Accounts on the specified Object having the indicated WaterType.

 Description This function returns a list of names of Accounts on a specified Object having the indicated WaterType, sorted in ascending Account priority date order. Accounts which don’t have a priority date are at the end of the list, sorted in ascending name order. Type LIST {STRING} Arguments Type Meaning 1 OBJECT The Object. 2 STRING WaterType name or NONE or ALL Evaluation The set of Accounts on the Object are examined. The names of the Accounts having the specified WaterType are added to the returned list.If the WaterType argument is NONE, then only Accounts having the default (unassigned) WaterType are included in the returned list.If the WaterType argument is ALL, then that attribute is ignored. The returned list will contain the names of ALL Accounts on the Object.The list is sorted as described above. Comments WaterTypes and priority dates are properties of Accounts.
Syntax Example
AccountNamesByWaterType (%"Heron Reservior", "SanJuan")
Return Example
{"Account3","Account4"}
AccountNamesFromObjReleaseDestination and AccountNamesFromObjReleaseDestinationIntra
This function evaluates to the list of names of Accounts on the specified Object having outflow Supplies of the given ReleaseType and Destination.

 Description This function returns a list of names of Accounts on a specified Object where the attributes of the outflow Supplies of the Accounts match the given ReleaseType and Destination. The list is sorted in ascending Account priority date order; Accounts which don’t have a priority date are at the end of the list, sorted in ascending name order. Type LIST {STRING} Arguments Type Meaning 1 OBJECT The Object. 2 STRING ReleaseType name or NONE or ALL 3 STRING Destination name or NONE or ALL Evaluation The set of Accounts on the Object are examined. The outflow Supplies on those Accounts are then examined. The names of the Accounts with Supplies that meet the following requirements are added to the returned list:• Link a different downstream Object, and• Have the indicated ReleaseType, and• Have the indicated DestinationIf the ReleaseType argument or the Destination argument is NONE, then only Supplies having the default (unassigned) attribute of that type are considered.If the ReleaseType argument or the Destination argument is ALL, then that Supply attribute is ignored.The list is sorted as described above.The Intra version of the function will only look at transfer supplies that are within the object. Comments ReleaseTypes and Destinations are properties of Supplies; priority dates are properties of Accounts.
Syntax Example
AccountNamesFromObjReleaseDestination (%"Heron Reservior",
"Account Fill", "Albiquiu")
Return Example
{"DownstreamAcct1", "NaturalFlowAccount"}
AccountPriorityDate
This function evaluates to the priority date of the Account, on the specified Object, having the specified name.

 Description This function returns the priority date of the Account, on the specified object, having the specified name. Type DATETIME Arguments Type Meaning 1 OBJECT The Object 2 STRING The Account name Evaluation The Object’s accounts are examined.If an Account exists with the specified name its priority date is returned. Comments Priority dates are a property of Accounts.It’s an error if either the Object doesn’t have an Account with the specified name or the Account doesn’t have a priority date.
Syntax Example
AccountPriorityDate (%"Reservoir1", "NaturalFlowAcct")
Return Example
@"February 23, 1902"
AnnualEventCount
This function analyzes a slot’s value over some number of years, counting the occurrence of certain events.

 Description Return the number of events which occurred on a slot in a given period. Type NUMERIC Arguments Type Meaning 1 SLOT a slot 2 DATETIME analysis period start date 3 DATETIME analysis period end date 4 DATETIME event period start date 5 DATETIME event period end date 6 NUMERIC value threshold 7 BOOLEAN value threshold is upper bound 8 NUMERIC event threshold 9 BOOLEAN event threshold is upper bound Evaluation See the on-line documentation for AnnualEventStats, which performs identical computation, but returns more information. This function returns only the number of events which occurred in the analysis period. Comments
Syntax Example
AnnualEventCount(\$ "Lottawatta Reservoir.Outflow", @"24:00:00 February 28, 1994", @"24:00:00 January 31, 2005", @"24:00:00 May 31", @"24:00:00 August 31", 100.0, TRUE, 2.0, TRUE)
Return Example
102.0000
AnnualEventLastOccurrence
This function analyzes a slot’s value over some number of years, noting the last occurrence of a certain type of event.

 Description Return the number of event periods which occurred after the last event on a slot. Type NUMERIC Arguments Type Meaning 1 SLOT a slot 2 DATETIME analysis period start date 3 DATETIME analysis period end date 4 DATETIME event period start date 5 DATETIME event period end date 6 NUMERIC value threshold 7 BOOLEAN value threshold is upper bound 8 NUMERIC event threshold 9 BOOLEAN event threshold is upper bound Evaluation See the on-line documentation for AnnualEventStats, which performs identical computation, but returns more information. This function returns only the number of event periods which occurred after the last event. If no events occurred, then this is the number of event periods. Comments
Syntax Example
AnnualEventLastOccurrence(\$ "Lottawatta Reservoir.Outflow", @"24:00:00 February 28, 1994", @"24:00:00 January 31, 2005", @"24:00:00 May 31", @"24:00:00 August 31", 100.0, TRUE, 2.0, TRUE)
Return Example
2.00000
AnnualEventStats
This function analyzes a slot’s value over some number of years, noting the occurrence of certain events.

 Description Collects and returns statistics on annual events occurring on a slot. Type LIST Arguments Type Meaning 1 SLOT a slot 2 DATETIME analysis period start date 3 DATETIME analysis period end date 4 DATETIME event period start date 5 DATETIME event period end date 6 NUMERIC value threshold 7 BOOLEAN value threshold is upper bound 8 NUMERIC event threshold 9 BOOLEAN event threshold is upper bound Evaluation The analysis period start and end dates define the period during which the analysis will be performed. Within the analysis period, only the timesteps which occur on or between the day and month of the event period start and end dates are considered. Each of these periods within the analysis period is called an event period. At each event period, an event can either occur or not.An event is defined by the value threshold and comparison type and the subevent count threshold and comparison type. At each timestep within an event analysis period, the slot’s value is compared to the threshold value. If the value threshold is an upper bound and the slot’s value is greater than the value threshold, then a subevent is said to have occurred at that timestep; similarly, if the value comparison is a lower bound and the slot’s value is less than the value threshold, then a subevent is said to have occurred. After the subevents within an event analysis period have been noted, then they are counted up and compared to the subevent count threshold. If the subevent count threshold is an upper bound and the number of subevents which occurred in an event analysis period is greater than the subevent count threshold, then an event is said to have occurred, and similarly, if the subevent count comparison is a lower bound and the number of subevents which occurred in an event analysis period is less than the subevent count threshold, then an event is said to have occurred.The return list contains the following items (listed in order):• The total number of event periods.• The number of events which occurred.The number of event periods which occurred after the last event. If no events occurred, then this is the number of event periods. Comments As defined above, the first and last event periods might be of shorter duration than the other event periods. For example, if the analysis period is July 1, 1980 through June 30, 1989 and the event period is May 1 through September 30, then the first event period will be July 1, 1980 through September 30, 1980; subsequent event periods will be from May 1 through September 30, until the last event period, which will be from May 1, 1989, through June 30, 1989.If the event period contains the end of February, then event periods during leap years will also have a different duration. It is an error for the start or end date of the event period to be February 29, which does not exist in each year.Event periods can span year boundaries. For example, if the event period begin is December and the event period end is January, then each event period will be from December of one year to January of the next.One can leave the year field of the event period start or end date unspecified, if one is using a format which contains that component, such as the month/day/year format. E.g., one could specify the event start as @"6:00 May 1". The year component of the event period start and end date is ignored whether or not it is specified.Any missing value in the slot’s series is treated as a non-subevent.The comparison with the value threshold is done to within 0.01% of the threshold’s value. That is, values which are within 0.01% of the threshold’s value are considered to have exceeded the threshold.
Syntax Example
AnnualEventStats(\$ "Lottawatta Reservoir.Outflow",
@"24:00:00 February 28, 1994",
@"24:00:00 January 31, 2005",
@"24:00:00 May 31",
@"24:00:00 August 31",
100.0,
TRUE,
2.0,
TRUE )
Note:  This call will determine how often outflow from Lottawatta Reservoir exceeded 100 cfs more than two times between May and August in an eleven year period starting in 1994.
Return Example
{11.00, 3.00, 2.00}
There were eleven event periods, In 3 of those, the flow exceeded 100cfs more than 2 times, and there were 4 event periods (i.e the summers of 2001, 2002, 2003, and 2004) after the last event in 2001.
AvgObjectsAggregatedOverTime
This function returns a single numeric value obtained by averaging several objects’ aggregated slot values. The objects’ slot values may be aggregated as a SUM, AVG, MIN, or MAX over a specified time range.

 Description Aggregates several objects’ values, each of which is the result of aggregating a slot’s values over time. Type NUMERIC Arguments Type Meaning 1 STRING Subbasin name 2 STRING slot name 3 STRING aggregation function (SUM, AVG, MIN, or MAX) 4 STRING aggregation filter (INPUT, OUTPUT, or ALL) 5 BOOLEAN time conversion option (TRUE or FALSE) 6 DATETIME start date 7 DATETIME end date Evaluation A list of slots is generated by searching all of the objects in the Subbasin argument for slots which match the slot name argument. If the time conversion option argument is TRUE, and the values to be aggregated are of the FLOW unit type, the values are multiplied by their corresponding timestep length to convert them to values of the unit type VOLUME. Next, each slot’s values are aggregated according to the aggregation function argument over the time range of the datetime arguments. During each of these slot aggregations, any values which do not satisfy the aggregation filter argument are ignored. Finally, all of the object’s aggregated slot values are averaged. Mathematical Expression Comments If the time conversion option argument is TRUE, but the unit of the slot values is not FLOW, RiverWare aborts the run with an error.If none of the values for a slot satisfy the aggregation filter argument, the SUM aggregation function yields an aggregated value of 0.0 for that slot, while the AVG, MIN, and MAX aggregation functions abort RiverWare with an error.
Syntax Example
AvgObjectsAggregatedOverTime("upper basin",
"Inflow",
"MAX",
"ALL",
TRUE,
@"October, Previous Year",
@"September, Current Year")
Return Example
52623.32 "cms"
AvgObjectsAtEachTimestep
This function evaluates to a list. Each item of the list is a list comprised of the datetime at which the average was performed, and the value of the average.

 Description Average several object’s slot values, for each timestep in a range. Type LIST{LIST{DATETIME, NUMERIC}} Arguments Type Meaning 1 STRING Subbasin name 2 STRING slot name 3 STRING aggregation filter (INPUT, OUTPUT, or ALL) 4 BOOLEAN time conversion option (TRUE or FALSE) 5 DATETIME start date 6 DATETIME end date Evaluation A list of slots is generated by searching all of the objects in the Subbasin argument for slots which match the slot name argument. If the time conversion option argument is TRUE, and the values to be averaged are of the FLOW unit type, the values are multiplied by their corresponding timestep length to convert them to values of the unit type VOLUME. Next, all of the object’s slot values are averaged, yielding one value for each timestep in the time range of the datetime arguments. The function returns a list of two items, where the first and second items of the inner lists are the datetime and the average value, respectively. Mathematical Expression Comments If the time conversion option argument is TRUE, but the unit of the slot values is not FLOW, RiverWare aborts the run with an error.If none of the values for a slot satisfy the aggregation filter argument, the SUM aggregation function yields an aggregated value of 0.0 for that slot, while the AVG, MIN, and MAX aggregation functions abort RiverWare with an error.
Syntax Example
AvgObjectsAtEachTimestep("upper basin", "Storage", "ALL", FALSE
@"October, Previous Year",
@"September, Current Year")
Return Example
For a model with a 1 Month timestep, the above function would return something like:
{ { 24:00 October 31, 1996, 1233232.2 "m3" },
{ 24:00 November 30, 1996, 1067478.3 "m3" },
....
{ 24:00 September 30, 1997, 1563456.7 "m3" } }
AvgTimestepsAggregatedOverObjects
This function evaluates to a single numeric value. This value is the average, over time, of values resulting from aggregating several objects slot values at each timestep.

 Description Aggregate over a timeseries of values, each of which is the result of aggregating several objects’ slot values. Type NUMERIC Arguments Type Meaning 1 STRING Subbasin name 2 STRING slot name 3 STRING aggregation function (SUM, AVG, MIN, or MAX) 4 STRING aggregation filter (INPUT, OUTPUT, or ALL) 5 BOOLEAN time conversion option (TRUE or FALSE) 6 DATETIME start datetime 7 DATETIME end datetime Evaluation A list of slots is generated by searching all of the objects in the Subbasin argument for slots which match the slot name argument. If the time conversion option argument is TRUE, and the values to be aggregated are of the FLOW unit type, the values are multiplied by their corresponding timestep length to convert them to values of the unit type VOLUME. Next, all of the objects’ slot values are aggregated according to the aggregation function argument for each timestep in the time range of the datetime arguments. During each of these slot aggregations, any values which do not satisfy the aggregation filter argument are ignored. Finally, the timeseries of object aggregated slot values are averaged. Mathematical Expression Comments If the time conversion option argument is TRUE, but the unit of the slot values is not FLOW, RiverWare aborts the run with an error.If none of the values for a slot satisfy the aggregation filter argument, the SUM aggregation function yields an aggregated value of 0.0 for that slot, while the AVG, MIN, and MAX aggregation functions abort RiverWare with an error.
Syntax Example
AvgTimeStepsAggregatedOverObjects ("upper basin",
"Storage",
"MAX",
"ALL",
FALSE,
@"October, Previous Year",
@"September, Current Year")
Return Example
230000 "m3"
AvgTimestepsForEachObject
This function evaluates to a list. Each item of the list is a list comprised of the object name and the average value of the slot on that object for the time range specified.

 Description Average a slot’s values over a time range, for each object in a subbasin. Type LIST {LIST {OBJECT, NUMERIC}} Arguments Type Meaning 1 STRING Subbasin name 2 STRING slot name 3 STRING aggregation filter (INPUT, OUTPUT, or ALL) 4 BOOLEAN time conversion option (TRUE or FALSE) 5 DATETIME start datetime 6 DATETIME end datetime Evaluation A list of slots is generated by searching all of the objects in the Subbasin argument for slots which match the slot name argument. For each object, the slot’s values are averaged over every timestep in the range of the datetime arguments. Any values which do not satisfy the aggregation filter argument are ignored during the calculation. If the time conversion option argument is TRUE, and the values to be aggregated are of the FLOW unit type, the values are first multiplied by their corresponding timestep length to convert them to values of the unit type VOLUME. Mathematical Expression Comments If the time conversion option argument is TRUE, but the unit of the slot values is not FLOW, this function aborts the run with an error. If none of the values for a slot satisfy the aggregation filter argument, this function also aborts RiverWare with an error.
Syntax Example
AvgTimestepsForEachObject("upper basin", "Storage", "ALL", TRUE,
@"October, Previous Year",@"September, Current Year")
Return Example
For a model with a 1 Month, the above function would return something like:
{ { %"Res1", 1233232.2 "m3" }, { %"Res2", 1067478.3 "m3" },
{ %"Res3", 1997, 1563456.7 "m3" } }
Ceiling
This function rounds a numeric value up to the nearest multiple of a numeric factor.

 Description The ceiling numeric operation, to a multiple of a factor. Type NUMERIC Arguments Type Meaning 1 NUMERIC the value 2 NUMERIC the factor Evaluation Converts the value into the units of the factor, then returns the smallest integral multiple of the factor which is not less than the converted value.The returned value has the units of the factor. Comments If the scalar portion of the factor is 1.0, then this function simply returns the ceiling of the value expressed in the units of the factor.If the two arguments are of a different unit type, this function aborts the run with an error.See also “RoundToFactor” and “Floor”.
Syntax Example
Ceiling("Dry Reservoir.Pool Elevation"[], 100.0 "ft")
Return Example
400 "ft"
ColumnLabel

 Description Returns the label associated with a given column of a table slot or aggregate series slot. Type STRING Arguments Type Meaning 1 SLOT A table slot or agg series slot. 2 NUMERIC The column index (0-based). Evaluation Returns the label of the column of the slot which has the given index. Comments It is an error to provide an illegal index (e.g., an index of 4 with a table which has only 4 columns). If the column index is legal but there is no label for that column, then the empty string is returned: " ".
Syntax Example
ColumnLabel(DataObjA.CoeffTable, 2)
Return Example
"Coefficient 3"
ColumnLabels

 Description Returns a list containing the labels of the columns of a given table slot or agg. series slot, in order. Type LIST of STRING values Arguments Type Meaning 1 SLOT A table slot or agg. series slot Evaluation Returns the label of the column of the table slot which has the given index. Comments It is an error if the input slot has a type other than table slot or agg. series slot. For each column, if no label exists the empty string is returned.
Syntax Example
ColumnLabels(DeepLake.Elevation Volume Table)
Return Example
{“Pool Elevation”, “Storage”}
CompletePartialDate

 Description Fill in the missing components of a partially specified date/time. Type DATETIME Arguments Type Meaning 1 DATETIME a partially specified date/time. 2 DATETIME a source date/time, used to complete the other date. Evaluation Fills in the missing components of a partially specified date value. The missing component values are taken from the second parameter, a date value which, if not fully specified, should have at least the components which are missing from the date which is being completed.See the following syntax examples. See “PreviousDate” and “NextDate” for details on related functions. Comments The behavior is not defined if the resulting date is not valid; for example, if the day of month is not valid for the month and year.
Syntax Example
CompletePartialDate(@"March", @"t")
Return Example
24:00 March 2, 1994
(assuming the @”t” is the 2nd day of some month in 1994)
ComputeReservoirDiversions

 Description Used to meet multiple water user demands using multiple reservoir diversions Type LIST{LIST {SLOT, NUMERIC, OBJECT}} Arguments Type Meaning 1 STRING The computational subbasin used for the calculations Evaluation Returns a LIST of slot, value triplets. Each triplet is a LIST that contains a slot (at index zero) and the value to set on that slot (at index one). The slot, value triplets computed by this function are for the subslots on the Supply From Reservoirs slot on each Water User object and the Incoming Available Water slot on each Water User object.For each Water User in the specified subbasin:• A list of supply reservoirs is generated by following the links to the Supply From Reservoirs slot• The list of reservoirs is ranked by Operating Level in descending order.• Each reservoir makes a diversion to meet the Water User’s Diversion Requested value. This value is limited by: the Maximum Delivery Rate specified on the Water User object that applies to the current reservoir, the Max Diversion specified on the Diversion object that applies to the current reservoir, and the amount of water remaining in the conservation pool.• If the Limit by Reservoir Level method is selected (on the Water User object) a diversion cannot be made if the Demand Reservoir is in the flood pool or has a higher operating level than the supply reservoir.• Each reservoir is visited until the Diversion Requested is met or there are no reservoirs left to consider.• The function returns each subslot on each Supply From Reservoirs slot and the associated value. Also the Incoming Available Water slot on each Water User is returned with the value to be set on that slot. The Incoming Available Water is the sum of all the Supply From Reservoirs subslot values Comments The computational subbasin specified as the argument to this function must contain all the objects relevant to these calculations (Water Users, Diversion Objects, Reservoirs, etc.)The computational subbasin must have a method selected in the Diversions from Reservoirs category. Please consult the help file for the Computational Subbasin object (under Simulation Objects) for more details on this method category.The use of this function requires a specific configuration of objects and method selections. The schematic diagram below displays the required object and link configurations.See “Reservoir Diversions” in USACE‑SWD Modeling Techniques for details on using this function for USACE-SWD.
Syntax Example
ComputeReservoirDiversions("Diversion Basin") if Diversion Basin contains two reservoirs and the WU1 and WU2 water users connected to those reservoirs.
Return Example
{ {"WU1.Supply From Reservoirs.WU1_Divert__dot__Multi Outflow",
2.26534773 "cms", "WU1"},
{"WU1.Incoming Available Water", 2.26534773 "cms", "WU1"},
{"WU2.Supply From Reservoirs.WU2_Divert__dot__Multi Outflow",
0.67960432 "cms", "WU2"},
{"WU2.Incoming Available Water", 0.67960432 "cms", "WU2"} }
Use Example
FOR EACH ( LIST result IN ComputeReservoirDiversions("Diversion Basin")) DO
result<0> [] = result<1>
END FOR EACH
In Figure 5.1, the Diversion slot on each reservoir is linked to the Diversion slot on the Diversion Object. The demands are represented by the Water User objects. The Supply From Reservoirs slot on each Water User is linked to the Multi Outflow slot on each Diversion Object that can act as a supply for that demand. The rule sets the values on the Supply From Reservoirs slots. These propagate to the Multi Outflow slots on the connected Diversion Objects. The Diversion objects solve for their Diversion slot. The Diversion values are passed to the Diversion slot on the Reservoir object and the water is removed from the Reservoir. On each reservoir, the Conservation and Flood Pools method in the Operating Levels category should be selected to instantiate the Bottom of Conservation Pool slot.
Figure 5.1  Schematic Diagram for ComputeReservoirDiversions Function
DateMax
This function returns the later of two dates.

 Description Compare two dates and return that which is chronologically greater. Type DATETIME Arguments Type Meaning 1 DATETIME a date 2 DATETIME another date Evaluation The two dates are resolved and compared, the one which is chronologically greater is returned. Comments
Syntax Example
DateMax(@"t", @"January 1, 2001")
Return Example
If current timestep is March 2, 2002: the function returns @"24:00 March 2, 2002"
If current timestep is May 3, 1999, the function returns @"24:00 January 1, 2001"
DateMin
This function returns the earlier of two dates
.

 Description Compare two dates and return that which is chronologically lesser. Type DATETIME Arguments Type Meaning 1 DATETIME a date 2 DATETIME another date Evaluation The two dates are resolved and compared, the one which is chronologically lesser is returned. Comments
Syntax Example
DateMin(@"t", @"January 1, 2001")
Return Example
If current timestep is May 2, 2002: the function returns @"24:00 January 1, 2001"
If current timestep is May 3, 1999, the function returns @"24:00 May 3, 1999"
DatesInPeriod

 Description Given a periodic slot and a date, this function returns an ordered list of dates representing the beginning time of each interval which begins in the specific period containing the input (reference) date. Type LIST {DATETIME} Arguments Type Meaning 1 SLOT a periodic slot 2 DATETIME a reference date Evaluation Every periodic slot has a period associated with it and this period is divided into intervals. Intervals are either regular (e.g., Days) or irregular (e.g., the beginning of one interval might be 8:00 July 3 of each period). One can map a period (divided into intervals) onto a time line, leading to several specific periods (divided into specific intervals). For example, the period "Year" maps onto specific periods corresponding to each year, such as the specific period which is the year 2003.Providing a reference date serves to indicate a specific period, and this function returns the dates corresponding to the beginning of each time interval which begins in that specific period. Comments When the beginning of an interval occurs exactly at a period boundary (e.g., an interval beginning at "0:00 January 1" with an 1 Year period), then we consider that interval to begin in the period occurring after midnight, not the one before.Not all time intervals (rows) defined in a Periodic Slot will correspond to intervals in a specific period. For example, for a period of Month, an interval might be defined which begins at "12:00 Day 30". This interval does not exist in all months and so for example if the reference date is 12:00 February 1, 2003, then the list returned by this function would not include the date 12:00 February 30, 2003.
Syntax Example
DatesInPeriod(TableA.AvePrecipitation, @"January 1, 2001")
Return Example
If TableA.AvePrecipitation has 3 rows for 0:00 January 1, 6:00 June 15, and 24:00 September 1, Then the above function returns:
{ @"24:00 December 31, 2000", @"6:00 June 15, 2001", @"24:00 September 1, 2001"}
DateToNumber

 Description Given a Date/Time value, returns that date encoded as a numeric value of the type used by slots to containing date/time values. Type NUMERIC Arguments Type Meaning 1 DATETIME The date/time value to encode as a numeric value. Comments Slots representing date/time values have unit type DateTime.The date/time value need not be fully specified, but the return value should only be assigned to a slot with appropriate units. For example, if the value @"January 1" should only be assigned to a slot with units "MonthAndDay".
Syntax Example
DateToNumber(@"t")
Return Example
6508706400.00 - which is equivalent to "06:00 April 3, 2006" (FullDateTime)
Use Example
This function should be used in conjunction with dates on series slots (see “DateTime Values in Slots” in User Interface) and the NumberToDate function (see “NumberToDate”). For a use example, see “Access to DateTime Values Using RPL” in User Interface.
Destinations
This function evaluates to the list of user-defined Destinations.

 Description This function returns a list of the names of all Destinations defined in the Water Accounting System Configuration. Type LIST {STRING} Arguments Type Meaning Evaluation Comments Destinations are properties of Supplies. The returned list does not include the default (NONE) Destination.
Syntax Example
Destinations()
Return Example
{"FarmerA", "City1", "City2"}
DestinationsFromObjectReleaseType
This function evaluates to the list of Destinations which represent outflows from an Object of a specified Release Type.

 Description This function returns a list of unique names of Destination Type of Supplies which represent outflows from a specified Object, and which have the indicated Release Type. Type LIST {STRING} Arguments Type Meaning 1 OBJECT The Object. 2 STRING Release Type name or NONE or ALL Evaluation The set of Accounts on the Object are examined. The outflow Supplies on those Accounts which link a different downstream Object and which have the indicated Release Type are considered. The names of the Destination Types of those Supplies are added to the returned list -- but any given Destination Type name will appear on the list only once.If the Release Type argument is NONE, then only Supplies having the default (unassigned) Release Type are considered.If the Release Type argument is ALL, then that attribute is ignored when considering Supplies. Comments Destination Type and Release Types are properties of Supplies. The returned list can include the default (NONE) Destination Type. Supplies which represent internal flows between two Accounts on the Object are not considered.
Syntax Example
DestinationsFromObjectReleaseType(%"Big Reservior", "Account Fill")
Return Example
{"FarmerA", "City2"}
DispatchCount

 Description Returns the number of dispatch method executions that have occurred since the beginning of the current run. Type NUMERIC Arguments None Meaning Comments Returns the number of dispatch method executions that have occurred since the beginning of the current run, if called during a dispatching run (Simulation or Rulebased Simulation). Otherwise, returns the total number of dispatch executions in the previous dispatching run.
Syntax Example
DispatchCount()
Return Example
12,345
DispatchEndDate
This function returns the last timestep in the model for which dispatching is allowed.

 Description The last dispatch timestep. Type DATETIME Arguments Type Meaning Evaluation Returns the DATETIME that is the last timestep at which the current controller allows dispatching. If this function is called from a context in which the current controller does not have a last dispatch timestep (i.e. optimization), then the end date of the run is returned. Comments The Number of Post-Run Dispatch Timesteps is set on the Run Control Parameters dialog for Simulation or Rulebased Simulation. See “Number of Post-Run Dispatch Timesteps” in User Interface for details on changing the Number of Post-Run Dispatch Timesteps.
Syntax Example
DispatchEndDate()
Return Example
If the Run Finish is March 19, 2011 (timestep of 1 Day) and the Number of Post-Run Dispatch Timesteps is 3, the function will return:
24:00 March 22, 2011
DispatchTime

 Description Returns the accumulated time spent executing dispatch methods since the beginning of the current run. Type NUMERIC Arguments None Meaning Comments Returns the accumulated time spent executing dispatch methods since the beginning of the current run, if called during a dispatching run (Simulation or Rulebased Simulation). Otherwise, returns the total time spent executing dispatch methods in the previous dispatching run
Syntax Example
DispatchTime()
Return Example
67.8 seconds
Div
This function computes the integer division of two numbers.

 Description Integer division of two numbers. Type NUMERIC Arguments Type Meaning 1 NUMERIC the numerator 2 NUMERIC the units to which to convert the numerator 3 NUMERIC the denominator 4 NUMERIC the units to which to convert the denominator Evaluation Converts numerator and denominator into the specified units, then returns the integral division of the converted values, where integral division of x and y is defined as: Comments If the denominator is equal to zero, this function aborts the run with an error.Each of the units arguments must have units which are compatible with the value with which they are associated, otherwise the run is aborted with an error.This function does not use the scalar portion of either of the units arguments.
Syntax Example
Div(10.5 "m", 0.0 "ft", 2.4 "sec", 0.0 "sec")
Return Example
17.00 "0.304800 m/s"
ElevationToArea
These function performs a lookup in a Reservoir object’s Elevation Area Table based on a given elevation and evaluates to the corresponding area.

 Description Find the surface area corresponding to a reservoir’s elevation. Type NUMERIC Arguments Type Meaning 1 OBJECT reservoir object 2 NUMERIC pool elevation Evaluation The pool elevation argument is looked up in the Pool Elevation column, of the Elevation Area Table, of the reservoir object argument, to determine the Surface Area. If the exact elevation is not in the table, the lookup performs a linear interpolation between the two nearest bounding elevations and their corresponding surface areas. Mathematical Expression Comments If the object is not a reservoir, or the reservoir does not have an Elevation Area Table, the function aborts the run with an error (CRSSEvaporationCalc, DailyEvaporationCalc, PanAndIceEvaporation, or InputEvaporation must be selected as the Evaporation and Precipitation Category selected Method.This function will issue an error if the Time Varying Elevation Area method is selected (see “Time Varying Elevation Area” in Objects and Methods). Instead, use the ElevationToAreaAtDate function (see “ElevationToAreaAtDate”).
Syntax Example
Return Example
634547087.2 [m2]
ElevationToAreaAtDate
This function performs a lookup in the Reservoir object’s Elevation Area Table or Elevation Area Table Time Varying based on a given elevation and datetime and evaluates to the corresponding surface area. This function must be used when the Time Varying Elevation Area method is selected. Otherwise, the ElevationToArea function can be used and no DATETIME argument is required. See “Elevation Area Table Time Varying” in Objects and Methods and “Time Varying Elevation Area” in Objects and Methods for details.
 Description Find the surface area corresponding to a reservoir’s elevation. Type NUMERIC Arguments Type Meaning 1 OBJECT reservoir object 2 NUMERIC pool elevation 3 DATETIME the datetime at which to do the conversion Evaluation On the specified reservoir object argument, if the Time Varying Elevation Area method is selected (see “Time Varying Elevation Area” in Objects and Methods), the function will reference the Elevation Area Table Time Varying table (see “Elevation Area Table Time Varying” in Objects and Methods). The function will select the appropriate column to use based on the datetime argument. On timesteps that exactly match a modification date, the previous column is used. The relationship changes only at the end of that timestep and is taken into account when the reservoir dispatches. For this algorithm the previous column relationship is used.Otherwise, the Elevation Area Table is used and the datetime is ignored.Then, the pool elevation argument is looked up in the Pool Elevation column to determine the Surface Area from the appropriate Surface Area column. If the exact elevation is not in the table, the lookup performs a linear interpolation between the two nearest bounding elevations and their corresponding surface areas. Mathematical Expression Comments If the object is not a reservoir, or the reservoir does not have an Elevation Area Table or Elevation Area Table Time Varying, the function aborts the run with an error (i.e. a method must be selected in the Evaporation and Precipitation Category).
Syntax Example
Return Example
634547087.2 [m2]
ElevationToMaxRegulatedSpill
This function performs a lookup in a Reservoir object’s Regulated Spill Table based on a given elevation and evaluates to the corresponding maximum regulated spill.

 Description Find the maximum regulated spill at a given reservoir elevation. Type NUMERIC Arguments Type Meaning 1 OBJECT reservoir object 2 NUMERIC pool elevation 3 DATETIME datetime context for unit conversions Evaluation The pool elevation argument is looked up in the Pool Elevation column, of the Regulated Spill Table, of the reservoir object argument, to determine the Max Regulated Spill. If the exact elevation is not in the table, the lookup performs a linear interpolation between the two nearest bounding elevations and their corresponding maximum regulated spills. Mathematical Expression Comments If the object is not a reservoir, or the reservoir does not have a Regulated Spill Table, the function aborts the run with an error (Regulated; Regulated and Unregulated; Regulated and Bypass; Regulated, Bypass and Unregulated; or Bypass, Regulated and Unregulated must be the Spill category selected method).
Syntax Example
@"t")
Return Example
1783.25 [cms]
ElevationToStorage
This function performs a lookup in a Reservoir object’s Elevation Volume Table based on a given elevation and evaluates to the corresponding storage.

 Description Find the reservoir storage at a given elevation. Type NUMERIC Arguments Type Meaning 1 OBJECT reservoir object 2 NUMERIC pool elevation Evaluation The pool elevation argument is looked up in the Pool Elevation column, of the Elevation Volume Table, of the reservoir object argument to determine the Storage. If the exact elevation is not in the table, the lookup performs a linear interpolation between the two nearest bounding elevations and their corresponding storage values. Mathematical Expression Comments If the object is not a reservoir, the function aborts the run with an error.If the reservoir is a Slope Power Reservoir, the calculation is based only on level storage and does not include any wedge storage effects.This function will issue an error if the Time Varying Elevation Volume method is selected (see “Time Varying Elevation Volume” in Objects and Methods). Instead, use the ElevationToStorageAtDate function described next.
Syntax Example
Return Example
2212323.233 "m3"
ElevationToStorageAtDate
This function performs a lookup in the Reservoir object’s Elevation Volume Table or Elevation Volume Table Time Varying based on a given elevation and datetime and evaluates to the corresponding volume. This function must be used when the Time Varying Elevation Volume method is selected. Otherwise, the ElevationToStorage function can be used and no DATETIME argument is required. See “Elevation Volume Table Time Varying” in Objects and Methods and “Time Varying Elevation Volume” in Objects and Methods.
 Description Find the volume corresponding to a reservoir’s elevation. Type NUMERIC Arguments Type Meaning 1 OBJECT reservoir object 2 NUMERIC pool elevation 3 DATETIME the datetime at which to do the conversion Evaluation On the specified reservoir object argument, if the Time Varying Elevation Volume method is selected, the function will reference the Elevation Volume Table Time Varying table. The function will select the appropriate column to use based on the datetime argument. On timesteps that exactly match a modification date, the previous column is used. The relationship changes at the end of that timestep and is taken into account when the reservoir dispatches. For this algorithm, the previous column relationship is used.Otherwise, the Elevation Volume Table is used and the datetime is ignored. Then, the pool elevation argument is looked up in the Pool Elevation column to determine the Volume from the appropriate column. If the exact elevation is not in the table, the lookup performs a linear interpolation between the two nearest bounding elevations and their corresponding surface areas. Mathematical Expression Comments If the object is not a reservoir, or the reservoir does not have an Elevation Volume Table or Elevation Volume Table Time Varying, the function aborts the run with an error.
Syntax Example
Return Example
634547087.2 [m3]
ElevationToUnregulatedSpill
This function performs a lookup in a Reservoir object’s Unregulated Spill Table based on a given elevation and evaluates to the corresponding unregulated spill.

 Description Find the unregulated spill at a given reservoir elevation. Type NUMERIC Arguments Type Meaning 1 OBJECT reservoir object 2 NUMERIC pool elevation 3 DATETIME datetime context for unit conversions Evaluation The pool elevation argument is looked up in the Pool Elevation column, of the Unregulated Spill Table, of the reservoir object argument, to determine the Unregulated Spill. If the exact elevation is not in the table, the lookup performs a linear interpolation between the two nearest bounding elevations and their corresponding unregulated spills. Mathematical Expression Comments If the object is not a reservoir, or the reservoir does not have an Unregulated Spill Table, the function aborts the run with an error (Unregulated; Regulated and Unregulated; Regulated, Bypass and Unregulated; or Bypass, Regulated and Unregulated must be the Spill selected method).
Syntax Example
@"t")
Return Example
1212.25 [cms]
Exp

 Description Exponentiation of a dimensionless quantity. Type NUMERIC Arguments Type Meaning 1 NUMERIC the operand 2 NUMERIC the exponent Evaluation Returns the result of exponentiating the operand to the power given by the exponent. The return value is dimensionless (has no units). Comments The exponent is not restricted to being an integer (as with the "^" operator), but it is an error for the operand to have units.
Syntax Example
Exp(16.0, 0.5)
Use Example
4.0000 "None"
FilterByObjType
This function evaluates to a list of objects containing objects from the original list which match the specified types.

 Description Filter a list of objects to include only objects of the specified types. Type LIST {OBJECT} Arguments Type Meaning 1 LIST list of objects 2 LIST list of object types to include, where each object type is expressed as a STRING. Evaluation The list of object types to include is parsed and mapped to RiverWare object types. Then, the list of objects is evaluated in order, and each object which is one of the requested object types is added to the returned list.The spellings and capitalization of objects can be found in the Subbasin Manager under the Automatic tab. Mathematical Expression Comments The order of objects is preserved from the argument object list to the returned object list. The list arguments may contain any number of items. If either of the arguments is an empty list, the function evaluates to an empty list.
Syntax Example
{"LevelPowerReservoir"})
Syntax Example
FlattenList

 Description This function takes a list and replaces any lists contained within that list with the individual items from those lists. Type NUMERIC Arguments Type Meaning 1 LIST the list to be flattened Evaluation For each item in the input list, if the item is not a list, it is appended to the answer list, if it is a list, then it is flattened and then all of its items are appended to the answer list in turn. Comments
Syntax Example
FlattenList( {1, {2, 3}, {{4}}})
Return Example
{ 1, 2, 3, 4}
FloodControl
This function invokes the selected Flood Control method on a computational subbasin; see “Flood Control” in Objects and Methods.

 Description Invokes computational subbasin’s selected Flood Control method. Type LIST { LIST { SLOT, NUMERIC, OBJECT } } Arguments Type Meaning 1 STRING the name of the computational subbasin Evaluation Runs the selected Flood Control method on the subbasin. Returns a list of { slot, value, object } sets. For each reservoir in the subbasin, three sets may be returned: one for the Outflow slot, one for the Flood Control Release slot on the reservoir, and one for the Target Balance Level on the reservoir. Comments The calling rule is expected to make the assignments of the values to the slots. Typically, this function should be called only once per timestep. To constrain this, use the following as an execution constraint: NOT(HasRuleFiredSucessfully("Rule Name") )See “Low-flow Releases” in USACE‑SWD Modeling Techniques for details on using this function for USACE-SWD.
Syntax Example
FloodControl("Flood Basin") where "Flood Basin" contains Res1 and Res2.
Return Example
{ {"Res1.Outflow", 6344.32 "cfs", "Res1"},
{"Res1.Flood Control Release", 6344.32 "cfs", "res1"},
{"Res1.Target Balance Level", 8.32, "res1"} ,
{"Res2.Outflow", 3243.02 "cfs", "Res2"},
{"Res2.Flood Control Release", 2312.20 "cfs", "Res2"},
{"Res2.Target Balance Level", 8.32, "Res2"} }
Use Example
FOREACH (LIST triplet IN FloodControl( "Flood Basin" )) DO
( triplet<0> )[] = triplet<1>
ENDFOREACH
Floor
This function rounds a numeric value down to the nearest multiple of a numeric factor.

 Description The floor numeric operation, to a multiple of a factor. Type NUMERIC Arguments Type Meaning 1 NUMERIC the value 2 NUMERIC the factor Evaluation Converts the value into the units of the factor, then returns the largest integral multiple of the factor which is not greater than the converted value.The returned value has the units of the factor. Comments If the scalar portion of the factor is 1.0, then this function simply returns the floor of the value expressed in the units of the factor.If the two arguments are of a different unit type, this function aborts the run with an error.See also “Ceiling” and “RoundToFactor”.
Syntax Example
Floor("Wet Reservoir.Pool Elevation"[], 100.0 "ft")
Return Example
If Wet Reservoir.Pool Elevation[] is 5343.35ft, then the above example will evaluate to 5300.0 ft
FlowToVolume
This function evaluates to the volume of water corresponding to a flow over a timestep.

 Description The volume of water resulting from a steady flow over a timestep. Type NUMERIC Arguments Type Meaning 1 NUMERIC constant flow to be converted 2 DATETIME timestep over which to convert Evaluation The number of seconds in the timestep of the datetime argument is determined. Then, the flow argument is multiplied by this number of seconds. Returns value in units of volume. Mathematical Expression Comments If the flow argument is entered in units containing a "/month" component, it is scaled to reflect the length of the month indicated by the timestep argument before being multiplied by this timestep length.
Syntax Example
FlowToVolume(Lake Powell.Inflow[], @"t")
Return Example
6155584.04 [m3]
Fraction
This function returns the fractional remainder after dividing two numbers.

 Description The fractional remainder after division. Type NUMERIC Arguments Type Meaning 1 NUMERIC the numerator 2 NUMERIC the denominator Evaluation Converts the numerator into the units of the denominator, divides the result by the denominator, then returns the fractional portion of the division. In other words:The returned value has the units of factor. Comments If the scalar portion of the denominator is 1.0, then this function simply returns the fractional portion of the first argument when it is expressed in the units of the denominator.If the values are of a different unit type, this function aborts the run with an error.
Syntax Example
Fraction("Whitewater Creek.Inflow"[], 1.0 "cms")
Return Example
If Whitewater Creek.Inflow is 134.3 cfs, the above function returns:
0.80295250 "cms"
Get3DTableVals

 Description Return the contents of a Table Slot that is structured for 3D table interpolation. Type LIST{LIST {NUMERIC LIST{NUMERIC} LIST{NUMERIC}}} Arguments Type Meaning 1 SLOT the table slot whose values are to be returned. 2 NUMERIC z column index (zero-based) 3 NUMERIC x column index (zero-based) 4 NUMERIC y column index (zero-based) Evaluation Returns the contents of a 3D table as a list of the table values associated with successive z value. For each distinct z value in the table slot, the returned list contains a sublist with the following values:1) The current z value2) The list of x values associated with the current z value3) The list of y values associated with the current z value Comments Units are not required for row and column indices and, if provided, will be ignored.In the context of rulebased simulation, if one of the slot’s values is NaN, the function exits the rule with an early termination.
Syntax Example
Get3DTableVals(Wet Reservoir.Plant Power Table, 0, 1, 2)

Turbine Release (cms)
Power (HP)
320
0.00
0
320
120.32
470
340
5.00
10
340
127.32
500
Return Example
{{320.00 "m", {0.00 "cms", 120.32 "cms"}, {0 "HP", 470 "HP"}},
{340.00 "m", {5.00 "cms", 127.32 "cms"}, {10 "HP", 500 "HP"}}}
Get3DTableValsSkipNaN

 Description Return the contents of a Table Slot that is structured for 3D table interpolation. Type LIST{LIST {NUMERIC LIST{NUMERIC} LIST{NUMERIC}}} Arguments Type Meaning 1 SLOT the table slot whose values are to be returned. 2 NUMERIC z column index (zero-based) 3 NUMERIC x column index (zero-based) 4 NUMERIC y column index (zero-based) Evaluation Returns the contents of a 3D table as a list of the table values associated with successive z value. For each distinct z value in the table slot, the returned list contains a sublist with the following values:1) The current z value2) The list of x values associated with the current z value3) The list of y values associated with the current z value Comments Units are not required for row and column indices and, if provided, will be ignored.In the context of rulebased simulation, if one of the slot’s values is NaN, all values in that row and rows below it are ignored.
Syntax Example
Get3DTableVals(Wet Reservoir.Plant Power Table, 0, 1, 2)

Turbine Release (cms)
Power (HP)
320
0.00
0
320
120.32
470
340
5.00
10
340
127.32
500
NaN
NaN
NaN
Return Example
{{320.00 "m", {0.00 "cms", 120.32 "cms"}, {0 "HP", 470 "HP"}},
{340.00 "m", {5.00 "cms", 127.32 "cms"}, {10 "HP", 500 "HP"}}}
GetAccountFromSlot

 Description Return the name of a slot’s account. Type STRING Arguments Meaning 1 SLOT The slot whose account is returned. Comments It is an error if the slot is not on an account.
Syntax Example
GetAccountFromSlot(\$"ResA^Municipal.Inflow")
Return Example
"Municipal"
GetAllNamedBasins
This function evaluates to a list containing the names of the user defined subbasins in a model.

 Description The names of all user defined subbasins in the current model, expressed as strings. Type LIST {STRING} Arguments none Meaning Evaluation The function first retrieves a list of all defined subbasins in the model, then filters out any automatic subbasins (object type basins generated by RiverWare). Comments If there are no user defined subbasins in the model, this function evaluates to an empty list.
Syntax Example
GetAllNamedBasins()
Return Example
{"Upper", "Flood Control", "Lower"}
GetColMapVal

 Description Get a column map value from a periodic slot given a date and a value. This is the inverse of the way values are usually accessed in periodic slots with column maps (i.e., given a date and column map value, find the corresponding slot value). Type NUMERIC Arguments Type Meaning 1 SLOT The periodic slot to be accessed. 2 DATETIME The date to be used to index into the time dimension of the Periodic Slot (its row map). 3 NUMERIC The value to use for the lookup, having the same type of units as the values in the periodic slot itself. Evaluation If the default access method for the table is lookup, then we first find the row whose associated time interval contains the input date. We then find the two consecutive values in that row whose values bracket the input value. We then find the column map values associated with these two values, and return a value interpolated between them according to where the input value falls between its two bracketing values.If the default access method is interpolation then the procedure described above is followed for the row whose time interval follows the given date, and the return value is interpolated between the values found for the two rows. Comments The input slot must be a periodic slot with a column map, the numeric value must have units compatible with the units of the periodic slot, for the relevant time intervals, the slot values must be either a monotonically non-decreasing or monotonically non-increasing function of the column map values, and the input value must fall within the domain of that function. If there are multiple possible return values, i.e., if the input value appears for multiple columns, then the largest column map value is returned.
Syntax Example
GetColMapVal(Meander Res.Operating Level Table, @"t", 1.0)
Return Example
2.323
GetColumnIndex

 Description The index of the table slot or agg. series slot column whose name matches a string. Type NUMERIC Arguments Type Meaning 1 SLOT the table slot or agg. series slot in which to find a column 2 STRING the name of the column to match Evaluation The labels of the slot columns are compared to the string argument until a match is found. Comments Slot column and row indices are zero based and have units of type [NONE]. If the specified slot is not a table slot or agg. series slot, or the specified string is not the label of a column on the slot, this function aborts the run with an error. If several columns of the slot match the string argument, this function evaluates to the index of the left-most matching column.The matching process treats sequences of white space characters as a blank; for example, the input string “ ab c “ will match a column with the label “ab c.” This allows the method to match labels that are displayed on multiple lines because they contain a carriage return character.
Syntax Example
GetColumnIndex(RiverData.Minimum Flow,"Dolores")
Return Example
0.000
GetDate

 Description Interpret a string as a date. Type DATETIME Arguments Type Meaning 1 STRING Textual representation of a date/time. Evaluation Returns the date which corresponds to the input text. Legal text is the same as is legal for symbolic date/times. For example, the expression:GetDate("January 1, Current Year")is exactly equivalent to the expression:@"January 1, Current Year".
Syntax Example
GetDate("January 20, 1996")
Return Example
@"24:00 January 20, 1996"
GetDates
This function evaluates to a list of datetimes; from a start datetime to an end datetime, with a given interval separating the dates.

 Description Generate a list of datetimes between two datetimes at a given interval. Type LIST {DATETIME} Arguments Type Meaning 1 DATETIME starting datetime 2 DATETIME ending datetime 3 STRING string representation of a datetime interval expressed as an integer, a space, and a time unit. Evaluation The starting datetime and ending datetime; which may be specified symbolically, are converted into actual datetimes. The string representation of the interval is resolved into a time length. Then, a list is created beginning with the starting datetime. The time length is added to each previous datetime in the list until the resulting datetime is later than the ending datetime. Mathematical Expression Comments If the ending date is before the starting date, the function evaluates to an empty list. If the ending date is equal to the starting date, or if the time interval is larger than the interval between the starting and ending dates, the function evaluates to a list which only contains the start date.The accepted datetime interval units are:• hours or Hours• days or Days• weeks or Weeks• months or Months• years or Years
Syntax Example
GetDates(@"January 20, 1996", @"January Max DayOfMonth, 1996",
"6 Hours"}
Return Example
{@"24:00 January 20, 1996", @"06:00 January 21, 1996", @"12:00 January 21, 1996", ...}
GetDatesCentered
This function evaluates to a list of datetimes, centered around a given date.

 Description Generate a list of datetimes separated by a given interval, and centered at a given date. If desired, dates not within the run duration are filtered out of the list. Type LIST {DATETIME} Arguments Type Meaning 1 DATETIME center datetime 2 NUMERIC number of dates to return in the list 3 STRING string representation of a datetime interval expressed as an integer, a space, and a time unit 3 BOOLEAN whether to limit return dates to those within the run Evaluation The center datetime, which may be specified symbolically, is converted into an actual datetime. The string representation of the interval is resolved into a time length. Then a list is created with the given number of dates, each separated by the given time interval. The center date is always included in this list, with an equal number of dates appearing before and after it (in the case of an odd number of dates). If their are an even number of dates, then there is one more date appearing before the center date than appear after. After the list has been created, if the user has specified that they only want dates within the run duration, then all other dates are filtered out of the return list. Mathematical Expression Comments The accepted datetime interval units are:• hours or Hours• days or Days• weeks or Weeks• months or Months• years or Years
Syntax Example
GetDatesCentered(@"January 20, 1996", 3, "6 Hours", true}
Return Example
{@"18:00 January 20, 1996", @"24:00 January 20, 1996", @"06:00 January 21, 1996"}
GetDayOfMonth
This function evaluates to a number which represents the day of the month of the given datetime in units of time.

 Description The day of the month as a unit of time. Type NUMERIC Arguments Type Meaning 1 DATETIME the datetime whose day of month to determine Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the day of the month in which the datetime is, is determined. This function requires that the datetime be at least partially specified with a valid month and day, E.g. @"January 1" or @"Current Month 23" will work. Comments When displayed, the return value will be displayed according to the active unit scheme’s time unit type rule. For example, if the active unit scheme displays Time values as Hours, then the return value for @”January 2” will be displayed as 48 “hours”.To convert the return value into a dimensionless value representing the number of days, divide it by 1 “day”.As elsewhere in RiverWare 24:00 hours is considered to be the day which is ending, and 00:00 hours is considered to be the day which is just beginning.
Syntax Example
GetDayOfMonth(@"February 23, 1996")
Return Example
23.0 “day” or 553 “hour”
GetDayOfYear
This function evaluates to a number which represents the day of the year of the given datetime.

 Description The day of the year as a one-based integer in units of time. Type NUMERIC Arguments Type Meaning 1 DATETIME the datetime whose day of the year to determine Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the day of the year in which the datetime is contained, is determined.This function requires that the specified datetime resolve to a fully specified datetime or an error will occur. Comments When displayed, the return value will be displayed according to the active unit scheme’s time unit type rule. For example, if the active unit scheme displays Time values as Hours, then the return value for @”January 2” will be displayed as 48 “hours”.To convert the return value into a dimensionless value representing the number of days, divide it by 1 “day”.As elsewhere in RiverWare, 24:00 hours is considered to be the day which is ending, and 00:00 hours is considered to be the day which is just beginning.
Syntax Example
GetDayOfYear(@"February 23, 1996")
Return Example
54.0 “day” or 1296 “hour”
GetDaysInMonth
This function evaluates to the number of days in the month of the given datetime.

 Description The number of days in the month in units of time. Type NUMERIC Arguments Type Meaning 1 DATETIME the datetime of any time within the month Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the number of days in the month in which the datetime is contained, is determined. This function requires that the specified datetime resolve to a fully specified datetime or an error will occur. Comments When displayed, the return value will be displayed according to the active unit scheme’s time unit type rule. For example, if the active unit scheme displays Time values as Hours, then the return value for @”January 2” will be displayed as 744 “hours”.To convert the return value into a dimensionless value representing the number of days, divide it by 1 “day”.As elsewhere in RiverWare, 24:00 hours is considered to be the day which is ending, and 00:00 hours is considered to be the day which is just beginning.
Syntax Example
GetDaysInMonth(@"February 23, 1996")
Return Example
29.0 “day” or 696 “hour”
GetDisplayVal

 Description This function takes a series or periodic slot and a date and returns the value of the slot at the given date, in units based on the display scale and units for that slot. Type NUMERIC Arguments Type Meaning 1 SLOT the series or periodic slot whose value is to be returned 2 DATETIME the datetime of the value to be returned Evaluation Comments The function returns an error and aborts the run if the input slot is not a series or periodic slot, if the date is not fully specified, or if the date is not contained in the series.
Syntax Example
GetDisplayVal(MyReservoir.Outflow, @"24:00 February 23, 1996")
Return Example
3.03012926 "1000 * cfs"
GetDisplayValByCol

 Description This function takes an agg series slot or periodic slot, a date, and a column, and returns the value of the slot in the given column and at the given date, in units based on the display scale and units for that slot. Type NUMERIC Arguments Type Meaning 1 SLOT the series or periodic slot whose value is to be returned 2 DATETIME the datetime of the value to be returned 3 NUMERIC the column, interpreted as a 0-based integral index Evaluation The function returns and error and aborts the run if the input slot is not of an appropriate type, if the date is not fully specified, or if the date is not contained in the series.
Syntax Example
GetDisplayValByCol(MyData.Flow, @"February 23, 1996", 1.0)
Return Example
3.03012926 "1000*cfs"
GetElementName
Given an element in an aggregate object, this function returns its name.

 Description Return the name of an element in an aggregate object, without the name of the object’s name prepended. Type STRING Arguments Type Meaning 1 OBJECT the element of an aggregate object (e.g., a WaterUser within an AggDiversionSite) whose name is to be returned. Evaluation The function returns the name of the element object. Comments This function returns only the name of the element itself, without the name of the parent aggregate object. If the full name is desired, then one may use the built-in RPL operation STRINGIFY.If the object argument is not an element of an aggregate object, then the run is aborted with an error.
Syntax Example
GetElementname(% "Below Abiquiu Diversions:Chamita")
Return Example
"Chamita"
GetEnsembleTraceValue
Given a keyword name for trace metadata when using an ensemble, return the keyword value for the current trace executing in a run.

 Description Return the value for a trace keyword for the current trace executing in a run. Type STRING Arguments Type Meaning 1 STRING the name of a trace metadata keyword. Evaluation The function returns the value for the trace keyword for the currently executing run. Comments If the function is called outside of a run or if the trace metadata keyword cannot be found, then the function fails.This function would typically be called during a multiple run when input ensembles are used in the MRM configuration. If a single trace is configured for an ensemble dataset to use outside of a multiple run and a DMI with this dataset is invoked during a single run, the metadata for that trace would also be available to query.
Syntax Example
GetEnsembleTraceValue("Hydrology")
Return Example
"Dry"
GetEnsembleValue
Given a keyword name for ensemble metadata when using an ensemble, return the keyword value for the metadata for that run.

 Description Return the value for an ensemble keyword for the current run. Type STRING Arguments Type Meaning 1 STRING the name of an ensemble metadata keyword. Evaluation The function returns the value for the ensemble keyword for the currently executing run. Comments If the function is called outside of a run or if the ensemble metadata keyword cannot be found, then the function fails.This function would typically be called during a multiple run when input ensembles are used in the MRM configuration. If a single trace is configured for an ensemble dataset to use outside of a multiple run and a DMI with this dataset is invoked during a single run, the metadata for that ensemble would also be available to query.
Syntax Example
GetEnsembleValue("Hydrology")
Return Example
"Historical"
GetJulianDate
This function evaluates to the Julian date of the given datetime.

 Description The Julian date of the timestep in units of NONE. Type NUMERIC Arguments Type Meaning 1 DATETIME the datetime whose Julian date to evaluate to Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the Julian date of this timestep is determined.This function requires that the specified datetime resolve to a fully specified datetime or an error will occur. Comments Julian Dates are represented as the number of days from noon GMT on January 1, 4713 B.C. (47120101 12:00 P.M. GMT). Julian Dates in RiverWare also include the decimal fraction of the day down to 0.00001, the equivalent of 1 second.
Syntax Example
GetJulianDate(@"14:31:59 February 23, 1996")
Return Example
2450137.10554398

 Description Given a slot, returns a list of the Objects which contain the slots to which the input slot is linked. Type LIST {OBJECT} Arguments Type Meaning 1 SLOT the slots whose links are to be explored Evaluation For each slot to which the input slot is linked, we determine if that slot is managed by a Objects; if so, it is added to the return list. Thus, an empty list is returned if the slot is not linked to any slots on a Objects. Comments It is considered an error if the input slot is not a Series Slot.
Syntax Example
Return Example
{%"Reach 1", %"Reach 2"}
GetLowerBound

 Description Returns the lower bound for the specified series slot Type NUMERIC Arguments Type Meaning 1 SLOT the slot whose bound is to be returned. Evaluation Comments It is considered an error if the specified slot is not a Series Slot with a valid lower bound. The lower bound is specified in the slot configuration.
Syntax Example
GetLowerBound(“Res A.Power”)
Return Example
0.0 MW
GetLowerBoundByCol

 Description Returns the lower bound for the column of the specified agg series slot. Type NUMERIC Arguments Type Meaning 1 SLOT the agg series slot whose bound is to be returned. 2 NUMERIC the column index (0-based). Evaluation Comments It is considered an error if the input slot is not an Agg Series Slot with a valid lower bound for the given column. The lower bound is specified in the slot configuration.
Syntax Example
GetLowerBoundByCol("Res A.Hydro Block Use", 3)
Return Example
0.0 MWH
GetMaxOutflowGivenHW
This function evaluates to the maximum Outflow from a StorageReservoir, LevelPowerReservoir, or SlopePowerReservoir with the given Pool Elevation at the specified timestep.

 Description The maximum combined outflow of a reservoir, including outlet works or turbine release, and any possible regulated, unregulated, and/or bypass spills. Type NUMERIC Arguments Type Meaning 1 OBJECT the reservoir object for which to calculate 2 NUMERIC the end of timestep pool elevation 3 DATETIME the timestep at which to calculate Evaluation • Unit Generator Power: The turbine release is the sum of the maximum releases for each available turbine, as specified in the Generators Available and Limit table. Each turbine’s maximum release is determined from a table interpolation in the Full Generator Flow table using the operating head as the lookup in the appropriate unit type’s Head for Type n column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Peak Power Equation with Off Peak Spill: The turbine release is the peak release over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Operating Head vs. Generator Capacity table. • Peak Power and Peak and Base: The turbine release is the peak flow over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Best Generator Flow table using the operating head as the lookup in the Head for Type 1 column.• LCRPowerCalc: Because this power method has no turbine release limit, a maximum outflow cannot be calculated. RiverWare issues an error message and aborts the execution of this rule.• Unregulated Spill (if an Unregulated Spill method is selected on the object): The maximum unregulated spill is determined from a table interpolation in the Unregulated Spill Table using the average pool elevation as the Pool Elevation. • Regulated Spill (if a Regulated Spill method is selected on the object): If the Regulated Spill slot is specified by the user (I, Z or R flag), the specified value is used as the maximum regulated spill. Otherwise the maximum regulated spill is determined from a table interpolation in the Regulated Spill Table using the average pool elevation in the Pool Elevation column. Note:  If the MonthlySpill method is selected, the result of GetMaxOutflowGivenInflow is the value in the Maximum Controlled Release table slot.• Bypass (if a Bypass Spill method is selected on the object): If the Bypass slot is specified by the user (I, Z or R flag), the specified value is used as the maximum bypass. Otherwise the maximum bypass is determined from a table interpolation in the Bypass Table using the average pool elevation. All of the individual outflows are then summed to calculate the maximum outflow.The individual outflows are then summed to calculate the maximum outflow. Mathematical Expression Comments The Tailwater Base Value is automatically added as a dependency to the calling rule.
Syntax Example
GetMaxOutflowGivenHW(%"Glen Canyon Dam", 3704 "ft", @"June 3, 1983"}
Return Example
1283.7047 "cms"
GetMaxOutflowGivenInflow
This function evaluates to the maximum Outflow from a StorageReservoir, LevelPowerReservoir, or SlopePowerReservoir with the given Inflow at the specified timestep.This function takes into account all side flows, sinks and sources. The inflow argument should be the inflow that would go into the Inflow slot on the reservoir. Since the function already considers Hydrologic Inflow, the hydrologic inflow value should NOT be included in the inflow argument.

 Description The maximum combined outflow of a reservoir, including outlet works or turbine release, and any possible regulated, unregulated, and/or bypass spills. Type NUMERIC Arguments Type Meaning 1 OBJECT the reservoir object for which to calculate 2 NUMERIC the average inflow over the timestep 3 DATETIME the timestep at which to calculate Evaluation A convergence algorithm is used in this function; see “Reservoir Convergence” in Objects and Methods for details. The function iterates to convergence by computing the end of timestep storage and pool elevation, the average pool elevation over the timestep, and the following outflows:• Release (if the object is a StorageReservoir): The maximum release is determined from a table interpolation in the Max Release table using the average pool elevation as the lookup in the Pool Elevation column.• Turbine Release (if the object is a LevelPowerReservoir or SlopePowerReservoir): The maximum turbine release is determined based on the selected Power method. This calculation is iterative, since the maximum outflow impacts the reservoir tailwater elevation and operating head, which affect the maximum turbine release. The selected Tailwater method is used to determine the tailwater elevation.• No Power Turbine Flow: The turbine release is determined from a table interpolation in the Max Flow Through Turbines table using the average pool elevation as the lookup in the Reservoir Elevation column.• Plant Power Coefficient: The turbine release is determined from a table interpolation in the Max Turbine Q table using the operating head as the lookup in the Operating Head column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Plant Efficiency Curve: The turbine release is determined from a table interpolation in the Auto Max Turbine Q table using the operating head as the lookup in the Operating Head column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Unit Generator Power: The turbine release is the sum of the maximum releases for each available turbine, as specified in the Generators Available and Limit table. Each turbine’s maximum release is determined from a table interpolation in the Full Generator Flow table using the operating head as the lookup in the appropriate unit type’s Head for Type n column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Peak Power Equation with Off Peak Spill: The turbine release is the peak release over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Operating Head vs. Generator Capacity table. • Peak Power and Peak and Base: The turbine release is the peak flow over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Best Generator Flow table using the operating head as the lookup in the Head for Type 1 column.• LCRPowerCalc: Because this power method has no turbine release limit, a maximum outflow cannot be calculated. RiverWare issues an error message and aborts the execution of this rule. • Unregulated Spill (if an Unregulated Spill method is selected on the object): The maximum unregulated spill is determined from a table interpolation in the Unregulated Spill Table using the average pool elevation as the Pool Elevation. • Regulated Spill (if a Regulated Spill method is selected on the object): If the Regulated Spill slot is specified by the user (I, Z or R flag), the specified value is used as the maximum regulated spill. Otherwise the maximum regulated spill is determined from a table interpolation in the Regulated Spill Table using the average pool elevation in the Pool Elevation column. Note:  If the MonthlySpill method is selected, the result of GetMaxOutflowGivenInflow is the value in the Maximum Controlled Release table slot.• Bypass (if a Bypass Spill method is selected on the object): If the Bypass slot is specified by the user (I, Z or R flag), the specified value is used as the maximum bypass. Otherwise the maximum bypass is determined from a table interpolation in the Bypass Table using the average pool elevation. in the Pool Elevation column.Once the iteration has converged on an ending storage and pool elevation, all of the individual outflows are summed to calculate the maximum outflow Mathematical Expression Comments This function takes into account the following sources and sinks automatically, and thus they should not be included in the inflow value for Argument 2.• The Evaporation and Precipitation category selected Method.• The Bank Storage category selected Method.• The Seepage category selected Method.• Side inflows including: Inflow 2 (Slope Power Reservoir only), Hydrologic Inflow Net, Diversion, Return Flow, Canal Flow, Flow FROM Pumped Storage, and Flow TO Pumped Storage. These slots in addition to Tailwater Base Value are automatically added as dependencies to the calling rule.
Syntax Example
GetMaxOutflowGivenInflow(%"Hoover Dam", 68651 "cfs", @"June, 1983}
Return Example
1283.7047 "cms"
GetMaxOutflowGivenStorage
This function evaluates to the maximum Outflow from a StorageReservoir, LevelPowerReservoir, or SlopePowerReservoir with the given Storage at the specified timestep.

 Description The maximum combined outflow of a reservoir, including outlet works or turbine release, and any possible regulated, unregulated, and/or bypass spills. Type NUMERIC Arguments Type Meaning 1 OBJECT the reservoir object for which to calculate 2 NUMERIC the end of timestep storage 3 DATETIME the timestep at which to calculate Evaluation The ending pool elevation is determined from the ending storage in argument 2 and is averaged with the previous timestep’s ending Pool Elevation to yield an average pool elevation over the timestep. The average pool elevation is then used to compute the following outflows:• Release (if the object is a StorageReservoir): The maximum release is determined from a table interpolation in the Max Release table using the average pool elevation as the lookup in the Pool Elevation column.• Turbine Release (if the object is a LevelPowerReservoir or SlopePowerReservoir): The maximum turbine release is determined based on the selected Power method. This calculation is iterative, since the maximum outflow impacts the reservoir tailwater elevation and operating head, which affect the maximum turbine release. The selected Tailwater method is used to determine the tailwater elevation.• No Power Turbine Flow: The turbine release is determined from a table interpolation in the Max Flow Through Turbines table using the average pool elevation as the lookup in the Reservoir Elevation column.• Plant Power Coefficient: The turbine release is determined from a table interpolation in the Max Turbine Q table using the operating head as the lookup in the Operating Head column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Plant Efficiency Curve: The turbine release is determined from a table interpolation in the Auto Max Turbine Q table using the operating head as the lookup in the Operating Head column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Unit Generator Power: The turbine release is the sum of the maximum releases for each available turbine, as specified in the Generators Available and Limit table. Each turbine’s maximum release is determined from a table interpolation in the Full Generator Flow table using the operating head as the lookup in the appropriate unit type’s Head for Type n column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Peak Power Equation with Off Peak Spill: The turbine release is the peak release over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Operating Head vs. Generator Capacity table. • Peak Power and Peak and Base: The turbine release is the peak flow over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Best Generator Flow table using the operating head as the lookup in the Head for Type 1 column.• LCRPowerCalc: Because this power method has no turbine release limit, a maximum outflow cannot be calculated. RiverWare issues an error message and aborts the execution of this rule.• Unregulated Spill (if an Unregulated Spill method is selected on the object): The maximum unregulated spill is determined from a table interpolation in the Unregulated Spill Table using the average pool elevation as the Pool Elevation. • Regulated Spill (if a Regulated Spill method is selected on the object): If the Regulated Spill slot is specified by the user (I, Z or R flag), the specified value is used as the maximum regulated spill. Otherwise the maximum regulated spill is determined from a table interpolation in the Regulated Spill Table using the average pool elevation in the Pool Elevation column. Note:  If the MonthlySpill method is selected, the result of GetMaxOutflowGivenInflow is the value in the Maximum Controlled Release table slot. Evaluation (continued) • Bypass (if a Bypass Spill method is selected on the object): If the Bypass slot is specified by the user (I, Z or R flag), the specified value is used as the maximum bypass. Otherwise the maximum bypass is determined from a table interpolation in the Bypass Table using the average pool elevation. All of the individual outflows are then summed to calculate the maximum outflow.The individual outflows are summed to calculate the maximum outflow. Mathematical Expression Comments The Tailwater Base Value is automatically added as a dependency to the calling rule.This function will issue an error if the Time Varying Elevation Volume method is selected (see “Time Varying Elevation Volume” in Objects and Methods) and the specified timestep is a modification date on the table.
Syntax Example
GetMaxOutflowGivenStorage(%"Hoover Dam", 17321.400"1000 acre-feet",@"May, 1998"}
Return Example
1283.7047 "cms"
GetMaxReleaseGivenInflow
This function evaluates to the maximum Release, or Turbine Release from a StorageReservoir, LevelPowerReservoir, or SlopePowerReservoir with the given Inflow at the specified timestep.

 Description The maximum release of a reservoir, through outlet works or turbine release. Type NUMERIC Arguments Type Meaning 1 OBJECT the reservoir object for which to calculate 2 NUMERIC the average inflow over the timestep 3 DATETIME the timestep at which to calculate Evaluation A convergence algorithm is used in this function; see “Reservoir Convergence” in Objects and Methods for details. The function iterates to convergence by computing the end of timestep storage and pool elevation, the average pool elevation over the timestep, and the release:• Release (if the object is a StorageReservoir): The maximum release is determined from a table interpolation in the Max Release table using the average pool elevation as the lookup in the Pool Elevation column.• Turbine Release (if the object is a LevelPowerReservoir or SlopePowerReservoir): The maximum turbine release is determined based on the selected Power method. This calculation is iterative, since the maximum outflow impacts the reservoir tailwater elevation and operating head, which affect the maximum turbine release. The selected Tailwater method is used to determine the tailwater elevation.• No Power Turbine Flow: The turbine release is determined from a table interpolation in the Max Flow Through Turbines table using the average pool elevation as the lookup in the Reservoir Elevation column.• Plant Power Coefficient: The turbine release is determined from a table interpolation in the Max Turbine Q table using the operating head as the lookup in the Operating Head column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Plant Efficiency Curve: The turbine release is determined from a table interpolation in the Auto Max Turbine Q table using the operating head as the lookup in the Operating Head column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Unit Generator Power: The turbine release is the sum of the maximum releases for each available turbine, as specified in the Generators Available and Limit table. Each turbine’s maximum release is determined from a table interpolation in the Full Generator Flow table using the operating head as the lookup in the appropriate unit type’s Head for Type n column. If the average pool elevation is less than the Minimum Power Elevation, the turbine release is zero.• Peak Power and Peak and Base: The turbine release is the peak flow over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Best Generator Flow table using the operating head as the lookup in the Head for Type 1 column.• Peak Power Equation with Off Peak Spill: The turbine release is the peak release over the entire timestep. This is calculated by iterating the selected Tailwater method and operating head calculation with a table interpolation in the Operating Head vs. Generator Capacity table. • LCRPowerCalc: Because this power Method has no turbine release limit, a maximum Outflow cannot be calculated. RiverWare issues an error message and aborts the execution of this rule. Mathematical Expression Comments This function takes into account the following sources and sinks automatically, and thus they should not be included in the inflow value for Argument 2.• The Evaporation and Precipitation category selected Method.• The Bank Storage category selected Method.• The Seepage category selected Method.• Side inflows including: Inflow 2 (Slope Power Reservoir only), Hydrologic Inflow Net, Diversion, Return Flow, Canal Flow, Flow FROM Pumped Storage, and Flow TO Pumped Storage. These slots in addition to Tailwater Base Value are automatically added as dependencies to the calling rule.
Syntax Example
GetMaxReleaseGivenInflow(%"Hoover Dam", 68651 "cfs", @"June, 1983"}
Return Example
1283.7047 "cms"
GetMinSpillGivenInflowRelease
This function evaluates to the minimum spill from a StorageReservoir, LevelPowerReservoir, or SlopePowerReservoir with the given inflow and release at the specified timestep.

 Description The minimum required spill through unregulated and regulated spillways. Type NUMERIC Arguments Type Meaning 1 OBJECT the reservoir object for which to calculate 2 NUMERIC the average inflow over the timestep 3 NUMERIC the average release over the timestep 4 DATETIME the timestep at which to calculate Evaluation This function calls the getMinSpillGivenInflowRelease() function on the given reservoir object at the given timestep, and provides it with the average inflow and release over the timestep. A convergence algorithm is used in this function; see “Reservoir Convergence” in Objects and Methods for details. The function iterates to convergence by computing the end of timestep storage and pool elevation, the average HW over the timestep, and the spill: • unregulated spill: calculated from the Unregulated Spill Table based on the average Pool Elevation. See the spill method for more details on how this is computed• regulated and bypass spills: assumed to be zero unless input by the user.• outflow: sum of the calculated spill and the release specified in the function.• pool elevation: solved for by mass balance using the specified inflow and calculated outflow. Mathematical Expressions Comments This function takes into account the following sources and sinks automatically, and thus they should not be included in the inflow value for Argument 2.• The Evaporation and Precipitation category selected Method.• The Bank Storage category selected Method.• The Seepage category selected Method.• Side inflows including: Inflow 2 (Slope Power Reservoir only), Hydrologic Inflow Net, Diversion, Return Flow, Canal Flow, Flow FROM Pumped Storage, and Flow TO Pumped Storage. These slots in addition to the previous timestep’s Pool Elevation and Storage are automatically added as dependencies to the calling rule. Since the function evaluation depends on these slots, any change to their values at the indicated timestep, may impact the function result.
Syntax Example
GetMinSpillGivenInflowRelease(%"Hoover Dam", Hoover Dam.Inflow[],
0.0 "cfs", @"t"}
Return Example
1283.7047 "cms"
GetMonth
This function evaluates to the integer number of the month of the given datetime.

 Description The month number, base 1, in units of NONE. Type NUMERIC Arguments Type Meaning 1 DATETIME the datetime of any time within the month Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the number of the month in which the datetime is contained, is determined. This function requires that the specified datetime resolve to at least a partially specified datetime in the “Month day, year” format with the month specified. Comments As elsewhere in RiverWare, 24:00 hours is considered to be the day which is ending, and 00:00 hours is considered to be the day which is just beginning.
Syntax Example
GetMonth(@"February 23, 1996")
Return Example
2.000
GetMonthAsString
This function evaluates to the string name of the month of the given datetime.

 Description The month name. Type STRING Arguments Type Meaning 1 DATETIME the datetime of any time within the month Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the name of the month in which the datetime is in, is determined. This function requires that the specified datetime resolve to at least a partially specified datetime in the “Month day, year” format with the month specified. Comments As elsewhere in RiverWare, 24:00 hours is considered to be the day which is ending, and 00:00 hours is considered to be the day which is just beginning.
Syntax Example
GetMonthAsString(@"February 23, 1996")
Return Example
"February"
GetNumbers
This function evaluates to a sequence of values in a given range with a given offset.

 Description Returns a sequence of values in a given range with a given offset. Type LIST Arguments Type Meaning 1 NUMERIC the start value 1 NUMERIC the end value 1 NUMERIC the offset Evaluation The end value and offset are converted into the units of the start value. A list is created whose first item is the start value, the second item is the start value plus the offset, and so on, until the next value to be added to the list would not be in the range defined by the start and end value. Comments The units of all values must be compatible. If the offset is positive and the start value is greater than the end value, the return list is empty; similarly, if the offset is negative and the start value is less than the end value, the return list is empty.
Syntax Example
GetNumbers(0.0 [cfs], 10 [cms], 1 [cfs])
Return Example
{0.0 "cfs", 1.0 "cfs", 2.0 "cfs", ... , 352.0 "cfs", 353.0 "cfs"}
GetObject
This function looks for an object on the global workspace with a given name and returns that object, if it exists.

 Description Return the object with a given name. Type OBJECT Arguments Type Meaning 1 STRING the name of the object for which to search. Evaluation The function returns the object with the given name, if it exists. Comments If no object with the given name exists on the global workspace, then the run is aborted with an error.
Syntax Example
GetObject("Heron Reservoir")
Return Example
%"Heron Reservoir"
GetObjectDebt
This function evaluates to the sum of the debts to all accounting exchanges which may be paid by supplies on the given object. If there are no exchange paybacks on the given object, the debt is zero.

 Description The total debt which can be paid by this object. Type NUMERIC Arguments Type Meaning 1 OBJECT the object who’s debt to calculate 2 DATETIME the timestep at which to calculate the debt Evaluation The function loops over all supplies, on all accounts, on the given object. If a supply is an exchange payback source, the value of its debt slot at the given timestep (if known) is added to the cumulative debt of the object. Mathematical Expression Comments If the debt slot of a payback supply at the given timestep is not known, its debt is assumed to be zero. If there are no payback supplies on the given object, the total debt is zero.
Syntax Example
GetObjectDebt(%"Heron Reservoir", @"t")
Return Example
1.823 "m3"
GetObjectFromSlot

 Description Return a slot’s parent object. Type OBJECT Arguments Meaning 1 SLOT The slot whose object is returned. Comments It is an error if the slot is not on a Simulation Object or an account (which is on an Object).
Syntax Example
GetObjectFromSlot(\$"ResA^Municipal.Inflow")
Return Example
%"ResA"
GetPaybackDebt
This function evaluates to the value of the debt slot of the given exchange payback source at the given timestep.

 Description The debt at a payback source. Type NUMERIC Arguments Type Meaning 1 STRING the payback source supply whose debt to calculate 2 DATETIME the timestep at which to calculate the debt Evaluation The function begins by verifying that the string argument is an accounting supply, and that this supply is a payback source. If so, the function evaluates to the value of the payback’s debt slot at the given timestep. Mathematical Expression Comments If the string argument is not a valid supply, or the supply is not a payback source, this function aborts the run with an error. If the debt slot of the payback for which this supply is a source does not contain a value at the given timestep, the function evaluates to zero.
Syntax Example
GetPaybackDebt("Heron SanJuan to WillowAndRioChama SanJuan.Supply",
@"t")
Return Example
1.823 "m3"
GetRowIndex
This function evaluates to the index of the row with the given name in a table slot.

 Description The index of the table slot row whose name matches a string. Type NUMERIC Arguments Type Meaning 1 SLOT the table slot in which to find a row 2 STRING the name of the row to match Evaluation The labels of the slot rows are compared to the string argument until a match is found. Comments Table row and column indices are zero based and have units of type [NONE]. If the specified slot is not a table slot or the specified string is not the label of a row on the slot, this function aborts the run with an error. If several rows of the table slot match the string argument, this function evaluates to the index of the topmost matching row.
Syntax Example
GetRowIndex(RiverData.Minimum Flow,"Dolores")
Return Example
1.00000
GetRowIndexByDate

 Description Given a slot with rows indexed by date, this function returns the 0-basedindex corresponding to a given date. Type NUMERIC Arguments Type Meaning 1 SLOT the slot in which to find a row 2 DATETIME date of the row to match Comments The value -1 is returned if the given date is not within the date range of the slot.This function is applicable to the following types of slot:• Series Slots• Table Series Slots• Periodic SlotIt is considered an error if the slot is not indexed by date (i.e, not one of these types).
Syntax Example
GetRowIndexByDate(DeepReservoir.Inflow,@"t")
Return Example
5.00000
GetRunCycleIndex

 Description Returns the 1-based index of the current cycle through the timesteps in the run time range, in units of NONE. Type NUMERIC Arguments Type Meaning none Comments Rulebased simulations can cycle through the run timesteps more than once each run (see “Run Cycles” in Solution Approaches). This function provides access to the current run cycle, which can be used, for example, within execution constraints to control the cycle on which a rule should execute. If called from outside of a run or when the controller is not Rulebased Simulation or Inline Rulebased Simulation and Accounting, the behavior of this function is undefined.
Syntax Example
GetRunCycleIndex()
Return Example
2.0000
GetRunIndex
This function evaluates to the number of the model run. It is commonly used within a Multiple Run Management ruleset to determine the run which is currently executing.

 Description The number of the currently executing model run, base 1, in units of NONE. Type NUMERIC Arguments Type Meaning none Comments If the current run is not a Multiple Run Management run, this function evaluates to 1. If called from within a pre-MRM run rule of an iterative MRM run, this function evaluates to 1. If called from within a post-run rule of an iterative MRM, this function evaluates to the index of the run which just completed.
Syntax Example
GetRunIndex()
Return Example
3.0000
GetSelectedUserMethod

 Description Given an object and a user method category name, return the name of the selected method. Type STRING Arguments Type Meaning 1 OBJECT the simulation object 2 STRING name of the user method category Comments An error is issued if the object or the category name is not found.
Syntax Example
GetSelectedUserMethod(DeepReservoir,"Power")
Return Example
"Peak Power"
GetSeriesSlots

 Description Returns a list of all of the visible Series Slots on an object. Type LIST{SLOT} Arguments Type Meaning 1 OBJECT The object whose Series Slots are to be returned. Comments If no object with the given name exists on the global workspace, then the run is aborted with an error.
Syntax Example
GetSeriesSlot(%"My Data Object")
Return Example
{\$"My Data Object.Series 1", \$"My Data Object.Series 2"}
GetSlot
This function looks for a slot on the global workspace with a given name and returns that slot, if it exists.

 Description Return the slot with a given name. Type SLOT Arguments Type Meaning 1 STRING the name of the slot for which to search. Evaluation The function returns the slot with the given name, if it exists. Comments If no slot with the given name exists on the global workspace, then the run is aborted with an error.
Syntax Example
GetSlot("Heron Reservoir.Inflow")
GetSlot("Abiquiu Reservoir^RioGrande.Inflow")
Return Example
\$"Heron Reservoir.Inflow"
\$"Abiquiu Reservoir^RioGrande.Inflow"
GetSlotName

 Description Return the slot name portion of a slot’s full name. Type STRING Arguments Meaning 1 SLOT The slot whose name is returned. Comments If the slot is a column of an aggregate series slot and if it is the first column, then the agg series slot name is returned. If the input slot is a column of an aggregate series slot other than the first column, the column label is returned. For example, assume that data.Agg is a two column aggregate series slot series slot with columns labeled 'zero' and 'one.' Then:• GetSlotName(data.Agg) = “Agg”• GetSlotName(data.Agg.0) = “Agg”• GetSlotName(data.Agg.zero) = “Agg”• GetSlotName(data.Agg.1) = “one”• GetSlotName(data.Agg.one) = “one”See also “GetSlotNameAndCol”, which behaves differently when the input slot is an aggregate series slot.
Syntax Example
GetSlotName(\$"ResA^Municipal.Inflow")
Return Example
"Inflow"
GetSlotNameAndCol

 Description Given a slot, return the slot name portion of the full name, combined with the column label when the input slot is an aggregate series slot or a column of an aggregate series slot. Type STRING Arguments Meaning 1 SLOT The desired aggregate series slot. Comments For example, assume that data.Agg is a two column aggregate series slot with columns labeled 'zero' and 'one.' Then:• GetSlotNameAndCol(data.Agg) = “Agg.zero”• GetSlotNameAndCol(data.Agg.0) = “Agg.zero”• GetSlotNameAndCol(data.Agg.zero) = “Agg.zero”• GetSlotNameAndCol(data.Agg.1) = “Agg.one”• GetSlotNameAndCol(data.Agg.one) =”Agg.one”See also “GetSlotName”, which behaves differently when the input slot is an agg. series slot.'
Syntax Example
GetSlotName(\$"DataObj.Aggregate.Inflow")
Return Example
"Aggregate.Inflow"
GetSlotVals and GetSlotValsNaNToZero

 Description This function evaluates to a list composed of the values of a given series slot within a time range. GetSlotVals can also be used on a periodic slot, while GetSlotValsNaNToZero, cannot. Type LIST{NUMERIC} Arguments Type Meaning 1 SLOT the series (or periodic slot) whose values to get 2 DATETIME start datetime 3 DATETIME end datetime Evaluation A list is generated by looking up each value in the given slot, beginning with the start datetime, and ending with the end datetime. All slot values in the range are returned, regardless of the slot data’s timestep resolution vis-a-vis that of the run control. Mathematical Expression Comments If the start datetime or end datetime does not match one of the slot’s values’, or if the start datetime is after the end datetime, this function aborts the run with an error. For GetSlotVals, if one of the slot values within the desired time range is a NaN, the function exits the rule with an early termination. For GetSlotValsNaNToZero, it converts any NaNs into zero.For periodic slots and GetSlotVals, the dates used are those within the range and falling on a run timestep; the column used is the first (column 0).
Syntax Example
GetSlotVals(Dolores.Inflow, @"t",
@"September 31,Current Year")
Return Example
{ 1.43"cms", 2.12 "cms" }
GetSlotValsByCol and GetSlotValsByColNaNToZero

 Description This function evaluates to a list composed of the values in a column of a given Agg Series Slots (or for GetSlotValsByCol, it could be a periodic slot) within a time range. Type LIST{NUMERIC} Arguments Type Meaning 1 SLOT the agg series slot (or for GetSlotValsByCol, it could be a periodic slot) whose values to get 2 DATETIME start datetime 3 DATETIME end datetime 4 NUMERIC the column (interpreted as a 0-based integral index) Evaluation A list is generated by looking up each value in the given column of the slot, beginning with the start datetime, and ending with the end datetime. All slot values in the range are returned, regardless of the slot data’s timestep resolution vis-a-vis that of the run control. Mathematical Expression Comments If the slot is an Agg Series Slot and the start datetime or end datetime does not match one of the slot’s values’, or if the start datetime is after the end datetime, this function aborts the run with an error. For GetSlotValsByCol, if one of the slot values within the desired time range is a NaN, the function exits the rule with an early termination. For GetSlotValsByColNaNToZero, it converts any NaNs into zero. For periodic slots and GetSlotValsByCol, the dates used are those within the range and falling on a run timestep.
Syntax Example
GetSlotValsByCol(WaterUser1.Periodic Diversion Request, @"t",
@"September 31,Current Year", 3)
GetSlotValsByColNaNToZero(WaterUser1.IrrigatedAreaByCrop, @"t",
@"September 31,Current Year", 3)
Return Example
{ 1.43"cms", 2.12 "cms", 2.54 "cms", 2.2 "cms"}
GetTableColumnVals & GetTableColumnValsSkipNaN
This function evaluates to a list. Each item of the list is the value of the given table slot, in the given column, from the given start row, to the given end row.

 Description All of the values of a table slot column between two rows. Type LIST{NUMERIC} Arguments Type Meaning 1 SLOT the table slot whose values to get 2 NUMERIC column 3 NUMERIC start row 4 NUMERIC end row Evaluation A list is generated by looking up each value in the given column of the given table slot beginning with the start row, and ending with the end row (inclusive). Rows and columns are numbered beginning with zero. Mathematical Expression Comments Units are not required for row and column indices and, if provided, will be ignored. If the column, start row, or end row does not exist in the slot, or if the start row is greater than the end row, this function aborts the run with an error.For the GetTableColumnVals function, if one of the slot values within the desired time range is a NaN, the function exits the rule with an early termination. For the GetTableColumnValsSkipNaN variation of this function, these values are just omitted from the return list.
Syntax Example
GetTableColumnVals(Chickamauga Data.Power Coeffs, 0, 0, 1)
GetTableColumnValsSkipNaN(Chickamauga Data.Power Coeffs, 0, 0, 1)
Return Example
{ 1.43"cms", 2.12 "cms"}
GetTableRowVals & GetTableRowValsSkipNaN
This function evaluates to a list. Each item of the list is the value of the given table slot, in the given row, from the given start column, to the given end column.

 Description All of the values of a table slot column between two columns. Type LIST{NUMERIC} Arguments Type Meaning 1 SLOT the table slot whose values to get 2 NUMERIC row 3 NUMERIC start column 4 NUMERIC end column Evaluation A list is generated by looking up each value in the given row, of the given table slot beginning with the start column, and ending with the end column (inclusive). Rows and columns are numbered beginning with zero. Mathematical Expression Comments Units are not required for row and column indices and, if provided, will be ignored. If the row, start column, or end column do not exist in the slot, or if the start column is greater than the end column, this function aborts the run with an error.For the GetTableRowVals function, if one of the slot values within the desired time range is a NaN, the function exits the rule with an early termination. For the GetTableRowValsSkipNaN variation of this function, these values are just omitted from the return list.
Syntax Example
GetTableRowVals(Chickamauga Data.Power Coeffs, 0, 0, 1)
GetTableRowValsSkipNaN(Chickamauga Data.Power Coeffs, 0, 0, 1)
Return Example
{2.54 "cms", 2.2 "cms"}
GetTextSlotValueAsString
This function gets the value off of a Text Series Slot at the specified datetime and returns a string.

 Description Returns the Text Series Slot value as a STRING Type STRING Arguments Type Meaning 1 SLOT The text series slot 2 DATETIME The timestep at which to lookup Evaluation Text Series Slots store text as a number encoded on the slot. See “Text Series Slots” in User Interface. This function returns the value of the specified Text Series Slot at the specified date as a STRING.An error will be issued if the slot is not a Text Series Slot or the DATETIME is not fully specified.If the slot does not have a value at the date then the function returns an invalid value, which will cause the calling block to terminate early. Comments See “TextSlotNumericToString” for a similar function. See “StringToTextSlotNumeric” for the opposite conversion function.
Syntax Example
GetTextSlowValueAsString(DataObject1.MyTextSlot,@”Start Timestep”)
Return Example
“Start of Flood Season”
GetTimestep
This function evaluates to the length of the timestep ending on the given datetime.

 Description The length of a timestep, in units of "sec". Type NUMERIC Arguments Type Meaning 1 DATETIME the datetime of the end of the timestep Evaluation The datetime argument; which may be specified symbolically, is converted into an actual datetime. Then, the length of the timestep within which this time is, is determined.This function requires that the specified datetime resolve to a fully specified datetime or an error will occur. Comments If the given datetime corresponds to the moment when one timestep ends and another begins, this function evaluates to the length of the timestep which is ending. As elsewhere in RiverWare, 24:00 hours is considered to be the day which is ending, and 00:00 hours is considered to be the day which is just beginning.
Syntax Example
GetTimestep(@"February 23, 1996")
Return Example
21600 "sec" in a model with a 6 Hour timestep
86400 "sec" in a model with a 1 Day timestep
2505600.0 "sec" in a model with a 1 Month timestep
GetUpperBound

 Description Returns the upper bound for the given series slot. Type NUMERIC Arguments Type Meaning 1 SLOT the slot whose bound is to be returned. Evaluation Comments It is considered an error if the specified slot is not a series slot with a valid upper bound. The upper bound is specified in the slot configuration under the view menu.
Syntax Example
GetUpperBound(“Res A.Power”)
Return Example
400.0 MW
GetUpperBoundByCol