correction in tube for parallel code
[unres.git] / source / unres / src_MD-M / energy_p_new_barrier.F
index 51867aa..38efafa 100644 (file)
@@ -671,7 +671,26 @@ c      enddo
 
 
         enddo
-      enddo 
+      enddo
+      j=1
+      i=0
+      print *,"KUPA2",gradbufc(j,i),wsc*gvdwc(j,i),
+     &                wscp*gvdwc_scp(j,i),gvdwc_scpp(j,i),
+     &                welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i),
+     &                wel_loc*gel_loc_long(j,i),
+     &                wcorr*gradcorr_long(j,i),
+     &                wcorr5*gradcorr5_long(j,i),
+     &                wcorr6*gradcorr6_long(j,i),
+     &                wturn6*gcorr6_turn_long(j,i),
+     &                wstrain*ghpbc(j,i)
+     &                ,wliptran*gliptranc(j,i)
+     &                ,gradafm(j,i)
+     &                 ,welec*gshieldc(j,i)
+     &                 ,wcorr*gshieldc_ec(j,i)
+     &                 ,wturn3*gshieldc_t3(j,i)
+     &                 ,wturn4*gshieldc_t4(j,i)
+     &                 ,wel_loc*gshieldc_ll(j,i)
+     &                ,wtube*gg_tube(j,i) 
 #else
       do i=0,nct
         do j=1,3
@@ -726,7 +745,7 @@ c      call flush(iout)
 #ifdef TIMING
 c      time_allreduce=time_allreduce+MPI_Wtime()-time00
 #endif
-      do i=nnt,nres
+      do i=0,nres
         do k=1,3
           gradbufc(k,i)=0.0d0
         enddo
@@ -902,7 +921,42 @@ C          print *,gradafm(1,13),"AFM"
 
 
         enddo
-      enddo 
+      enddo
+C       i=0
+C       j=1
+C       print *,"KUPA",    gradbufc(j,i),welec*gelc(j,i),
+C     &                wel_loc*gel_loc(j,i),
+C     &                0.5d0*wscp*gvdwc_scpp(j,i),
+C     &                welec*gelc_long(j,i),wvdwpp*gvdwpp(j,i),
+C     &                wel_loc*gel_loc_long(j,i),
+C     &                wcorr*gradcorr_long(j,i),
+C     &                wcorr5*gradcorr5_long(j,i),
+C     &                wcorr6*gradcorr6_long(j,i),
+C     &                wturn6*gcorr6_turn_long(j,i),
+C     &                wbond*gradb(j,i),
+C     &                wcorr*gradcorr(j,i),
+C     &                wturn3*gcorr3_turn(j,i),
+C     &                wturn4*gcorr4_turn(j,i),
+C     &                wcorr5*gradcorr5(j,i),
+C     &                wcorr6*gradcorr6(j,i),
+C     &                wturn6*gcorr6_turn(j,i),
+C     &                wsccor*gsccorc(j,i)
+C     &               ,wscloc*gscloc(j,i)
+C     &               ,wliptran*gliptranc(j,i)
+C     &                ,gradafm(j,i)
+C     &                 +welec*gshieldc(j,i)
+C     &                 +welec*gshieldc_loc(j,i)
+C     &                 +wcorr*gshieldc_ec(j,i)
+C     &                 +wcorr*gshieldc_loc_ec(j,i)
+C     &                 +wturn3*gshieldc_t3(j,i)
+C     &                 +wturn3*gshieldc_loc_t3(j,i)
+C     &                 +wturn4*gshieldc_t4(j,i)
+C     &                 ,wturn4*gshieldc_loc_t4(j,i)
+C     &                 ,wel_loc*gshieldc_ll(j,i)
+C     &                 ,wel_loc*gshieldc_loc_ll(j,i)
+C     &                ,wtube*gg_tube(j,i)
+
+C      print *,gg_tube(1,0),"TU3" 
 #ifdef DEBUG
       write (iout,*) "gloc before adding corr"
       do i=1,4*nres
@@ -954,7 +1008,7 @@ c#undef DEBUG
         call MPI_Barrier(FG_COMM,IERR)
         time_barrier_g=time_barrier_g+MPI_Wtime()-time00
         time00=MPI_Wtime()
-        call MPI_Reduce(gradbufc(1,1),gradc(1,1,icg),3*nres,
+        call MPI_Reduce(gradbufc(1,0),gradc(1,0,icg),3*nres+3,
      &    MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
         call MPI_Reduce(gradbufx(1,1),gradx(1,1,icg),3*nres,
      &    MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
@@ -12096,13 +12150,14 @@ C simple Kihara potential
       include 'COMMON.SBRIDGE'
       double precision tub_r,vectube(3),enetube(maxres*2)
       Etube=0.0d0
-      do i=1,2*nres
+      do i=itube_start,itube_end
         enetube(i)=0.0d0
+        enetube(i+nres)=0.0d0
       enddo
 C first we calculate the distance from tube center
 C first sugare-phosphate group for NARES this would be peptide group 
 C for UNRES
-      do i=1,nres
+       do i=itube_start,itube_end
 C lets ommit dummy atoms for now
        if ((itype(i).eq.ntyp1).or.(itype(i+1).eq.ntyp1)) cycle
 C now calculate distance from center of tube and direction vectors
@@ -12163,7 +12218,10 @@ C now direction of gg_tube vector
         enddo
         enddo
 C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
-        do i=1,nres
+C        print *,gg_tube(1,0),"TU"
+
+
+       do i=itube_start,itube_end
 C Lets not jump over memory as we use many times iti
          iti=itype(i)
 C lets ommit dummy atoms for now
@@ -12224,8 +12282,8 @@ C now direction of gg_tube vector
           gg_tube(j,i-1)=gg_tube(j,i-1)+vectube(j)*fac
          enddo
         enddo
-        do i=1,2*nres
-          Etube=Etube+enetube(i)
+        do i=itube_start,itube_end
+          Etube=Etube+enetube(i)+enetube(i+nres)
         enddo
 C        print *,"ETUBE", etube
         return
@@ -12265,13 +12323,14 @@ C simple Kihara potential
       include 'COMMON.SBRIDGE'
       double precision tub_r,vectube(3),enetube(maxres*2)
       Etube=0.0d0
-      do i=1,2*nres
+      do i=itube_start,itube_end
         enetube(i)=0.0d0
+        enetube(i+nres)=0.0d0
       enddo
 C first we calculate the distance from tube center
 C first sugare-phosphate group for NARES this would be peptide group 
 C for UNRES
-      do i=1,nres
+       do i=itube_start,itube_end
 C lets ommit dummy atoms for now
        
        if ((itype(i).eq.ntyp1).or.(itype(i+1).eq.ntyp1)) cycle
@@ -12316,7 +12375,8 @@ C now direction of gg_tube vector
         enddo
         enddo
 C basically thats all code now we split for side-chains (REMEMBER to sum up at the END)
-        do i=1,nres
+C        print *,gg_tube(1,0),"TU"
+        do i=itube_start,itube_end
 C Lets not jump over memory as we use many times iti
          iti=itype(i)
 C lets ommit dummy atoms for now
@@ -12411,8 +12471,8 @@ C now direction of gg_tube vector
      &+ssgradtube*enetube(i+nres)/sstube
 
         enddo
-        do i=1,2*nres
-          Etube=Etube+enetube(i)
+        do i=itube_start,itube_end
+          Etube=Etube+enetube(i)+enetube(i+nres)
         enddo
 C        print *,"ETUBE", etube
         return