gibuu is hosted by Hepforge, IPPP Durham
close Warning:
  • Error with navigation contributor "BrowserModule"
  • Failed to sync with repository "(default)": instance.__dict__ not accessible in restricted mode; repository information may be out of date. Look in the Trac log for more information including mitigation strategies.

Use python scripts to automate development and job card submission

Simulation is usually connected with large amounts of output but sometimes also with a great variety of input files. Both sides (input and output) need to be handled automatically, and usually depending on one another. Here a collection of tools is presented which can be found in SVN under workingCode/testRun/JobCardManagement.

Why python?

Working on UNIX-like machines a natural choice would be using bash scripts to automate file handling. Such efforts have already been undertaken for GiBUU:

When coming to more complex applications the scripts become practically unmaintainable since the lack of language functionality (e.g. string handling) needs to be compensated by using chains of external programs with varying syntax and error handling. This results in lines like this

free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2-4 >> mem.stats 

With python being a mature interpreted language not only the high level (object-oriented) design patterns but also the interactive debugging possibilities are very promising.

A standard development cycle

Here are some solutions to the daily GiBUU routine using bash scripts where the problems are very straight forward and python for the rest. All these scripts are bundled in the directory workingCode/testRun/JobCardManagement (general info in README_ODIC). The [custom] tags mean that prior to executing these script you should check the header of the script for custom PATHs.

Write code and debug

Compilation and execution of development versions of GiBUU (prior to submitting to SVN) should be done on powerful machines. A possibility is to use one of the tp workstations via ssh, in this fashion:

1) Create a debug folder in workingCode

2) execute [custom] to sync it to a folder on the nucleus file system

  • this makes use of the script, which compiles the code and submits all the jobs to the local queue
  • submission is managed by [custom]

Generate job cards

Once your code runs with the job cards from debug you might want to modify them - to increase statistics or study further effects. Useful tools are:

To increase statistics in all job cards, you can set the numEnsembles variable to a higher number. --pattern="numEnsembles=",500 *.job

If you want to create a set of job cards where only some parameters vary, e.g. energy_li, try it in the following fashion: --var=energy_li= --low=1. --up=2. --steps=11 *.job

But other similar features like "fixed q" or "transversal analysis" are also implemented.

Submit all job cards

Once you have a set of job cards ready, you would like to have them computed on a cluster. One possibility is copying them by hand and writing a submit script for each, then submitting each, then collecting them by random output numbers separately. Another is to let [custom] do all this in a fashion like --machine=skylla --queue=serial --project=p1 *.job

This simply means that all jobs will be copied to the skylla cluster, where they will be submitted to the serial queue and the links to the processes and the results collected in the folder p1. *.job

will send all jobs to hadron and create a meaningful project title by default.

Mostly this routine relies on [custom] and [custom], where jobs are submitted, linked and managed on the cluster side (necessitates python version >=2.5)

Manage the output

Folder structure

If everything worked properly your project folder will contain only the files done and jobcards. Within the folder done you will find the results of the different job cards in folders named according to them. These folders will NOT contain redundant files like 'GiBUU.x'. In addition if you specified a --target, you will extract special files from the result directories which can be used for direct plotting.

Most of this sorting is done by and

Data file manipulation

Of course there are many UNIX tools like awk to handle data files. Useful shorthands are however:

collect data from different output files into one

Extract columns from csv like data files to new files

plot multiple files into one graph

rename files according to strings contained within them

Developing the scripts

As most modules have a doctest routine you can check if your contributions didn't break everything by using --doctest


Also you can have a look at the other files in the directory which may not have a lot to do with GiBUU, or are still in alpha phase and thus not documented here. Do not hesitate to contact the author (

Here you can see an example of the entire formalism in action

Last modified 10 years ago Last modified on Apr 7, 2010, 5:27:58 PM