/* set current vmdcon log level */ void vmdcon_set_loglvl(int lvl) { wkf_mutex_lock(&vmdcon_status_lock); vmdcon_loglvl=lvl; wkf_mutex_unlock(&vmdcon_status_lock); }
extern "C" void * bondsearchthread(void *voidparms) { int i, j, aindex; int paircount = 0; bondsearchthrparms *parms = (bondsearchthrparms *) voidparms; const int threadid = parms->threadid; const int threadcount = parms->threadcount; wkf_mutex_t *pairlistmutex = parms->pairlistmutex; const float *pos = parms->pos; const float *radii = parms->radii; const int totb = parms->totb; const int **boxatom = (const int **) parms->boxatom; const int *numinbox = parms->numinbox; const int **nbrlist = (const int **) parms->nbrlist; const int maxpairs = parms->maxpairs; const float pairdist = parms->pairdist; ResizeArray<int> *pairs = new ResizeArray<int>; float sqdist = pairdist * pairdist; wkfmsgtimer *msgt = wkf_msg_timer_create(5); for (aindex = threadid; (aindex < totb) && (paircount < maxpairs); aindex+=threadcount) { const int *tmpbox, *nbr; tmpbox = boxatom[aindex]; int anbox = numinbox[aindex]; if (((aindex & 255) == 0) && wkf_msg_timer_timeout(msgt)) { char tmpbuf[128]; sprintf(tmpbuf, "%6.2f", (100.0f * aindex) / (float) totb); // XXX: we have to use printf here as msgInfo is not thread-safe. // msgInfo << "vmd_gridsearch_bonds (thread " << threadid << "): " // << tmpbuf << "% complete" << sendmsg; printf("vmd_gridsearch_bonds (thread %d): %s %% complete\n", threadid, tmpbuf); } for (nbr = nbrlist[aindex]; (*nbr != -1) && (paircount < maxpairs); nbr++) { int nnbr=*nbr; const int *nbrbox = boxatom[nnbr]; int nbox=numinbox[nnbr]; int self = (aindex == nnbr) ? 1 : 0; for (i=0; (i<anbox) && (paircount < maxpairs); i++) { int ind1 = tmpbox[i]; const float *p1 = pos + 3L*ind1; // skip over self and already-tested atoms int startj = (self) ? i+1 : 0; for (j=startj; (j<nbox) && (paircount < maxpairs); j++) { int ind2 = nbrbox[j]; const float *p2 = pos + 3L*ind2; float dx = p1[0] - p2[0]; float dy = p1[1] - p2[1]; float dz = p1[2] - p2[2]; float ds2 = dx*dx + dy*dy + dz*dz; // perform distance test, but ignore pairs between atoms // with nearly identical coords if ((ds2 > sqdist) || (ds2 < 0.001)) continue; if (radii) { // Do atom-specific distance check float cut = 0.6f * (radii[ind1] + radii[ind2]); if (ds2 > cut*cut) continue; } pairs->append(ind1); pairs->append(ind2); paircount++; } } } } // setup results pairlist node GridSearchPairlist *head; head = (GridSearchPairlist *) malloc(sizeof(GridSearchPairlist)); head->next = NULL; head->pairlist = pairs; wkf_mutex_lock(pairlistmutex); // lock pairlist before update parms->head = head; wkf_mutex_unlock(pairlistmutex); // unlock pairlist after update wkf_msg_timer_destroy(msgt); return NULL; }