dm_z Module

Utility module for (de-)serialisation and (de-)compression (zlib, zstd) of derived types. Namelist is the only serialisation format supported.


Uses

  • module~~dm_z~~UsesGraph module~dm_z dm_z module~dm_error dm_error module~dm_z->module~dm_error module~dm_kind dm_kind module~dm_z->module~dm_kind module~dm_nml dm_nml module~dm_z->module~dm_nml module~dm_zlib dm_zlib module~dm_z->module~dm_zlib module~dm_zstd dm_zstd module~dm_z->module~dm_zstd module~dm_error->module~dm_kind module~dm_ascii dm_ascii module~dm_error->module~dm_ascii iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env module~dm_nml->module~dm_error module~dm_nml->module~dm_kind module~dm_zlib->module~dm_error module~dm_zlib->module~dm_kind zlib zlib module~dm_zlib->zlib module~dm_zstd->module~dm_error module~dm_zstd->module~dm_kind iso_c_binding iso_c_binding module~dm_zstd->iso_c_binding zstd zstd module~dm_zstd->zstd

Used by

  • module~~dm_z~~UsedByGraph module~dm_z dm_z module~dm_rpc dm_rpc module~dm_rpc->module~dm_z module~dmpack dmpack module~dmpack->module~dm_z module~dmpack->module~dm_rpc

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: Z_TYPE_INVALID = -1

Invalid or unknown type.

integer, public, parameter :: Z_TYPE_NONE = 0

No compression.

integer, public, parameter :: Z_TYPE_ZLIB = 1

Deflate compression.

integer, public, parameter :: Z_TYPE_ZSTD = 2

Zstandard compression.

integer, public, parameter :: Z_TYPE_LAST = 2

Never use this.

integer, public, parameter :: Z_TYPE_NAME_LEN = 4

Max. type enumerator name length.

character(len=*), public, parameter :: Z_TYPE_NAMES(0:Z_TYPE_LAST) = [character(len=4)::'none', 'zlib', 'zstd']

Compression type enumerator names.


Interfaces

public interface dm_z_compress

Generic serialisation and compression function.

  • private function z_compress(input, z, output, input_len, output_len, context) result(rc)

    Compresses given input and returns the result in allocatable string output. The actual length may be smaller than the string length and is returned in output_len.

    The following compression types are supported:

    • Z_TYPE_NONE – No compression (output equals input).
    • Z_TYPE_ZLIB – Deflate compression.
    • Z_TYPE_ZSTD – Zstandard compression.

    The function returns the following error codes:

    • E_INVALID if compression type is invalid.
    • E_ZLIB if zlib library call failed.
    • E_ZSTD if zstd library call failed.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Uncompressed data.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Compressed data.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    integer(kind=i8), intent(out), optional :: output_len

    Actual output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_compress_beat(beat, z, output, output_len, context) result(rc)

    Serialises beat beat to namelist format and compresses it depending on z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output.

    Arguments

    Type IntentOptional Attributes Name
    type(beat_type), intent(inout) :: beat

    Beat type to serialise and compress.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Serialised and compressed beat.

    integer(kind=i8), intent(out), optional :: output_len

    Output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_compress_log(log, z, output, output_len, context) result(rc)

    Serialises log log to namelist format and compresses it depending on z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output.

    Arguments

    Type IntentOptional Attributes Name
    type(log_type), intent(inout) :: log

    Log type to serialise and compress.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Serialised and compressed log.

    integer(kind=i8), intent(out), optional :: output_len

    Output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_compress_node(node, z, output, output_len, context) result(rc)

    Serialises node node to namelist format and compresses it depending on z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output.

    Arguments

    Type IntentOptional Attributes Name
    type(node_type), intent(inout) :: node

    Node type to serialise and compress.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Serialised and compressed node.

    integer(kind=i8), intent(out), optional :: output_len

    Output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_compress_observ(observ, z, output, output_len, context) result(rc)

    Serialises observation observ to namelist format and compresses it depending on z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output.

    Arguments

    Type IntentOptional Attributes Name
    type(observ_type), intent(inout) :: observ

    Observation type to serialise and compress.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Serialised and compressed observation.

    integer(kind=i8), intent(out), optional :: output_len

    Output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_compress_sensor(sensor, z, output, output_len, context) result(rc)

    Serialises sensor sensor to namelist format and compresses it depending on z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output.

    Arguments

    Type IntentOptional Attributes Name
    type(sensor_type), intent(inout) :: sensor

    Sensor type to serialise and compress.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Serialised and compressed sensor.

    integer(kind=i8), intent(out), optional :: output_len

    Output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_compress_target(target, z, output, output_len, context) result(rc)

    Serialises target target to namelist format and compresses it depending on z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output.

    Arguments

    Type IntentOptional Attributes Name
    type(target_type), intent(inout) :: target

    Target type to serialise and compress.

    integer, intent(in) :: z

    Output compression enumerator (Z_TYPE_*).

    character(len=:), intent(out), allocatable :: output

    Serialised and compressed target.

    integer(kind=i8), intent(out), optional :: output_len

    Output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard compression context to use with type Z_TYPE_ZSTD.

    Return Value integer

public interface dm_z_uncompress

