Skip to content

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 ​

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

NameTypeIntentAttributesDescription
stringcharacter(len=:)inoutallocatableString.

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, is_swapped)

Arguments

NameTypeIntentAttributesDescription
codecharacter(len=*)inBase64 code, without white space.
word_sizeinteger(kind=I8P)inSize of a header word: 4 (UInt32) or 8 (UInt64).
is_compressedlogicalinThe data are zlib compressed.
bytesinteger(kind=I1P)outallocatableData bytes.
errorinteger(kind=I4P)outError status: 0, or 6 if the code does not decode.
is_swappedlogicalinoptionalThe file is of the other byte order (its header words).

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; a sign alone before a value (+ Infinity, written by VTKFortran up to v3.x for non-finite reals) is the sign of that value. Reals are read as Fortran reads them (nan, inf, -inf, as VTK writes them, and Infinity). UInt64 values above huge(I8P) are kept with their bits (two's complement). The type String holds the bytes of the strings, written as integers.

fortran
subroutine decode_ascii(text, data_type, bytes, error)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText of the DataArray.
data_typecharacter(len=*)inVTK type.
bytesinteger(kind=I1P)outallocatableData bytes.
errorinteger(kind=I4P)outError 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. A sign alone, followed by a value, is the sign of that value (negative); the value returned is the one after it.

Attributes: pure

fortran
subroutine next_value(text, p, s, e, negative)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.
pinteger(kind=I8P)inoutCurrent position.
sinteger(kind=I8P)outFirst character of the value, 0 if there are no more values.
einteger(kind=I8P)outLast character of the value.
negativelogicaloutoptionalThe value is preceded by a minus alone.

Call graph

next_token ​

Return the next token of an ASCII text from a position, and advance the position after it.

Attributes: pure

fortran
subroutine next_token(text, p, s, e)

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)inText.
pinteger(kind=I8P)inoutCurrent position.
sinteger(kind=I8P)outFirst character of the token, 0 if there are no more tokens.
einteger(kind=I8P)outLast character of the token.

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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the strings.
xcharacter(len=:)outallocatableStrings.
errorinteger(kind=I4P)outError 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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the dataarray (native byte order).
data_typecharacter(len=*)inVTK type of the dataarray.
xreal(kind=R8P)outallocatableValues.
errorinteger(kind=I4P)outError 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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the dataarray (native byte order).
data_typecharacter(len=*)inVTK type of the dataarray.
xreal(kind=R4P)outallocatableValues.
errorinteger(kind=I4P)outError 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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the dataarray (native byte order).
data_typecharacter(len=*)inVTK type of the dataarray.
xinteger(kind=I8P)outallocatableValues.
errorinteger(kind=I4P)outError 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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the dataarray (native byte order).
data_typecharacter(len=*)inVTK type of the dataarray.
xinteger(kind=I4P)outallocatableValues.
errorinteger(kind=I4P)outError 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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the dataarray (native byte order).
data_typecharacter(len=*)inVTK type of the dataarray.
xinteger(kind=I2P)outallocatableValues.
errorinteger(kind=I4P)outError 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

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the dataarray (native byte order).
data_typecharacter(len=*)inVTK type of the dataarray.
xinteger(kind=I1P)outallocatableValues.
errorinteger(kind=I4P)outError 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; Bit (vtkBitArray) one byte per value as ASCII text, packed 8 values per byte otherwise (the reader unpacks them).

Attributes: elemental

Returns: integer(kind=I8P)

fortran
function data_type_size(data_type) result(bytes)

Arguments

NameTypeIntentAttributesDescription
data_typecharacter(len=*)inVTK 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

NameTypeIntentAttributesDescription
codecharacter(len=*)inBase64 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; with is_swapped (a file of the other byte order than the host's) the bytes of each word reversed first.

Attributes: pure

Returns: integer(kind=I8P)

fortran
function header_words(bytes, word_size, is_swapped) result(words)

Arguments

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes of the header (a multiple of the word size).
word_sizeinteger(kind=I8P)inSize of a word: 4 (UInt32) or 8 (UInt64).
is_swappedlogicalinoptionalThe file is of the other byte order.

Call graph

swap_bytes ​

Reverse the bytes of each word of word_size bytes (the byte order of the values of a binary array); trailing bytes of an incomplete word are left as they are.

Attributes: pure

Returns: integer(kind=I1P)

fortran
function swap_bytes(bytes, word_size) result(swapped)

Arguments

NameTypeIntentAttributesDescription
bytesinteger(kind=I1P)inBytes.
word_sizeinteger(kind=I8P)inSize of a word, bytes.

Call graph

uint64_bits ​

Return the bits of an unsigned 64-bit decimal value above huge(I8P) (two's complement, v - 2**64).

The value is q*10 + r (q its leading digits, r the last one); v - 2**64 = (t*9 + r - 6) + t, with t = q - 1844674407370955161 (2**64 = 1844674407370955161*10 + 6): no intermediate overflows.

Returns: logical

fortran
function uint64_bits(token, v) result(is_uint64)

Arguments

NameTypeIntentAttributesDescription
tokencharacter(len=*)inValue, decimal digits with an optional +.
vinteger(kind=I8P)outBits of the value.

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

NameTypeIntentAttributesDescription
ccharacter(len=1)inCharacter.

Call graph