[1] | 1 | PROGRAM compare_palm_logs |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
| 4 | ! Actual revisions: |
---|
| 5 | ! ----------------- |
---|
| 6 | ! |
---|
| 7 | ! |
---|
| 8 | ! Former revisions: |
---|
| 9 | ! ----------------- |
---|
| 10 | ! |
---|
| 11 | ! Description: |
---|
| 12 | ! ------------ |
---|
| 13 | ! This routine compares the log files from two different PALM runs. |
---|
| 14 | ! |
---|
| 15 | ! This routine must be compiled with: |
---|
| 16 | ! decalpha: |
---|
| 17 | ! f95 -cpp -fast -r8 |
---|
| 18 | ! IBM-Regatta: |
---|
| 19 | ! xlf95 -qsuffix=cpp=f90 -qrealsize=8 -q64 -qmaxmem=-1 -Q -O3 |
---|
| 20 | ! IMUK: |
---|
| 21 | ! ifort compare...f90 -o compare...x |
---|
| 22 | ! -cpp -axW -r8 -nbs -Vaxlib |
---|
| 23 | ! NEC-SX6: |
---|
| 24 | ! sxf90 compare...f90 -o compare...x |
---|
| 25 | ! -C hopt -Wf '-A idbl4' |
---|
| 26 | !------------------------------------------------------------------------------! |
---|
| 27 | |
---|
| 28 | IMPLICIT NONE |
---|
| 29 | |
---|
| 30 | ! |
---|
| 31 | !-- Local variables |
---|
| 32 | CHARACTER (LEN=5) :: id_char |
---|
| 33 | CHARACTER (LEN=80), DIMENSION(2) :: directory, log_message |
---|
| 34 | CHARACTER (LEN=100), DIMENSION(2) :: filename |
---|
| 35 | |
---|
| 36 | INTEGER :: count=0, i, id, i1(2), i2(2), j, j1(2), j2(2), k, k1(2), k2(2), & |
---|
| 37 | n_err, n_files(2) |
---|
| 38 | |
---|
| 39 | LOGICAL :: found |
---|
| 40 | |
---|
| 41 | REAL :: simtime(2) |
---|
| 42 | |
---|
| 43 | INTEGER, DIMENSION(:,:), ALLOCATABLE :: array_2d_i_1, array_2d_i_2 |
---|
| 44 | |
---|
| 45 | REAL, DIMENSION(:,:), ALLOCATABLE :: array_2d_1, array_2d_2 |
---|
| 46 | REAL, DIMENSION(:,:,:), ALLOCATABLE :: array_1, array_2 |
---|
| 47 | |
---|
| 48 | directory(1) = 'const_log/' |
---|
| 49 | directory(2) = 'const_log.1/' |
---|
| 50 | |
---|
| 51 | ! |
---|
| 52 | !-- Check, if file from PE0 exists on directory 1. Stop, if it does not exist. |
---|
| 53 | n_files(1) = 0 |
---|
| 54 | |
---|
| 55 | WRITE (id_char,'(''_'',I4.4)') n_files(1) |
---|
| 56 | INQUIRE ( FILE=TRIM( directory(1) )//id_char, EXIST=found ) |
---|
| 57 | ! |
---|
| 58 | !-- Find out the number of files (equal to the number of PEs which |
---|
| 59 | !-- have been used in PALM) and open them |
---|
| 60 | DO WHILE ( found ) |
---|
| 61 | |
---|
| 62 | OPEN ( n_files(1)+100, FILE=TRIM( directory(1) )//id_char, & |
---|
| 63 | FORM='UNFORMATTED' ) |
---|
| 64 | n_files(1) = n_files(1) + 1 |
---|
| 65 | WRITE (id_char,'(''_'',I4.4)') n_files(1) |
---|
| 66 | INQUIRE ( FILE=TRIM( directory(1) )//id_char, EXIST=found ) |
---|
| 67 | |
---|
| 68 | ENDDO |
---|
| 69 | |
---|
| 70 | IF ( n_files(1) == 0 ) THEN |
---|
| 71 | PRINT*, '+++ no file _0000 in directory "', TRIM( directory(1) ), '"' |
---|
| 72 | STOP |
---|
| 73 | ELSE |
---|
| 74 | PRINT*, '*** directory "', TRIM( directory(1) ), '": ', n_files(1), & |
---|
| 75 | ' files found' |
---|
| 76 | ENDIF |
---|
| 77 | |
---|
| 78 | ! |
---|
| 79 | !-- Same for the second directory |
---|
| 80 | n_files(2) = 0 |
---|
| 81 | |
---|
| 82 | WRITE (id_char,'(''_'',I4.4)') n_files(2) |
---|
| 83 | INQUIRE ( FILE=TRIM( directory(2) )//id_char, EXIST=found ) |
---|
| 84 | |
---|
| 85 | DO WHILE ( found ) |
---|
| 86 | |
---|
| 87 | OPEN ( n_files(2)+200, FILE=TRIM( directory(2) )//id_char, & |
---|
| 88 | FORM='UNFORMATTED' ) |
---|
| 89 | n_files(2) = n_files(2) + 1 |
---|
| 90 | WRITE (id_char,'(''_'',I4.4)') n_files(2) |
---|
| 91 | INQUIRE ( FILE=TRIM( directory(2) )//id_char, EXIST=found ) |
---|
| 92 | |
---|
| 93 | ENDDO |
---|
| 94 | |
---|
| 95 | ! |
---|
| 96 | !-- Number of files must be identical |
---|
| 97 | IF ( n_files(1) /= n_files(2) ) THEN |
---|
| 98 | PRINT*, '+++ file number mismatch' |
---|
| 99 | PRINT*, ' ', TRIM( directory(1) ), ': ', n_files(1), ' files' |
---|
| 100 | PRINT*, ' ', TRIM( directory(2) ), ': ', n_files(2), ' files' |
---|
| 101 | STOP |
---|
| 102 | ENDIF |
---|
| 103 | |
---|
| 104 | ! |
---|
| 105 | !-- Compare the data file by file |
---|
| 106 | DO id = 0, n_files(1)-1 |
---|
| 107 | |
---|
| 108 | count = 0 |
---|
| 109 | |
---|
| 110 | WRITE (filename(1),'(A,''_'',I4.4)') TRIM( directory(1) ), id |
---|
| 111 | WRITE (filename(2),'(A,''_'',I4.4)') TRIM( directory(2) ), id |
---|
| 112 | |
---|
| 113 | PRINT*, '*** comparing files "', TRIM( filename(1) ),'" "', & |
---|
| 114 | TRIM( filename(2) ), '"' |
---|
| 115 | DO |
---|
| 116 | PRINT*,' ' |
---|
| 117 | READ ( id+100, END=100 ) log_message(1) |
---|
| 118 | PRINT*,' --- ', TRIM( log_message(1) ) |
---|
| 119 | READ ( id+200, END=900 ) log_message(2) |
---|
| 120 | |
---|
| 121 | IF ( TRIM( log_message(1) ) /= TRIM( log_message(2) ) ) THEN |
---|
| 122 | PRINT*,' +++ log message on file 2 does not match:' |
---|
| 123 | PRINT*,' ', TRIM( log_message(2) ) |
---|
| 124 | ENDIF |
---|
| 125 | |
---|
| 126 | count = count + 1 |
---|
| 127 | IF ( log_message(1)(1:2) == '3d' ) THEN |
---|
| 128 | PRINT*,' *** reading 3d array' |
---|
| 129 | READ ( id+100, END=901 ) simtime(1), i1(1), i2(1), j1(1), j2(1), & |
---|
| 130 | k1(1), k2(1) |
---|
| 131 | PRINT*,' time=', simtime(1) |
---|
| 132 | PRINT*,' array size=(',i1(1),':',i2(1), & |
---|
| 133 | ',',j1(1),':',j2(1),',',k1(1),':',k2(1),')' |
---|
| 134 | READ ( id+200, END=902 ) simtime(2), i1(2), i2(2), j1(2), j2(2), & |
---|
| 135 | k1(2), k2(2) |
---|
| 136 | IF ( simtime(1) /= simtime(2) .OR. i1(1) /= i1(2) .OR. & |
---|
| 137 | i2(1) /= i2(2) .OR. j1(1) /= j1(2) .OR. j2(1) /= j2(2) .OR. & |
---|
| 138 | k1(1) /= k1(2) .OR. k2(1) /= k2(2) ) THEN |
---|
| 139 | PRINT*,' +++ time/indices on file 2 does not match:' |
---|
| 140 | PRINT*,' time=', simtime(2) |
---|
| 141 | PRINT*,' array size=(',i1(2),':', & |
---|
| 142 | i2(2), ',',j1(2),':',j2(2),',',k1(2),':',k2(2),')' |
---|
| 143 | STOP |
---|
| 144 | ENDIF |
---|
| 145 | |
---|
| 146 | ALLOCATE( array_1(i1(1):i2(1),j1(1):j2(1),k1(1):k2(1)), & |
---|
| 147 | array_2(i1(2):i2(2),j1(2):j2(2),k1(2):k2(2)) ) |
---|
| 148 | |
---|
| 149 | READ ( id+100, END=903 ) array_1 |
---|
| 150 | READ ( id+200, END=904 ) array_2 |
---|
| 151 | |
---|
| 152 | n_err = 0 |
---|
| 153 | loop: DO k = k1(1), k2(1) |
---|
| 154 | loop1: DO j = j1(1), j2(1) |
---|
| 155 | DO i = i1(1), i2(1) |
---|
| 156 | IF ( array_1(i,j,k) /= array_2(i,j,k) ) THEN |
---|
| 157 | PRINT*,'+++ data mismatch on element (',i,',',j,',',k,')' |
---|
| 158 | PRINT*,' array_1: ', array_1(i,j,k) |
---|
| 159 | PRINT*,' array_2: ', array_2(i,j,k) |
---|
| 160 | n_err = n_err + 1 |
---|
| 161 | IF ( n_err > 5 ) EXIT loop |
---|
| 162 | ENDIF |
---|
| 163 | ENDDO |
---|
| 164 | ENDDO loop1 |
---|
| 165 | ENDDO loop |
---|
| 166 | |
---|
| 167 | DEALLOCATE( array_1, array_2 ) |
---|
| 168 | |
---|
| 169 | ELSEIF ( log_message(1)(1:2) == '2d' ) THEN |
---|
| 170 | PRINT*,' *** reading 2d array' |
---|
| 171 | READ ( id+100, END=901 ) simtime(1), i1(1), i2(1), j1(1), j2(1) |
---|
| 172 | PRINT*,' time=', simtime(1) |
---|
| 173 | PRINT*,' array size=(',i1(1),':',i2(1), & |
---|
| 174 | ',',j1(1),':',j2(1),')' |
---|
| 175 | READ ( id+200, END=902 ) simtime(2), i1(2), i2(2), j1(2), j2(2) |
---|
| 176 | IF ( simtime(1) /= simtime(2) .OR. i1(1) /= i1(2) .OR. & |
---|
| 177 | i2(1) /= i2(2) .OR. j1(1) /= j1(2) .OR. j2(1) /= j2(2) ) THEN |
---|
| 178 | PRINT*,' +++ time/indices on file 2 does not match:' |
---|
| 179 | PRINT*,' time=', simtime(2) |
---|
| 180 | PRINT*,' array size=(',i1(2),':', & |
---|
| 181 | i2(2), ',',j1(2),':',j2(2),')' |
---|
| 182 | ENDIF |
---|
| 183 | |
---|
| 184 | ALLOCATE( array_2d_1(i1(1):i2(1),j1(1):j2(1)), & |
---|
| 185 | array_2d_2(i1(2):i2(2),j1(2):j2(2)) ) |
---|
| 186 | |
---|
| 187 | READ ( id+100, END=903 ) array_2d_1 |
---|
| 188 | READ ( id+200, END=904 ) array_2d_2 |
---|
| 189 | |
---|
| 190 | IF ( i1(1) /= i1(2) ) i1(1) = i1(2) |
---|
| 191 | IF ( i2(1) /= i2(2) ) i2(1) = i2(2) |
---|
| 192 | IF ( j1(1) /= j1(2) ) j1(1) = j1(2) |
---|
| 193 | IF ( j2(1) /= j2(2) ) j2(1) = j2(2) |
---|
| 194 | |
---|
| 195 | n_err = 0 |
---|
| 196 | loop2: DO j = j1(1), j2(1) |
---|
| 197 | DO i = i1(1), i2(1) |
---|
| 198 | IF ( array_2d_1(i,j) /= array_2d_2(i,j) ) THEN |
---|
| 199 | PRINT*,'+++ data mismatch on element (',i,',',j,')' |
---|
| 200 | PRINT*,' array_1: ', array_2d_1(i,j) |
---|
| 201 | PRINT*,' array_2: ', array_2d_2(i,j) |
---|
| 202 | n_err = n_err + 1 |
---|
| 203 | IF ( n_err > 5 ) EXIT loop2 |
---|
| 204 | ENDIF |
---|
| 205 | ENDDO |
---|
| 206 | ENDDO loop2 |
---|
| 207 | |
---|
| 208 | DEALLOCATE( array_2d_1, array_2d_2 ) |
---|
| 209 | |
---|
| 210 | ELSE |
---|
| 211 | PRINT*,' *** reading 2d int array' |
---|
| 212 | READ ( id+100, END=901 ) simtime(1), i1(1), i2(1), j1(1), j2(1) |
---|
| 213 | PRINT*,' time=', simtime(1) |
---|
| 214 | PRINT*,' array size=(',i1(1),':',i2(1), & |
---|
| 215 | ',',j1(1),':',j2(1),')' |
---|
| 216 | READ ( id+200, END=902 ) simtime(2), i1(2), i2(2), j1(2), j2(2) |
---|
| 217 | IF ( simtime(1) /= simtime(2) .OR. i1(1) /= i1(2) .OR. & |
---|
| 218 | i2(1) /= i2(2) .OR. j1(1) /= j1(2) .OR. j2(1) /= j2(2) ) THEN |
---|
| 219 | PRINT*,' +++ time/indices on file 2 does not match:' |
---|
| 220 | PRINT*,' time=', simtime(2) |
---|
| 221 | PRINT*,' array size=(',i1(2),':', & |
---|
| 222 | i2(2), ',',j1(2),':',j2(2),')' |
---|
| 223 | ENDIF |
---|
| 224 | |
---|
| 225 | ALLOCATE( array_2d_i_1(i1(1):i2(1),j1(1):j2(1)), & |
---|
| 226 | array_2d_i_2(i1(2):i2(2),j1(2):j2(2)) ) |
---|
| 227 | |
---|
| 228 | READ ( id+100, END=903 ) array_2d_i_1 |
---|
| 229 | READ ( id+200, END=904 ) array_2d_i_2 |
---|
| 230 | |
---|
| 231 | IF ( i1(1) /= i1(2) ) i1(1) = i1(2) |
---|
| 232 | IF ( i2(1) /= i2(2) ) i2(1) = i2(2) |
---|
| 233 | IF ( j1(1) /= j1(2) ) j1(1) = j1(2) |
---|
| 234 | IF ( j2(1) /= j2(2) ) j2(1) = j2(2) |
---|
| 235 | |
---|
| 236 | n_err = 0 |
---|
| 237 | loop3: DO j = j1(1), j2(1) |
---|
| 238 | DO i = i1(1), i2(1) |
---|
| 239 | IF ( array_2d_i_1(i,j) /= array_2d_i_2(i,j) ) THEN |
---|
| 240 | PRINT*,'+++ data mismatch on element (',i,',',j,')' |
---|
| 241 | PRINT*,' array_1: ', array_2d_i_1(i,j) |
---|
| 242 | PRINT*,' array_2: ', array_2d_i_2(i,j) |
---|
| 243 | n_err = n_err + 1 |
---|
| 244 | IF ( n_err > 5 ) EXIT loop3 |
---|
| 245 | ENDIF |
---|
| 246 | ENDDO |
---|
| 247 | ENDDO loop3 |
---|
| 248 | |
---|
| 249 | DEALLOCATE( array_2d_i_1, array_2d_i_2 ) |
---|
| 250 | |
---|
| 251 | ENDIF |
---|
| 252 | |
---|
| 253 | ! IF ( count > 8 ) STOP |
---|
| 254 | ENDDO |
---|
| 255 | |
---|
| 256 | 100 PRINT*, '*** end of data on file "', TRIM( filename(1) ), '"' |
---|
| 257 | PRINT*, '*** files seem to be identical' |
---|
| 258 | PRINT*, ' ' |
---|
| 259 | ENDDO |
---|
| 260 | |
---|
| 261 | STOP |
---|
| 262 | |
---|
| 263 | 900 PRINT*,'+++ unexpected end on file "', TRIM( filename(2) ), '"' |
---|
| 264 | STOP |
---|
| 265 | 901 PRINT*,'+++ unexpected end on file "', TRIM( filename(1) ), '"' |
---|
| 266 | PRINT*,' while reading indices' |
---|
| 267 | STOP |
---|
| 268 | 902 PRINT*,'+++ unexpected end on file "', TRIM( filename(2) ), '"' |
---|
| 269 | PRINT*,' while reading indices' |
---|
| 270 | STOP |
---|
| 271 | 903 PRINT*,'+++ unexpected end on file "', TRIM( filename(1) ), '"' |
---|
| 272 | PRINT*,' while reading array data' |
---|
| 273 | STOP |
---|
| 274 | 904 PRINT*,'+++ unexpected end on file "', TRIM( filename(2) ), '"' |
---|
| 275 | PRINT*,' while reading array data' |
---|
| 276 | STOP |
---|
| 277 | |
---|
| 278 | END PROGRAM compare_palm_logs |
---|
| 279 | |
---|
| 280 | |
---|
| 281 | |
---|