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