if(!(itom[i].attr&ATOM_ATTR_3BP))
return 0;
- link_cell_neighbour_index(moldyn,
+ // thread safe this way!
+ dnlc=link_cell_neighbour_index(moldyn,
(itom[i].r.x+moldyn->dim.x/2)/lc->x,
(itom[i].r.y+moldyn->dim.y/2)/lc->y,
(itom[i].r.z+moldyn->dim.z/2)/lc->z,
neighbour_i);
- dnlc=lc->dnlc;
-
/* copy the neighbour lists */
#ifdef STATIC_LISTS
#elif LOWMEM_LISTS
while(p!=-1) {
jtom=&(itom[p]);
- p=lc->subcell->list[p];
+ p=lc->subcell->list[p]; // thread safe!
#else
this=&(neighbour_i[j]);
list_reset_f(this);
scale=-0.5*(f_c*(df_r-b*df_a)+df_c*(f_r-b*f_a)); // - in albe formalism
#endif
v3_scale(&force,&(dist_ij),scale);
- pthread_mutex_lock(&(amutex[ai->tag]));
+ if(pthread_mutex_lock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex lock (1)\n");
v3_add(&(ai->f),&(ai->f),&force);
- pthread_mutex_unlock(&(amutex[ai->tag]));
+ if(pthread_mutex_unlock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex unlock (1)\n");
/* force contribution for atom j */
v3_scale(&force,&force,-1.0); // dri rij = - drj rij
- pthread_mutex_lock(&(amutex[jtom->tag]));
+ if(pthread_mutex_lock(&(amutex[jtom->tag])))
+ perror("[albe fast] mutex lock (2)\n");
v3_add(&(jtom->f),&(jtom->f),&force);
- pthread_mutex_unlock(&(amutex[jtom->tag]));
+ if(pthread_mutex_unlock(&(amutex[jtom->tag])))
+ perror("[albe fast] mutex unlock (2)\n");
/* virial */
- pthread_mutex_lock(&(amutex[ai->tag]));
+ if(pthread_mutex_lock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex lock (3)\n");
albe_v_calc(ai,&force,&(dist_ij));
//virial_calc(ai,&force,&(dist_ij));
- pthread_mutex_unlock(&(amutex[ai->tag]));
+ if(pthread_mutex_unlock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex unlock (3)\n");
#ifdef DEBUG
if(moldyn->time>DSTART&&moldyn->time<DEND) {
/* energy contribution */
energy=0.5*f_c*(f_r-b*f_a); // - in albe formalism
- pthread_mutex_lock(&emutex);
+ if(pthread_mutex_lock(&emutex))
+ perror("[albe fast] mutex lock (energy)\n");
moldyn->energy+=energy;
- pthread_mutex_unlock(&emutex);
- pthread_mutex_lock(&(amutex[ai->tag]));
+ if(pthread_mutex_unlock(&emutex))
+ perror("[albe fast] mutex unlock (energy)\n");
+ if(pthread_mutex_lock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex lock (4)\n");
ai->e+=energy;
- pthread_mutex_unlock(&(amutex[ai->tag]));
+ if(pthread_mutex_unlock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex unlock (4)\n");
/* reset k counter for second k loop */
kcount=0;
v3_scale(&force,&dcosdrj,fcdg*pre_dzeta);
/* force contribution */
- pthread_mutex_lock(&(amutex[jtom->tag]));
+ if(pthread_mutex_lock(&(amutex[jtom->tag])))
+ perror("[albe fast] mutex lock (5)\n");
v3_add(&(jtom->f),&(jtom->f),&force);
- pthread_mutex_unlock(&(amutex[jtom->tag]));
+ if(pthread_mutex_unlock(&(amutex[jtom->tag])))
+ perror("[albe fast] mutex unlock (5)\n");
#ifdef DEBUG
if(moldyn->time>DSTART&&moldyn->time<DEND) {
#endif
/* virial */
- pthread_mutex_lock(&(amutex[ai->tag]));
+ if(pthread_mutex_lock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex lock (6)\n");
albe_v_calc(ai,&force,&dist_ij);
//virial_calc(ai,&force,&dist_ij);
/* force contribution to atom i */
v3_scale(&force,&force,-1.0);
v3_add(&(ai->f),&(ai->f),&force);
- pthread_mutex_unlock(&(amutex[ai->tag]));
+ if(pthread_mutex_unlock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex unlock (6)\n");
/* derivative wrt k */
#ifdef MATTONI
#endif
/* force contribution */
- pthread_mutex_lock(&(amutex[ktom->tag]));
+ if(pthread_mutex_lock(&(amutex[ktom->tag])))
+ perror("[albe fast] mutex lock (7)\n");
v3_add(&(ktom->f),&(ktom->f),&force);
- pthread_mutex_unlock(&(amutex[ktom->tag]));
+ if(pthread_mutex_unlock(&(amutex[ktom->tag])))
+ perror("[albe fast] mutex unlock (7)\n");
#ifdef DEBUG
if(moldyn->time>DSTART&&moldyn->time<DEND) {
#endif
/* virial */
- pthread_mutex_lock(&(amutex[ai->tag]));
+ if(pthread_mutex_lock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex lock (8)\n");
albe_v_calc(ai,&force,&dist_ik);
//virial_calc(ai,&force,&dist_ik);
/* force contribution to atom i */
v3_scale(&force,&force,-1.0);
v3_add(&(ai->f),&(ai->f),&force);
- pthread_mutex_unlock(&(amutex[ai->tag]));
+ if(pthread_mutex_unlock(&(amutex[ai->tag])))
+ perror("[albe fast] mutex unlock (8)\n");
/* increase k counter */
kcount++;