我使用了stackoverflow发布的代码并将其修改为:
program VTKBinary
implicit none
real*4 :: x(2) = (0., 1.)
real*4 :: y(2) = (0., 1.)
real*4 :: z(2) = (0., 1.)
character :: buffer*80, lf*1, str1*8, str2*8, str3*8
integer :: ivtk = 9, int,i
lf = char(10) ! line feed character
!open(unit=ivtk,file='test_bin.vtk',form='binary',convert='BIG_ENDIAN')
open(unit=ivtk,file='test_bin.vtk',access='stream',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
write(ivtk) (x(i),i=1,size(x))
buffer = lf//'Y_COORDINATES '//str2//' float'//lf ; write(ivtk) trim(buffer)
!write(ivtk) y
write(ivtk) (y(i),i=1,size(y))
buffer = lf//'Z_COORDINATES '//str3//' float'//lf ; write(ivtk) trim(buffer)
!write(ivtk) z
write(ivtk) (z(i),i=1,size(z))
close(ivtk)
end program VTKBinary
这段代码由gfortran很好地编译,运行良好,可以生成vtk文件。
问题:当paraview读取vtk时出现以下错误:
Warning: In C:\DBD\pvs-x64\paraview\src\paraview\VTK\Rendering\Core\vtkRenderer.cxx, line 1029
vtkOpenGLRenderer (000000000BF00BF0): Resetting view-up since view plane normal is parallel
问题:你能帮我解决这个问题吗?
非常感谢。
答案 0 :(得分:0)
@AlexanderVoigt指出了主要问题。数组指定为Invalid CSS after "a.": expected class name, was "&"
,而不是[0., 1.]
,这是一个等于一个虚数单位 i 的复数。
另一个问题是最后缺少(0., 1.)
。只需使用
lf
最好始终将buffer = 'X_COORDINATES '//str1//' float'//lf ; write(ivtk) trim(buffer)
write(ivtk) x, lf
buffer = 'Y_COORDINATES '//str2//' float'//lf ; write(ivtk) trim(buffer)
write(ivtk) y, lf
buffer = 'Z_COORDINATES '//str3//' float'//lf ; write(ivtk) trim(buffer)
write(ivtk) z, lf
放在最后,这样你就不会忘记它。
顺便说一下,您不必将字符串放入缓冲区然后修剪它,您甚至可以直接编写它们:
lf