Skip to content

Features ​

Feature map ​

TopicReferenceComplete programs
Image, rectilinear, structured, unstructured grids, polydata, polyhedraTopologiescookbook, tutorial 1, 5
Field data, vectors, tensors, active arrays, unsigned and ghost arraysData arrayscookbook, tutorial 3
ASCII, binary, raw, zlib; UInt64 headers, 64-bit idsFormats and large datacookbook, tutorial 2
Parallel headers, multi-block, time series, volatile filesParallel and composite filescookbook, tutorial 4, 6, 7
Reading every file back, checking parallel piecesReading filescookbook, tutorial 8
Every procedure and its argumentsProcedures summary, API

VTK XML Exporters ​

Serial datasets ​

TopologyExtensionStatus
Image Data.vti✅
Polydata.vtp✅
Rectilinear Grid.vtr✅
Structured Grid.vts✅
Unstructured Grid.vtu✅

Parallel (partitioned) datasets ​

TopologyExtensionStatus
Parallel Image Data.pvti✅
Parallel Polydata.pvtp✅
Parallel Rectilinear Grid.pvtr✅
Parallel Structured Grid.pvts✅
Parallel Unstructured Grid.pvtu✅

Composite datasets ​

TypeExtensionStatus
vtkMultiBlockDataSet.vtm✅
Time series (collection).pvd✅

VTK XML Importers ​

Files are read with initialize(filename=..., action='read'), see Reading files: every format (ascii, binary, raw, binary-appended), UInt32 and UInt64 headers, zlib compressed or not, as written by VTKFortran or by VTK and ParaView. Only the array asked for is loaded and decoded.

TypeExtensionStatus
Serial datasets.vti, .vtp, .vtr, .vts, .vtu✅
Parallel (partitioned) headers, with the check of the pieces.pvti, .pvtp, .pvtr, .pvts, .pvtu✅
Multi-block entries and time series datasets.vtm, .pvd✅

Not supported: BigEndian files and the LZ4 and LZMA compressors.

VTK Legacy Exporters ​

The legacy (.vtk) format is not supported: VTKFortran writes the VTK XML formats only. Legacy writers were part of the old Lib_VTK_IO (VTKFortran 1.x) and were dropped with the OOP refactoring.

Output Formats ​

FormatDescription
asciiHuman-readable text inside XML elements
binaryBase64-encoded binary inside XML elements
rawRaw binary in the XML appended section (with byte offsets)
binary-appendedBase64-encoded binary in the XML appended section
raw-zlibShorthand for raw with compressor='zlib'

The format string passed to initialize is case-insensitive. Binary arrays are prefixed by a UInt32 bytes count by default (2 GiB per array); header_type='UInt64' lifts the limit, see Large data arrays.

Compression ​

The three binary formats (binary, raw, binary-appended) can be zlib-compressed with compressor='zlib', the layout VTK and ParaView write (vtkZLibDataCompressor, 32 KiB blocks): the encoded arrays are byte-identical to VTK's own writer at the same compression level. zlib is optional: it needs the library built with VTKFORTRAN_USE_ZLIB, see Compressed binary data and Installation.

Global Field Data ​

Optional simulation metadata (time, cycle number, solver name, residuals history, etc.) can be attached before the first piece via write_fielddata: scalars and rank-1 arrays of all PENF kinds, strings and arrays of strings.

fortran
error = a_vtk_file%xml_writer%write_fielddata(action='open')
error = a_vtk_file%xml_writer%write_fielddata(x=0._R8P, data_name='TIME')
error = a_vtk_file%xml_writer%write_fielddata(x=1_I8P,  data_name='CYCLE')
error = a_vtk_file%xml_writer%write_fielddata(x=residuals, data_name='residuals')  ! rank-1 array
error = a_vtk_file%xml_writer%write_fielddata(x='my solver v1.2', data_name='solver')
error = a_vtk_file%xml_writer%write_fielddata(action='close')

See Field data for details.

Data Arrays ​

write_dataarray is a heavily overloaded interface that accepts:

  • All PENF numeric kinds: R8P, R4P, I8P, I4P, I2P, I1P
  • Ranks 1–4 for dense arrays
  • Scalar, 1-component, 3-component (vector), and 6-component (symmetric tensor) layouts
  • Node-centered or cell-centered placement (location='node' or location='cell')
  • Active arrays: the arrays readers use by default for each role (Scalars, Vectors, Normals, Tensors, TCoords) can be designated when opening the node/cell data, see Active arrays
  • Unsigned integers (UInt8, UInt16, UInt32, UInt64, e.g. vtkGhostType) with write_dataarray_unsigned, see Unsigned integer arrays

Parallel Support ​

VTKFortran can safely manage multiple concurrent open files: each vtk_file (writer or reader) keeps its state in its own components, so files can be written or read concurrently within OpenMP parallel regions and by MPI programs where each rank writes its own partition file. The dependencies PENF and BeFoR64 initialize their constant tables at the first initialize; in OpenMP, initialize one file (or call penf_init and b64_init) before the parallel region, so that two threads never run that initialization at the same time.

Compiler Support ​

CompilerStatus
GNU gfortran 12, 13, 14, 16✅ Tested (the CI uses gfortran 14)
GNU gfortran 11⚠️ Builds; the string form of vtm_file%write_block crashes (in StringiFor split)
Intel ifx 2025.3✅ Tested (the discontinued ifort is not tested)
NAG, NVIDIA, Cray, LLVM FlangNot tested

Design Principles ​

  • Pure Fortran — no system calls beyond standard I/O; the only C library is zlib, optional, for compressed data
  • OOP — polymorphic xml_writer allocated at runtime, an xml_reader to read files back; vtk_file, pvtk_file, vtm_file, pvd_file expose type-bound procedures
  • KISS — simple, focused API without unnecessary abstractions
  • Error codes — every procedure returns an integer; zero means success
  • Free & Open Source — multi-licensed for FOSS and commercial use