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 f77skernel113
33 C Coulomb interaction: Normal Coulomb
34 C VdW interaction: Lennard-Jones
35 C water optimization: TIP4P - other atoms
36 C Calculate forces: yes
38 subroutine f77skernel113
(
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
98 real*4 dx21
,dy21
,dz21
,rsq21
,rinv21
99 real*4 dx31
,dy31
,dz31
,rsq31
,rinv31
100 real*4 dx41
,dy41
,dz41
,rsq41
,rinv41
105 C Initialize water data
107 qH
= facel*charge
(ii
+1)
108 qM
= facel*charge
(ii
+3)
109 nti
= 2*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
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
+2*type
(jnr
)+1
210 C Lennard-Jones interaction
211 rinvsix
= rinvsq*rinvsq*rinvsq
213 Vvdw12
= c12*rinvsix*rinvsix
214 Vvdwtot
= Vvdwtot
+Vvdw12
-Vvdw6
215 fscal
= (12.0*Vvdw12
-6.0*Vvdw6
)*rinvsq
217 C Calculate temporary vectorial force
222 C Increment i atom force
227 C Decrement j atom force
228 fjx1
= faction
(j3
+0) - tx
229 fjy1
= faction
(j3
+1) - ty
230 fjz1
= faction
(j3
+2) - tz
232 C Load parameters for j atom
235 rinvsq
= rinv21*rinv21
237 C Coulomb interaction
240 fscal
= (vcoul
)*rinvsq
242 C Calculate temporary vectorial force
247 C Increment i atom force
252 C Decrement j atom force
257 C Load parameters for j atom
258 rinvsq
= rinv31*rinv31
260 C Coulomb interaction
263 fscal
= (vcoul
)*rinvsq
265 C Calculate temporary vectorial force
270 C Increment i atom force
275 C Decrement j atom force
280 C Load parameters for j atom
282 rinvsq
= rinv41*rinv41
284 C Coulomb interaction
287 fscal
= (vcoul
)*rinvsq
289 C Calculate temporary vectorial force
294 C Increment i atom force
299 C Decrement j atom force
300 faction
(j3
+0) = fjx1
- tx
301 faction
(j3
+1) = fjy1
- ty
302 faction
(j3
+2) = fjz1
- tz
304 C Inner loop uses 113 flops/iteration
308 C Add i forces to mem and shifted force list
309 faction
(ii3
+0) = faction
(ii3
+0) + fix1
310 faction
(ii3
+1) = faction
(ii3
+1) + fiy1
311 faction
(ii3
+2) = faction
(ii3
+2) + fiz1
312 faction
(ii3
+3) = faction
(ii3
+3) + fix2
313 faction
(ii3
+4) = faction
(ii3
+4) + fiy2
314 faction
(ii3
+5) = faction
(ii3
+5) + fiz2
315 faction
(ii3
+6) = faction
(ii3
+6) + fix3
316 faction
(ii3
+7) = faction
(ii3
+7) + fiy3
317 faction
(ii3
+8) = faction
(ii3
+8) + fiz3
318 faction
(ii3
+9) = faction
(ii3
+9) + fix4
319 faction
(ii3
+10) = faction
(ii3
+10) + fiy4
320 faction
(ii3
+11) = faction
(ii3
+11) + fiz4
321 fshift
(is3
) = fshift
(is3
)+fix1
+fix2
+fix3
+fix4
322 fshift
(is3
+1) = fshift
(is3
+1)+fiy1
+fiy2
+fiy3
+fiy4
323 fshift
(is3
+2) = fshift
(is3
+2)+fiz1
+fiz2
+fiz3
+fiz4
325 C Add potential energies to the group for this list
327 Vc
(ggid
) = Vc
(ggid
) + vctot
328 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
330 C Increment number of inner iterations
331 ninner
= ninner
+ nj1
- nj0
333 C Outer loop uses 38 flops/iteration
337 C Increment number of outer iterations
338 nouter
= nouter
+ nn1
- nn0
339 if(nn1
.lt
.nri
) goto 10
341 C Write outer/inner iteration count to pointers
353 C Gromacs nonbonded kernel f77skernel113nf
354 C Coulomb interaction: Normal Coulomb
355 C VdW interaction: Lennard-Jones
356 C water optimization: TIP4P - other atoms
357 C Calculate forces: no
359 subroutine f77skernel113nf
(
392 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
393 real*4 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
394 integer*4 gid
(*),type
(*),ntype
395 real*4 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
396 real*4 Vvdw
(*),tabscale
,VFtab
(*)
397 real*4 invsqrta
(*),dvda
(*),gbtabscale
,GBtab
(*)
398 integer*4 nthreads
,count
,mtx
,outeriter
,inneriter
401 integer*4 n
,ii
,is3
,ii3
,k
,nj0
,nj1
,jnr
,j3
,ggid
402 integer*4 nn0
,nn1
,nouter
,ninner
406 real*4 qq
,vcoul
,vctot
417 real*4 dx11
,dy11
,dz11
,rsq11
418 real*4 dx21
,dy21
,dz21
,rsq21
,rinv21
419 real*4 dx31
,dy31
,dz31
,rsq31
,rinv31
420 real*4 dx41
,dy41
,dz41
,rsq41
,rinv41
425 C Initialize water data
427 qH
= facel*charge
(ii
+1)
428 qM
= facel*charge
(ii
+3)
429 nti
= 2*ntype*type
(ii
)
432 C Reset outer and inner iteration counters
436 C Loop over thread workunits
437 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
438 if(nn1
.gt
.nri
) nn1
=nri
440 C Start outer loop over neighborlists
444 C Load shift vector for this list
447 shY
= shiftvec
(is3
+1)
448 shZ
= shiftvec
(is3
+2)
450 C Load limits for loop over neighbors
454 C Get outer coordinate index
458 C Load i atom data, add shift vector
459 ix1
= shX
+ pos
(ii3
+0)
460 iy1
= shY
+ pos
(ii3
+1)
461 iz1
= shZ
+ pos
(ii3
+2)
462 ix2
= shX
+ pos
(ii3
+3)
463 iy2
= shY
+ pos
(ii3
+4)
464 iz2
= shZ
+ pos
(ii3
+5)
465 ix3
= shX
+ pos
(ii3
+6)
466 iy3
= shY
+ pos
(ii3
+7)
467 iz3
= shZ
+ pos
(ii3
+8)
468 ix4
= shX
+ pos
(ii3
+9)
469 iy4
= shY
+ pos
(ii3
+10)
470 iz4
= shZ
+ pos
(ii3
+11)
472 C Zero the potential energy for this list
476 C Clear i atom forces
480 C Get j neighbor index, and coordinate index
484 C load j atom coordinates
493 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
497 rsq21
= dx21*dx21
+dy21*dy21
+dz21*dz21
501 rsq31
= dx31*dx31
+dy31*dy31
+dz31*dz31
505 rsq41
= dx41*dx41
+dy41*dy41
+dz41*dz41
507 C Calculate 1/r and 1/r2
509 rinv21
= 1.0/sqrt
(rsq21
)
510 rinv31
= 1.0/sqrt
(rsq31
)
511 rinv41
= 1.0/sqrt
(rsq41
)
513 C Load parameters for j atom
514 tj
= nti
+2*type
(jnr
)+1
518 C Lennard-Jones interaction
519 rinvsix
= rinvsq*rinvsq*rinvsq
521 Vvdw12
= c12*rinvsix*rinvsix
522 Vvdwtot
= Vvdwtot
+Vvdw12
-Vvdw6
524 C Load parameters for j atom
528 C Coulomb interaction
532 C Load parameters for j atom
534 C Coulomb interaction
538 C Load parameters for j atom
541 C Coulomb interaction
545 C Inner loop uses 66 flops/iteration
549 C Add i forces to mem and shifted force list
551 C Add potential energies to the group for this list
553 Vc
(ggid
) = Vc
(ggid
) + vctot
554 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
556 C Increment number of inner iterations
557 ninner
= ninner
+ nj1
- nj0
559 C Outer loop uses 14 flops/iteration
563 C Increment number of outer iterations
564 nouter
= nouter
+ nn1
- nn0
565 if(nn1
.lt
.nri
) goto 10
567 C Write outer/inner iteration count to pointers