Skip to content

vtk_fortran_pvd_file ​

PVD file class: VTK collection of datasets (time series).

A .pvd file lists datasets (VTK XML files written with vtk_file, pvtk_file or vtm_file) with their time step, and optionally part, group and name: readers such as ParaView load the listed files as a time series.

The file is kept valid after each write_dataset: every new dataset is written over the closing tags, which are written again after it. Therefore a run that stops before finalize (crash, killed job) still leaves a readable collection of all the datasets written so far, and a restarted run can continue an existing collection with action='append'.

Source: src/lib/vtk_fortran_pvd_file.f90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
closing_tagscharacter(len=*)parameterClosing tags.

Derived Types ​

pvd_file ​

PVD file class.

Components ​

NameTypeAttributesDescription
unitinteger(kind=I4P)Logical unit, 0 when the file is not open.
pos_closeinteger(kind=I8P)Stream position of the closing tags, i.e. where the next dataset is written.
xmltype(xml_scanner)Index of the file read (action='read').
is_readinglogicalThe file is open for reading.

Type-Bound Procedures ​

NameAttributesDescription
get_datasetspass(self)Return the datasets of a file read.
initializepass(self)Initialize (create or append to) the file.
write_datasetpass(self)Write one dataset entry.
finalizepass(self)Finalize (close) the file.
write_closing_tagspass(self)Write the closing tags at the current end of datasets.

Subroutines ​

write_closing_tags ​

Write the closing tags at the current end of datasets, drop anything after them and flush the file.

fortran
subroutine write_closing_tags(self, error)

Arguments

NameTypeIntentAttributesDescription
selfclass(pvd_file)inoutPVD file.
errorinteger(kind=I4P)outError status.

Call graph

Functions ​

initialize ​

Initialize the file: create a new collection, or reopen an existing one to append datasets.

Example of usage ​

fortran
 type(pvd_file) :: pvd
 ...
 error = pvd%initialize(filename='simulation.pvd')                  ! new collection (an existing file is replaced)
 error = pvd%initialize(filename='simulation.pvd', action='append') ! continue an existing collection (e.g. restart)
 error = pvd%initialize(filename='simulation.pvd', action='read')   ! read the collection, see get_datasets
 ...

@note With action='append' the file must exist and be a VTK collection (<Collection>): the datasets already listed are kept and the new ones are written after them. @note With action='read' the file is indexed, its datasets are returned by get_datasets and finalize frees the index: the error is 1 if the file cannot be read, 2 if it is not a VTK collection.

Returns: integer(kind=I4P)

fortran
function initialize(self, filename, action) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(pvd_file)inoutPVD file.
filenamecharacter(len=*)inFile name, with the .pvd extension.
actioncharacter(len=*)inoptionalAction: new (default), append or read.

Call graph

write_dataset ​

Write one dataset entry: the file name of the dataset and its time step (and optionally part, group and name).

The collection is valid (closing tags included) as soon as this function returns.

Example of usage ​

fortran
 error = pvd%write_dataset(filename='simulation_0010.vtu', timestep=0.1_R8P)
 error = pvd%write_dataset(filename='simulation_0010_rank1.vtu', timestep=0.1_R8P, part=1)

@note filename is written as given: a relative path is relative to the directory of the .pvd file.

Returns: integer(kind=I4P)

fortran
function write_dataset(self, filename, timestep, part, group, name) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(pvd_file)inoutPVD file.
filenamecharacter(len=*)inFile name of the dataset.
timestepreal(kind=R8P)inTime step (time value) of the dataset.
partinteger(kind=I4P)inoptionalPart (piece) of the dataset at this time step, default 0.
groupcharacter(len=*)inoptionalGroup of the dataset.
namecharacter(len=*)inoptionalName of the dataset.

Call graph

finalize ​

Finalize the file: close it. The file is already a valid collection, the datasets written so far included.

Returns: integer(kind=I4P)

fortran
function finalize(self) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(pvd_file)inoutPVD file.

Call graph

get_datasets ​

Return the datasets of a file read (initialize(..., action='read')), in the order of the file.

Missing attributes are returned as 0 (timestep, part) or empty (group, name, file). The strings are blank padded to the longest one; relative files are relative to the directory of the .pvd file.

fortran
 type(pvd_file)                :: pvd
 real(R8P),        allocatable :: timestep(:)
 character(len=:), allocatable :: file(:)
 error = pvd%initialize(filename='simulation.pvd', action='read')
 error = pvd%get_datasets(timestep=timestep, file=file)
 error = pvd%finalize()

Returns: integer(kind=I4P)

fortran
function get_datasets(self, timestep, part, group, name, file) result(error)

Arguments

NameTypeIntentAttributesDescription
selfclass(pvd_file)inPVD file.
timestepreal(kind=R8P)outallocatable, optionalTime step of the datasets.
partinteger(kind=I4P)outallocatable, optionalPart of the datasets.
groupcharacter(len=:)outallocatable, optionalGroup of the datasets.
namecharacter(len=:)outallocatable, optionalName of the datasets.
filecharacter(len=:)outallocatable, optionalFile of the datasets.

Call graph

upper ​

Return a string in upper case (ASCII letters only).

Attributes: pure

Returns: character(len=len(string))

fortran
function upper(string) result(upper_string)

Arguments

NameTypeIntentAttributesDescription
stringcharacter(len=*)inInput string.

Call graph