TCL/Apsim
Description
This module provides a simple link between apsim and TCL interpreters. Variables are exchanged through a Get/Set mechanism.
Settings
Rules are defined just like the manager: the rules in [xyz.tcllink.init] will be evaluated at the simulation's initialisation. The other rules of interest are “init”, “prepare”, “start_of_day”, “process”,“ post”, “end_of_day”, and "exit".
Apsim messages are generated with the TCL procedure apsimSendMessage. It has two mandatory arguments, the destination module, the message name, and optional message name/value pairs are encoded as list elements. For example,
apsimSendMessage wheat sow {cultivar hartog} {plants 120} {sowing_depth 30}
Apsim variables are set/get with apsimGet, apsimSet.
The procedure apsimWriteToSummaryFile sends a log message to the current summary file
A simple “command line” debugger is provided in the sample directory. It demonstrates the ability to examine apsim variables, step through simulations and set breakpoints.
(Sample) 1 % link clock.day day
Link the apsim variable “clock.day” to the tcl variable “day”.
(Sample) 2 % b {$day == 182}
{$day == 182}
Set a breakpoint for day 182. Equivalent to
“ b {[apsimGet clock.day] == 182} ”
(Sample) 3 % c
-1
Continue. Control returns after a crop is planted
(Sample) 4 % p wheat.biomass
12.874
Print an apsim variable
(Sample) 5 % s
1
Single step
(Sample) 6 % p wheat.biomass
14.095
etc..
(Sample) 7 %
Missing features
Cannot uncrack messageData structures (eg newmet)