adding contact map
[unres4.git] / source / unres / MD.F90
index c902d0b..e3aea93 100644 (file)
 !el      external ilen
       character(len=50) :: tytul
 !el      common /gucio/ cm
-      integer :: itime,i,j,nharp
+      integer :: i,j,nharp
       integer,dimension(4,nres/3) :: iharp     !(4,nres/3)(4,maxres/3)
 !      logical :: ovrtim
       real(kind=8) :: tt0,scalfac
-      integer :: nres2
+      integer :: nres2,itime
       nres2=2*nres
       print *, "ENTER MD"
 !
           stop
 #endif
         endif
+        itime_mat=itime
         if (ntwe.ne.0) then
          if (mod(itime,ntwe).eq.0) then
             call statout(itime)
       use comm_gucio
       use control, only:tcpu
       use control_data
+      use minimm, only:minim_dc
 #ifdef MPI
       include 'mpif.h'
       integer :: ierror,ierrcode
 !el      common /gucio/ cm
 !el      real(kind=8),dimension(6*nres) :: stochforcvec        !(MAXRES6) maxres6=6*maxres
 !el      common /stochcalc/ stochforcvec
-      integer :: itime,icount_scale,itime_scal,i,j,ifac_time
+      integer :: icount_scale,itime_scal,i,j,ifac_time,iretcode,itime
       logical :: scalel
       real(kind=8) :: epdrift,tt0,fac_time
 !
         call etotal(potEcomp)
 ! AL 4/17/17: Reduce the steps if NaNs occurred.
         if (potEcomp(0).gt.0.99e18 .or. isnan(potEcomp(0)).gt.0) then
+          call enerprint(potEcomp)
           d_time=d_time/10.0
-!          write (iout,*) "Tu jest problem",potEcomp(0),d_time
-          call gen_rand_conf(1,*335)
-          cycle
-  335     write(iout,*) "Failed genrand"
+          if (icount_scale.gt.15) then
+          write (iout,*) "Tu jest problem",potEcomp(0),d_time
+!          call gen_rand_conf(1,*335)
+!          call minim_dc(potEcomp(0),iretcode,100)
+
+!          call zerograd
+!          call etotal(potEcomp)
+!          write(iout,*) "needed to repara,",potEcomp
+          endif
           cycle
+!  335     write(iout,*) "Failed genrand"
+!          cycle
         endif
 ! end change
         if (large.and. mod(itime,ntwe).eq.0) &
 !el      common /gucio/ cm
 !el      real(kind=8),dimension(6*nres) :: stochforcvec        !(MAXRES6) maxres6=6*maxres
 !el      common /stochcalc/ stochforcvec
-      integer :: itime,itt,i,j,itsplit
+      integer :: itt,i,j,itsplit,itime
       logical :: scale
 !el      common /cipiszcze/ itt
 
       character(len=50) :: tytul
       logical :: file_exist
 !el      common /gucio/ cm
-      integer :: i,j,ipos,iq,iw,nft_sc,iretcode,nfun,itime,ierr,mnum
+      integer :: i,j,ipos,iq,iw,nft_sc,iretcode,nfun,ierr,mnum,itime
       real(kind=8) :: etot,tt0
       logical :: fail
 
       potE=potEcomp(0)-potEcomp(20)
       totE=EK+potE
       itime=0
+      itime_mat=itime
       if (ntwe.ne.0) call statout(itime)
       if(me.eq.king.or..not.out1file) &
         write (iout,'(/a/3(a25,1pe14.5/))') "Initial:", &