Writing a vtk legacy file in binary format with Fortran. String datafield issue

Hi everybody ! To enable the visualization with Paraview of the results of my Fortran FE code, I developed in it the generation of a vtk file as output (legacy format, either ASCII or BINARY). The vtk legacy format is quite sufficient for the FE post-processing, thanks to POINTS, CELLS and associated DATA (scalars, vectors and tensors). However, to allow an easy filtering of data by “group names”, I define some appropriate FieldData of string type, wich are to be displayed in the Information tab of Paraview. My problem is that String Field Data work fine if the vtk file is in ASCII format, but unfortunately Paraview crashes when reading the field data in the BINARY format file. To open the vtk BINARY file, i use the following statement in IFX Fortran on Windows : “open(iufile,FILE=trim(ficname),FORM=“unformatted”,RECORDTYPE=‘stream_lf’,CONVERT=‘big_endian’,ERR=1,IOSTAT=io)”. Then, then, to create the FiedData, I use the unformatted write “write(iufile) chain_data”..

The crash of the Paraview reader comes from my binary FieldData because Paraview reads correctly my binary file if I remove all the FieldData, So, the issue probably is an incorrect string separator or end of record due to my binary write. It is very difficult to find detailed information on legacy vtk + FieldData + binary files…Has anybody experienced that kinf of issue in writing text in a binary file by a fortran code?

While it may be sufficient, I higly recommend you to look into using VTKHDF format instead, it is a modern and very efficient format that is easy to write if you know your way around hdf5: VTKHDF File Format - VTK documentation

Thanks Mathieu for your quick reply! VTKHDF does indeed look very promising and may eventually solve my problem.

But in practice, my code has to run on a very basic computing environment, and it’s difficult for me to make it rely on an external library such as HDF. I had the same type of concern with the HDF5 wrapper of Salome’s med format on Windows (rather poor doc in that case).

My question for now is specifically about the correct way to write a string-type Fielddata with Intel Fortran (on Vindows) into a vtk binary legacy file, if that is possible of course. This is the last obstacle to achieving my goal right now.

have a nice day!

1 Like