Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ci workflow #3

Merged
merged 7 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: zfp Fortran Testing

# Define when to trigger the workflow
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
test_bindings:
name: Test zfp Fortran example on ubuntu-latest
runs-on: ubuntu-latest

strategy:
matrix:
gcc-version: [10, 11]

steps:
# Setup GCC
- name: Get compiler
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: ${{ matrix.gcc-version }}

# Clone the own repository to access test data files
- name: Clone own repository
uses: actions/checkout@v4
with:
fetch-depth: 0

# Build executable and compare output files
- name: Build simple and exe executables and compare files
run: |
cmake -S . -B build -DREAL_KIND=REAL64 -DBUILD_EXAMPLES=ON -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build build
cd build
./exe -c
./exe -d
cd _deps/zfp-build/bin/
./simple > compressed_c.zfp
./simple -d < compressed_c.zfp > decompressed_c.zfp
cmp compressed_c.zfp ../../../compressed.zfp && echo "Files are identical" || { echo "Files are different"; exit 1; }
cmp decompressed_c.zfp ../../../decompressed.zfp && echo "Files are identical" || { echo "Files are different"; exit 1; }
6 changes: 3 additions & 3 deletions zfp_fct_wrapper.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module zfp_fct_wrapper
use, intrinsic :: iso_c_binding, only : c_long, c_double, c_loc, c_sizeof
use, intrinsic :: iso_c_binding, only : c_ptr, c_long, c_double, c_loc, c_sizeof
use, intrinsic :: iso_fortran_env
use zfp

Expand Down Expand Up @@ -43,7 +43,7 @@ subroutine compress(indata, buffer, tolerance, precision, rate, parallel)
if(present(tolerance) .and. present(precision)) stop 'only 1 parameter is allowed'
if(present(tolerance) .and. present(rate)) stop 'only 1 parameter is allowed'
if(present(rate) .and. present(precision)) stop 'only 1 parameter is allowed'
if(present(parallel) .and. (parallel .eq. .false.)) parl =.false.
if(present(parallel) .and. (parallel .eqv. .false.)) parl =.false.

in_ptr = c_loc(indata); shap = shape(indata)
if (c_sizeof(1._wp) .eq. 8) then
Expand Down Expand Up @@ -114,7 +114,7 @@ subroutine decompress(buffer, outdata, tolerance, precision, rate, parallel)
if(present(tolerance) .and. present(precision)) stop 'only 1 parameter is allowed'
if(present(tolerance) .and. present(rate)) stop 'only 1 parameter is allowed'
if(present(rate) .and. present(precision)) stop 'only 1 parameter is allowed'
if(present(parallel) .and. (parallel .eq. .false.)) parl =.false.
if(present(parallel) .and. (parallel .eqv. .false.)) parl =.false.

out_ptr = c_loc(outdata); shap = shape(outdata)
if (c_sizeof(1._wp) .eq. 8) then
Expand Down