The
Nimrod Portal Manual
 

Plan file examples

Introduction - Plan file examples

This page gives some examples and comments of the Nimrod Plan file syntax.

Contents

This section has the following sections:

Example 1 - Simple A simple example with file copying.
Example 2 - Cross product sweep A simple example sweeping across multiple parameters.
Example 3 - Keeping it clean with subdirectories Example of copy commands and subdirectories.
Example 4 - Parameter substitution A simple substitution example.
Example 5 - Command substitution A simple substitution example.
Example 6 - onerror A simple onerror example.
Other types of input References to other types of Nimrod input files.

Example 1 - Simple

top
parameter var0 float range from 1 to 500 step 1;

task main
    copy inputfile node:output
    node:execute /bin/uname -a >> output
    copy node:output output.${var0}
endtask

Task syntax:
node:execute <command to be executed on the processing node with parameters>
copy <source file where Nimrod is installed> node:<destination name on the processing node>
copy node:<source file on the processing node> <destination name where Nimrod is installed>

This example will generate 500 jobs where each job will have ${var0} set to a value from 1 to 500. For each job (or each value of ${var0}) the main task will be executed.

In this main task there are three commands that will be performed. First, the file inputfile will be copied to the execution node and renamed to output. Then the Unix command uname is called and the output is appended to the file output. The output file is then copied back to the experiment directory and renamed to be unique (as this task is executed 500 times, each file must be a different name). The output files will look like output.1, output.2, ..., output.500.

Tip: Although optional, you should always put braces (curly brackets, I.e., "{" and "}") around your variables names like so: ${x}. This will solve any future headaches when you use your variables near other letters or characters. E.g., $x_output is ${x_output}, not ${x}_output.

Tip: There is a special parameter called jobname. This parameter is different for each parameter set and can be used to create a unique name.

Example 2 - Cross product sweep

top
parameter x float range from 1 to 10 step 1;
parameter y float range from 1 to 10 step 1;

task main
    node:execute /bin/echo X:${x} Y:${y} > output
    copy node:output output.${x}.${y}
endtask

Nimrod will perform a cross product of the two parameters and generate a job for each combination. In this case Nimrod will generate 10x10 jobs and like the previous example, copies the files back with unique names. The output files will look like output.1.1, output.1.2, ..., output.10.10.

Example 3 - Keeping it clean with subdirectories

top
parameter x float range from 1 to 10 step 1;

task main
    node:execute ${HOME}/bin/fileCreator ${x}
    copy node:file* output.${x}/
endtask

If you had a task that generated many output files, Nimrod supports wildcards with its copy command (Note: wildcards only work on the node: directive). In this example, Nimrod will copy all the files that match the wildcard file* and copy them back into a directory called output.${x}. The "/" tells nimrod to create a directory with that name and copy the files there. The output directories are output.1, output.2, ..., output.10.

Example 4 - Parameter Substitution

top
parameter x float range from 1 to 10 step 1;

task main
    copy inputfile.sub node:.
    node:subsitute inputfile.sub inputfile
    node:execute ${HOME}/bin/program inputfile
    copy node:output output.${x}
endtask

Nimrod supports a simple input file parameter substitution for when an application cannot take parameters on the command-line, but reads everything from a file.

The syntax for the command is:
node:substitute <inputfile> <outputfile>

In the above example, Nimrod copies to the node a file called inputfile.sub. This file will be a complete input file that the program accepts, but with one difference. Any value that you want Nimrod to change, must be replaced with a "${name}" placeholder. E.g. If you had the following file:

X: 3
Y: 7
Z: 9

And if you want Nimrod to perform a sweep over all the X values (as per the plan file), then you would create a file called inputfile.sub which will contain:

X: ${x}
Y: 7
Z: 9

When Nimrod executes the node:subsitute command, it takes the first file on the command-line and replaces all the occurrences of known parameters in the format "${name}" and writes it to the second filename on the line. The next line in the script calls your program giving it the input file that has the ${x} replaced with the value of x for that job.

Example 5 - Command substitution

top
parameter x float range from 1 to 10 step 1;
parameter y float range from 1 to 10 step 1;

task main
    node:execute /bin/echo X:${x} Y:${y} > output
    copy node:output output.`expr ${y} \* 10 + ${x}`
endtask

The above example is identical to example 2 except the filename that is being copied back. Nimrod support the single back quote (" ` ", not " ' ") command substitution on both the node:execute and copy commands. Output of the command inside the back quotes will be placed on the command-line. In this example, when X=2 and Y=3, the output of the command expr ${y} \* 10 + ${x} is 32. 32 is then placed in the rest of the copy command making the line copy node:output output.32.

Note: The command inside the quotes is executed on the remote node and does not have access to files on the Nimrod server.

Tip: You can use the back quotes to launch your own scripts. E.g., if you copy a script call myscript to the node (using "copy myscript node:."), you could then put this `./myscript ${x} ${y}` on your node:execute or copy commands and the output of your script will be substituted into the command.

Example 6 - onerror example

top
parameter x float range from 1 to 10 step 1;
parameter y float range from -4 to 5 step 1;

task main
    onerror fail
    node:execute /bin/echo X:${x} Y:${y} > output
    onerror ignore
    node:execute /bin/sleep ${y}
    onerror fail
    copy node:output output.${x}.${y}
endtask

This example is like example 2, but with an extra command, sleep, that will pause for ${y} seconds. The "onerror fail" and "onerror ignore" commands instruct Nimrod on how to behave if a "node:execute" returns a non-zero result. In the above example, if the sleep command was to fail (if ${y} is negative), Nimrod will continue with the script. If the "onerror ignore" wasn't there, Nimrod would use the previously given onerror value that was set and when sleep returns a non-zero result, Nimrod will stop the script and mark the job as "failed". A Nimrod script starts with "onerror fail" set (the first "onerror fail" is not needed in the above example).

Other types of Nimrod input files

top
More examples of different type of Nimrod experiments can be found here:

.run file
Dependencies
Single Job submission
Optimization (Nimrod/O)
APST
Experimental design

(To be added)

top