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