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