Macro Files (.ce)
A SELES macro defines a named array of function expressions. Macros are defined similarly to landscape events and loaded via the dynamic model configuration (.sel) file. They allow a model to be parameterised with functions, or allow a single function to be reused in multiple parts of a model.
Indexing a macro evaluates the function at that index in the current spatio-temporal context — unlike a global variable array, which simply returns the stored value at that index.
6.1 Specifying Macro Files
A macro file consists of two parts:
- Definitions — declares the state variables accessible in the context where the macro will be used.
- Expressions — one or more function expressions (indexed starting at 0).
General format:
MACRO: <MacroName>
DEFINITIONS
{ variable declarations }
ENDDEF
<varName1> = Expr /* index 0 */
<varName2> = Expr /* index 1 */
...
Each expression must be an assignment. The left-hand variable name is not used — it can be any arbitrary name (but avoid names of known model variables). The right-hand expression is what is returned when the macro is indexed.
The Definitions section has the same format as in landscape events (see Landscape Events — Variable Declarations).
Example:
MACRO: Priorities
DEFINITIONS
LAYER: MgmtUnit
ENDDEF
p1 = MgmtUnit EQ 1 /* index 0 — identify management unit 1 */
p2 = MgmtUnit EQ 2 /* index 1 — identify management unit 2 */
6.2 Including Macro Files in a Dynamic Model
Macros are declared in the MACROS: block of the .sel file:
Macros:
<MacroName> = <FileName.ce>
The number of expressions in a macro can be obtained with the ROWS() built-in function and assigned to a global constant:
Global Constants:
NumPriorityMacros = ROWS(PriorityMacros)
Example:
Macros:
PriorityMacros = priorities.ce
Global Constants:
NumPriorityMacros = ROWS(PriorityMacros)
6.3 Including and Using Macros in Landscape Events
Declare the macro in the landscape event definitions section using array syntax:
MACRO: <macroName>[]
Example definitions section:
DEFINITIONS
MACRO: PriorityMacros[]
ENDDEF
Use the macro like a one-dimensional array index — but instead of returning a stored value, it evaluates the function at that index in the current spatio-temporal context:
PROBINIT
PROBINIT = PriorityMacros[currMgmtUnit] EQ TRUE
ENDPI
In this example, the macro function at index currMgmtUnit is evaluated in each cell of the event location at every time step, returning TRUE in the cells that match the corresponding management unit condition.