gibuu is hosted by Hepforge, IPPP Durham
GiBUU

Tools to work with Fortran Namelists and Jobcards

sed

If you want to change GiBUU input jobcards via a (bash) script, one way is to store the skeleton as a template, where the variables you want to change are given by placeholders like XXX, YYY etc. Then you may use sed to replace the placeholder by the actual value, e.g. "sed s/XXX/myValue/"

f90nml, nmltab

Recently (april 2022) I became aware of two projects at GitHub, which are capable of reading in, changing, fine printing, comparing etc. of Fortran jobcards/namelists, written in Python:

f90nml may be easily used to change entries in the jobcard. You may use the program within own python scripts, or use its cli at the prompt.

In the later case, with the option "--patch" it keeps the formatting and the comments of the original input unchanged!

With the option '-g XXX' you have to specify the namelist in the jobcard you want to change, then you can specify new values for input variables by '-v "variable=VAL"'. If in the original namelist 'variable' is already defined, its value is replaced, otherwise a line with the new assignment is added.

  • Not setting the right namelist with the option '-g ...' adds the variable to a wrong namelist and leads to a crash of GiBUU.x
  • One can give multiple '-v ...' arguments, but all changes are done in the namelist you specified with '-g ...' (no multiple '-g ...' are possible!).

So, if one wants to change multiple variables in different namelists, one has to call the program again and again for every namelist (or use a short python program, where one can define the patch including differences in multiple namelists.)

Examples:

  • f90nml -g "input" -v "numTimeSteps=42" --patch in.job out.job
    will (correctly) change the number of timesteps to the value '42' and produce the output jobcard 'out.job', which is a unchanged copy of 'in.job' otherwise.
  • f90nml -g "input" -v "numTimeSteps=42" -g "baryonPotential" -v "EQS_Type=42" --patch in.job out.job
    will (correctly) change the value of 'EQS_Type' in the namelist 'baryonPotential', but will also (incorrectly) add the line "numTimeSteps=42" in the same namelist.

So you have to run the cli multiple times, if you want to change variables in different namelists of the one and only jobcard. Alternatevily, you can write a short python program, where you define the 'patch' and run this instead.

I opened an issue at github for f90nml to extend the syntax of the cli to understand arguments like -v "NML:VAR=val". The author agreed...

Last modified 8 months ago Last modified on Aug 16, 2023, 7:00:28 PM