--- gdal-2.3.1/GNUmakefile.ext_g2clib 2018-06-23 17:05:46.000000000 +0200 +++ gdal-2.3.1/GNUmakefile 2018-07-30 15:56:11.517697753 +0200 @@ -17,6 +17,9 @@ GDAL_OBJ += $(GDAL_ROOT)/ogr/ogrsf_frmts/o/*.o +# Use external grib2c +LDFLAGS += -lgrib2c + ifeq ($(GNM_ENABLED),yes) GDAL_OBJ += $(GDAL_ROOT)/gnm/*.o $(GDAL_ROOT)/gnm/gnm_frmts/o/*.o endif --- gdal-2.3.1/frmts/grib/GNUmakefile.ext_g2clib 2018-06-23 17:05:47.000000000 +0200 +++ gdal-2.3.1/frmts/grib/GNUmakefile 2018-07-30 17:21:54.693877257 +0200 @@ -7,7 +7,9 @@ OBJ = gribdataset.o gribcreatecopy.o \ clock.o \ degrib1.o \ - degrib2.o inventory.o metaname.o myerror.o filedatasource.o memorydatasource.o grib1tab.o myutil.o metaparse.o weather.o metaprint.o grib2api.o myassert.o scan.o tendian.o gridtemplates.o drstemplates.o pdstemplates.o gbits.o g2_free.o g2_unpack1.o g2_unpack2.o g2_unpack3.o g2_unpack4.o g2_unpack5.o g2_unpack6.o g2_unpack7.o g2_info.o g2_getfld.o simunpack.o comunpack.o pack_gp.o reduce.o specunpack.o rdieee.o mkieee.o int_power.o simpack.o compack.o cmplxpack.o misspack.o \ + degrib2.o inventory.o metaname.o myerror.o filedatasource.o memorydatasource.o grib1tab.o myutil.o metaparse.o weather.o metaprint.o grib2api.o myassert.o scan.o tendian.o hazard.o +##in grid2c +#gridtemplates.o drstemplates.o pdstemplates.o gbits.o g2_free.o g2_unpack1.o g2_unpack2.o g2_unpack3.o g2_unpack4.o g2_unpack5.o g2_unpack6.o g2_unpack7.o g2_info.o g2_getfld.o simunpack.o comunpack.o pack_gp.o reduce.o specunpack.o rdieee.o mkieee.o int_power.o simpack.o compack.o cmplxpack.o misspack.o \ dec_jpeg2000.o jpcunpack.o hazard.o ifeq ($(PNG_SETTING),internal) @@ -20,7 +22,8 @@ ifeq ($(PNG_SETTING),external) EXTRAFLAGS := $(EXTRAFLAGS) -DUSE_PNG -OBJ := $(OBJ) pngunpack.o dec_png.o +## in grib2c +## OBJ := $(OBJ) pngunpack.o dec_png.o endif CPPFLAGS := $(CPPFLAGS) $(EXTRAFLAGS) --- gdal-2.3.1/frmts/grib/degrib/degrib/engribapi.c~ 2018-06-23 17:06:56.000000000 +0200 +++ gdal-2.3.1/frmts/grib/degrib/degrib/engribapi.c 2018-07-30 16:06:32.166815369 +0200 @@ -19,9 +19,9 @@ #include "grib2api.h" #include "engribapi.h" #include "myassert.h" -#include "gridtemplates.h" -#include "pdstemplates.h" -#include "drstemplates.h" +#include <gridtemplates.h> +#include <pdstemplates.h> +#include <drstemplates.h> #ifdef MEMWATCH #include "memwatch.h" @@ -428,7 +428,7 @@ double meshLat, double orientLon, double scaleLat1, double scaleLat2, double southLat, double southLon) { - const struct gridtemplate *templatesgrid = get_templatesgrid(); + int i; /* loop counter over number of GDS templates. */ double unit; /* Used to convert from stored value to degrees * lat/lon. See GRIB2 Regulation 92.1.6 */ @@ -649,7 +649,7 @@ double dSurfVal2) { int i; /* loop counter over number of PDS templates. */ - const struct pdstemplate *templatespds = get_templatespds(); + /* analysis template (0) */ /* In addition templates (1, 2, 5, 8, 9, 12) begin with 4.0 info. */ @@ -1205,7 +1205,7 @@ uChar orderOfDiff) { int i; /* loop counter over number of DRS templates. */ - const struct drstemplate *templatesdrs = get_templatesdrs(); + /* Find NCEP's template match */ for (i = 0; i < MAXDRSTEMP; i++) { --- gdal-2.3.1/frmts/grib/degrib/degrib/grib2api.c~ 2018-06-23 17:06:56.000000000 +0200 +++ gdal-2.3.1/frmts/grib/degrib/degrib/grib2api.c 2018-07-30 16:09:19.161190928 +0200 @@ -18,13 +18,13 @@ #include <stdlib.h> #include <string.h> #include "grib2api.h" -#include "grib2.h" +#include <grib2.h> #include "scan.h" #include "tendian.h" #include "myassert.h" -#include "gridtemplates.h" -#include "pdstemplates.h" -#include "drstemplates.h" +#include <gridtemplates.h> +#include <pdstemplates.h> +#include <drstemplates.h> #include "cpl_port.h" @@ -818,7 +818,7 @@ char f_ignoreScan; /* Flag to ignore the attempt at changing the scan */ sInt4 dummyScan; /* Dummy place holder for call to Transfer routines * if ignoring scan. */ - const struct gridtemplate *templatesgrid = get_templatesgrid(); + myAssert(*ndjer >= 8); /* Init the error handling array. */ @@ -1094,7 +1094,7 @@ { curIndex = 9; for (i = 0; i < gfld->ipdtlen; i++) { - const struct pdstemplate *templatespds = get_templatespds(); + if( curIndex >= *ns4 ) { /* Should we error out instead ? */ @@ -1126,7 +1126,7 @@ } curIndex = 11; for (i = 0; i < gfld->idrtlen; i++) { - const struct drstemplate *templatesdrs = get_templatesdrs(); + is5[curIndex] = gfld->idrtmpl[i]; curIndex += abs(templatesdrs[drsIndex].mapdrs[i]); } --- gdal-2.3.1/frmts/grib/gribcreatecopy.cpp.orig 2018-07-30 17:11:49.764512589 +0200 +++ gdal-2.3.1/frmts/grib/gribcreatecopy.cpp 2018-07-30 17:12:09.413850306 +0200 @@ -38,7 +38,7 @@ #include "degrib/degrib/meta.h" CPL_C_START -#include "degrib/g2clib/grib2.h" +#include <grib2.h> CPL_C_END /************************************************************************/ --- gdal-2.3.1/frmts/grib/gribdataset.cpp.orig 2018-07-30 17:00:11.418053168 +0200 +++ gdal-2.3.1/frmts/grib/gribdataset.cpp 2018-07-30 17:09:04.360087637 +0200 @@ -61,8 +61,10 @@ #include "degrib/degrib/myerror.h" #include "degrib/degrib/type.h" CPL_C_START -#include "degrib/g2clib/grib2.h" -#include "degrib/g2clib/pdstemplates.h" +#include <grib2.h> +#include <pdstemplates.h> +#include <gridtemplates.h> +#include <drstemplates.h> CPL_C_END #include "gdal.h" #include "gdal_frmts.h"