[gmx-developers] get_einp bug ?

Bogdan Costescu bcostescu at gmail.com
Mon Jul 5 18:28:29 CEST 2010


Hi!

Can someone comment on the intention for the last "if" in
readinp.c::get_einp() in GROMACS 4.0.7 ? I think that the code there
is wrong, making it discard the last (correct) assignment in the input
file. Most likely the test should look like:

 if (i == (*ninp))
    return -1;
  else
    return i;

which is similar in spirit to the test above it (checks whether the
end was reached). I can see that the trunk has a different
implementation of this function with seemingly correct behaviour.

Here's how I discovered it:

  inp = read_inpfile(file_in, &ninp);
  for (i=0; i < ninp; i++) {
    fprintf(stderr, "%d, %s, %s\n", i, inp[i].name, inp[i].value);
    }
  fprintf(stderr, "%s\n", get_estr(&ninp, &inp, "group1", "Protein"));
  fprintf(stderr, "%s\n", get_estr(&ninp, &inp, "group2", "Protein"));

with an input file containing:

group1 = x1
group2 = x2

which prints:

0, group1, x1
1, group2, x2
x1
Protein

Because "group2" is the last element in the inp array, i == (*ninp)-1
becomes true and get_einp() returns -1; then get_estr() will use the
default value ("Protein") rather than the one from inp.

I'm not familiar enough with the code to understand what are the
implications for reading of user data from the .mdp file...

Cheers,
Bogdan



More information about the gromacs.org_gmx-developers mailing list