dm_z_compress Interface

public interface dm_z_compress

Generic serialisation and compression function.


Module Procedures

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