I am having a fortran code to generate a grid in binary VTK format. This code produces a binary VTK file like this one:
# vtk DataFile Version 3.0 vtk output BINARY DATASET RECTILINEAR_GRID DIMENSIONS 2 2 1 X_COORDINATES 2 float ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ Y_COORDINATES 2 float ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ Z_COORDINATES 1 float ^@^@^@^@^@^@^@^@
When, I try to open it with ParaView it crashes with the following error message:
ERROR: In /home/athanasios/OpenFOAM/ThirdParty-2.3.0/ParaView-4.1.0/VTK/IO/Legacy/vtkRectilinearGridReader.cxx, line 311 vtkRectilinearGridReader (0x379f4b0): Unrecognized keyword: ...
If I write the above file in ASCII instead, then it opens properly in ParaView, that's the ASCII analogous file that opens:
# vtk DataFile Version 3.0 vtk output ASCII DATASET RECTILINEAR_GRID DIMENSIONS 2 2 1 X_COORDINATES 2 float 0 1 Y_COORDINATES 2 float 0 1 Z_COORDINATES 1 float 0
I am using the following code to generate the grid in binary VTK format (I am giving a minimum working code):
program VTKBinary implicit none real*8 :: x(2) = (0., 1.) real*8 :: y(2) = (0., 1.) real*8 :: z(1) = (0.) character :: buffer*80, lf*1, str1*8, str2*8, str3*8 integer :: ivtk = 9, int lf = char(10) ! line feed character open(unit=ivtk,file='test_bin.vtk',form='binary',convert='BIG_ENDIAN') buffer = '# vtk DataFile Version 3.0'//lf ; write(ivtk) trim(buffer) buffer = 'vtk output'//lf ; write(ivtk) trim(buffer) buffer = 'BINARY'//lf ; write(ivtk) trim(buffer) buffer = 'DATASET RECTILINEAR_GRID'//lf ; write(ivtk) trim(buffer) ! WRITE GRID write(str1(1:8),'(i8)') size(x) write(str2(1:8),'(i8)') size(y) write(str3(1:8),'(i8)') size(z) buffer = 'DIMENSIONS '//str1//str2//str3//lf ; write(ivtk) trim(buffer) buffer = 'X_COORDINATES '//str1//' float'//lf ; write(ivtk) trim(buffer) write(ivtk) x buffer = lf//'Y_COORDINATES '//str2//' float'//lf ; write(ivtk) trim(buffer) write(ivtk) y buffer = lf//'Z_COORDINATES '//str3//' float'//lf ; write(ivtk) trim(buffer) write(ivtk) z close(ivtk) end program VTKBinary
What is wrong with the binary VTK file? why it exits?