2 C This source code is part of
6 C Copyright (c) 1991-2000, University of Groningen, The Netherlands.
7 C Copyright (c) 2001-2009, The GROMACS Development Team
9 C Gromacs is a library for molecular simulation and trajectory analysis,
10 C written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for
11 C a full list of developers and information, check out http://www.gromacs.org
13 C This program is free software; you can redistribute it and/or modify it under
14 C the terms of the GNU Lesser General Public License as published by the Free
15 C Software Foundation; either version 2 of the License, or (at your option) any
17 C As a special exception, you may use this file as part of a free software
18 C library without restriction. Specifically, if other files instantiate
19 C templates or use macros or inline functions from this file, or you compile
20 C this file and link it with other files to produce an executable, this
21 C file does not by itself cause the resulting executable to be covered by
22 C the GNU Lesser General Public License.
24 C In plain-speak: do not worry about classes/macros/templates either - only
25 C changes to the library have to be LGPL, not an application linking with it.
27 C To help fund GROMACS development, we humbly ask that you cite
28 C the papers people have written on it - you can find them on the website!
36 # define gmxreal real*8
38 # define gmxreal real*4
44 C Gromacs nonbonded kernel pwr6kernel120
45 C Coulomb interaction: Normal Coulomb
46 C VdW interaction: Buckingham
47 C water optimization: No
48 C Calculate forces: yes
50 subroutine pwr6kernel120(
83 integer*4 nri,iinr(*),jindex(*),jjnr(*),shift(*)
84 gmxreal shiftvec(*),fshift(*),pos(*),faction(*)
85 integer*4 gid(*),type(*),ntype
86 gmxreal charge(*),facel,krf,crf,Vc(*),vdwparam(*)
87 gmxreal Vvdw(*),tabscale,VFtab(*)
88 gmxreal invsqrta(*),dvda(*),gbtabscale,GBtab(*)
89 integer*4 nthreads,count,mtx,outeriter,inneriter
92 integer*4 n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid
93 integer*4 nn0,nn1,nouter,ninner
95 gmxreal fscal,tx,ty,tz
98 gmxreal qq,vcoul,vctot
102 gmxreal Vvdw6,Vvdwtot
104 gmxreal ix1,iy1,iz1,fix1,fiy1,fiz1
106 gmxreal dx11,dy11,dz11,rsq11,rinv11
107 gmxreal c6,cexp1,cexp2
110 C Reset outer and inner iteration counters
114 C Loop over thread workunits
115 10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
116 if(nn1.gt.nri) nn1=nri
118 C Start outer loop over neighborlists
122 C Load shift vector for this list
125 shY = shiftvec(is3+1)
126 shZ = shiftvec(is3+2)
128 C Load limits for loop over neighbors
132 C Get outer coordinate index
136 C Load i atom data, add shift vector
137 ix1 = shX + pos(ii3+0)
138 iy1 = shY + pos(ii3+1)
139 iz1 = shZ + pos(ii3+2)
141 C Load parameters for i atom
142 iq = facel*charge(ii)
143 nti = 3*ntype*type(ii)
145 C Zero the potential energy for this list
149 C Clear i atom forces
156 C Get j neighbor index, and coordinate index
160 C load j atom coordinates
169 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11
171 C Calculate 1/r and 1/r2
173 C PowerPC intrinsics 1/sqrt lookup table
175 rinv11 = frsqrtes(rsq11)
177 rinv11 = frsqrte(dble(rsq11))
179 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
182 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
186 C Load parameters for j atom
188 tj = nti+3*type(jnr)+1
190 cexp1 = vdwparam(tj+1)
191 cexp2 = vdwparam(tj+2)
192 rinvsq = rinv11*rinv11
194 C Coulomb interaction
198 C Buckingham interaction
199 rinvsix = rinvsq*rinvsq*rinvsq
201 br = cexp2*rsq11*rinv11
202 Vvdwexp = cexp1*exp(-br)
203 Vvdwtot = Vvdwtot+Vvdwexp-Vvdw6
204 fscal = (vcoul+br*Vvdwexp-6.0*Vvdw6)*rinvsq
206 C Calculate temporary vectorial force
211 C Increment i atom force
216 C Decrement j atom force
217 faction(j3+0) = faction(j3+0) - tx
218 faction(j3+1) = faction(j3+1) - ty
219 faction(j3+2) = faction(j3+2) - tz
221 C Inner loop uses 65 flops/iteration
225 C Add i forces to mem and shifted force list
226 faction(ii3+0) = faction(ii3+0) + fix1
227 faction(ii3+1) = faction(ii3+1) + fiy1
228 faction(ii3+2) = faction(ii3+2) + fiz1
229 fshift(is3) = fshift(is3)+fix1
230 fshift(is3+1) = fshift(is3+1)+fiy1
231 fshift(is3+2) = fshift(is3+2)+fiz1
233 C Add potential energies to the group for this list
235 Vc(ggid) = Vc(ggid) + vctot
236 Vvdw(ggid) = Vvdw(ggid) + Vvdwtot
238 C Increment number of inner iterations
239 ninner = ninner + nj1 - nj0
241 C Outer loop uses 12 flops/iteration
245 C Increment number of outer iterations
246 nouter = nouter + nn1 - nn0
247 if(nn1.lt.nri) goto 10
249 C Write outer/inner iteration count to pointers
261 C Gromacs nonbonded kernel pwr6kernel120nf
262 C Coulomb interaction: Normal Coulomb
263 C VdW interaction: Buckingham
264 C water optimization: No
265 C Calculate forces: no
267 subroutine pwr6kernel120nf(
300 integer*4 nri,iinr(*),jindex(*),jjnr(*),shift(*)
301 gmxreal shiftvec(*),fshift(*),pos(*),faction(*)
302 integer*4 gid(*),type(*),ntype
303 gmxreal charge(*),facel,krf,crf,Vc(*),vdwparam(*)
304 gmxreal Vvdw(*),tabscale,VFtab(*)
305 gmxreal invsqrta(*),dvda(*),gbtabscale,GBtab(*)
306 integer*4 nthreads,count,mtx,outeriter,inneriter
309 integer*4 n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid
310 integer*4 nn0,nn1,nouter,ninner
314 gmxreal qq,vcoul,vctot
318 gmxreal Vvdw6,Vvdwtot
322 gmxreal dx11,dy11,dz11,rsq11,rinv11
323 gmxreal c6,cexp1,cexp2
326 C Reset outer and inner iteration counters
330 C Loop over thread workunits
331 10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
332 if(nn1.gt.nri) nn1=nri
334 C Start outer loop over neighborlists
338 C Load shift vector for this list
341 shY = shiftvec(is3+1)
342 shZ = shiftvec(is3+2)
344 C Load limits for loop over neighbors
348 C Get outer coordinate index
352 C Load i atom data, add shift vector
353 ix1 = shX + pos(ii3+0)
354 iy1 = shY + pos(ii3+1)
355 iz1 = shZ + pos(ii3+2)
357 C Load parameters for i atom
358 iq = facel*charge(ii)
359 nti = 3*ntype*type(ii)
361 C Zero the potential energy for this list
365 C Clear i atom forces
369 C Get j neighbor index, and coordinate index
373 C load j atom coordinates
382 rsq11 = dx11*dx11+dy11*dy11+dz11*dz11
384 C Calculate 1/r and 1/r2
386 C PowerPC intrinsics 1/sqrt lookup table
388 rinv11 = frsqrtes(rsq11)
390 rinv11 = frsqrte(dble(rsq11))
392 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
395 rinv11 = (0.5*rinv11*(3.0-((rsq11*rinv11)
399 C Load parameters for j atom
401 tj = nti+3*type(jnr)+1
403 cexp1 = vdwparam(tj+1)
404 cexp2 = vdwparam(tj+2)
405 rinvsq = rinv11*rinv11
407 C Coulomb interaction
411 C Buckingham interaction
412 rinvsix = rinvsq*rinvsq*rinvsq
414 br = cexp2*rsq11*rinv11
415 Vvdwexp = cexp1*exp(-br)
416 Vvdwtot = Vvdwtot+Vvdwexp-Vvdw6
418 C Inner loop uses 52 flops/iteration
422 C Add i forces to mem and shifted force list
424 C Add potential energies to the group for this list
426 Vc(ggid) = Vc(ggid) + vctot
427 Vvdw(ggid) = Vvdw(ggid) + Vvdwtot
429 C Increment number of inner iterations
430 ninner = ninner + nj1 - nj0
432 C Outer loop uses 6 flops/iteration
436 C Increment number of outer iterations
437 nouter = nouter + nn1 - nn0
438 if(nn1.lt.nri) goto 10
440 C Write outer/inner iteration count to pointers