What is the manager module?
The manager module provides the capability to specify a set of rules using conditional logic during simulations to control the actions of modules within APSIM.
It does this by using “if” constructs created by the user. It also allows the user to create their own variables and define these as a function of other variables within APSIM.
This documentation only gives a brief insight into the possibilities achievable via the APSIM manager module.
How does it manage?
This module manages by issuing messages to modules in the system, many of which are conditional upon states or events within the modules during simulation.
if (day = 100) then fertilise apply amount = 10 (kg/ha), type = urea (), depth = 50(mm) endif
Here the fertilise module will be sent a message containing a directive to apply (the action) fertiliser when the condition is satisfied. It receives a data string (the underlined text) which further describes the action. The manager module can broadcast a message to all modules by substituting the keyword ‘act_mods’ in the place of the module name.
This capability is useful for multi-point simulations where a sow message needs to be sent to multiple points.
The following mathematical operators and reserved words are allowed in APSIM manager files
|^ or **||Exponent (eg. x**2 is the same as x ^ 2 )|
|<>||Not equal to|
|<=||Less than or equal to|
|>=||Greater than or equal to|
|else||Logical ELSE (for alternate logic)|
· Names must begin with a letter.
· Numbers must begin with a digit.
· Literals must begin and end with an apostrophe.
The manager uses the following character set:
|a to z||letters – case insensitive|
|0 to 9||Digits|
|.||Period or decimal point|
Manager functions may not have any spaces. This applies from the first character of the function name to the terminating bracket. The manager has the following functions:-
|date||returns the julian day number of specified date.
The date must be a literal enclosed in single quotes.
|date_within||returns 1 if “today’s” date is within the range specified, otherwise returns 0.
The pair of dates must be two date literals separated by a comma, and the whole argument must be enclosed in quotes. Note the lack of quotes near the comma.
|nearest_int||Returns the nearest integer to the value specified.
Here ‘var1′ must be a numeric variable. It cannot be a literal or an expression.
|paddock_is_fallow||Returns 1 if there are no crops in the ground.
e.g. if (paddock_is_fallow() = 1 and today = date(‘1-jun’)) then
wheat sow …
|add_months||Takes 2 parameters, a date and the number of months to add to the date. The new date is then returned.
e.g. gsrDate = date(‘1/9/2005’)
gsrDate = add_months(‘gsrDate, 1’)
The whole argument to add_months must be enclosed in single quotes. The number of months can be positive or negative.
Dates may take the following forms:
· date(’30/6/95′) returns the julian day number for 30 jun 1995
· date(‘Jun’) returns the julian day number for 1 jun for current year.
· date(’30_jun’) returns the julian day number for 30 jun for current year.
· date(’30_jun_1995′) returns the julian day number for 30 jun 1995
For related chronological or date variables which can be used by the manager module, see the documentation for the CLOCK module.
day – returns the day of the month
dd/mm/yyy – returns the day, month and year of the given day.
See the CLOCK module for further details.
Using the manager to send actions to other modules
The APSIM manager module can be used to invoke any action available by any module. Possible actions include:
· Resetting individual module values
· Reinitialising all data in modules to a given state
· Sowing, harvesting or killing crops.
· Applications of fertiliser, irrigation or tillage to soil.
Refer to the individual module’s documentation for a list of available actions and examples of usage. Refer also to the module’s sample files for further examples.