-
- mat.nx=nframes;
- mat.ny=hb->nrhb;
-
- snew(mat.matrix,mat.nx);
- for(x=0; (x<mat.nx); x++)
- snew(mat.matrix[x],mat.ny);
- y=0;
- for(id=0; (id<hb->d.nrd); id++)
- for(ia=0; (ia<hb->a.nra); ia++) {
- for(hh=0; (hh<hb->maxhydro); hh++) {
- if (hb->hbmap[id][ia]) {
- if (ISHB(hb->hbmap[id][ia]->history[hh])) {
- /* Changed '<' into '<=' in the for-statement below.
- * It fixed the previously undiscovered bug that caused
- * the last occurance of an hbond/contact to not be
- * set in mat.matrix. Have a look at any old -hbm-output
- * and you will notice that the last column is allways empty.
- * - Erik Marklund May 30, 2006
- */
- for(x=0; (x<=hb->hbmap[id][ia]->nframes); x++) {
- int nn0 = hb->hbmap[id][ia]->n0;
- range_check(y,0,mat.ny);
- mat.matrix[x+nn0][y] = is_hb(hb->hbmap[id][ia]->h[hh],x);
+
+ if ((nframes > 0) && (hb->nrhb > 0))
+ {
+ mat.nx=nframes;
+ mat.ny=hb->nrhb;
+
+ snew(mat.matrix,mat.nx);
+ for(x=0; (x<mat.nx); x++)
+ snew(mat.matrix[x],mat.ny);
+ y=0;
+ for(id=0; (id<hb->d.nrd); id++)
+ for(ia=0; (ia<hb->a.nra); ia++) {
+ for(hh=0; (hh<hb->maxhydro); hh++) {
+ if (hb->hbmap[id][ia]) {
+ if (ISHB(hb->hbmap[id][ia]->history[hh])) {
+ /* Changed '<' into '<=' in the for-statement below.
+ * It fixed the previously undiscovered bug that caused
+ * the last occurance of an hbond/contact to not be
+ * set in mat.matrix. Have a look at any old -hbm-output
+ * and you will notice that the last column is allways empty.
+ * - Erik Marklund May 30, 2006
+ */
+ for(x=0; (x<=hb->hbmap[id][ia]->nframes); x++) {
+ int nn0 = hb->hbmap[id][ia]->n0;
+ range_check(y,0,mat.ny);
+ mat.matrix[x+nn0][y] = is_hb(hb->hbmap[id][ia]->h[hh],x);
+ }
+ y++;