Skip to content

Commit

Permalink
feat: upgrade g2clib to 1.6.3 (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebaptiste authored Oct 19, 2023
1 parent 9214196 commit 9696327
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .metwork-framework/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
| [folium](https://github.com/python-visualization/folium) | 0.14.0 | python3_scientific |
| [fonttools](http://github.com/fonttools/fonttools) | 4.38.0 | python3_scientific |
| [fsspec](http://github.com/fsspec/filesystem_spec) | 2022.11.0 | python3_scientific |
| [g2clib](https://www.ncl.ucar.edu/) | 1.6.0 | scientific |
| [g2clib](https://www.ncl.ucar.edu/) | 1.6.3 | scientific |
| [gast](https://github.com/serge-sans-paille/gast/) | 0.5.4 | python3_scientific |
| [GDAL](http://www.gdal.org) | 3.7.2 | python3_scientific |
| [geographiclib](https://geographiclib.sourceforge.io/Python/2.0) | 2.0 | python3_scientific |
Expand Down
12 changes: 7 additions & 5 deletions layers/layer1_scientific/0089_g2clib/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ include ../../../adm/root.mk
include $(MFEXT_HOME)/share/package.mk

export NAME=g2clib
export VERSION=1.6.0
export VERSION=1.6.3
export EXTENSION=tar.bz2
export CHECKTYPE=MD5
export CHECKSUM=89a6df22cf1362d284d04873c5d0b8ce
export CHECKSUM=5182a27323481e29d3cd6c2cbcf7add9
DESCRIPTION=\
G2CLIB contains "C" decoder/encoder routines for GRIB edition 2
WEBSITE=https://www.ncl.ucar.edu/
LICENSE=Apache 2.0

all::$(PREFIX)/lib/libgrib2c.a
$(PREFIX)/lib/libgrib2c.a:
#Version 1.7.0 would require to build jasper >= 2.0.25

all::$(PREFIX)/lib/libg2c.a
$(PREFIX)/lib/libg2c.a:
$(MAKE) --file=$(MFEXT_HOME)/share/Makefile.standard PREFIX=$(PREFIX) download uncompress build
cd build/$(NAME)-$(VERSION) && cp libg2c_v1.6.0.a $(PREFIX)/lib/libgrib2c.a && cp *.h $(PREFIX)/include
cd build/$(NAME)-$(VERSION) && cp libg2c_v1.6.3.a $(PREFIX)/lib/libg2c.a && cp *.h $(PREFIX)/include
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--- g2clib-1.6.3/dec_jpeg2000.c.jasper3_internal 2021-03-09 05:09:53.000000000 +0900
+++ g2clib-1.6.3/dec_jpeg2000.c 2022-02-14 17:13:00.280165566 +0900
@@ -56,7 +56,6 @@
jas_image_t *image=0;
jas_stream_t *jpcstream;
jas_image_cmpt_t *pcmpt;
- char *opts=0;
jas_matrix_t *data;

// jas_init();
@@ -70,8 +69,8 @@

//
// Decode JPEG200 codestream into jas_image_t structure.
-//
- image=jpc_decode(jpcstream,opts);
+//
+ image=jas_image_decode (jpcstream, -1, 0);
if ( image == 0 ) {
printf(" jpc_decode return\n");
return -3;
--- g2clib-1.6.3/enc_jpeg2000.c.jasper3_internal 2022-02-14 17:13:00.278165564 +0900
+++ g2clib-1.6.3/enc_jpeg2000.c 2022-02-14 17:27:57.490383488 +0900
@@ -72,6 +72,7 @@
g2int jpclen)
{
int ier,rwcnt;
+ int fmt;
jas_image_t image;
jas_stream_t *jpcstream,*istream;
jas_image_cmpt_t cmpt,*pcmpt;
@@ -162,7 +163,8 @@
//
// Encode image.
//
- ier=jpc_encode(&image,jpcstream,opts);
+ fmt = jas_image_strtofmt("jpc");
+ ier=jas_image_encode(&image,jpcstream,fmt,opts);
if ( ier != 0 ) {
printf(" jpc_encode return = %d \n",ier);
return -3;
99 changes: 52 additions & 47 deletions layers/layer1_scientific/0089_g2clib/g2clib-64bit.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
diff -up g2clib-1.6.0_orig/g2_addfield.c g2clib-1.6.0/g2_addfield.c
--- g2clib-1.6.0_orig/g2_addfield.c 2015-05-06 13:54:24.000000000 +0200
+++ g2clib-1.6.0/g2_addfield.c 2017-08-13 10:02:58.232596592 +0200
@@ -1,3 +1,4 @@
diff -up g2clib-1.6.3/g2_addfield.c.64bit g2clib-1.6.3/g2_addfield.c
--- g2clib-1.6.3/g2_addfield.c.64bit 2021-03-08 13:09:53.000000000 -0700
+++ g2clib-1.6.3/g2_addfield.c 2021-03-08 19:22:29.878289756 -0700
@@ -1,5 +1,6 @@
/** @file
*/
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "grib2.h"
@@ -190,8 +191,8 @@ g2int g2_addfield(unsigned char *cgrib,g
@@ -192,8 +193,8 @@ g2int g2_addfield(unsigned char *cgrib,g
// total length, then there is a problem.
if ( len > lencurr ) {
printf("g2_addfield: Section byte counts don''t add to total.\n");
Expand All @@ -17,7 +19,7 @@ diff -up g2clib-1.6.0_orig/g2_addfield.c g2clib-1.6.0/g2_addfield.c
ierr=-3;
return(ierr);
}
@@ -392,7 +393,7 @@ g2int g2_addfield(unsigned char *cgrib,g
@@ -394,7 +395,7 @@ g2int g2_addfield(unsigned char *cgrib,g
}
#endif /* USE_PNG */
else {
Expand All @@ -26,15 +28,17 @@ diff -up g2clib-1.6.0_orig/g2_addfield.c g2clib-1.6.0/g2_addfield.c
ierr=-7;
return(ierr);
}
diff -up g2clib-1.6.0_orig/g2_addgrid.c g2clib-1.6.0/g2_addgrid.c
--- g2clib-1.6.0_orig/g2_addgrid.c 2015-05-06 13:54:24.000000000 +0200
+++ g2clib-1.6.0/g2_addgrid.c 2017-08-13 10:02:58.233596570 +0200
@@ -1,3 +1,4 @@
diff -up g2clib-1.6.3/g2_addgrid.c.64bit g2clib-1.6.3/g2_addgrid.c
--- g2clib-1.6.3/g2_addgrid.c.64bit 2021-03-08 13:09:53.000000000 -0700
+++ g2clib-1.6.3/g2_addgrid.c 2021-03-08 19:22:29.878289756 -0700
@@ -1,5 +1,6 @@
/** @file
*/
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "grib2.h"
@@ -125,8 +126,8 @@ g2int g2_addgrid(unsigned char *cgrib,g2
@@ -127,8 +128,8 @@ g2int g2_addgrid(unsigned char *cgrib,g2
// total length, then there is a problem.
if ( len > lencurr ) {
printf("g2_addgrid: Section byte counts don''t add to total.\n");
Expand All @@ -45,15 +49,17 @@ diff -up g2clib-1.6.0_orig/g2_addgrid.c g2clib-1.6.0/g2_addgrid.c
ierr=-3;
return(ierr);
}
diff -up g2clib-1.6.0_orig/g2_addlocal.c g2clib-1.6.0/g2_addlocal.c
--- g2clib-1.6.0_orig/g2_addlocal.c 2015-05-06 13:54:24.000000000 +0200
+++ g2clib-1.6.0/g2_addlocal.c 2017-08-13 10:02:58.233596570 +0200
@@ -1,3 +1,4 @@
diff -up g2clib-1.6.3/g2_addlocal.c.64bit g2clib-1.6.3/g2_addlocal.c
--- g2clib-1.6.3/g2_addlocal.c.64bit 2021-03-08 13:09:53.000000000 -0700
+++ g2clib-1.6.3/g2_addlocal.c 2021-03-08 19:22:29.878289756 -0700
@@ -1,5 +1,6 @@
/** @file
*/
+#include <inttypes.h>
#include <stdio.h>
#include "grib2.h"

@@ -102,8 +103,8 @@ g2int g2_addlocal(unsigned char *cgrib,u
@@ -104,8 +105,8 @@ g2int g2_addlocal(unsigned char *cgrib,u
// total length, then there is a problem.
if ( len > lencurr ) {
printf("g2_addlocal: Section byte counts don't add to total.\n");
Expand All @@ -64,7 +70,7 @@ diff -up g2clib-1.6.0_orig/g2_addlocal.c g2clib-1.6.0/g2_addlocal.c
ierr=-3;
return(ierr);
}
@@ -113,7 +114,7 @@ g2int g2_addlocal(unsigned char *cgrib,u
@@ -115,7 +116,7 @@ g2int g2_addlocal(unsigned char *cgrib,u
//
if ( (isecnum!=1) && (isecnum!=7) ) {
printf("g2_addlocal: Section 2 can only be added after Section 1 or Section 7.\n");
Expand All @@ -73,15 +79,17 @@ diff -up g2clib-1.6.0_orig/g2_addlocal.c g2clib-1.6.0/g2_addlocal.c
ierr=-4;
return(ierr);
}
diff -up g2clib-1.6.0_orig/g2_getfld.c g2clib-1.6.0/g2_getfld.c
--- g2clib-1.6.0_orig/g2_getfld.c 2015-05-06 13:54:25.000000000 +0200
+++ g2clib-1.6.0/g2_getfld.c 2017-08-13 10:02:58.234596548 +0200
@@ -1,3 +1,4 @@
diff -up g2clib-1.6.3/g2_getfld.c.64bit g2clib-1.6.3/g2_getfld.c
--- g2clib-1.6.3/g2_getfld.c.64bit 2021-03-08 13:09:53.000000000 -0700
+++ g2clib-1.6.3/g2_getfld.c 2021-03-08 19:22:29.878289756 -0700
@@ -1,5 +1,6 @@
/** @file
*/
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "grib2.h"
@@ -345,12 +346,12 @@ g2int g2_getfld(unsigned char *cgrib,g2i
@@ -347,12 +348,12 @@ g2int g2_getfld(unsigned char *cgrib,g2i
iofst=iofst+32;
gbit(cgrib,&isecnum,iofst,8); // Get Section number
iofst=iofst+8;
Expand All @@ -96,7 +104,7 @@ diff -up g2clib-1.6.0_orig/g2_getfld.c g2clib-1.6.0/g2_getfld.c
ierr=8;
return(ierr);
}
@@ -543,8 +544,8 @@ g2int g2_getfld(unsigned char *cgrib,g2i
@@ -545,8 +546,8 @@ g2int g2_getfld(unsigned char *cgrib,g2i
// If exited from above loop, the end of the GRIB message was reached
// before the requested field was found.
//
Expand All @@ -107,15 +115,17 @@ diff -up g2clib-1.6.0_orig/g2_getfld.c g2clib-1.6.0/g2_getfld.c
ierr=6;

return(ierr);
diff -up g2clib-1.6.0_orig/g2_gribend.c g2clib-1.6.0/g2_gribend.c
--- g2clib-1.6.0_orig/g2_gribend.c 2015-05-06 13:54:25.000000000 +0200
+++ g2clib-1.6.0/g2_gribend.c 2017-08-13 10:02:58.234596548 +0200
@@ -1,3 +1,4 @@
diff -up g2clib-1.6.3/g2_gribend.c.64bit g2clib-1.6.3/g2_gribend.c
--- g2clib-1.6.3/g2_gribend.c.64bit 2021-03-08 13:09:53.000000000 -0700
+++ g2clib-1.6.3/g2_gribend.c 2021-03-08 19:22:29.879289763 -0700
@@ -1,5 +1,6 @@
/** @file
*/
+#include <inttypes.h>
#include <stdio.h>
#include "grib2.h"

@@ -97,7 +98,7 @@ g2int g2_gribend(unsigned char *cgrib)
@@ -99,7 +100,7 @@ g2int g2_gribend(unsigned char *cgrib)
//
if ( isecnum != 7 ) {
printf("g2_gribend: Section 8 can only be added after Section 7.\n");
Expand All @@ -124,15 +134,17 @@ diff -up g2clib-1.6.0_orig/g2_gribend.c g2clib-1.6.0/g2_gribend.c
ierr=-4;
return (ierr);
}
diff -up g2clib-1.6.0_orig/g2_info.c g2clib-1.6.0/g2_info.c
--- g2clib-1.6.0_orig/g2_info.c 2015-05-06 13:54:25.000000000 +0200
+++ g2clib-1.6.0/g2_info.c 2017-08-13 10:02:58.234596548 +0200
@@ -1,3 +1,4 @@
diff -up g2clib-1.6.3/g2_info.c.64bit g2clib-1.6.3/g2_info.c
--- g2clib-1.6.3/g2_info.c.64bit 2021-03-08 13:09:53.000000000 -0700
+++ g2clib-1.6.3/g2_info.c 2021-03-08 19:22:29.879289763 -0700
@@ -1,5 +1,6 @@
/** @file
*/
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "grib2.h"
@@ -178,7 +179,7 @@ g2int g2_info(unsigned char *cgrib,g2int
@@ -180,7 +181,7 @@ g2int g2_info(unsigned char *cgrib,g2int
(*numfields)++;
}
else {
Expand All @@ -141,29 +153,22 @@ diff -up g2clib-1.6.0_orig/g2_info.c g2clib-1.6.0/g2_info.c
ierr=6;
return(ierr);
}
diff -up g2clib-1.6.0_orig/grib2.h g2clib-1.6.0/grib2.h
--- g2clib-1.6.0_orig/grib2.h 2016-01-22 13:27:13.000000000 +0100
+++ g2clib-1.6.0/grib2.h 2017-08-13 10:02:58.235596526 +0200
@@ -1,5 +1,6 @@
diff -up g2clib-1.6.3/grib2.h.64bit g2clib-1.6.3/grib2.h
--- g2clib-1.6.3/grib2.h.64bit 2021-03-08 19:22:29.879289763 -0700
+++ g2clib-1.6.3/grib2.h 2021-03-08 19:23:52.710885385 -0700
@@ -148,12 +148,13 @@
*/
#ifndef _grib2_H
#define _grib2_H
+#include<inttypes.h>
#include<stdio.h>

#define G2_VERSION "g2clib-1.6.0"
@@ -151,13 +152,8 @@
// that holds the data.
*/
#define G2_VERSION "g2clib-1.6.3"

-#ifdef __64BIT__
-typedef int g2int;
-typedef unsigned int g2intu;
-#else
-typedef long g2int;
-typedef unsigned long g2intu;
-#endif
+typedef int32_t g2int;
+typedef uint32_t g2intu;

typedef float g2float;

struct gtemplate {
7 changes: 3 additions & 4 deletions layers/layer1_scientific/0089_g2clib/g2clib-degrib.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
diff -up g2clib-1.6.0.p123/gridtemplates.c g2clib-1.6.0.p1234/gridtemplates.c
--- g2clib-1.6.0.p123/gridtemplates.c 2017-08-13 10:50:40.668001879 +0200
+++ g2clib-1.6.0.p1234/gridtemplates.c 2017-08-13 10:52:24.579434531 +0200
@@ -24,11 +24,11 @@ const struct gridtemplate templatesgrid[
--- g2clib-1.6.2.p123/gridtemplates.c 2021-01-07 09:22:58.005395269 +0100
+++ g2clib-1.6.2.p1234/gridtemplates.c 2021-01-07 09:24:25.639126323 +0100
@@ -26,11 +26,11 @@ const struct gridtemplate templatesgrid[
{140, 17, 0, {1,1,4,1,4,1,4,4,4,-4,4,4,4,1,4,4,1} },
//
// 3.10: Mercator
Expand Down
10 changes: 5 additions & 5 deletions layers/layer1_scientific/0089_g2clib/g2clib-jasper2.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff -up g2clib-1.6.0.p1234/enc_jpeg2000.c g2clib-1.6.0.p12345/enc_jpeg2000.c
--- g2clib-1.6.0.p1234/enc_jpeg2000.c 2017-08-13 10:52:12.990720854 +0200
+++ g2clib-1.6.0.p12345/enc_jpeg2000.c 2017-08-13 10:55:41.220584631 +0200
@@ -121,7 +121,9 @@ int enc_jpeg2000(unsigned char *cin,g2in
--- g2clib-1.6.2.p1234/enc_jpeg2000.c 2021-01-07 09:24:13.152449617 +0100
+++ g2clib-1.6.2.p12345/enc_jpeg2000.c 2021-01-07 09:33:27.386963771 +0100
@@ -123,7 +123,9 @@ int enc_jpeg2000(unsigned char *cin,g2in
image.clrspc_=JAS_CLRSPC_SGRAY; /* grayscale Image */
image.cmprof_=0;
#endif
-// image.inmem_=1;
+#if JAS_VERSION_MAJOR == 1
image.inmem_=1;
+ image.inmem_=1;
+#endif

cmpt.tlx_=0;
Expand Down
7 changes: 3 additions & 4 deletions layers/layer1_scientific/0089_g2clib/g2clib-simunpack.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
diff -up g2clib-1.6.0.p12/simunpack.c g2clib-1.6.0.p123/simunpack.c
--- g2clib-1.6.0.p12/simunpack.c 2017-08-13 10:24:02.266764550 +0200
+++ g2clib-1.6.0.p123/simunpack.c 2017-08-13 10:50:49.881774231 +0200
@@ -49,7 +49,7 @@ g2int simunpack(unsigned char *cpack,g2i
--- g2clib-1.6.2.p12/simunpack.c 2021-01-07 09:11:50.845682809 +0100
+++ g2clib-1.6.2.p123/simunpack.c 2021-01-07 09:23:07.786142031 +0100
@@ -51,7 +51,7 @@ g2int simunpack(unsigned char *cpack,g2i
nbits = idrstmpl[3];
itype = idrstmpl[4];

Expand Down
Loading

0 comments on commit 9696327

Please sign in to comment.