From 4ad0b538037a23751238812f2536da7e0f5f6429 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Thu, 20 Jul 2023 09:11:12 -0500 Subject: [PATCH] Try compiling C example for netcdf --- .github/workflows/ci.yaml | 11 +++++++++++ continuous_integration/environment.yaml | 2 ++ test_write_netcdf.c | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 test_write_netcdf.c diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 39bc4a161b..5dc925f6d6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -62,6 +62,17 @@ jobs: run: | python -m pip install --no-deps -e . +# - name: Run test_write_netcdf +# shell: cmd +# run: | +# cl test_write_netcdf.c /out:test_write_netcdf.exe +# test_write_netcdf.exe + - name: Run test_write_netcdf + shell: bash -l {0} + run: | + gcc -o test_write_netcdf -L "${CONDA_PREFIX}/lib" -I "${CONDA_PREFIX}/include" -lnetcdf test_write_netcdf.c + ./test_write_netcdf + - name: Run test_netcdf manually - netcdf4 python close shell: bash -l {0} run: | diff --git a/continuous_integration/environment.yaml b/continuous_integration/environment.yaml index 96d7efa7ef..2e6f9c2091 100644 --- a/continuous_integration/environment.yaml +++ b/continuous_integration/environment.yaml @@ -9,3 +9,5 @@ dependencies: # PNetCDF (build 109) # - libnetcdf - netcdf4 +# - vc # [win] + - gcc diff --git a/test_write_netcdf.c b/test_write_netcdf.c new file mode 100644 index 0000000000..b85ff3e3fd --- /dev/null +++ b/test_write_netcdf.c @@ -0,0 +1,22 @@ +#include +#include +#include + +/* This macro handles errors by outputting a message to stdout and + then exiting. */ +#define NC_EXAMPLE_ERROR 2 /* This is the exit code for failure. */ +#define BAIL(e) do { \ + printf("Bailing out in file %s, line %d, error:%s.\n", \ + __FILE__, __LINE__, nc_strerror(e)); \ + return NC_EXAMPLE_ERROR; \ + } while (0) + +int main() { + int res, ncid; + res = nc_create("test_netcdf_c.nc", NC_CLOBBER, &ncid); + if (res) { + BAIL(res); + } + printf("SUCCESS!\n"); + return 0; +}