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 f77dkernel304
33 C Coulomb interaction: Tabulated
34 C VdW interaction: Not calculated
35 C water optimization: pairs of TIP4P interactions
36 C Calculate forces: yes
38 subroutine f77dkernel304
(
71 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
72 real*8 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
73 integer*4 gid
(*),type
(*),ntype
74 real*8 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
75 real*8 Vvdw
(*),tabscale
,VFtab
(*)
76 real*8 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
87 real*8 Y
,F
,Geps
,Heps2
,Fp
,VV
90 real*8 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
91 real*8 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
92 real*8 ix4
,iy4
,iz4
,fix4
,fiy4
,fiz4
93 real*8 jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
94 real*8 jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
95 real*8 jx4
,jy4
,jz4
,fjx4
,fjy4
,fjz4
96 real*8 dx22
,dy22
,dz22
,rsq22
,rinv22
97 real*8 dx23
,dy23
,dz23
,rsq23
,rinv23
98 real*8 dx24
,dy24
,dz24
,rsq24
,rinv24
99 real*8 dx32
,dy32
,dz32
,rsq32
,rinv32
100 real*8 dx33
,dy33
,dz33
,rsq33
,rinv33
101 real*8 dx34
,dy34
,dz34
,rsq34
,rinv34
102 real*8 dx42
,dy42
,dz42
,rsq42
,rinv42
103 real*8 dx43
,dy43
,dz43
,rsq43
,rinv43
104 real*8 dx44
,dy44
,dz44
,rsq44
,rinv44
105 real*8 qH
,qM
,qqMM
,qqMH
,qqHH
108 C Initialize water data
117 C Reset outer and inner iteration counters
121 C Loop over thread workunits
122 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
123 if(nn1
.gt
.nri
) nn1
=nri
125 C Start outer loop over neighborlists
129 C Load shift vector for this list
132 shY
= shiftvec
(is3
+1)
133 shZ
= shiftvec
(is3
+2)
135 C Load limits for loop over neighbors
139 C Get outer coordinate index
143 C Load i atom data, add shift vector
144 ix2
= shX
+ pos
(ii3
+3)
145 iy2
= shY
+ pos
(ii3
+4)
146 iz2
= shZ
+ pos
(ii3
+5)
147 ix3
= shX
+ pos
(ii3
+6)
148 iy3
= shY
+ pos
(ii3
+7)
149 iz3
= shZ
+ pos
(ii3
+8)
150 ix4
= shX
+ pos
(ii3
+9)
151 iy4
= shY
+ pos
(ii3
+10)
152 iz4
= shZ
+ pos
(ii3
+11)
154 C Zero the potential energy for this list
157 C Clear i atom forces
170 C Get j neighbor index, and coordinate index
174 C load j atom coordinates
189 rsq22
= dx22*dx22
+dy22*dy22
+dz22*dz22
193 rsq23
= dx23*dx23
+dy23*dy23
+dz23*dz23
197 rsq24
= dx24*dx24
+dy24*dy24
+dz24*dz24
201 rsq32
= dx32*dx32
+dy32*dy32
+dz32*dz32
205 rsq33
= dx33*dx33
+dy33*dy33
+dz33*dz33
209 rsq34
= dx34*dx34
+dy34*dy34
+dz34*dz34
213 rsq42
= dx42*dx42
+dy42*dy42
+dz42*dz42
217 rsq43
= dx43*dx43
+dy43*dy43
+dz43*dz43
221 rsq44
= dx44*dx44
+dy44*dy44
+dz44*dz44
223 C Calculate 1/r and 1/r2
224 rinv22
= 1.0/sqrt
(rsq22
)
225 rinv23
= 1.0/sqrt
(rsq23
)
226 rinv24
= 1.0/sqrt
(rsq24
)
227 rinv32
= 1.0/sqrt
(rsq32
)
228 rinv33
= 1.0/sqrt
(rsq33
)
229 rinv34
= 1.0/sqrt
(rsq34
)
230 rinv42
= 1.0/sqrt
(rsq42
)
231 rinv43
= 1.0/sqrt
(rsq43
)
232 rinv44
= 1.0/sqrt
(rsq44
)
234 C Load parameters for j atom
237 C Calculate table index
240 C Calculate table index
247 C Tabulated coulomb interaction
250 Geps
= eps*VFtab
(nnn
+2)
251 Heps2
= eps2*VFtab
(nnn
+3)
254 FF
= Fp
+Geps
+2.0*Heps2
257 vctot
= vctot
+ vcoul
258 fscal
= -((fijC
)*tabscale
)*rinv22
260 C Calculate temporary vectorial force
265 C Increment i atom force
270 C Decrement j atom force
271 fjx2
= faction
(j3
+3) - tx
272 fjy2
= faction
(j3
+4) - ty
273 fjz2
= faction
(j3
+5) - tz
275 C Load parameters for j atom
278 C Calculate table index
281 C Calculate table index
288 C Tabulated coulomb interaction
291 Geps
= eps*VFtab
(nnn
+2)
292 Heps2
= eps2*VFtab
(nnn
+3)
295 FF
= Fp
+Geps
+2.0*Heps2
298 vctot
= vctot
+ vcoul
299 fscal
= -((fijC
)*tabscale
)*rinv23
301 C Calculate temporary vectorial force
306 C Increment i atom force
311 C Decrement j atom force
312 fjx3
= faction
(j3
+6) - tx
313 fjy3
= faction
(j3
+7) - ty
314 fjz3
= faction
(j3
+8) - tz
316 C Load parameters for j atom
319 C Calculate table index
322 C Calculate table index
329 C Tabulated coulomb interaction
332 Geps
= eps*VFtab
(nnn
+2)
333 Heps2
= eps2*VFtab
(nnn
+3)
336 FF
= Fp
+Geps
+2.0*Heps2
339 vctot
= vctot
+ vcoul
340 fscal
= -((fijC
)*tabscale
)*rinv24
342 C Calculate temporary vectorial force
347 C Increment i atom force
352 C Decrement j atom force
353 fjx4
= faction
(j3
+9) - tx
354 fjy4
= faction
(j3
+10) - ty
355 fjz4
= faction
(j3
+11) - tz
357 C Load parameters for j atom
360 C Calculate table index
363 C Calculate table index
370 C Tabulated coulomb interaction
373 Geps
= eps*VFtab
(nnn
+2)
374 Heps2
= eps2*VFtab
(nnn
+3)
377 FF
= Fp
+Geps
+2.0*Heps2
380 vctot
= vctot
+ vcoul
381 fscal
= -((fijC
)*tabscale
)*rinv32
383 C Calculate temporary vectorial force
388 C Increment i atom force
393 C Decrement j atom force
398 C Load parameters for j atom
401 C Calculate table index
404 C Calculate table index
411 C Tabulated coulomb interaction
414 Geps
= eps*VFtab
(nnn
+2)
415 Heps2
= eps2*VFtab
(nnn
+3)
418 FF
= Fp
+Geps
+2.0*Heps2
421 vctot
= vctot
+ vcoul
422 fscal
= -((fijC
)*tabscale
)*rinv33
424 C Calculate temporary vectorial force
429 C Increment i atom force
434 C Decrement j atom force
439 C Load parameters for j atom
442 C Calculate table index
445 C Calculate table index
452 C Tabulated coulomb interaction
455 Geps
= eps*VFtab
(nnn
+2)
456 Heps2
= eps2*VFtab
(nnn
+3)
459 FF
= Fp
+Geps
+2.0*Heps2
462 vctot
= vctot
+ vcoul
463 fscal
= -((fijC
)*tabscale
)*rinv34
465 C Calculate temporary vectorial force
470 C Increment i atom force
475 C Decrement j atom force
480 C Load parameters for j atom
483 C Calculate table index
486 C Calculate table index
493 C Tabulated coulomb interaction
496 Geps
= eps*VFtab
(nnn
+2)
497 Heps2
= eps2*VFtab
(nnn
+3)
500 FF
= Fp
+Geps
+2.0*Heps2
503 vctot
= vctot
+ vcoul
504 fscal
= -((fijC
)*tabscale
)*rinv42
506 C Calculate temporary vectorial force
511 C Increment i atom force
516 C Decrement j atom force
517 faction
(j3
+3) = fjx2
- tx
518 faction
(j3
+4) = fjy2
- ty
519 faction
(j3
+5) = fjz2
- tz
521 C Load parameters for j atom
524 C Calculate table index
527 C Calculate table index
534 C Tabulated coulomb interaction
537 Geps
= eps*VFtab
(nnn
+2)
538 Heps2
= eps2*VFtab
(nnn
+3)
541 FF
= Fp
+Geps
+2.0*Heps2
544 vctot
= vctot
+ vcoul
545 fscal
= -((fijC
)*tabscale
)*rinv43
547 C Calculate temporary vectorial force
552 C Increment i atom force
557 C Decrement j atom force
558 faction
(j3
+6) = fjx3
- tx
559 faction
(j3
+7) = fjy3
- ty
560 faction
(j3
+8) = fjz3
- tz
562 C Load parameters for j atom
565 C Calculate table index
568 C Calculate table index
575 C Tabulated coulomb interaction
578 Geps
= eps*VFtab
(nnn
+2)
579 Heps2
= eps2*VFtab
(nnn
+3)
582 FF
= Fp
+Geps
+2.0*Heps2
585 vctot
= vctot
+ vcoul
586 fscal
= -((fijC
)*tabscale
)*rinv44
588 C Calculate temporary vectorial force
593 C Increment i atom force
598 C Decrement j atom force
599 faction
(j3
+9) = fjx4
- tx
600 faction
(j3
+10) = fjy4
- ty
601 faction
(j3
+11) = fjz4
- tz
603 C Inner loop uses 414 flops/iteration
607 C Add i forces to mem and shifted force list
608 faction
(ii3
+3) = faction
(ii3
+3) + fix2
609 faction
(ii3
+4) = faction
(ii3
+4) + fiy2
610 faction
(ii3
+5) = faction
(ii3
+5) + fiz2
611 faction
(ii3
+6) = faction
(ii3
+6) + fix3
612 faction
(ii3
+7) = faction
(ii3
+7) + fiy3
613 faction
(ii3
+8) = faction
(ii3
+8) + fiz3
614 faction
(ii3
+9) = faction
(ii3
+9) + fix4
615 faction
(ii3
+10) = faction
(ii3
+10) + fiy4
616 faction
(ii3
+11) = faction
(ii3
+11) + fiz4
617 fshift
(is3
) = fshift
(is3
)+fix2
+fix3
+fix4
618 fshift
(is3
+1) = fshift
(is3
+1)+fiy2
+fiy3
+fiy4
619 fshift
(is3
+2) = fshift
(is3
+2)+fiz2
+fiz3
+fiz4
621 C Add potential energies to the group for this list
623 Vc
(ggid
) = Vc
(ggid
) + vctot
625 C Increment number of inner iterations
626 ninner
= ninner
+ nj1
- nj0
628 C Outer loop uses 28 flops/iteration
632 C Increment number of outer iterations
633 nouter
= nouter
+ nn1
- nn0
634 if(nn1
.lt
.nri
) goto 10
636 C Write outer/inner iteration count to pointers
648 C Gromacs nonbonded kernel f77dkernel304nf
649 C Coulomb interaction: Tabulated
650 C VdW interaction: Not calculated
651 C water optimization: pairs of TIP4P interactions
652 C Calculate forces: no
654 subroutine f77dkernel304nf
(
687 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
688 real*8 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
689 integer*4 gid
(*),type
(*),ntype
690 real*8 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
691 real*8 Vvdw
(*),tabscale
,VFtab
(*)
692 real*8 invsqrta
(*),dvda
(*),gbtabscale
,GBtab
(*)
693 integer*4 nthreads
,count
,mtx
,outeriter
,inneriter
696 integer*4 n
,ii
,is3
,ii3
,k
,nj0
,nj1
,jnr
,j3
,ggid
697 integer*4 nn0
,nn1
,nouter
,ninner
699 real*8 qq
,vcoul
,vctot
702 real*8 Y
,F
,Geps
,Heps2
,Fp
,VV
709 real*8 dx22
,dy22
,dz22
,rsq22
,rinv22
710 real*8 dx23
,dy23
,dz23
,rsq23
,rinv23
711 real*8 dx24
,dy24
,dz24
,rsq24
,rinv24
712 real*8 dx32
,dy32
,dz32
,rsq32
,rinv32
713 real*8 dx33
,dy33
,dz33
,rsq33
,rinv33
714 real*8 dx34
,dy34
,dz34
,rsq34
,rinv34
715 real*8 dx42
,dy42
,dz42
,rsq42
,rinv42
716 real*8 dx43
,dy43
,dz43
,rsq43
,rinv43
717 real*8 dx44
,dy44
,dz44
,rsq44
,rinv44
718 real*8 qH
,qM
,qqMM
,qqMH
,qqHH
721 C Initialize water data
730 C Reset outer and inner iteration counters
734 C Loop over thread workunits
735 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
736 if(nn1
.gt
.nri
) nn1
=nri
738 C Start outer loop over neighborlists
742 C Load shift vector for this list
745 shY
= shiftvec
(is3
+1)
746 shZ
= shiftvec
(is3
+2)
748 C Load limits for loop over neighbors
752 C Get outer coordinate index
756 C Load i atom data, add shift vector
757 ix2
= shX
+ pos
(ii3
+3)
758 iy2
= shY
+ pos
(ii3
+4)
759 iz2
= shZ
+ pos
(ii3
+5)
760 ix3
= shX
+ pos
(ii3
+6)
761 iy3
= shY
+ pos
(ii3
+7)
762 iz3
= shZ
+ pos
(ii3
+8)
763 ix4
= shX
+ pos
(ii3
+9)
764 iy4
= shY
+ pos
(ii3
+10)
765 iz4
= shZ
+ pos
(ii3
+11)
767 C Zero the potential energy for this list
770 C Clear i atom forces
774 C Get j neighbor index, and coordinate index
778 C load j atom coordinates
793 rsq22
= dx22*dx22
+dy22*dy22
+dz22*dz22
797 rsq23
= dx23*dx23
+dy23*dy23
+dz23*dz23
801 rsq24
= dx24*dx24
+dy24*dy24
+dz24*dz24
805 rsq32
= dx32*dx32
+dy32*dy32
+dz32*dz32
809 rsq33
= dx33*dx33
+dy33*dy33
+dz33*dz33
813 rsq34
= dx34*dx34
+dy34*dy34
+dz34*dz34
817 rsq42
= dx42*dx42
+dy42*dy42
+dz42*dz42
821 rsq43
= dx43*dx43
+dy43*dy43
+dz43*dz43
825 rsq44
= dx44*dx44
+dy44*dy44
+dz44*dz44
827 C Calculate 1/r and 1/r2
828 rinv22
= 1.0/sqrt
(rsq22
)
829 rinv23
= 1.0/sqrt
(rsq23
)
830 rinv24
= 1.0/sqrt
(rsq24
)
831 rinv32
= 1.0/sqrt
(rsq32
)
832 rinv33
= 1.0/sqrt
(rsq33
)
833 rinv34
= 1.0/sqrt
(rsq34
)
834 rinv42
= 1.0/sqrt
(rsq42
)
835 rinv43
= 1.0/sqrt
(rsq43
)
836 rinv44
= 1.0/sqrt
(rsq44
)
838 C Load parameters for j atom
841 C Calculate table index
844 C Calculate table index
851 C Tabulated coulomb interaction
854 Geps
= eps*VFtab
(nnn
+2)
855 Heps2
= eps2*VFtab
(nnn
+3)
859 vctot
= vctot
+ vcoul
861 C Load parameters for j atom
864 C Calculate table index
867 C Calculate table index
874 C Tabulated coulomb interaction
877 Geps
= eps*VFtab
(nnn
+2)
878 Heps2
= eps2*VFtab
(nnn
+3)
882 vctot
= vctot
+ vcoul
884 C Load parameters for j atom
887 C Calculate table index
890 C Calculate table index
897 C Tabulated coulomb interaction
900 Geps
= eps*VFtab
(nnn
+2)
901 Heps2
= eps2*VFtab
(nnn
+3)
905 vctot
= vctot
+ vcoul
907 C Load parameters for j atom
910 C Calculate table index
913 C Calculate table index
920 C Tabulated coulomb interaction
923 Geps
= eps*VFtab
(nnn
+2)
924 Heps2
= eps2*VFtab
(nnn
+3)
928 vctot
= vctot
+ vcoul
930 C Load parameters for j atom
933 C Calculate table index
936 C Calculate table index
943 C Tabulated coulomb interaction
946 Geps
= eps*VFtab
(nnn
+2)
947 Heps2
= eps2*VFtab
(nnn
+3)
951 vctot
= vctot
+ vcoul
953 C Load parameters for j atom
956 C Calculate table index
959 C Calculate table index
966 C Tabulated coulomb interaction
969 Geps
= eps*VFtab
(nnn
+2)
970 Heps2
= eps2*VFtab
(nnn
+3)
974 vctot
= vctot
+ vcoul
976 C Load parameters for j atom
979 C Calculate table index
982 C Calculate table index
989 C Tabulated coulomb interaction
992 Geps
= eps*VFtab
(nnn
+2)
993 Heps2
= eps2*VFtab
(nnn
+3)
997 vctot
= vctot
+ vcoul
999 C Load parameters for j atom
1002 C Calculate table index
1005 C Calculate table index
1012 C Tabulated coulomb interaction
1015 Geps
= eps*VFtab
(nnn
+2)
1016 Heps2
= eps2*VFtab
(nnn
+3)
1020 vctot
= vctot
+ vcoul
1022 C Load parameters for j atom
1025 C Calculate table index
1028 C Calculate table index
1035 C Tabulated coulomb interaction
1038 Geps
= eps*VFtab
(nnn
+2)
1039 Heps2
= eps2*VFtab
(nnn
+3)
1043 vctot
= vctot
+ vcoul
1045 C Inner loop uses 270 flops/iteration
1049 C Add i forces to mem and shifted force list
1051 C Add potential energies to the group for this list
1053 Vc
(ggid
) = Vc
(ggid
) + vctot
1055 C Increment number of inner iterations
1056 ninner
= ninner
+ nj1
- nj0
1058 C Outer loop uses 10 flops/iteration
1062 C Increment number of outer iterations
1063 nouter
= nouter
+ nn1
- nn0
1064 if(nn1
.lt
.nri
) goto 10
1066 C Write outer/inner iteration count to pointers