Changeset 3496 for palm/trunk
- Timestamp:
- Nov 6, 2018 3:59:50 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/UTIL/surface_output_processing/surface_output_to_vtk.f90
r3494 r3496 25 25 ! ----------------- 26 26 ! $Id$ 27 ! Use subroutine call for fseek instead of function call. gfortran has some 28 ! problems with this. 29 ! 30 ! 3494 2018-11-06 14:51:27Z suehring 27 31 ! Initial version 28 !29 ! 3241 2018-09-12 15:02:00Z raasch30 !31 32 ! 32 33 ! Authors: … … 43 44 !> Output is distinguished between instantaneous and time-averaged data. 44 45 !------------------------------------------------------------------------------! 45 PROGRAM surface_output_ merge46 PROGRAM surface_output_to_vtk 46 47 47 48 IMPLICIT NONE … … 59 60 60 61 INTEGER(4) :: ftell !< intrinsic function, get current position in file 61 INTEGER(4) :: fseek !< intrinsic function, go to given position in file62 ! INTEGER(4) :: fseek !< intrinsic function, go to given position in file 62 63 INTEGER(4) :: ndum !< return parameter of intrinsic function fseek 63 64 … … 67 68 INTEGER(iwp) :: cycle_number !< cycle number 68 69 INTEGER(iwp) :: f !< running index over all binary files 69 INTEGER(iwp) :: file_id_in = 1 10!< file unit for input binaray file70 INTEGER(iwp) :: file_id_in = 18 !< file unit for input binaray file 70 71 INTEGER(iwp) :: file_id_out = 20 !< file unit for output VTK file 71 72 INTEGER(iwp) :: file_id_out_header = 19 !< file unit for temporary header file … … 89 90 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: points !< point / vertex data 90 91 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: polygons !< polygon data 92 93 logical :: flag 91 94 92 95 ! 93 96 !-- Read namelist. 94 CALL surface_output_ merge_parin97 CALL surface_output_parin 95 98 ! 96 99 !-- Allocate array which contains the file position in each output file, … … 124 127 ! 125 128 !-- Create filename of the treated binary file. 126 CALL surface_output_ merge_create_file_string129 CALL surface_output_create_file_string 127 130 ! 128 131 !-- Open file with surface output for processor f. 129 OPEN ( file_id_in + f, FILE = TRIM( path ) // TRIM( run ) //&130 TRIM( myid_char ), FORM ='UNFORMATTED' )132 OPEN ( file_id_in, FILE = TRIM( path ) // TRIM( run ) // & 133 TRIM( myid_char ), FORM = 'UNFORMATTED' ) 131 134 ! 132 135 !-- Read number of vertices / points and surface elements 133 READ ( file_id_in + f) npoints(f)134 READ ( file_id_in + f) npoints_total135 READ ( file_id_in + f) ns(f)136 READ ( file_id_in + f) ns_total136 READ ( file_id_in ) npoints(f) 137 READ ( file_id_in ) npoints_total 138 READ ( file_id_in ) ns(f) 139 READ ( file_id_in ) ns_total 137 140 138 141 ! … … 142 145 ! 143 146 !-- Read polygon data and store them in a temporary file. 144 READ ( file_id_in + f) points147 READ ( file_id_in ) points 145 148 ! 146 149 !-- Obtain current file position. Will be stored for next file opening. 147 filepos(f) = ftell( file_id_in + f ) 150 filepos(f) = ftell( file_id_in ) 151 ! CALL FTELL( file_id_in, filepos(f) ) 148 152 ! 149 153 !-- Write header information. Only one time required. … … 165 169 DEALLOCATE( points ) 166 170 167 CLOSE ( file_id_in + f)171 CLOSE ( file_id_in ) 168 172 ENDDO 169 173 ! … … 172 176 ! 173 177 !-- Create filename of the treated binary file . 174 CALL surface_output_ merge_create_file_string178 CALL surface_output_create_file_string 175 179 ! 176 180 !-- Open file with surface output for processor f. 177 OPEN ( file_id_in + f, FILE = TRIM( path ) // TRIM( run ) //&178 TRIM( myid_char ), FORM ='UNFORMATTED' )181 OPEN ( file_id_in, FILE = TRIM( path ) // TRIM( run ) // & 182 TRIM( myid_char ), FORM = 'UNFORMATTED' ) 179 183 ! 180 184 !-- Move to last postion. 181 ndum = fseek( file_id_in + f, filepos(f), 0 ) 185 ! ndum = fseek( file_id_in, filepos(f), 0 ) 186 CALL FSEEK( file_id_in, filepos(f), 0, ndum ) 182 187 ! 183 188 !-- Allocate array for polygon data … … 185 190 ! 186 191 !-- Read polygon data and store them in a temporary file. 187 READ ( file_id_in + f) polygons192 READ ( file_id_in ) polygons 188 193 ! 189 194 !-- Obtain current file position after reading the local polygon data. 190 195 !-- Will be used for next file opening. 191 filepos(f) = ftell( file_id_in + f ) 196 filepos(f) = ftell( file_id_in ) 197 ! CALL FTELL( file_id_in, filepos(f) ) 192 198 ! 193 199 !-- Write further header information. Only one time required. … … 200 206 !-- surface element. 201 207 DO n = 1, ns(f) 202 WRITE ( file_id_out_header, '(8I10)' ) INT (polygons(1:5,n) )208 WRITE ( file_id_out_header, '(8I10)' ) INT( polygons(1:5,n) ) 203 209 ENDDO 204 210 ! … … 206 212 DEALLOCATE( polygons ) 207 213 208 CLOSE ( file_id_in + f)214 CLOSE ( file_id_in ) 209 215 210 216 ENDDO 211 217 212 218 f = 0 213 CALL surface_output_ merge_create_file_string219 CALL surface_output_create_file_string 214 220 ! 215 221 !-- Write further header information. Only once required. … … 240 246 ! 241 247 !-- Create filename of the treated binary file. 242 CALL surface_output_ merge_create_file_string248 CALL surface_output_create_file_string 243 249 ! 244 250 !-- Open binary file with surface output for processor f. 245 OPEN ( file_id_in + f, FILE = TRIM( path ) // TRIM( run ) // &246 TRIM( myid_char ), FORM ='UNFORMATTED' )251 OPEN ( file_id_in, FILE = TRIM( path ) // TRIM( run ) // & 252 TRIM( myid_char ), FORM = 'UNFORMATTED' ) 247 253 ! 248 254 !-- Move to last postion. 249 ndum = fseek( file_id_in + f, filepos(f), 0 ) 255 ! ndum = fseek( file_id_in, filepos(f), 0 ) 256 CALL FSEEK( file_id_in, filepos(f), 0, ndum ) 250 257 ! 251 258 !-- Read string length and string indicating the output time step. 252 READ ( file_id_in + f) length253 READ ( file_id_in + f) char_time(1:length)259 READ ( file_id_in ) length 260 READ ( file_id_in ) char_time(1:length) 254 261 ! 255 262 !-- If string for the output time indicates the end-of-file, set the eof … … 257 264 IF ( char_time(1:length) == 'END' ) THEN 258 265 eof(f) = .TRUE. 259 CLOSE ( file_id_in + f)266 CLOSE ( file_id_in ) 260 267 CYCLE 261 268 ENDIF 262 269 ! 263 270 !-- Read output time, and variable name. 264 READ ( file_id_in + f) simulated_time265 READ ( file_id_in + f) length266 READ ( file_id_in + f) variable_name(1:length)271 READ ( file_id_in ) simulated_time 272 READ ( file_id_in ) length 273 READ ( file_id_in ) variable_name(1:length) 267 274 ! 268 275 !-- For first loop index, open the target output file. First create the … … 296 303 OPEN ( file_id_out, FILE = TRIM( path ) // TRIM( char_dum ) // & 297 304 's_' // TRIM( variable_name ) // '.vtk', FORM='FORMATTED', & 298 POSITION ='APPEND' )305 POSITION = 'APPEND' ) 299 306 ENDIF 300 307 ! … … 302 309 ALLOCATE( var(1:ns(f)) ) 303 310 304 READ( file_id_in + f) var311 READ( file_id_in ) var 305 312 ! 306 313 !-- Write variable data into output VTK file. … … 310 317 ! 311 318 !-- Remember file position in binary file and close it. 312 filepos(f) = ftell( file_id_in + f ) 313 314 CLOSE ( file_id_in + f ) 319 filepos(f) = ftell( file_id_in ) 320 ! CALL FTELL( file_id_in, filepos(f) ) 321 322 CLOSE ( file_id_in ) 315 323 ! 316 324 !-- Deallocate temporary array for variable data. … … 338 346 !> This subroutine read the namelist file. 339 347 !------------------------------------------------------------------------------! 340 SUBROUTINE surface_output_ merge_parin348 SUBROUTINE surface_output_parin 341 349 342 350 IMPLICIT NONE … … 358 366 CLOSE( file_id_parin ) 359 367 360 END SUBROUTINE surface_output_ merge_parin368 END SUBROUTINE surface_output_parin 361 369 362 370 !------------------------------------------------------------------------------! … … 365 373 !> This subroutine creates the filename string of the treated binary file. 366 374 !------------------------------------------------------------------------------! 367 SUBROUTINE surface_output_ merge_create_file_string375 SUBROUTINE surface_output_create_file_string 368 376 369 377 IMPLICIT NONE … … 417 425 ENDIF 418 426 419 END SUBROUTINE surface_output_ merge_create_file_string420 421 END PROGRAM surface_output_ merge422 423 424 427 END SUBROUTINE surface_output_create_file_string 428 429 END PROGRAM surface_output_to_vtk 430 431 432
Note: See TracChangeset
for help on using the changeset viewer.