RES: RES: [Paraview] VTK formats and Fortran (again...)
Kent Eschenberg
eschenbe at psc.edu
Fri Apr 27 11:59:07 EDT 2007
Some quick answers:
Renato N. Elias wrote:
> I'm now trying to fix my Fortran routine to write a simple triangle as
> unstructured data following your suggestions, but I still have some doubts:
>
> - Silly question number 1: What is such offset in VTK/XML files?
The offset for appended raw binary data is the number of bytes beyond the
underscore ("_") at the start of the binary section. For example, the offset
for the first binary array is always 0.
Each binary array must start with a 4-byte integer that is the length or number
of bytes in the array that immediately follows. You must take into account
whether the array is, for example, 16-bit shorts or 32-bit integers. The number
of bytes does not include the length itself. For example, the length for 10000
32-bit floats is 40000.
The offset for the second and later arrays must include the lengths. For
example, if the first binary array is 10000 32-bit floats then the offset for
the second array will be 40004.
These offsets are completely different than the offsets used with unstructured
data.
> 2). In the AppendedData section must I put all arrays (raw binary)
> contiguously or can I call Fortran "write" statements more than once?
I haven't tried this but I think you can leave gaps between arrays - it merely
wastes space. The VTK code that reads this does a "seek" using the provided
offset so would not care if there was extra space. Two things to check:
1) How much is actually written to the file? You'll need to know this to
calculate the offset for the following array. For example, lets say the first
array is 10000 32-bit floats plus the 32-bit length. And, lets say it is padded
to a multiple of 512 bytes. It will occupy 79 512-byte chunks or 40448 bytes.
The offset to the second array will therefore be 40448.
2) Be sure Fortran adds no padding before the binary data. Some add an extra
byte; others will add an extra 512-byte section.
Warning: although I've created this type of VTK file from C I haven't done so
from Fortran. Hopefully those with relevant experience will point out my errors.
Kent
Pittsburgh Supercomputing Center
More information about the ParaView
mailing list