working cluster for nano parameters
[unres.git] / source / cluster / wham / src-M / probabl.F
index 293fb8f..4af79ea 100644 (file)
       character*80 bxname
       character*2 licz1
       character*5 ctemper
-      integer ilen
+      integer ilen,ijk
       external ilen
-      real*4 Fdimless(maxconf)
-      double precision energia(0:max_ene)
+      real*4 Fdimless(maxconf), Fdimless_buf(maxconf)
+      double precision energia(0:max_ene), totfree_buf(0:maxconf),
+     &  entfac_buf(maxconf)
       do i=1,ncon
         list_conf(i)=i
       enddo
@@ -41,7 +42,8 @@ c      enddo
       write (iout,*) me," indstart",indstart(me)," indend",indend(me)
       call daread_ccoords(indstart(me),indend(me))
 #endif
-c      write (iout,*) "ncon",ncon
+C      write (iout,*) "ncon",ncon
+C      call flush(iout)
       temper=1.0d0/(beta_h(ib)*1.987D-3)
 c      write (iout,*) "ib",ib," beta_h",beta_h(ib)," temper",temper
 c      quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
@@ -53,6 +55,7 @@ c        quotl=quotl*quot
 c        kfacl=kfacl*kfac
 c        fT(l)=kfacl/(kfacl-1.0d0+quotl)
 c      enddo
+C#define DEBUG
             if (rescale_mode.eq.1) then
               quot=1.0d0/(T0*beta_h(ib)*1.987D-3)
               quotl=1.0d0
@@ -87,8 +90,8 @@ c      enddo
                 fT(l)=1.12692801104297249644d0/
      &             dlog(dexp(quotl)+dexp(-quotl))
               enddo
-c              write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
-c              call flush(iout)
+              write (iout,*) 1.0d0/(beta_h(ib)*1.987D-3),ft
+              call flush(iout)
 #if defined(FUNCTH)
               ft(6)=(320.0d0+80.0d0*dtanh((betaT-320.0d0)/80.0d0))/
      &                  320.0d0
@@ -113,36 +116,47 @@ c              call flush(iout)
       do i=1,ncon
         ii=i
 #endif
-c        write (iout,*) "i",i," ii",ii
-c        call flush(iout)
+C        write (iout,*) "i",i," ii",ii,"ib",ib,scount(me)
+        call flush(iout)
         if (ib.eq.1) then
           do j=1,nres
             do k=1,3
               c(k,j)=allcart(k,j,i)
               c(k,j+nres)=allcart(k,j+nres,i)
+C              write(iout,*) "coord",i,j,k,allcart(k,j,i),c(k,j),
+C     &        c(k,j+nres),allcart(k,j+nres,i)
             enddo
           enddo
+C          write(iout,*) "out of j loop"
+C          call flush(iout)
           do k=1,3
             c(k,nres+1)=c(k,1)
             c(k,nres+nres)=c(k,nres)
           enddo
+C          write(iout,*) "after nres+nres",nss_all(i)
+C          call flush(iout)
           nss=nss_all(i)
           do j=1,nss
             ihpb(j)=ihpb_all(j,i)
             jhpb(j)=jhpb_all(j,i)
           enddo 
           call int_from_cart1(.false.)
+C          write(iout,*) "before etotal"
+C          call flush(iout)
           call etotal(energia(0),fT)
           totfree(i)=energia(0)         
+          totfree_buf(i)=totfree(i)
 c          write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres)
 c          write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct)
 c          call enerprint(energia(0),fT)
 c          call pdbout(totfree(i),16,i)
+#define DEBUG
 #ifdef DEBUG
-          write (iout,*) i," energia",(energia(j),j=0,19)
+          write (iout,*) i," energia",(energia(j),j=0,max_ene)
           write (iout,*) "etot", etot
-          write (iout,*) "ft(6)", ft(6)
+          write (iout,*) "ft(6)", ft(6),energia(25)
 #endif
+#undef DEBUG
           do k=1,max_ene
             enetb(k,i)=energia(k)
           enddo
@@ -205,30 +219,54 @@ c#endif
         write (iout,*) "evdw2", wscp, evdw2
         write (iout,*) "welec", ft(1),welec,ees
         write (iout,*) "evdw1", wvdwpp,evdw1
