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 f77skernel232
33 C Coulomb interaction: Reaction field
34 C VdW interaction: Tabulated
35 C water optimization: pairs of SPC/TIP3P interactions
36 C Calculate forces: yes
38 subroutine f77skernel232
(
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
91 real*4 Y
,F
,Geps
,Heps2
,Fp
,VV
95 real*4 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
96 real*4 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
97 real*4 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
98 real*4 jx1
,jy1
,jz1
,fjx1
,fjy1
,fjz1
99 real*4 jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
100 real*4 jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
101 real*4 dx11
,dy11
,dz11
,rsq11
,rinv11
102 real*4 dx12
,dy12
,dz12
,rsq12
,rinv12
103 real*4 dx13
,dy13
,dz13
,rsq13
,rinv13
104 real*4 dx21
,dy21
,dz21
,rsq21
,rinv21
105 real*4 dx22
,dy22
,dz22
,rsq22
,rinv22
106 real*4 dx23
,dy23
,dz23
,rsq23
,rinv23
107 real*4 dx31
,dy31
,dz31
,rsq31
,rinv31
108 real*4 dx32
,dy32
,dz32
,rsq32
,rinv32
109 real*4 dx33
,dy33
,dz33
,rsq33
,rinv33
110 real*4 qO
,qH
,qqOO
,qqOH
,qqHH
114 C Initialize water data
121 tj
= 2*(ntype
+1)*type
(ii
)+1
126 C Reset outer and inner iteration counters
130 C Loop over thread workunits
131 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
132 if(nn1
.gt
.nri
) nn1
=nri
134 C Start outer loop over neighborlists
138 C Load shift vector for this list
141 shY
= shiftvec
(is3
+1)
142 shZ
= shiftvec
(is3
+2)
144 C Load limits for loop over neighbors
148 C Get outer coordinate index
152 C Load i atom data, add shift vector
153 ix1
= shX
+ pos
(ii3
+0)
154 iy1
= shY
+ pos
(ii3
+1)
155 iz1
= shZ
+ pos
(ii3
+2)
156 ix2
= shX
+ pos
(ii3
+3)
157 iy2
= shY
+ pos
(ii3
+4)
158 iz2
= shZ
+ pos
(ii3
+5)
159 ix3
= shX
+ pos
(ii3
+6)
160 iy3
= shY
+ pos
(ii3
+7)
161 iz3
= shZ
+ pos
(ii3
+8)
163 C Zero the potential energy for this list
167 C Clear i atom forces
180 C Get j neighbor index, and coordinate index
184 C load j atom coordinates
199 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
203 rsq12
= dx12*dx12
+dy12*dy12
+dz12*dz12
207 rsq13
= dx13*dx13
+dy13*dy13
+dz13*dz13
211 rsq21
= dx21*dx21
+dy21*dy21
+dz21*dz21
215 rsq22
= dx22*dx22
+dy22*dy22
+dz22*dz22
219 rsq23
= dx23*dx23
+dy23*dy23
+dz23*dz23
223 rsq31
= dx31*dx31
+dy31*dy31
+dz31*dz31
227 rsq32
= dx32*dx32
+dy32*dy32
+dz32*dz32
231 rsq33
= dx33*dx33
+dy33*dy33
+dz33*dz33
233 C Calculate 1/r and 1/r2
234 rinv11
= 1.0/sqrt
(rsq11
)
235 rinv12
= 1.0/sqrt
(rsq12
)
236 rinv13
= 1.0/sqrt
(rsq13
)
237 rinv21
= 1.0/sqrt
(rsq21
)
238 rinv22
= 1.0/sqrt
(rsq22
)
239 rinv23
= 1.0/sqrt
(rsq23
)
240 rinv31
= 1.0/sqrt
(rsq31
)
241 rinv32
= 1.0/sqrt
(rsq32
)
242 rinv33
= 1.0/sqrt
(rsq33
)
244 C Load parameters for j atom
246 rinvsq
= rinv11*rinv11
248 C Coulomb reaction-field interaction
250 vcoul
= qq*
(rinv11
+krsq
-crf
)
253 C Calculate table index
256 C Calculate table index
263 C Tabulated VdW interaction - dispersion
266 Geps
= eps*VFtab
(nnn
+2)
267 Heps2
= eps2*VFtab
(nnn
+3)
270 FF
= Fp
+Geps
+2.0*Heps2
274 C Tabulated VdW interaction - repulsion
278 Geps
= eps*VFtab
(nnn
+2)
279 Heps2
= eps2*VFtab
(nnn
+3)
282 FF
= Fp
+Geps
+2.0*Heps2
285 Vvdwtot
= Vvdwtot
+ Vvdw6
+ Vvdw12
286 fscal
= (qq*
(rinv11
-2.0*krsq
))*rinvsq
287 & -((fijD
+fijR
)*tabscale
)*rinv11
289 C Calculate temporary vectorial force
294 C Increment i atom force
299 C Decrement j atom force
300 fjx1
= faction
(j3
+0) - tx
301 fjy1
= faction
(j3
+1) - ty
302 fjz1
= faction
(j3
+2) - tz
304 C Load parameters for j atom
306 rinvsq
= rinv12*rinv12
308 C Coulomb reaction-field interaction
310 vcoul
= qq*
(rinv12
+krsq
-crf
)
312 fscal
= (qq*
(rinv12
-2.0*krsq
))*rinvsq
314 C Calculate temporary vectorial force
319 C Increment i atom force
324 C Decrement j atom force
325 fjx2
= faction
(j3
+3) - tx
326 fjy2
= faction
(j3
+4) - ty
327 fjz2
= faction
(j3
+5) - tz
329 C Load parameters for j atom
331 rinvsq
= rinv13*rinv13
333 C Coulomb reaction-field interaction
335 vcoul
= qq*
(rinv13
+krsq
-crf
)
337 fscal
= (qq*
(rinv13
-2.0*krsq
))*rinvsq
339 C Calculate temporary vectorial force
344 C Increment i atom force
349 C Decrement j atom force
350 fjx3
= faction
(j3
+6) - tx
351 fjy3
= faction
(j3
+7) - ty
352 fjz3
= faction
(j3
+8) - tz
354 C Load parameters for j atom
356 rinvsq
= rinv21*rinv21
358 C Coulomb reaction-field interaction
360 vcoul
= qq*
(rinv21
+krsq
-crf
)
362 fscal
= (qq*
(rinv21
-2.0*krsq
))*rinvsq
364 C Calculate temporary vectorial force
369 C Increment i atom force
374 C Decrement j atom force
379 C Load parameters for j atom
381 rinvsq
= rinv22*rinv22
383 C Coulomb reaction-field interaction
385 vcoul
= qq*
(rinv22
+krsq
-crf
)
387 fscal
= (qq*
(rinv22
-2.0*krsq
))*rinvsq
389 C Calculate temporary vectorial force
394 C Increment i atom force
399 C Decrement j atom force
404 C Load parameters for j atom
406 rinvsq
= rinv23*rinv23
408 C Coulomb reaction-field interaction
410 vcoul
= qq*
(rinv23
+krsq
-crf
)
412 fscal
= (qq*
(rinv23
-2.0*krsq
))*rinvsq
414 C Calculate temporary vectorial force
419 C Increment i atom force
424 C Decrement j atom force
429 C Load parameters for j atom
431 rinvsq
= rinv31*rinv31
433 C Coulomb reaction-field interaction
435 vcoul
= qq*
(rinv31
+krsq
-crf
)
437 fscal
= (qq*
(rinv31
-2.0*krsq
))*rinvsq
439 C Calculate temporary vectorial force
444 C Increment i atom force
449 C Decrement j atom force
450 faction
(j3
+0) = fjx1
- tx
451 faction
(j3
+1) = fjy1
- ty
452 faction
(j3
+2) = fjz1
- tz
454 C Load parameters for j atom
456 rinvsq
= rinv32*rinv32
458 C Coulomb reaction-field interaction
460 vcoul
= qq*
(rinv32
+krsq
-crf
)
462 fscal
= (qq*
(rinv32
-2.0*krsq
))*rinvsq
464 C Calculate temporary vectorial force
469 C Increment i atom force
474 C Decrement j atom force
475 faction
(j3
+3) = fjx2
- tx
476 faction
(j3
+4) = fjy2
- ty
477 faction
(j3
+5) = fjz2
- tz
479 C Load parameters for j atom
481 rinvsq
= rinv33*rinv33
483 C Coulomb reaction-field interaction
485 vcoul
= qq*
(rinv33
+krsq
-crf
)
487 fscal
= (qq*
(rinv33
-2.0*krsq
))*rinvsq
489 C Calculate temporary vectorial force
494 C Increment i atom force
499 C Decrement j atom force
500 faction
(j3
+6) = fjx3
- tx
501 faction
(j3
+7) = fjy3
- ty
502 faction
(j3
+8) = fjz3
- tz
504 C Inner loop uses 320 flops/iteration
508 C Add i forces to mem and shifted force list
509 faction
(ii3
+0) = faction
(ii3
+0) + fix1
510 faction
(ii3
+1) = faction
(ii3
+1) + fiy1
511 faction
(ii3
+2) = faction
(ii3
+2) + fiz1
512 faction
(ii3
+3) = faction
(ii3
+3) + fix2
513 faction
(ii3
+4) = faction
(ii3
+4) + fiy2
514 faction
(ii3
+5) = faction
(ii3
+5) + fiz2
515 faction
(ii3
+6) = faction
(ii3
+6) + fix3
516 faction
(ii3
+7) = faction
(ii3
+7) + fiy3
517 faction
(ii3
+8) = faction
(ii3
+8) + fiz3
518 fshift
(is3
) = fshift
(is3
)+fix1
+fix2
+fix3
519 fshift
(is3
+1) = fshift
(is3
+1)+fiy1
+fiy2
+fiy3
520 fshift
(is3
+2) = fshift
(is3
+2)+fiz1
+fiz2
+fiz3
522 C Add potential energies to the group for this list
524 Vc
(ggid
) = Vc
(ggid
) + vctot
525 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
527 C Increment number of inner iterations
528 ninner
= ninner
+ nj1
- nj0
530 C Outer loop uses 29 flops/iteration
534 C Increment number of outer iterations
535 nouter
= nouter
+ nn1
- nn0
536 if(nn1
.lt
.nri
) goto 10
538 C Write outer/inner iteration count to pointers
550 C Gromacs nonbonded kernel f77skernel232nf
551 C Coulomb interaction: Reaction field
552 C VdW interaction: Tabulated
553 C water optimization: pairs of SPC/TIP3P interactions
554 C Calculate forces: no
556 subroutine f77skernel232nf
(
589 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
590 real*4 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
591 integer*4 gid
(*),type
(*),ntype
592 real*4 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
593 real*4 Vvdw
(*),tabscale
,VFtab
(*)
594 real*4 invsqrta
(*),dvda
(*),gbtabscale
,GBtab
(*)
595 integer*4 nthreads
,count
,mtx
,outeriter
,inneriter
598 integer*4 n
,ii
,is3
,ii3
,k
,nj0
,nj1
,jnr
,j3
,ggid
599 integer*4 nn0
,nn1
,nouter
,ninner
601 real*4 qq
,vcoul
,vctot
607 real*4 Y
,F
,Geps
,Heps2
,Fp
,VV
615 real*4 dx11
,dy11
,dz11
,rsq11
,rinv11
616 real*4 dx12
,dy12
,dz12
,rsq12
,rinv12
617 real*4 dx13
,dy13
,dz13
,rsq13
,rinv13
618 real*4 dx21
,dy21
,dz21
,rsq21
,rinv21
619 real*4 dx22
,dy22
,dz22
,rsq22
,rinv22
620 real*4 dx23
,dy23
,dz23
,rsq23
,rinv23
621 real*4 dx31
,dy31
,dz31
,rsq31
,rinv31
622 real*4 dx32
,dy32
,dz32
,rsq32
,rinv32
623 real*4 dx33
,dy33
,dz33
,rsq33
,rinv33
624 real*4 qO
,qH
,qqOO
,qqOH
,qqHH
628 C Initialize water data
635 tj
= 2*(ntype
+1)*type
(ii
)+1
640 C Reset outer and inner iteration counters
644 C Loop over thread workunits
645 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
646 if(nn1
.gt
.nri
) nn1
=nri
648 C Start outer loop over neighborlists
652 C Load shift vector for this list
655 shY
= shiftvec
(is3
+1)
656 shZ
= shiftvec
(is3
+2)
658 C Load limits for loop over neighbors
662 C Get outer coordinate index
666 C Load i atom data, add shift vector
667 ix1
= shX
+ pos
(ii3
+0)
668 iy1
= shY
+ pos
(ii3
+1)
669 iz1
= shZ
+ pos
(ii3
+2)
670 ix2
= shX
+ pos
(ii3
+3)
671 iy2
= shY
+ pos
(ii3
+4)
672 iz2
= shZ
+ pos
(ii3
+5)
673 ix3
= shX
+ pos
(ii3
+6)
674 iy3
= shY
+ pos
(ii3
+7)
675 iz3
= shZ
+ pos
(ii3
+8)
677 C Zero the potential energy for this list
681 C Clear i atom forces
685 C Get j neighbor index, and coordinate index
689 C load j atom coordinates
704 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
708 rsq12
= dx12*dx12
+dy12*dy12
+dz12*dz12
712 rsq13
= dx13*dx13
+dy13*dy13
+dz13*dz13
716 rsq21
= dx21*dx21
+dy21*dy21
+dz21*dz21
720 rsq22
= dx22*dx22
+dy22*dy22
+dz22*dz22
724 rsq23
= dx23*dx23
+dy23*dy23
+dz23*dz23
728 rsq31
= dx31*dx31
+dy31*dy31
+dz31*dz31
732 rsq32
= dx32*dx32
+dy32*dy32
+dz32*dz32
736 rsq33
= dx33*dx33
+dy33*dy33
+dz33*dz33
738 C Calculate 1/r and 1/r2
739 rinv11
= 1.0/sqrt
(rsq11
)
740 rinv12
= 1.0/sqrt
(rsq12
)
741 rinv13
= 1.0/sqrt
(rsq13
)
742 rinv21
= 1.0/sqrt
(rsq21
)
743 rinv22
= 1.0/sqrt
(rsq22
)
744 rinv23
= 1.0/sqrt
(rsq23
)
745 rinv31
= 1.0/sqrt
(rsq31
)
746 rinv32
= 1.0/sqrt
(rsq32
)
747 rinv33
= 1.0/sqrt
(rsq33
)
749 C Load parameters for j atom
752 C Coulomb reaction-field interaction
754 vcoul
= qq*
(rinv11
+krsq
-crf
)
757 C Calculate table index
760 C Calculate table index
767 C Tabulated VdW interaction - dispersion
770 Geps
= eps*VFtab
(nnn
+2)
771 Heps2
= eps2*VFtab
(nnn
+3)
776 C Tabulated VdW interaction - repulsion
780 Geps
= eps*VFtab
(nnn
+2)
781 Heps2
= eps2*VFtab
(nnn
+3)
785 Vvdwtot
= Vvdwtot
+ Vvdw6
+ Vvdw12
787 C Load parameters for j atom
790 C Coulomb reaction-field interaction
792 vcoul
= qq*
(rinv12
+krsq
-crf
)
795 C Load parameters for j atom
798 C Coulomb reaction-field interaction
800 vcoul
= qq*
(rinv13
+krsq
-crf
)
803 C Load parameters for j atom
806 C Coulomb reaction-field interaction
808 vcoul
= qq*
(rinv21
+krsq
-crf
)
811 C Load parameters for j atom
814 C Coulomb reaction-field interaction
816 vcoul
= qq*
(rinv22
+krsq
-crf
)
819 C Load parameters for j atom
822 C Coulomb reaction-field interaction
824 vcoul
= qq*
(rinv23
+krsq
-crf
)
827 C Load parameters for j atom
830 C Coulomb reaction-field interaction
832 vcoul
= qq*
(rinv31
+krsq
-crf
)
835 C Load parameters for j atom
838 C Coulomb reaction-field interaction
840 vcoul
= qq*
(rinv32
+krsq
-crf
)
843 C Load parameters for j atom
846 C Coulomb reaction-field interaction
848 vcoul
= qq*
(rinv33
+krsq
-crf
)
851 C Inner loop uses 182 flops/iteration
855 C Add i forces to mem and shifted force list
857 C Add potential energies to the group for this list
859 Vc
(ggid
) = Vc
(ggid
) + vctot
860 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
862 C Increment number of inner iterations
863 ninner
= ninner
+ nj1
- nj0
865 C Outer loop uses 11 flops/iteration
869 C Increment number of outer iterations
870 nouter
= nouter
+ nn1
- nn0
871 if(nn1
.lt
.nri
) goto 10
873 C Write outer/inner iteration count to pointers