Parameter change files
Purpose¶
cal_parms.cal is the dictionary of every parameter that calibration can touch: its name, the object type it lives on, and the absolute range it may be moved through. calibration.cal is the change list applied during a hard-calibration run: each row picks a parameter from the dictionary, sets a change type and magnitude, optionally restricts the change to a list of objects, and optionally attaches conditions. Both files feed the same parameter selector (cal_parm_select) used by hard calibration and by parameter changes inside soft calibration.
Source¶
cal_parms.calreader:src/cal_parm_read.f90calibration.calreader:src/cal_parmchg_read.f90- Type definitions:
src/calibration_data_module.f90,type calibration_parameters(rows ofcal_parms.cal) andtype update_parameters(rows ofcalibration.cal). - File slot names:
src/input_file_module.f90,type input_chg. Defaults:cal_parms = "cal_parms.cal",cal_upd = "calibration.cal".
cal_parms.cal¶
cal_parm_read.f90 reads:
- Line 1: title (skipped).
- Line 2: integer
mchg_par, the number of parameter records that follow. - Line 3: header (skipped).
- Lines 4 .. 3 +
mchg_par: one record per parameter, read list-directed intocal_parms(i).
Record layout (type calibration_parameters):
| # | Field | Type | Description |
|---|---|---|---|
| 1 | name |
char(25) | Parameter name. Must match a case in cal_parm_select.f90. Examples: cn2, awc, alpha, epco, lat_ttime. |
| 2 | ob_typ |
char(25) | Object type the parameter is attached to: hru, hlt, sol, lyr, plt, aqu, cha, sdc, rte, swq, res, rdt, ru, bsn, pcp, tmp, gwf. Determines which collection is iterated. |
| 3 | absmin |
real | Lower bound. Any change is clamped to this value. |
| 4 | absmax |
real | Upper bound. Any change is clamped to this value. |
| 5 | units |
char(25) | Units string for the parameter (mm, m, days, null, ...). Documentation only; the reader does not interpret it. |
Example¶
refdata/Osu_1hru/cal_parms.cal:
cal_parms.cal: written by SWAT+ editor v2.2.0 on 2023-03-22 04:25 for SWAT+ rev.60.5.4
186
name obj_typ abs_min abs_max units
cn2 hru 35.00000 95.00000 null
cn3_swf hru 0.00000 1.00000 null
usle_p hru 0.00000 1.00000 null
ovn hru 0.01000 30.00000 null
elev hru 0.00000 5000.00000 m
slope hru 0.00010 0.90000 m/m
slope_len hru 10.00000 150.00000 m
lat_ttime hru 0.50000 180.00000 days
The count line on line 2 (186) drives the allocation of cal_parms(0:mchg_par). The header on line 3 (name, obj_typ, abs_min, abs_max, units) is skipped; values are read by position.
calibration.cal¶
cal_parmchg_read.f90 reads:
- Line 1: title (skipped).
- Line 2: integer
mcal, the number of change records. - Line 3: header (skipped).
- Then
mcalchange records, each followed bycondscondition lines (often zero).
Change record¶
Each change record is one logical line, read list-directed in two passes. The first pass reads the fixed prefix; if the prefix indicates an object list is present, the line is backspaced and re-read to pick up the integers.
Fixed prefix:
| # | Field | Type | Description |
|---|---|---|---|
| 1 | name |
char(25) | Parameter name. Must match a name in cal_parms.cal. The reader crosswalks this to num_db. |
| 2 | chg_typ |
char(16) | Change operator. One of absval (replace), abschg (add), pctchg (percent change). |
| 3 | val |
real | Magnitude of the change, interpreted per chg_typ. |
| 4 | conds |
int | Number of condition lines that follow this record. May be zero. |
| 5 | lyr1 |
int | First soil layer in range (0 means all layers). For reservoir decision tables, reused as a storage-zone flag. |
| 6 | lyr2 |
int | Last soil layer in range (0 means through last layer). |
| 7 | year1 |
int | First year (for climate parameter changes). |
| 8 | year2 |
int | Last year (for climate parameter changes). |
| 9 | day1 |
int | First day of year (for climate parameter changes). |
| 10 | day2 |
int | Last day of year (for climate parameter changes). |
| 11 | nspu |
int | Number of object indices listed after this prefix. 0 means apply to every object of this parameter's ob_typ. |
If nspu > 0, the same line continues with nspu integers giving the object indices to update. When nspu == 0 the reader allocates a num array that lists every object of the matching type (every HRU, every channel, every plant, and so on) so the change applies globally.
Condition lines¶
A condition line takes one of two forms, distinguished by the literal token in column 1:
range <var> <val1> <val2>. Restricts the change to objects whose<var>falls betweenval1andval2. Used incal_conditions.f90forres_pvol.<var> <alt> <targ> <targc>. Read as acalibration_conditionsrecord. Used for categorical filters:hsg,texture,plant,pl_class,landuse,cal_group,res_typ.
See Conditions and regionalization for the supported variable list.
Example¶
refdata/Osu_1hru/calibration.cal:
hru-new.cal developed from soft data calibration
13
NAME CHG_TYP VAL CONDS LYR1 LYR2 YEAR1 YEAR2 DAY1 DAY2 OBJ_TOT
cn2 pctchg 7.714000E+00 0 0 0 0 0 0 0 0 0
petco pctchg -5.273950E+01 0 0 0 0 0 0 0 0 0
latq_co pctchg -3.732030E+01 0 0 0 0 0 0 0 0 0
alpha pctchg 6.859000E+00 0 0 0 0 0 0 0 0 0
epco pctchg 6.534100E+01 0 0 0 0 0 0 0 0 0
awc pctchg -6.256550E+01 0 0 0 0 0 0 0 0 0
esco pctchg 3.305500E+01 0 0 0 0 0 0 0 0 0
perco pctchg 1.434000E+00 0 0 0 0 0 0 0 0 0
cn3_swf pctchg -7.710000E-02 0 0 0 0 0 0 0 0 0
canmx pctchg -6.680230E+01 0 0 0 0 0 0 0 0 0
lat_len pctchg -6.241200E+00 0 0 0 0 0 0 0 0 0
revap_co pctchg -5.854530E+01 0 0 0 0 0 0 0 0 0
surlag pctchg -2.125720E+01 0 0 0 0 0 0 0 0 0
In this file every record has conds = 0 and nspu = 0, so each change applies to every HRU. The trailing integer count is 11 per row: conds, lyr1, lyr2, year1, year2, day1, day2, and nspu (eight integers), padded by the editor with extra zeros that the list-directed reader ignores.
Related files¶
- Hard calibration. How these files are consumed during a calibration run.
- Conditions and regionalization. Condition-line vocabulary.
Important¶
Tool padding. SWAT+ Editor writes more zero integers than the reader consumes. The list-directed read tolerates this; do not rely on a fixed column count in tools that parse calibration.cal. Count from the left, in the order defined above.