从FORTRAN code为Rectilinear_grid二进制VTK无法通过的Paraview工作 [英] binary vtk for Rectilinear_grid from fortran code can not worked by paraview

查看:875
本文介绍了从FORTRAN code为Rectilinear_grid二进制VTK无法通过的Paraview工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用code从计算器和发布其修改为:

I used the code posted from stackoverflow and modified it as:

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

这code由gfortran编译好,它运行良好,产生VTK文件。

This code is compiled well by gfortran and it runs well to generate vtk file.

问题:有当VTK是的Paraview如下读取错误:

Problem: there is an error when the vtk is read by paraview as following:

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

问:你能帮我解决这个问题。

Question: can you help me to solve this problem?

非常感谢。

推荐答案

被@AlexanderVoigt指出的主要问题。数组被指定为 [0,1] ,而不是(0,1),这将是等于一个虚数单位复数的 I

The main issue was pointed out by @AlexanderVoigt. Arrays are specified as [0., 1.], not as (0., 1.), that would be a complex number equal to one imaginary unit i.

另一个问题是缺少 LF 结尾。只需使用

The other problem is missing lf at the end. Just use

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 结尾这样你就不会忘记它。

It is better to always put the lf at the end so you do not forget it.

BTW你不必把字符串在缓冲区中,然后修剪它,你可以直接与他们甚至写:

BTW you do not have to put the strings in a buffer and then trim it, you can even write them directly:

write(ivtk) 'X_COORDINATES '//str1//'  float'//lf

这篇关于从FORTRAN code为Rectilinear_grid二进制VTK无法通过的Paraview工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