Fix component for libcudart
[alexxy/gromacs.git] / src / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecRF_VdwLJ_GeomW4P1_c.c
1 /*
2  * Note: this file was generated by the Gromacs c kernel generator.
3  *
4  *                This source code is part of
5  *
6  *                 G   R   O   M   A   C   S
7  *
8  * Copyright (c) 2001-2012, The GROMACS Development Team
9  *
10  * Gromacs is a library for molecular simulation and trajectory analysis,
11  * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
12  * a full list of developers and information, check out http://www.gromacs.org
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License as published by the Free
16  * Software Foundation; either version 2 of the License, or (at your option) any
17  * later version.
18  *
19  * To help fund GROMACS development, we humbly ask that you cite
20  * the papers people have written on it - you can find them on the website.
21  */
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <math.h>
27
28 #include "../nb_kernel.h"
29 #include "types/simple.h"
30 #include "vec.h"
31 #include "nrnb.h"
32
33 /*
34  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4P1_VF_c
35  * Electrostatics interaction: ReactionField
36  * VdW interaction:            LennardJones
37  * Geometry:                   Water4-Particle
38  * Calculate force/pot:        PotentialAndForce
39  */
40 void
41 nb_kernel_ElecRF_VdwLJ_GeomW4P1_VF_c
42                     (t_nblist * gmx_restrict                nlist,
43                      rvec * gmx_restrict                    xx,
44                      rvec * gmx_restrict                    ff,
45                      t_forcerec * gmx_restrict              fr,
46                      t_mdatoms * gmx_restrict               mdatoms,
47                      nb_kernel_data_t * gmx_restrict        kernel_data,
48                      t_nrnb * gmx_restrict                  nrnb)
49 {
50     int              i_shift_offset,i_coord_offset,j_coord_offset;
51     int              j_index_start,j_index_end;
52     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
53     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
54     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
55     real             *shiftvec,*fshift,*x,*f;
56     int              vdwioffset0;
57     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
58     int              vdwioffset1;
59     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
60     int              vdwioffset2;
61     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
62     int              vdwioffset3;
63     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
64     int              vdwjidx0;
65     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
66     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
67     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
68     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
69     real             dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
70     real             velec,felec,velecsum,facel,crf,krf,krf2;
71     real             *charge;
72     int              nvdwtype;
73     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
74     int              *vdwtype;
75     real             *vdwparam;
76
77     x                = xx[0];
78     f                = ff[0];
79
80     nri              = nlist->nri;
81     iinr             = nlist->iinr;
82     jindex           = nlist->jindex;
83     jjnr             = nlist->jjnr;
84     shiftidx         = nlist->shift;
85     gid              = nlist->gid;
86     shiftvec         = fr->shift_vec[0];
87     fshift           = fr->fshift[0];
88     facel            = fr->epsfac;
89     charge           = mdatoms->chargeA;
90     krf              = fr->ic->k_rf;
91     krf2             = krf*2.0;
92     crf              = fr->ic->c_rf;
93     nvdwtype         = fr->ntype;
94     vdwparam         = fr->nbfp;
95     vdwtype          = mdatoms->typeA;
96
97     /* Setup water-specific parameters */
98     inr              = nlist->iinr[0];
99     iq1              = facel*charge[inr+1];
100     iq2              = facel*charge[inr+2];
101     iq3              = facel*charge[inr+3];
102     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
103
104     outeriter        = 0;
105     inneriter        = 0;
106
107     /* Start outer loop over neighborlists */
108     for(iidx=0; iidx<nri; iidx++)
109     {
110         /* Load shift vector for this list */
111         i_shift_offset   = DIM*shiftidx[iidx];
112         shX              = shiftvec[i_shift_offset+XX];
113         shY              = shiftvec[i_shift_offset+YY];
114         shZ              = shiftvec[i_shift_offset+ZZ];
115
116         /* Load limits for loop over neighbors */
117         j_index_start    = jindex[iidx];
118         j_index_end      = jindex[iidx+1];
119
120         /* Get outer coordinate index */
121         inr              = iinr[iidx];
122         i_coord_offset   = DIM*inr;
123
124         /* Load i particle coords and add shift vector */
125         ix0              = shX + x[i_coord_offset+DIM*0+XX];
126         iy0              = shY + x[i_coord_offset+DIM*0+YY];
127         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
128         ix1              = shX + x[i_coord_offset+DIM*1+XX];
129         iy1              = shY + x[i_coord_offset+DIM*1+YY];
130         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
131         ix2              = shX + x[i_coord_offset+DIM*2+XX];
132         iy2              = shY + x[i_coord_offset+DIM*2+YY];
133         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
134         ix3              = shX + x[i_coord_offset+DIM*3+XX];
135         iy3              = shY + x[i_coord_offset+DIM*3+YY];
136         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
137
138         fix0             = 0.0;
139         fiy0             = 0.0;
140         fiz0             = 0.0;
141         fix1             = 0.0;
142         fiy1             = 0.0;
143         fiz1             = 0.0;
144         fix2             = 0.0;
145         fiy2             = 0.0;
146         fiz2             = 0.0;
147         fix3             = 0.0;
148         fiy3             = 0.0;
149         fiz3             = 0.0;
150
151         /* Reset potential sums */
152         velecsum         = 0.0;
153         vvdwsum          = 0.0;
154
155         /* Start inner kernel loop */
156         for(jidx=j_index_start; jidx<j_index_end; jidx++)
157         {
158             /* Get j neighbor index, and coordinate index */
159             jnr              = jjnr[jidx];
160             j_coord_offset   = DIM*jnr;
161
162             /* load j atom coordinates */
163             jx0              = x[j_coord_offset+DIM*0+XX];
164             jy0              = x[j_coord_offset+DIM*0+YY];
165             jz0              = x[j_coord_offset+DIM*0+ZZ];
166
167             /* Calculate displacement vector */
168             dx00             = ix0 - jx0;
169             dy00             = iy0 - jy0;
170             dz00             = iz0 - jz0;
171             dx10             = ix1 - jx0;
172             dy10             = iy1 - jy0;
173             dz10             = iz1 - jz0;
174             dx20             = ix2 - jx0;
175             dy20             = iy2 - jy0;
176             dz20             = iz2 - jz0;
177             dx30             = ix3 - jx0;
178             dy30             = iy3 - jy0;
179             dz30             = iz3 - jz0;
180
181             /* Calculate squared distance and things based on it */
182             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
183             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
184             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
185             rsq30            = dx30*dx30+dy30*dy30+dz30*dz30;
186
187             rinv10           = gmx_invsqrt(rsq10);
188             rinv20           = gmx_invsqrt(rsq20);
189             rinv30           = gmx_invsqrt(rsq30);
190
191             rinvsq00         = 1.0/rsq00;
192             rinvsq10         = rinv10*rinv10;
193             rinvsq20         = rinv20*rinv20;
194             rinvsq30         = rinv30*rinv30;
195
196             /* Load parameters for j particles */
197             jq0              = charge[jnr+0];
198             vdwjidx0         = 2*vdwtype[jnr+0];
199
200             /**************************
201              * CALCULATE INTERACTIONS *
202              **************************/
203
204             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
205             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
206
207             /* LENNARD-JONES DISPERSION/REPULSION */
208
209             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
210             vvdw6            = c6_00*rinvsix;
211             vvdw12           = c12_00*rinvsix*rinvsix;
212             vvdw             = vvdw12*(1.0/12.0) - vvdw6*(1.0/6.0);
213             fvdw             = (vvdw12-vvdw6)*rinvsq00;
214
215             /* Update potential sums from outer loop */
216             vvdwsum         += vvdw;
217
218             fscal            = fvdw;
219
220             /* Calculate temporary vectorial force */
221             tx               = fscal*dx00;
222             ty               = fscal*dy00;
223             tz               = fscal*dz00;
224
225             /* Update vectorial force */
226             fix0            += tx;
227             fiy0            += ty;
228             fiz0            += tz;
229             f[j_coord_offset+DIM*0+XX] -= tx;
230             f[j_coord_offset+DIM*0+YY] -= ty;
231             f[j_coord_offset+DIM*0+ZZ] -= tz;
232
233             /**************************
234              * CALCULATE INTERACTIONS *
235              **************************/
236
237             qq10             = iq1*jq0;
238
239             /* REACTION-FIELD ELECTROSTATICS */
240             velec            = qq10*(rinv10+krf*rsq10-crf);
241             felec            = qq10*(rinv10*rinvsq10-krf2);
242
243             /* Update potential sums from outer loop */
244             velecsum        += velec;
245
246             fscal            = felec;
247
248             /* Calculate temporary vectorial force */
249             tx               = fscal*dx10;
250             ty               = fscal*dy10;
251             tz               = fscal*dz10;
252
253             /* Update vectorial force */
254             fix1            += tx;
255             fiy1            += ty;
256             fiz1            += tz;
257             f[j_coord_offset+DIM*0+XX] -= tx;
258             f[j_coord_offset+DIM*0+YY] -= ty;
259             f[j_coord_offset+DIM*0+ZZ] -= tz;
260
261             /**************************
262              * CALCULATE INTERACTIONS *
263              **************************/
264
265             qq20             = iq2*jq0;
266
267             /* REACTION-FIELD ELECTROSTATICS */
268             velec            = qq20*(rinv20+krf*rsq20-crf);
269             felec            = qq20*(rinv20*rinvsq20-krf2);
270
271             /* Update potential sums from outer loop */
272             velecsum        += velec;
273
274             fscal            = felec;
275
276             /* Calculate temporary vectorial force */
277             tx               = fscal*dx20;
278             ty               = fscal*dy20;
279             tz               = fscal*dz20;
280
281             /* Update vectorial force */
282             fix2            += tx;
283             fiy2            += ty;
284             fiz2            += tz;
285             f[j_coord_offset+DIM*0+XX] -= tx;
286             f[j_coord_offset+DIM*0+YY] -= ty;
287             f[j_coord_offset+DIM*0+ZZ] -= tz;
288
289             /**************************
290              * CALCULATE INTERACTIONS *
291              **************************/
292
293             qq30             = iq3*jq0;
294
295             /* REACTION-FIELD ELECTROSTATICS */
296             velec            = qq30*(rinv30+krf*rsq30-crf);
297             felec            = qq30*(rinv30*rinvsq30-krf2);
298
299             /* Update potential sums from outer loop */
300             velecsum        += velec;
301
302             fscal            = felec;
303
304             /* Calculate temporary vectorial force */
305             tx               = fscal*dx30;
306             ty               = fscal*dy30;
307             tz               = fscal*dz30;
308
309             /* Update vectorial force */
310             fix3            += tx;
311             fiy3            += ty;
312             fiz3            += tz;
313             f[j_coord_offset+DIM*0+XX] -= tx;
314             f[j_coord_offset+DIM*0+YY] -= ty;
315             f[j_coord_offset+DIM*0+ZZ] -= tz;
316
317             /* Inner loop uses 128 flops */
318         }
319         /* End of innermost loop */
320
321         tx = ty = tz = 0;
322         f[i_coord_offset+DIM*0+XX] += fix0;
323         f[i_coord_offset+DIM*0+YY] += fiy0;
324         f[i_coord_offset+DIM*0+ZZ] += fiz0;
325         tx                         += fix0;
326         ty                         += fiy0;
327         tz                         += fiz0;
328         f[i_coord_offset+DIM*1+XX] += fix1;
329         f[i_coord_offset+DIM*1+YY] += fiy1;
330         f[i_coord_offset+DIM*1+ZZ] += fiz1;
331         tx                         += fix1;
332         ty                         += fiy1;
333         tz                         += fiz1;
334         f[i_coord_offset+DIM*2+XX] += fix2;
335         f[i_coord_offset+DIM*2+YY] += fiy2;
336         f[i_coord_offset+DIM*2+ZZ] += fiz2;
337         tx                         += fix2;
338         ty                         += fiy2;
339         tz                         += fiz2;
340         f[i_coord_offset+DIM*3+XX] += fix3;
341         f[i_coord_offset+DIM*3+YY] += fiy3;
342         f[i_coord_offset+DIM*3+ZZ] += fiz3;
343         tx                         += fix3;
344         ty                         += fiy3;
345         tz                         += fiz3;
346         fshift[i_shift_offset+XX]  += tx;
347         fshift[i_shift_offset+YY]  += ty;
348         fshift[i_shift_offset+ZZ]  += tz;
349
350         ggid                        = gid[iidx];
351         /* Update potential energies */
352         kernel_data->energygrp_elec[ggid] += velecsum;
353         kernel_data->energygrp_vdw[ggid] += vvdwsum;
354
355         /* Increment number of inner iterations */
356         inneriter                  += j_index_end - j_index_start;
357
358         /* Outer loop uses 41 flops */
359     }
360
361     /* Increment number of outer iterations */
362     outeriter        += nri;
363
364     /* Update outer/inner flops */
365
366     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_VF,outeriter*41 + inneriter*128);
367 }
368 /*
369  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
370  * Electrostatics interaction: ReactionField
371  * VdW interaction:            LennardJones
372  * Geometry:                   Water4-Particle
373  * Calculate force/pot:        Force
374  */
375 void
376 nb_kernel_ElecRF_VdwLJ_GeomW4P1_F_c
377                     (t_nblist * gmx_restrict                nlist,
378                      rvec * gmx_restrict                    xx,
379                      rvec * gmx_restrict                    ff,
380                      t_forcerec * gmx_restrict              fr,
381                      t_mdatoms * gmx_restrict               mdatoms,
382                      nb_kernel_data_t * gmx_restrict        kernel_data,
383                      t_nrnb * gmx_restrict                  nrnb)
384 {
385     int              i_shift_offset,i_coord_offset,j_coord_offset;
386     int              j_index_start,j_index_end;
387     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
388     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
389     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
390     real             *shiftvec,*fshift,*x,*f;
391     int              vdwioffset0;
392     real             ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
393     int              vdwioffset1;
394     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
395     int              vdwioffset2;
396     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
397     int              vdwioffset3;
398     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
399     int              vdwjidx0;
400     real             jx0,jy0,jz0,fjx0,fjy0,fjz0,jq0,isaj0;
401     real             dx00,dy00,dz00,rsq00,rinv00,rinvsq00,r00,qq00,c6_00,c12_00,cexp1_00,cexp2_00;
402     real             dx10,dy10,dz10,rsq10,rinv10,rinvsq10,r10,qq10,c6_10,c12_10,cexp1_10,cexp2_10;
403     real             dx20,dy20,dz20,rsq20,rinv20,rinvsq20,r20,qq20,c6_20,c12_20,cexp1_20,cexp2_20;
404     real             dx30,dy30,dz30,rsq30,rinv30,rinvsq30,r30,qq30,c6_30,c12_30,cexp1_30,cexp2_30;
405     real             velec,felec,velecsum,facel,crf,krf,krf2;
406     real             *charge;
407     int              nvdwtype;
408     real             rinvsix,rvdw,vvdw,vvdw6,vvdw12,fvdw,fvdw6,fvdw12,vvdwsum,br,vvdwexp,sh_vdw_invrcut6;
409     int              *vdwtype;
410     real             *vdwparam;
411
412     x                = xx[0];
413     f                = ff[0];
414
415     nri              = nlist->nri;
416     iinr             = nlist->iinr;
417     jindex           = nlist->jindex;
418     jjnr             = nlist->jjnr;
419     shiftidx         = nlist->shift;
420     gid              = nlist->gid;
421     shiftvec         = fr->shift_vec[0];
422     fshift           = fr->fshift[0];
423     facel            = fr->epsfac;
424     charge           = mdatoms->chargeA;
425     krf              = fr->ic->k_rf;
426     krf2             = krf*2.0;
427     crf              = fr->ic->c_rf;
428     nvdwtype         = fr->ntype;
429     vdwparam         = fr->nbfp;
430     vdwtype          = mdatoms->typeA;
431
432     /* Setup water-specific parameters */
433     inr              = nlist->iinr[0];
434     iq1              = facel*charge[inr+1];
435     iq2              = facel*charge[inr+2];
436     iq3              = facel*charge[inr+3];
437     vdwioffset0      = 2*nvdwtype*vdwtype[inr+0];
438
439     outeriter        = 0;
440     inneriter        = 0;
441
442     /* Start outer loop over neighborlists */
443     for(iidx=0; iidx<nri; iidx++)
444     {
445         /* Load shift vector for this list */
446         i_shift_offset   = DIM*shiftidx[iidx];
447         shX              = shiftvec[i_shift_offset+XX];
448         shY              = shiftvec[i_shift_offset+YY];
449         shZ              = shiftvec[i_shift_offset+ZZ];
450
451         /* Load limits for loop over neighbors */
452         j_index_start    = jindex[iidx];
453         j_index_end      = jindex[iidx+1];
454
455         /* Get outer coordinate index */
456         inr              = iinr[iidx];
457         i_coord_offset   = DIM*inr;
458
459         /* Load i particle coords and add shift vector */
460         ix0              = shX + x[i_coord_offset+DIM*0+XX];
461         iy0              = shY + x[i_coord_offset+DIM*0+YY];
462         iz0              = shZ + x[i_coord_offset+DIM*0+ZZ];
463         ix1              = shX + x[i_coord_offset+DIM*1+XX];
464         iy1              = shY + x[i_coord_offset+DIM*1+YY];
465         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
466         ix2              = shX + x[i_coord_offset+DIM*2+XX];
467         iy2              = shY + x[i_coord_offset+DIM*2+YY];
468         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
469         ix3              = shX + x[i_coord_offset+DIM*3+XX];
470         iy3              = shY + x[i_coord_offset+DIM*3+YY];
471         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
472
473         fix0             = 0.0;
474         fiy0             = 0.0;
475         fiz0             = 0.0;
476         fix1             = 0.0;
477         fiy1             = 0.0;
478         fiz1             = 0.0;
479         fix2             = 0.0;
480         fiy2             = 0.0;
481         fiz2             = 0.0;
482         fix3             = 0.0;
483         fiy3             = 0.0;
484         fiz3             = 0.0;
485
486         /* Start inner kernel loop */
487         for(jidx=j_index_start; jidx<j_index_end; jidx++)
488         {
489             /* Get j neighbor index, and coordinate index */
490             jnr              = jjnr[jidx];
491             j_coord_offset   = DIM*jnr;
492
493             /* load j atom coordinates */
494             jx0              = x[j_coord_offset+DIM*0+XX];
495             jy0              = x[j_coord_offset+DIM*0+YY];
496             jz0              = x[j_coord_offset+DIM*0+ZZ];
497
498             /* Calculate displacement vector */
499             dx00             = ix0 - jx0;
500             dy00             = iy0 - jy0;
501             dz00             = iz0 - jz0;
502             dx10             = ix1 - jx0;
503             dy10             = iy1 - jy0;
504             dz10             = iz1 - jz0;
505             dx20             = ix2 - jx0;
506             dy20             = iy2 - jy0;
507             dz20             = iz2 - jz0;
508             dx30             = ix3 - jx0;
509             dy30             = iy3 - jy0;
510             dz30             = iz3 - jz0;
511
512             /* Calculate squared distance and things based on it */
513             rsq00            = dx00*dx00+dy00*dy00+dz00*dz00;
514             rsq10            = dx10*dx10+dy10*dy10+dz10*dz10;
515             rsq20            = dx20*dx20+dy20*dy20+dz20*dz20;
516             rsq30            = dx30*dx30+dy30*dy30+dz30*dz30;
517
518             rinv10           = gmx_invsqrt(rsq10);
519             rinv20           = gmx_invsqrt(rsq20);
520             rinv30           = gmx_invsqrt(rsq30);
521
522             rinvsq00         = 1.0/rsq00;
523             rinvsq10         = rinv10*rinv10;
524             rinvsq20         = rinv20*rinv20;
525             rinvsq30         = rinv30*rinv30;
526
527             /* Load parameters for j particles */
528             jq0              = charge[jnr+0];
529             vdwjidx0         = 2*vdwtype[jnr+0];
530
531             /**************************
532              * CALCULATE INTERACTIONS *
533              **************************/
534
535             c6_00            = vdwparam[vdwioffset0+vdwjidx0];
536             c12_00           = vdwparam[vdwioffset0+vdwjidx0+1];
537
538             /* LENNARD-JONES DISPERSION/REPULSION */
539
540             rinvsix          = rinvsq00*rinvsq00*rinvsq00;
541             fvdw             = (c12_00*rinvsix-c6_00)*rinvsix*rinvsq00;
542
543             fscal            = fvdw;
544
545             /* Calculate temporary vectorial force */
546             tx               = fscal*dx00;
547             ty               = fscal*dy00;
548             tz               = fscal*dz00;
549
550             /* Update vectorial force */
551             fix0            += tx;
552             fiy0            += ty;
553             fiz0            += tz;
554             f[j_coord_offset+DIM*0+XX] -= tx;
555             f[j_coord_offset+DIM*0+YY] -= ty;
556             f[j_coord_offset+DIM*0+ZZ] -= tz;
557
558             /**************************
559              * CALCULATE INTERACTIONS *
560              **************************/
561
562             qq10             = iq1*jq0;
563
564             /* REACTION-FIELD ELECTROSTATICS */
565             felec            = qq10*(rinv10*rinvsq10-krf2);
566
567             fscal            = felec;
568
569             /* Calculate temporary vectorial force */
570             tx               = fscal*dx10;
571             ty               = fscal*dy10;
572             tz               = fscal*dz10;
573
574             /* Update vectorial force */
575             fix1            += tx;
576             fiy1            += ty;
577             fiz1            += tz;
578             f[j_coord_offset+DIM*0+XX] -= tx;
579             f[j_coord_offset+DIM*0+YY] -= ty;
580             f[j_coord_offset+DIM*0+ZZ] -= tz;
581
582             /**************************
583              * CALCULATE INTERACTIONS *
584              **************************/
585
586             qq20             = iq2*jq0;
587
588             /* REACTION-FIELD ELECTROSTATICS */
589             felec            = qq20*(rinv20*rinvsq20-krf2);
590
591             fscal            = felec;
592
593             /* Calculate temporary vectorial force */
594             tx               = fscal*dx20;
595             ty               = fscal*dy20;
596             tz               = fscal*dz20;
597
598             /* Update vectorial force */
599             fix2            += tx;
600             fiy2            += ty;
601             fiz2            += tz;
602             f[j_coord_offset+DIM*0+XX] -= tx;
603             f[j_coord_offset+DIM*0+YY] -= ty;
604             f[j_coord_offset+DIM*0+ZZ] -= tz;
605
606             /**************************
607              * CALCULATE INTERACTIONS *
608              **************************/
609
610             qq30             = iq3*jq0;
611
612             /* REACTION-FIELD ELECTROSTATICS */
613             felec            = qq30*(rinv30*rinvsq30-krf2);
614
615             fscal            = felec;
616
617             /* Calculate temporary vectorial force */
618             tx               = fscal*dx30;
619             ty               = fscal*dy30;
620             tz               = fscal*dz30;
621
622             /* Update vectorial force */
623             fix3            += tx;
624             fiy3            += ty;
625             fiz3            += tz;
626             f[j_coord_offset+DIM*0+XX] -= tx;
627             f[j_coord_offset+DIM*0+YY] -= ty;
628             f[j_coord_offset+DIM*0+ZZ] -= tz;
629
630             /* Inner loop uses 108 flops */
631         }
632         /* End of innermost loop */
633
634         tx = ty = tz = 0;
635         f[i_coord_offset+DIM*0+XX] += fix0;
636         f[i_coord_offset+DIM*0+YY] += fiy0;
637         f[i_coord_offset+DIM*0+ZZ] += fiz0;
638         tx                         += fix0;
639         ty                         += fiy0;
640         tz                         += fiz0;
641         f[i_coord_offset+DIM*1+XX] += fix1;
642         f[i_coord_offset+DIM*1+YY] += fiy1;
643         f[i_coord_offset+DIM*1+ZZ] += fiz1;
644         tx                         += fix1;
645         ty                         += fiy1;
646         tz                         += fiz1;
647         f[i_coord_offset+DIM*2+XX] += fix2;
648         f[i_coord_offset+DIM*2+YY] += fiy2;
649         f[i_coord_offset+DIM*2+ZZ] += fiz2;
650         tx                         += fix2;
651         ty                         += fiy2;
652         tz                         += fiz2;
653         f[i_coord_offset+DIM*3+XX] += fix3;
654         f[i_coord_offset+DIM*3+YY] += fiy3;
655         f[i_coord_offset+DIM*3+ZZ] += fiz3;
656         tx                         += fix3;
657         ty                         += fiy3;
658         tz                         += fiz3;
659         fshift[i_shift_offset+XX]  += tx;
660         fshift[i_shift_offset+YY]  += ty;
661         fshift[i_shift_offset+ZZ]  += tz;
662
663         /* Increment number of inner iterations */
664         inneriter                  += j_index_end - j_index_start;
665
666         /* Outer loop uses 39 flops */
667     }
668
669     /* Increment number of outer iterations */
670     outeriter        += nri;
671
672     /* Update outer/inner flops */
673
674     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4_F,outeriter*39 + inneriter*108);
675 }