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