multichain cleaning output
[unres.git] / source / unres / src_MD / minimize_p.F
index 902dde2..dbf9629 100644 (file)
@@ -24,7 +24,7 @@
       external func,gradient,fdum
       external func_restr,grad_restr
       logical not_done,change,reduce 
-      common /przechowalnia/ v
+c      common /przechowalnia/ v
 
       icall = 1
 
@@ -44,14 +44,14 @@ c     DO WHILE (NOT_DONE)
 * controls output                                                       
       iv(19)=2                                                          
 * selects output unit                                                   
-c     iv(21)=iout                                                       
       iv(21)=0
+      if (print_min_ini+print_min_stat+print_min_res.gt.0) iv(21)=iout
 * 1 means to print out result                                           
-      iv(22)=0                                                          
+      iv(22)=print_min_res
 * 1 means to print out summary stats                                    
-      iv(23)=0                                                          
+      iv(23)=print_min_stat
 * 1 means to print initial x and d                                      
-      iv(24)=0                                                          
+      iv(24)=print_min_ini
 * min val for v(radfac) default is 0.1                                  
       v(24)=0.1D0                                                       
 * max val for v(radfac) default is 4.0                                  
@@ -134,6 +134,7 @@ c----------------------------------------------------------------------------
       double precision z(maxres6),d_a_tmp(maxres6)
       double precision edum(0:n_ene),time_order(0:10)
       double precision Gcopy(maxres2,maxres2)
+      double precision e_tmp
       common /przechowalnia/ Gcopy
       integer icall /0/
 C Workers wait for variables and NF, and NFL from the boss 
@@ -229,12 +230,26 @@ c           call MATOUT2(my_ng_count,dimen3,maxres2,maxers2,ginv_block)
           call fricmat_mult(z,d_a_tmp)
         else if (iorder.eq.10) then
           call setup_fricmat
+        else if (iorder.eq.11) then
+c broadcast new value of iset
+          call MPI_Bcast(iset,1,MPI_INTEGER,king,FG_COMM,IERROR)
+        else if (iorder.eq.12) then
+c broadcast new value of iset and
+c calculate restraint homology energy and
+c sum it over FG_COMM
+          call MPI_Bcast(iset,1,MPI_INTEGER,king,FG_COMM,IERROR)
+          call e_modeller(e_tmp)
+          call MPI_Barrier(FG_COMM,IERR)
+          call MPI_Reduce(e_tmp,ehomology_constr,1,
+     &    MPI_DOUBLE_PRECISION,MPI_SUM,king,FG_COMM,IERR)
+        else if (iorder.eq.13) then
+          call chainbuild
         endif
       enddo
       write (*,*) 'Processor',fg_rank,' CG group',kolor,
      &  ' absolute rank',myrank,' leves ERGASTULUM.'
       write(*,*)'Processor',fg_rank,' wait times for respective orders',
-     & (' order[',i,']',time_order(i),i=0,10)
+     & (' order[',i,']',time_order(i),i=0,12)
       return
       end
 #endif
@@ -268,7 +283,7 @@ cd    write (iout,*) 'ETOTAL called from FUNC'
       f=energia(0)
 c     if (jjj.gt.0) then
 c       write (iout,'(10f8.3)') (rad2deg*x(i),i=1,n)
-c       write (iout,*) 'f=',etot
+c       write (iout,*) 'f=',f
 c       jjj=0
 c     endif
       return                                                            
@@ -416,7 +431,7 @@ c----------------------------------------------------------
       include 'COMMON.CHAIN'
       dimension iv(liv)                                               
       double precision minval,x(maxvar),d(maxvar),v(1:lv),xx(maxvar)
-      common /przechowalnia/ v
+c      common /przechowalnia/ v
 
       double precision energia(0:n_ene)
       external func_dc,grad_dc,fdum
@@ -435,14 +450,14 @@ c----------------------------------------------------------
 * controls output                                                       
       iv(19)=2                                                          
 * selects output unit                                                   
-c     iv(21)=iout                                                       
-       iv(21)=0
+      iv(21)=0
+      if (print_min_ini+print_min_stat+print_min_res.gt.0) iv(21)=iout 
 * 1 means to print out result                                           
-      iv(22)=0                                                         
+      iv(22)=print_min_res
 * 1 means to print out summary stats                                    
-      iv(23)=0                                                          
+      iv(23)=print_min_stat
 * 1 means to print initial x and d                                      
-      iv(24)=0                                                         
+      iv(24)=print_min_ini
 * min val for v(radfac) default is 0.1                                  
       v(24)=0.1D0                                                       
 * max val for v(radfac) default is 4.0                                  
@@ -483,6 +498,7 @@ c     v(25)=4.0D0
         endif
       enddo
 
+      call flush(iout)
       call sumsl(k,d,x,func_dc,grad_dc,iv,liv,lv,v,idum,rdum,fdum)      
 
       k=0