Appearance
vtk_fortran_dataarray_decoder
VTK_Fortran dataarray decoder: the inverse of the encoder, from ASCII and Base64 (optionally zlib compressed) data.
A DataArray is decoded into its bytes, in the native byte order (the reader refuses BigEndian files, so the bytes of the little endian files are native on the supported platforms), then converted into an array of the kind requested by bytes_to_array. The errors are 0 on success, 5 for a kind that cannot hold the type, 6 for data that do not decode.
Source: src/lib/vtk_fortran_dataarray_decoder.f90
Dependencies
Contents
- bytes_to_array
- strip_spaces
- decode_base64
- decode_ascii
- next_value
- bytes_to_strings
- bytes_to_array_R8P
- bytes_to_array_R4P
- bytes_to_array_I8P
- bytes_to_array_I4P
- bytes_to_array_I2P
- bytes_to_array_I1P
- data_type_size
- base64_decoded_size
- header_words
- is_space
Interfaces
bytes_to_array
Convert the bytes of a dataarray of a VTK type into an array.
The array must have the kind of the type, or a kind that holds all its values: Int8 into I1P...I8P, Int16 into I2P...I8P, Int32 into I4P or I8P, Int64 into I8P, Float32 into R4P or R8P, Float64 into R8P. The unsigned types go into the signed kind of the same width, with the same bits (as write_dataarray_unsigned writes them), or into any wider kind, with their values. Other kinds return the error 5.
Module procedures: bytes_to_array_R8P, bytes_to_array_R4P, bytes_to_array_I8P, bytes_to_array_I4P, bytes_to_array_I2P, bytes_to_array_I1P
Subroutines
strip_spaces
Remove the white space (blank, tab, line feed, carriage return) of a string, in place.
Attributes: pure
fortran
subroutine strip_spaces(string)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
string | character(len=:) | inout | allocatable | String. |
Call graph
decode_base64
Decode the base64 code of a binary DataArray (inline or appended), header included, into its data bytes.
Uncompressed, the code is one base64 stream: the bytes count (a header word) followed by the data. Compressed, it is two streams: the VTK header of the compressed data (number of blocks, block size, last block size, compressed size of each block), then the compressed blocks. The code must be without white space.
fortran
subroutine decode_base64(code, word_size, is_compressed, bytes, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
code | character(len=*) | in | Base64 code, without white space. | |
word_size | integer(kind=I8P) | in | Size of a header word: 4 (UInt32) or 8 (UInt64). | |
is_compressed | logical | in | The data are zlib compressed. | |
bytes | integer(kind=I1P) | out | allocatable | Data bytes. |
error | integer(kind=I4P) | out | Error status: 0, or 6 if the code does not decode. |
Call graph
decode_ascii
Decode the text of an ASCII DataArray into its bytes (native byte order).
Values are separated by white space; values written without separation (e.g. +0.3E+001+0.1E+002, written by VTKFortran up to v2.0.10) are split at the sign that follows a digit or a point. The type String holds the bytes of the strings, written as integers.
fortran
subroutine decode_ascii(text, data_type, bytes, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text of the DataArray. | |
data_type | character(len=*) | in | VTK type. | |
bytes | integer(kind=I1P) | out | allocatable | Data bytes. |
error | integer(kind=I4P) | out | Error status: 0, or 6 if the text does not decode. |
Call graph
next_value
Return the next value of an ASCII text from a position, and advance the position after it.
Attributes: pure
fortran
subroutine next_value(text, p, s, e)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
p | integer(kind=I8P) | inout | Current position. | |
s | integer(kind=I8P) | out | First character of the value, 0 if there are no more values. | |
e | integer(kind=I8P) | out | Last character of the value. |
Call graph
bytes_to_strings
Convert the bytes of a String array (each string terminated by a NUL byte) into an array of strings.
The strings are blank padded to the length of the longest one; a last string without a NUL byte is kept.
fortran
subroutine bytes_to_strings(bytes, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the strings. | |
x | character(len=:) | out | allocatable | Strings. |
error | integer(kind=I4P) | out | Error status: 0 on success. |
Call graph
bytes_to_array_R8P
Convert the bytes of a dataarray of a VTK type into an array (R8P): see bytes_to_array for the conversions allowed.
fortran
subroutine bytes_to_array_R8P(bytes, data_type, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the dataarray (native byte order). | |
data_type | character(len=*) | in | VTK type of the dataarray. | |
x | real(kind=R8P) | out | allocatable | Values. |
error | integer(kind=I4P) | out | Error status: 0, or 5 if R8P cannot hold the type. |
Call graph
bytes_to_array_R4P
Convert the bytes of a dataarray of a VTK type into an array (R4P): see bytes_to_array for the conversions allowed.
fortran
subroutine bytes_to_array_R4P(bytes, data_type, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the dataarray (native byte order). | |
data_type | character(len=*) | in | VTK type of the dataarray. | |
x | real(kind=R4P) | out | allocatable | Values. |
error | integer(kind=I4P) | out | Error status: 0, or 5 if R4P cannot hold the type. |
Call graph
bytes_to_array_I8P
Convert the bytes of a dataarray of a VTK type into an array (I8P): see bytes_to_array for the conversions allowed.
fortran
subroutine bytes_to_array_I8P(bytes, data_type, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the dataarray (native byte order). | |
data_type | character(len=*) | in | VTK type of the dataarray. | |
x | integer(kind=I8P) | out | allocatable | Values. |
error | integer(kind=I4P) | out | Error status: 0, or 5 if I8P cannot hold the type. |
Call graph
bytes_to_array_I4P
Convert the bytes of a dataarray of a VTK type into an array (I4P): see bytes_to_array for the conversions allowed.
fortran
subroutine bytes_to_array_I4P(bytes, data_type, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the dataarray (native byte order). | |
data_type | character(len=*) | in | VTK type of the dataarray. | |
x | integer(kind=I4P) | out | allocatable | Values. |
error | integer(kind=I4P) | out | Error status: 0, or 5 if I4P cannot hold the type. |
Call graph
bytes_to_array_I2P
Convert the bytes of a dataarray of a VTK type into an array (I2P): see bytes_to_array for the conversions allowed.
fortran
subroutine bytes_to_array_I2P(bytes, data_type, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the dataarray (native byte order). | |
data_type | character(len=*) | in | VTK type of the dataarray. | |
x | integer(kind=I2P) | out | allocatable | Values. |
error | integer(kind=I4P) | out | Error status: 0, or 5 if I2P cannot hold the type. |
Call graph
bytes_to_array_I1P
Convert the bytes of a dataarray of a VTK type into an array (I1P): see bytes_to_array for the conversions allowed.
fortran
subroutine bytes_to_array_I1P(bytes, data_type, x, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the dataarray (native byte order). | |
data_type | character(len=*) | in | VTK type of the dataarray. | |
x | integer(kind=I1P) | out | allocatable | Values. |
error | integer(kind=I4P) | out | Error status: 0, or 5 if I1P cannot hold the type. |
Call graph
Functions
data_type_size
Return the size in bytes of a value of a VTK type (0 for an unknown type).
The type String (field data strings) counts the bytes of the strings.
Attributes: elemental
Returns: integer(kind=I8P)
fortran
function data_type_size(data_type) result(bytes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
data_type | character(len=*) | in | VTK type. |
Call graph
base64_decoded_size
Return the number of bytes encoded by a base64 code (without white space), 0 if its length is not a multiple of 4.
Attributes: pure
Returns: integer(kind=I8P)
fortran
function base64_decoded_size(code) result(n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
code | character(len=*) | in | Base64 code. |
Call graph
header_words
Return the words of a VTK binary header (UInt32 or UInt64, given by their size, 4 or 8 bytes) from its bytes.
Attributes: pure
Returns: integer(kind=I8P)
fortran
function header_words(bytes, word_size) result(words)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=I1P) | in | Bytes of the header (a multiple of the word size). | |
word_size | integer(kind=I8P) | in | Size of a word: 4 (UInt32) or 8 (UInt64). |
Call graph
is_space
Return .true. if a character is white space (blank, tab, line feed, carriage return).
Attributes: elemental
Returns: logical
fortran
function is_space(c) result(is_blank)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
c | character(len=1) | in | Character. |
Call graph