Command_line (092908)

CRHM Platform

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"

  1. *.prj - only the first project file is recognized.  Any other is ignored.
  2. *.obs - multiple observation files can be loaded.  No error handling is done.   Faulty file format or duplicate variable definitions will stop the loading.
  3. *.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.

  1. Create a project file for the desired modules.
  2. Save the project file with these options set: AutoRun, AutoExit and either Log/Last or Log/All.
  3. 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.
  4. Change the basin RUN_ID parameter every CRHM execution to identify the model output file,  file name is CRHM_output with RUN_ID appended.
  5. 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.
  6. 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.