# Automating Runs

In addition to running Anaqsim interactively through the graphic user interface, you can make automated runs using the Windows command prompt. This may be useful for running parameter estimation software such as PEST or for executing a batch of unattended runs. Two input files are required for each model run:

- Anaqsim model file (.anaq) - this is the file which describes the model setup and is created by Anaqsim.
- Run control file (.txt) - a text file which describes what type of outputs the model should create and where these will be saved. This is created by the user with a text editor, like the Notepad accessory that comes with Windows operating systems. See the following sections for a description and examples.

To run an automated model in the Command Prompt, the command syntax is:

&lt;path\_to\_Anaqsim&gt; &lt;path\_to\_input\_file&gt; &lt;path\_to\_run\_control\_file&gt;

<p class="callout info">The command prompt is accessed in Windows 11 by clicking Start Button and searching for 'Command Prompt'.  
  
Within the command prompt it is necessary to put quotes around the path when the path contains names with spaces such as "program files" or "my documents".  
  
To avoid typing out the full file path it is possible to change the current directory within the command prompt to the location that files are saved, then just type in the file names (no path needed) for every input/output file.</p>

Assuming you've changed the current directory in the command prompt to the directory with all input/output files, the following is an example command that would execute a run of Anaqsim:

```bash
"c:\program files\yellow sub hydro\Anaqsim\Anaqsim.exe" run23.anaq run23.txt 
```

In the above example, Anaqsim is launched, run23.anaq is opened from the command prompt current directory, then execution and outputs are controlled by lines in the run control file run23.txt, also in the command prompt current directory.   
An optional 'batch' command can be added to the command which will force Anaqsim to work in the background and not open a user-interface. An example command that would execute a run of Anaqsim in the background is:

```bash
"c:\program files\yellow sub hydro\Anaqsim\Anaqsim.exe" run23.anaq run23.txt batch
```

The section below shows all the possible commands that can be included in the run control file, their output options, and examples of each. Some output files are dynamically named based on the input file name, and labels of elements in the model. Where &lt;name&gt; is specified this relates to the filename of the .anaq input file. Where &lt;well\_label&gt; is specified, it relates to the label associated with each well in the model. Similar syntax is used for lines, rivers, etc which have labels within the model.

Starting from version 2023-1 additional outputs and output options are available.

### Run Control File Commands

All of the commands listed in the run control file are lower case (case sensitive). The lines may appear in any order.

##### Initial Heads File

**Command:** initialheadsfile filename.hds  
**Required:** required for transient runs  
**Explanation**: Tells Anaqsim to use file filename.hds (replace with your own filename) as the initial heads for a transient run. As written with no path, the file must be located in the command prompt current directory. If it's located elsewhere, you must write the entire path+filename here instead of just the filename. The two parameters on this line must be separated by any combination of spaces and/or tab characters. This line is only needed for transient runs where [the starting heads are to be read from a file](https://docs.anaqsim.com/link/93#bkmrk-solve-settings).  
**Output options:** N/A  
**Examples:** initialheadsfile run23.hds

##### Output Log File

**Command:** outputfile filename.out  
**Required:** Yes  
**Explanation**: Tells Anaqsim to write text outputs from the automated run to a new text file named filename.out (replace with your own filename). As written with no path, filename.out will be written to the command prompt current directory. If you want it written elsewhere, you must enter the entire path+filename here. The two parameters on this line must be separated by any combination of spaces and/or tab characters   
**Output options:** N/A  
**Examples:** outputfile run23.out

##### Write Head Locations

**Command:** writeheadlocations filename.ihl  
**Required:** No  
**Explanation**: Tells Anaqsim to write the initial head locations from the automated run to a new file named filename.ihl (replace with your own filename). This command (combined with the Save Initial Heads command) is useful if you wish to automate running a steady state model, and creating the initial conditions for a subsequent transient model. As written with no path, filename.ihl will be written to the command prompt current directory. If you want it written elsewhere, you must enter the entire path+filename here. The two parameters on this line must be separated by any combination of spaces and/or tab characters   
**Output options:** N/A  
**Examples:** writeheadlocations run23.ihl

##### Save Initial Heads

**Command:** saveinitialheads filename.hds  
**Required:** No  
**Explanation**: Tells Anaqsim to save the initial head locations from the automated run to a new file named filename.hds (replace with your own filename). This command (combined with the Write Head Locations) is useful if you wish to automate running a steady state model, and creating the initial conditions for a subsequent transient model. As written with no path, filename.hds will be written to the command prompt current directory. If you want it written elsewhere, you must enter the entire path+filename here. The two parameters on this line must be separated by any combination of spaces and/or tab characters   
**Output options:** N/A  
**Examples:** saveinitialheads run23.hds

