From 0b492fe3fe8f83ee34dfb920fd582da451ea0fa4 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sat, 3 Nov 2018 14:04:05 -0500 Subject: [PATCH] Removing progress_header. --- CMakeLists.txt | 1 - src/progress_header.F90 | 102 ---------------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 src/progress_header.F90 diff --git a/CMakeLists.txt b/CMakeLists.txt index fd0bbf457..3dd1b8b2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,7 +344,6 @@ add_library(libopenmc SHARED src/photon_physics.F90 src/physics_common.F90 src/physics.F90 - src/progress_header.F90 src/pugixml/pugixml_f.F90 src/random_lcg.F90 src/reaction_header.F90 diff --git a/src/progress_header.F90 b/src/progress_header.F90 deleted file mode 100644 index 5f462e0fa..000000000 --- a/src/progress_header.F90 +++ /dev/null @@ -1,102 +0,0 @@ -module progress_header - - use, intrinsic :: ISO_FORTRAN_ENV, only: OUTPUT_UNIT - - implicit none - -#ifdef UNIX - interface - function check_isatty(fd) bind(C, name = 'isatty') - use, intrinsic :: ISO_C_BINDING, only: c_int - integer(c_int) :: check_isatty - integer(c_int), value :: fd - end function check_isatty - end interface -#endif - -!=============================================================================== -! PROGRESSBAR -!=============================================================================== - - type ProgressBar - private - character(len=72) :: bar="???% | " // & - " |" - contains - procedure :: set_value => bar_set_value - end type ProgressBar - -contains - -!=============================================================================== -! IS_TERMINAL checks if output is currently being output to a terminal. Relies -! on a POSIX implementation of isatty, and defaults to false if that is not -! available -!=============================================================================== - - function is_terminal() result(istty) - logical :: istty - - istty = .true. - -#ifdef UNIX - if (check_isatty(1) == 0) istty = .false. -#else - istty = .false. -#endif - - end function is_terminal - -!=============================================================================== -! BAR_SET_VALUE prints the progress bar without advancing. The value is -! specified as percent completion, from 0 to 100. If the value is ever set to -! 100 or above, the bar is set to 100 and a newline is written. -!=============================================================================== - - subroutine bar_set_value(self, val) - - class(ProgressBar), intent(inout) :: self - real(8), intent(in) :: val - - integer :: i - - if (.not. is_terminal()) return - - ! set the percentage - if (val >= 100.) then - write(self % bar(1:3), "(I3)") 100 - else if (val <= 0.) then - write(self % bar(1:3), "(I3)") 0 - else - write(self % bar(1:3), "(I3)") int(val) - end if - - ! set the bar width - if (val >= 100.) then - do i=1,65 - write(self % bar(i+6:i+6), '(A)') '=' - end do - else - do i=1,int(dble(65)*val/100.) - write(self % bar(i+6:i+6), '(A)') '=' - end do - end if - - write(OUTPUT_UNIT, '(A1,A1,A72)', ADVANCE='no') '+', char(13), self % bar - flush(OUTPUT_UNIT) - - if (val >= 100.) then - - ! make new line - write(OUTPUT_UNIT, "(A)") "" - flush(OUTPUT_UNIT) - - ! reset the bar in case we want to use this instance again - self % bar = "???% | " // & - " |" - - end if - - end subroutine bar_set_value - -end module progress_header