11 Managing simulation experiments
The iLand viewer (iland.exe
) is an excellent tool for designing, initializing, evaluating, debugging, and visualizing your iLand landscape and simulation experiment. However, once you are ready to scale up from a single simulation run to a set of simulation scenarios (e.g., different climate, disturbance, or management scenarios) and multiple replications, it is much more efficient to automate this process. To do this, you can use the iLand console (ilandc.exe
), which runs on both Windows and Linux platforms, and a shell script written in, e.g., Windows CMD or in bash. The critical first step of this process is making sure you are using the same version of the iLand viewer and iLand console. To check this, open iland.exe
and go to Help > About iLand
and note both the SVN-Revision number
and build date
. Then navigate to the iLand executable folder and enter ilandc.exe
in a command line window and compare.
11.1 Command line parameters
The iLand console requires two inputs, the project file and the number of simulation years, and can take any number of additional options.
Additional inputs include any settings in the project file and should be specified following the hierarchical structure of the XML below the <project>
level. For example, a different input climate database could be specified with database.climate.out=new_climate.sqlite
or a different sequence of prescribed disturbance events could be specified with
model.world.timeEventsFile=timeevents_2.txt
.
Additional inputs can also include a javascript function run on model creation or simulation end.
For additional examples and more detail, see the iLand console wiki page.
You can check the console output and/or the iLand log file to ensure that XML settings are being modified as expected.
11.2 Running multiple scenarios and replicates
The ability to modify any settings in the project file from the command line makes it straightforward to run many different simulation scenarios and multiple replicates in sequence or in parallel on a local machine or server. Scenarios can be specified in a file to run in sequence, as input arguments to a shell script to enable running in parallel, or as a combination of the two.
Here is an example of a .csv
file with different climate and disturbance scenarios, each with 10 replicates.
gcm,rcp,wind_speed_mult,nreps
ICHEC-EC-EARTH,rcp45,0,10
ICHEC-EC-EARTH,rcp85,0,10
ICHEC-EC-EARTH,rcp45,15,10
ICHEC-EC-EARTH,rcp85,15,10
MPI-M-MPI-ESM-LR,rcp45,0,10
MPI-M-MPI-ESM-LR,rcp85,0,10
MPI-M-MPI-ESM-LR,rcp45,15,10
MPI-M-MPI-ESM-LR,rcp85,15,10
These can be used as inputs in a script to sequentially run iLand. Example bash script:
#!/bin/bash
# bash script to run iland for a list of scenarios
# usage: bash scripts/run_iland_local.sh
#####
# variables and arguments
#####
# set variables
# set this path to location of iland exe
path="/c/Users/user1/iland_executable/"
simulation_years="80"
csv_name="iland/main_file.csv" # csv filename
xml="cc_wind.xml"
#####
# loop through csv and run iland for each scenario
#####
# read in line by line, assign to variable
sed 1d $csv_name | while IFS=, read -r gcm rcp wind nreps
do
for rep in $(seq 1 $nreps)
do
echo "running gcm $gcm with wind speed $wind rep $rep"
# run iland with scenario settings
${path}ilandc.exe iland/${xml} $simulation_years \
${gcm}_${wind}_${rep}.sqlite \
system.database.out=output_${gcm}.sqlite \
system.database.climate=${rcp}_${wind}_${rep}.txt
model.world.timeEventsFile=timeevents_
done
done
To run this script in bash, enter:
bash scripts/run_iland_local.sh
The script could alternatively include arguments, such as replicate number, that would make it easy to run multiple simulations in parallel. For example, the below script allows running all simulation scenarios for only a specified range of replicates:
#!/bin/bash
# bash script to run iland for a list of scenarios
# usage: bash scripts/run_iland_local.sh [start_rep] [end_rep]
#####
# variables and arguments
#####
# arguments
start_rep=$1
end_rep=$2
# set variables
# set this path to location of iland exe
path="/c/Users/user1/iland_executable/"
simulation_years="80"
csv_name="iland/main_file.csv" # csv filename
xml="cc_wind.xml"
#####
# loop through csv and run iland for each scenario
#####
# read in line by line, assign to variable
sed 1d $csv_name | while IFS=, read -r gcm rcp wind nreps
do
for rep in $(seq $start_rep $end_rep)
do
echo "running gcm $gcm with wind speed $wind rep $rep"
# run iland with scenario settings
${path}ilandc.exe iland/${xml} $simulation_years \
${gcm}_${wind}_${rep}.sqlite \
system.database.out=output_${gcm}.sqlite \
system.database.climate=${rcp}_${wind}_${rep}.txt
model.world.timeEventsFile=timeevents_
done
done
To run this script in bash for a single replicate (e.g., replicate 4), enter:
bash scripts/run_iland_local.sh 4 4
11.3 Pre-processing outputs
The same automation and scripting approach can be used to pre-process iLand outputs, for example using an .R
script. This may be desirable if detailed iLand outputs (i.e., large file sizes) are needed, but then the same set of steps are applied to generate the dataset used for one’s analysis. For example, Braziunas et al. (2021) applied a custom calculation to estimate fire intensity from iLand outputs. This required detailed information on stand structure, species composition, and sapling cohorts by resource unit, as well as fire spread rasters for each fire event. By adding a pre-processing step, they were able to automate the computationally intensive process of calculating fire intensity, delete the large iLand output files, and save a much smaller output file for each simulation replicate. Scripts associated with this project are on GitHub.
11.4 Running on a cluster
To further decrease the time required to complete simulations, iLand can be run on a compute cluster, which enables running many scenarios and replicates in parallel across multiple machines. This process requires compiling iLand on the compute cluster and preparing other files and scripts based on the cluster management software. If supported, pre-processing of outputs can also be included in compute cluster runs.
For additional information and examples, see the iLand wiki cluster page and this GitHub for an example with HTCondor software.