Overview

Introduction

PVD (ParaView Data format) is a project which goals is to define Fortran modules to produce ParaView data files from 2D or 3D scalar and vector fields. These routines can be called from a single-threaded or a multi-processes (MPI) applications. It has been developed by Jalel Chergui, LIMSI-CNRS.

Installation

  1. You'll need a Fortran 2003 compiler and a MPI-1 implementation (no need in single-threaded context).
  2. Download PVD sources.
  3. tar -xvzf pvd-(version).tar.gz
  4. cd PVD-(version)
    cd options and Configure the "Make.inc" file.
  5. cd ../modules and make This will produce a "libpvd.a" in the "library" and *.mod files in the "include" directory.

Quick guide

Presentation

The current release includes the following files :
  1. README
  2. VTR_mod.f90
  3. VTK_mod.f90
  4. PVD.f90
  5. Makefile
VTR_mod.f90 and VTK_mod.f90 defines Fortran modules which USE enable writing VTR or VTK format of 2D or 3D scalar and vector fields.
  1. "VTR" module defines 5 subroutines which calls enable writing ASCII data in new XML VTK format.
  2. "VTK" module defines 5 subroutines which calls enable writing BINARY data in native VTK format. However, native VTK files can be converted to BINARY XML VTK files using the python script "vtk2xml.py" released with official tools of the ParaView distribution.

Examples

The following examples make USE of the "VTR" module to :
    a) create a set of ".vtr" files,
    b) write a 3D rectilinear mesh defined here by x, y and z components,
    c) write a 3D vector field defined here by u, v, and w components,
    d) write a 3D scalar field denoted here by p,
    e) close ".vtr" files,
    f) Collect the set of ".vtr" files in a unique ".pvd" file.

Single-thread example

        program calcul
          USE PVD
          type(VTR_file_handle) :: fd
          ...
          real(kind=8), dimension(15)       :: x, y, z    ! mesh
          real(kind=8), dimension(15,15,15) :: u, v, w, p ! fields
          integer :: t, max_time_iter
          ...

          do t = 1, max_time_iter
             ...

  (a)        call VTR_open_file(PREFIX="project", FD=fd)
  (b)        call VTR_write_mesh(FD=fd, X=x, Y=y, Z=z)
  (c)        call VTR_write_var(FD=fd, NAME="Velocity", VX=u, VY=v, VZ=w)
  (d)        call VTR_write_var(FD=fd, NAME="Pressure", FIELD=p)
  (e)        call VTR_close_file(FD=fd)

             ...
          end do

  (f)     call VTR_collect_file(fd)  ! Produces "project.pvd" file
          ...
        end program calcul

Multi-processes (MPI) example

        program calcul
	  USE PVD
          type(VTR_file_handle) :: fd
          include "mpif.h"
          ...
          real(kind=8), dimension(11)       :: x, y, z    ! mesh
          real(kind=8), dimension(11,11,11) :: u, v, w, p ! fields
          integer :: t, max_time_iter, code, rank, nb_procs
          ...
          call MPI_Init(code)
          call MPI_Comm_size(MPI_COMM_WORLD, nb_procs, code)
          call MPI_Comm_rank(MPI_COMM_WORLD, rank, code)

          do t = 1, max_time_iter
             ...

  (a)        call VTR_open_file(PREFIX="project", PROC_RANK=rank, NUM_PROCS=nb_procs, FD=fd)
  (b)        call VTR_write_mesh(FD=fd, X=x, Y=y, Z=z)
  (c)        call VTR_write_var(FD=fd, NAME="Velocity", VX=u, VY=v, VZ=w)
  (d)        call VTR_write_var(FD=fd, NAME="Pressure", FIELD=p)
  (e)        call VTR_close_file(FD=fd)

             ...
          end do

  (f)     call VTR_collect_file(fd)  ! Produces "project.pvd" file
          ...
          call MPI_Finalize(code)
        end program calcul

Remarques

  1. To use the "VTK", instead of the "VTR" module, just replace the string "VTR" by "VTK" in the examples above.
  2. If the mesh is staggered, it's up to the user to translate the vector components to a common origin (e.g. center of cells or faces).

Compilation and link

User must compile first the module files "VTR_mod.f90", "VTK_mod.f90" and "PVD.f90" prior to the program making USE of them. Then, he has to load his program with the archive "libpvd.a" to generate the executable code. The example below uses "gfortran" compiler to go through the mentioned steps above :
Compilation geared towards single-threaded execution :

       gfortran -c VTR_mod.f90 VTK_mod.f90
       gfortran -O3 -c monprog.f90
       gfortran -o prog.x monprog.o VTR_mod.o VTK_mod.o
       ./prog.x
Compilation geared towards multi-processes execution :

       mpif90 -c VTR_mod.f90 VTK_mod.f90
       mpif90 -O3 -c monprog.f90
       mpif90 -o prog.x monprog.o VTR_mod.o VTK_mod.o
       mpirun -np 32 ./prog.x

Visualisation

Once the execution of the program terminates, user can see (among ".vtr" suffixed files) a uniq ".pvd" suffixed file which represents a single entry point to be read by ParaView.