Adam's lipid and dfa corrections
[unres.git] / source / unres / src-HCD-5D / unres.F
index be40e75..978fa59 100644 (file)
@@ -59,7 +59,8 @@ c      call memmon_print_usage()
 C Read force field parameters and job setup data
       call readrtns
 C
-c      write (iout,*) "After readrtns"
+      write (iout,*) "After readrtns"
+      call flush(iout)
       call cartprint
       call intout
       if (me.eq.king .or. .not. out1file) then
@@ -86,9 +87,14 @@ C Fine-grain slaves just do energy and gradient components.
         call ergastulum ! slave workhouse in Latin
       else
 #endif
+      if (indpdb.eq.0 .and. .not.read_cart) call chainbuild
+      if (indpdb.ne.0 .or. read_cart) then
+        dc(1,0)=c(1,1)
+        dc(2,0)=c(2,1)
+        dc(3,0)=c(3,1)
+      endif
       if (modecalc.eq.0) then
         write (iout,*) "Calling exec_eeval_or_minim"
-        call cartprint
         call exec_eeval_or_minim
       else if (modecalc.eq.1) then
         call exec_regularize
@@ -223,8 +229,8 @@ c      include 'COMMON.CONTACTS'
       common /lbfgstat/ status,niter,nfun
 #endif
       integer ilen
-      if (indpdb.eq.0)     call chainbuild
-      if (indpdb.ne.0) then
+      if (indpdb.eq.0 .and. .not.read_cart) call chainbuild
+      if (indpdb.ne.0 .or. read_cart) then
       dc(1,0)=c(1,1)
       dc(2,0)=c(2,1)
       dc(3,0)=c(3,1)
@@ -331,16 +337,7 @@ c          print *,'Calling MINIMIZE.'
         call etotal(energy(0))
         etot = energy(0)
         call enerprint(energy(0))
-
         call intout
-        if (out_int) call briefout(0,etot)
-        if (out_cart) then
-          cartname=prefix(:ilen(prefix))//'.x'
-          potE=etot
-          call cartoutx(0.0d0)
-        endif
-        if (outpdb) call pdbout(etot,titel(:50),ipdb)
-        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
@@ -350,10 +347,13 @@ c          print *,'Calling MINIMIZE.'
           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.)
-        call briefout(0,etot)
+      endif
+      if (refstr) call rms_nac_nnc(rms,frac,frac_nn,co,.true.)
+      if (out_int) call briefout(0,etot)
+      if (out_cart) then
+        cartname=prefix(:ilen(prefix))//'.x'
+        potE=etot
+        call cartoutx(0.0d0)
       endif
       if (outpdb) call pdbout(etot,titel(:50),ipdb)
       if (outmol2) call mol2out(etot,titel(:32))