Changeset 1468 for palm/trunk/SOURCE/progress_bar.f90
- Timestamp:
- Sep 24, 2014 2:06:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/progress_bar.f90
r1402 r1468 20 20 ! Current revisions: 21 21 ! ----------------- 22 ! 22 ! Added support for progress file PROGRESS which is used in case of batch jobs 23 23 ! 24 24 ! Former revisions: … … 28 28 ! Description: 29 29 ! ------------ 30 ! CPU-time measurements for any program part whatever. Results of the 30 ! This routine prints either a progress bar on the standard output in case of 31 ! interactive runs, or it prints the progress in a separate file called 32 ! PROGRESS. 31 33 !------------------------------------------------------------------------------! 32 34 33 35 USE control_parameters, & 34 ONLY : end_time, simulated_time, simulated_time_at_begin, time_restart 36 ONLY : end_time, run_identifier, simulated_time, & 37 simulated_time_at_begin, time_restart 35 38 36 USE, INTRINSIC :: ISO_FORTRAN_ENV, &39 USE, INTRINSIC :: ISO_FORTRAN_ENV, & 37 40 ONLY : OUTPUT_UNIT 38 41 … … 60 63 61 64 SUBROUTINE init_progress_bar 65 !------------------------------------------------------------------------------! 66 ! Description: 67 ! ------------ 68 ! Initialize the progress bar/file 69 !------------------------------------------------------------------------------! 62 70 63 71 IMPLICIT NONE … … 74 82 ENDIF 75 83 76 bar = '____________________________________________________________' 77 crosses = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' 84 IF ( batch_job ) THEN 85 86 CALL check_open ( 117 ) 87 WRITE ( 117, FMT='(A20,/)' ) run_identifier 88 89 ELSE 90 bar = '____________________________________________________________' 91 crosses = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' 78 92 ! 79 !-- Line feed on stdout to seperate the progress bar from previous messages80 WRITE ( OUTPUT_UNIT, '(1X)' )93 !-- Line feed on stdout to seperate the progress bar from previous messages 94 WRITE ( OUTPUT_UNIT, '(1X)' ) 81 95 #if defined( __intel_compiler ) 82 96 ! 83 !-- The Intel compiler does not allow to immediately flush the output buffer84 !-- in case that option ADVANCE='NO' is used in the write statement.85 !-- A workaround is to set a special carriage control feature and use "+" as86 !-- first output character, but this non-standard and only available with the87 !-- Intel compiler88 OPEN ( OUTPUT_UNIT, CARRIAGECONTROL='FORTRAN' )97 !-- The Intel compiler does not allow to immediately flush the output buffer 98 !-- in case that option ADVANCE='NO' is used in the write statement. 99 !-- A workaround is to set a special carriage control feature and use "+" as 100 !-- first output character, but this non-standard and only available with the 101 !-- Intel compiler 102 OPEN ( OUTPUT_UNIT, CARRIAGECONTROL='FORTRAN' ) 89 103 #endif 104 105 ENDIF 106 90 107 initialized = .TRUE. 91 108 … … 97 114 ! Description: 98 115 ! ------------ 99 ! 116 ! Print progress data to standard output (interactive) or to file (batch jobs) 100 117 !------------------------------------------------------------------------------! 101 118 … … 104 121 REAL(wp) :: remaining_time_in_percent !: remaining time to be simulated 105 122 !: in the job 123 REAL(wp) :: remaining_time_in_percent_total !: total remaining time of 124 !: the job chain 125 126 IF ( .NOT. initialized ) CALL init_progress_bar 127 128 129 remaining_time_in_percent = & 130 ( simulated_time - simulated_time_at_begin ) / time_to_be_simulated 131 132 remaining_time_in_percent_total = ( simulated_time / end_time ) 106 133 107 134 ! 108 !-- Porgress bar does not make sense in batch mode (and also ADVANCE=no does 109 !-- not properly work in batch mode on Cray XC30) 110 IF ( batch_job ) RETURN 135 !-- In batch mode, use a file (PROGRESS), otherwise use progress bar 136 IF ( batch_job ) THEN 111 137 112 IF ( .NOT. initialized ) CALL init_progress_bar 138 BACKSPACE ( 117 ) 139 WRITE ( 117, FMT='(F5.2,1X,F5.2)' ) remaining_time_in_percent, & 140 remaining_time_in_percent_total 141 CALL local_flush( 117 ) 142 143 ELSE 144 113 145 ! 114 !-- Calculate length of progress bar115 remaining_time_in_percent = &116 ( simulated_time - simulated_time_at_begin ) / time_to_be_simulated146 !-- Calculate length of progress bar 147 ilength = remaining_time_in_percent * 60.0_wp 148 ilength = MIN( ilength, 60 ) 117 149 118 ilength = remaining_time_in_percent * 60.0_wp 119 ilength = MIN( ilength, 60 ) 120 121 bar(1:ilength) = crosses(1:ilength) 150 bar(1:ilength) = crosses(1:ilength) 122 151 123 152 #if defined( __intel_compiler ) 124 WRITE ( OUTPUT_UNIT, '(A,6X,''['',A,''] '',F5.1,'' left'')' ) & 125 '+', bar, & 126 MAX( 0.0_wp, ( 1.0_wp - remaining_time_in_percent ) * 100.0_wp ) 153 WRITE ( OUTPUT_UNIT, '(A,6X,''['',A,''] '',F5.1,'' left'')' ) & 154 '+', bar, & 155 MAX( 0.0_wp, ( 1.0_wp - remaining_time_in_percent ) * & 156 100.0_wp ) 127 157 #else 128 WRITE ( OUTPUT_UNIT, '(A,6X,''['',A,''] '',F5.1,'' left'')', & 129 ADVANCE='NO' ) CHAR( 13 ), bar, & 130 MAX( 0.0_wp, ( 1.0_wp - remaining_time_in_percent ) * 100.0_wp ) 158 WRITE ( OUTPUT_UNIT, '(A,6X,''['',A,''] '',F5.1,'' left'')', & 159 ADVANCE='NO' ) CHAR( 13 ), bar, & 160 MAX( 0.0_wp, ( 1.0_wp - remaining_time_in_percent ) * & 161 100.0_wp ) 131 162 #endif 132 CALL local_flush( OUTPUT_UNIT ) 163 CALL local_flush( OUTPUT_UNIT ) 164 165 ENDIF 133 166 134 167 END SUBROUTINE output_progress_bar 135 168 136 169 SUBROUTINE finish_progress_bar 170 !------------------------------------------------------------------------------! 171 ! Description: 172 ! ------------ 173 ! Finalization of the progress bar/file 174 !------------------------------------------------------------------------------! 137 175 138 176 IMPLICIT NONE 139 177 140 IF ( batch_job ) RETURN178 IF ( batch_job ) THEN 141 179 180 CALL close_file ( 117 ) 181 182 ELSE 183 142 184 #if defined( __intel_compiler ) 143 185 ! 144 !-- Reset to the default carriage control145 OPEN ( OUTPUT_UNIT, CARRIAGECONTROL='LIST' )186 !-- Reset to the default carriage control 187 OPEN ( OUTPUT_UNIT, CARRIAGECONTROL='LIST' ) 146 188 #endif 147 189 ! 148 !-- Line feed when simulation has finished 149 WRITE ( OUTPUT_UNIT, '(1X)' ) 190 !-- Line feed when simulation has finished 191 WRITE ( OUTPUT_UNIT, '(1X)' ) 192 193 ENDIF 150 194 151 195 END SUBROUTINE finish_progress_bar 152 196 197 153 198 END MODULE progress_bar
Note: See TracChangeset
for help on using the changeset viewer.