Include File Mechanism

    Table of contents
    No headers

    When constructing a system topology in a .top file for presentation to grompp, GROMACS uses a built-in version of the the so-called C preprocessor, cpp (in GROMACS 3, it really was cpp). cpp interprets lines like

    #include "ions.itp"

    by looking for the indicated file in the current directory, the GROMACS share/top directory as indicated by the GMXLIB environment variable, and any directory indicated by a -I flag in the value of the include run parameter in the .mdp file. It either finds this file or reports a warning. (Note that when you supply a directory name, you should use Unix-style forward slashes '/', not Windows-style backslashes '\' for separators.) When found, it then uses the contents exactly as if you had cut and pasted the included file into the main file yourself. Note that you shouldn't go and do this copy-and-paste yourself, since the main purposes of the include file mechanism are to re-use previous work, make future changes easier, and prevent typos.

    Further, cpp interprets code such as

    #ifdef POSRES_WATER
    ; Position restraint for each water oxygen
    [ position_restraints ]
    ;  i funct       fcx        fcy        fcz
       1    1       1000       1000       1000

    by testing whether the non-environment variable POSRES_WATER was defined somewhere (i.e. "if defined"). This could be done with #define POSRES_WATER earlier in the .top file (or its #include files), with a -D flag in the include run parameter as above, or on the command line to cpp. The function of the -D flag is borrowed from the similar usage in cpp. The string that follows -D must match exactly; using -DPOSRES will not trigger #ifdef POSRE or #ifdef DPOSRES. This mechanism allows you to change your .mdp file to choose whether or not you want position restraints on your solvent, rather than your .top file.

    Note that in GROMACS 3, you may choose a different underlying preprocessor with the cpprun parameter. (This was obsoleted for GROMACS 4, which implements its own pre-processor work-alike for cpp.)

    Page last modified 12:21, 18 Mar 2013 by mabraham