Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/interkosmos/fortran-zstd
Fortran 2018 interface bindings to Zstandard (zstd)
https://github.com/interkosmos/fortran-zstd
archiving compression fortran fortran-2018 fortran-package-manager zstandard zstd
Last synced: about 1 month ago
JSON representation
Fortran 2018 interface bindings to Zstandard (zstd)
- Host: GitHub
- URL: https://github.com/interkosmos/fortran-zstd
- Owner: interkosmos
- License: isc
- Created: 2024-04-02T21:52:53.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-07-19T08:01:18.000Z (7 months ago)
- Last Synced: 2024-11-08T03:09:37.318Z (3 months ago)
- Topics: archiving, compression, fortran, fortran-2018, fortran-package-manager, zstandard, zstd
- Language: Fortran
- Homepage:
- Size: 24.4 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fortran-zstd
A collection of Fortran 2018 interface bindings to selected
[Zstandard](http://www.zstd.net/) functions (zstd ≥ 1.5.5). In comparison to the
original C API, the Fortran interfaces, types, and arguments have been converted
to snake case. See [COVERAGE](COVERAGE.md) for an overview of bound procedures.## Build Instructions
The zstd library has to be installed with development headers. On FreeBSD, run:
```
# pkg install archivers/zstd
```On Linux, instead:
```
# apt-get install libzstd1 libzstd-dev
```Or, to build the zstd library from source, and to install to `/usr/local`, run:
```
$ cd /tmp/
$ git clone --depth 1 https://github.com/facebook/zstd
$ cd zstd/build/cmake/
$ mkdir build && cd build/
$ cmake ..
$ cmake --build . --config Release
$ sudo cmake --install . --prefix /usr/local
```Build and install the Fortran library using the provided Makefile:
```
$ make
$ make install PREFIX=/opt
```Link your programs against `/opt/lib/libfortran-zstd.a -lzstd`. Optionally,
overwrite the default compiler and the compiler flags:```
$ make FC=ifx FFLAGS="-O3"
```Or, use the [Fortran Package Manager](https://github.com/fortran-lang/fpm):
```
$ fpm build --profile release
```Build and run the test program:
```
$ make test
$ ./test_zstd
```## Example
The following basic example compresses and uncompresses an input string.
```fortran
! example.f90
program main
use, intrinsic :: iso_c_binding
use :: zstd
implicit none (type, external)character(len=:), allocatable :: dst1, dst2, src
integer(kind=c_size_t) :: dst_len, src_len, statsrc = repeat('Hello, there! ', 32)
src_len = len(src, kind=c_size_t)
dst_len = zstd_compress_bound(src_len)allocate (character(len=dst_len) :: dst1)
allocate (character(len=src_len) :: dst2)stat = zstd_compress(dst1, dst_len, src, src_len, zstd_default_c_level())
dst_len = statif (zstd_is_error(stat)) then
print '("zstd_compress: ", a)', zstd_get_error_name(stat)
error stop
end ifstat = zstd_decompress(dst2, src_len, dst1, dst_len)
if (zstd_is_error(stat)) then
print '("zstd_decompress: ", a)', zstd_get_error_name(stat)
error stop
end if
end program main
```If the library is installed to `/opt`, then compile, link, and run the example
program with:```
$ gfortran -I/opt/include/libfortran-zstd -o example example.f90 \
/opt/lib/libfortran-zstd.a -lzstd
$ ./example
```## Fortran Package Manager
You can add *fortran-zstd* as an FPM dependency:
```toml
[dependencies]
fortran-zstd = { git = "https://github.com/interkosmos/fortran-zstd.git" }
```## References
* [Zstandard manual](http://facebook.github.io/zstd/zstd_manual.html)
* [Zstandard repository](https://github.com/facebook/zstd)
* [Zstandard website](http://www.zstd.net/)## Licence
ISC