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 f77dkernel214
33 C Coulomb interaction: Reaction field
34 C VdW interaction: Lennard-Jones
35 C water optimization: pairs of TIP4P interactions
36 C Calculate forces: yes
38 subroutine f77dkernel214
(
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
91 real*8 ix1
,iy1
,iz1
,fix1
,fiy1
,fiz1
92 real*8 ix2
,iy2
,iz2
,fix2
,fiy2
,fiz2
93 real*8 ix3
,iy3
,iz3
,fix3
,fiy3
,fiz3
94 real*8 ix4
,iy4
,iz4
,fix4
,fiy4
,fiz4
96 real*8 jx2
,jy2
,jz2
,fjx2
,fjy2
,fjz2
97 real*8 jx3
,jy3
,jz3
,fjx3
,fjy3
,fjz3
98 real*8 jx4
,jy4
,jz4
,fjx4
,fjy4
,fjz4
99 real*8 dx11
,dy11
,dz11
,rsq11
100 real*8 dx22
,dy22
,dz22
,rsq22
,rinv22
101 real*8 dx23
,dy23
,dz23
,rsq23
,rinv23
102 real*8 dx24
,dy24
,dz24
,rsq24
,rinv24
103 real*8 dx32
,dy32
,dz32
,rsq32
,rinv32
104 real*8 dx33
,dy33
,dz33
,rsq33
,rinv33
105 real*8 dx34
,dy34
,dz34
,rsq34
,rinv34
106 real*8 dx42
,dy42
,dz42
,rsq42
,rinv42
107 real*8 dx43
,dy43
,dz43
,rsq43
,rinv43
108 real*8 dx44
,dy44
,dz44
,rsq44
,rinv44
109 real*8 qH
,qM
,qqMM
,qqMH
,qqHH
113 C Initialize water data
120 tj
= 2*(ntype
+1)*type
(ii
)+1
125 C Reset outer and inner iteration counters
129 C Loop over thread workunits
130 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
131 if(nn1
.gt
.nri
) nn1
=nri
133 C Start outer loop over neighborlists
137 C Load shift vector for this list
140 shY
= shiftvec
(is3
+1)
141 shZ
= shiftvec
(is3
+2)
143 C Load limits for loop over neighbors
147 C Get outer coordinate index
151 C Load i atom data, add shift vector
152 ix1
= shX
+ pos
(ii3
+0)
153 iy1
= shY
+ pos
(ii3
+1)
154 iz1
= shZ
+ pos
(ii3
+2)
155 ix2
= shX
+ pos
(ii3
+3)
156 iy2
= shY
+ pos
(ii3
+4)
157 iz2
= shZ
+ pos
(ii3
+5)
158 ix3
= shX
+ pos
(ii3
+6)
159 iy3
= shY
+ pos
(ii3
+7)
160 iz3
= shZ
+ pos
(ii3
+8)
161 ix4
= shX
+ pos
(ii3
+9)
162 iy4
= shY
+ pos
(ii3
+10)
163 iz4
= shZ
+ pos
(ii3
+11)
165 C Zero the potential energy for this list
169 C Clear i atom forces
185 C Get j neighbor index, and coordinate index
189 C load j atom coordinates
207 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
211 rsq22
= dx22*dx22
+dy22*dy22
+dz22*dz22
215 rsq23
= dx23*dx23
+dy23*dy23
+dz23*dz23
219 rsq24
= dx24*dx24
+dy24*dy24
+dz24*dz24
223 rsq32
= dx32*dx32
+dy32*dy32
+dz32*dz32
227 rsq33
= dx33*dx33
+dy33*dy33
+dz33*dz33
231 rsq34
= dx34*dx34
+dy34*dy34
+dz34*dz34
235 rsq42
= dx42*dx42
+dy42*dy42
+dz42*dz42
239 rsq43
= dx43*dx43
+dy43*dy43
+dz43*dz43
243 rsq44
= dx44*dx44
+dy44*dy44
+dz44*dz44
245 C Calculate 1/r and 1/r2
247 rinv22
= 1.0/sqrt
(rsq22
)
248 rinv23
= 1.0/sqrt
(rsq23
)
249 rinv24
= 1.0/sqrt
(rsq24
)
250 rinv32
= 1.0/sqrt
(rsq32
)
251 rinv33
= 1.0/sqrt
(rsq33
)
252 rinv34
= 1.0/sqrt
(rsq34
)
253 rinv42
= 1.0/sqrt
(rsq42
)
254 rinv43
= 1.0/sqrt
(rsq43
)
255 rinv44
= 1.0/sqrt
(rsq44
)
257 C Load parameters for j atom
259 C Lennard-Jones interaction
260 rinvsix
= rinvsq*rinvsq*rinvsq
262 Vvdw12
= c12*rinvsix*rinvsix
263 Vvdwtot
= Vvdwtot
+Vvdw12
-Vvdw6
264 fscal
= (12.0*Vvdw12
-6.0*Vvdw6
)*rinvsq
266 C Calculate temporary vectorial force
271 C Increment i atom force
276 C Decrement j atom force
277 faction
(j3
+0) = faction
(j3
+0) - tx
278 faction
(j3
+1) = faction
(j3
+1) - ty
279 faction
(j3
+2) = faction
(j3
+2) - tz
281 C Load parameters for j atom
283 rinvsq
= rinv22*rinv22
285 C Coulomb reaction-field interaction
287 vcoul
= qq*
(rinv22
+krsq
-crf
)
289 fscal
= (qq*
(rinv22
-2.0*krsq
))*rinvsq
291 C Calculate temporary vectorial force
296 C Increment i atom force
301 C Decrement j atom force
302 fjx2
= faction
(j3
+3) - tx
303 fjy2
= faction
(j3
+4) - ty
304 fjz2
= faction
(j3
+5) - tz
306 C Load parameters for j atom
308 rinvsq
= rinv23*rinv23
310 C Coulomb reaction-field interaction
312 vcoul
= qq*
(rinv23
+krsq
-crf
)
314 fscal
= (qq*
(rinv23
-2.0*krsq
))*rinvsq
316 C Calculate temporary vectorial force
321 C Increment i atom force
326 C Decrement j atom force
327 fjx3
= faction
(j3
+6) - tx
328 fjy3
= faction
(j3
+7) - ty
329 fjz3
= faction
(j3
+8) - tz
331 C Load parameters for j atom
333 rinvsq
= rinv24*rinv24
335 C Coulomb reaction-field interaction
337 vcoul
= qq*
(rinv24
+krsq
-crf
)
339 fscal
= (qq*
(rinv24
-2.0*krsq
))*rinvsq
341 C Calculate temporary vectorial force
346 C Increment i atom force
351 C Decrement j atom force
352 fjx4
= faction
(j3
+9) - tx
353 fjy4
= faction
(j3
+10) - ty
354 fjz4
= faction
(j3
+11) - tz
356 C Load parameters for j atom
358 rinvsq
= rinv32*rinv32
360 C Coulomb reaction-field interaction
362 vcoul
= qq*
(rinv32
+krsq
-crf
)
364 fscal
= (qq*
(rinv32
-2.0*krsq
))*rinvsq
366 C Calculate temporary vectorial force
371 C Increment i atom force
376 C Decrement j atom force
381 C Load parameters for j atom
383 rinvsq
= rinv33*rinv33
385 C Coulomb reaction-field interaction
387 vcoul
= qq*
(rinv33
+krsq
-crf
)
389 fscal
= (qq*
(rinv33
-2.0*krsq
))*rinvsq
391 C Calculate temporary vectorial force
396 C Increment i atom force
401 C Decrement j atom force
406 C Load parameters for j atom
408 rinvsq
= rinv34*rinv34
410 C Coulomb reaction-field interaction
412 vcoul
= qq*
(rinv34
+krsq
-crf
)
414 fscal
= (qq*
(rinv34
-2.0*krsq
))*rinvsq
416 C Calculate temporary vectorial force
421 C Increment i atom force
426 C Decrement j atom force
431 C Load parameters for j atom
433 rinvsq
= rinv42*rinv42
435 C Coulomb reaction-field interaction
437 vcoul
= qq*
(rinv42
+krsq
-crf
)
439 fscal
= (qq*
(rinv42
-2.0*krsq
))*rinvsq
441 C Calculate temporary vectorial force
446 C Increment i atom force
451 C Decrement j atom force
452 faction
(j3
+3) = fjx2
- tx
453 faction
(j3
+4) = fjy2
- ty
454 faction
(j3
+5) = fjz2
- tz
456 C Load parameters for j atom
458 rinvsq
= rinv43*rinv43
460 C Coulomb reaction-field interaction
462 vcoul
= qq*
(rinv43
+krsq
-crf
)
464 fscal
= (qq*
(rinv43
-2.0*krsq
))*rinvsq
466 C Calculate temporary vectorial force
471 C Increment i atom force
476 C Decrement j atom force
477 faction
(j3
+6) = fjx3
- tx
478 faction
(j3
+7) = fjy3
- ty
479 faction
(j3
+8) = fjz3
- tz
481 C Load parameters for j atom
483 rinvsq
= rinv44*rinv44
485 C Coulomb reaction-field interaction
487 vcoul
= qq*
(rinv44
+krsq
-crf
)
489 fscal
= (qq*
(rinv44
-2.0*krsq
))*rinvsq
491 C Calculate temporary vectorial force
496 C Increment i atom force
501 C Decrement j atom force
502 faction
(j3
+9) = fjx4
- tx
503 faction
(j3
+10) = fjy4
- ty
504 faction
(j3
+11) = fjz4
- tz
506 C Inner loop uses 366 flops/iteration
510 C Add i forces to mem and shifted force list
511 faction
(ii3
+0) = faction
(ii3
+0) + fix1
512 faction
(ii3
+1) = faction
(ii3
+1) + fiy1
513 faction
(ii3
+2) = faction
(ii3
+2) + fiz1
514 faction
(ii3
+3) = faction
(ii3
+3) + fix2
515 faction
(ii3
+4) = faction
(ii3
+4) + fiy2
516 faction
(ii3
+5) = faction
(ii3
+5) + fiz2
517 faction
(ii3
+6) = faction
(ii3
+6) + fix3
518 faction
(ii3
+7) = faction
(ii3
+7) + fiy3
519 faction
(ii3
+8) = faction
(ii3
+8) + fiz3
520 faction
(ii3
+9) = faction
(ii3
+9) + fix4
521 faction
(ii3
+10) = faction
(ii3
+10) + fiy4
522 faction
(ii3
+11) = faction
(ii3
+11) + fiz4
523 fshift
(is3
) = fshift
(is3
)+fix1
+fix2
+fix3
+fix4
524 fshift
(is3
+1) = fshift
(is3
+1)+fiy1
+fiy2
+fiy3
+fiy4
525 fshift
(is3
+2) = fshift
(is3
+2)+fiz1
+fiz2
+fiz3
+fiz4
527 C Add potential energies to the group for this list
529 Vc
(ggid
) = Vc
(ggid
) + vctot
530 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
532 C Increment number of inner iterations
533 ninner
= ninner
+ nj1
- nj0
535 C Outer loop uses 38 flops/iteration
539 C Increment number of outer iterations
540 nouter
= nouter
+ nn1
- nn0
541 if(nn1
.lt
.nri
) goto 10
543 C Write outer/inner iteration count to pointers
555 C Gromacs nonbonded kernel f77dkernel214nf
556 C Coulomb interaction: Reaction field
557 C VdW interaction: Lennard-Jones
558 C water optimization: pairs of TIP4P interactions
559 C Calculate forces: no
561 subroutine f77dkernel214nf
(
594 integer*4 nri
,iinr
(*),jindex
(*),jjnr
(*),shift
(*)
595 real*8 shiftvec
(*),fshift
(*),pos
(*),faction
(*)
596 integer*4 gid
(*),type
(*),ntype
597 real*8 charge
(*),facel
,krf
,crf
,Vc
(*),vdwparam
(*)
598 real*8 Vvdw
(*),tabscale
,VFtab
(*)
599 real*8 invsqrta
(*),dvda
(*),gbtabscale
,GBtab
(*)
600 integer*4 nthreads
,count
,mtx
,outeriter
,inneriter
603 integer*4 n
,ii
,is3
,ii3
,k
,nj0
,nj1
,jnr
,j3
,ggid
604 integer*4 nn0
,nn1
,nouter
,ninner
607 real*8 qq
,vcoul
,vctot
621 real*8 dx11
,dy11
,dz11
,rsq11
622 real*8 dx22
,dy22
,dz22
,rsq22
,rinv22
623 real*8 dx23
,dy23
,dz23
,rsq23
,rinv23
624 real*8 dx24
,dy24
,dz24
,rsq24
,rinv24
625 real*8 dx32
,dy32
,dz32
,rsq32
,rinv32
626 real*8 dx33
,dy33
,dz33
,rsq33
,rinv33
627 real*8 dx34
,dy34
,dz34
,rsq34
,rinv34
628 real*8 dx42
,dy42
,dz42
,rsq42
,rinv42
629 real*8 dx43
,dy43
,dz43
,rsq43
,rinv43
630 real*8 dx44
,dy44
,dz44
,rsq44
,rinv44
631 real*8 qH
,qM
,qqMM
,qqMH
,qqHH
635 C Initialize water data
642 tj
= 2*(ntype
+1)*type
(ii
)+1
647 C Reset outer and inner iteration counters
651 C Loop over thread workunits
652 10 call f77kernelsync
(mtx
,count
,nri
,nthreads
,nn0
,nn1
)
653 if(nn1
.gt
.nri
) nn1
=nri
655 C Start outer loop over neighborlists
659 C Load shift vector for this list
662 shY
= shiftvec
(is3
+1)
663 shZ
= shiftvec
(is3
+2)
665 C Load limits for loop over neighbors
669 C Get outer coordinate index
673 C Load i atom data, add shift vector
674 ix1
= shX
+ pos
(ii3
+0)
675 iy1
= shY
+ pos
(ii3
+1)
676 iz1
= shZ
+ pos
(ii3
+2)
677 ix2
= shX
+ pos
(ii3
+3)
678 iy2
= shY
+ pos
(ii3
+4)
679 iz2
= shZ
+ pos
(ii3
+5)
680 ix3
= shX
+ pos
(ii3
+6)
681 iy3
= shY
+ pos
(ii3
+7)
682 iz3
= shZ
+ pos
(ii3
+8)
683 ix4
= shX
+ pos
(ii3
+9)
684 iy4
= shY
+ pos
(ii3
+10)
685 iz4
= shZ
+ pos
(ii3
+11)
687 C Zero the potential energy for this list
691 C Clear i atom forces
695 C Get j neighbor index, and coordinate index
699 C load j atom coordinates
717 rsq11
= dx11*dx11
+dy11*dy11
+dz11*dz11
721 rsq22
= dx22*dx22
+dy22*dy22
+dz22*dz22
725 rsq23
= dx23*dx23
+dy23*dy23
+dz23*dz23
729 rsq24
= dx24*dx24
+dy24*dy24
+dz24*dz24
733 rsq32
= dx32*dx32
+dy32*dy32
+dz32*dz32
737 rsq33
= dx33*dx33
+dy33*dy33
+dz33*dz33
741 rsq34
= dx34*dx34
+dy34*dy34
+dz34*dz34
745 rsq42
= dx42*dx42
+dy42*dy42
+dz42*dz42
749 rsq43
= dx43*dx43
+dy43*dy43
+dz43*dz43
753 rsq44
= dx44*dx44
+dy44*dy44
+dz44*dz44
755 C Calculate 1/r and 1/r2
757 rinv22
= 1.0/sqrt
(rsq22
)
758 rinv23
= 1.0/sqrt
(rsq23
)
759 rinv24
= 1.0/sqrt
(rsq24
)
760 rinv32
= 1.0/sqrt
(rsq32
)
761 rinv33
= 1.0/sqrt
(rsq33
)
762 rinv34
= 1.0/sqrt
(rsq34
)
763 rinv42
= 1.0/sqrt
(rsq42
)
764 rinv43
= 1.0/sqrt
(rsq43
)
765 rinv44
= 1.0/sqrt
(rsq44
)
767 C Load parameters for j atom
769 C Lennard-Jones interaction
770 rinvsix
= rinvsq*rinvsq*rinvsq
772 Vvdw12
= c12*rinvsix*rinvsix
773 Vvdwtot
= Vvdwtot
+Vvdw12
-Vvdw6
775 C Load parameters for j atom
778 C Coulomb reaction-field interaction
780 vcoul
= qq*
(rinv22
+krsq
-crf
)
783 C Load parameters for j atom
786 C Coulomb reaction-field interaction
788 vcoul
= qq*
(rinv23
+krsq
-crf
)
791 C Load parameters for j atom
794 C Coulomb reaction-field interaction
796 vcoul
= qq*
(rinv24
+krsq
-crf
)
799 C Load parameters for j atom
802 C Coulomb reaction-field interaction
804 vcoul
= qq*
(rinv32
+krsq
-crf
)
807 C Load parameters for j atom
810 C Coulomb reaction-field interaction
812 vcoul
= qq*
(rinv33
+krsq
-crf
)
815 C Load parameters for j atom
818 C Coulomb reaction-field interaction
820 vcoul
= qq*
(rinv34
+krsq
-crf
)
823 C Load parameters for j atom
826 C Coulomb reaction-field interaction
828 vcoul
= qq*
(rinv42
+krsq
-crf
)
831 C Load parameters for j atom
834 C Coulomb reaction-field interaction
836 vcoul
= qq*
(rinv43
+krsq
-crf
)
839 C Load parameters for j atom
842 C Coulomb reaction-field interaction
844 vcoul
= qq*
(rinv44
+krsq
-crf
)
847 C Inner loop uses 226 flops/iteration
851 C Add i forces to mem and shifted force list
853 C Add potential energies to the group for this list
855 Vc
(ggid
) = Vc
(ggid
) + vctot
856 Vvdw
(ggid
) = Vvdw
(ggid
) + Vvdwtot
858 C Increment number of inner iterations
859 ninner
= ninner
+ nj1
- nj0
861 C Outer loop uses 14 flops/iteration
865 C Increment number of outer iterations
866 nouter
= nouter
+ nn1
- nn0
867 if(nn1
.lt
.nri
) goto 10
869 C Write outer/inner iteration count to pointers