[gmx-developers] cmap_setup_grid_index bug?

David van der Spoel spoel at xray.bmc.uu.se
Tue Oct 28 08:29:49 CET 2014


On 2014-10-24 13:50, David van der Spoel wrote:
> In listed-forces/bonded.cpp I found the following function (when
> debugging a SEGV in cmap_dihs), note the comment was already there. It
> seems that the grid_spacing is used in a strange way, with data from 1
> until grid_spacing - 2, is that correct?
>
> /*! \brief Mysterious undocumented function */
> static int
> cmap_setup_grid_index(int ip, int grid_spacing, int *ipm1, int *ipp1,
> int *ipp2)
> {
>      int im1, ip1, ip2;
>
>      if (ip < 0)
>      {
>          ip = ip + grid_spacing - 1;
>      }
>      else if (ip > grid_spacing)
>      {
>          ip = ip - grid_spacing - 1;
>      }
>
> If that is correct, then code like
>          pos1    = iphi1*cmap_grid->grid_spacing+iphi2;
>
> is suspect. The SEGV finally comes in this statement:
>         ty[0]   = cmapd[pos1*4];
>
> But topology/idef.h seems to tell me that the array should be indexed
> from 0 to grid_spacing-1
> typedef struct
> {
>      real *cmap; /* Has length 4*grid_spacing*grid_spacing, */
>      /* there are 4 entries for each cmap type (V,dVdx,dVdy,d2dVdxdy) */
> } gmx_cmapdata_t;
>
> In summary, cmap_setup_grid_index seems very suspicious.
>
> Any deeper insights anyone?

Do we have any CMAP experts still?


-- 
David van der Spoel, Ph.D., Professor of Biology
Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone:	+46184714205.
spoel at xray.bmc.uu.se    http://folding.bmc.uu.se


More information about the gromacs.org_gmx-developers mailing list