I’m still working with SLHA files and noticed that people are using C/C++, Fortran, or also Mathematica programs for batch manipulation and processing of SLHA files (for example for repeatedly increasing some parameters in a SLHA file, feeding this file to some program and reading its output). For someone experienced with the shell (no, not that shell) this sounds like an easy task doable in a few lines of shell code. There is however no simple way to manipulate SLHA files on the command line.
The script I’m presenting in this post, slha-io.sh, tries to close that gap. Its description is:
This script is a very simple (and stupid) tool to get or set data in SLHA (SUSY Les Houches Accord) files. It can output complete blocks or individual data lines and replace existing data lines with user given input. It is stupid because it does not check after replacing data lines if the resultant file conforms to the SLHA. So care must be taken when using the “set” action.
But as so often, it is best described by examples. The basic things you can do with slha-io.sh are (MSSM.in is the SLHA file in these examples):
$ slha-io.sh MSSM.in get modsel
Block MODSEL # Select model
1 0 # MSSM
4 1 # R-parity is violated
Block SMINPUTS # Standard Model inputs
$ slha-io.sh MSSM.in get sminputs 6
6 1.729000E+02 # m_top(pole)
$ slha-io.sh MSSM.in get sminputs 6 | awk '{ print $2 }'
1.729000E+02
$ slha-io.sh MSSM.in set sminputs 6 \
" 6 1.730000E+02 # m_top(pole)"
$ slha-io.sh MSSM.in get sminputs 6
6 1.730000E+02 # m_top(pole)
Here is another example of using slha-io.sh to create a batch of files where a parameter is constantly increased from 70 to 80 in steps of 0.5:
for NUM in `seq -f "%.8E" 70 0.5 80`; do FILE = "m0_$NUM.in" cp MSSM.in "$FILE" slha-io.sh "$FILE" set minpar 1 " 1 $NUM # m0" done
Maybe this script is useful for one or two!
By the way, more sophisticated tools for SLHA I/O are SLHALib and SLHAio.