Appearance
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
| Name | Type | Attributes | Description |
|---|---|---|---|
closing_tags | character(len=*) | parameter | Closing tags. |
Derived Types
pvd_file
PVD file class.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
unit | integer(kind=I4P) | Logical unit, 0 when the file is not open. | |
pos_close | integer(kind=I8P) | Stream position of the closing tags, i.e. where the next dataset is written. | |
xml | type(xml_scanner) | Index of the file read (action='read'). | |
is_reading | logical | The file is open for reading. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
get_datasets | pass(self) | Return the datasets of a file read. |
initialize | pass(self) | Initialize (create or append to) the file. |
write_dataset | pass(self) | Write one dataset entry. |
finalize | pass(self) | Finalize (close) the file. |
write_closing_tags | pass(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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(pvd_file) | inout | PVD file. | |
error | integer(kind=I4P) | out | Error 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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(pvd_file) | inout | PVD file. | |
filename | character(len=*) | in | File name, with the .pvd extension. | |
action | character(len=*) | in | optional | Action: 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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(pvd_file) | inout | PVD file. | |
filename | character(len=*) | in | File name of the dataset. | |
timestep | real(kind=R8P) | in | Time step (time value) of the dataset. | |
part | integer(kind=I4P) | in | optional | Part (piece) of the dataset at this time step, default 0. |
group | character(len=*) | in | optional | Group of the dataset. |
name | character(len=*) | in | optional | Name 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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(pvd_file) | inout | PVD 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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(pvd_file) | in | PVD file. | |
timestep | real(kind=R8P) | out | allocatable, optional | Time step of the datasets. |
part | integer(kind=I4P) | out | allocatable, optional | Part of the datasets. |
group | character(len=:) | out | allocatable, optional | Group of the datasets. |
name | character(len=:) | out | allocatable, optional | Name of the datasets. |
file | character(len=:) | out | allocatable, optional | File 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
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
string | character(len=*) | in | Input string. |
Call graph