cmake pgf90
[unres.git] / source / wham / src / enecalc1.F
index 01e5684..397e0f3 100644 (file)
@@ -33,7 +33,8 @@
       double precision rmsnat,gyrate
       external rmsnat,gyrate
       double precision tole /1.0d-1/
-      integer i,itj,ii,iii,j,k,l,licz
+      integer i,itj,ii,iii,j,k,l,licz,scme,itmp
+      integer ires
       integer ir,ib,ipar,iparm
       integer iscor,islice
       real*4 csingle(3,maxres2)
@@ -45,7 +46,8 @@
       double precision tt
       integer snk_p(MaxR,MaxT_h,Max_parm)
       logical lerr
-      character*64 bprotfile_temp
+      character*128 bprotfile_temp
+      integer scount_t(0:maxprocs-1)
       call opentmp(islice,ientout,bprotfile_temp)
       iii=0
       ii=0
      &    ((csingle(l,k+nres),l=1,3),k=nnt,nct),
      &    nss,(ihpb(k),jhpb(k),k=1,nss),
      &    eini,efree,rmsdev,(q(j,iii+1),j=1,nQ),iR,ib,ipar
+#ifdef DEBUG
+        write (iout,*) "homol_nset",homol_nset,
+     &    "  i",i," iR",iR," ib",ib," iset",iset
+#endif
+        if (homol_nset.gt.1) iset=iR
+#ifdef DEBUG
+        write (iout,*) "homol_nset",homol_nset,
+     &    "  i",i," iR",iR," ib",ib," iset",iset
+#endif
 cc       write(iout,*), 'NAWEJ',i,eini
          if (indpdb.gt.0) then
            do k=1,nres
@@ -154,14 +165,25 @@ 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
         call enerprint(energia(0),fT)
 c        write (iout,'(2i5,21f8.2)') i,iparm,(energia(k),k=1,21)
 c        write (iout,*) "ftors",ftors
-c        call intout
+c      write (iout,'(a,3(3x,a5),5x,3(3x,a5))')
+c     & "Residue","X(CA)","Y(CA)","Z(CA)","X(SC)","Y(SC)","Z(SC)"
+c      do ires=1,nres
+c        write (iout,'(a3,1x,i3,3f8.3,5x,3f8.3)')
+c     &    restyp(itype(ires)),ires,(c(j,ires),j=1,3),
+c     &    (c(j,ires+nres),j=1,3)
+c      enddo
+        call intout
 #endif
-        if (energia(0).ge.1.0d20) then
+        if (energia(0).ge.1.0d6) then
           write (iout,*) "NaNs detected in some of the energy",
      &     " components for conformation",ii+1
           write (iout,*) "The Cartesian geometry is:"
@@ -195,11 +217,25 @@ c        call pdbout(ii+1,beta_h(ib,ipar),efree,energia(0),0.0d0,rmsdev)
      &         " the value read in: ",energia(0),eini," point",
      &         iii+1,indstart(me1)+iii," T",
      &         1.0d0/(1.987D-3*beta_h(ib,ipar))
+#define DEBUG
+#ifdef DEBUG
              call enerprint(energia(0),fT)
+#endif
+#undef DEBUG
+#ifdef DEBUG
+             write (iout,'(4f10.5,2i5)') 0.0,energia(0),0.0,
+     &       1.0d0/(beta_h(ib,ipar)*1.987D-3),
+     &       0,0
+             write(iout,'(8f10.5)')
+     &       ((c(l,k),l=1,3),k=1,nres),
+     &       ((c(l,k+nres),l=1,3),k=nnt,nct)
+             itmp=ipdb
+             ipdb=iout
              call pdbout(iii+1,beta_h(ib,ipar),
      &                   eini,energia(0),0.0d0,rmsdev)
              write (iout,*)
-
+             ipdb=itmp
+#endif
               errmsg_count=errmsg_count+1
               if (errmsg_count.gt.maxerrmsg_count) 
      &          write (iout,*) "Too many warning messages"
@@ -215,7 +251,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,max_ene
             enetb(k,iii+1,iparm)=energia(k)
           enddo
 c          write(iout,*) "iCHUJ TU STRZELI",i,iii,entfac(i)
@@ -273,8 +309,12 @@ 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, 
+      scme = scount(me)
+      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
@@ -348,7 +388,7 @@ c------------------------------------------------------------------------------
       include "COMMON.PROT"
       character*64 nazwa
       character*80 bxname,cxname
-      character*64 bprotfile_temp
+      character*128 bprotfile_temp
       character*3 liczba,licz
       character*2 licz2
       integer i,itj,ii,iii,j,k,l
@@ -485,7 +525,7 @@ c        else
 c     &    potE(i,iparm),-entfac(i),rms_nat,iscore
      &    potE(i,nparmset),-entfac(i),rms_nat,iscore
 c        endif
-        write (iout,'(2i5,3e15.5)') i,me,potE(i,iparm),-entfac(i)
+c        write (iout,'(2i5,3e15.5)') i,me,potE(i,iparm),-entfac(i)
 #ifndef MPI
         if (cxfile) call cxwrite(ixdrf,csingle,potE(i,nparmset),
      &    -entfac(i),rms_nat,iscore)