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'.
A file name ending in .series is a ParaView file series instead (JSON: {"file-series-version" : "1.0", "files" : [{"name" : ..., "time" : ...}, ...]}), written, continued and read by the same calls: it lists files and times only (part, group and name are refused), and is valid after each write_dataset too.
Source: src/lib/vtk_fortran_pvd_file.f90
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
closing_tags | character(len=*) | parameter | Closing tags. |
series_closing | character(len=*) | parameter | Closing of .series. |
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. | |
file_end | integer(kind=I8P) | Size of the file: its last byte. | |
xml | type(xml_index) | Index of the file read (action='read', FoXy). | |
is_reading | logical | The file is open for reading. | |
is_series | logical | A ParaView .series file (JSON) instead of a .pvd. | |
n_entries | integer(kind=I4P) | Entries of a .series file written (a comma before the next one). | |
series_times | real(kind=R8P) | allocatable | Times of the entries. |
series_text | integer(kind=I4P) | allocatable | Start and length of the file name of each entry. |
series_chars | character(len=:) | allocatable | The file names. |
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. |
read_series | pass(self) | Read the entries of a .series file. |
Subroutines
write_closing_tags
Write the closing tags at the current end of datasets, blank anything after them and flush the file.
Older content after the closing tags (an appended file edited by hand) is overwritten with blanks on the line of the closing tag, not truncated: the file is a valid collection at any time, and ENDFILE does not truncate a stream file with every compiler (nvfortran 26.9).
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. @note A file name ending in .series (case insensitive) is a ParaView file series (JSON), with the same actions.
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 (or .series) 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. filename, group and name are escaped as XML attribute values (&, <, >, ", '). In a .series file the entry is { "name" : filename, "time" : timestep } (a JSON string: " and \ escaped, control characters as \u00XX, read back); part, group and name are refused (error 1).
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. A .series file gives the name of each entry as file and its time as timestep (its position in the list, from 0, without time, as ParaView takes it); part 0, group and name empty.
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
read_series
Read the entries of a .series file (JSON): the name and time of each object of the array files. Error 1 if the file cannot be read, 2 if it is not a file series (no file-series-version, no files array, an entry without name, a time that is not a number).
Returns: integer(kind=I4P)
fortran
function read_series(self, filename) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(pvd_file) | inout | PVD file. | |
filename | character(len=*) | in | File name. |
Call graph
json_escape
Return a string as the content of a JSON string: " and \ escaped, control characters as \u00XX.
Attributes: pure
Returns: character(len=:)
fortran
function json_escape(string) result(escaped)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
string | character(len=*) | in | Input string. |
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