[gmx-developers] Where can I define a truly global variable?

Lee-Ping leeping at MIT.EDU
Thu Aug 2 17:11:10 CEST 2007


Dear community,

I'm trying to add a feature to GROMACS which involves a variable being
passed between all of the bonded and nonbonded force functions (in the same
way that the total potential energy is passed).  I thought of increasing the
number of variables with which each function is declared, but that leads to
an immense amount of errors since each piece of code is intimately linked to
so many others.  Currently I'm working around this problem by having each
force function print numbers to a file, but this involves printf statements
in the inner loops, which the program is not very happy about (it slows down
considerably).  The other solution is to make the variable truly global, so
I don't need to pass it between functions, but where would I declare a
variable so global that I can, for example, call it from
nonbonded_kernel330_c.c if I declared it in md.c or force.c?  Is this even
possible?  If not, is there anywhere I can declare such a global variable
(maybe in a .h file?)  Your input is appreciated.  Thanks,

- Lee-Ping, a novice programmer




More information about the gromacs.org_gmx-developers mailing list