Skip to content

Basin Linkage

Description

The Basin Linkage utility, SmLink, allows the input from one or more StateMod input files to be combined in order to operate as a single model. Smlink does the following:

  • Reads 2 to 5 StateMod response (*.rsp) files to generate all the input files required to operate StateMod as a linked basin.
  • Allows the user to input replacement commands required to delete nodes where the models overlap or add nodes required to facilitate linkage.
  • Generates a log file that records the required dimensions for the StateMod Model and any duplicate ID's that need to be revised before a successful execution of StateMod can be performed.

Constraints used by the model include:

To link the *.rin file the code searches for a river node named 'End' or 'END'.

The code warns the user if duplicate ID's are provided in the log file.

The path of each input file is taken from the path specified in the command files unless a path is provided in the response (*.rsp) file.

The information in the control (*.ctl) files must be exactly the same (unit conversions, beginning year, etc.) to avoid any warnings. If inconsistent data is provided the information in the first file read is used for the linked control (*.ctl) file.

Because it is common for several StateMod input files to use the same evaporation, precipitation and delay files the user can specify input data that controls whether or not these files should to be linked.

Because it is common for several StateMod input files to use the StateCU input and output files that span an entire watershed the user can specify input data that controls whether or not these files should to be linked.

StateMod allows a unit response (*.urm) or delay (*.dly) file data to be provided in a free format. In order for SmLink to differentiate between an ID and data, columns 1-12 should be reserved for an ID. See below for an example free format unit response file where the ID is URM_1, 12 unit response values of 10 are provided as input, and columns 1-12 are reserved for an ID designation.

URM_1       12  10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10  (data begins in column 13)

StateMod allows an operating rule (*.opr) file to be provided in free format. In order for SmLink to differentiate between an ID and data, columns 1-12 should be reserved for an ID. See below for an example free format operating rule file with monthly on off switch.

Opr_Mead.01 Opr_Meadow_D&S_01   100.00000      12.       1 
1 1 1 1 -15 0 0 0 0 0 0 0 (on/off data begins in column 13)

Options

Smlink expects a command file which, if not provided, defaults to smlink.rsp.

SmLink has the capability to perform the following types of edits to an input file

* `delsta(fn,id)` Delete station ID from file fn

* `addrec(fn,rec)` Adds a record (rec) to file (fn).

* `repzero(fn,id,zero)` Set data for station (id) in file (fn) to zero.

Example

#       SmLink.rsp
#
#       Output File name (e.g. wslope)
wslope
#
#
# _________________________________________________________
#       Compare and link selected files 
#      (0=no compare and use first file read, 1 yes compare and link files)
#       nEva = evap; nPre = precip; nStr = structure, nIpy = Irrigation Practice, 
#       nDly = delay file; nUnit output units = 1 cfs, 2=af, 3=kaf
# nEva nPre nStr nIpy nDdc nDly nUnit
     0    0    0    0    0    0     3
# _________________________________________________________
# 
#       Input File names (e.g. cm2009H.rsp)
\w\statem\Verification\Base\YM2009\ym2009H.rsp
\w\statem\Verification\Base\WM2009\wm2009H.rsp
\w\statem\Verification\Base\SJ2009\SJ2009H2.rsp
\w\statem\Verification\Base\CM2009\cm2009H2.rsp 
\w\statem\Verification\Base\GM2009\gm2009H2.rsp
#
#       River Network
#       09152500 is Gunison R nr Grand Junction
#       420541 is Redlands Power
#       950050 is Redlands Irrig
-delsta(cm2009.rin,09152500)
-delsta(cm2009.rin,420541) 
-delsta(gm2009.rin,680636)
#
#       Diversion Stations
-delsta(gm2009.dds,420541)
-delsta(gm2009.dds,680636)
#
#       Add compact node Station, water right and demand
-addrec(gm2009.ifs,Compact_Dem Compact_Dem             Compact_Dem        1 COMPACT_DEM  0                 2)
-addrec(gm2009.ifr,Compact_Dem Compact_Dem             Compact_Dem         1.00000 99999.99       1)
-addrec(gm2009.ifa,     Compact_Dem  9999999 9999999 9999999 9999999 9999999 9999999 9999999 9999999 9999999 9999999 9999999 9999999)
#

-repzero(cm2009.rih,950040,zero)
-repzero(cm2009.rih,504600,zero)
-repzero(ym2009.ddh,584686,zero)
-repzero(ym2009H.ddm,584686,zero)
#
-addrec(gm2009.rin,End_File_1  File 1-Compact_Dem  _OTHCompact_Dem  End_File_1       -999)
-addrec(gm2009.rin,End_File_2  File 2-420541       _OTH420541       End_File_2       -999)
-addrec(gm2009.rin,End_File_3  File 3-Compact_Dem  _OTHCompact_Dem  End_File_3       -999)
-addrec(gm2009.rin,End_File_4  File 4-Compact_Dem  _OTHCompact_Dem  End_File_4       -999)
-addrec(gm2009.rin,End_File_5  File 5-Compact_Dem  _OTHCompact_Dem  End_File_5       -999)
-addrec(gm2009.rin,Compact_Dem Compact_Dem         _IFSEnd_All      Compact_Dem      -999)
-addrec(gm2009.rin,End_All     End)