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!
32 C Gromacs nonbonded kernel f77skernel123
33 C Coulomb interaction: Normal Coulomb
34 C VdW interaction: Buckingham
35 C water optimization: TIP4P - other atoms
36 C Calculate forces: yes
38 subroutine f77skernel123
(
71 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
72 real*4 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
73 integer*4 gid
(*),type
(*),ntype
74 real*4 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
75 real*4 Vvdw
(*),tabscale
,VFtab
(*)
76 real*4 invsqrta
(*),dvda
(*),gbtabscale
,GBtab
(*)
77 integer*4 nthreads
,count
,mtx
,outeriter
,inneriter
80 integer*4 n
,ii
,is3
,ii3
,k
,nj0
,nj1
,jnr
,j3
,ggid
81 integer*4 nn0
,nn1
,nouter
,ninner
92 real*4 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
93 real*4 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
94 real*4 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
95 real*4 ix4
,iy4
,iz4
,fix4
,fiy4
,fiz4
96 real*4 jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
97 real*4 dx11
,dy11
,dz11
,rsq11
,rinv11
98 real*4 dx21
,dy21
,dz21
,rsq21
,rinv21
99 real*4 dx31
,dy31
,dz31
,rsq31
,rinv31
100 real*4 dx41
,dy41
,dz41
,rsq41
,rinv41
102 real*4 c6
,cexp1
,cexp2
105 C Initialize water data
107 qH
= facel*charge
(ii
+1)
108 qM
= facel*charge
(ii
+3)
109 nti
= 3*ntype*type
(ii
)
112 C Reset outer and inner iteration counters
116 C Loop over thread workunits
117 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
118 if(nn1
.gt
.nri
) nn1
=nri
120 C Start outer loop over neighborlists
124 C Load shift vector for this list
127 shY
= shiftvec
(is3
+1)
128 shZ
= shiftvec
(is3
+2)
130 C Load limits for loop over neighbors
134 C Get outer coordinate index
138 C Load i atom data, add shift vector
139 ix1
= shX
+ pos
(ii3
+0)
140 iy1
= shY
+ pos
(ii3
+1)
141 iz1
= shZ
+ pos
(ii3
+2)
142 ix2
= shX
+ pos
(ii3
+3)
143 iy2
= shY
+ pos
(ii3
+4)
144 iz2
= shZ
+ pos
(ii3
+5)
145 ix3
= shX
+ pos
(ii3
+6)
146 iy3
= shY
+ pos
(ii3
+7)
147 iz3
= shZ
+ pos
(ii3
+8)
148 ix4
= shX
+ pos
(ii3
+9)
149 iy4
= shY
+ pos
(ii3
+10)
150 iz4
= shZ
+ pos
(ii3
+11)
152 C Zero the potential energy for this list
156 C Clear i atom forces
172 C Get j neighbor index, and coordinate index
176 C load j atom coordinates
185 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
189 rsq21
= dx21*dx21
+dy21*dy21
+dz21*dz21
193 rsq31
= dx31*dx31
+dy31*dy31
+dz31*dz31
197 rsq41
= dx41*dx41
+dy41*dy41
+dz41*dz41
199 C Calculate 1/r and 1/r2
200 rinv11
= 1.0/sqrt
(rsq11
)
201 rinv21
= 1.0/sqrt
(rsq21
)
202 rinv31
= 1.0/sqrt
(rsq31
)
203 rinv41
= 1.0/sqrt
(rsq41
)
205 C Load parameters for j atom
206 tj
= nti
+3*type
(jnr
)+1
208 cexp1
= vdwparam
(tj
+1)
209 cexp2
= vdwparam
(tj
+2)
210 rinvsq
= rinv11*rinv11
212 C Buckingham interaction
213 rinvsix
= rinvsq*rinvsq*rinvsq
215 br
= cexp2*rsq11*rinv11
216 Vvdwexp
= cexp1*exp
(-br
)
217 Vvdwtot
= Vvdwtot
+Vvdwexp
-Vvdw6
218 fscal
= (br*Vvdwexp
-6.0*Vvdw6
)*rinvsq
220 C Calculate temporary vectorial force
225 C Increment i atom force
230 C Decrement j atom force
231 fjx1
= faction
(j3
+0) - tx
232 fjy1
= faction
(j3
+1) - ty
233 fjz1
= faction
(j3
+2) - tz
235 C Load parameters for j atom
238 rinvsq
= rinv21*rinv21
240 C Coulomb interaction
243 fscal
= (vcoul
)*rinvsq
245 C Calculate temporary vectorial force
250 C Increment i atom force
255 C Decrement j atom force
260 C Load parameters for j atom
261 rinvsq
= rinv31*rinv31
263 C Coulomb interaction
266 fscal
= (vcoul
)*rinvsq
268 C Calculate temporary vectorial force
273 C Increment i atom force
278 C Decrement j atom force
283 C Load parameters for j atom
285 rinvsq
= rinv41*rinv41
287 C Coulomb interaction
290 fscal
= (vcoul
)*rinvsq
292 C Calculate temporary vectorial force
297 C Increment i atom force
302 C Decrement j atom force
303 faction
(j3
+0) = fjx1
- tx
304 faction
(j3
+1) = fjy1
- ty
305 faction
(j3
+2) = fjz1
- tz
307 C Inner loop uses 141 flops/iteration
311 C Add i forces to mem and shifted force list
312 faction
(ii3
+0) = faction
(ii3
+0) + fix1
313 faction
(ii3
+1) = faction
(ii3
+1) + fiy1
314 faction
(ii3
+2) = faction
(ii3
+2) + fiz1
315 faction
(ii3
+3) = faction
(ii3
+3) + fix2
316 faction
(ii3
+4) = faction
(ii3
+4) + fiy2
317 faction
(ii3
+5) = faction
(ii3
+5) + fiz2
318 faction
(ii3
+6) = faction
(ii3
+6) + fix3
319 faction
(ii3
+7) = faction
(ii3
+7) + fiy3
320 faction
(ii3
+8) = faction
(ii3
+8) + fiz3
321 faction
(ii3
+9) = faction
(ii3
+9) + fix4
322 faction
(ii3
+10) = faction
(ii3
+10) + fiy4
323 faction
(ii3
+11) = faction
(ii3
+11) + fiz4
324 fshift
(is3
) = fshift
(is3
)+fix1
+fix2
+fix3
+fix4
325 fshift
(is3
+1) = fshift
(is3
+1)+fiy1
+fiy2
+fiy3
+fiy4
326 fshift
(is3
+2) = fshift
(is3
+2)+fiz1
+fiz2
+fiz3
+fiz4
328 C Add potential energies to the group for this list
330 Vc
(ggid
) = Vc
(ggid
) + vctot
331 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
333 C Increment number of inner iterations
334 ninner
= ninner
+ nj1
- nj0
336 C Outer loop uses 38 flops/iteration
340 C Increment number of outer iterations
341 nouter
= nouter
+ nn1
- nn0
342 if(nn1
.lt
.nri
) goto 10
344 C Write outer/inner iteration count to pointers
356 C Gromacs nonbonded kernel f77skernel123nf
357 C Coulomb interaction: Normal Coulomb
358 C VdW interaction: Buckingham
359 C water optimization: TIP4P - other atoms
360 C Calculate forces: no
362 subroutine f77skernel123nf
(
395 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
396 real*4 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
397 integer*4 gid
(*),type
(*),ntype
398 real*4 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
399 real*4 Vvdw
(*),tabscale
,VFtab
(*)
400 real*4 invsqrta
(*),dvda
(*),gbtabscale
,GBtab
(*)
401 integer*4 nthreads
,count
,mtx
,outeriter
,inneriter
404 integer*4 n
,ii
,is3
,ii3
,k
,nj0
,nj1
,jnr
,j3
,ggid
405 integer*4 nn0
,nn1
,nouter
,ninner
409 real*4 qq
,vcoul
,vctot
420 real*4 dx11
,dy11
,dz11
,rsq11
,rinv11
421 real*4 dx21
,dy21
,dz21
,rsq21
,rinv21
422 real*4 dx31
,dy31
,dz31
,rsq31
,rinv31
423 real*4 dx41
,dy41
,dz41
,rsq41
,rinv41
425 real*4 c6
,cexp1
,cexp2
428 C Initialize water data
430 qH
= facel*charge
(ii
+1)
431 qM
= facel*charge
(ii
+3)
432 nti
= 3*ntype*type
(ii
)
435 C Reset outer and inner iteration counters
439 C Loop over thread workunits
440 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
441 if(nn1
.gt
.nri
) nn1
=nri
443 C Start outer loop over neighborlists
447 C Load shift vector for this list
450 shY
= shiftvec
(is3
+1)
451 shZ
= shiftvec
(is3
+2)
453 C Load limits for loop over neighbors
457 C Get outer coordinate index
461 C Load i atom data, add shift vector
462 ix1
= shX
+ pos
(ii3
+0)
463 iy1
= shY
+ pos
(ii3
+1)
464 iz1
= shZ
+ pos
(ii3
+2)
465 ix2
= shX
+ pos
(ii3
+3)
466 iy2
= shY
+ pos
(ii3
+4)
467 iz2
= shZ
+ pos
(ii3
+5)
468 ix3
= shX
+ pos
(ii3
+6)
469 iy3
= shY
+ pos
(ii3
+7)
470 iz3
= shZ
+ pos
(ii3
+8)
471 ix4
= shX
+ pos
(ii3
+9)
472 iy4
= shY
+ pos
(ii3
+10)
473 iz4
= shZ
+ pos
(ii3
+11)
475 C Zero the potential energy for this list
479 C Clear i atom forces
483 C Get j neighbor index, and coordinate index
487 C load j atom coordinates
496 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
500 rsq21
= dx21*dx21
+dy21*dy21
+dz21*dz21
504 rsq31
= dx31*dx31
+dy31*dy31
+dz31*dz31
508 rsq41
= dx41*dx41
+dy41*dy41
+dz41*dz41
510 C Calculate 1/r and 1/r2
511 rinv11
= 1.0/sqrt
(rsq11
)
512 rinv21
= 1.0/sqrt
(rsq21
)
513 rinv31
= 1.0/sqrt
(rsq31
)
514 rinv41
= 1.0/sqrt
(rsq41
)
516 C Load parameters for j atom
517 tj
= nti
+3*type
(jnr
)+1
519 cexp1
= vdwparam
(tj
+1)
520 cexp2
= vdwparam
(tj
+2)
521 rinvsq
= rinv11*rinv11
523 C Buckingham interaction
524 rinvsix
= rinvsq*rinvsq*rinvsq
526 br
= cexp2*rsq11*rinv11
527 Vvdwexp
= cexp1*exp
(-br
)
528 Vvdwtot
= Vvdwtot
+Vvdwexp
-Vvdw6
530 C Load parameters for j atom
534 C Coulomb interaction
538 C Load parameters for j atom
540 C Coulomb interaction
544 C Load parameters for j atom
547 C Coulomb interaction
551 C Inner loop uses 95 flops/iteration
555 C Add i forces to mem and shifted force list
557 C Add potential energies to the group for this list
559 Vc
(ggid
) = Vc
(ggid
) + vctot
560 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
562 C Increment number of inner iterations
563 ninner
= ninner
+ nj1
- nj0
565 C Outer loop uses 14 flops/iteration
569 C Increment number of outer iterations
570 nouter
= nouter
+ nn1
- nn0
571 if(nn1
.lt
.nri
) goto 10
573 C Write outer/inner iteration count to pointers