Appearance
vtk_fortran_zlib
Minimal zlib bindings used for VTK XML internal compression (vtkZLibDataCompressor), compression and decompression.
The module is always compiled: without VTKFORTRAN_USE_ZLIB the procedures are stubs returning an error, and is_zlib_enabled is .false.. With it, the library must be linked with zlib (-lz).
Source: src/lib/vtk_fortran_zlib.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
Z_DEFAULT_COMPRESSION | integer(kind=c_int) | parameter | zlib default compression level (currently 6). |
Z_BEST_SPEED | integer(kind=c_int) | parameter | zlib fastest compression level. |
Z_BEST_COMPRESSION | integer(kind=c_int) | parameter | zlib best compression level. |
is_zlib_enabled | logical | parameter | The library is built with zlib (VTKFORTRAN_USE_ZLIB). |
Subroutines
zlib_compress_blocks
Compress a bytes stream into VTK compressed blocks (vtkZLibDataCompressor layout).
The stream is split into blocks of block_size bytes (the last one can be shorter), each compressed independently. The VTK header of the compressed data is returned as I8P words, its width in the file (UInt32 or UInt64) is chosen by the caller:
header = [number of blocks, block size, last block size, compressed size of each block]As VTK writes it, the last block size is the size of a partial last block, 0 when all blocks are full; an empty stream has no blocks. blocks holds the compressed blocks, concatenated.
fortran
subroutine zlib_compress_blocks(bytes, block_size, level, header, blocks, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
bytes | integer(kind=c_signed_char) | in | Uncompressed bytes. | |
block_size | integer(kind=I8P) | in | Uncompressed block size in bytes. | |
level | integer(kind=c_int) | in | zlib compression level. | |
header | integer(kind=I8P) | out | allocatable | VTK header of the compressed data. |
blocks | integer(kind=c_signed_char) | out | allocatable | Compressed blocks. |
error | integer | out | Error status: 0 on success. |
Call graph
zlib_uncompress_blocks
Decompress VTK compressed blocks (vtkZLibDataCompressor layout) into a bytes stream: the inverse of zlib_compress_blocks.
The header, read from the file as UInt32 or UInt64 words and passed as I8P, is
header = [number of blocks, block size, last block size, compressed size of each block]where a last block size of 0 means that the last block is full. blocks holds the compressed blocks, concatenated (it can be longer than their total). The header is checked before decompressing: an inconsistent header, a block that does not decompress to its declared size, or a library built without zlib return a non-zero error.
fortran
subroutine zlib_uncompress_blocks(header, blocks, bytes, error)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
header | integer(kind=I8P) | in | VTK header of the compressed data. | |
blocks | integer(kind=c_signed_char) | in | Compressed blocks. | |
bytes | integer(kind=c_signed_char) | out | allocatable | Uncompressed bytes. |
error | integer | out | Error status: 0 on success. |
Call graph
Functions
zlib_compress_bound
Upper bound of the compressed size of n bytes (0 without zlib).
Returns: integer(kind=c_long)
fortran
function zlib_compress_bound(n) result(bound)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
n | integer(kind=c_long) | value | Uncompressed size in bytes. |
Call graph
zlib_compress2
Compress a byte buffer with zlib compress2 (an error without zlib).
Returns: integer(kind=c_int)
fortran
function zlib_compress2(dst, dst_len, src, src_len, level) result(ret)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
dst | integer(kind=c_signed_char) | inout | target | Compressed buffer. |
dst_len | integer(kind=c_long) | inout | target | Size of dst on input, compressed size on output. |
src | integer(kind=c_signed_char) | in | target | Uncompressed buffer. |
src_len | integer(kind=c_long) | in | Uncompressed size in bytes. | |
level | integer(kind=c_int) | in | Compression level. |
Call graph
zlib_uncompress
Decompress a byte buffer with zlib uncompress (an error without zlib).
Returns: integer(kind=c_int)
fortran
function zlib_uncompress(dst, dst_len, src, src_len) result(ret)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
dst | integer(kind=c_signed_char) | inout | target | Uncompressed buffer. |
dst_len | integer(kind=c_long) | inout | target | Size of dst on input, uncompressed size on output. |
src | integer(kind=c_signed_char) | in | target | Compressed buffer. |
src_len | integer(kind=c_long) | in | Compressed size in bytes. |
Call graph