Using Commands in Scripts

    Version as of 08:09, 2 Dec 2021

    to this version.

    Return to Version archive.

    View current version

    GROMACS programs are typically interactive, with selection of index groups made after the program is started.

    There are two options to enable the programs to be executed non-interactively in shell scripts (using the example of g_rms):


    Command Line

    echo 3 3 | g_rms -flags


    Within Script

    There is no fundamental difference between a script and the command line (above) but for extensive user input the following syntax may be used as well (note that this is csh / tcsh notation, bash fanatics might want to add the bash equivalent here).

    g_rms -flags <<EOF

    Or by having the index choices contained within a text file:

    g_rms -flags < choices.txt

    Where choices.txt contains:



    Using Group Names

    As sometimes the numbers of certain choices may vary from file to file from on Gromacs 3.3.1 it is possible to pass the explicit names to the tools.

    g_energy -f ener.edr << EOF

    The best fit will be used, if you select e.g. Pres the first term starting with Pres will be used.


    Complex cases

    Should you encounter a more complex need, the expect tool automates human-script interaction in a programmatic fashion.

    Page last modified 20:17, 22 Sep 2011 by JLemkul?