Updated patch attached which also works with older NetCDF.

Kind Regards,

Bas

--
 GPG Key ID: 4096R/6750F10AE88D4AF1
Fingerprint: 8182 DE41 7056 408D 6146  50D1 6750 F10A E88D 4AF1
diff -Nru minc-tools-2.3.00+dfsg/debian/patches/netcdf-4.9.3.patch 
minc-tools-2.3.00+dfsg/debian/patches/netcdf-4.9.3.patch
--- minc-tools-2.3.00+dfsg/debian/patches/netcdf-4.9.3.patch    1970-01-01 
01:00:00.000000000 +0100
+++ minc-tools-2.3.00+dfsg/debian/patches/netcdf-4.9.3.patch    2025-02-08 
10:56:30.000000000 +0100
@@ -0,0 +1,124 @@
+Description: Replace _FillValue by NC_FillValue for NetCDF 4.9.3.
+Author: Bas Couwenberg <sebas...@debian.org>
+
+--- a/progs/mincgen/ncgentab.y
++++ b/progs/mincgen/ncgentab.y
+@@ -14,6 +14,10 @@
+ #include        "ncgen.h"
+ #include      "genlib.h"      /* for grow_darray() et al */
+ 
++#if defined(_FillValue) && !defined(NC_FillValue)
++#define NC_FillValue _FillValue
++#endif
++
+ YYSTYPE symlist;              /* symbol table: linked list */
+ 
+ extern int derror_count;      /* counts errors in netcdf definition */
+@@ -68,7 +72,7 @@ static void *rec_start;              /* start of spa
+       NETCDF      /* keyword declaring netcdf name */
+         HDF5        /* keyword declaring hdf5 name */
+       DATA        /* keyword starting data section, if any */
+-        FILLVALUE   /* fill value, from _FillValue attribute or default */
++        FILLVALUE   /* fill value, from NC_FillValue attribute or default */
+ 
+ %start        ncdesc /* start symbol for grammar */
+ 
+@@ -204,7 +208,7 @@ varspec:        var
+                   vars[nvars].lname = decodify($1->name);
+                   vars[nvars].type = type_code;
+                   /* set default fill value.  You can override this with
+-                   * the variable attribute "_FillValue". */
++                   * the variable attribute "NC_FillValue". */
+                   nc_getfill(type_code, &vars[nvars].fill_value);
+                   vars[nvars].has_data = 0; /* has no data (yet) */
+                  }
+@@ -275,14 +279,14 @@ attdecl:        att
+                      /* shrink space down to what was really needed */
+                      att_space = erealloc(att_space, 
valnum*nctypesize(valtype));
+                      atts[natts].val = att_space;
+-                     if (STREQ(atts[natts].name, _FillValue) &&
++                     if (STREQ(atts[natts].name, NC_FillValue) &&
+                          atts[natts].var != NC_GLOBAL) {
+                          nc_putfill(atts[natts].type,
+                                      atts[natts].val,
+                                      &vars[atts[natts].var].fill_value);
+                          if(atts[natts].type != vars[atts[natts].var].type) {
+                              derror("variable %s: %s type mismatch",
+-                                    vars[atts[natts].var].name, _FillValue);
++                                    vars[atts[natts].var].name, NC_FillValue);
+                          }
+                      }
+                      natts++;
+--- a/progs/mincdump/mincdump.c
++++ b/progs/mincdump/mincdump.c
+@@ -19,6 +19,10 @@
+ #include "dumplib.h"
+ #include "vardata.h"
+ 
++#if defined(_FillValue) && !defined(NC_FillValue)
++#define NC_FillValue _FillValue
++#endif
++
+ static void usage(void);
+ static char* name_path(const char* path);
+ static char* type_name(nc_type  type);
+@@ -475,20 +479,20 @@ do_ncdump(char *path, struct fspec* spec
+                 vdims[id] = dims[var.dims[id]].size;
+               var.has_fillval = 1; /* by default, but turn off for bytes */
+ 
+-              /* get _FillValue attribute */
++              /* get NC_FillValue attribute */
+                 old_nc_opts = ncopts;
+                 ncopts = 0;
+-                nc_status = 
ncattinq(ncid,varid,_FillValue,&att.type,&att.len);
++                nc_status = 
ncattinq(ncid,varid,NC_FillValue,&att.type,&att.len);
+                 ncopts = old_nc_opts;
+               if(nc_status == NC_NOERR &&
+                  att.type == var.type && att.len == 1) {
+                   if(var.type == NC_CHAR) {
+                       char fillc;
+-                      ncattget(ncid, varid, _FillValue, &fillc );
++                      ncattget(ncid, varid, NC_FillValue, &fillc );
+                       var.fillval = fillc;
+                   } 
+                     else {
+-                      ncattget(ncid, varid, _FillValue, &var.fillval);
++                      ncattget(ncid, varid, NC_FillValue, &var.fillval);
+                   }
+               } else {
+                   switch (var.type) {
+--- a/progs/mincdump/mincdump.man1
++++ b/progs/mincdump/mincdump.man1
+@@ -52,8 +52,8 @@ and shapes; attribute names and values;
+ data for all variables or selected variables in a netCDF file.
+ .LP
+ \fBmincdump\fP uses `_' to represent data values that are equal to the
+-`_FillValue' attribute for a variable, intended to represent data that
+-has not yet been written.  If a variable has no `_FillValue' attribute, the
++`NC_FillValue' attribute for a variable, intended to represent data that
++has not yet been written.  If a variable has no `NC_FillValue' attribute, the
+ default fill value for the variable type is used if the variable is not of
+ byte type.
+ .SH OPTIONS
+--- a/progs/mincgen/mincgen.man1
++++ b/progs/mincgen/mincgen.man1
+@@ -167,7 +167,7 @@ arrays, the last dimension varies fastes
+ column order is used for matrices.  If fewer values are supplied than
+ are needed to fill a variable, it is extended with a type-dependent
+ `fill value', which can be overridden by supplying a value for a
+-distinguished variable attribute named `_FillValue'.  The
++distinguished variable attribute named `NC_FillValue'.  The
+ types of constants need not match the type declared for a variable;
+ coercions are done to convert integers to floating point, for example.
+ The constant `_' can be used to designate the fill value for a variable.
+--- a/progs/mincgen/ncgen.h
++++ b/progs/mincgen/ncgen.h
+@@ -39,7 +39,7 @@ extern struct vars {
+     nc_type type;
+     int ndims;
+     int *dims;                        /* array of dimension ids */
+-    union generic fill_value; /* set to value of _FillValue attribute */
++    union generic fill_value; /* set to value of NC_FillValue attribute */
+     int has_data;             /* 1 if data specified, 0 otherwise */
+     size_t nrecs;             /* for record variables, number of records
+                                * of data in CDL */
diff -Nru minc-tools-2.3.00+dfsg/debian/patches/series 
minc-tools-2.3.00+dfsg/debian/patches/series
--- minc-tools-2.3.00+dfsg/debian/patches/series        2024-12-29 
23:39:42.000000000 +0100
+++ minc-tools-2.3.00+dfsg/debian/patches/series        2025-02-08 
10:56:30.000000000 +0100
@@ -5,3 +5,4 @@
 fix_manpages.patch
 fix-gcc10-build.patch
 mnc2nii-use-size-t.patch
+netcdf-4.9.3.patch

Reply via email to