the first working version of multichain homology
[unres.git] / source / wham / src-M / enecalc1.F
index 880664c..a2347d3 100644 (file)
@@ -47,6 +47,7 @@
       integer snk_p(MaxR,MaxT_h,Max_parm)
       logical lerr
       character*64 bprotfile_temp
+      integer scount_t(0:maxprocs-1)
       call opentmp(islice,ientout,bprotfile_temp)
       iii=0
       ii=0
@@ -60,6 +61,8 @@
           enddo
         enddo
       enddo
+      write (iout,*) "indstart(me1),indend(me1)"
+     &,indstart(me1),indend(me1)
       do i=indstart(me1),indend(me1)
 #else
       do iparm=1,nParmSet
@@ -155,13 +158,17 @@ c     &   " kfac",kfac,"quot",quot," fT",fT
      &      wtor_d,wsccor,wbond
 #endif
         call etotal(energia(0),fT)
+        if (constr_homology.gt.0) energia(0)=energia(0)+
+     &   waga_homology(iset)*energia(22)
+c        write (iout,*) "constr_homology",constr_homology," iset",iset,
+c     &   " waga_homology",waga_homology(iset)
 #ifdef DEBUG
         write (iout,*) "Conformation",i
           write (iout,'(8f10.5)') ((c(l,k),l=1,3),k=1,nres)
           write (iout,'(8f10.5)') ((c(l,k+nres),l=1,3),k=nnt,nct)
         call enerprint(energia(0),fT)
         write (iout,'(2i5,21f8.2)') i,iparm,(energia(k),k=1,21)
-        write (iout,*) "ftors",ftors
+        write (iout,*) "ftors(1)",ftors(1)
         call briefout(i,energia(0))
         temp=1.0d0/(beta_h(ib,ipar)*1.987D-3)
         write (iout,*) "temp", temp
@@ -220,7 +227,7 @@ c        call pdbout(ii+1,beta_h(ib,ipar),efree,energia(0),0.0d0,rmsdev)
             endif
           endif
           potE(iii+1,iparm)=energia(0)
-          do k=1,21
+          do k=1,22
             enetb(k,iii+1,iparm)=energia(k)
           enddo
 #ifdef DEBUG
@@ -273,8 +280,11 @@ c     &   " snk",snk_p(iR,ib,ipar)
       write (iout,*) "Me",me," scount",scount(me)
       call flush(iout)
 c  Master gathers updated numbers of conformations written by all procs.
-      call MPI_AllGather( scount(me), 1, MPI_INTEGER, scount(0), 1, 
+      call MPI_AllGather( scount(me), 1, MPI_INTEGER, scount_t(0), 1, 
      &  MPI_INTEGER, WHAM_COMM, IERROR)
+      do k=0,nprocs-1
+        scount(k) = scount_t(k)
+      enddo
       indstart(0)=1
       indend(0)=scount(0)
       do i=1, Nprocs-1
@@ -346,6 +356,7 @@ c------------------------------------------------------------------------------
       include "COMMON.ENERGIES"
       include "COMMON.COMPAR"
       include "COMMON.PROT"
+      include "COMMON.CONTACTS1"
       character*64 nazwa
       character*80 bxname,cxname
       character*64 bprotfile_temp
@@ -359,7 +370,8 @@ c------------------------------------------------------------------------------
       double precision energ
       integer ilen,iroof
       external ilen,iroof
-      integer ir,ib,iparm
+      integer ir,ib,iparm, scount_buff(0:99)
+      integer isecstr(maxres)
       write (licz2,'(bz,i2.2)') islice
       call opentmp(islice,ientout,bprotfile_temp)
       write (iout,*) "bprotfile_temp ",bprotfile_temp
@@ -458,8 +470,12 @@ c        write (iout,*) iR,ib,iparm,eini,efree
         iscore=0
 c        write (iout,*) "Calling conf_compar",i
 c        call flush(iout)
+         anatemp= 1.0d0/(beta_h(ib,iparm)*1.987D-3)
         if (indpdb.gt.0) then
           call conf_compar(i,.false.,.true.)
+c        else
+c            call elecont(.false.,ncont,icont,nnt,nct)
+c            call secondary2(.false.,.false.,ncont,icont,isecstr)
         endif
 c        write (iout,*) "Exit conf_compar",i
 c        call flush(iout)
@@ -659,8 +675,13 @@ c      write (iout,*) "xdrf3dfcoord"
 c      call flush(iout)
       call xdrfint_(ixdrf, nss, iret)
       do j=1,nss
-        call xdrfint_(ixdrf, ihpb(j), iret)
-        call xdrfint_(ixdrf, jhpb(j), iret)
+           if (dyn_ss) then
+            call xdrfint(ixdrf, idssb(j)+nres, iret)
+            call xdrfint(ixdrf, jdssb(j)+nres, iret)
+           else
+            call xdrfint_(ixdrf, ihpb(j), iret)
+            call xdrfint_(ixdrf, jhpb(j), iret)
+           endif
       enddo
       call xdrffloat_(ixdrf,real(eini),iret) 
       call xdrffloat_(ixdrf,real(efree),iret) 
@@ -671,8 +692,13 @@ c      call flush(iout)
 
       call xdrfint(ixdrf, nss, iret)
       do j=1,nss
-        call xdrfint(ixdrf, ihpb(j), iret)
-        call xdrfint(ixdrf, jhpb(j), iret)
+           if (dyn_ss) then
+            call xdrfint(ixdrf, idssb(j)+nres, iret)
+            call xdrfint(ixdrf, jdssb(j)+nres, iret)
+           else
+            call xdrfint(ixdrf, ihpb(j), iret)
+            call xdrfint(ixdrf, jhpb(j), iret)
+           endif
       enddo
       call xdrffloat(ixdrf,real(eini),iret) 
       call xdrffloat(ixdrf,real(efree),iret) 
@@ -716,8 +742,8 @@ c------------------------------------------------------------------------------
       endif
       call int_from_cart1(.false.)
       do j=nnt+1,nct
-        if (itype(j-1).ne.21 .and. itype(j).ne.21 .and. 
-     &    (vbld(j).lt.2.0d0 .or. vbld(j).gt.5.0d0)) then
+        if (itype(j-1).ne.ntyp1 .and. itype(j).ne.ntyp1 .and. 
+     &    (vbld(j).lt.2.0d0 .or. vbld(j).gt.6.0d0)) then
           if (iprint.gt.0) 
      &    write (iout,*) "Bad CA-CA bond length",j," ",vbld(j),
      &      " for conformation",ii
@@ -741,8 +767,8 @@ c------------------------------------------------------------------------------
       enddo
       do j=nnt,nct
         itj=itype(j)
-        if (itype(j).ne.10 .and.itype(j).ne.21 .and. 
-     &     (vbld(nres+j)-dsc(itj)).gt.2.0d0) then
+        if (itype(j).ne.10 .and.itype(j).ne.ntyp1 .and. 
+     &     (vbld(nres+j)-dsc(iabs(itj))).gt.5.0d0) then
           if (iprint.gt.0) 
      &    write (iout,*) "Bad CA-SC bond length",j," ",vbld(nres+j),
      &     " for conformation",ii