Debian Codegraph @

docs/ug/user_manual/text_based_suite_definition/dependencies/trigger.rst

raw
1 .. _text_based_def_trigger:
2
3 trigger
4 ///////
5
6 This defines a dependency for a task or family. There can be only one
7 trigger dependency per node, but that can be a complex boolean
8 expression of the status of several nodes. Triggers should be avoided on
9 suites.
10
11 A node with a trigger can only be activated when its trigger has
12 expired. A trigger holds the node as long as the trigger's expression
13 evaluation returns false. There are a few additional keywords and some
14 names may point to other nodes with their value acting as the status of
15 those nodes. Trigger mathematics are computed, using double arithmetic
16 (with no string comparisons). There should not be any need to use
17 numerical expressions, instead logical functions (and, or, not, eq, ne)
18 with node names should be used.
19
20 The keywords in trigger mathematics are: **unknown, suspended,
21 complete, queued, submitted, active** and **aborted** for task and
22 family status; and **clear** and **set** for event status. These keywords are treated as numbers
23 starting from 0 (unknown) to 6 (aborted). There is no need to be
24 aware of the numerical values as long as you do not use a trigger in the form:
25
26 .. code-block:: shell
27
28 trigger plain_name # WARNING! DO NOT USE!
29
30 This is true only as long as the status of plain_name is unknown. It
31 is not advisable to use mathematical function names for node names.
32
33 The **full name** or **relative name** of a node can also be used as
34 an operand. A full name starts from the super-node. A **relative
35 name** can include "../" to indicate the parent node level. A relative name can also include "./'
36 to indicate the same level, this is needed if the task name is
37 numeric (otherwise its numeric value would be used in the expression.)
38
39 .. code-block:: shell
40
41 family foo
42 task bar
43 task foobar
44 endfamily
45 family second
46 task 00z
47 trigger ../foo/foobar==complete # task from previous family
48 task another
49 trigger ./00z == complete # the previous task
50
51 For events it is convenient to use a plain name, since an event can only have values **clear** or **set**, numerically 0 or 1.
52 Notice that the following triggers will hold as long as the event is not set, with the second line considered a clearer alternative.
53
54 .. code-block:: shell
55
56 trigger taskname:event
57 trigger taskname:event == set
58
59 Meters can be used in triggers the same as events, except that their
60 value should be compared against numerical expression. It is
61 important to remember to use **greater or equal** instead of **equals** . In the following
62 example **foobar** will not be submitted if, let's say, suite is
63 suspended while **foo** sets it meter to first 120 and then to 130. **bar** will still be submitted once the suite is resumed.
64
65 .. code-block:: shell
66
67 task foo
68 meter hour 0 240
69 task bar
70 trigger foo:hour >= 120
71 task foobar
72 trigger foo:hour == 120 # dangerous !!!
73
74 The conversion between date values (formated as :code:`DDMMYYYY`) and Julian Day can be done using
75 the functions :code:`cal::date_to_julian` and :code:`cal::julian_to_date`. The following example shows how to use these functions:
76
77 .. code-block:: shell
78
79 family foo
80 task first
81 edit YMD 20000101
82 edit JULIAN 2451545
83 task second
84 trigger cal::date_to_julian(./first:YMD) == 2451546
85 task third
86 trigger cal::julian_to_date(./first:JULIAN) == 20000102
87
88 There is no automatic checking for deadlocks, which can be difficult to detect. However, if your suite is known to complete
89 (i.e. it does not run forever), then simulation can be used to check for deadlocks.
90
91 The following example is a simple case:
92
93 .. code-block:: shell
94
95 task a ; trigger ./b == complete
96 task b ; trigger ./a == complete # DEADLOCKS tasks a & b
97
98 There is no automatic simplification of the mathematics. ecFlow will
99 read the whole of a suite definition into memory, but with comment lines
100 removed and possibly different indentation.
101
102 Mathematical expressions must be given in a single logical line. Use
103 continuation lines for long expressions. For example:
104
105 .. code-block:: shell
106
107 trigger /suite/family1/task1==complete and ( /suite/family2 \
108 eq complete or /suite/family3 eq complete )
109
110 There cannot be any characters after the **line continuation character**
111 \'\\'; any keyword can appear in an expression but they must be used in a
112 way that makes sense. For example, a task can *never* be **set** or **clear** and,
113 likewise, an event can only be **set** or **clear** .
114
115 See section https://confluence.ecmwf.int/display/ECFLOW/extern on for details on using triggers external to the suite.