[lammps-users] bug with special function max and min

Hello,
I am computing the centers of mass for the molecules in my system and when I use max(c_id[3]) to find the max z coordinate center of mass it gives me the max x coordinate center of mass. max(c_id[2]) gives the max z coordinate and max(c_id[1]) gives the max y coordinate. The min function does the same. The column index is permutated by 1. This is how I get this error, maybe my input script is in the problem. Please let me know if I’m making a mistake with how I’m using the max function.
Thanks
Lynn

I think I found the bug.

In variable.cpp are these lines:

    if (compute) {
      double *vec;
      if (index) vec = &compute->array[0][index];
      else vec = compute->vector;

Please change them to index-1:

    if (compute) {
      double *vec;
      if (index) vec = &compute->array[0][index-1];
      else vec = compute->vector;

and try your test again. If it works, let me know
and I will post a patch.

Thanks,
Steve