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