Generic deserialisation and decompression function.

  • private function z_uncompress(input, z, output, input_len, output_len, context) result(rc)

    Uncompresses given input and returns the result in string output. The string must be allocated and large enough to hold the uncompressed data. The actual length may be smaller than the output length and is returned in output_len.

    The following compression types are supported:

    • Z_TYPE_NONE – No compression (output equals input).
    • Z_TYPE_ZLIB – Deflate compression.
    • Z_TYPE_ZSTD – Zstandard compression.

    The function returns the following error codes:

    • E_INVALID if compression type is invalid.
    • E_ZLIB if zlib library call failed.
    • E_ZSTD if zstd library call failed.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed data.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    character(len=*), intent(inout) :: output

    Uncompressed data.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    integer(kind=i8), intent(out), optional :: output_len

    Actual output length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_uncompress_beat(input, z, beat, input_len, context) result(rc)

    Uncompressed compressed beat namelist input and returns deserialised type in beat.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed and Namelist-serialised beat.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    type(beat_type), intent(out) :: beat

    Uncompressed and deserialised beat.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_uncompress_log(input, z, log, input_len, context) result(rc)

    Uncompressed compressed log namelist input and returns deserialised type in log.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed and Namelist-serialised log.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    type(log_type), intent(out) :: log

    Uncompressed and deserialised log.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_uncompress_node(input, z, node, input_len, context) result(rc)

    Uncompressed compressed node namelist input and returns deserialised type in node.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed and Namelist-serialised node.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    type(node_type), intent(out) :: node

    Uncompressed and deserialised node.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_uncompress_observ(input, z, observ, input_len, context) result(rc)

    Uncompressed compressed observation namelist input and returns deserialised z in observ.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed and Namelist-serialised observation.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    type(observ_type), intent(out) :: observ

    Uncompressed and deserialised observation.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_uncompress_sensor(input, z, sensor, input_len, context) result(rc)

    Uncompressed compressed sensor namelist input and returns deserialised type in sensor.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed and Namelist-serialised sensor.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    type(sensor_type), intent(out) :: sensor

    Uncompressed and deserialised sensor.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

  • private function z_uncompress_target(input, z, target, input_len, context) result(rc)

    Uncompressed compressed target namelist input and returns deserialised type in target.

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(inout) :: input

    Compressed and Namelist-serialised target.

    integer, intent(in) :: z

    Input compression enumerator (Z_TYPE_*).

    type(target_type), intent(out) :: target

    Uncompressed and deserialised target.

    integer(kind=i8), intent(in), optional :: input_len

    Actual input length.

    type(zstd_context_type), intent(inout), optional :: context

    Zstandard decompression context to use with type Z_TYPE_ZSTD.

    Return Value integer

public interface dm_z_valid

Generic validation function.

  • public pure elemental function dm_z_valid_type(z) result(valid)

    Returns .true. if the given compression enumerator z is valid. The type Z_TYPE_NONE is a valid type, and Z_TYPE_INVALID is invalid.

    Arguments

    Type IntentOptional Attributes Name
    integer, intent(in) :: z

    Compression enumerator.

    Return Value logical


Functions

public function dm_z_compress_type(type, z, output, output_len, context) result(rc)

Serialises derived type to namelist format and compresses it depending on compression type z. The serialised and compressed result is returned in output. The argument output_len will equal the length of output. The function returns E_INVALID if type is unsupported.

Arguments

Type IntentOptional Attributes Name
class(*), intent(inout) :: type

Derived type to serialise and compress.

integer, intent(in) :: z

Output compression enumerator (Z_TYPE_*).

character(len=:), intent(out), allocatable :: output

Serialised and compressed type.

integer(kind=i8), intent(out), optional :: output_len

Output length.

type(zstd_context_type), intent(inout), optional :: context

Zstandard compression context to use with type Z_TYPE_ZSTD.

Return Value integer

public function dm_z_compress_types(types, z, output) result(rc)

Serialises derived types types to namelist format and compresses them depending on compression type z. If z is Z_TYPE_ZSTD, the function uses a Zstandard compression context. The serialised and compressed results are returned in output. The function returns E_INVALID if types is unsupported. On error, not all strings of output may be allocated.

Arguments

Type IntentOptional Attributes Name
class(*), intent(inout) :: types(:)

Derived types to serialise and compress.

integer, intent(in) :: z

Output compression enumerator (Z_TYPE_*).

type(string_type), intent(out), allocatable :: output(:)

Serialised and compressed types.

Return Value integer

public pure elemental function dm_z_type_from_encoding(encoding) result(z)

Returns compression type enumerator from HTTP content encoding:

Read more…

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: encoding

Content encoding name.

Return Value integer

public pure elemental function dm_z_type_from_name(name) result(z)

Returns compression type enumerator from name. The function returns Z_TYPE_INVALID if the name is not a valid type name.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Compression enumerator name.

Return Value integer

public pure function dm_z_type_to_encoding(z) result(encoding)

Returns allocatable HTTP content type string from compression type enumerator. The function returns an empty string for types Z_TYPE_INVALID and Z_TYPE_NONE.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: z

Compression enumerator.

Return Value character(len=:), allocatable

Content encoding string.

public pure elemental function dm_z_valid_type(z) result(valid)

Returns .true. if the given compression enumerator z is valid. The type Z_TYPE_NONE is a valid type, and Z_TYPE_INVALID is invalid.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: z

Compression enumerator.

Return Value logical