Generating PBS Files
xFDS can programmatically generate .pbs files!¶
If you need .pbs files, simply add the .pbs file to the files parameter in the config file and build your .pbs file as you would any other template.
In the simple atrium example, a variable proc is defined to indicate the number of processors required and is accessable in the template.
In Python, // is the operator for floor division. Therefore, {{ proc // <ppn> }} will produce the number of full nodes required. For example, if the model requires 28 nodes and each node has 8 processors, {{ proc // 8 }} will render as 3 implying that 3 full nodes are required.
In Python, % is the operator for determining the remainder. Therefore {{ proc % <ppn> }} will produce the number of cores needed on a partial node. For example, if the model requires 28 nodes and each node has 8 processors, {{ proc % 8 }} will render as 4 implying only 4 cores are required on that node.
| examples/simple_atrium/pbd.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
| examples/simple_atrium/simple_atrium.pbs | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
Tip
Use the xfds.render.parameters.include directive if you need to modify the number of processors based on the a specific configuration.
If you require fewer cores than available on a single node, {{ n // 8 }} will render to 0. Similarly, if the number of required cores is a multiple of the cores on a single node, {{ n % 8 }} will render to 0. If this is undesireable, use an if statement containing the node filter.
The node filter requires two parameters in addition to the number of cores needed: ppn, or how many processors there are per node, and what mode to consider. The modes are as follows:
full: ReturnsTrueif at least one full node is required.part: ReturnsTrueif a partial node is required.both: ReturnsTrueif bothfullandpartare required.
Tip
Use Jinja's whitespace control syntax to collapse multiple lines onto one line.
| examples/pbs/pbd.yml | |
|---|---|
1 2 3 4 5 6 7 8 | |
| examples/pbs/model.pbs | |
|---|---|
1 2 3 4 | |
If only 4 of the 8 processors on a node are needed, only 4 are requested.
| examples/pbs/output/using_4_nodes/using_4_nodes.pbs | |
|---|---|
1 | |
| examples/pbs/output/using_8_nodes/using_8_nodes.pbs | |
|---|---|
1 | |
| examples/pbs/output/using_12_nodes/using_12_nodes.pbs | |
|---|---|
1 | |