Changes between Version 1 and Version 2 of BovFiles
- Timestamp:
- 11/28/11 13:07:07 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BovFiles
v1 v2 3 3 = BOV (Brick of Value) files = 4 4 5 BOV files are the easiest way to get fixed grid data into visit. While the .bov files are what are opened in visit, the actual data itself is in an accompanying unformatted data file. Each BOV file contains meta data that describes the size, spatial extents, the time, the number of components for each cell, and the name of the actual data file. Those BOV files always come in pairs - one data file for each bov file. This is important to keep in mind when transferring files from one folder to another.5 BOV files are the easiest way to get fixed grid data into visit. While the .bov files are what are opened in visit, the actual data itself is in an accompanying unformatted data file. Each BOV file contains meta data that describes the size, spatial extents, the time, the number of components for each cell, and the name of the actual file with the actual data. Those BOV files always come in pairs - one data file for each bov file. This is important to keep in mind when transferring files from one folder to another. 6 6 7 Writing to the bov file is fairly straightforward. See io/io_bov.f90 for an example. Writing to the data file is a little bit tricky because of the ordering of the fields. 8 9 First the data file has to be opened as unformatted. 10 11 {{{OPEN(UNIT=UNIT_ID, FILE=FileName, status="replace", FORM="unformatted")}}} 12 13 Then to output the data just execute 7 Here is a sample bov file for a 512x512x1 data cube with only 1 component and a spatial extent of 50x50x0 14 8 {{{ 15 DO i=1,NrComps 16 WRITE(UNIT_ID) q(:,:,:,i) 17 END DO 9 TIME: 0.100000000000000 10 DATA_FILE: Mass_along_3_00001.dat 11 DATA_SIZE: 512 512 1 12 DATA_FORMAT: DOUBLE 13 VARIABLE: projection 14 DATA_ENDIAN: LITTLE 15 CENTERING: zonal 16 BRICK_ORIGIN: 0.0000000000000000E+00 0.0000000000000000E+00 0.0000000000000000E+00 17 BRICK_SIZE: 0.5000000000000000E+02 0.5000000000000000E+02 0.0000000000000000E+00 18 BYTE_OFFSET: 4 19 DATA_COMPONENTS: 1 18 20 }}} 19 21 20 Note that this is different then 22 Generating a bov file is fairly straightforward. 21 23 {{{ 22 WRITE(UNIT_ID) q(:,:,:,:) 24 OPEN(UNIT=BOV_DATA_HANDLE, FILE=Filename) 25 WRITE(BOV_DATA_HANDLE,*) "TIME: ", tnow 26 write(BOV_DATA_HANDLE,'(A13,A,A4)') "DATA_FILE: ", TRIM(name), ".dat" 27 WRITE(BOV_DATA_HANDLE,'(A11,3I12)') "DATA_SIZE: ", shape(data), 1 28 WRITE(BOV_DATA_HANDLE,*) "DATA_FORMAT: DOUBLE" 29 WRITE(BOV_DATA_HANDLE,'(2A)') "VARIABLE: ", TRIM(varname) 30 WRITE(BOV_DATA_HANDLE,*) "DATA_ENDIAN: LITTLE" 31 WRITE(BOV_DATA_HANDLE,*) "CENTERING: zonal" 32 WRITE(BOV_DATA_HANDLE,'(A14,3E26.16)') "BRICK_ORIGIN: ", lower,0 33 WRITE(BOV_DATA_HANDLE,'(A12,3E26.16)') "BRICK_SIZE: ", upper-lower,0 34 WRITE(BOV_DATA_HANDLE,*) "BYTE_OFFSET: 4" 35 WRITE(BOV_DATA_HANDLE,'(A17,I4)') "DATA_COMPONENTS: ", 4 36 CLOSE(BOV_DATA_HANDLE) 23 37 }}} 24 because Fortran uses Column Major ordering25 38 26 If we want to write a one-liner we have to swap the order by using a transpose 39 Writing to the data file is a little bit tricky because of the ordering of the fields. The BOV files expect data to be ordered in {{{field-x-y-z}}} format where as you go from byte to byte, the field varies the fastest, then x position, y position, and finally z position. Since Fortran is Column Major this would work fine if arrays were stored {{{q(field, x, y, z}}}. However since most arrays in astrobear are stored {{{q(x,y,z,field}}} the data needs to be cycled. This can be done with a combination of reshape and transpose. 27 40 28 41 {{{ 29 WRITE(UNIT_ID) transpose(reshape(q(:,:,:,:), (/size(q)/ NrComps,NrComps/)))42 WRITE(UNIT_ID) transpose(reshape(q(:,:,:,:), (/size(q)/nFields,nFields/))) 30 43 }}} 31 44 45 Note that if there is only 1 field, then there is no need to transpose 46 {{{ 47 WRITE(UNIT_ID) q(:,:,:,1) 48 }}} 32 49 33 The {{{.bov}}} file contains information about the data as well as the location of the actual data file {{{.dat}}} which contains the raw unformatted binary data. Visit will only recognize the {{{.bov}}} files. 50 Or if the data set is a single field in 2D 51 {{{ 52 WRITE(UNIT_ID) q(:,:) 53 }}}