working gradient for cations
[unres4.git] / source / unres / compare.F90
index 75a9bce..45ed3e5 100644 (file)
       logical :: lprint
 !el local variables
       real(kind=8) :: co,rcomp
-      integer :: kkk,i,j,i1,i2,it1,it2,iti,itj
+      integer :: kkk,i,j,i1,i2,it1,it2,iti,itj,inum,jnum
 
       ncont=0
       kkk=3
       do i=nnt+kkk,nct
         iti=iabs(itype(i,molnum(i)))
+        if (molnum(i).lt.3) then
+                inum=i+nres
+        else
+                inum=i
+        endif
+
         do j=nnt,i-kkk
           itj=iabs(itype(j,molnum(i)))
+        if (molnum(j).lt.3) then
+                jnum=j+nres
+        else
+                jnum=j
+        endif
           if (ipot.ne.4) then
 !           rcomp=sigmaii(iti,itj)+1.0D0
             rcomp=facont*sigmaii(iti,itj)
@@ -58,7 +69,7 @@
           endif
 !         rcomp=6.5D0
 !         print *,'rcomp=',rcomp,' dist=',dist(nres+i,nres+j)
-         if (dist(nres+i,nres+j).lt.rcomp) then
+         if (dist(inum,jnum).lt.rcomp) then
             ncont=ncont+1
             icont(1,ncont)=i
             icont(2,ncont)=j
       do i=nnt,nct
         if (itype(i,1).ne.10) then
 !d        print *,'i=',i,' itype=',itype(i,1),' theta=',theta(i+1)  
-          call gen_side(itype(i,1),theta(i+1),alph(i),omeg(i),fail)
+          call gen_side(itype(i,1),theta(i+1),alph(i),omeg(i),fail,1)
         endif
       enddo
       call chainbuild
         alph0=alph(ind_sc)
         omeg0=omeg(ind_sc)
         call gen_side(itype(ind_sc,1),theta(ind_sc+1),alph(ind_sc),&
-             omeg(ind_sc),fail)
+             omeg(ind_sc),fail,1)
         call chainbuild
         call etotal(energia)
 !d      write (iout,'(a,i5,a,i4,2(a,f8.3),2(a,1pe14.5))')