Command line interpreter.
Normally CRHM is used as a window program. However, in order that it can execute from a project file or display an observation file it must have a command line interpreter (cil).
The cil is able to handle project, observation and parameter files. An example is "CRHM_new.exe Project.prj MyObs1.obs MyObs2.obs Myparam1.par Myparam2.par". No special error handling is implemented and any errors will cause the loading to stop and the program display the error. Use double quotes to wrap multiple words as one parameter (such as long file names containing spaces), e.g. "C:\Program Files\CRHM\Examples\MacroExample1.prj"
- *.prj - only the first project file is recognized. Any other is ignored.
- *.obs - multiple observation files can be loaded. No error handling is done. Faulty file format or duplicate variable definitions will stop the loading.
- *.par - multiple parameter files can be loaded. The project file using all the parameters must be loaded first. If parameters are doubly defined this is not recognised as an error. However, unknown parameters will cause an error stopping loading. An error will occur if there are too few parameter values defined for a parameter, i.e. number of values not equal to the number of HRUs in the model or group.
Automation.
For optimisation it is convenient to run a model and generate output and change the value of the parameter and repeat. After multiple runs the output files are processed with the parameter changes to determine sensitivity etc. CRHM has this capability.
- Create a project file for the desired modules.
- Save the project file with these options set: AutoRun, AutoExit and either Log/Last or Log/All.
- From the saved project or parameter file create a series of batch parameter files to insert in the command line to vary the desired parameter.
- Change the basin RUN_ID parameter every CRHM execution to identify the model output file, file name is CRHM_output with RUN_ID appended.
- CHRM just before closing sets the registry entry, HKEY_CURRENT_USER/CRHM_output/basin RUN_ID to the integer value of RUN_ID. By checking this registry entry a calling program can check the progress of CRHM in processing command line requests.
- In Microsoft Excel, code from http://www.cpearson.com/excel/ShellAndWait.htmt can be used to ensure that the last process is blocked until the Excel RefreshAll picks up all the new values.