Version 2 (modified by 13 years ago) ( diff ) | ,
---|
BOV (Brick of Value) files
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.
Here is a sample bov file for a 512x512x1 data cube with only 1 component and a spatial extent of 50x50x0
TIME: 0.100000000000000 DATA_FILE: Mass_along_3_00001.dat DATA_SIZE: 512 512 1 DATA_FORMAT: DOUBLE VARIABLE: projection DATA_ENDIAN: LITTLE CENTERING: zonal BRICK_ORIGIN: 0.0000000000000000E+00 0.0000000000000000E+00 0.0000000000000000E+00 BRICK_SIZE: 0.5000000000000000E+02 0.5000000000000000E+02 0.0000000000000000E+00 BYTE_OFFSET: 4 DATA_COMPONENTS: 1
Generating a bov file is fairly straightforward.
OPEN(UNIT=BOV_DATA_HANDLE, FILE=Filename) WRITE(BOV_DATA_HANDLE,*) "TIME: ", tnow write(BOV_DATA_HANDLE,'(A13,A,A4)') "DATA_FILE: ", TRIM(name), ".dat" WRITE(BOV_DATA_HANDLE,'(A11,3I12)') "DATA_SIZE: ", shape(data), 1 WRITE(BOV_DATA_HANDLE,*) "DATA_FORMAT: DOUBLE" WRITE(BOV_DATA_HANDLE,'(2A)') "VARIABLE: ", TRIM(varname) WRITE(BOV_DATA_HANDLE,*) "DATA_ENDIAN: LITTLE" WRITE(BOV_DATA_HANDLE,*) "CENTERING: zonal" WRITE(BOV_DATA_HANDLE,'(A14,3E26.16)') "BRICK_ORIGIN: ", lower,0 WRITE(BOV_DATA_HANDLE,'(A12,3E26.16)') "BRICK_SIZE: ", upper-lower,0 WRITE(BOV_DATA_HANDLE,*) "BYTE_OFFSET: 4" WRITE(BOV_DATA_HANDLE,'(A17,I4)') "DATA_COMPONENTS: ", 4 CLOSE(BOV_DATA_HANDLE)
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.
WRITE(UNIT_ID) transpose(reshape(q(:,:,:,:), (/size(q)/nFields,nFields/)))
Note that if there is only 1 field, then there is no need to transpose
WRITE(UNIT_ID) q(:,:,:,1)
Or if the data set is a single field in 2D
WRITE(UNIT_ID) q(:,:)