Excel macros (12/09/08)

CRHM Platform

Purpose.

    Normally CRHM is run interactively by the user.  However, if a comparison of different model runs with different parameters is required, it can be very tedious.  Example Excel spreadsheets with a Visual Basic macro are described here and are distributed with CRHM.  This demonstration allows the user to list in an Excel workbook the parameters for each run and the macro will execute CRHM for each set of parameters and record in the workbook the final values of variables requested by the user.  These variables are the same as being displayed by CRHM as specified in the project file. The process seems involved but if taken in steps it is straightforward. The current implementation only records the values of the selected variables at the end of the model run.  If an intermediate value is required (e.g. peak evaporation),  the user can write a CRHM macro which saves the desired variable value till the end of the run.

Preparation of input files.

    Required files are,

  1. CRHM_XLS.xls - This Excel workbook specifies the names of the process files to be used and controls the execution of the macro to execute CRHM.
  2. Location of CRHM - where CRHM is installed, e.g. C:\Program Files\CRHM\CRHM.exe.
  3. CRHM parameter file - a text parameter file saved from the CRHM project, e.g. Parameters.par.
  4. List of parameter changes - an Excel file listing the parameters for each run, e.g. Changes.xls.
  5. CRHM project file - project  file to be run, e.g. pbsm.prj.
  6. List of Observation files - an Excel file listing the observation files to be used, e.g. Changes_Obs.xls.  This file is not used if the observation file is in the project file.

 

    Three example files are distributed with CRHM in the directory "\Program Files\CRHM\CRHM_XLS".

        CRHM_XLS.xls using the files; pbsm.prj,   parameters.par and Changes.xls.  This the simplest example and uses a basic project (no groups).  The parameters need only to be specified by name only.

        CRHM_XLS_G.xls using the files; pbsmG.prj,   parametersG.par and ChangesG.xls. Since this project uses groups the parameters must be specified by the group name + the parameter name, e.g. "pbsm_GrpA Ht".

        CRHM_XLS_Obs.xls using the files; PBSM_NO_obs.prj, parameters.par, Changes.xls and Changes_Obs.xls.  The project file does not specify any observation files since these are determined by file list in Changes_Obs.xls.  N.B. that the Excel file defining the parameters is always used as its length determines the number of times CRHM is run.

Necessary CRHM options.

    The following settings are required to be set so that the process can be automated.

  1. AutoRun.
  2. AutoExit.
  3. Log/Last.