<p class="callout warning">This command will fail if you have not also specified 'writeheadlocations' as Anaqsim requires the head locations to be written first before the initial heads can be saved at those locations.</p>

##### Head Specified Wells

**Command:** headspecifiedwells  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the discharges of head-specified wells](https://docs.anaqsim.com/link/73#bkmrk-head-specified-well-) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_hspecWells\_&lt;well\_label&gt;.png

**Examples:**

- headspecifiedwells log
- headspecifiedwells csv run23\_head\_wells.csv
- headspecifiedwells graph

##### Discharge Specified Wells

**Command:** dischargespecifiedwells  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the heads at discharge-specified wells](https://docs.anaqsim.com/link/73#bkmrk-discharge-specified-) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_qspecWells\_&lt;well\_label&gt;.png

**Examples:**

- dischargespecifiedwells log
- dischargespecifiedwells csv run23\_discharge\_wells.csv
- dischargespecifiedwells graph

##### Discharge Specified Multilayer Wells

**Command:** dischargespecifiedmultilayerwells  
**Required:** No  
**Explanation:** Directs Anaqsim to[ write multi-level discharge-specified wells](https://docs.anaqsim.com/link/73#bkmrk-multi-domain-well-di) in the model. For these the breakdown of discharges by domain will be written to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_qspecMultiWells\_&lt;well\_label&gt;.png

**Examples:**

- dischargespecifiedmultilayerwells log
- dischargespecifiedmultilayerwells csv run23\_discharge\_multilayer\_wells.csv
- dischargespecifiedmultilayerwells graph

##### Head Specified Lines

**Command:** headspecifiedlines  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the discharges of internal head-specified line boundaries](https://docs.anaqsim.com/link/73#bkmrk-internal-head-specif) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_HspecLines\_&lt;line\_label&gt;.png

**Examples:**

- headspecifiedlines log
- headspecifiedlines csv run23\_HspecLines.csv
- headspecifiedlines graph

##### Rivers

**Command:** rivers  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the discharges of river line boundaries](https://docs.anaqsim.com/link/73#bkmrk-river-line-boundary-) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_RiverDischarge\_&lt;river\_label&gt;.png

**Examples:**

- rivers log
- rivers csv run23\_Rivers.csv
- rivers graph

##### River Groups

**Command:** rivergroups  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the cumulative discharge of grouped rivers](https://docs.anaqsim.com/link/73#bkmrk-river-line-boundary-) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_RiverDsicharge\_&lt;river\_group\_label&gt;.png

**Examples:**

- rivergroups log
- rivergroups csv run23\_RiverGroups.csv
- rivergroups graph

##### External Boundaries

**Command:** externalboundaries  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the discharges across external boundaries](https://docs.anaqsim.com/link/73#bkmrk-sum-discharge-across-1) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to 
    - Head Boundaries: &lt;name&gt;\_ExternalHeadBoundaries\_&lt;line\_label&gt;.png
    - Normal Flux Boundaries: &lt;name&gt;\_ExternalNormalFluxBoundaries\_&lt;line\_label&gt;.png
    - Head Normal Flux Boundaries: &lt;name&gt;\_ExternalHeadNormalFluxBoundaries\_&lt;line\_label&gt;.png

**Examples:**

- externalboundaries log
- externalboundaries csv run23\_ExternalBoundaries.csv
- externalboundaries graph

##### Vertical Leakage

**Command:** verticalleakage  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the vertical leakages over polygon areas](https://docs.anaqsim.com/link/73#bkmrk-vertical-leakage-ove) to the output file.  
**Output options:**

- log - outputs saved to log file
- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_VerticalLeakage\_&lt;polygon\_label&gt;.png

**Examples:**

- verticalleakage log
- verticalleakage csv run23\_Vertical\_Leakage.csv
- verticalleakage graph

##### Conditions along a Line

**Command:** conditionsalongline  
**Required:** No  
**Explanation:** Directs Anaqsim to write [steady and/or transient conditions along a line](https://docs.anaqsim.com/link/73#bkmrk-conditions-along-a-l) to the output file. All variables are output for all preset lines.  
**Output options:**

- csv - csv files will be saved to &lt;name&gt;\_TransientLine\_&lt;line\_label&gt;\_&lt;variable&gt;.csv where &lt;variable&gt; is either: 
    - Head
    - DischargeTangent
    - DischargeNormal
    - ExtractionModel
    - ExtractionHBased
    - LeakageTop
    - LeakageBottom
    - StorageFlux

<p class="callout warning">Unlike other csv options, you do not specify a filename following the csv key word</p>

- graph - graphs will be saved to &lt;name&gt;\_TransientLine\_&lt;line\_label&gt;\_&lt;variable&gt;.png

**Examples:**

- conditionsalongline csv
- conditionsalongline graph

##### Head Hydrographs

**Command:** headhydrographs  
**Required:** No  
**Explanation:** Directs Anaqsim to [write head hydrographs for preset hydrograph points](https://docs.anaqsim.com/link/73#bkmrk-head-hydrographs) to the output file.  
**Output options:**

- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_HeadHydrograph\_&lt;point\_label&gt;.png

**Examples:**

- headhydrographs csv run23\_Head\_Hydrographs.csv
- headhydrographs graph

##### Drawdown Hydrographs

**Command:** drawdownhydrographs  
**Required:** No  
**Explanation:** Directs Anaqsim to [write drawdown hydrographs for preset hydrograph points](https://docs.anaqsim.com/link/73#bkmrk-drawdown-hydrographs) to the output file.  
**Output options:**

- csv - a filename must be provided after csv key word
- graph - graphs will be saved to &lt;name&gt;\_DrawdownHydrograph\_&lt;point\_label&gt;.png

**Examples:**

- drawdownhydrographs csv run23\_Drawdown\_Hydrographs.csv
- drawdownhydrographs graph

##### Captured Pathlines

**Command:** capturedpathlines  
**Required:** No  
**Explanation:** If no csv key word provided, directs Anaqsim to [write the number of captured pathlines](https://docs.anaqsim.com/link/73#bkmrk-write-number-of-disp) to the output file. This is useful for running parameter optimization problems where you want to maximize or minimize the number of pathlines captured by specified wells or line boundaries. Use this with capture constrain in pathline settings.  
If csv is specified and a filename is provided, then the x,y,z vertices of all pathlines (whether captured or not) are saved to a file.   
**Output options:**

- No keyword - captured pathlines written to output file (specified by outputfile command)
- csv - a filename must be provided after csv key word

**Examples:**

- capturedpathlines
- capturedpathlines csv run23\_Pathlines.csv

##### Head Output File

**Command:** headoutputfile  
**Required:** No  
**Explanation:** Directs Anaqsim to evaluate heads according to the current plot settings ([Plot Input / What to Plot / Window and Plot Input / Contours Settings / Points\_Evaluate](https://docs.anaqsim.com/link/71#bkmrk-contour-settings)) in each model level and at each time step if it is a transient simulation.   
**Output options:**

- xyz - A filename must be provided where the outputs will be written. x, y locations and head levels are written to a csv file for each level, time period, and time step
- binary - A filename prefix should be specified. Outputs will be named: &lt;prefix&gt;\_t&lt;time&gt;\_L&lt;level&gt;.cgd
- surfer - A filename prefix should be specified. Outputs will be named: &lt;prefix&gt;\_t&lt;time&gt;\_L&lt;level&gt;.GRD

**Examples:**

- headoutputfile xyz run23\_Head\_Output.csv
- headoutputfile binary run23
- headoutputfile surfer run23

##### Calibration

**Command:** calibration  
**Required:** No  
**Explanation:** Directs Anaqsim to [write the calibration](https://docs.anaqsim.com/link/73#bkmrk-calibration-results) to the output file. All types of calibration information is written.  
**Output options:**

- log - outputs saved to log file
- graph - graphs will be saved to &lt;name&gt;\_HeadCalibration.png

**Examples:**

- calibration log
- calibration graph

##### Check Boundary Conditions

**Command:** checkboundaryconditions  
**Required:** No  
**Explanation:** Directs Anaqsim to [write boundary checks](https://docs.anaqsim.com/link/73#bkmrk-check-boundary-condi) to the log file.   
**Output options:** N/A  
**Examples:** checkboundaryconditions

##### Save

**Command:** save  
**Required:** No  
**Explanation:** Directs Anaqsim to [save the solution file](https://docs.anaqsim.com/link/29#bkmrk-save-solution) to the specified location.  
**Output options:** A filename must be provided with extension .solu after the save key word. The solution file will be saved to this file.  
**Examples:** save run23.solu

##### Exit

**Command:** exit  
**Required:** No  
**Explanation:** Directs Anaqsim to close after having solved and written the specified outputs. If a line with "exit" is not in the control file, Anaqsim will remain open so that the user could continue with other ways of analyzing the solution or making plots.  
**Output options:** N/A  
**Examples:** exit

#### Example Run Control File

An example file for a transient model that uses initial head levels from file run23.hds, writes text outputs to file run23.out, outputs head levels at discharge specified wells to a csv file, outputs discharge from grouped river reaches to graphs, and then saves the solution before exiting is as follows:

initialheadsfile run23.hds  
outputfile run23.out  
dischargespecifiedwells csv run23\_Discharge\_Wells.csv  
rivergroups graph  
save run23.solu  
exit