Skip to content

Batch Processing and Command Line

Overview

The CE-QUAL-W2 model preprocessor and executable are command-line aware. Users can execute both programs from any directory and specify the default model directory as a command-line argument. This capability is particularly useful for linked models that run independently as separate model applications rather than as one large, combined model.

Linked Model Workflow

Consider an example with two linked CE-QUAL-W2 models stored in separate directories, with the W2 model and preprocessor executable in the c:\w2 directory:

  • c:\w2\LakeA: an upstream lake model with all required input files
  • c:\w2\RiverBelowLakeA: a downstream river model that receives outflow from the lake, with all required input files

Since the outflow from LakeA goes into RiverBelowLakeA, the general workflow for linked models is:

  1. Run the preprocessor for each model to verify input files.
  2. Run the upstream model first.
  3. Copy the upstream model's output files to serve as input files for the downstream model.
  4. Run the downstream model.

Batch files automate this process so that the entire sequence executes without manual intervention.

Preprocessor Batch File

The following batch file (checkW2.bat) runs the preprocessor for both model directories in sequence:

prew2-v4_64.exe "c:\w2\LakeA"
prew2-v4_64.exe "c:\w2\RiverBelowLakeA"

When the preprocessor runs, it opens a dialog box displaying results. The dialog box must be closed manually before the next command in the batch file executes. This behavior is by design, allowing the user to review the preprocessor results for each model before proceeding to the next.

Model Run Batch File

The following batch file (runW2.bat) runs both linked models and transfers the necessary output files between them:

w2_v4_64.exe "c:\w2\LakeA"
copy "c:\w2\LakeA\qwd.opt" "c:\w2\RiverBelowLakeA\qin.npt" /Y
copy "c:\w2\LakeA\twd.opt" "c:\w2\RiverBelowLakeA\tin.npt" /Y
copy "c:\w2\LakeA\cwd.opt" "c:\w2\RiverBelowLakeA\cin.npt" /Y
w2_v4_64.exe "c:\w2\RiverBelowLakeA"

This batch file performs the following steps in order:

  1. Run the upstream lake model (LakeA).
  2. Copy the withdrawal flow output (qwd.opt) to serve as the inflow file (qin.npt) for the downstream model.
  3. Copy the withdrawal temperature output (twd.opt) to serve as the inflow temperature file (tin.npt) for the downstream model.
  4. Copy the withdrawal constituent output (cwd.opt) to serve as the inflow constituent file (cin.npt) for the downstream model.
  5. Run the downstream river model (RiverBelowLakeA).

The /Y flag on each copy command suppresses the overwrite confirmation prompt, allowing the batch file to run without user interaction.

Quotation marks in file paths

Enclose directory paths in quotation marks to handle paths that contain spaces. This is standard practice for Windows batch files and prevents errors when directory or file names include spaces.

Automatic Dialog Box Closure

By default, the CE-QUAL-W2 executable opens a dialog box that remains open after a model run completes. In a batch processing workflow, this requires the user to manually close each dialog box before the next command executes.

Set CLOSEC to ON for unattended batch runs

Set the CLOSEC parameter to ON in the control file (w2_con.npt) to automatically close the dialog box when the model run finishes. This allows batch files to proceed through multiple model runs without manual intervention. When CLOSEC is set to OFF (the default), the dialog box remains open after each run, which is useful for reviewing run status before continuing.