Note: This is a fork from Lib_VTK_IO, made by Stefano Zaghi. The main purpose of this fork is to add reading capabilities to the library by taking as starting point the previous work of Francisco Pena.
A KISS pure Fortran Library to IO data conforming the VTK standard
- Lib_VTK_IO is a pure Fortran library to write and read data conforming the VTK standard;
- Lib_VTK_IO is Fortran 2003+ standard compliant;
- Lib_VTK_IO supports parallel architectures by means OpenMP and MPI paradigms;
- Lib_VTK_IO supports ascii, binary and base64 file formats;
- Lib_VTK_IO is a Free, Open Source Project.
The Lib_VTK_IO is an open source project, it is distributed under a dual licensing system: the GPL v3 and the MIT licenses. Anyone is interest to use, to develop or to contribute to Lib_VTK_IO is welcome: you are free to select the GPL license for FOSS projects or the MIT one for commercial softwares.
Go to Top
Lib_VTK_IO has a comprehensive wiki. Moreover, the API is well documented, on the GitHub pages of the project.
Go to Top
Let us assume our aim being to save our pure Fortran data into a VTK structured grid file in binary XML form. This is simple as
USE Lib_VTK_IO
...
! dataset dimensions
integer, parameter:: nx1=0,nx2=9,ny1=0,ny2=5,nz1=0,nz2=5
integer, parameter:: nn=(nx2-nx1+1)*(ny2-ny1+1)*(nz2-nz1+1)
! grid coordinates
real, dimension(nx1:nx2,ny1:ny2,nz1:nz2):: x,y,z
! variables associated at grid nodes
real, dimension(nx1:nx2,ny1:ny2,nz1:nz2):: v_R
! auxiliary variables
integer:: E_IO
...
E_IO = VTK_INI_XML(output_format='binary',filename='XML_STRG.vts',mesh_topology='StructuredGrid',nx1=nx1,nx2=nx2,ny1=ny1,ny2=ny2,nz1=nz1,nz2=nz2)
E_IO = VTK_GEO_XML(nx1=nx1,nx2=nx2,ny1=ny1,ny2=ny2,nz1=nz1,nz2=nz2,NN=nn,X=x,Y=y,Z=z)
E_IO = VTK_DAT_XML(var_location='node',var_block_action='open')
E_IO = VTK_VAR_XML(NC_NN=nn,varname='real scalar',var=v_R)
E_IO = VTK_DAT_XML(var_location='node',var_block_action='close')
E_IO = VTK_GEO_XML()
E_IO = VTK_END_XML()
Note that all Lib_VTK_IO functions return an error code (E_IO
) that can be used for sophisticated error trapping algorithms.