unres Adam's changes
[unres.git] / source / unres / src-HCD-5D / elecont.f
index 690fd44..7c024ea 100644 (file)
@@ -9,10 +9,10 @@
       include 'COMMON.NAMES'
       logical lprint
       double precision elpp_6(2,2),elpp_3(2,2),ael6_(2,2),ael3_(2,2)
-      double precision app_(2,2),bpp_(2,2),rpp_(2,2)
+      double precision app_(2,2),bpp_(2,2),epp_(2,2),rpp_(2,2)
       integer ncont,icont(2,maxcont)
       double precision econt(maxcont)
-      integer xshift,yshift,zshift
+      double precision boxshift
 *
 * Load the constants of peptide bond - peptide bond interactions.
 * Type 1 - ordinary peptide bond, type 2 - alkylated peptide bond (e.g.
@@ -20,7 +20,7 @@
 *
 * as of 7/06/91.
 *
-c      data epp    / 0.3045d0, 0.3649d0, 0.3649d0, 0.5743d0/
+c      data epp_    / 0.3045d0, 0.3649d0, 0.3649d0, 0.5743d0/
       data rpp_    / 4.5088d0, 4.5395d0, 4.5395d0, 4.4846d0/
       data elpp_6  /-0.2379d0,-0.2056d0,-0.2056d0,-0.0610d0/
       data elpp_3  / 0.0503d0, 0.0000d0, 0.0000d0, 0.0692d0/
@@ -53,13 +53,7 @@ c      data epp    / 0.3045d0, 0.3649d0, 0.3649d0, 0.5743d0/
         xmedi=xi+0.5*dxi
         ymedi=yi+0.5*dyi
         zmedi=zi+0.5*dzi
-c        write (iout,*) "i",xmedi,ymedi,zmedi
-          xmedi=mod(xmedi,boxxsize)
-          if (xmedi.lt.0) xmedi=xmedi+boxxsize
-          ymedi=mod(ymedi,boxysize)
-          if (ymedi.lt.0) ymedi=ymedi+boxysize
-          zmedi=mod(zmedi,boxzsize)
-          if (zmedi.lt.0) zmedi=zmedi+boxzsize
+        call to_box(xmedi,ymedi,zmedi)
 c        write (iout,*) "i",xmedi,ymedi,zmedi
         do 4 j=i+2,nct-1
 c          write (iout,*) "i",i," j",j
@@ -79,48 +73,12 @@ c          write (iout,*) "i",i," j",j
           xj=c(1,j)+0.5*dxj
           yj=c(2,j)+0.5*dyj
           zj=c(3,j)+0.5*dzj
+          call to_box(xj,yj,zj)
 c          write (iout,*) "j",xj,yj,zj
-          xj=mod(xj,boxxsize)
-          if (xj.lt.0) xj=xj+boxxsize
-          yj=mod(yj,boxysize)
-          if (yj.lt.0) yj=yj+boxysize
-          zj=mod(zj,boxzsize)
-          if (zj.lt.0) zj=zj+boxzsize
+          xj=boxshift(xj-xmedi,boxxsize)
+          yj=boxshift(yj-ymedi,boxysize)
+          zj=boxshift(zj-zmedi,boxzsize)
 c          write (iout,*) "j",xj,yj,zj
-      dist_init=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
-c      write (iout,*) "dist",dsqrt(dist_init)
-      xj_safe=xj
-      yj_safe=yj
-      zj_safe=zj
-      isubchap=0
-      do xshift=-1,1
-      do yshift=-1,1
-      do zshift=-1,1
-          xj=xj_safe+xshift*boxxsize
-          yj=yj_safe+yshift*boxysize
-          zj=zj_safe+zshift*boxzsize
-          dist_temp=(xj-xmedi)**2+(yj-ymedi)**2+(zj-zmedi)**2
-c          write (iout,*) "shift",xshift,yshift,zshift," dist_temp",
-c     &      dist_temp," dist_init",dist_init
-          if(dist_temp.lt.dist_init) then
-            dist_init=dist_temp
-            xj_temp=xj
-            yj_temp=yj
-            zj_temp=zj
-            isubchap=1
-          endif
-       enddo
-       enddo
-       enddo
-       if (isubchap.eq.1) then
-          xj=xj_temp-xmedi
-          yj=yj_temp-ymedi
-          zj=zj_temp-zmedi
-       else
-          xj=xj_safe-xmedi
-          yj=yj_safe-ymedi
-          zj=zj_safe-zmedi
-       endif
           rij=xj*xj+yj*yj+zj*zj
           rrmij=1.0/(xj*xj+yj*yj+zj*zj)
           rmij=sqrt(rrmij)
@@ -147,7 +105,7 @@ c     &      dist_temp," dist_init",dist_init
             econt(ncont)=eesij
           endif
           ees=ees+eesij
-c          write (iout,*) "i"," j",j," rij",dsqrt(rij)," eesij",eesij
+c          write (iout,*) "i",i," j",j," rij",dsqrt(rij)," eesij",eesij
     4   continue
     1 continue
       if (lprint) then
@@ -160,7 +118,7 @@ c          write (iout,*) "i"," j",j," rij",dsqrt(rij)," eesij",eesij
           i2=icont(2,i)
           it1=itype(i1)
           it2=itype(i2)
-          write (iout,'(i3,2x,a,i4,2x,a,i4,f10.5)')
+          write (iout,'(i7,2x,a,i6,2x,a,i6,f10.5)')
      &     i,restyp(it1),i1,restyp(it2),i2,econt(i)
         enddo
       endif
@@ -246,7 +204,7 @@ c              enddo
           i2=icont(2,i)
           it1=itype(i1)
           it2=itype(i2)
-          write (iout,'(i3,2x,a,i4,2x,a,i4,f10.5)')
+          write (iout,'(i7,2x,a,i6,2x,a,i6,f10.5)')
      &     i,restyp(it1),i1,restyp(it2),i2,econt(i)
         enddo
       endif
@@ -309,7 +267,7 @@ cd            write (iout,*) i1,j1,not_done
             ii1=max0(ii1-1,1)
             jj1=max0(jj1-1,1)
             nbeta=nbeta+1
-            if(lprint)write(iout,'(a,i3,4i4)')'parallel beta',
+            if(lprint)write(iout,'(a,i7,4i6)')'parallel beta',
      &               nbeta,ii1,i1,jj1,j1
 
             nbfrag=nbfrag+1
@@ -484,29 +442,29 @@ cd            write (iout,*) i1,j1,not_done
 
 
            if (lprint) then
-            write (iout,'(a,i3,4i4)')'antiparallel beta',
+            write (iout,'(a,i3,4i6)')'antiparallel beta',
      &                   nbeta,ii1-1,i1,jj1,j1-1
             nstrand=nstrand+1
             if (nstrand.le.9) then
-              write(12,'(a18,i1,a9,i3,a2,i3,a1)') 
+              write(12,'(a18,i1,a9,i6,a2,i6,a1)') 
      &          "DefPropRes 'strand",nstrand,
      &          "' 'num = ",ii1-2,"..",i1-1,"'"
             else
-              write(12,'(a18,i2,a9,i3,a2,i3,a1)') 
+              write(12,'(a18,i2,a9,i6,a2,i6,a1)') 
      &          "DefPropRes 'strand",nstrand,
      &          "' 'num = ",ii1-2,"..",i1-1,"'"
             endif
             nstrand=nstrand+1
             if (nstrand.le.9) then
-              write(12,'(a18,i1,a9,i3,a2,i3,a1)') 
+              write(12,'(a18,i1,a9,i6,a2,i6,a1)') 
      &          "DefPropRes 'strand",nstrand,
      &          "' 'num = ",j1-2,"..",jj1-1,"'"
             else
-              write(12,'(a18,i2,a9,i3,a2,i3,a1)') 
+              write(12,'(a18,i2,a9,i6,a2,i6,a1)') 
      &          "DefPropRes 'strand",nstrand,
      &          "' 'num = ",j1-2,"..",jj1-1,"'"
             endif
-              write(12,'(a8,4i4)')
+              write(12,'(a8,4i6)')
      &          "SetNeigh",ii1-2,i1-1,jj1-1,j1-2
            endif
           endif