Merge remote-tracking branch 'origin/release-4-6' into HEAD
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_adress_c / nb_kernel233_c_adress.c
1 /*
2  * Copyright (c) Erik Lindahl, David van der Spoel 2003
3  * 
4  * This file is generated automatically at compile time
5  * by the program mknb in the Gromacs distribution.
6  *
7  * Options used when generation this file:
8  * Language:         c
9  * Precision:        single
10  * Threads:          yes
11  * Software invsqrt: no
12  * PowerPC invsqrt:  no
13  * Prefetch forces:  no
14  * Adress kernel:  yes
15  * Comments:         no
16  */
17 #ifdef HAVE_CONFIG_H
18 #include<config.h>
19 #endif
20 #ifdef GMX_THREAD_SHM_FDECOMP
21 #include<thread_mpi.h>
22 #endif
23 #define ALMOST_ZERO 1e-30
24 #define ALMOST_ONE 1-(1e-30)
25 #include<math.h>
26
27 #include "nb_kernel233_adress.h"
28
29
30
31 /*
32  * Gromacs nonbonded kernel nb_kernel233_adress_cg
33  * Coulomb interaction:     Reaction field
34  * VdW interaction:         Tabulated
35  * water optimization:      TIP4P - other atoms
36  * Calculate forces:        yes
37  */
38 void nb_kernel233_adress_cg(
39                     int *           p_nri,
40                     int *           iinr,
41                     int *           jindex,
42                     int *           jjnr,
43                     int *           shift,
44                     real *         shiftvec,
45                     real *         fshift,
46                     int *           gid,
47                     real *         pos,
48                     real *         faction,
49                     real *         charge,
50                     real *         p_facel,
51                     real *         p_krf,
52                     real *         p_crf,
53                     real *         Vc,
54                     int *           type,
55                     int *           p_ntype,
56                     real *         vdwparam,
57                     real *         Vvdw,
58                     real *         p_tabscale,
59                     real *         VFtab,
60                     real *         invsqrta,
61                     real *         dvda,
62                     real *         p_gbtabscale,
63                     real *         GBtab,
64                     int *           p_nthreads,
65                     int *           count,
66                     void *          mtx,
67                     int *           outeriter,
68                     int *           inneriter,
69                     real           force_cap,
70                     real *         wf)
71 {
72     int           nri,ntype,nthreads;
73     real         facel,krf,crf,tabscale,gbtabscale;
74     int           n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid;
75     int           nn0,nn1,nouter,ninner;
76     real         shX,shY,shZ;
77     real         fscal,tx,ty,tz;
78     real         rinvsq;
79     real         jq;
80     real         qq,vcoul,vctot;
81     int           nti;
82     int           tj;
83     real         Vvdw6,Vvdwtot;
84     real         Vvdw12;
85     real         r,rt,eps,eps2;
86     int           n0,nnn;
87     real         Y,F,Geps,Heps2,Fp,VV;
88     real         FF;
89     real         fijD,fijR;
90     real         krsq;
91     real         ix1,iy1,iz1,fix1,fiy1,fiz1;
92     real         ix2,iy2,iz2,fix2,fiy2,fiz2;
93     real         ix3,iy3,iz3,fix3,fiy3,fiz3;
94     real         ix4,iy4,iz4,fix4,fiy4,fiz4;
95     real         jx1,jy1,jz1,fjx1,fjy1,fjz1;
96     real         dx11,dy11,dz11,rsq11,rinv11;
97     real         dx21,dy21,dz21,rsq21,rinv21;
98     real         dx31,dy31,dz31,rsq31,rinv31;
99     real         dx41,dy41,dz41,rsq41,rinv41;
100     real         qH,qM;
101     real         c6,c12;
102     real         weight_cg1, weight_cg2, weight_product;
103     real         hybscal;
104
105     nri              = *p_nri;         
106     ntype            = *p_ntype;       
107     nthreads         = *p_nthreads;    
108     facel            = *p_facel;       
109     krf              = *p_krf;         
110     crf              = *p_crf;         
111     tabscale         = *p_tabscale;    
112     ii               = iinr[0];        
113     qH               = facel*charge[ii+1];
114     qM               = facel*charge[ii+3];
115     nti              = 2*ntype*type[ii];
116
117     nouter           = 0;              
118     ninner           = 0;              
119     
120     do
121     {
122         #ifdef GMX_THREAD_SHM_FDECOMP
123         tMPI_Thread_mutex_lock((tMPI_Thread_mutex_t *)mtx);
124         nn0              = *count;         
125         nn1              = nn0+(nri-nn0)/(2*nthreads)+10;
126         *count           = nn1;            
127         tMPI_Thread_mutex_unlock((tMPI_Thread_mutex_t *)mtx);
128         if(nn1>nri) nn1=nri;
129         #else
130         nn0 = 0;
131         nn1 = nri;
132         #endif
133         
134         for(n=nn0; (n<nn1); n++)
135         {
136             is3              = 3*shift[n];     
137             shX              = shiftvec[is3];  
138             shY              = shiftvec[is3+1];
139             shZ              = shiftvec[is3+2];
140             nj0              = jindex[n];      
141             nj1              = jindex[n+1];    
142             ii               = iinr[n];        
143             ii3              = 3*ii;           
144             ix1              = shX + pos[ii3+0];
145             iy1              = shY + pos[ii3+1];
146             iz1              = shZ + pos[ii3+2];
147             ix2              = shX + pos[ii3+3];
148             iy2              = shY + pos[ii3+4];
149             iz2              = shZ + pos[ii3+5];
150             ix3              = shX + pos[ii3+6];
151             iy3              = shY + pos[ii3+7];
152             iz3              = shZ + pos[ii3+8];
153             ix4              = shX + pos[ii3+9];
154             iy4              = shY + pos[ii3+10];
155             iz4              = shZ + pos[ii3+11];
156             weight_cg1       = wf[ii];         
157             vctot            = 0;              
158             Vvdwtot          = 0;              
159             fix1             = 0;              
160             fiy1             = 0;              
161             fiz1             = 0;              
162             fix2             = 0;              
163             fiy2             = 0;              
164             fiz2             = 0;              
165             fix3             = 0;              
166             fiy3             = 0;              
167             fiz3             = 0;              
168             fix4             = 0;              
169             fiy4             = 0;              
170             fiz4             = 0;              
171             
172             for(k=nj0; (k<nj1); k++)
173             {
174                 jnr              = jjnr[k];        
175                 weight_cg2       = wf[jnr];        
176                 weight_product   = weight_cg1*weight_cg2;
177                 if (weight_product < ALMOST_ZERO) {
178                        hybscal = 1.0;
179                 }
180                 else if (weight_product >= ALMOST_ONE)
181                 {
182                   /* force is zero, skip this molecule */
183                        continue;
184                 }
185                 else
186                 {
187                    hybscal = 1.0 - weight_product;
188                 }
189                 j3               = 3*jnr;          
190                 jx1              = pos[j3+0];      
191                 jy1              = pos[j3+1];      
192                 jz1              = pos[j3+2];      
193                 dx11             = ix1 - jx1;      
194                 dy11             = iy1 - jy1;      
195                 dz11             = iz1 - jz1;      
196                 rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
197                 dx21             = ix2 - jx1;      
198                 dy21             = iy2 - jy1;      
199                 dz21             = iz2 - jz1;      
200                 rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
201                 dx31             = ix3 - jx1;      
202                 dy31             = iy3 - jy1;      
203                 dz31             = iz3 - jz1;      
204                 rsq31            = dx31*dx31+dy31*dy31+dz31*dz31;
205                 dx41             = ix4 - jx1;      
206                 dy41             = iy4 - jy1;      
207                 dz41             = iz4 - jz1;      
208                 rsq41            = dx41*dx41+dy41*dy41+dz41*dz41;
209                 rinv11           = 1.0/sqrt(rsq11);
210                 rinv21           = 1.0/sqrt(rsq21);
211                 rinv31           = 1.0/sqrt(rsq31);
212                 rinv41           = 1.0/sqrt(rsq41);
213                 tj               = nti+2*type[jnr];
214                 c6               = vdwparam[tj];   
215                 c12              = vdwparam[tj+1]; 
216                 r                = rsq11*rinv11;   
217                 rt               = r*tabscale;     
218                 n0               = rt;             
219                 eps              = rt-n0;          
220                 eps2             = eps*eps;        
221                 nnn              = 8*n0;           
222                 Y                = VFtab[nnn];     
223                 F                = VFtab[nnn+1];   
224                 Geps             = eps*VFtab[nnn+2];
225                 Heps2            = eps2*VFtab[nnn+3];
226                 Fp               = F+Geps+Heps2;   
227                 VV               = Y+eps*Fp;       
228                 FF               = Fp+Geps+2.0*Heps2;
229                 Vvdw6            = c6*VV;          
230                 fijD             = c6*FF;          
231                 nnn              = nnn+4;          
232                 Y                = VFtab[nnn];     
233                 F                = VFtab[nnn+1];   
234                 Geps             = eps*VFtab[nnn+2];
235                 Heps2            = eps2*VFtab[nnn+3];
236                 Fp               = F+Geps+Heps2;   
237                 VV               = Y+eps*Fp;       
238                 FF               = Fp+Geps+2.0*Heps2;
239                 Vvdw12           = c12*VV;         
240                 fijR             = c12*FF;         
241                 Vvdwtot          = Vvdwtot+ Vvdw6 + Vvdw12;
242                 fscal            = -((fijD+fijR)*tabscale)*rinv11;
243                 fscal *= hybscal;
244                 tx               = fscal*dx11;     
245                 ty               = fscal*dy11;     
246                 tz               = fscal*dz11;     
247                 fix1             = fix1 + tx;      
248                 fiy1             = fiy1 + ty;      
249                 fiz1             = fiz1 + tz;      
250                 fjx1             = faction[j3+0] - tx;
251                 fjy1             = faction[j3+1] - ty;
252                 fjz1             = faction[j3+2] - tz;
253                 jq               = charge[jnr+0];  
254                 qq               = qH*jq;          
255                 rinvsq           = rinv21*rinv21;  
256                 krsq             = krf*rsq21;      
257                 vcoul            = qq*(rinv21+krsq-crf);
258                 vctot            = vctot+vcoul;    
259                 fscal            = (qq*(rinv21-2.0*krsq))*rinvsq;
260                 fscal *= hybscal;
261                 tx               = fscal*dx21;     
262                 ty               = fscal*dy21;     
263                 tz               = fscal*dz21;     
264                 fix2             = fix2 + tx;      
265                 fiy2             = fiy2 + ty;      
266                 fiz2             = fiz2 + tz;      
267                 fjx1             = fjx1 - tx;      
268                 fjy1             = fjy1 - ty;      
269                 fjz1             = fjz1 - tz;      
270                 rinvsq           = rinv31*rinv31;  
271                 krsq             = krf*rsq31;      
272                 vcoul            = qq*(rinv31+krsq-crf);
273                 vctot            = vctot+vcoul;    
274                 fscal            = (qq*(rinv31-2.0*krsq))*rinvsq;
275                 fscal *= hybscal;
276                 tx               = fscal*dx31;     
277                 ty               = fscal*dy31;     
278                 tz               = fscal*dz31;     
279                 fix3             = fix3 + tx;      
280                 fiy3             = fiy3 + ty;      
281                 fiz3             = fiz3 + tz;      
282                 fjx1             = fjx1 - tx;      
283                 fjy1             = fjy1 - ty;      
284                 fjz1             = fjz1 - tz;      
285                 qq               = qM*jq;          
286                 rinvsq           = rinv41*rinv41;  
287                 krsq             = krf*rsq41;      
288                 vcoul            = qq*(rinv41+krsq-crf);
289                 vctot            = vctot+vcoul;    
290                 fscal            = (qq*(rinv41-2.0*krsq))*rinvsq;
291                 fscal *= hybscal;
292                 tx               = fscal*dx41;     
293                 ty               = fscal*dy41;     
294                 tz               = fscal*dz41;     
295                 fix4             = fix4 + tx;      
296                 fiy4             = fiy4 + ty;      
297                 fiz4             = fiz4 + tz;      
298                 faction[j3+0]    = fjx1 - tx;      
299                 faction[j3+1]    = fjy1 - ty;      
300                 faction[j3+2]    = fjz1 - tz;      
301             }
302             
303             faction[ii3+0]   = faction[ii3+0] + fix1;
304             faction[ii3+1]   = faction[ii3+1] + fiy1;
305             faction[ii3+2]   = faction[ii3+2] + fiz1;
306             faction[ii3+3]   = faction[ii3+3] + fix2;
307             faction[ii3+4]   = faction[ii3+4] + fiy2;
308             faction[ii3+5]   = faction[ii3+5] + fiz2;
309             faction[ii3+6]   = faction[ii3+6] + fix3;
310             faction[ii3+7]   = faction[ii3+7] + fiy3;
311             faction[ii3+8]   = faction[ii3+8] + fiz3;
312             faction[ii3+9]   = faction[ii3+9] + fix4;
313             faction[ii3+10]  = faction[ii3+10] + fiy4;
314             faction[ii3+11]  = faction[ii3+11] + fiz4;
315             fshift[is3]      = fshift[is3]+fix1+fix2+fix3+fix4;
316             fshift[is3+1]    = fshift[is3+1]+fiy1+fiy2+fiy3+fiy4;
317             fshift[is3+2]    = fshift[is3+2]+fiz1+fiz2+fiz3+fiz4;
318             ggid             = gid[n];         
319             Vc[ggid]         = Vc[ggid] + vctot;
320             Vvdw[ggid]       = Vvdw[ggid] + Vvdwtot;
321             ninner           = ninner + nj1 - nj0;
322         }
323         
324         nouter           = nouter + nn1 - nn0;
325     }
326     while (nn1<nri);
327     
328     *outeriter       = nouter;         
329     *inneriter       = ninner;         
330 }
331
332
333
334
335
336 /*
337  * Gromacs nonbonded kernel nb_kernel233_adress_ex
338  * Coulomb interaction:     Reaction field
339  * VdW interaction:         Tabulated
340  * water optimization:      TIP4P - other atoms
341  * Calculate forces:        yes
342  */
343 void nb_kernel233_adress_ex(
344                     int *           p_nri,
345                     int *           iinr,
346                     int *           jindex,
347                     int *           jjnr,
348                     int *           shift,
349                     real *         shiftvec,
350                     real *         fshift,
351                     int *           gid,
352                     real *         pos,
353                     real *         faction,
354                     real *         charge,
355                     real *         p_facel,
356                     real *         p_krf,
357                     real *         p_crf,
358                     real *         Vc,
359                     int *           type,
360                     int *           p_ntype,
361                     real *         vdwparam,
362                     real *         Vvdw,
363                     real *         p_tabscale,
364                     real *         VFtab,
365                     real *         invsqrta,
366                     real *         dvda,
367                     real *         p_gbtabscale,
368                     real *         GBtab,
369                     int *           p_nthreads,
370                     int *           count,
371                     void *          mtx,
372                     int *           outeriter,
373                     int *           inneriter,
374                     real           force_cap,
375                     real *         wf)
376 {
377     int           nri,ntype,nthreads;
378     real         facel,krf,crf,tabscale,gbtabscale;
379     int           n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid;
380     int           nn0,nn1,nouter,ninner;
381     real         shX,shY,shZ;
382     real         fscal,tx,ty,tz;
383     real         rinvsq;
384     real         jq;
385     real         qq,vcoul,vctot;
386     int           nti;
387     int           tj;
388     real         Vvdw6,Vvdwtot;
389     real         Vvdw12;
390     real         r,rt,eps,eps2;
391     int           n0,nnn;
392     real         Y,F,Geps,Heps2,Fp,VV;
393     real         FF;
394     real         fijD,fijR;
395     real         krsq;
396     real         ix1,iy1,iz1,fix1,fiy1,fiz1;
397     real         ix2,iy2,iz2,fix2,fiy2,fiz2;
398     real         ix3,iy3,iz3,fix3,fiy3,fiz3;
399     real         ix4,iy4,iz4,fix4,fiy4,fiz4;
400     real         jx1,jy1,jz1,fjx1,fjy1,fjz1;
401     real         dx11,dy11,dz11,rsq11,rinv11;
402     real         dx21,dy21,dz21,rsq21,rinv21;
403     real         dx31,dy31,dz31,rsq31,rinv31;
404     real         dx41,dy41,dz41,rsq41,rinv41;
405     real         qH,qM;
406     real         c6,c12;
407     real         weight_cg1, weight_cg2, weight_product;
408     real         hybscal;
409
410     nri              = *p_nri;         
411     ntype            = *p_ntype;       
412     nthreads         = *p_nthreads;    
413     facel            = *p_facel;       
414     krf              = *p_krf;         
415     crf              = *p_crf;         
416     tabscale         = *p_tabscale;    
417     ii               = iinr[0];        
418     qH               = facel*charge[ii+1];
419     qM               = facel*charge[ii+3];
420     nti              = 2*ntype*type[ii];
421
422     nouter           = 0;              
423     ninner           = 0;              
424     
425     do
426     {
427         #ifdef GMX_THREAD_SHM_FDECOMP
428         tMPI_Thread_mutex_lock((tMPI_Thread_mutex_t *)mtx);
429         nn0              = *count;         
430         nn1              = nn0+(nri-nn0)/(2*nthreads)+10;
431         *count           = nn1;            
432         tMPI_Thread_mutex_unlock((tMPI_Thread_mutex_t *)mtx);
433         if(nn1>nri) nn1=nri;
434         #else
435         nn0 = 0;
436         nn1 = nri;
437         #endif
438         
439         for(n=nn0; (n<nn1); n++)
440         {
441             is3              = 3*shift[n];     
442             shX              = shiftvec[is3];  
443             shY              = shiftvec[is3+1];
444             shZ              = shiftvec[is3+2];
445             nj0              = jindex[n];      
446             nj1              = jindex[n+1];    
447             ii               = iinr[n];        
448             ii3              = 3*ii;           
449             ix1              = shX + pos[ii3+0];
450             iy1              = shY + pos[ii3+1];
451             iz1              = shZ + pos[ii3+2];
452             ix2              = shX + pos[ii3+3];
453             iy2              = shY + pos[ii3+4];
454             iz2              = shZ + pos[ii3+5];
455             ix3              = shX + pos[ii3+6];
456             iy3              = shY + pos[ii3+7];
457             iz3              = shZ + pos[ii3+8];
458             ix4              = shX + pos[ii3+9];
459             iy4              = shY + pos[ii3+10];
460             iz4              = shZ + pos[ii3+11];
461             weight_cg1       = wf[ii];         
462             vctot            = 0;              
463             Vvdwtot          = 0;              
464             fix1             = 0;              
465             fiy1             = 0;              
466             fiz1             = 0;              
467             fix2             = 0;              
468             fiy2             = 0;              
469             fiz2             = 0;              
470             fix3             = 0;              
471             fiy3             = 0;              
472             fiz3             = 0;              
473             fix4             = 0;              
474             fiy4             = 0;              
475             fiz4             = 0;              
476             
477             for(k=nj0; (k<nj1); k++)
478             {
479                 jnr              = jjnr[k];        
480                 weight_cg2       = wf[jnr];        
481                 weight_product   = weight_cg1*weight_cg2;
482                 if (weight_product < ALMOST_ZERO) {
483                 /* force is zero, skip this molecule */
484                  continue;
485                 }
486                 else if (weight_product >= ALMOST_ONE)
487                 {
488                        hybscal = 1.0;
489                 }
490                 else
491                 {
492                    hybscal = weight_product;
493                 }
494                 j3               = 3*jnr;          
495                 jx1              = pos[j3+0];      
496                 jy1              = pos[j3+1];      
497                 jz1              = pos[j3+2];      
498                 dx11             = ix1 - jx1;      
499                 dy11             = iy1 - jy1;      
500                 dz11             = iz1 - jz1;      
501                 rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
502                 dx21             = ix2 - jx1;      
503                 dy21             = iy2 - jy1;      
504                 dz21             = iz2 - jz1;      
505                 rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
506                 dx31             = ix3 - jx1;      
507                 dy31             = iy3 - jy1;      
508                 dz31             = iz3 - jz1;      
509                 rsq31            = dx31*dx31+dy31*dy31+dz31*dz31;
510                 dx41             = ix4 - jx1;      
511                 dy41             = iy4 - jy1;      
512                 dz41             = iz4 - jz1;      
513                 rsq41            = dx41*dx41+dy41*dy41+dz41*dz41;
514                 rinv11           = 1.0/sqrt(rsq11);
515                 rinv21           = 1.0/sqrt(rsq21);
516                 rinv31           = 1.0/sqrt(rsq31);
517                 rinv41           = 1.0/sqrt(rsq41);
518                 tj               = nti+2*type[jnr];
519                 c6               = vdwparam[tj];   
520                 c12              = vdwparam[tj+1]; 
521                 r                = rsq11*rinv11;   
522                 rt               = r*tabscale;     
523                 n0               = rt;             
524                 eps              = rt-n0;          
525                 eps2             = eps*eps;        
526                 nnn              = 8*n0;           
527                 Y                = VFtab[nnn];     
528                 F                = VFtab[nnn+1];   
529                 Geps             = eps*VFtab[nnn+2];
530                 Heps2            = eps2*VFtab[nnn+3];
531                 Fp               = F+Geps+Heps2;   
532                 VV               = Y+eps*Fp;       
533                 FF               = Fp+Geps+2.0*Heps2;
534                 Vvdw6            = c6*VV;          
535                 fijD             = c6*FF;          
536                 nnn              = nnn+4;          
537                 Y                = VFtab[nnn];     
538                 F                = VFtab[nnn+1];   
539                 Geps             = eps*VFtab[nnn+2];
540                 Heps2            = eps2*VFtab[nnn+3];
541                 Fp               = F+Geps+Heps2;   
542                 VV               = Y+eps*Fp;       
543                 FF               = Fp+Geps+2.0*Heps2;
544                 Vvdw12           = c12*VV;         
545                 fijR             = c12*FF;         
546                 Vvdwtot          = Vvdwtot+ Vvdw6 + Vvdw12;
547                 fscal            = -((fijD+fijR)*tabscale)*rinv11;
548                 fscal *= hybscal;
549                 if(force_cap>0 && (fabs(fscal)> force_cap)){
550                 fscal=force_cap*fscal/fabs(fscal);
551                 }
552                 tx               = fscal*dx11;     
553                 ty               = fscal*dy11;     
554                 tz               = fscal*dz11;     
555                 fix1             = fix1 + tx;      
556                 fiy1             = fiy1 + ty;      
557                 fiz1             = fiz1 + tz;      
558                 fjx1             = faction[j3+0] - tx;
559                 fjy1             = faction[j3+1] - ty;
560                 fjz1             = faction[j3+2] - tz;
561                 jq               = charge[jnr+0];  
562                 qq               = qH*jq;          
563                 rinvsq           = rinv21*rinv21;  
564                 krsq             = krf*rsq21;      
565                 vcoul            = qq*(rinv21+krsq-crf);
566                 vctot            = vctot+vcoul;    
567                 fscal            = (qq*(rinv21-2.0*krsq))*rinvsq;
568                 fscal *= hybscal;
569                 if(force_cap>0 && (fabs(fscal)> force_cap)){
570                 fscal=force_cap*fscal/fabs(fscal);
571                 }
572                 tx               = fscal*dx21;     
573                 ty               = fscal*dy21;     
574                 tz               = fscal*dz21;     
575                 fix2             = fix2 + tx;      
576                 fiy2             = fiy2 + ty;      
577                 fiz2             = fiz2 + tz;      
578                 fjx1             = fjx1 - tx;      
579                 fjy1             = fjy1 - ty;      
580                 fjz1             = fjz1 - tz;      
581                 rinvsq           = rinv31*rinv31;  
582                 krsq             = krf*rsq31;      
583                 vcoul            = qq*(rinv31+krsq-crf);
584                 vctot            = vctot+vcoul;    
585                 fscal            = (qq*(rinv31-2.0*krsq))*rinvsq;
586                 fscal *= hybscal;
587                 if(force_cap>0 && (fabs(fscal)> force_cap)){
588                 fscal=force_cap*fscal/fabs(fscal);
589                 }
590                 tx               = fscal*dx31;     
591                 ty               = fscal*dy31;     
592                 tz               = fscal*dz31;     
593                 fix3             = fix3 + tx;      
594                 fiy3             = fiy3 + ty;      
595                 fiz3             = fiz3 + tz;      
596                 fjx1             = fjx1 - tx;      
597                 fjy1             = fjy1 - ty;      
598                 fjz1             = fjz1 - tz;      
599                 qq               = qM*jq;          
600                 rinvsq           = rinv41*rinv41;  
601                 krsq             = krf*rsq41;      
602                 vcoul            = qq*(rinv41+krsq-crf);
603                 vctot            = vctot+vcoul;    
604                 fscal            = (qq*(rinv41-2.0*krsq))*rinvsq;
605                 fscal *= hybscal;
606                 if(force_cap>0 && (fabs(fscal)> force_cap)){
607                 fscal=force_cap*fscal/fabs(fscal);
608                 }
609                 tx               = fscal*dx41;     
610                 ty               = fscal*dy41;     
611                 tz               = fscal*dz41;     
612                 fix4             = fix4 + tx;      
613                 fiy4             = fiy4 + ty;      
614                 fiz4             = fiz4 + tz;      
615                 faction[j3+0]    = fjx1 - tx;      
616                 faction[j3+1]    = fjy1 - ty;      
617                 faction[j3+2]    = fjz1 - tz;      
618             }
619             
620             faction[ii3+0]   = faction[ii3+0] + fix1;
621             faction[ii3+1]   = faction[ii3+1] + fiy1;
622             faction[ii3+2]   = faction[ii3+2] + fiz1;
623             faction[ii3+3]   = faction[ii3+3] + fix2;
624             faction[ii3+4]   = faction[ii3+4] + fiy2;
625             faction[ii3+5]   = faction[ii3+5] + fiz2;
626             faction[ii3+6]   = faction[ii3+6] + fix3;
627             faction[ii3+7]   = faction[ii3+7] + fiy3;
628             faction[ii3+8]   = faction[ii3+8] + fiz3;
629             faction[ii3+9]   = faction[ii3+9] + fix4;
630             faction[ii3+10]  = faction[ii3+10] + fiy4;
631             faction[ii3+11]  = faction[ii3+11] + fiz4;
632             fshift[is3]      = fshift[is3]+fix1+fix2+fix3+fix4;
633             fshift[is3+1]    = fshift[is3+1]+fiy1+fiy2+fiy3+fiy4;
634             fshift[is3+2]    = fshift[is3+2]+fiz1+fiz2+fiz3+fiz4;
635             ggid             = gid[n];         
636             Vc[ggid]         = Vc[ggid] + vctot;
637             Vvdw[ggid]       = Vvdw[ggid] + Vvdwtot;
638             ninner           = ninner + nj1 - nj0;
639         }
640         
641         nouter           = nouter + nn1 - nn0;
642     }
643     while (nn1<nri);
644     
645     *outeriter       = nouter;         
646     *inneriter       = ninner;         
647 }
648
649