Run APSIM from command line or from scripts

Using Scripts to Run APSIM

There are two ways to interact with APSIM. The most common way is to use the APSIM user interface. With it you create simulations by dragging and dropping components, simulations and folders. The file that runs when you load the interface is called ApsimUI.exe. When you click the run button, your .apsim file is sent off to another program called Apsim.exe. This file is the one that actually runs your simulation.

A .apsim file is simply an XML file so the ApsimUI program can be seen as a visual XML editor. What this means is that you don’t need to use the UI to run APSIM. This can be useful when you are running a large number of simulations and it becomes impractical to use the UI (for example, sensitivity analysis which can require over a million simulations).

A common approach is to use automated tools to create and run the simulations. While the creation of the simulations will be different for each project, the commands to run them are the same.

Running APSIM from the command line.

In the APSIM folder, you will find a folder called Model. This is where all the executable code for APSIM is kept. The following table describes the syntax for running APSIM from the command line:

Command Description
apsim <file name>.apsim Run a single .apsim file in the current folder.
apsim *.apsim Run all .apsim files in the current folder.

(non-recursive)

apsim <folder name> Run all .apsim files in the given folder and all child folders. (recursive)