Appearance
vtk_fortran_vtm_file
VTM file class.
Source: src/lib/vtk_fortran_vtm_file.F90
Dependencies
Contents
- vtm_file
- initialize
- finalize
- get_entries
- write_block_array
- write_block_string
- parse_scratch_files
- write_block_scratch
Derived Types
vtm_file
VTM file class.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
xml_writer | class(xml_writer_abstract) | allocatable | XML writer. |
scratch_unit | integer(kind=I4P) | allocatable | Scratch units for very large list of named blocks. |
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 |
|---|---|---|
initialize | pass(self) | Initialize file. |
finalize | pass(self) | Finalize file. |
get_entries | pass(self) | Return the blocks and datasets of a file read. |
write_block | Write one block dataset. | |
write_block_array | pass(self) | Write one block dataset (array input). |
write_block_string | pass(self) | Write one block dataset (string input). |
parse_scratch_files | pass(self) | Parse scratch files. |
write_block_scratch | pass(self) | Write one block dataset on scratch files. |
Functions
initialize
Initialize file: open it for writing (default) or for reading.
With action='read' (case insensitive) the file is indexed: its blocks and datasets are returned by get_entries, and each dataset file can then be read with vtk_file (or pvtk_file); finalize frees the index. The error is 1 if the file cannot be read, 2 if it is not a multi-block file (vtkMultiBlockDataSet).
Returns: integer(kind=I4P)
fortran
function initialize(self, filename, scratch_units_number, action) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | inout | VTM file. | |
filename | character(len=*) | in | File name of output VTM file. | |
scratch_units_number | integer(kind=I4P) | in | optional | Number of scratch units for very large list of named blocks. |
action | character(len=*) | in | optional | Action: write (default) or read. |
Call graph
finalize
Finalize file (writer).
Returns: integer(kind=I4P)
fortran
function finalize(self) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | inout | VTM file. |
Call graph
get_entries
Return the blocks and datasets of a file read (initialize(..., action='read')), in the order of the file.
The hierarchy is flattened depth first: each entry has its nesting level (1 for the children of the root), its kind (block, dataset, or piece for the pieces of a vtkMultiPieceDataSet written by VTK), its index among the children of its parent (-1 if the file has none), its name and, for datasets, its file (empty for blocks and pieces, or for datasets without file). The children of an entry are the following entries of the next level. The names and files are blank padded to the longest one; relative files are relative to the directory of the .vtm file.
fortran
type(vtm_file) :: vtm
integer(I4P), allocatable :: level(:)
character(len=:), allocatable :: kind(:), file(:)
error = vtm%initialize(filename='assembly.vtm', action='read')
error = vtm%get_entries(level=level, kind=kind, file=file)
error = vtm%finalize()Returns: integer(kind=I4P)
fortran
function get_entries(self, level, kind, index, name, file) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | in | VTM file. | |
level | integer(kind=I4P) | out | allocatable, optional | Nesting level of the entries, from 1. |
kind | character(len=:) | out | allocatable, optional | Kind of the entries: block, dataset or piece. |
index | integer(kind=I4P) | out | allocatable, optional | Index of the entries among their siblings. |
name | character(len=:) | out | allocatable, optional | Name of the entries. |
file | character(len=:) | out | allocatable, optional | File of the datasets. |
Call graph
write_block_array
Write one block dataset (array input).
By default the files are wrapped in a new block; with action='write' they are written as datasets of the current (open) block, without a new block.
Example of usage: 3 files blocks
fortran
error = vtm%write_block(filenames=['file_1.vts', 'file_2.vts', 'file_3.vtu'], name='my_block')Example of usage: 3 files blocks with custom name
fortran
error = vtm%write_block(filenames=['file_1.vts', 'file_2.vts', 'file_3.vtu'], &
names=['block-bar', 'block-foo', 'block-baz'], name='my_block')Example of usage: nested blocks
fortran
error = vtm%write_block(action='open', name='assembly')
error = vtm%write_block(filenames=['part_1.vtu', 'part_2.vtu'], action='write') ! datasets 0, 1 of assembly
error = vtm%write_block(filenames=['bolt_1.vtu', 'bolt_2.vtu'], name='bolts') ! block 2 of assembly
error = vtm%write_block(action='close')Returns: integer(kind=I4P)
fortran
function write_block_array(self, filenames, names, name, action) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | inout | VTM file. | |
filenames | character(len=*) | in | File names of VTK files grouped into current block. | |
names | character(len=*) | in | optional | Auxiliary names attributed to each files. |
name | character(len=*) | in | optional | Block name |
action | character(len=*) | in | optional | Action: 'write' (datasets of the current block) or default. |
Call graph
write_block_string
Write one block dataset (string input).
With action the block is written in steps, so blocks can be nested: 'open' opens a (child) block, 'write' writes the files as datasets of the current block, 'close' closes it. The children of a block (blocks and datasets) are indexed from 0 in the order they are written.
Example of usage: 3 files blocks
fortran
error = vtm%write_block(filenames='file_1.vts file_2.vts file_3.vtu', name='my_block')Example of usage: 3 files blocks with custom name
fortran
error = vtm%write_block(filenames='file_1.vts file_2.vts file_3.vtu', names='block-bar block-foo block-baz', name='my_block')Returns: integer(kind=I4P)
fortran
function write_block_string(self, action, filenames, names, name) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | inout | VTM file. | |
action | character(len=*) | in | optional | Action: [open, close, write]. |
filenames | character(len=*) | in | optional | File names of VTK files grouped into current block. |
names | character(len=*) | in | optional | Auxiliary names attributed to each files. |
name | character(len=*) | in | optional | Block name |
Call graph
parse_scratch_files
Parse scratch files.
Returns: integer(kind=I4P)
fortran
function parse_scratch_files(self) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | inout | VTM file. |
Call graph
write_block_scratch
Write one block dataset on scratch files.
Returns: integer(kind=I4P)
fortran
function write_block_scratch(self, scratch, action, filename, name) result(error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(vtm_file) | inout | VTM file. | |
scratch | integer(kind=I4P) | in | Scratch unit. | |
action | character(len=*) | in | Action: [open, write]. | |
filename | character(len=*) | in | optional | File name of VTK file grouped into current block. |
name | character(len=*) | in | optional | Block name |