-        write (iout,*) "ebe" ebe,wang
+        write (iout,*) "ebe", ebe,wang
 #endif        
         Fdimless(i)=beta_h(ib)*etot+entfac(ii)
+        Fdimless_buf(i)=Fdimless(i)
         totfree(i)=etot
+        totfree_buf(i)=totfree(i)
+#define DEBUG
 #ifdef DEBUG
         write (iout,*) "fdim calc", i,ii,ib,
      &   1.0d0/(1.987d-3*beta_h(ib)),totfree(i),
      &   entfac(ii),Fdimless(i)
 #endif
+#undef DEBUG
       enddo   ! i
+
+      do ijk=1,maxconf
+      entfac_buf(ijk)=entfac(ijk)
+      Fdimless_buf(ijk)=Fdimless(ijk)
+      enddo
+      do ijk=0,maxconf
+      totfree_buf(ijk)=totfree(ijk)
+      enddo
+
+
+c      scount_buf=scount(me)
+c      scount_buf2=scount(0)
+
+c      entfac_buf(indstart(me)+1)=entfac(indstart(me)+1)
+
 #ifdef MPI
-      call MPI_Gatherv(Fdimless(1),scount(me),
+      WRITE (iout,*) "Wchodze do call MPI_Gatherv1 (Propabl)"
+      call MPI_Gatherv(Fdimless_buf(1),scount(me),
      & MPI_REAL,Fdimless(1),
      & scount(0),idispl(0),MPI_REAL,Master,
      & MPI_COMM_WORLD, IERROR)
-      call MPI_Gatherv(totfree(1),scount(me),
+      WRITE (iout,*) "Wchodze do call MPI_Gatherv2 (Propabl)"
+      call MPI_Gatherv(totfree_buf(1),scount(me),
      & MPI_DOUBLE_PRECISION,totfree(1),
      & scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master,
      & MPI_COMM_WORLD, IERROR)
-      call MPI_Gatherv(entfac(indstart(me)+1),scount(me),
+      WRITE (iout,*) "Wchodze do call MPI_Gatherv3 (Propabl)"
+      call MPI_Gatherv(entfac_buf(indstart(me)+1),scount(me),
      & MPI_DOUBLE_PRECISION,entfac(1),
      & scount(0),idispl(0),MPI_DOUBLE_PRECISION,Master,
      & MPI_COMM_WORLD, IERROR)
+      WRITE (iout,*) "Wychodze z call MPI_Gatherv (Propabl)"
       if (me.eq.Master) then
+      WRITE (iout,*) "me.eq.Master"
 #endif
 #ifdef DEBUG
         write (iout,*) "The FDIMLESS array before sorting"
@@ -236,13 +274,16 @@ c#endif
 c          write (iout,*) i,fdimless(i)
         enddo
 #endif
+      WRITE (iout,*) "Wchodze do call mysort1"
         call mysort1(ncon,Fdimless,list_conf)
-#ifdef DEBUG
+      WRITE (iout,*) "Wychodze z call mysort1"
+C#ifdef DEBUG
         write (iout,*) "The FDIMLESS array after sorting"
         do i=1,ncon
           write (iout,*) i,list_conf(i),fdimless(i)
         enddo
-#endif
+c#endif
+      WRITE (iout,*) "Wchodze do petli i=1,ncon totfree(i)=fdimless(i)"
         do i=1,ncon
           totfree(i)=fdimless(i)
         enddo
@@ -257,12 +298,13 @@ c        write (iout,*) "qfree",qfree
         write (iout,*) "ncon", ncon,maxstr_proc
         do i=1,min0(ncon,maxstr_proc)-1 
           sumprob=sumprob+exp(-fdimless(i)+fdimless(1))/qfree 
-#ifdef DEBUG
+C#ifdef DEBUG
+          write (iout,*) "tu szukaj ponizej 7"
           write (iout,*) i,ib,beta_h(ib),
      &     1.0d0/(1.987d-3*beta_h(ib)),list_conf(i),
      &     totfree(list_conf(i)),
      &     -entfac(list_conf(i)),fdimless(i),sumprob
-#endif
+C#endif
           if (sumprob.gt.prob_limit) goto 122
 c          if (sumprob.gt.1.00d0) goto 122
           nlist=nlist+1