Toy example of CHAIN usage

Here is toy example for using chain. Thanks to Stephen Eglen.

Problem: to add two numbers using `bc'.

The in.dat.fmt file containts the two parameters, N1 and N2. For various combinations of these parameters, we would like to add them up using bc, and then save the result in out.dat. This output file is then copied to a file

sum_<N1>_<N2>

For chain to work on this example, we need two files: in.dat.fmt and chain.dat. Save the two snippets below under those names.

Save the following snippet as a file "in.dat.fmt":

/* this is the format file */ <N1> + <N2>

Save the following snippet as a file "chain.dat":

# # This is a parameter file for CHAIN (created by version 3.2). # # The contents of this file describe # - the commands to run one job # - the names of input and output files and of parameters # - the storage names that are used to save output from different runs # - the parameter combinations to be explored # # The file contains example text (to help your memory). # This text has to be replaced. # # USE "perldoc chain" TO GET A FULL DESCRIPTION # #=============================================================================== # # 1. Define some options, prefixes, and postfixes. # a) The minor options for CHAIN you want to be in effect always # b) A mail address for email notifications # c) An optional prefix to be added to all storage names # d) An optional postfix to be added to all storage names # e) A storage name postfix indicating an error # MINOR OPTIONS : MAIL ADDRESS : stephene STORAGE NAME PREFIX : STORAGE NAME POSTFIX: ERROR CASE POSTFIX: _ERROR #=============================================================================== # # 2. Define the shell script that runs your code. Parameters will be # interpolated into that script # # ---- Start of Shell script -------------------------------------------------- bc < in.dat > out.dat # ---- End of Shell script ---------------------------------------------------- # #=============================================================================== # # 3. Define some names: # a) The names of the input files your code is expecting. # b) The names of the format files corresponding to the input files. # c) The names of the output files/directories the code produces. # d) The names of the parameters (should be alpha_numeric) # INPUT FILE NAMES: in.dat FORMAT FILE NAMES: {}.fmt OUTPUT FILE NAMES: out.dat PARAMETER NAMES : N1 N2 #=============================================================================== # # 4. Define the TODO list for the job-chain. Each line contains storage names # (as many as OUTPUT FILE NAMES defined above) and a list of parameters. # '\' at line end makes the following line a continuation line. # Embedded macros and much more is possible. See documentation. # #--STORAGE-NAMES----------INPUT-PARAMETERS--------------------------------------- sum_<N1>_<N2> (1,2,3) [0:10:2]

After doing this, test the setup with

chain -t If everything looks ok, run the chain with chain -s