From a609d60bc1a8147a915fc52d5026dc1b06ffd845 Mon Sep 17 00:00:00 2001 From: Leandro Martinez Date: Fri, 25 Oct 2024 11:50:50 -0300 Subject: [PATCH] improve the progress bar printing --- src/ahestetic.f90 | 38 +++++++++++++++++++++++++++++--------- src/gencan.f | 30 ++++-------------------------- src/heuristics.f90 | 2 +- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/ahestetic.f90 b/src/ahestetic.f90 index ed231f6..2ffa68d 100644 --- a/src/ahestetic.f90 +++ b/src/ahestetic.f90 @@ -2,20 +2,40 @@ ! Written by Leandro Martínez, 2009-2011. ! Copyright (c) 2009-2018, Leandro Martínez, Jose Mario Martinez, ! Ernesto G. Birgin. -! +! ! Module that contains some ahestetic output definitions ! module ahestetic - character(len=13), parameter :: dash1_line = "( 80('-') )",& - dash2_line = "(/,80('-') )",& - dash3_line = "(/,80('-'),/)" + character(len=13), parameter :: dash1_line = "( 80('-') )",& + dash2_line = "(/,80('-') )",& + dash3_line = "(/,80('-'),/)" - character(len=13), parameter :: hash1_line = "( 80('#') )",& - hash2_line = "(/,80('#') )",& - hash3_line = "(/,80('#'),/)" + character(len=13), parameter :: hash1_line = "( 80('#') )",& + hash2_line = "(/,80('#') )",& + hash3_line = "(/,80('#'),/)" - character(len=31), parameter :: prog1_line = "(' Packing:|0 ',tr60,'100%|' )",& - prog2_line = "(' Moving:|0 ',tr60,'100%|' )" + character(len=31), parameter :: prog1_line = "(' Packing:|0 ',tr55,'100%|' )",& + prog2_line = "(' Moving:|0 ',tr55,'100%|' )" end module ahestetic + + +subroutine printbar(iprint, iter, maxit) + integer :: iter, maxit + itprint = 60 / (maxit) + if( iprint .ge. 2 ) then + if( iter.eq.0) then + write(*,"(' |')",advance='no') + else if(iter.eq.maxit) then + do i = itprint*(maxit-1), 60 + write(*,"('*')", advance='no') + end do + write(*,"('|')") + else + do i = 1, itprint + write(*,"('*')", advance='no') + end do + end if + end if +end subroutine printbar diff --git a/src/gencan.f b/src/gencan.f index 13a2fff..389a284 100644 --- a/src/gencan.f +++ b/src/gencan.f @@ -1855,20 +1855,8 @@ subroutine gencan(n,x,l,u,m,lambda,rho,epsgpen,epsgpsn,maxitnfp, C Print initial information - if( iprint .ge. 2 ) then -c LM: output for packmol -c write(*,1003) iter,f,gpsupn - if((mod((iter-1),10).eq.0.or.iter.eq.0).and.iter.ne.1) then - write(*,778) - else if(mod(iter,10).eq.0) then - write(*,779) - else if(iter.ne.1) then - write(*,777) - end if - end if -777 format('*******',$) -778 format(' |',$) -779 format('**********|') +c LM: progress bar for packmol + call printbar(iprint, iter, maxit) if( iprint .ge. 3 ) then write(*, 981) iter @@ -2421,18 +2409,8 @@ subroutine gencan(n,x,l,u,m,lambda,rho,epsgpen,epsgpsn,maxitnfp, end do C Print information of this iteration - - if( iprint .ge. 2 ) then -c Output for packmol -c write(*, 1003) iter,f,gpsupn - if((mod((iter-1),10).eq.0.or.iter.eq.0).and.iter.ne.1) then - write(*,778) - else if(mod(iter,10).eq.0) then - write(*,779) - else if(iter.ne.1) then - write(*,777) - end if - end if +c LM: progress bar for packmol + call printbar(iprint, iter, maxit) if ( iprint .ge. 3 ) then write(*, 983) iter,ittype diff --git a/src/heuristics.f90 b/src/heuristics.f90 index c24a3dc..fb434ee 100644 --- a/src/heuristics.f90 +++ b/src/heuristics.f90 @@ -130,7 +130,7 @@ subroutine movebad(n,x,fx,movebadprint) x(ilugan+2) = x(ilugan2+2) x(ilugan+3) = x(ilugan2+3) call restmol(itype,ilubar,n,x,fx,.true.) - do while( j <= 65.d0*i/nmove ) + do while( j <= 60*i/nmove ) write(*,"('*',$)") j = j + 1 end do