d04e2ecbe1905659eba88df8f48761b6990deed1
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_c / nb_kernel_ElecCSTab_VdwNone_GeomW4W4_c.c
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
5  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6  * and including many others, as listed in the AUTHORS file in the
7  * top-level source directory and at http://www.gromacs.org.
8  *
9  * GROMACS is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1
12  * of the License, or (at your option) any later version.
13  *
14  * GROMACS is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with GROMACS; if not, see
21  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23  *
24  * If you want to redistribute modifications to GROMACS, please
25  * consider that scientific software is very special. Version
26  * control is crucial - bugs must be traceable. We will be happy to
27  * consider code for inclusion in the official distribution, but
28  * derived work must not be called official GROMACS. Details are found
29  * in the README & COPYING files - if they are missing, get the
30  * official version at http://www.gromacs.org.
31  *
32  * To help us fund GROMACS development, we humbly ask that you cite
33  * the research papers on the package. Check out http://www.gromacs.org.
34  */
35 /*
36  * Note: this file was generated by the GROMACS c kernel generator.
37  */
38 #include "config.h"
39
40 #include <math.h>
41
42 #include "../nb_kernel.h"
43 #include "gromacs/legacyheaders/types/simple.h"
44 #include "gromacs/math/vec.h"
45 #include "gromacs/legacyheaders/nrnb.h"
46
47 /*
48  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomW4W4_VF_c
49  * Electrostatics interaction: CubicSplineTable
50  * VdW interaction:            None
51  * Geometry:                   Water4-Water4
52  * Calculate force/pot:        PotentialAndForce
53  */
54 void
55 nb_kernel_ElecCSTab_VdwNone_GeomW4W4_VF_c
56                     (t_nblist                    * gmx_restrict       nlist,
57                      rvec                        * gmx_restrict          xx,
58                      rvec                        * gmx_restrict          ff,
59                      t_forcerec                  * gmx_restrict          fr,
60                      t_mdatoms                   * gmx_restrict     mdatoms,
61                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
62                      t_nrnb                      * gmx_restrict        nrnb)
63 {
64     int              i_shift_offset,i_coord_offset,j_coord_offset;
65     int              j_index_start,j_index_end;
66     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
67     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
68     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
69     real             *shiftvec,*fshift,*x,*f;
70     int              vdwioffset1;
71     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
72     int              vdwioffset2;
73     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
74     int              vdwioffset3;
75     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
76     int              vdwjidx1;
77     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
78     int              vdwjidx2;
79     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
80     int              vdwjidx3;
81     real             jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
82     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
83     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
84     real             dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
85     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
86     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
87     real             dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
88     real             dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
89     real             dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
90     real             dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
91     real             velec,felec,velecsum,facel,crf,krf,krf2;
92     real             *charge;
93     int              vfitab;
94     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
95     real             *vftab;
96
97     x                = xx[0];
98     f                = ff[0];
99
100     nri              = nlist->nri;
101     iinr             = nlist->iinr;
102     jindex           = nlist->jindex;
103     jjnr             = nlist->jjnr;
104     shiftidx         = nlist->shift;
105     gid              = nlist->gid;
106     shiftvec         = fr->shift_vec[0];
107     fshift           = fr->fshift[0];
108     facel            = fr->epsfac;
109     charge           = mdatoms->chargeA;
110
111     vftab            = kernel_data->table_elec->data;
112     vftabscale       = kernel_data->table_elec->scale;
113
114     /* Setup water-specific parameters */
115     inr              = nlist->iinr[0];
116     iq1              = facel*charge[inr+1];
117     iq2              = facel*charge[inr+2];
118     iq3              = facel*charge[inr+3];
119
120     jq1              = charge[inr+1];
121     jq2              = charge[inr+2];
122     jq3              = charge[inr+3];
123     qq11             = iq1*jq1;
124     qq12             = iq1*jq2;
125     qq13             = iq1*jq3;
126     qq21             = iq2*jq1;
127     qq22             = iq2*jq2;
128     qq23             = iq2*jq3;
129     qq31             = iq3*jq1;
130     qq32             = iq3*jq2;
131     qq33             = iq3*jq3;
132
133     outeriter        = 0;
134     inneriter        = 0;
135
136     /* Start outer loop over neighborlists */
137     for(iidx=0; iidx<nri; iidx++)
138     {
139         /* Load shift vector for this list */
140         i_shift_offset   = DIM*shiftidx[iidx];
141         shX              = shiftvec[i_shift_offset+XX];
142         shY              = shiftvec[i_shift_offset+YY];
143         shZ              = shiftvec[i_shift_offset+ZZ];
144
145         /* Load limits for loop over neighbors */
146         j_index_start    = jindex[iidx];
147         j_index_end      = jindex[iidx+1];
148
149         /* Get outer coordinate index */
150         inr              = iinr[iidx];
151         i_coord_offset   = DIM*inr;
152
153         /* Load i particle coords and add shift vector */
154         ix1              = shX + x[i_coord_offset+DIM*1+XX];
155         iy1              = shY + x[i_coord_offset+DIM*1+YY];
156         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
157         ix2              = shX + x[i_coord_offset+DIM*2+XX];
158         iy2              = shY + x[i_coord_offset+DIM*2+YY];
159         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
160         ix3              = shX + x[i_coord_offset+DIM*3+XX];
161         iy3              = shY + x[i_coord_offset+DIM*3+YY];
162         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
163
164         fix1             = 0.0;
165         fiy1             = 0.0;
166         fiz1             = 0.0;
167         fix2             = 0.0;
168         fiy2             = 0.0;
169         fiz2             = 0.0;
170         fix3             = 0.0;
171         fiy3             = 0.0;
172         fiz3             = 0.0;
173
174         /* Reset potential sums */
175         velecsum         = 0.0;
176
177         /* Start inner kernel loop */
178         for(jidx=j_index_start; jidx<j_index_end; jidx++)
179         {
180             /* Get j neighbor index, and coordinate index */
181             jnr              = jjnr[jidx];
182             j_coord_offset   = DIM*jnr;
183
184             /* load j atom coordinates */
185             jx1              = x[j_coord_offset+DIM*1+XX];
186             jy1              = x[j_coord_offset+DIM*1+YY];
187             jz1              = x[j_coord_offset+DIM*1+ZZ];
188             jx2              = x[j_coord_offset+DIM*2+XX];
189             jy2              = x[j_coord_offset+DIM*2+YY];
190             jz2              = x[j_coord_offset+DIM*2+ZZ];
191             jx3              = x[j_coord_offset+DIM*3+XX];
192             jy3              = x[j_coord_offset+DIM*3+YY];
193             jz3              = x[j_coord_offset+DIM*3+ZZ];
194
195             /* Calculate displacement vector */
196             dx11             = ix1 - jx1;
197             dy11             = iy1 - jy1;
198             dz11             = iz1 - jz1;
199             dx12             = ix1 - jx2;
200             dy12             = iy1 - jy2;
201             dz12             = iz1 - jz2;
202             dx13             = ix1 - jx3;
203             dy13             = iy1 - jy3;
204             dz13             = iz1 - jz3;
205             dx21             = ix2 - jx1;
206             dy21             = iy2 - jy1;
207             dz21             = iz2 - jz1;
208             dx22             = ix2 - jx2;
209             dy22             = iy2 - jy2;
210             dz22             = iz2 - jz2;
211             dx23             = ix2 - jx3;
212             dy23             = iy2 - jy3;
213             dz23             = iz2 - jz3;
214             dx31             = ix3 - jx1;
215             dy31             = iy3 - jy1;
216             dz31             = iz3 - jz1;
217             dx32             = ix3 - jx2;
218             dy32             = iy3 - jy2;
219             dz32             = iz3 - jz2;
220             dx33             = ix3 - jx3;
221             dy33             = iy3 - jy3;
222             dz33             = iz3 - jz3;
223
224             /* Calculate squared distance and things based on it */
225             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
226             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
227             rsq13            = dx13*dx13+dy13*dy13+dz13*dz13;
228             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
229             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
230             rsq23            = dx23*dx23+dy23*dy23+dz23*dz23;
231             rsq31            = dx31*dx31+dy31*dy31+dz31*dz31;
232             rsq32            = dx32*dx32+dy32*dy32+dz32*dz32;
233             rsq33            = dx33*dx33+dy33*dy33+dz33*dz33;
234
235             rinv11           = gmx_invsqrt(rsq11);
236             rinv12           = gmx_invsqrt(rsq12);
237             rinv13           = gmx_invsqrt(rsq13);
238             rinv21           = gmx_invsqrt(rsq21);
239             rinv22           = gmx_invsqrt(rsq22);
240             rinv23           = gmx_invsqrt(rsq23);
241             rinv31           = gmx_invsqrt(rsq31);
242             rinv32           = gmx_invsqrt(rsq32);
243             rinv33           = gmx_invsqrt(rsq33);
244
245             /**************************
246              * CALCULATE INTERACTIONS *
247              **************************/
248
249             r11              = rsq11*rinv11;
250
251             /* Calculate table index by multiplying r with table scale and truncate to integer */
252             rt               = r11*vftabscale;
253             vfitab           = rt;
254             vfeps            = rt-vfitab;
255             vfitab           = 1*4*vfitab;
256
257             /* CUBIC SPLINE TABLE ELECTROSTATICS */
258             Y                = vftab[vfitab];
259             F                = vftab[vfitab+1];
260             Geps             = vfeps*vftab[vfitab+2];
261             Heps2            = vfeps*vfeps*vftab[vfitab+3];
262             Fp               = F+Geps+Heps2;
263             VV               = Y+vfeps*Fp;
264             velec            = qq11*VV;
265             FF               = Fp+Geps+2.0*Heps2;
266             felec            = -qq11*FF*vftabscale*rinv11;
267
268             /* Update potential sums from outer loop */
269             velecsum        += velec;
270
271             fscal            = felec;
272
273             /* Calculate temporary vectorial force */
274             tx               = fscal*dx11;
275             ty               = fscal*dy11;
276             tz               = fscal*dz11;
277
278             /* Update vectorial force */
279             fix1            += tx;
280             fiy1            += ty;
281             fiz1            += tz;
282             f[j_coord_offset+DIM*1+XX] -= tx;
283             f[j_coord_offset+DIM*1+YY] -= ty;
284             f[j_coord_offset+DIM*1+ZZ] -= tz;
285
286             /**************************
287              * CALCULATE INTERACTIONS *
288              **************************/
289
290             r12              = rsq12*rinv12;
291
292             /* Calculate table index by multiplying r with table scale and truncate to integer */
293             rt               = r12*vftabscale;
294             vfitab           = rt;
295             vfeps            = rt-vfitab;
296             vfitab           = 1*4*vfitab;
297
298             /* CUBIC SPLINE TABLE ELECTROSTATICS */
299             Y                = vftab[vfitab];
300             F                = vftab[vfitab+1];
301             Geps             = vfeps*vftab[vfitab+2];
302             Heps2            = vfeps*vfeps*vftab[vfitab+3];
303             Fp               = F+Geps+Heps2;
304             VV               = Y+vfeps*Fp;
305             velec            = qq12*VV;
306             FF               = Fp+Geps+2.0*Heps2;
307             felec            = -qq12*FF*vftabscale*rinv12;
308
309             /* Update potential sums from outer loop */
310             velecsum        += velec;
311
312             fscal            = felec;
313
314             /* Calculate temporary vectorial force */
315             tx               = fscal*dx12;
316             ty               = fscal*dy12;
317             tz               = fscal*dz12;
318
319             /* Update vectorial force */
320             fix1            += tx;
321             fiy1            += ty;
322             fiz1            += tz;
323             f[j_coord_offset+DIM*2+XX] -= tx;
324             f[j_coord_offset+DIM*2+YY] -= ty;
325             f[j_coord_offset+DIM*2+ZZ] -= tz;
326
327             /**************************
328              * CALCULATE INTERACTIONS *
329              **************************/
330
331             r13              = rsq13*rinv13;
332
333             /* Calculate table index by multiplying r with table scale and truncate to integer */
334             rt               = r13*vftabscale;
335             vfitab           = rt;
336             vfeps            = rt-vfitab;
337             vfitab           = 1*4*vfitab;
338
339             /* CUBIC SPLINE TABLE ELECTROSTATICS */
340             Y                = vftab[vfitab];
341             F                = vftab[vfitab+1];
342             Geps             = vfeps*vftab[vfitab+2];
343             Heps2            = vfeps*vfeps*vftab[vfitab+3];
344             Fp               = F+Geps+Heps2;
345             VV               = Y+vfeps*Fp;
346             velec            = qq13*VV;
347             FF               = Fp+Geps+2.0*Heps2;
348             felec            = -qq13*FF*vftabscale*rinv13;
349
350             /* Update potential sums from outer loop */
351             velecsum        += velec;
352
353             fscal            = felec;
354
355             /* Calculate temporary vectorial force */
356             tx               = fscal*dx13;
357             ty               = fscal*dy13;
358             tz               = fscal*dz13;
359
360             /* Update vectorial force */
361             fix1            += tx;
362             fiy1            += ty;
363             fiz1            += tz;
364             f[j_coord_offset+DIM*3+XX] -= tx;
365             f[j_coord_offset+DIM*3+YY] -= ty;
366             f[j_coord_offset+DIM*3+ZZ] -= tz;
367
368             /**************************
369              * CALCULATE INTERACTIONS *
370              **************************/
371
372             r21              = rsq21*rinv21;
373
374             /* Calculate table index by multiplying r with table scale and truncate to integer */
375             rt               = r21*vftabscale;
376             vfitab           = rt;
377             vfeps            = rt-vfitab;
378             vfitab           = 1*4*vfitab;
379
380             /* CUBIC SPLINE TABLE ELECTROSTATICS */
381             Y                = vftab[vfitab];
382             F                = vftab[vfitab+1];
383             Geps             = vfeps*vftab[vfitab+2];
384             Heps2            = vfeps*vfeps*vftab[vfitab+3];
385             Fp               = F+Geps+Heps2;
386             VV               = Y+vfeps*Fp;
387             velec            = qq21*VV;
388             FF               = Fp+Geps+2.0*Heps2;
389             felec            = -qq21*FF*vftabscale*rinv21;
390
391             /* Update potential sums from outer loop */
392             velecsum        += velec;
393
394             fscal            = felec;
395
396             /* Calculate temporary vectorial force */
397             tx               = fscal*dx21;
398             ty               = fscal*dy21;
399             tz               = fscal*dz21;
400
401             /* Update vectorial force */
402             fix2            += tx;
403             fiy2            += ty;
404             fiz2            += tz;
405             f[j_coord_offset+DIM*1+XX] -= tx;
406             f[j_coord_offset+DIM*1+YY] -= ty;
407             f[j_coord_offset+DIM*1+ZZ] -= tz;
408
409             /**************************
410              * CALCULATE INTERACTIONS *
411              **************************/
412
413             r22              = rsq22*rinv22;
414
415             /* Calculate table index by multiplying r with table scale and truncate to integer */
416             rt               = r22*vftabscale;
417             vfitab           = rt;
418             vfeps            = rt-vfitab;
419             vfitab           = 1*4*vfitab;
420
421             /* CUBIC SPLINE TABLE ELECTROSTATICS */
422             Y                = vftab[vfitab];
423             F                = vftab[vfitab+1];
424             Geps             = vfeps*vftab[vfitab+2];
425             Heps2            = vfeps*vfeps*vftab[vfitab+3];
426             Fp               = F+Geps+Heps2;
427             VV               = Y+vfeps*Fp;
428             velec            = qq22*VV;
429             FF               = Fp+Geps+2.0*Heps2;
430             felec            = -qq22*FF*vftabscale*rinv22;
431
432             /* Update potential sums from outer loop */
433             velecsum        += velec;
434
435             fscal            = felec;
436
437             /* Calculate temporary vectorial force */
438             tx               = fscal*dx22;
439             ty               = fscal*dy22;
440             tz               = fscal*dz22;
441
442             /* Update vectorial force */
443             fix2            += tx;
444             fiy2            += ty;
445             fiz2            += tz;
446             f[j_coord_offset+DIM*2+XX] -= tx;
447             f[j_coord_offset+DIM*2+YY] -= ty;
448             f[j_coord_offset+DIM*2+ZZ] -= tz;
449
450             /**************************
451              * CALCULATE INTERACTIONS *
452              **************************/
453
454             r23              = rsq23*rinv23;
455
456             /* Calculate table index by multiplying r with table scale and truncate to integer */
457             rt               = r23*vftabscale;
458             vfitab           = rt;
459             vfeps            = rt-vfitab;
460             vfitab           = 1*4*vfitab;
461
462             /* CUBIC SPLINE TABLE ELECTROSTATICS */
463             Y                = vftab[vfitab];
464             F                = vftab[vfitab+1];
465             Geps             = vfeps*vftab[vfitab+2];
466             Heps2            = vfeps*vfeps*vftab[vfitab+3];
467             Fp               = F+Geps+Heps2;
468             VV               = Y+vfeps*Fp;
469             velec            = qq23*VV;
470             FF               = Fp+Geps+2.0*Heps2;
471             felec            = -qq23*FF*vftabscale*rinv23;
472
473             /* Update potential sums from outer loop */
474             velecsum        += velec;
475
476             fscal            = felec;
477
478             /* Calculate temporary vectorial force */
479             tx               = fscal*dx23;
480             ty               = fscal*dy23;
481             tz               = fscal*dz23;
482
483             /* Update vectorial force */
484             fix2            += tx;
485             fiy2            += ty;
486             fiz2            += tz;
487             f[j_coord_offset+DIM*3+XX] -= tx;
488             f[j_coord_offset+DIM*3+YY] -= ty;
489             f[j_coord_offset+DIM*3+ZZ] -= tz;
490
491             /**************************
492              * CALCULATE INTERACTIONS *
493              **************************/
494
495             r31              = rsq31*rinv31;
496
497             /* Calculate table index by multiplying r with table scale and truncate to integer */
498             rt               = r31*vftabscale;
499             vfitab           = rt;
500             vfeps            = rt-vfitab;
501             vfitab           = 1*4*vfitab;
502
503             /* CUBIC SPLINE TABLE ELECTROSTATICS */
504             Y                = vftab[vfitab];
505             F                = vftab[vfitab+1];
506             Geps             = vfeps*vftab[vfitab+2];
507             Heps2            = vfeps*vfeps*vftab[vfitab+3];
508             Fp               = F+Geps+Heps2;
509             VV               = Y+vfeps*Fp;
510             velec            = qq31*VV;
511             FF               = Fp+Geps+2.0*Heps2;
512             felec            = -qq31*FF*vftabscale*rinv31;
513
514             /* Update potential sums from outer loop */
515             velecsum        += velec;
516
517             fscal            = felec;
518
519             /* Calculate temporary vectorial force */
520             tx               = fscal*dx31;
521             ty               = fscal*dy31;
522             tz               = fscal*dz31;
523
524             /* Update vectorial force */
525             fix3            += tx;
526             fiy3            += ty;
527             fiz3            += tz;
528             f[j_coord_offset+DIM*1+XX] -= tx;
529             f[j_coord_offset+DIM*1+YY] -= ty;
530             f[j_coord_offset+DIM*1+ZZ] -= tz;
531
532             /**************************
533              * CALCULATE INTERACTIONS *
534              **************************/
535
536             r32              = rsq32*rinv32;
537
538             /* Calculate table index by multiplying r with table scale and truncate to integer */
539             rt               = r32*vftabscale;
540             vfitab           = rt;
541             vfeps            = rt-vfitab;
542             vfitab           = 1*4*vfitab;
543
544             /* CUBIC SPLINE TABLE ELECTROSTATICS */
545             Y                = vftab[vfitab];
546             F                = vftab[vfitab+1];
547             Geps             = vfeps*vftab[vfitab+2];
548             Heps2            = vfeps*vfeps*vftab[vfitab+3];
549             Fp               = F+Geps+Heps2;
550             VV               = Y+vfeps*Fp;
551             velec            = qq32*VV;
552             FF               = Fp+Geps+2.0*Heps2;
553             felec            = -qq32*FF*vftabscale*rinv32;
554
555             /* Update potential sums from outer loop */
556             velecsum        += velec;
557
558             fscal            = felec;
559
560             /* Calculate temporary vectorial force */
561             tx               = fscal*dx32;
562             ty               = fscal*dy32;
563             tz               = fscal*dz32;
564
565             /* Update vectorial force */
566             fix3            += tx;
567             fiy3            += ty;
568             fiz3            += tz;
569             f[j_coord_offset+DIM*2+XX] -= tx;
570             f[j_coord_offset+DIM*2+YY] -= ty;
571             f[j_coord_offset+DIM*2+ZZ] -= tz;
572
573             /**************************
574              * CALCULATE INTERACTIONS *
575              **************************/
576
577             r33              = rsq33*rinv33;
578
579             /* Calculate table index by multiplying r with table scale and truncate to integer */
580             rt               = r33*vftabscale;
581             vfitab           = rt;
582             vfeps            = rt-vfitab;
583             vfitab           = 1*4*vfitab;
584
585             /* CUBIC SPLINE TABLE ELECTROSTATICS */
586             Y                = vftab[vfitab];
587             F                = vftab[vfitab+1];
588             Geps             = vfeps*vftab[vfitab+2];
589             Heps2            = vfeps*vfeps*vftab[vfitab+3];
590             Fp               = F+Geps+Heps2;
591             VV               = Y+vfeps*Fp;
592             velec            = qq33*VV;
593             FF               = Fp+Geps+2.0*Heps2;
594             felec            = -qq33*FF*vftabscale*rinv33;
595
596             /* Update potential sums from outer loop */
597             velecsum        += velec;
598
599             fscal            = felec;
600
601             /* Calculate temporary vectorial force */
602             tx               = fscal*dx33;
603             ty               = fscal*dy33;
604             tz               = fscal*dz33;
605
606             /* Update vectorial force */
607             fix3            += tx;
608             fiy3            += ty;
609             fiz3            += tz;
610             f[j_coord_offset+DIM*3+XX] -= tx;
611             f[j_coord_offset+DIM*3+YY] -= ty;
612             f[j_coord_offset+DIM*3+ZZ] -= tz;
613
614             /* Inner loop uses 369 flops */
615         }
616         /* End of innermost loop */
617
618         tx = ty = tz = 0;
619         f[i_coord_offset+DIM*1+XX] += fix1;
620         f[i_coord_offset+DIM*1+YY] += fiy1;
621         f[i_coord_offset+DIM*1+ZZ] += fiz1;
622         tx                         += fix1;
623         ty                         += fiy1;
624         tz                         += fiz1;
625         f[i_coord_offset+DIM*2+XX] += fix2;
626         f[i_coord_offset+DIM*2+YY] += fiy2;
627         f[i_coord_offset+DIM*2+ZZ] += fiz2;
628         tx                         += fix2;
629         ty                         += fiy2;
630         tz                         += fiz2;
631         f[i_coord_offset+DIM*3+XX] += fix3;
632         f[i_coord_offset+DIM*3+YY] += fiy3;
633         f[i_coord_offset+DIM*3+ZZ] += fiz3;
634         tx                         += fix3;
635         ty                         += fiy3;
636         tz                         += fiz3;
637         fshift[i_shift_offset+XX]  += tx;
638         fshift[i_shift_offset+YY]  += ty;
639         fshift[i_shift_offset+ZZ]  += tz;
640
641         ggid                        = gid[iidx];
642         /* Update potential energies */
643         kernel_data->energygrp_elec[ggid] += velecsum;
644
645         /* Increment number of inner iterations */
646         inneriter                  += j_index_end - j_index_start;
647
648         /* Outer loop uses 31 flops */
649     }
650
651     /* Increment number of outer iterations */
652     outeriter        += nri;
653
654     /* Update outer/inner flops */
655
656     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_VF,outeriter*31 + inneriter*369);
657 }
658 /*
659  * Gromacs nonbonded kernel:   nb_kernel_ElecCSTab_VdwNone_GeomW4W4_F_c
660  * Electrostatics interaction: CubicSplineTable
661  * VdW interaction:            None
662  * Geometry:                   Water4-Water4
663  * Calculate force/pot:        Force
664  */
665 void
666 nb_kernel_ElecCSTab_VdwNone_GeomW4W4_F_c
667                     (t_nblist                    * gmx_restrict       nlist,
668                      rvec                        * gmx_restrict          xx,
669                      rvec                        * gmx_restrict          ff,
670                      t_forcerec                  * gmx_restrict          fr,
671                      t_mdatoms                   * gmx_restrict     mdatoms,
672                      nb_kernel_data_t gmx_unused * gmx_restrict kernel_data,
673                      t_nrnb                      * gmx_restrict        nrnb)
674 {
675     int              i_shift_offset,i_coord_offset,j_coord_offset;
676     int              j_index_start,j_index_end;
677     int              nri,inr,ggid,iidx,jidx,jnr,outeriter,inneriter;
678     real             shX,shY,shZ,tx,ty,tz,fscal,rcutoff,rcutoff2;
679     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
680     real             *shiftvec,*fshift,*x,*f;
681     int              vdwioffset1;
682     real             ix1,iy1,iz1,fix1,fiy1,fiz1,iq1,isai1;
683     int              vdwioffset2;
684     real             ix2,iy2,iz2,fix2,fiy2,fiz2,iq2,isai2;
685     int              vdwioffset3;
686     real             ix3,iy3,iz3,fix3,fiy3,fiz3,iq3,isai3;
687     int              vdwjidx1;
688     real             jx1,jy1,jz1,fjx1,fjy1,fjz1,jq1,isaj1;
689     int              vdwjidx2;
690     real             jx2,jy2,jz2,fjx2,fjy2,fjz2,jq2,isaj2;
691     int              vdwjidx3;
692     real             jx3,jy3,jz3,fjx3,fjy3,fjz3,jq3,isaj3;
693     real             dx11,dy11,dz11,rsq11,rinv11,rinvsq11,r11,qq11,c6_11,c12_11,cexp1_11,cexp2_11;
694     real             dx12,dy12,dz12,rsq12,rinv12,rinvsq12,r12,qq12,c6_12,c12_12,cexp1_12,cexp2_12;
695     real             dx13,dy13,dz13,rsq13,rinv13,rinvsq13,r13,qq13,c6_13,c12_13,cexp1_13,cexp2_13;
696     real             dx21,dy21,dz21,rsq21,rinv21,rinvsq21,r21,qq21,c6_21,c12_21,cexp1_21,cexp2_21;
697     real             dx22,dy22,dz22,rsq22,rinv22,rinvsq22,r22,qq22,c6_22,c12_22,cexp1_22,cexp2_22;
698     real             dx23,dy23,dz23,rsq23,rinv23,rinvsq23,r23,qq23,c6_23,c12_23,cexp1_23,cexp2_23;
699     real             dx31,dy31,dz31,rsq31,rinv31,rinvsq31,r31,qq31,c6_31,c12_31,cexp1_31,cexp2_31;
700     real             dx32,dy32,dz32,rsq32,rinv32,rinvsq32,r32,qq32,c6_32,c12_32,cexp1_32,cexp2_32;
701     real             dx33,dy33,dz33,rsq33,rinv33,rinvsq33,r33,qq33,c6_33,c12_33,cexp1_33,cexp2_33;
702     real             velec,felec,velecsum,facel,crf,krf,krf2;
703     real             *charge;
704     int              vfitab;
705     real             rt,vfeps,vftabscale,Y,F,Geps,Heps2,Fp,VV,FF;
706     real             *vftab;
707
708     x                = xx[0];
709     f                = ff[0];
710
711     nri              = nlist->nri;
712     iinr             = nlist->iinr;
713     jindex           = nlist->jindex;
714     jjnr             = nlist->jjnr;
715     shiftidx         = nlist->shift;
716     gid              = nlist->gid;
717     shiftvec         = fr->shift_vec[0];
718     fshift           = fr->fshift[0];
719     facel            = fr->epsfac;
720     charge           = mdatoms->chargeA;
721
722     vftab            = kernel_data->table_elec->data;
723     vftabscale       = kernel_data->table_elec->scale;
724
725     /* Setup water-specific parameters */
726     inr              = nlist->iinr[0];
727     iq1              = facel*charge[inr+1];
728     iq2              = facel*charge[inr+2];
729     iq3              = facel*charge[inr+3];
730
731     jq1              = charge[inr+1];
732     jq2              = charge[inr+2];
733     jq3              = charge[inr+3];
734     qq11             = iq1*jq1;
735     qq12             = iq1*jq2;
736     qq13             = iq1*jq3;
737     qq21             = iq2*jq1;
738     qq22             = iq2*jq2;
739     qq23             = iq2*jq3;
740     qq31             = iq3*jq1;
741     qq32             = iq3*jq2;
742     qq33             = iq3*jq3;
743
744     outeriter        = 0;
745     inneriter        = 0;
746
747     /* Start outer loop over neighborlists */
748     for(iidx=0; iidx<nri; iidx++)
749     {
750         /* Load shift vector for this list */
751         i_shift_offset   = DIM*shiftidx[iidx];
752         shX              = shiftvec[i_shift_offset+XX];
753         shY              = shiftvec[i_shift_offset+YY];
754         shZ              = shiftvec[i_shift_offset+ZZ];
755
756         /* Load limits for loop over neighbors */
757         j_index_start    = jindex[iidx];
758         j_index_end      = jindex[iidx+1];
759
760         /* Get outer coordinate index */
761         inr              = iinr[iidx];
762         i_coord_offset   = DIM*inr;
763
764         /* Load i particle coords and add shift vector */
765         ix1              = shX + x[i_coord_offset+DIM*1+XX];
766         iy1              = shY + x[i_coord_offset+DIM*1+YY];
767         iz1              = shZ + x[i_coord_offset+DIM*1+ZZ];
768         ix2              = shX + x[i_coord_offset+DIM*2+XX];
769         iy2              = shY + x[i_coord_offset+DIM*2+YY];
770         iz2              = shZ + x[i_coord_offset+DIM*2+ZZ];
771         ix3              = shX + x[i_coord_offset+DIM*3+XX];
772         iy3              = shY + x[i_coord_offset+DIM*3+YY];
773         iz3              = shZ + x[i_coord_offset+DIM*3+ZZ];
774
775         fix1             = 0.0;
776         fiy1             = 0.0;
777         fiz1             = 0.0;
778         fix2             = 0.0;
779         fiy2             = 0.0;
780         fiz2             = 0.0;
781         fix3             = 0.0;
782         fiy3             = 0.0;
783         fiz3             = 0.0;
784
785         /* Start inner kernel loop */
786         for(jidx=j_index_start; jidx<j_index_end; jidx++)
787         {
788             /* Get j neighbor index, and coordinate index */
789             jnr              = jjnr[jidx];
790             j_coord_offset   = DIM*jnr;
791
792             /* load j atom coordinates */
793             jx1              = x[j_coord_offset+DIM*1+XX];
794             jy1              = x[j_coord_offset+DIM*1+YY];
795             jz1              = x[j_coord_offset+DIM*1+ZZ];
796             jx2              = x[j_coord_offset+DIM*2+XX];
797             jy2              = x[j_coord_offset+DIM*2+YY];
798             jz2              = x[j_coord_offset+DIM*2+ZZ];
799             jx3              = x[j_coord_offset+DIM*3+XX];
800             jy3              = x[j_coord_offset+DIM*3+YY];
801             jz3              = x[j_coord_offset+DIM*3+ZZ];
802
803             /* Calculate displacement vector */
804             dx11             = ix1 - jx1;
805             dy11             = iy1 - jy1;
806             dz11             = iz1 - jz1;
807             dx12             = ix1 - jx2;
808             dy12             = iy1 - jy2;
809             dz12             = iz1 - jz2;
810             dx13             = ix1 - jx3;
811             dy13             = iy1 - jy3;
812             dz13             = iz1 - jz3;
813             dx21             = ix2 - jx1;
814             dy21             = iy2 - jy1;
815             dz21             = iz2 - jz1;
816             dx22             = ix2 - jx2;
817             dy22             = iy2 - jy2;
818             dz22             = iz2 - jz2;
819             dx23             = ix2 - jx3;
820             dy23             = iy2 - jy3;
821             dz23             = iz2 - jz3;
822             dx31             = ix3 - jx1;
823             dy31             = iy3 - jy1;
824             dz31             = iz3 - jz1;
825             dx32             = ix3 - jx2;
826             dy32             = iy3 - jy2;
827             dz32             = iz3 - jz2;
828             dx33             = ix3 - jx3;
829             dy33             = iy3 - jy3;
830             dz33             = iz3 - jz3;
831
832             /* Calculate squared distance and things based on it */
833             rsq11            = dx11*dx11+dy11*dy11+dz11*dz11;
834             rsq12            = dx12*dx12+dy12*dy12+dz12*dz12;
835             rsq13            = dx13*dx13+dy13*dy13+dz13*dz13;
836             rsq21            = dx21*dx21+dy21*dy21+dz21*dz21;
837             rsq22            = dx22*dx22+dy22*dy22+dz22*dz22;
838             rsq23            = dx23*dx23+dy23*dy23+dz23*dz23;
839             rsq31            = dx31*dx31+dy31*dy31+dz31*dz31;
840             rsq32            = dx32*dx32+dy32*dy32+dz32*dz32;
841             rsq33            = dx33*dx33+dy33*dy33+dz33*dz33;
842
843             rinv11           = gmx_invsqrt(rsq11);
844             rinv12           = gmx_invsqrt(rsq12);
845             rinv13           = gmx_invsqrt(rsq13);
846             rinv21           = gmx_invsqrt(rsq21);
847             rinv22           = gmx_invsqrt(rsq22);
848             rinv23           = gmx_invsqrt(rsq23);
849             rinv31           = gmx_invsqrt(rsq31);
850             rinv32           = gmx_invsqrt(rsq32);
851             rinv33           = gmx_invsqrt(rsq33);
852
853             /**************************
854              * CALCULATE INTERACTIONS *
855              **************************/
856
857             r11              = rsq11*rinv11;
858
859             /* Calculate table index by multiplying r with table scale and truncate to integer */
860             rt               = r11*vftabscale;
861             vfitab           = rt;
862             vfeps            = rt-vfitab;
863             vfitab           = 1*4*vfitab;
864
865             /* CUBIC SPLINE TABLE ELECTROSTATICS */
866             F                = vftab[vfitab+1];
867             Geps             = vfeps*vftab[vfitab+2];
868             Heps2            = vfeps*vfeps*vftab[vfitab+3];
869             Fp               = F+Geps+Heps2;
870             FF               = Fp+Geps+2.0*Heps2;
871             felec            = -qq11*FF*vftabscale*rinv11;
872
873             fscal            = felec;
874
875             /* Calculate temporary vectorial force */
876             tx               = fscal*dx11;
877             ty               = fscal*dy11;
878             tz               = fscal*dz11;
879
880             /* Update vectorial force */
881             fix1            += tx;
882             fiy1            += ty;
883             fiz1            += tz;
884             f[j_coord_offset+DIM*1+XX] -= tx;
885             f[j_coord_offset+DIM*1+YY] -= ty;
886             f[j_coord_offset+DIM*1+ZZ] -= tz;
887
888             /**************************
889              * CALCULATE INTERACTIONS *
890              **************************/
891
892             r12              = rsq12*rinv12;
893
894             /* Calculate table index by multiplying r with table scale and truncate to integer */
895             rt               = r12*vftabscale;
896             vfitab           = rt;
897             vfeps            = rt-vfitab;
898             vfitab           = 1*4*vfitab;
899
900             /* CUBIC SPLINE TABLE ELECTROSTATICS */
901             F                = vftab[vfitab+1];
902             Geps             = vfeps*vftab[vfitab+2];
903             Heps2            = vfeps*vfeps*vftab[vfitab+3];
904             Fp               = F+Geps+Heps2;
905             FF               = Fp+Geps+2.0*Heps2;
906             felec            = -qq12*FF*vftabscale*rinv12;
907
908             fscal            = felec;
909
910             /* Calculate temporary vectorial force */
911             tx               = fscal*dx12;
912             ty               = fscal*dy12;
913             tz               = fscal*dz12;
914
915             /* Update vectorial force */
916             fix1            += tx;
917             fiy1            += ty;
918             fiz1            += tz;
919             f[j_coord_offset+DIM*2+XX] -= tx;
920             f[j_coord_offset+DIM*2+YY] -= ty;
921             f[j_coord_offset+DIM*2+ZZ] -= tz;
922
923             /**************************
924              * CALCULATE INTERACTIONS *
925              **************************/
926
927             r13              = rsq13*rinv13;
928
929             /* Calculate table index by multiplying r with table scale and truncate to integer */
930             rt               = r13*vftabscale;
931             vfitab           = rt;
932             vfeps            = rt-vfitab;
933             vfitab           = 1*4*vfitab;
934
935             /* CUBIC SPLINE TABLE ELECTROSTATICS */
936             F                = vftab[vfitab+1];
937             Geps             = vfeps*vftab[vfitab+2];
938             Heps2            = vfeps*vfeps*vftab[vfitab+3];
939             Fp               = F+Geps+Heps2;
940             FF               = Fp+Geps+2.0*Heps2;
941             felec            = -qq13*FF*vftabscale*rinv13;
942
943             fscal            = felec;
944
945             /* Calculate temporary vectorial force */
946             tx               = fscal*dx13;
947             ty               = fscal*dy13;
948             tz               = fscal*dz13;
949
950             /* Update vectorial force */
951             fix1            += tx;
952             fiy1            += ty;
953             fiz1            += tz;
954             f[j_coord_offset+DIM*3+XX] -= tx;
955             f[j_coord_offset+DIM*3+YY] -= ty;
956             f[j_coord_offset+DIM*3+ZZ] -= tz;
957
958             /**************************
959              * CALCULATE INTERACTIONS *
960              **************************/
961
962             r21              = rsq21*rinv21;
963
964             /* Calculate table index by multiplying r with table scale and truncate to integer */
965             rt               = r21*vftabscale;
966             vfitab           = rt;
967             vfeps            = rt-vfitab;
968             vfitab           = 1*4*vfitab;
969
970             /* CUBIC SPLINE TABLE ELECTROSTATICS */
971             F                = vftab[vfitab+1];
972             Geps             = vfeps*vftab[vfitab+2];
973             Heps2            = vfeps*vfeps*vftab[vfitab+3];
974             Fp               = F+Geps+Heps2;
975             FF               = Fp+Geps+2.0*Heps2;
976             felec            = -qq21*FF*vftabscale*rinv21;
977
978             fscal            = felec;
979
980             /* Calculate temporary vectorial force */
981             tx               = fscal*dx21;
982             ty               = fscal*dy21;
983             tz               = fscal*dz21;
984
985             /* Update vectorial force */
986             fix2            += tx;
987             fiy2            += ty;
988             fiz2            += tz;
989             f[j_coord_offset+DIM*1+XX] -= tx;
990             f[j_coord_offset+DIM*1+YY] -= ty;
991             f[j_coord_offset+DIM*1+ZZ] -= tz;
992
993             /**************************
994              * CALCULATE INTERACTIONS *
995              **************************/
996
997             r22              = rsq22*rinv22;
998
999             /* Calculate table index by multiplying r with table scale and truncate to integer */
1000             rt               = r22*vftabscale;
1001             vfitab           = rt;
1002             vfeps            = rt-vfitab;
1003             vfitab           = 1*4*vfitab;
1004
1005             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1006             F                = vftab[vfitab+1];
1007             Geps             = vfeps*vftab[vfitab+2];
1008             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1009             Fp               = F+Geps+Heps2;
1010             FF               = Fp+Geps+2.0*Heps2;
1011             felec            = -qq22*FF*vftabscale*rinv22;
1012
1013             fscal            = felec;
1014
1015             /* Calculate temporary vectorial force */
1016             tx               = fscal*dx22;
1017             ty               = fscal*dy22;
1018             tz               = fscal*dz22;
1019
1020             /* Update vectorial force */
1021             fix2            += tx;
1022             fiy2            += ty;
1023             fiz2            += tz;
1024             f[j_coord_offset+DIM*2+XX] -= tx;
1025             f[j_coord_offset+DIM*2+YY] -= ty;
1026             f[j_coord_offset+DIM*2+ZZ] -= tz;
1027
1028             /**************************
1029              * CALCULATE INTERACTIONS *
1030              **************************/
1031
1032             r23              = rsq23*rinv23;
1033
1034             /* Calculate table index by multiplying r with table scale and truncate to integer */
1035             rt               = r23*vftabscale;
1036             vfitab           = rt;
1037             vfeps            = rt-vfitab;
1038             vfitab           = 1*4*vfitab;
1039
1040             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1041             F                = vftab[vfitab+1];
1042             Geps             = vfeps*vftab[vfitab+2];
1043             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1044             Fp               = F+Geps+Heps2;
1045             FF               = Fp+Geps+2.0*Heps2;
1046             felec            = -qq23*FF*vftabscale*rinv23;
1047
1048             fscal            = felec;
1049
1050             /* Calculate temporary vectorial force */
1051             tx               = fscal*dx23;
1052             ty               = fscal*dy23;
1053             tz               = fscal*dz23;
1054
1055             /* Update vectorial force */
1056             fix2            += tx;
1057             fiy2            += ty;
1058             fiz2            += tz;
1059             f[j_coord_offset+DIM*3+XX] -= tx;
1060             f[j_coord_offset+DIM*3+YY] -= ty;
1061             f[j_coord_offset+DIM*3+ZZ] -= tz;
1062
1063             /**************************
1064              * CALCULATE INTERACTIONS *
1065              **************************/
1066
1067             r31              = rsq31*rinv31;
1068
1069             /* Calculate table index by multiplying r with table scale and truncate to integer */
1070             rt               = r31*vftabscale;
1071             vfitab           = rt;
1072             vfeps            = rt-vfitab;
1073             vfitab           = 1*4*vfitab;
1074
1075             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1076             F                = vftab[vfitab+1];
1077             Geps             = vfeps*vftab[vfitab+2];
1078             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1079             Fp               = F+Geps+Heps2;
1080             FF               = Fp+Geps+2.0*Heps2;
1081             felec            = -qq31*FF*vftabscale*rinv31;
1082
1083             fscal            = felec;
1084
1085             /* Calculate temporary vectorial force */
1086             tx               = fscal*dx31;
1087             ty               = fscal*dy31;
1088             tz               = fscal*dz31;
1089
1090             /* Update vectorial force */
1091             fix3            += tx;
1092             fiy3            += ty;
1093             fiz3            += tz;
1094             f[j_coord_offset+DIM*1+XX] -= tx;
1095             f[j_coord_offset+DIM*1+YY] -= ty;
1096             f[j_coord_offset+DIM*1+ZZ] -= tz;
1097
1098             /**************************
1099              * CALCULATE INTERACTIONS *
1100              **************************/
1101
1102             r32              = rsq32*rinv32;
1103
1104             /* Calculate table index by multiplying r with table scale and truncate to integer */
1105             rt               = r32*vftabscale;
1106             vfitab           = rt;
1107             vfeps            = rt-vfitab;
1108             vfitab           = 1*4*vfitab;
1109
1110             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1111             F                = vftab[vfitab+1];
1112             Geps             = vfeps*vftab[vfitab+2];
1113             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1114             Fp               = F+Geps+Heps2;
1115             FF               = Fp+Geps+2.0*Heps2;
1116             felec            = -qq32*FF*vftabscale*rinv32;
1117
1118             fscal            = felec;
1119
1120             /* Calculate temporary vectorial force */
1121             tx               = fscal*dx32;
1122             ty               = fscal*dy32;
1123             tz               = fscal*dz32;
1124
1125             /* Update vectorial force */
1126             fix3            += tx;
1127             fiy3            += ty;
1128             fiz3            += tz;
1129             f[j_coord_offset+DIM*2+XX] -= tx;
1130             f[j_coord_offset+DIM*2+YY] -= ty;
1131             f[j_coord_offset+DIM*2+ZZ] -= tz;
1132
1133             /**************************
1134              * CALCULATE INTERACTIONS *
1135              **************************/
1136
1137             r33              = rsq33*rinv33;
1138
1139             /* Calculate table index by multiplying r with table scale and truncate to integer */
1140             rt               = r33*vftabscale;
1141             vfitab           = rt;
1142             vfeps            = rt-vfitab;
1143             vfitab           = 1*4*vfitab;
1144
1145             /* CUBIC SPLINE TABLE ELECTROSTATICS */
1146             F                = vftab[vfitab+1];
1147             Geps             = vfeps*vftab[vfitab+2];
1148             Heps2            = vfeps*vfeps*vftab[vfitab+3];
1149             Fp               = F+Geps+Heps2;
1150             FF               = Fp+Geps+2.0*Heps2;
1151             felec            = -qq33*FF*vftabscale*rinv33;
1152
1153             fscal            = felec;
1154
1155             /* Calculate temporary vectorial force */
1156             tx               = fscal*dx33;
1157             ty               = fscal*dy33;
1158             tz               = fscal*dz33;
1159
1160             /* Update vectorial force */
1161             fix3            += tx;
1162             fiy3            += ty;
1163             fiz3            += tz;
1164             f[j_coord_offset+DIM*3+XX] -= tx;
1165             f[j_coord_offset+DIM*3+YY] -= ty;
1166             f[j_coord_offset+DIM*3+ZZ] -= tz;
1167
1168             /* Inner loop uses 333 flops */
1169         }
1170         /* End of innermost loop */
1171
1172         tx = ty = tz = 0;
1173         f[i_coord_offset+DIM*1+XX] += fix1;
1174         f[i_coord_offset+DIM*1+YY] += fiy1;
1175         f[i_coord_offset+DIM*1+ZZ] += fiz1;
1176         tx                         += fix1;
1177         ty                         += fiy1;
1178         tz                         += fiz1;
1179         f[i_coord_offset+DIM*2+XX] += fix2;
1180         f[i_coord_offset+DIM*2+YY] += fiy2;
1181         f[i_coord_offset+DIM*2+ZZ] += fiz2;
1182         tx                         += fix2;
1183         ty                         += fiy2;
1184         tz                         += fiz2;
1185         f[i_coord_offset+DIM*3+XX] += fix3;
1186         f[i_coord_offset+DIM*3+YY] += fiy3;
1187         f[i_coord_offset+DIM*3+ZZ] += fiz3;
1188         tx                         += fix3;
1189         ty                         += fiy3;
1190         tz                         += fiz3;
1191         fshift[i_shift_offset+XX]  += tx;
1192         fshift[i_shift_offset+YY]  += ty;
1193         fshift[i_shift_offset+ZZ]  += tz;
1194
1195         /* Increment number of inner iterations */
1196         inneriter                  += j_index_end - j_index_start;
1197
1198         /* Outer loop uses 30 flops */
1199     }
1200
1201     /* Increment number of outer iterations */
1202     outeriter        += nri;
1203
1204     /* Update outer/inner flops */
1205
1206     inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_W4W4_F,outeriter*30 + inneriter*333);
1207 }