adam's update
[unres.git] / source / unres / src-HCD-5D / unres.F
index 76bd280..f556eb6 100644 (file)
@@ -20,7 +20,7 @@ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
       include 'COMMON.GEO'
       include 'COMMON.HEADER'
       include 'COMMON.CONTROL'
-      include 'COMMON.CONTACTS'
+c      include 'COMMON.CONTACTS'
       include 'COMMON.CHAIN'
       include 'COMMON.VAR'
       include 'COMMON.IOUNITS'
@@ -73,8 +73,8 @@ c      write (iout,*) "After readrtns"
       call flush(iout)
 C
       if (modecalc.eq.-2) then
-        call test
-        stop
+c        call test
+c        stop
       else if (modecalc.eq.-1) then
         write(iout,*) "call check_sc_map next"
         call check_bond
@@ -199,7 +199,7 @@ c---------------------------------------------------------------------------
       include 'COMMON.GEO'
       include 'COMMON.HEADER'
       include 'COMMON.CONTROL'
-      include 'COMMON.CONTACTS'
+c      include 'COMMON.CONTACTS'
       include 'COMMON.CHAIN'
       include 'COMMON.VAR'
       include 'COMMON.IOUNITS'
@@ -217,6 +217,11 @@ c---------------------------------------------------------------------------
       double precision rms,frac,frac_nn,co
       double precision varia(maxvar)
       double precision time00,time1,time_ene,evals
+#ifdef LBFGS
+      character*9 status
+      integer niter
+      common /lbfgstat/ status,niter,nfun
+#endif
       integer ilen
       if (indpdb.eq.0)     call chainbuild
       if (indpdb.ne.0) then
@@ -269,10 +274,18 @@ c        print *,'after hairpin'
 c        print *,'after secondary'
       if (minim) then
 crc overlap test
+        if (indpdb.ne.0 .and. .not.dccart) then 
+          call bond_regular
+          call chainbuild_extconf
+          call etotal(energy(0))
+          write (iout,*) "After bond regularization"
+          call enerprint(energy(0))
+        endif
+
         if (overlapsc) then 
-          print *, 'Calling OVERLAP_SC'
+c          print *, 'Calling OVERLAP_SC'
           call overlap_sc(fail)
-          print *,"After overlap_sc"
+c          print *,"After overlap_sc"
         endif 
 
         if (searchsc) then 
@@ -290,12 +303,8 @@ crc overlap test
 #endif
           call minim_dc(etot,iretcode,nfun)
         else
-          if (indpdb.ne.0) then 
-            call bond_regular
-            call chainbuild_extconf
-          endif
           call geom_to_var(nvar,varia)
-          print *,'Calling MINIMIZE.'
+c          print *,'Calling MINIMIZE.'
 #ifdef MPI
           time1=MPI_WTIME()
 #else
@@ -303,7 +312,11 @@ crc overlap test
 #endif
           call minimize(etot,varia,iretcode,nfun)
         endif
+#ifdef LBFGS
+        print *,'LBFGS return code is',status,' eval ',nfun
+#else
         print *,'SUMSL return code is',iretcode,' eval ',nfun
+#endif
 #ifdef MPI
         evals=nfun/(MPI_WTIME()-time1)
 #else
@@ -327,9 +340,15 @@ crc overlap test
           call cartoutx(0.0d0)
         endif
         if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
+#ifdef LBFGS
+          write (iout,'(a,a9)') 'LBFGS return code:',status
+          write (iout,'(a,i20)') '# of energy evaluations:',nfun+1
+          write (iout,'(a,f16.3)')'# of energy evaluations/sec:',evals
+#else
           write (iout,'(a,i3)') 'SUMSL return code:',iretcode
           write (iout,'(a,i20)') '# of energy evaluations:',nfun+1
           write (iout,'(a,f16.3)')'# of energy evaluations/sec:',evals
+#endif
       else
         print *,'refstr=',refstr
         if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
@@ -353,7 +372,7 @@ c---------------------------------------------------------------------------
       include 'COMMON.GEO'
       include 'COMMON.HEADER'
       include 'COMMON.CONTROL'
-      include 'COMMON.CONTACTS'
+c      include 'COMMON.CONTACTS'
       include 'COMMON.CHAIN'
       include 'COMMON.VAR'
       include 'COMMON.IOUNITS'
@@ -364,6 +383,11 @@ c---------------------------------------------------------------------------
       double precision energy(0:n_ene)
       double precision etot,rms,frac,frac_nn,co
       integer iretcode
+#ifdef LBFGS
+      character*9 status
+      integer niter,nfun
+      common /lbfgstat/ status,niter,nfun
+#endif
 
       call gen_dist_constr
       call sc_conf
@@ -378,7 +402,11 @@ c---------------------------------------------------------------------------
       if (outpdb) call pdbout(etot,titel(:50),ipdb)
       if (outmol2) call mol2out(etot,titel(:32))
       if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
+#ifdef LBFGS
+      write (iout,'(a,a9)') 'LBFGS return code:',status
+#else
       write (iout,'(a,i3)') 'SUMSL return code:',iretcode
+#endif
       return
       end
 c---------------------------------------------------------------------------
@@ -440,7 +468,7 @@ c---------------------------------------------------------------------------
       include 'COMMON.GEO'
       include 'COMMON.HEADER'
       include 'COMMON.CONTROL'
-      include 'COMMON.CONTACTS'
+c      include 'COMMON.CONTACTS'
       include 'COMMON.CHAIN'
       include 'COMMON.VAR'
       include 'COMMON.IOUNITS'
@@ -739,7 +767,7 @@ c---------------------------------------------------------------------------
       include 'COMMON.GEO'
       include 'COMMON.HEADER'
       include 'COMMON.CONTROL'
-      include 'COMMON.CONTACTS'
+c      include 'COMMON.CONTACTS'
       include 'COMMON.CHAIN'
       include 'COMMON.VAR'
       include 'COMMON.IOUNITS'
@@ -825,7 +853,8 @@ c      enddo
       goto (10,20,30) icheckgrad
   10  call check_ecartint
       return
-  20  call check_cartgrad
+  20  write (iout,*) 
+     & "Checking the gradient of Cartesian coordinates disabled."
       return
   30  call check_eint
       return