From 45a492f25817d7456d5b4ed41babb89759ed032d Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 13:40:56 -0700 Subject: [PATCH 01/43] require g2c for jasper and use g2c dec/enc --- .github/workflows/developer.yml | 41 ++++++++++++++------------------- CMakeLists.txt | 19 +++++++-------- wgrib2/CMakeLists.txt | 2 +- wgrib2/jpeg_pk.c | 4 ++-- wgrib2/unpk.c | 33 +++++++++++++++++--------- wgrib2/wgrib2.h | 4 ++-- 6 files changed, 54 insertions(+), 49 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 9f4defff..fba1f1dd 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -34,29 +34,6 @@ jobs: sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config sudo apt-get install libpng-dev autotools-dev libaec-dev autoconf gcovr doxygen - - name: cache-jasper - id: cache-jasper - uses: actions/cache@v4 - with: - path: ~/jasper - key: jasper-${{ runner.os }}-1.900.1 - - - name: checkout-jasper - if: steps.cache-jasper.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - repository: jasper-software/jasper - path: jasper - ref: version-1.900.1 - - - name: build-jasper - if: steps.cache-jasper.outputs.cache-hit != 'true' - run: | - cd jasper - ./configure --prefix=$HOME/jasper - make - make install - - name: checkout-ip uses: actions/checkout@v4 with: @@ -73,6 +50,22 @@ jobs: make -j2 make install + - name: checkout-g2c + uses: actions/checkout@v4 + with: + repository: NOAA-EMC/NCEPLIBS-g2c + path: g2c + ref: develop + + - name: build-g2c + run: | + cd g2c + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX=~/g2c -DCMAKE_PREFIX_PATH=~ -DUSE_JASPER=ON + make -j2 + make install + - name: checkout uses: actions/checkout@v4 with: @@ -93,7 +86,7 @@ jobs: export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/jasper" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON + cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_G2CLIB=ON -DUSE_JASPER=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index 07168a58..412bb491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,13 +75,11 @@ endif() message(STATUS "Checking if user wants to use NCEPLIBS-g2c...") if(USE_G2CLIB) + find_package(g2c REQUIRED) + if(USE_PNG) message(FATAL_ERROR "If USE_G2CLIB is on, USE_PNG must be off") endif() - - if(USE_JASPER) - message(FATAL_ERROR "If USE_G2CLIB is on, USE_JASPER must be off") - endif() endif() # If user wants to use NCEPLIBS-ip, find it and the sp library. @@ -103,17 +101,20 @@ endif() message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) - list(APPEND definitions_list -DUSE_JASPER) - find_package(Jasper REQUIRED) - if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "1.900.25") - list(APPEND definitions_list -DJAS_VERSION_MAJOR=2) + if (NOT USE_G2CLIB) + message(FATAL_ERROR "If USE_JASPER, USE_G2CLIB must be on") endif() + list(APPEND definitions_list -DUSE_JASPER) +# find_package(Jasper REQUIRED) +# if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "1.900.25") +# list(APPEND definitions_list -DJAS_VERSION_MAJOR=2) +# endif() endif() # Find required packages to use OpenJPEG message(STATUS "Checking if the user wants to use OpenJPEG...") if(USE_OPENJPEG) - find_package(OpenJPEG REQUIRED) +find_package(OpenJPEG REQUIRED) endif() message(STATUS "Checking if the user want to use OpenMP...") diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 4a8033d3..767d7281 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -10,7 +10,7 @@ Check_pdt_size.c Checksum.c Cluster.c cname.c codetable_4_230.c CodeTable.c Code_Values.c Code_Values_JMA.c complex_pk.c Config.c copy.c crc32.c Cress_lola.c Csv.c Csv_long.c cubed_sphere2ll.c CubeFace2global.c Cyclic.c Data.c decenc_openjpeg.c dec_png_clone.c -Dump.c Earth.c Else.c enc_jpeg2000_clone.c End.c Endif.c Ensemble.c +Dump.c Earth.c Else.c End.c Endif.c Ensemble.c Ens_processing.c Ens_qc.c EOF.c Export_lonlat.c ExtName.c fatal_error.c Fcst_ave.c ffopen.c Fi.c File.c Fix_CFSv2_fcst.c Fix_ncep_2.c Fix_ncep_3.c Fix_ncep_4.c Fix_ncep.c Fix_undef.c diff --git a/wgrib2/jpeg_pk.c b/wgrib2/jpeg_pk.c index 495d49ca..ab778975 100644 --- a/wgrib2/jpeg_pk.c +++ b/wgrib2/jpeg_pk.c @@ -163,11 +163,11 @@ int jpeg2000_grib_out(unsigned char **sec, float *data, unsigned int ndata, outjpc = (char *) malloc(jpclen); #ifdef USE_JASPER - i = enc_jpeg2000_clone(cdata,ix,iy,nbits,ltype,ratio,retry,outjpc,jpclen); + i = g2c_enc_jpeg2000(cdata,ix,iy,nbits,ltype,ratio,retry,outjpc,jpclen); // we try to catch following error: "error: too few guard bits (need at least x)" if (i == -3) { retry = 1; - i = enc_jpeg2000_clone(cdata,ix,iy,nbits,ltype,ratio,retry,outjpc,jpclen); + i = g2c_enc_jpeg2000(cdata,ix,iy,nbits,ltype,ratio,retry,outjpc,jpclen); } free(cdata); #endif diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index 42b3e854..9f170011 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -49,15 +49,7 @@ int unpk_grib(unsigned char **sec, float *data) { int width, height; #endif -#ifdef USE_JASPER - jas_image_t *image; - char *opts; - jas_stream_t *jpcstream; - jas_image_cmpt_t *pcmpt; - jas_matrix_t *jas_data; - int j, k; -#endif -#ifdef USE_OPENJPEG +#if (defined USE_JASPER || defined USE_OPENJPEG) int *ifld, err; unsigned int kk; #endif @@ -202,7 +194,25 @@ int unpk_grib(unsigned char **sec, float *data) { #ifdef USE_JASPER - image = NULL; + ifld = (int *) malloc(ndata * sizeof(int)); + if (ifld == 0) fatal_error("unpk: memory allocation error",""); + err = g2c_dec_jpeg2000((char *) sec[7]+5, (size_t) GB2_Sec7_size(sec)-5, ifld); + if (err != 0) fatal_error_i("dec_jpeg2000, error %d",err); + + if (bitmap_flag == 0 || bitmap_flag == 254) { + mask_pointer = sec[6] + 6; + mask = 0; + kk = 0; + for (ii = 0; ii < ndata; ii++) { + if ((ii & 7) == 0) mask = *mask_pointer++; + data[ii] = (mask & 128) ? ((ifld[kk++]*bin_scale)+reference)*dec_scale : UNDEFINED; + mask <<= 1; + } + } + else if (bitmap_flag != 255) { + fatal_error_i("unknown bitmap: %d", bitmap_flag); + } + /* image = NULL; opts = NULL; jpcstream=jas_stream_memopen((char *) sec[7]+5, (int) GB2_Sec7_size(sec)-5); image = jpc_decode(jpcstream, opts); @@ -241,7 +251,8 @@ int unpk_grib(unsigned char **sec, float *data) { } jas_matrix_destroy(jas_data); jas_stream_close(jpcstream); - jas_image_destroy(image); + jas_image_destroy(image); */ + free(ifld); return 0; #endif #ifdef USE_OPENJPEG diff --git a/wgrib2/wgrib2.h b/wgrib2/wgrib2.h index 6339601c..1ba52fed 100644 --- a/wgrib2/wgrib2.h +++ b/wgrib2/wgrib2.h @@ -503,8 +503,8 @@ int scaling(unsigned char **sec, double *base, int *decimal, int *binary, int *n unsigned char *mk_bms(float *data, unsigned int *ndata); int dec_png_clone(unsigned char *pngbuf,int *width,int *height, unsigned char *cout, int *grib2_bit_depth, unsigned int ndata); -int enc_jpeg2000_clone(unsigned char *cin,int width,int height,int nbits, int ltype, - int ratio, int retry, char *outjpc, int jpclen); +/*int enc_jpeg2000_clone(unsigned char *cin,int width,int height,int nbits, int ltype, + int ratio, int retry, char *outjpc, int jpclen);*/ #ifdef USE_OPENJPEG int dec_jpeg2000_clone(char *injpc, int bufsize, int *outfld); int enc_jpeg2000_clone_float(float *data, int width, int height, int nbits, From 499d6c84f4b2d801a9e982874e142cb03da9e4de Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 13:51:56 -0700 Subject: [PATCH 02/43] testing updates to developer workflow --- .github/workflows/developer.yml | 38 ++++++--------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index fba1f1dd..04c50769 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -34,37 +34,13 @@ jobs: sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config sudo apt-get install libpng-dev autotools-dev libaec-dev autoconf gcovr doxygen - - name: checkout-ip - uses: actions/checkout@v4 - with: - repository: NOAA-EMC/NCEPLIBS-ip - path: ip - ref: develop - - - name: build-ip - run: | - cd ip - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~ - make -j2 - make install - - - name: checkout-g2c - uses: actions/checkout@v4 + - name: "Build dependencies" + uses: NOAA-EMC/ci-build-nceplibs@develop with: - repository: NOAA-EMC/NCEPLIBS-g2c - path: g2c - ref: develop - - - name: build-g2c - run: | - cd g2c - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=~/g2c -DCMAKE_PREFIX_PATH=~ -DUSE_JASPER=ON - make -j2 - make install + jasper-version: version-4.0.0 + ip-version: develop + g2c-version: develop + g2c-cmake-args: -DUSE_JASPER=ON - name: checkout uses: actions/checkout@v4 @@ -86,7 +62,7 @@ jobs: export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_G2CLIB=ON -DUSE_JASPER=ON + cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_G2CLIB=ON -DUSE_JASPER=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null From 9d436ab4a96557631ee45506a0946b91cb5fcb7e Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 13:58:06 -0700 Subject: [PATCH 03/43] fixing issues with Config.c --- CMakeLists.txt | 2 +- wgrib2/Config.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 412bb491..d39ff6d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ if(USE_JASPER) if (NOT USE_G2CLIB) message(FATAL_ERROR "If USE_JASPER, USE_G2CLIB must be on") endif() - list(APPEND definitions_list -DUSE_JASPER) +# list(APPEND definitions_list -DUSE_JASPER) # find_package(Jasper REQUIRED) # if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "1.900.25") # list(APPEND definitions_list -DJAS_VERSION_MAJOR=2) diff --git a/wgrib2/Config.c b/wgrib2/Config.c index 76f84fd1..d1d2e688 100644 --- a/wgrib2/Config.c +++ b/wgrib2/Config.c @@ -4,9 +4,6 @@ #include #include #include "wgrib2.h" -#ifdef USE_JASPER -#include -#endif #include "grb2.h" #include "fnlist.h" @@ -50,11 +47,8 @@ int f_config(ARG0) { strcat(inv_out, USE_AEC " is installed\n" ); #endif #ifdef USE_JASPER - strcat(inv_out, "Jasper "); - strcat(inv_out, jas_getversion()); - strcat(inv_out, " is installed\n"); + strcat(inv_out,USE_JASPER " is installed\n"); inv_out += strlen(inv_out); -// sprintf(inv_out,"JAS_VERSION_MAJOR=%d\n", JAS_VERSION_MAJOR); #endif #ifdef USE_OPENJPEG strcat(inv_out,USE_OPENJPEG " is installed\n"); From 1b33ca280743aa36157ba81e58c5f3e849e5c2cc Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:09:43 -0700 Subject: [PATCH 04/43] fixed missing link to g2c --- CMakeLists.txt | 2 +- wgrib2/CMakeLists.txt | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d39ff6d8..7e94bd74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ endif() message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) if (NOT USE_G2CLIB) - message(FATAL_ERROR "If USE_JASPER, USE_G2CLIB must be on") + message(FATAL_ERROR "If USE_JASPER, USE_G2CLIB must be on") endif() # list(APPEND definitions_list -DUSE_JASPER) # find_package(Jasper REQUIRED) diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 767d7281..870b5286 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -88,11 +88,11 @@ if(USE_NETCDF) target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C) endif() -if(USE_JASPER) - include_directories(${JASPER_INCLUDE_DIR}) - target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) - target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) -endif() +#if(USE_JASPER) +# include_directories(${JASPER_INCLUDE_DIR}) +# target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) +# target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) +#endif() if(USE_PNG) target_link_libraries(obj_lib PUBLIC PNG::PNG) @@ -103,6 +103,7 @@ if(OpenMP_C_FOUND) endif() if(USE_G2CLIB) + target_link_libraries(obj_lib PUBLIC g2c::g2c) endif() if(USE_IPOLATES) From 5370b60b20366218c0e87e228e2eac75124290f2 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:14:35 -0700 Subject: [PATCH 05/43] remove reference to jasper.h --- wgrib2/unpk.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index 9f170011..79030e26 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -16,9 +16,6 @@ #include int i; #endif -#ifdef USE_JASPER - #include -#endif #ifdef USE_AEC #include From c9db44d6ef0508432a79d87959573811bece082e Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:29:28 -0700 Subject: [PATCH 06/43] trying to fix grib2.h error --- wgrib2/GDT.c | 2 +- wgrib2/init.c | 2 +- wgrib2/wgrib2.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wgrib2/GDT.c b/wgrib2/GDT.c index b56eb33f..34c4a144 100644 --- a/wgrib2/GDT.c +++ b/wgrib2/GDT.c @@ -7,7 +7,7 @@ #ifdef USE_G2CLIB -#include "grib2.h" +#include g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **, g2int *,g2int **,g2int *); diff --git a/wgrib2/init.c b/wgrib2/init.c index dbaa94f2..23922a1d 100644 --- a/wgrib2/init.c +++ b/wgrib2/init.c @@ -20,7 +20,7 @@ #include "fnlist.h" #ifdef USE_G2CLIB -#include "grib2.h" +#include extern gribfield *grib_data; extern int free_gribfield; // flag for allocated gribfield #endif diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index 806a5f26..c30abe9e 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -27,7 +27,7 @@ jmp_buf fatal_err; #include "fnlist.h" #ifdef USE_G2CLIB -#include "grib2.h" +#include gribfield *grib_data; int free_gribfield; // flag for allocated gribfield #endif From b5765d28f7d747682c33614474898209de4176c3 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:37:59 -0700 Subject: [PATCH 07/43] debugging --- .github/workflows/developer.yml | 2 +- wgrib2/GDT.c | 2 +- wgrib2/init.c | 2 +- wgrib2/wgrib2.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 04c50769..b046948e 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -40,7 +40,7 @@ jobs: jasper-version: version-4.0.0 ip-version: develop g2c-version: develop - g2c-cmake-args: -DUSE_JASPER=ON + g2c-cmake-args: -DUSE_JASPER=ON -DBUILD_G2C=ON - name: checkout uses: actions/checkout@v4 diff --git a/wgrib2/GDT.c b/wgrib2/GDT.c index 34c4a144..b56eb33f 100644 --- a/wgrib2/GDT.c +++ b/wgrib2/GDT.c @@ -7,7 +7,7 @@ #ifdef USE_G2CLIB -#include +#include "grib2.h" g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **, g2int *,g2int **,g2int *); diff --git a/wgrib2/init.c b/wgrib2/init.c index 23922a1d..dbaa94f2 100644 --- a/wgrib2/init.c +++ b/wgrib2/init.c @@ -20,7 +20,7 @@ #include "fnlist.h" #ifdef USE_G2CLIB -#include +#include "grib2.h" extern gribfield *grib_data; extern int free_gribfield; // flag for allocated gribfield #endif diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index c30abe9e..806a5f26 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -27,7 +27,7 @@ jmp_buf fatal_err; #include "fnlist.h" #ifdef USE_G2CLIB -#include +#include "grib2.h" gribfield *grib_data; int free_gribfield; // flag for allocated gribfield #endif From 39161400636919675902cf8dcfe0112aa098cb72 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:44:27 -0700 Subject: [PATCH 08/43] more debug --- wgrib2/GDT.c | 2 +- wgrib2/init.c | 2 +- wgrib2/wgrib2.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wgrib2/GDT.c b/wgrib2/GDT.c index b56eb33f..fe31720d 100644 --- a/wgrib2/GDT.c +++ b/wgrib2/GDT.c @@ -7,7 +7,7 @@ #ifdef USE_G2CLIB -#include "grib2.h" +//#include "grib2.h" g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **, g2int *,g2int **,g2int *); diff --git a/wgrib2/init.c b/wgrib2/init.c index dbaa94f2..ce441f87 100644 --- a/wgrib2/init.c +++ b/wgrib2/init.c @@ -20,7 +20,7 @@ #include "fnlist.h" #ifdef USE_G2CLIB -#include "grib2.h" +//#include "grib2.h" extern gribfield *grib_data; extern int free_gribfield; // flag for allocated gribfield #endif diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index 806a5f26..e71602d2 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -27,7 +27,7 @@ jmp_buf fatal_err; #include "fnlist.h" #ifdef USE_G2CLIB -#include "grib2.h" +//#include "grib2.h" gribfield *grib_data; int free_gribfield; // flag for allocated gribfield #endif From 568f5fbb6e4a918967989b1fa32d3edfd0e66f3c Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:48:54 -0700 Subject: [PATCH 09/43] debug --- wgrib2/GDT.c | 2 +- wgrib2/init.c | 2 +- wgrib2/wgrib2.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wgrib2/GDT.c b/wgrib2/GDT.c index fe31720d..abaec871 100644 --- a/wgrib2/GDT.c +++ b/wgrib2/GDT.c @@ -7,7 +7,7 @@ #ifdef USE_G2CLIB -//#include "grib2.h" +#include "grib2_int.h" g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **, g2int *,g2int **,g2int *); diff --git a/wgrib2/init.c b/wgrib2/init.c index ce441f87..152219a5 100644 --- a/wgrib2/init.c +++ b/wgrib2/init.c @@ -20,7 +20,7 @@ #include "fnlist.h" #ifdef USE_G2CLIB -//#include "grib2.h" +#include "grib2_int.h" extern gribfield *grib_data; extern int free_gribfield; // flag for allocated gribfield #endif diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index e71602d2..ebd3031f 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -27,7 +27,7 @@ jmp_buf fatal_err; #include "fnlist.h" #ifdef USE_G2CLIB -//#include "grib2.h" +#include "grib2_int.h" gribfield *grib_data; int free_gribfield; // flag for allocated gribfield #endif From 9b53db71cf57ed0c52e4470c2b3499e60fc69902 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:26:06 -0700 Subject: [PATCH 10/43] debugging --- wgrib2/GDT.c | 2 +- wgrib2/init.c | 2 +- wgrib2/wgrib2.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wgrib2/GDT.c b/wgrib2/GDT.c index abaec871..34c4a144 100644 --- a/wgrib2/GDT.c +++ b/wgrib2/GDT.c @@ -7,7 +7,7 @@ #ifdef USE_G2CLIB -#include "grib2_int.h" +#include g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **, g2int *,g2int **,g2int *); diff --git a/wgrib2/init.c b/wgrib2/init.c index 152219a5..23922a1d 100644 --- a/wgrib2/init.c +++ b/wgrib2/init.c @@ -20,7 +20,7 @@ #include "fnlist.h" #ifdef USE_G2CLIB -#include "grib2_int.h" +#include extern gribfield *grib_data; extern int free_gribfield; // flag for allocated gribfield #endif diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index ebd3031f..c30abe9e 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -27,7 +27,7 @@ jmp_buf fatal_err; #include "fnlist.h" #ifdef USE_G2CLIB -#include "grib2_int.h" +#include gribfield *grib_data; int free_gribfield; // flag for allocated gribfield #endif From cbfb6aab5dfab27845055060bab96c65008915f0 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:18:41 -0700 Subject: [PATCH 11/43] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e94bd74..f317e5b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ endif() message(STATUS "Checking if user wants to use NCEPLIBS-g2c...") if(USE_G2CLIB) - find_package(g2c REQUIRED) + find_package(g2c 1.9.0 CONFIG REQUIRED) if(USE_PNG) message(FATAL_ERROR "If USE_G2CLIB is on, USE_PNG must be off") From 4b5440c00ab913c05468c22af920aa9a49ced599 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:30:34 -0700 Subject: [PATCH 12/43] debugging --- wgrib2/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 870b5286..d097dd1c 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -104,6 +104,7 @@ endif() if(USE_G2CLIB) target_link_libraries(obj_lib PUBLIC g2c::g2c) + target_link_libraries(wgrib2_exe PRIVATE g2c::g2c) endif() if(USE_IPOLATES) From d0b2119ba68e2866220d8c677ac66daebc2e36d8 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:35:38 -0700 Subject: [PATCH 13/43] undo --- wgrib2/CMakeLists.txt | 1 - wgrib2/gctpc/source/makefile | 149 +++++++++++++++++++++++++++++------ 2 files changed, 124 insertions(+), 26 deletions(-) diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index d097dd1c..870b5286 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -104,7 +104,6 @@ endif() if(USE_G2CLIB) target_link_libraries(obj_lib PUBLIC g2c::g2c) - target_link_libraries(wgrib2_exe PRIVATE g2c::g2c) endif() if(USE_IPOLATES) diff --git a/wgrib2/gctpc/source/makefile b/wgrib2/gctpc/source/makefile index 3e8a209a..a2620f1f 100644 --- a/wgrib2/gctpc/source/makefile +++ b/wgrib2/gctpc/source/makefile @@ -1,31 +1,130 @@ -SHELL=/bin/sh -# -# makefile for gctpc, invoked by makefile for wgrib2 -# does not compile fortran bridge routine -# +INCDIR = +ARCHIVE = geolib.a +LIBDIR = +SRCDIR = . +INCS = cproj.h proj.h +CC = cc -LIB=libgeo.a -ARFLAGS=-ruv +OBJECTS= \ + $(ARCHIVE)(alberfor.o) $(ARCHIVE)(alberinv.o) \ + $(ARCHIVE)(alconfor.o) $(ARCHIVE)(alconinv.o) \ + $(ARCHIVE)(azimfor.o) $(ARCHIVE)(aziminv.o) \ + $(ARCHIVE)(eqconfor.o) $(ARCHIVE)(eqconinv.o) \ + $(ARCHIVE)(equifor.o) $(ARCHIVE)(equiinv.o) \ + $(ARCHIVE)(gnomfor.o) $(ARCHIVE)(gnominv.o) \ + $(ARCHIVE)(goodfor.o) $(ARCHIVE)(goodinv.o) \ + $(ARCHIVE)(gvnspfor.o) $(ARCHIVE)(gvnspinv.o) \ + $(ARCHIVE)(hamfor.o) $(ARCHIVE)(haminv.o) \ + $(ARCHIVE)(imolwfor.o) $(ARCHIVE)(imolwinv.o) \ + $(ARCHIVE)(lamazfor.o) $(ARCHIVE)(lamazinv.o) \ + $(ARCHIVE)(lamccfor.o) $(ARCHIVE)(lamccinv.o) \ + $(ARCHIVE)(merfor.o) $(ARCHIVE)(merinv.o) \ + $(ARCHIVE)(millfor.o) $(ARCHIVE)(millinv.o) \ + $(ARCHIVE)(molwfor.o) $(ARCHIVE)(molwinv.o) \ + $(ARCHIVE)(obleqfor.o) $(ARCHIVE)(obleqinv.o) \ + $(ARCHIVE)(omerfor.o) $(ARCHIVE)(omerinv.o) \ + $(ARCHIVE)(orthfor.o) $(ARCHIVE)(orthinv.o) \ + $(ARCHIVE)(polyfor.o) $(ARCHIVE)(polyinv.o) \ + $(ARCHIVE)(psfor.o) $(ARCHIVE)(psinv.o) \ + $(ARCHIVE)(robfor.o) $(ARCHIVE)(robinv.o) \ + $(ARCHIVE)(sinfor.o) $(ARCHIVE)(sininv.o) \ + $(ARCHIVE)(somfor.o) $(ARCHIVE)(sominv.o) \ + $(ARCHIVE)(sterfor.o) $(ARCHIVE)(sterinv.o) \ + $(ARCHIVE)(stplnfor.o) $(ARCHIVE)(stplninv.o) \ + $(ARCHIVE)(tmfor.o) $(ARCHIVE)(tminv.o) \ + $(ARCHIVE)(utmfor.o) $(ARCHIVE)(utminv.o) \ + $(ARCHIVE)(vandgfor.o) $(ARCHIVE)(vandginv.o) \ + $(ARCHIVE)(wivfor.o) $(ARCHIVE)(wivinv.o) \ + $(ARCHIVE)(wviifor.o) $(ARCHIVE)(wviiinv.o) \ + $(ARCHIVE)(for_init.o) $(ARCHIVE)(inv_init.o) \ + $(ARCHIVE)(cproj.o) $(ARCHIVE)(report.o) \ + $(ARCHIVE)(paksz.o) $(ARCHIVE)(sphdz.o) \ + $(ARCHIVE)(untfz.o) $(ARCHIVE)(gctp.o) \ + $(ARCHIVE)(br_gctp.o) +SOURCES = gctp.c alberfor.c alberinv.c alconfor.c alconinv.c azimfor.c \ + aziminv.c eqconfor.c eqconinv.c equifor.c equiinv.c gnomfor.c \ + gnominv.c goodfor.c goodinv.c gvnspfor.c gvnspinv.c hamfor.c \ + haminv.c imolwfor.c imolwnv.c lamazfor.c lamazinv.c merfor.c \ + merinv.c millfor.c millinv.c molwfor.c molwinv.c obleqfor.c \ + obleqinv.c omerfor.c omerinv.c orthfor.c orthinv.c polyfor.c \ + polyinv.c psfor.c psinv.c robfor.c robinv.c sinfor.c sininv.c \ + somfor.c sominv.c sterfor.c sterinv.c stplnfor.c stplninv.c \ + tmfor.c tminv.c utmfor.c utminv.c vandgfor.c vandginv.c \ + wivfor.c wivinv.c wviifor.c wviiinv.c for_init.c inv_init.c \ + cproj.c report.c lamccfor.c lamccinv.c paksz.c untfz.c sphdz.c \ + br_gctp.c Makefile cproj.h proj.h -objs=gctp.o alberfor.o alberinv.o alconfor.o alconinv.o azimfor.o aziminv.o eqconfor.o eqconinv.o \ - equifor.o equiinv.o for_init.o gnomfor.o gnominv.o goodfor.o goodinv.o gvnspfor.o gvnspinv.o \ - hamfor.o haminv.o imolwfor.o imolwinv.o inv_init.o lamazfor.o lamazinv.o lamccfor.o lamccinv.o \ - merfor.o merinv.o millfor.o millinv.o molwfor.o molwinv.o obleqfor.o obleqinv.o omerfor.o omerinv.o \ - orthfor.o orthinv.o paksz.o polyinv.o polyfor.o psinv.o psfor.o robinv.o robfor.o sininv.o sinfor.o \ - sominv.o somfor.o sphdz.o sterinv.o sterfor.o stplninv.o stplnfor.o tminv.o tmfor.o utminv.o utmfor.o \ - untfz.o vandginv.o vandgfor.o wivinv.o wivfor.o wviiinv.o wviifor.o cproj.o report.o +$(ARCHIVE): $(OBJECTS) -.c.o: - $(CC) -c $(CPPFLAGS) $(CFLAGS) ${DEFS} $< - -$(LIB): $(objs) - ar $(ARFLAGS) ${LIB} $(objs) - -clean: - touch junk.o - rm *.o - touch libgeo.a - rm libgeo.a +$(ARCHIVE)(gctp.o): $(INCS) +$(ARCHIVE)(alberfor.o): $(INCS) +$(ARCHIVE)(alberinv.o): $(INCS) +$(ARCHIVE)(alconfor.o): $(INCS) +$(ARCHIVE)(alconinv.o): $(INCS) +$(ARCHIVE)(azimfor.o): $(INCS) +$(ARCHIVE)(aziminv.o): $(INCS) +$(ARCHIVE)(eqconfor.o): $(INCS) +$(ARCHIVE)(eqconinv.o): $(INCS) +$(ARCHIVE)(equifor.o): $(INCS) +$(ARCHIVE)(equiinv.o): $(INCS) +$(ARCHIVE)(for_init.o): $(INCS) +$(ARCHIVE)(gnomfor.o): $(INCS) +$(ARCHIVE)(gnominv.o): $(INCS) +$(ARCHIVE)(goodfor.o): $(INCS) +$(ARCHIVE)(goodinv.o): $(INCS) +$(ARCHIVE)(gvnspfor.o): $(INCS) +$(ARCHIVE)(gvnspinv.o): $(INCS) +$(ARCHIVE)(hamfor.o): $(INCS) +$(ARCHIVE)(haminv.o): $(INCS) +$(ARCHIVE)(imolwfor.o): $(INCS) +$(ARCHIVE)(imolwinv.o): $(INCS) +$(ARCHIVE)(inv_init.o): $(INCS) +$(ARCHIVE)(lamazfor.o): $(INCS) +$(ARCHIVE)(lamazinv.o): $(INCS) +$(ARCHIVE)(lamccfor.o): $(INCS) +$(ARCHIVE)(lamccinv.o): $(INCS) +$(ARCHIVE)(merfor.o): $(INCS) +$(ARCHIVE)(merinv.o): $(INCS) +$(ARCHIVE)(millfor.o): $(INCS) +$(ARCHIVE)(millinv.o): $(INCS) +$(ARCHIVE)(molwfor.o): $(INCS) +$(ARCHIVE)(molwinv.o): $(INCS) +$(ARCHIVE)(obleqfor.o): $(INCS) +$(ARCHIVE)(obleqinv.o): $(INCS) +$(ARCHIVE)(omerfor.o): $(INCS) +$(ARCHIVE)(omerinv.o): $(INCS) +$(ARCHIVE)(orthfor.o): $(INCS) +$(ARCHIVE)(orthinv.o): $(INCS) +$(ARCHIVE)(paksz.o): $(INCS) +$(ARCHIVE)(polyinv.o): $(INCS) +$(ARCHIVE)(polyfor.o): $(INCS) +$(ARCHIVE)(psinv.o): $(INCS) +$(ARCHIVE)(psfor.o): $(INCS) +$(ARCHIVE)(robinv.o): $(INCS) +$(ARCHIVE)(robfor.o): $(INCS) +$(ARCHIVE)(sininv.o): $(INCS) +$(ARCHIVE)(sinfor.o): $(INCS) +$(ARCHIVE)(sominv.o): $(INCS) +$(ARCHIVE)(somfor.o): $(INCS) +$(ARCHIVE)(sphdz.o): $(INCS) +$(ARCHIVE)(sterinv.o): $(INCS) +$(ARCHIVE)(sterfor.o): $(INCS) +$(ARCHIVE)(stplninv.o): $(INCS) +$(ARCHIVE)(stplnfor.o): $(INCS) +$(ARCHIVE)(tminv.o): $(INCS) +$(ARCHIVE)(tmfor.o): $(INCS) +$(ARCHIVE)(utminv.o): $(INCS) +$(ARCHIVE)(utmfor.o): $(INCS) +$(ARCHIVE)(untfz.o): $(INCS) +$(ARCHIVE)(vandginv.o): $(INCS) +$(ARCHIVE)(vandgfor.o): $(INCS) +$(ARCHIVE)(wivinv.o): $(INCS) +$(ARCHIVE)(wivfor.o): $(INCS) +$(ARCHIVE)(wviiinv.o): $(INCS) +$(ARCHIVE)(wviifor.o): $(INCS) +$(ARCHIVE)(cproj.o): $(INCS) +$(ARCHIVE)(report.o): $(INCS) +$(ARCHIVE)(br_gctp.o): $(INCS) From 849c005e2f7c445694bd52e3a9f6742b45da8a08 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:53:34 -0700 Subject: [PATCH 14/43] don't use USE_G2CLIB --- .github/workflows/developer.yml | 4 +- CMakeLists.txt | 6 +- wgrib2/CMakeLists.txt | 10 +-- wgrib2/gctpc/source/makefile | 149 ++++++-------------------------- 4 files changed, 32 insertions(+), 137 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index b046948e..3a4ee9a3 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -40,7 +40,7 @@ jobs: jasper-version: version-4.0.0 ip-version: develop g2c-version: develop - g2c-cmake-args: -DUSE_JASPER=ON -DBUILD_G2C=ON + g2c-cmake-args: -DUSE_JASPER=ON - name: checkout uses: actions/checkout@v4 @@ -62,7 +62,7 @@ jobs: export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_G2CLIB=ON -DUSE_JASPER=ON + cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null diff --git a/CMakeLists.txt b/CMakeLists.txt index f317e5b2..f0bdd098 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,8 +75,6 @@ endif() message(STATUS "Checking if user wants to use NCEPLIBS-g2c...") if(USE_G2CLIB) - find_package(g2c 1.9.0 CONFIG REQUIRED) - if(USE_PNG) message(FATAL_ERROR "If USE_G2CLIB is on, USE_PNG must be off") endif() @@ -101,9 +99,7 @@ endif() message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) - if (NOT USE_G2CLIB) - message(FATAL_ERROR "If USE_JASPER, USE_G2CLIB must be on") - endif() + find_package(g2c 1.9.0 CONFIG REQUIRED) # list(APPEND definitions_list -DUSE_JASPER) # find_package(Jasper REQUIRED) # if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "1.900.25") diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 870b5286..12811db5 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -88,11 +88,12 @@ if(USE_NETCDF) target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C) endif() -#if(USE_JASPER) +if(USE_JASPER) + target_link_libraries(obj_lib PUBLIC g2c::g2c) # include_directories(${JASPER_INCLUDE_DIR}) # target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) # target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) -#endif() +endif() if(USE_PNG) target_link_libraries(obj_lib PUBLIC PNG::PNG) @@ -102,10 +103,6 @@ if(OpenMP_C_FOUND) target_link_libraries(obj_lib PUBLIC OpenMP::OpenMP_C) endif() -if(USE_G2CLIB) - target_link_libraries(obj_lib PUBLIC g2c::g2c) -endif() - if(USE_IPOLATES) target_link_libraries(obj_lib PUBLIC ip::ip_d) @@ -129,6 +126,7 @@ if(USE_AEC) target_link_libraries(wgrib2_exe PRIVATE aec) endif() + if(USE_OPENJPEG) include_directories(${OPENJPEG_INCLUDE_DIRS}) target_link_libraries(wgrib2_exe PRIVATE ${OPENJPEG_LIBRARIES}) diff --git a/wgrib2/gctpc/source/makefile b/wgrib2/gctpc/source/makefile index a2620f1f..2dc0fb70 100644 --- a/wgrib2/gctpc/source/makefile +++ b/wgrib2/gctpc/source/makefile @@ -1,130 +1,31 @@ +SHELL=/bin/sh -INCDIR = -ARCHIVE = geolib.a -LIBDIR = -SRCDIR = . -INCS = cproj.h proj.h -CC = cc +# +# makefile for gctpc, invoked by makefile for wgrib2 +# does not compile fortran bridge routine +# -OBJECTS= \ - $(ARCHIVE)(alberfor.o) $(ARCHIVE)(alberinv.o) \ - $(ARCHIVE)(alconfor.o) $(ARCHIVE)(alconinv.o) \ - $(ARCHIVE)(azimfor.o) $(ARCHIVE)(aziminv.o) \ - $(ARCHIVE)(eqconfor.o) $(ARCHIVE)(eqconinv.o) \ - $(ARCHIVE)(equifor.o) $(ARCHIVE)(equiinv.o) \ - $(ARCHIVE)(gnomfor.o) $(ARCHIVE)(gnominv.o) \ - $(ARCHIVE)(goodfor.o) $(ARCHIVE)(goodinv.o) \ - $(ARCHIVE)(gvnspfor.o) $(ARCHIVE)(gvnspinv.o) \ - $(ARCHIVE)(hamfor.o) $(ARCHIVE)(haminv.o) \ - $(ARCHIVE)(imolwfor.o) $(ARCHIVE)(imolwinv.o) \ - $(ARCHIVE)(lamazfor.o) $(ARCHIVE)(lamazinv.o) \ - $(ARCHIVE)(lamccfor.o) $(ARCHIVE)(lamccinv.o) \ - $(ARCHIVE)(merfor.o) $(ARCHIVE)(merinv.o) \ - $(ARCHIVE)(millfor.o) $(ARCHIVE)(millinv.o) \ - $(ARCHIVE)(molwfor.o) $(ARCHIVE)(molwinv.o) \ - $(ARCHIVE)(obleqfor.o) $(ARCHIVE)(obleqinv.o) \ - $(ARCHIVE)(omerfor.o) $(ARCHIVE)(omerinv.o) \ - $(ARCHIVE)(orthfor.o) $(ARCHIVE)(orthinv.o) \ - $(ARCHIVE)(polyfor.o) $(ARCHIVE)(polyinv.o) \ - $(ARCHIVE)(psfor.o) $(ARCHIVE)(psinv.o) \ - $(ARCHIVE)(robfor.o) $(ARCHIVE)(robinv.o) \ - $(ARCHIVE)(sinfor.o) $(ARCHIVE)(sininv.o) \ - $(ARCHIVE)(somfor.o) $(ARCHIVE)(sominv.o) \ - $(ARCHIVE)(sterfor.o) $(ARCHIVE)(sterinv.o) \ - $(ARCHIVE)(stplnfor.o) $(ARCHIVE)(stplninv.o) \ - $(ARCHIVE)(tmfor.o) $(ARCHIVE)(tminv.o) \ - $(ARCHIVE)(utmfor.o) $(ARCHIVE)(utminv.o) \ - $(ARCHIVE)(vandgfor.o) $(ARCHIVE)(vandginv.o) \ - $(ARCHIVE)(wivfor.o) $(ARCHIVE)(wivinv.o) \ - $(ARCHIVE)(wviifor.o) $(ARCHIVE)(wviiinv.o) \ - $(ARCHIVE)(for_init.o) $(ARCHIVE)(inv_init.o) \ - $(ARCHIVE)(cproj.o) $(ARCHIVE)(report.o) \ - $(ARCHIVE)(paksz.o) $(ARCHIVE)(sphdz.o) \ - $(ARCHIVE)(untfz.o) $(ARCHIVE)(gctp.o) \ - $(ARCHIVE)(br_gctp.o) +LIB=libgeo.a +ARFLAGS=-ruv -SOURCES = gctp.c alberfor.c alberinv.c alconfor.c alconinv.c azimfor.c \ - aziminv.c eqconfor.c eqconinv.c equifor.c equiinv.c gnomfor.c \ - gnominv.c goodfor.c goodinv.c gvnspfor.c gvnspinv.c hamfor.c \ - haminv.c imolwfor.c imolwnv.c lamazfor.c lamazinv.c merfor.c \ - merinv.c millfor.c millinv.c molwfor.c molwinv.c obleqfor.c \ - obleqinv.c omerfor.c omerinv.c orthfor.c orthinv.c polyfor.c \ - polyinv.c psfor.c psinv.c robfor.c robinv.c sinfor.c sininv.c \ - somfor.c sominv.c sterfor.c sterinv.c stplnfor.c stplninv.c \ - tmfor.c tminv.c utmfor.c utminv.c vandgfor.c vandginv.c \ - wivfor.c wivinv.c wviifor.c wviiinv.c for_init.c inv_init.c \ - cproj.c report.c lamccfor.c lamccinv.c paksz.c untfz.c sphdz.c \ - br_gctp.c Makefile cproj.h proj.h -$(ARCHIVE): $(OBJECTS) +objs=gctp.o alberfor.o alberinv.o alconfor.o alconinv.o azimfor.o aziminv.o eqconfor.o eqconinv.o \ + equifor.o equiinv.o for_init.o gnomfor.o gnominv.o goodfor.o goodinv.o gvnspfor.o gvnspinv.o \ + hamfor.o haminv.o imolwfor.o imolwinv.o inv_init.o lamazfor.o lamazinv.o lamccfor.o lamccinv.o \ + merfor.o merinv.o millfor.o millinv.o molwfor.o molwinv.o obleqfor.o obleqinv.o omerfor.o omerinv.o \ + orthfor.o orthinv.o paksz.o polyinv.o polyfor.o psinv.o psfor.o robinv.o robfor.o sininv.o sinfor.o \ + sominv.o somfor.o sphdz.o sterinv.o sterfor.o stplninv.o stplnfor.o tminv.o tmfor.o utminv.o utmfor.o \ + untfz.o vandginv.o vandgfor.o wivinv.o wivfor.o wviiinv.o wviifor.o cproj.o report.o -$(ARCHIVE)(gctp.o): $(INCS) -$(ARCHIVE)(alberfor.o): $(INCS) -$(ARCHIVE)(alberinv.o): $(INCS) -$(ARCHIVE)(alconfor.o): $(INCS) -$(ARCHIVE)(alconinv.o): $(INCS) -$(ARCHIVE)(azimfor.o): $(INCS) -$(ARCHIVE)(aziminv.o): $(INCS) -$(ARCHIVE)(eqconfor.o): $(INCS) -$(ARCHIVE)(eqconinv.o): $(INCS) -$(ARCHIVE)(equifor.o): $(INCS) -$(ARCHIVE)(equiinv.o): $(INCS) -$(ARCHIVE)(for_init.o): $(INCS) -$(ARCHIVE)(gnomfor.o): $(INCS) -$(ARCHIVE)(gnominv.o): $(INCS) -$(ARCHIVE)(goodfor.o): $(INCS) -$(ARCHIVE)(goodinv.o): $(INCS) -$(ARCHIVE)(gvnspfor.o): $(INCS) -$(ARCHIVE)(gvnspinv.o): $(INCS) -$(ARCHIVE)(hamfor.o): $(INCS) -$(ARCHIVE)(haminv.o): $(INCS) -$(ARCHIVE)(imolwfor.o): $(INCS) -$(ARCHIVE)(imolwinv.o): $(INCS) -$(ARCHIVE)(inv_init.o): $(INCS) -$(ARCHIVE)(lamazfor.o): $(INCS) -$(ARCHIVE)(lamazinv.o): $(INCS) -$(ARCHIVE)(lamccfor.o): $(INCS) -$(ARCHIVE)(lamccinv.o): $(INCS) -$(ARCHIVE)(merfor.o): $(INCS) -$(ARCHIVE)(merinv.o): $(INCS) -$(ARCHIVE)(millfor.o): $(INCS) -$(ARCHIVE)(millinv.o): $(INCS) -$(ARCHIVE)(molwfor.o): $(INCS) -$(ARCHIVE)(molwinv.o): $(INCS) -$(ARCHIVE)(obleqfor.o): $(INCS) -$(ARCHIVE)(obleqinv.o): $(INCS) -$(ARCHIVE)(omerfor.o): $(INCS) -$(ARCHIVE)(omerinv.o): $(INCS) -$(ARCHIVE)(orthfor.o): $(INCS) -$(ARCHIVE)(orthinv.o): $(INCS) -$(ARCHIVE)(paksz.o): $(INCS) -$(ARCHIVE)(polyinv.o): $(INCS) -$(ARCHIVE)(polyfor.o): $(INCS) -$(ARCHIVE)(psinv.o): $(INCS) -$(ARCHIVE)(psfor.o): $(INCS) -$(ARCHIVE)(robinv.o): $(INCS) -$(ARCHIVE)(robfor.o): $(INCS) -$(ARCHIVE)(sininv.o): $(INCS) -$(ARCHIVE)(sinfor.o): $(INCS) -$(ARCHIVE)(sominv.o): $(INCS) -$(ARCHIVE)(somfor.o): $(INCS) -$(ARCHIVE)(sphdz.o): $(INCS) -$(ARCHIVE)(sterinv.o): $(INCS) -$(ARCHIVE)(sterfor.o): $(INCS) -$(ARCHIVE)(stplninv.o): $(INCS) -$(ARCHIVE)(stplnfor.o): $(INCS) -$(ARCHIVE)(tminv.o): $(INCS) -$(ARCHIVE)(tmfor.o): $(INCS) -$(ARCHIVE)(utminv.o): $(INCS) -$(ARCHIVE)(utmfor.o): $(INCS) -$(ARCHIVE)(untfz.o): $(INCS) -$(ARCHIVE)(vandginv.o): $(INCS) -$(ARCHIVE)(vandgfor.o): $(INCS) -$(ARCHIVE)(wivinv.o): $(INCS) -$(ARCHIVE)(wivfor.o): $(INCS) -$(ARCHIVE)(wviiinv.o): $(INCS) -$(ARCHIVE)(wviifor.o): $(INCS) -$(ARCHIVE)(cproj.o): $(INCS) -$(ARCHIVE)(report.o): $(INCS) -$(ARCHIVE)(br_gctp.o): $(INCS) +.c.o: + $(CC) -c $(CPPFLAGS) $(CFLAGS) ${DEFS} $< + +$(LIB): $(objs) + ar $(ARFLAGS) ${LIB} $(objs) + +clean: + touch junk.o + rm *.o + touch libgeo.a + rm libgeo.a \ No newline at end of file From 890a254fc35d68ec6c164cbf79971e7c4fb63462 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:21:23 -0700 Subject: [PATCH 15/43] Update CMakeLists.txt --- wgrib2/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 12811db5..4916d1b5 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -89,7 +89,7 @@ if(USE_NETCDF) endif() if(USE_JASPER) - target_link_libraries(obj_lib PUBLIC g2c::g2c) +# target_link_libraries(obj_lib PUBLIC g2c::g2c) # include_directories(${JASPER_INCLUDE_DIR}) # target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) # target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) @@ -126,6 +126,9 @@ if(USE_AEC) target_link_libraries(wgrib2_exe PRIVATE aec) endif() +if(USE_JASPER) + target_link_libraries(wgrib2_exe PRIVATE g2c::g2c) +endif() if(USE_OPENJPEG) include_directories(${OPENJPEG_INCLUDE_DIRS}) From a47b9b134660fbba042d250f51c4879c57ea8259 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:29:56 -0700 Subject: [PATCH 16/43] Update developer.yml --- .github/workflows/developer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 3a4ee9a3..3df07bc7 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -40,7 +40,7 @@ jobs: jasper-version: version-4.0.0 ip-version: develop g2c-version: develop - g2c-cmake-args: -DUSE_JASPER=ON + g2c-cmake-args: -DBUILD_G2C=ON - name: checkout uses: actions/checkout@v4 From 18d203ab10b2475f3410ca54c6bccb96ea12b09a Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:13:03 -0700 Subject: [PATCH 17/43] Update package.py --- spack/package.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spack/package.py b/spack/package.py index 26a199d1..30ff11f8 100644 --- a/spack/package.py +++ b/spack/package.py @@ -172,7 +172,8 @@ def url_for_version(self, version): depends_on("ip@5.1:", when="@develop +ipolates") depends_on("libaec@1.0.6:", when="@3.2: +aec") depends_on("netcdf-c", when="@3.2: +netcdf4") - depends_on("jasper@:2", when="@3.2: +jasper") + depends_on("jasper@:2", when="@3.2:3.4 +jasper") + depends_on("g2c", when="@develop +jasper") depends_on("zlib-api", when="@3.2: +png") depends_on("libpng", when="@3.2: +png") depends_on("openjpeg", when="@3.2: +openjpeg") From 4a7fee8966b348f1455d3c26856e29750ed32789 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:01:20 -0700 Subject: [PATCH 18/43] reverted all changes to developer workflow and added g2c --- .github/workflows/developer.yml | 63 ++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 3df07bc7..db94e9a3 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -34,13 +34,60 @@ jobs: sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config sudo apt-get install libpng-dev autotools-dev libaec-dev autoconf gcovr doxygen - - name: "Build dependencies" - uses: NOAA-EMC/ci-build-nceplibs@develop + - name: cache-jasper + id: cache-jasper + uses: actions/cache@v4 + with: + path: ~/jasper + key: jasper-${{ runner.os }}-4.0.0 + + - name: checkout-jasper + if: steps.cache-jasper.outputs.cache-hit != 'true' + uses: actions/checkout@v4 + with: + repository: jasper-software/jasper + path: jasper + ref: version-4.0.0 + + - name: build-jasper + if: steps.cache-jasper.outputs.cache-hit != 'true' + run: | + cd jasper + ./configure --prefix=$HOME/jasper + make + make install + + - name: checkout-ip + uses: actions/checkout@v4 with: - jasper-version: version-4.0.0 - ip-version: develop - g2c-version: develop - g2c-cmake-args: -DBUILD_G2C=ON + repository: NOAA-EMC/NCEPLIBS-ip + path: ip + ref: develop + + - name: build-ip + run: | + cd ip + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~ + make -j2 + make install + + - name: checkout-g2c + uses: actions/checkout@v4 + with: + repository: NOAA-EMC/NCEPLIBS-g2c + path: g2c + ref: develop + + - name: build-g2c + run: | + cd g2c + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX=~/g2c -DCMAKE_PREFIX_PATH=~ + make -j2 + make install - name: checkout uses: actions/checkout@v4 @@ -62,7 +109,7 @@ jobs: export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/nceplibs/jasper;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-ip;$GITHUB_WORKSPACE/nceplibs/NCEPLIBS-g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON + cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/jasper;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed gcovr --root .. -v --html-details --exclude ../tests --exclude CMakeFiles --print-summary -o test-coverage.html &> /dev/null @@ -84,4 +131,4 @@ jobs: - name: Upload built documentation uses: actions/upload-pages-artifact@v1 with: - path: wgrib2/build/docs/html # Path to the built site files + path: wgrib2/build/docs/html # Path to the built site files \ No newline at end of file From 2ba517913b0daeaf6e992afc5c9c82199cc14f11 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:13:34 -0700 Subject: [PATCH 19/43] Update developer.yml --- .github/workflows/developer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index db94e9a3..1ecbd2e8 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -53,7 +53,7 @@ jobs: if: steps.cache-jasper.outputs.cache-hit != 'true' run: | cd jasper - ./configure --prefix=$HOME/jasper + cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper make make install From 55f7ff5f5bf43a7f55dd89eff984fa7402c27f1c Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:17:31 -0700 Subject: [PATCH 20/43] forgot some lines for jasper build --- .github/workflows/developer.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 1ecbd2e8..b402f9d4 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -53,6 +53,8 @@ jobs: if: steps.cache-jasper.outputs.cache-hit != 'true' run: | cd jasper + mkdir build + cd build cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper make make install From 3e6832ce4d1d90d43e7203119b59c95e5f75dc03 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:28:07 -0700 Subject: [PATCH 21/43] Update developer.yml --- .github/workflows/developer.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index b402f9d4..736eb556 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -53,11 +53,9 @@ jobs: if: steps.cache-jasper.outputs.cache-hit != 'true' run: | cd jasper - mkdir build - cd build - cmake .. -DCMAKE_INSTALL_PREFIX=~/jasper - make - make install + cmake -B build_dir -DCMAKE_INSTALL_PREFIX=~/jasper + cmake --build build_dir + cmake --install build_dir - name: checkout-ip uses: actions/checkout@v4 From 108a600346071361322db029ed757c0c940d853d Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:30:30 -0700 Subject: [PATCH 22/43] update prefix path for g2c --- .github/workflows/developer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 736eb556..d3cd43db 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -85,7 +85,7 @@ jobs: cd g2c mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=~/g2c -DCMAKE_PREFIX_PATH=~ + cmake .. -DCMAKE_INSTALL_PREFIX=~/g2c -DCMAKE_PREFIX_PATH="~/jasper" make -j2 make install From 369a99b0bcf544be9900f1013acac966f625b0bd Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:36:58 -0700 Subject: [PATCH 23/43] add ld_librar_path --- .github/workflows/developer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index d3cd43db..5de85b79 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -21,6 +21,7 @@ jobs: env: FC: gfortran CC: gcc + LD_LIBRARY_PATH: /home/runner/jasper/lib/ permissions: id-token: write From 3a1fb4e9bf27e10113ec4f50d90e262170b33eb7 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA Date: Fri, 11 Oct 2024 10:50:55 -0600 Subject: [PATCH 24/43] restoring original gctpc makefile after accidental overwrite --- wgrib2/gctpc/source/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgrib2/gctpc/source/makefile b/wgrib2/gctpc/source/makefile index 2dc0fb70..3e8a209a 100644 --- a/wgrib2/gctpc/source/makefile +++ b/wgrib2/gctpc/source/makefile @@ -28,4 +28,4 @@ clean: touch junk.o rm *.o touch libgeo.a - rm libgeo.a \ No newline at end of file + rm libgeo.a From 0553b2109ee81eb9cf23c9bea3b4a9a9a30f4ee3 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:53:26 -0700 Subject: [PATCH 25/43] cleaning up --- CMakeLists.txt | 5 ----- wgrib2/CMakeLists.txt | 7 ------- wgrib2/GDT.c | 2 +- wgrib2/init.c | 2 +- wgrib2/wgrib2.c | 2 +- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0bdd098..c3890567 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,11 +100,6 @@ endif() message(STATUS "Checking if the user wants to use Jasper...") if(USE_JASPER) find_package(g2c 1.9.0 CONFIG REQUIRED) -# list(APPEND definitions_list -DUSE_JASPER) -# find_package(Jasper REQUIRED) -# if(JASPER_VERSION_STRING VERSION_GREATER_EQUAL "1.900.25") -# list(APPEND definitions_list -DJAS_VERSION_MAJOR=2) -# endif() endif() # Find required packages to use OpenJPEG diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 4916d1b5..0b157401 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -88,13 +88,6 @@ if(USE_NETCDF) target_link_libraries(obj_lib PUBLIC NetCDF::NetCDF_C) endif() -if(USE_JASPER) -# target_link_libraries(obj_lib PUBLIC g2c::g2c) -# include_directories(${JASPER_INCLUDE_DIR}) -# target_include_directories(obj_lib PUBLIC ${JASPER_INCLUDE_DIR}) -# target_link_libraries(obj_lib PUBLIC ${JASPER_LIBRARIES}) -endif() - if(USE_PNG) target_link_libraries(obj_lib PUBLIC PNG::PNG) endif() diff --git a/wgrib2/GDT.c b/wgrib2/GDT.c index 34c4a144..b56eb33f 100644 --- a/wgrib2/GDT.c +++ b/wgrib2/GDT.c @@ -7,7 +7,7 @@ #ifdef USE_G2CLIB -#include +#include "grib2.h" g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **, g2int *,g2int **,g2int *); diff --git a/wgrib2/init.c b/wgrib2/init.c index 23922a1d..dbaa94f2 100644 --- a/wgrib2/init.c +++ b/wgrib2/init.c @@ -20,7 +20,7 @@ #include "fnlist.h" #ifdef USE_G2CLIB -#include +#include "grib2.h" extern gribfield *grib_data; extern int free_gribfield; // flag for allocated gribfield #endif diff --git a/wgrib2/wgrib2.c b/wgrib2/wgrib2.c index c30abe9e..806a5f26 100644 --- a/wgrib2/wgrib2.c +++ b/wgrib2/wgrib2.c @@ -27,7 +27,7 @@ jmp_buf fatal_err; #include "fnlist.h" #ifdef USE_G2CLIB -#include +#include "grib2.h" gribfield *grib_data; int free_gribfield; // flag for allocated gribfield #endif From 295d2c8e6045f228ce770cbfda46aca481a4fb29 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:59:35 -0700 Subject: [PATCH 26/43] fixing implicit function declarations for g2c functions --- wgrib2/jpeg_pk.c | 4 ++++ wgrib2/unpk.c | 4 ++++ wgrib2/wgrib2.h | 2 -- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wgrib2/jpeg_pk.c b/wgrib2/jpeg_pk.c index ab778975..26085f4b 100644 --- a/wgrib2/jpeg_pk.c +++ b/wgrib2/jpeg_pk.c @@ -7,6 +7,10 @@ #include "wgrib2.h" #include "fnlist.h" +#ifdef USE_JASPER + #include "grib2.h" +#endif + /* 10/2024 Public Domain Wesley Ebisuzaki */ #if defined USE_JASPER || defined USE_OPENJPEG diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index 79030e26..d2e1a5a8 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -21,6 +21,10 @@ #include #endif +#ifdef USE_JASPER + #include "grib2.h" +#endif + /* * unpack grib -- only some formats (code table 5.0) are supported * diff --git a/wgrib2/wgrib2.h b/wgrib2/wgrib2.h index 1ba52fed..95005b15 100644 --- a/wgrib2/wgrib2.h +++ b/wgrib2/wgrib2.h @@ -503,8 +503,6 @@ int scaling(unsigned char **sec, double *base, int *decimal, int *binary, int *n unsigned char *mk_bms(float *data, unsigned int *ndata); int dec_png_clone(unsigned char *pngbuf,int *width,int *height, unsigned char *cout, int *grib2_bit_depth, unsigned int ndata); -/*int enc_jpeg2000_clone(unsigned char *cin,int width,int height,int nbits, int ltype, - int ratio, int retry, char *outjpc, int jpclen);*/ #ifdef USE_OPENJPEG int dec_jpeg2000_clone(char *injpc, int bufsize, int *outfld); int enc_jpeg2000_clone_float(float *data, int width, int height, int nbits, From e250cd056860108a62b1bc99936b76c1ec31a2f9 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:07:10 -0700 Subject: [PATCH 27/43] Update CMakeLists.txt --- wgrib2/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/wgrib2/CMakeLists.txt b/wgrib2/CMakeLists.txt index 0b157401..6308b6c2 100644 --- a/wgrib2/CMakeLists.txt +++ b/wgrib2/CMakeLists.txt @@ -120,6 +120,7 @@ if(USE_AEC) endif() if(USE_JASPER) + target_link_libraries(obj_lib PUBLIC g2c::g2c) target_link_libraries(wgrib2_exe PRIVATE g2c::g2c) endif() From d28b72ae5048192fcd127515b46bdd6995530dd4 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:12:56 -0700 Subject: [PATCH 28/43] undo some changes --- wgrib2/jpeg_pk.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wgrib2/jpeg_pk.c b/wgrib2/jpeg_pk.c index 26085f4b..ab778975 100644 --- a/wgrib2/jpeg_pk.c +++ b/wgrib2/jpeg_pk.c @@ -7,10 +7,6 @@ #include "wgrib2.h" #include "fnlist.h" -#ifdef USE_JASPER - #include "grib2.h" -#endif - /* 10/2024 Public Domain Wesley Ebisuzaki */ #if defined USE_JASPER || defined USE_OPENJPEG From 045b441f847f0be88f9d5c5a6c2ed83c9a6060ae Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:16:33 -0700 Subject: [PATCH 29/43] more code cleanup --- wgrib2/unpk.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index d2e1a5a8..c5ac458d 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -194,7 +194,6 @@ int unpk_grib(unsigned char **sec, float *data) { // decode jpeg2000 #ifdef USE_JASPER - ifld = (int *) malloc(ndata * sizeof(int)); if (ifld == 0) fatal_error("unpk: memory allocation error",""); err = g2c_dec_jpeg2000((char *) sec[7]+5, (size_t) GB2_Sec7_size(sec)-5, ifld); @@ -213,46 +212,6 @@ int unpk_grib(unsigned char **sec, float *data) { else if (bitmap_flag != 255) { fatal_error_i("unknown bitmap: %d", bitmap_flag); } - /* image = NULL; - opts = NULL; - jpcstream=jas_stream_memopen((char *) sec[7]+5, (int) GB2_Sec7_size(sec)-5); - image = jpc_decode(jpcstream, opts); - if (image == NULL) fatal_error("jpeg2000 decoding", ""); - pcmpt = image->cmpts_[0]; - if (image->numcmpts_ != 1 ) - fatal_error("unpk: Found color image. Grayscale expected",""); - - jas_data=jas_matrix_create(jas_image_height(image), jas_image_width(image)); - jas_image_readcmpt(image,0,0,0,jas_image_width(image), jas_image_height(image),jas_data); - - // transfer data - - k = ndata - pcmpt->height_ * pcmpt->width_; - -// #pragma omp parallel for private(ii,j) - for (ii=0;iiheight_;ii++) { - for (j=0;jwidth_;j++) { -// data[k++] = (((jas_data->rows_[ii][j])*bin_scale)+reference)*dec_scale; - data[k+j+ii*pcmpt->width_] = (((jas_data->rows_[ii][j])*bin_scale)+reference)*dec_scale; - } - } - - if (bitmap_flag == 0 || bitmap_flag == 254) { - k = ndata - pcmpt->height_ * pcmpt->width_; - mask_pointer = sec[6] + 6; - mask = 0; - for (ii = 0; ii < ndata; ii++) { - if ((ii & 7) == 0) mask = *mask_pointer++; - data[ii] = (mask & 128) ? data[k++] : UNDEFINED; - mask <<= 1; - } - } - else if (bitmap_flag != 255) { - fatal_error_i("unknown bitmap: %d", bitmap_flag); - } - jas_matrix_destroy(jas_data); - jas_stream_close(jpcstream); - jas_image_destroy(image); */ free(ifld); return 0; #endif From ef10ff584533f9e1423a1ad87fd098b1ff5b9078 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA Date: Fri, 11 Oct 2024 11:28:01 -0600 Subject: [PATCH 30/43] adding to jpeg tests --- tests/data/ref_simple2jpeg.txt | 19 +++++++++++++++++++ tests/run_jpeg_tests.sh | 15 ++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tests/data/ref_simple2jpeg.txt diff --git a/tests/data/ref_simple2jpeg.txt b/tests/data/ref_simple2jpeg.txt new file mode 100644 index 00000000..d1e76f83 --- /dev/null +++ b/tests/data/ref_simple2jpeg.txt @@ -0,0 +1,19 @@ +1:0:00Z30nov2021:WIND Wind Speed [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +2:15252:00Z30nov2021:WDIR Wind Direction (from which blowing) [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +3:37893:00Z30nov2021:UGRD U-Component of Wind [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +4:53788:00Z30nov2021:VGRD V-Component of Wind [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +5:69056:00Z30nov2021:HTSGW Significant Height of Combined Wind Waves and Swell [m]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +6:79472:00Z30nov2021:PERPW Primary Wave Mean Period [s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +7:91296:00Z30nov2021:DIRPW Primary Wave Direction [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +8:108527:00Z30nov2021:WVHGT Significant Height of Wind Waves [m]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +9:116700:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: +10:128814:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: +11:140828:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: +12:151710:00Z30nov2021:WVPER Mean Period of Wind Waves [s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +13:160997:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: +14:173650:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: +15:189397:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: +16:205255:00Z30nov2021:WVDIR Direction of Wind Waves [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: +17:218231:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: +18:237001:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: +19:259187:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: diff --git a/tests/run_jpeg_tests.sh b/tests/run_jpeg_tests.sh index a2035400..05ffb91d 100644 --- a/tests/run_jpeg_tests.sh +++ b/tests/run_jpeg_tests.sh @@ -9,10 +9,15 @@ echo "" echo "*** Running wgrib2 jpeg tests" echo "*** Converting from jpeg to simple packing" -../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -set_grib_type simple -grib_out jpeg2simple.grb -../wgrib2/wgrib2 jpeg2simple.grb -v2 -s > jpeg2simple.txt -touch jpeg2simple.txt -diff -w jpeg2simple.txt data/ref_jpeg2simple.txt +../wgrib2/wgrib2 data/gdaswave.t00z.wcoast.0p16.f000.grib2 -set_grib_type simple -grib_out junk_jpeg2simple.grb +../wgrib2/wgrib2 junk_jpeg2simple.grb -v2 -s > junk_jpeg2simple.txt +touch junk_jpeg2simple.txt +diff -w junk_jpeg2simple.txt data/ref_jpeg2simple.txt + +echo "*** Converting from simple back to jpeg packing" +../wgrib2/wgrib2 junk_jpeg2simple.grb -set_grib_type jpeg -grib_out junk_simple2jpeg.grb +../wgrib2/wgrib2 junk_simple2jpeg.grb -v2 > junk_simple2jpeg.txt +diff -w junk_simple2jpeg.txt data/ref_simple2jpeg.txt echo "*** SUCCESS!" -exit 0 \ No newline at end of file +exit 0 From 851f30a817f5b792b34b11fdd79b5b0b599c55e5 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:29:10 -0700 Subject: [PATCH 31/43] forgot to copy test data in cmake --- tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d14fced4..589686c7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -164,6 +164,7 @@ endif() if (USE_JASPER OR USE_OPENJPEG) shell_test(run_jpeg_tests) copy_test_data(ref_jpeg2simple.txt) + copy_test_data(ref_simple2jpeg.txt) endif() if (FTP_TEST_FILES) From 91e39e0823394b50eb1ee94d38a4db4c51fa136e Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:34:32 -0700 Subject: [PATCH 32/43] Update unpk.c --- wgrib2/unpk.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index c5ac458d..59a54f24 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -21,10 +21,6 @@ #include #endif -#ifdef USE_JASPER - #include "grib2.h" -#endif - /* * unpack grib -- only some formats (code table 5.0) are supported * From 25503c63c2b482b3fe1c6e2f97c8bff03d13d3ec Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:43:41 -0700 Subject: [PATCH 33/43] removing last test - file diff not ideal for test --- tests/CMakeLists.txt | 1 - tests/data/ref_simple2jpeg.txt | 19 ------------------- tests/run_jpeg_tests.sh | 5 ----- 3 files changed, 25 deletions(-) delete mode 100644 tests/data/ref_simple2jpeg.txt diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 589686c7..d14fced4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -164,7 +164,6 @@ endif() if (USE_JASPER OR USE_OPENJPEG) shell_test(run_jpeg_tests) copy_test_data(ref_jpeg2simple.txt) - copy_test_data(ref_simple2jpeg.txt) endif() if (FTP_TEST_FILES) diff --git a/tests/data/ref_simple2jpeg.txt b/tests/data/ref_simple2jpeg.txt deleted file mode 100644 index d1e76f83..00000000 --- a/tests/data/ref_simple2jpeg.txt +++ /dev/null @@ -1,19 +0,0 @@ -1:0:00Z30nov2021:WIND Wind Speed [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -2:15252:00Z30nov2021:WDIR Wind Direction (from which blowing) [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -3:37893:00Z30nov2021:UGRD U-Component of Wind [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -4:53788:00Z30nov2021:VGRD V-Component of Wind [m/s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -5:69056:00Z30nov2021:HTSGW Significant Height of Combined Wind Waves and Swell [m]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -6:79472:00Z30nov2021:PERPW Primary Wave Mean Period [s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -7:91296:00Z30nov2021:DIRPW Primary Wave Direction [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -8:108527:00Z30nov2021:WVHGT Significant Height of Wind Waves [m]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -9:116700:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: -10:128814:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: -11:140828:00Z30nov2021:SWELL Significant Height of Swell Waves [m]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: -12:151710:00Z30nov2021:WVPER Mean Period of Wind Waves [s]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -13:160997:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: -14:173650:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: -15:189397:00Z30nov2021:SWPER Mean Period of Swell Waves [s]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: -16:205255:00Z30nov2021:WVDIR Direction of Wind Waves [deg]:lvl1=(1,1) lvl2=(255,missing):surface:anl: -17:218231:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,1) lvl2=(255,missing):1 in sequence:anl: -18:237001:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,2) lvl2=(255,missing):2 in sequence:anl: -19:259187:00Z30nov2021:SWDIR Direction of Swell Waves [deg]:lvl1=(241,3) lvl2=(255,missing):3 in sequence:anl: diff --git a/tests/run_jpeg_tests.sh b/tests/run_jpeg_tests.sh index 05ffb91d..69c1c7a8 100644 --- a/tests/run_jpeg_tests.sh +++ b/tests/run_jpeg_tests.sh @@ -14,10 +14,5 @@ echo "*** Converting from jpeg to simple packing" touch junk_jpeg2simple.txt diff -w junk_jpeg2simple.txt data/ref_jpeg2simple.txt -echo "*** Converting from simple back to jpeg packing" -../wgrib2/wgrib2 junk_jpeg2simple.grb -set_grib_type jpeg -grib_out junk_simple2jpeg.grb -../wgrib2/wgrib2 junk_simple2jpeg.grb -v2 > junk_simple2jpeg.txt -diff -w junk_simple2jpeg.txt data/ref_simple2jpeg.txt - echo "*** SUCCESS!" exit 0 From 954640880a58978040a7f2f02aae3bb52e43a773 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:53:37 -0700 Subject: [PATCH 34/43] only require fortran if needed for make_ftn_api=ON --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07168a58..2c10345e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15) file(STRINGS "VERSION" pVersion) # Set up project with version number from VERSION file. -project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C) +project(wgrib2 VERSION ${pVersion} LANGUAGES C) # Handle user build options. option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) @@ -39,6 +39,10 @@ option(BUILD_LIB "Build wgrib2 library?" on) option(BUILD_SHARED_LIB "Build shared library?" off) option(BUILD_WGRIB "Build wgrib code?" off) +if (MAKE_FTN_API OR USE_IPOLATES) + enable_language(Fortran) +endif() + # Developers can use this option to specify a local directory which # holds the test files. They will be copied instead of fetching the # files via FTP. From e1b596d99262ecf9d48a0be01ad1c11720b3aea9 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:54:50 -0700 Subject: [PATCH 35/43] Delete enc_jpeg2000_clone.c --- wgrib2/enc_jpeg2000_clone.c | 194 ------------------------------------ 1 file changed, 194 deletions(-) delete mode 100644 wgrib2/enc_jpeg2000_clone.c diff --git a/wgrib2/enc_jpeg2000_clone.c b/wgrib2/enc_jpeg2000_clone.c deleted file mode 100644 index f19ddfa2..00000000 --- a/wgrib2/enc_jpeg2000_clone.c +++ /dev/null @@ -1,194 +0,0 @@ -#include -#include -#include "wgrib2.h" - -#ifdef USE_JASPER -#include -#define JAS_1_700_2 - -/* 2004-12-16 Public Domain Steve Gilbert */ - - -int enc_jpeg2000_clone(unsigned char *cin,int width,int height,int nbits, - int ltype, int ratio, int retry, char *outjpc, - int jpclen) -/*$$$ SUBPROGRAM DOCUMENTATION BLOCK -* . . . . -* SUBPROGRAM: enc_jpeg2000 Encodes JPEG2000 code stream -* PRGMMR: Gilbert ORG: W/NP11 DATE: 2002-12-02 -* -* ABSTRACT: This Function encodes a grayscale image into a JPEG2000 code stream -* specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC 15444-1) -* using JasPer Software version 1.500.4 (or 1.700.2 ) written by the -* University of British Columbia, Image Power Inc, and others. -* JasPer is available at http://www.ece.uvic.ca/~mdadams/jasper/. -* -* PROGRAM HISTORY LOG: -* 2002-12-02 Gilbert -* 2004-12-16 Gilbert - Added retry argument/option to allow option of -* increasing the maximum number of guard bits to the -* JPEG2000 algorithm. -* -* USAGE: int enc_jpeg2000(unsigned char *cin,g2int width,g2int height, -* g2int nbits, g2int ltype, g2int ratio, -* g2int retry, char *outjpc, g2int jpclen) -* -* INPUT ARGUMENTS: -* cin - Packed matrix of Grayscale image values to encode. -* width - width of image -* height - height of image -* nbits - depth (in bits) of image. i.e number of bits -* used to hold each data value -* ltype - indicator of lossless or lossy compression -* = 1, for lossy compression -* != 1, for lossless compression -* ratio - target compression ratio. (ratio:1) -* Used only when ltype == 1. -* retry - Pointer to option type. -* 1 = try increasing number of guard bits -* otherwise, no additional options -* jpclen - Number of bytes allocated for new JPEG2000 code stream in -* outjpc. -* -* INPUT ARGUMENTS: -* outjpc - Output encoded JPEG2000 code stream -* -* RETURN VALUES : -* > 0 = Length in bytes of encoded JPEG2000 code stream -* -3 = Error decode jpeg2000 code stream. -* -5 = decoded image had multiple color components. -* Only grayscale is expected. -* -* REMARKS: -* -* Requires JasPer Software version 1.500.4 or 1.700.2 -* -* ATTRIBUTES: -* LANGUAGE: C -* MACHINE: IBM SP -* -*$$$*/ -{ - int ier,rwcnt; - jas_image_t image; - jas_stream_t *jpcstream,*istream; - jas_image_cmpt_t cmpt,*pcmpt; -#define MAXOPTSSIZE 1024 - char opts[MAXOPTSSIZE]; - -/* - printf(" enc_jpeg2000:width %ld\n",width); - printf(" enc_jpeg2000:height %ld\n",height); - printf(" enc_jpeg2000:nbits %ld\n",nbits); - printf(" enc_jpeg2000:jpclen %ld\n",jpclen); -*/ -// jas_init(); - -// -// Set lossy compression options, if requested. -// - if ( ltype != 1 ) { - opts[0]=(char)0; - } - else { - snprintf(opts,MAXOPTSSIZE,"mode=real\nrate=%f",1.0/(float)ratio); - } - if ( retry == 1 ) { // option to increase number of guard bits - strcat(opts,"\nnumgbits=4"); - } - //printf("SAGopts: %s\n",opts); - -// -// Initialize the JasPer image structure describing the grayscale -// image to encode into the JPEG2000 code stream. -// - image.tlx_=0; - image.tly_=0; -#ifdef JAS_1_500_4 - image.brx_=(uint_fast32_t)width; - image.bry_=(uint_fast32_t)height; -#endif -#ifdef JAS_1_700_2 - image.brx_=(jas_image_coord_t)width; - image.bry_=(jas_image_coord_t)height; -#endif - image.numcmpts_=1; - image.maxcmpts_=1; -#ifdef JAS_1_500_4 - image.colormodel_=JAS_IMAGE_CM_GRAY; /* grayscale Image */ -#endif -#ifdef JAS_1_700_2 - image.clrspc_=JAS_CLRSPC_SGRAY; /* grayscale Image */ - image.cmprof_=0; -#endif - - -/* - image.inmem_=1; - is only used for japser version 1.x up to 1.9.24 - for newer code the above line is removed - */ -#if JAS_VERSION_MAJOR == 1 - image.inmem_=1; -#endif -#ifndef JAS_VERSION_MAJOR - image.inmem_=1; -#endif - - - - - cmpt.tlx_=0; - cmpt.tly_=0; - cmpt.hstep_=1; - cmpt.vstep_=1; -#ifdef JAS_1_500_4 - cmpt.width_=(uint_fast32_t)width; - cmpt.height_=(uint_fast32_t)height; -#endif -#ifdef JAS_1_700_2 - cmpt.width_=(jas_image_coord_t)width; - cmpt.height_=(jas_image_coord_t)height; - cmpt.type_=JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y); -#endif - cmpt.prec_=nbits; - cmpt.sgnd_=0; - cmpt.cps_=(nbits+7)/8; - - pcmpt=&cmpt; - image.cmpts_=&pcmpt; - -// -// Open a JasPer stream containing the input grayscale values -// - istream=jas_stream_memopen((char *)cin,height*width*cmpt.cps_); - cmpt.stream_=istream; - -// -// Open an output stream that will contain the encoded jpeg2000 -// code stream. -// - jpcstream=jas_stream_memopen(outjpc,(int)jpclen); - -// -// Encode image. -// - ier=jpc_encode(&image,jpcstream,opts); - if ( ier != 0 ) { - printf(" jpc_encode return = %d \n",ier); - return -3; - } -// -// Clean up JasPer work structures. -// - rwcnt=jpcstream->rwcnt_; - ier=jas_stream_close(istream); - ier=jas_stream_close(jpcstream); -// -// Return size of jpeg2000 code stream -// - return (rwcnt); - -} - -#endif From 7d34d01ae396904d98814d18d5d51c927da53a42 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:19:18 -0700 Subject: [PATCH 36/43] removing some recent build changes to debug error --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da99120f..5d450b60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 3.15) file(STRINGS "VERSION" pVersion) # Set up project with version number from VERSION file. -project(wgrib2 VERSION ${pVersion} LANGUAGES C) +#project(wgrib2 VERSION ${pVersion} LANGUAGES C) +project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C) # Handle user build options. option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) @@ -39,9 +40,9 @@ option(BUILD_LIB "Build wgrib2 library?" on) option(BUILD_SHARED_LIB "Build shared library?" off) option(BUILD_WGRIB "Build wgrib code?" off) -if (MAKE_FTN_API OR USE_IPOLATES) - enable_language(Fortran) -endif() +#if (MAKE_FTN_API OR USE_IPOLATES) +# enable_language(Fortran) +#endif() # Developers can use this option to specify a local directory which # holds the test files. They will be copied instead of fetching the From 89ea502c57021140f281d986189c54df245f395c Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:41:29 -0700 Subject: [PATCH 37/43] removed last changes + debugging ip build error --- .github/workflows/developer.yml | 2 +- CMakeLists.txt | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 5de85b79..6313b2aa 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -70,7 +70,7 @@ jobs: cd ip mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~ + cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~ -DBLA_VENDOR=OpenBLAS make -j2 make install diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d450b60..da99120f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,7 @@ cmake_minimum_required(VERSION 3.15) file(STRINGS "VERSION" pVersion) # Set up project with version number from VERSION file. -#project(wgrib2 VERSION ${pVersion} LANGUAGES C) -project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C) +project(wgrib2 VERSION ${pVersion} LANGUAGES C) # Handle user build options. option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF) @@ -40,9 +39,9 @@ option(BUILD_LIB "Build wgrib2 library?" on) option(BUILD_SHARED_LIB "Build shared library?" off) option(BUILD_WGRIB "Build wgrib code?" off) -#if (MAKE_FTN_API OR USE_IPOLATES) -# enable_language(Fortran) -#endif() +if (MAKE_FTN_API OR USE_IPOLATES) + enable_language(Fortran) +endif() # Developers can use this option to specify a local directory which # holds the test files. They will be copied instead of fetching the From d9fdfe23ae7977a1752582315c88d353716f4754 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:46:38 -0700 Subject: [PATCH 38/43] Update developer.yml --- .github/workflows/developer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 6313b2aa..3cfda62e 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -32,7 +32,7 @@ jobs: - name: install run: | sudo apt-get update - sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config + sudo apt-get install libnetcdf-dev libnetcdff-dev netcdf-bin pkg-config libopenblas-dev sudo apt-get install libpng-dev autotools-dev libaec-dev autoconf gcovr doxygen - name: cache-jasper @@ -70,7 +70,7 @@ jobs: cd ip mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~ -DBLA_VENDOR=OpenBLAS + cmake .. -DCMAKE_INSTALL_PREFIX=~/ip -DCMAKE_PREFIX_PATH=~ make -j2 make install From 0574ecd451ffc756559757ba8cd6c0f22ed368a7 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 10:57:14 -0700 Subject: [PATCH 39/43] Update package.py --- spack/package.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spack/package.py b/spack/package.py index 30ff11f8..7ddd52a3 100644 --- a/spack/package.py +++ b/spack/package.py @@ -170,6 +170,7 @@ def url_for_version(self, version): conflicts("+openmp", when="%apple-clang") depends_on("ip@5.1:", when="@develop +ipolates") + depends_on("lapack", when="@develop +ipolates") depends_on("libaec@1.0.6:", when="@3.2: +aec") depends_on("netcdf-c", when="@3.2: +netcdf4") depends_on("jasper@:2", when="@3.2:3.4 +jasper") @@ -177,6 +178,7 @@ def url_for_version(self, version): depends_on("zlib-api", when="@3.2: +png") depends_on("libpng", when="@3.2: +png") depends_on("openjpeg", when="@3.2: +openjpeg") + @when("@:2 ^gmake@4.2:") From d1a322b8a7456394ef2667d05ca137b8f8513990 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:11:13 -0700 Subject: [PATCH 40/43] debugging --- .github/workflows/developer.yml | 2 +- wgrib2/jpeg_pk.c | 4 ++++ wgrib2/unpk.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 3cfda62e..2c1e0178 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -21,7 +21,7 @@ jobs: env: FC: gfortran CC: gcc - LD_LIBRARY_PATH: /home/runner/jasper/lib/ + LD_LIBRARY_PATH: "/home/runner/jasper/lib:/home/runner/g2c/lib" permissions: id-token: write diff --git a/wgrib2/jpeg_pk.c b/wgrib2/jpeg_pk.c index ab778975..cc4661cf 100644 --- a/wgrib2/jpeg_pk.c +++ b/wgrib2/jpeg_pk.c @@ -7,6 +7,10 @@ #include "wgrib2.h" #include "fnlist.h" +#ifdef USE_JASPER + #include "grib2.h" +#endif + /* 10/2024 Public Domain Wesley Ebisuzaki */ #if defined USE_JASPER || defined USE_OPENJPEG diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index 59a54f24..eae07106 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -12,6 +12,10 @@ #include "wgrib2.h" #include "grb2.h" +#ifdef USE_JASPER + #include "grib2.h" +#endif + #ifdef USE_PNG #include int i; From 40f220b22064c7a99769f09a2f13816e2879a86f Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:26:30 -0700 Subject: [PATCH 41/43] more debugging --- .github/workflows/developer.yml | 2 +- spack/package.py | 5 +++-- wgrib2/jpeg_pk.c | 4 ---- wgrib2/unpk.c | 4 ---- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 2c1e0178..3cfda62e 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -21,7 +21,7 @@ jobs: env: FC: gfortran CC: gcc - LD_LIBRARY_PATH: "/home/runner/jasper/lib:/home/runner/g2c/lib" + LD_LIBRARY_PATH: /home/runner/jasper/lib/ permissions: id-token: write diff --git a/spack/package.py b/spack/package.py index 7ddd52a3..4db87fec 100644 --- a/spack/package.py +++ b/spack/package.py @@ -188,8 +188,9 @@ def patch(self): # Use Spack compiler wrapper flags def inject_flags(self, name, flags): if name == "cflags": - if self.spec.compiler.name == "apple-clang": - flags.append("-Wno-error=implicit-function-declaration") + flags.append("-Wno-error=implicit-function-declaration") + #if self.spec.compiler.name == "apple-clang": + # flags.append("-Wno-error=implicit-function-declaration") # When mixing Clang/gfortran need to link to -lgfortran # Find this by searching for gfortran/../lib diff --git a/wgrib2/jpeg_pk.c b/wgrib2/jpeg_pk.c index cc4661cf..ab778975 100644 --- a/wgrib2/jpeg_pk.c +++ b/wgrib2/jpeg_pk.c @@ -7,10 +7,6 @@ #include "wgrib2.h" #include "fnlist.h" -#ifdef USE_JASPER - #include "grib2.h" -#endif - /* 10/2024 Public Domain Wesley Ebisuzaki */ #if defined USE_JASPER || defined USE_OPENJPEG diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index eae07106..59a54f24 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -12,10 +12,6 @@ #include "wgrib2.h" #include "grb2.h" -#ifdef USE_JASPER - #include "grib2.h" -#endif - #ifdef USE_PNG #include int i; From 19e25578daa366415bfd79bf95d93a7a2eb4c9ed Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:44:20 -0700 Subject: [PATCH 42/43] trying to debug header file error to avoid implicit function declaration error --- .github/workflows/developer.yml | 8 ++++---- spack/package.py | 5 ++--- wgrib2/jpeg_pk.c | 4 ++++ wgrib2/unpk.c | 4 ++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 3cfda62e..3b118c52 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -21,7 +21,7 @@ jobs: env: FC: gfortran CC: gcc - LD_LIBRARY_PATH: /home/runner/jasper/lib/ + LD_LIBRARY_PATH: "/home/runner/jasper/lib/:/home/runner/g2c/include/" permissions: id-token: write @@ -107,9 +107,9 @@ jobs: cd wgrib2 mkdir build cd build - export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' - export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' + export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' + export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' + export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/jasper;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON make VERBOSE=1 ctest --verbose --output-on-failure --rerun-failed diff --git a/spack/package.py b/spack/package.py index 4db87fec..7ddd52a3 100644 --- a/spack/package.py +++ b/spack/package.py @@ -188,9 +188,8 @@ def patch(self): # Use Spack compiler wrapper flags def inject_flags(self, name, flags): if name == "cflags": - flags.append("-Wno-error=implicit-function-declaration") - #if self.spec.compiler.name == "apple-clang": - # flags.append("-Wno-error=implicit-function-declaration") + if self.spec.compiler.name == "apple-clang": + flags.append("-Wno-error=implicit-function-declaration") # When mixing Clang/gfortran need to link to -lgfortran # Find this by searching for gfortran/../lib diff --git a/wgrib2/jpeg_pk.c b/wgrib2/jpeg_pk.c index ab778975..cc4661cf 100644 --- a/wgrib2/jpeg_pk.c +++ b/wgrib2/jpeg_pk.c @@ -7,6 +7,10 @@ #include "wgrib2.h" #include "fnlist.h" +#ifdef USE_JASPER + #include "grib2.h" +#endif + /* 10/2024 Public Domain Wesley Ebisuzaki */ #if defined USE_JASPER || defined USE_OPENJPEG diff --git a/wgrib2/unpk.c b/wgrib2/unpk.c index 59a54f24..eae07106 100644 --- a/wgrib2/unpk.c +++ b/wgrib2/unpk.c @@ -12,6 +12,10 @@ #include "wgrib2.h" #include "grb2.h" +#ifdef USE_JASPER + #include "grib2.h" +#endif + #ifdef USE_PNG #include int i; From 0e3298cdd43363d90fdcc9e19c04031f3194749a Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Tue, 15 Oct 2024 12:00:43 -0700 Subject: [PATCH 43/43] Update developer.yml --- .github/workflows/developer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/developer.yml b/.github/workflows/developer.yml index 3b118c52..fa9dd0d5 100644 --- a/.github/workflows/developer.yml +++ b/.github/workflows/developer.yml @@ -21,7 +21,7 @@ jobs: env: FC: gfortran CC: gcc - LD_LIBRARY_PATH: "/home/runner/jasper/lib/:/home/runner/g2c/include/" + LD_LIBRARY_PATH: "/home/runner/jasper/lib/" permissions: id-token: write @@ -107,7 +107,7 @@ jobs: cd wgrib2 mkdir build cd build - export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' + export CFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0 -I/home/runner/g2c/include' export FCFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' export FFLAGS='-Wall -g -fprofile-abs-path -fprofile-arcs -ftest-coverage -O0' cmake .. -DENABLE_DOCS=ON -DFTP_TEST_FILES=ON -DCMAKE_PREFIX_PATH="~/ip;~/jasper;~/g2c" -DTEST_FILE_DIR=/home/runner/data -DUSE_NETCDF4=ON -DUSE_AEC=ON -DUSE_IPOLATES=ON -DUSE_JASPER=ON