[metview] 08/14: Upstream 4.9.1

Alastair McKinstry mckinstry at moszumanska.debian.org
Wed Oct 25 12:49:02 UTC 2017


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository metview.

commit 603780b4c84d757af4d853d3795ac3d8b4c225e1
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Wed Oct 11 17:02:31 2017 +0100

    Upstream 4.9.1
---
 VERSION.cmake                    |   2 +-
 src/libMarsClient/CMakeLists.txt |   1 +
 src/libMarsClient/base.c         |   6 +-
 src/libMarsClient/calc.c         |  48 +++++------
 src/libMarsClient/field.c        |  66 +++++++++++---
 src/libMarsClient/field.h        |  20 +++--
 src/libMarsClient/forwardbase.c  | 180 +++++++++++++++++++++++++++++++++++++++
 src/libMarsClient/pproc.c        |  96 ++++++++++-----------
 src/libMarsClient/proto.h        |   5 +-
 9 files changed, 326 insertions(+), 98 deletions(-)

diff --git a/VERSION.cmake b/VERSION.cmake
index 47f3cc7..cdb169e 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -1,5 +1,5 @@
 set(${PROJECT_NAME}_MAJOR_VERSION_STR    "4")
 set(${PROJECT_NAME}_MINOR_VERSION_STR    "9")
-set(${PROJECT_NAME}_REVISION_VERSION_STR "0")
+set(${PROJECT_NAME}_REVISION_VERSION_STR "1")
 
 set(${PROJECT_NAME}_VERSION_STR  "${${PROJECT_NAME}_MAJOR_VERSION_STR}.${${PROJECT_NAME}_MINOR_VERSION_STR}.${${PROJECT_NAME}_REVISION_VERSION_STR}")
diff --git a/src/libMarsClient/CMakeLists.txt b/src/libMarsClient/CMakeLists.txt
index 2706a52..723aaba 100644
--- a/src/libMarsClient/CMakeLists.txt
+++ b/src/libMarsClient/CMakeLists.txt
@@ -74,6 +74,7 @@ expand.c
 extargs.c
 externf.c
 fdb5base.cc
+forwardbase.c
 odbdirect.cc
 feedtask.c
 field.c
diff --git a/src/libMarsClient/base.c b/src/libMarsClient/base.c
index 242eae9..5eb7d08 100644
--- a/src/libMarsClient/base.c
+++ b/src/libMarsClient/base.c
@@ -24,8 +24,9 @@ ECMWF Oct-93
 /* extern base_class *cachebase; */
 extern base_class *netbase;
 extern base_class *nfdbbase;
-extern base_class *fdb5base;
 extern base_class *filebase;
+extern base_class *fdb5base;
+extern base_class *forwardbase;
 extern base_class *targetbase;
 extern base_class *nullbase;
 extern base_class *dhsbase;
@@ -53,7 +54,8 @@ static base_class **bases[] = {
 	/* &cachebase, */
 	&dhsbase,
 	&flatfilebase,
-	&multibase,
+    &multibase,
+    &forwardbase,
     &apibase,
 };
 
diff --git a/src/libMarsClient/calc.c b/src/libMarsClient/calc.c
index 82f878c..edc933d 100644
--- a/src/libMarsClient/calc.c
+++ b/src/libMarsClient/calc.c
@@ -1,5 +1,5 @@
 /*
- * © Copyright 1996-2012 ECMWF.
+ * © Copyright 1996-2017 ECMWF.
  * 
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -193,7 +193,7 @@ static err f_v_minmax(math *p,fop2 f)
 	else
 	{
 		m = g->values[0];
-		if(FIELD_HAS_BITMAP(g)) {
+		if(FIELD_HAS_MISSING_VALS(g)) {
 			int i = 0;
 			while(MISSING_VALUE(m) && i != g->value_count)
 				m = g->values[i++];
@@ -207,7 +207,7 @@ static err f_v_minmax(math *p,fop2 f)
 
 			if(! MISSING_FIELD(g))
 			{
-				if(FIELD_HAS_BITMAP(g))
+				if(FIELD_HAS_MISSING_VALS(g))
 				{
 					for(j=0;j<g->value_count;j++)
 						if( ! MISSING_VALUE(g->values[j]))
@@ -259,7 +259,7 @@ static err unop(math *p,fop1 f)
 			gc = copy_field(ga,false);
 			for(j=0;j<ga->value_count;j++)
 				gc->values[j] = f(ga->values[j]);
-			copy_bitmap(gc,ga,0);
+			copy_missing_vals(gc,ga,0);
 		}
 
 		set_field(vc,gc,i);
@@ -318,7 +318,7 @@ static err binop(math *p,fop2 f)
 				gc = copy_field(gb,false);
 				for(j=0;j<gb->value_count;j++)
 					gc->values[j] = f(x,gb->values[j]);
-				copy_bitmap(gc,0,gb);
+				copy_missing_vals(gc,0,gb);
 			}
 
 			set_field(vc,gc,i);
@@ -357,7 +357,7 @@ static err binop(math *p,fop2 f)
 				gc = copy_field(ga,false);
 				for(j=0;j<ga->value_count;j++)
 					gc->values[j] = f(ga->values[j],x);
-				copy_bitmap(gc,ga,0);
+				copy_missing_vals(gc,ga,0);
 			}
 
 			set_field(vc,gc,i);
@@ -415,7 +415,7 @@ static err binop(math *p,fop2 f)
 			for(j=0;j<ga->value_count;j++)
 				gc->values[j] = f(ga->values[j],gb->values[j]);
 
-			copy_bitmap(gc,ga,gb);
+			copy_missing_vals(gc,ga,gb);
 		}
 
 		set_field(vc,gc,i);
@@ -482,7 +482,7 @@ static err f_sum(math *p,void *data)
 				for(j=0;j<gin->value_count;j++)
 					gout->values[j] += gin->values[j];
 
-			copy_bitmap(gout,gin,0);
+			copy_missing_vals(gout,gin,0);
 			release_field(gin);
 
 		}
@@ -554,7 +554,7 @@ static err f_mean(math *p,void *data)
 				missing++;
 
 			if(e == 0)
-				copy_bitmap(gout,gin,0);
+				copy_missing_vals(gout,gin,0);
 			release_field(gin);
 
 		}
@@ -620,7 +620,7 @@ static err f_rms(math *p,void *data)
 			else
 				missing++;
 
-			copy_bitmap(gout,gin,0);
+			copy_missing_vals(gout,gin,0);
 			release_field(gin);
 
 		}
@@ -678,12 +678,12 @@ static err f_minmax(math *p,fop2 f)
 
 				if(! MISSING_FIELD(gin))
 				{
-					if(FIELD_HAS_BITMAP(gin) || FIELD_HAS_BITMAP(gout))
+					if(FIELD_HAS_MISSING_VALS(gin) || FIELD_HAS_MISSING_VALS(gout))
 					{
 						for(j=0;j<gin->value_count;j++)
 							if( ! (MISSING_VALUE(gin->values[j]) || MISSING_VALUE(gout->values[j])) )
 								gout->values[j] = f(gin->values[j],gout->values[j]);
-						copy_bitmap(gout,gin,0);
+						copy_missing_vals(gout,gin,0);
 
 					}
 					for(j=0;j<gin->value_count;j++)
@@ -821,7 +821,7 @@ static err f_distribution(math *p,void *data)
 				e = -1;
 			}
 
-			if(FIELD_HAS_BITMAP(f)) 
+			if(FIELD_HAS_MISSING_VALS(f)) 
 				bitmap++;
 
 			if(count && count != f->value_count)
@@ -839,7 +839,7 @@ static err f_distribution(math *p,void *data)
 
 		if(bitmap)
 			for(j = 0; j < size ; j++)
-				g[j]->bitmap = true;
+				set_bitmap(g[j]);
 
 
 
@@ -981,7 +981,7 @@ static err f_stdev(math *p,void *data)
 			else
 				missing++;
 
-			copy_bitmap(gout,gin,0);
+			copy_missing_vals(gout,gin,0);
 			release_field(gin);
 
 		}
@@ -1064,7 +1064,7 @@ static err f_var(math *p,void *data)
 			else
 				missing++;
 
-			copy_bitmap(gout,gin,0);
+			copy_missing_vals(gout,gin,0);
 
 			release_field(gin);
 
@@ -1162,7 +1162,7 @@ static err f_covar(math *p,void *data)
 
 		for(j=0;j<gx->value_count;j++)
 			gout->values[j] = 0;
-		copy_bitmap(gout,gx,gy);
+		copy_missing_vals(gout,gx,gy);
 
 		release_field(gx);
 		release_field(gy);
@@ -1193,7 +1193,7 @@ static err f_covar(math *p,void *data)
 					gout->values[j] += (gx->values[j] * gy->values[j]);
 				}
 
-			copy_bitmap(gout,gx,gy);
+			copy_missing_vals(gout,gx,gy);
 
 			release_field(gx);
 			release_field(gy);
@@ -1401,7 +1401,7 @@ static err f_bitmap(math *p,void *data)
 						if(ga->values[j] == vy->val)
 						{
 							gc->values[j] = mars.grib_missing_value;
-							gc->bitmap = true;
+							set_bitmap(gc);
 						}
 				}
 				set_field(vout,gc,i);
@@ -1435,8 +1435,8 @@ static err f_bitmap(math *p,void *data)
 				else
 				{
 					gc = copy_field(ga,true);
-					if(FIELD_HAS_BITMAP(gb)) 
-						copy_bitmap(gc,gb,0);
+					if(FIELD_HAS_MISSING_VALS(gb)) 
+						copy_missing_vals(gc,gb,0);
 				}
 
 				set_field(vout,gc,i);
@@ -1477,8 +1477,8 @@ static err f_bitmap(math *p,void *data)
 						return -1;
 					}
 					gc = copy_field(ga,true);
-					if(FIELD_HAS_BITMAP(gb)) 
-						copy_bitmap(gc,gb,0);
+					if(FIELD_HAS_MISSING_VALS(gb)) 
+						copy_missing_vals(gc,gb,0);
 				}
 				set_field(vout,gc,i);
 				if( ((i+1) % SAVE_CNT) == 0) 
@@ -1553,7 +1553,7 @@ static err f_nobitmap(math *p,void *data)
 		{
 			field *ga = get_field(vx->fs,i,expand_mem);
 			field *gc = copy_field(ga,true);
-			if(FIELD_HAS_BITMAP(ga))
+			if(FIELD_HAS_MISSING_VALS(ga))
 			{
 				for(j=0;j<ga->value_count;j++)
 					if(MISSING_VALUE(ga->values[j]))
diff --git a/src/libMarsClient/field.c b/src/libMarsClient/field.c
index a6e0d94..149a118 100644
--- a/src/libMarsClient/field.c
+++ b/src/libMarsClient/field.c
@@ -1,5 +1,5 @@
 /*
- * © Copyright 1996-2012 ECMWF.
+ * © Copyright 1996-2017 ECMWF.
  * 
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -44,6 +44,19 @@ extern int strcasecmp(const char*,const char*);
 #endif
 
 
+/* Not all versions of ecCodes and GRIB_API support the missingValuesPresent key */
+#ifdef ECCODES_VERSION
+	#if (ECCODES_VERSION) >= 20401
+		#define MISSING_VALUES_PRESENT_KEY_EXISTS 1
+    #endif
+#else
+	#if (GRIB_API_VERSION) >= 12301
+		#define MISSING_VALUES_PRESENT_KEY_EXISTS 1
+    #endif
+#endif
+
+
+
 static mempool varmem = {
 	10, /* 10 pages = 40k */
 	1,  /* clear */
@@ -276,10 +289,11 @@ field *copy_field(field *gx,boolean copydata)
 {
 	field *gv   = new_field();
 
-	gv->value_count = gx->value_count;
-	gv->shape   = gx->shape;
-	gv->missing = gx->missing;
-	gv->bitmap  = gx->bitmap;
+	gv->value_count  = gx->value_count;
+	gv->shape        = gx->shape;
+	gv->missing      = gx->missing;
+	gv->bitmap       = gx->bitmap;
+	gv->missing_vals = gx->missing_vals;
 
 	if(gx->r) {
 		gv->r = gx->r;
@@ -301,9 +315,9 @@ field *copy_field(field *gx,boolean copydata)
 	return gv;
 }
 
-void copy_bitmap(field *gc, field *ga, field *gb)
+void copy_missing_vals(field *gc, field *ga, field *gb)
 {
-	boolean doit = ( ga && ga->bitmap) || (gb && gb->bitmap);
+	boolean doit = ( ga && ga->missing_vals) || (gb && gb->missing_vals);
 
 	if(doit)
 	{
@@ -323,7 +337,7 @@ void copy_bitmap(field *gc, field *ga, field *gb)
 					gc->values[j] = mars.grib_missing_value;
 		}
 
-		gc->bitmap = true;
+		set_bitmap(gc);
 	}
 }
 
@@ -335,12 +349,30 @@ void remove_bitmap(field *gc)
 	gc->ksec1[4] &= ~0x40; /* ~0x40 == 0xAF */
 #endif
 	gc->bitmap = false;
+	gc->missing_vals = false;
 	err = grib_set_long(gc->handle,"bitmapPresent",0);
 	if(err) {
 		marslog(LOG_EXIT,"grib_set_long(bitmapPresent) failed: %s", grib_get_error_message(err));
 	}
 }
 
+
+void set_bitmap(field *gc)
+{
+	/* only flag a bitmap to be created if field currently has no concept of missing values
+	   (if bitmap=true, then no need to add one, and in this case missing_vals will be true
+	   too; if bitmap=false and missing_vals=true then we have one of these packing types
+	   that allows missing values to be encoded directly in the data, and we don't want
+	   to add a bitmap to that) */
+
+	if (!gc->missing_vals)
+	{
+		gc->bitmap = true;
+		gc->missing_vals = true;
+	}
+}
+
+
 fieldset *copy_fieldset(fieldset *x,int count,boolean copydata)
 {
 	fieldset *v = new_fieldset(count);
@@ -481,7 +513,7 @@ static err to_packed_mem(field *g)
 
 		}
 
-		/* Bitmap */
+		/* Bitmap. Note that missingValuesPresent is read-only, so we do not need to set it */
 		if((e = grib_set_double(g->handle,"missingValue",mars.grib_missing_value)))
 		{
 			marslog(LOG_EROR,"%s: cannot set missingValue %s",grib_get_package_name(),grib_get_error_message(e));
@@ -605,6 +637,7 @@ static err to_expand_mem(field *g)
 	{
 		size_t count = 0;
 		long bitmap = 0;
+		long missing_vals = 0;
 
 		if((e = grib_get_size(g->handle,"values",&g->value_count)))
 		{
@@ -636,7 +669,20 @@ static err to_expand_mem(field *g)
 			return e;
 		}
 
-		g->bitmap = (bitmap != 0);
+#ifdef MISSING_VALUES_PRESENT_KEY_EXISTS
+		if((e = grib_get_long(g->handle,"missingValuesPresent",&missing_vals)))
+		{
+			marslog(LOG_EROR,"%s: cannot get missingValuesPresent %s",grib_get_package_name(),grib_get_error_message(e));
+			return e;
+		}
+#else
+		/* if this key is not supported by the GRIB-decoding package, we revert to the 'old'
+		   behaviour, which is to equate a bitmap with the existence of missing values */
+		missing_vals = bitmap;
+#endif
+
+		g->bitmap       = (bitmap != 0);
+		g->missing_vals = (missing_vals != 0);
 
 #ifdef COMEBACK
 		set g->missing
diff --git a/src/libMarsClient/field.h b/src/libMarsClient/field.h
index d0f6824..54a5492 100644
--- a/src/libMarsClient/field.h
+++ b/src/libMarsClient/field.h
@@ -1,5 +1,5 @@
 /*
- * © Copyright 1996-2012 ECMWF.
+ * © Copyright 1996-2017 ECMWF.
  * 
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -48,10 +48,16 @@ typedef struct field {
 	size_t        length;
 	gribfile      *file;
 
-	/* missing fields/values */
+	/* missing fields/values; usually a field has a bitmap to represent
+       missing values, but if the packing type is grid_complex_spatial_differencing
+       then the missing values can be encoded directly in the array of values;
+       the flag 'bitmap' specifically tells us if the field has a bitmap, and the
+       flag 'missing_values' tells us if the field contains missing values,
+       regardles of which encoding method was used. */
 
 	boolean   missing;         /* field is missing */
-	boolean   bitmap;          /* field has missing values (= bitmap) */
+	boolean   bitmap;          /* field has bitmap */
+	boolean   missing_vals;    /* field has missing values */
 
 	field_request *r;
 
@@ -71,6 +77,8 @@ typedef struct fieldset {
 }fieldset;
 
 
-#define MISSING_VALUE(n)      ((n) == mars.grib_missing_value)
-#define MISSING_FIELD(f)      ((f)->missing)
-#define FIELD_HAS_BITMAP(f)   ((f)->bitmap)
+
+
+#define MISSING_VALUE(n)          ((n) == mars.grib_missing_value)
+#define MISSING_FIELD(f)          ((f)->missing)
+#define FIELD_HAS_MISSING_VALS(f) ((f)->missing_vals)
diff --git a/src/libMarsClient/forwardbase.c b/src/libMarsClient/forwardbase.c
new file mode 100644
index 0000000..4be672a
--- /dev/null
+++ b/src/libMarsClient/forwardbase.c
@@ -0,0 +1,180 @@
+/*
+ * © Copyright 1996-2012 ECMWF.
+ * 
+ * This software is licensed under the terms of the Apache Licence Version 2.0
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
+ * In applying this licence, ECMWF does not waive the privileges and immunities 
+ * granted to it by virtue of its status as an intergovernmental organisation nor
+ * does it submit to any jurisdiction.
+ */
+
+#include "mars.h"
+#include <ctype.h>
+
+static void     forward_init(void);
+static err      forward_open(void *data,request*,request*,int);
+static err      forward_close(void *data);
+static err      forward_read(void *data,request *r,void *buffer,long *length);
+static err      forward_write(void *data,request *r,void *buffer,long *length);
+static boolean  forward_check(void *data,request *r);
+static err      forward_validate(void *data,request*,request*,int);
+
+
+typedef struct forwarddata {
+    char      *forward;
+    char      *defaultdbname;
+    database  *db;
+} forwarddata;
+
+static option opts[] = {
+  {"forward", NULL, NULL, NULL, t_str, sizeof(char*),
+  OFFSET(forwarddata, forward)},
+  {"default", NULL, NULL, NULL, t_str, sizeof(char*),
+  OFFSET(forwarddata, defaultdbname)},
+};
+
+
+base_class _forwardbase = {
+
+	NULL,                      /* parent class */
+    "forwardbase",             /* name         */
+
+	false,                     /* inited       */
+
+    sizeof(forwarddata),       /* private size */
+	NUMBER(opts),              /* option count */
+	opts,                      /* options      */
+
+    forward_init,              /* init         */
+
+    forward_open,              /* open         */
+    forward_close,             /* close        */
+
+    forward_read,              /* read         */
+    forward_write,             /* write        */
+
+	NULL,                      /* control      */
+
+    forward_check,             /* check        */
+    NULL,                      /* query        */
+
+    NULL,                      /* archive      */
+    NULL,                      /* admin        */
+
+    forward_validate,          /* validate */
+
+
+};
+
+
+base_class *forwardbase = &_forwardbase;
+
+static void forward_init(void)
+{
+}
+
+static char* select_dbname(forwarddata* fdata, boolean report) {
+
+  char* dbname = 0;
+
+  if(fdata->forward) {
+
+    dbname = getenv(fdata->forward);
+
+    if(dbname) return dbname;
+
+    if(report) marslog(LOG_DBUG,"Forward-base: forward environment variable not defined");
+  }
+  else {
+    if(report) marslog(LOG_DBUG,"Forward-base: forward keyword not defined");
+  }
+
+  if(fdata->defaultdbname) return fdata->defaultdbname;
+
+  if(report) marslog(LOG_DBUG,"Forward-base: default database name not defined");
+
+  return 0;
+}
+
+static err  forward_open(void *data,request *r,request *e,int mode)
+{
+  const char   *name;
+  request      *cachesetup = 0;
+
+  forwarddata *fdata = (forwarddata*)data;
+
+  char* dbname = select_dbname(fdata, true);
+
+  if(!dbname) {
+    marslog(LOG_EROR,"Forward-base: failed to select a database to forward to");
+    return -2;
+  }
+
+  request* setup = findbase(dbname);
+  if(!setup)
+    return -2;
+
+  marslog(LOG_INFO,"Forward-base: forwarding to database %s", dbname);
+
+  fdata->db = openbase(setup, r, &name, &cachesetup, READ_MODE);
+  if(!fdata->db)
+    return -2;
+
+  return NOERR;
+}
+
+static err  forward_close(void *data)
+{
+    forwarddata *fdata = (forwarddata*)data;
+	int ret = 0;
+
+    if(fdata->db != 0)
+    {
+      ret = database_close(fdata->db);
+    }
+
+	return ret;
+}
+
+static err  forward_read(void *data,request *r,void *buffer,long *length)
+{
+    forwarddata *fdata = (forwarddata*)data;
+
+    return database_read(fdata->db, r, buffer, length);
+}
+
+static err  forward_write(void *data, request *r, void *buffer, long *length)
+{
+    marslog(LOG_EROR,"Cannot write on Forward-base");
+	return -2;
+}
+
+static boolean  forward_check(void *data, request *r)
+{
+    forwarddata *fdata = (forwarddata*)data;
+    return database_check(fdata->db, r);
+}
+
+static err      forward_validate(void *data,request *r,request *e,int mode)
+{
+    forwarddata *fdata = (forwarddata*)data;
+	const char   *name;
+	request     *setup;
+	int i;
+
+    char* dbname = select_dbname(fdata, false);
+    if(!dbname) {
+      marslog(LOG_EROR,"Forward-base: failed to select a database to forward to");
+      return -2;
+    }
+
+    setup = findbase(dbname);
+    if(!setup)
+      return -1;
+
+    name  = get_value(setup,"class",0);
+    if(database_validate(base_class_by_name(name),dbname,r,e,mode) != 0)
+      return -1;
+
+    return NOERR;
+}
diff --git a/src/libMarsClient/pproc.c b/src/libMarsClient/pproc.c
index 3f27948..6711e9d 100644
--- a/src/libMarsClient/pproc.c
+++ b/src/libMarsClient/pproc.c
@@ -1734,25 +1734,22 @@ err ppinit(const request *r, postproc *proc)
 
 		}
 
-        /* gridname */
-
-        const char *gridname = get_value(r,"_GRIDNAME",0);
-        if(gridname)
-        {
-            ret = ppout("gridname",n,array,gridname);
-            if(ret) return ret;
-
-            n = atoi(get_value(r,"_GAUSSIAN",0));
-            long guess;
-            guess = (2*n) * (4*n+20); /* nb lats * nb points at equator for octahedral grid */
-            if( guess > ppdata.estimate ) ppdata.estimate = guess;
-        }
+		/* gridname */
+		const char *gridname = get_value(r,"_GRIDNAME",0);
+		if(gridname)
+		{
+			ret = ppout("gridname",n,array,gridname);
+			if(ret) return ret;
 
-        /* set LatLon grid */
+			n = atoi(get_value(r,"_GAUSSIAN",0));
+			long guess;
+			guess = (2*n) * (4*n+20); /* nb lats * nb points at equator for octahedral grid */
+			if( guess > ppdata.estimate ) ppdata.estimate = guess;
+		}
 
+		/* set LatLon grid */
 		if(get_value(r,"_GRID_EW",0))
 		{
-
 			array[0] = atof(get_value(r,"_GRID_EW",0));
 			array[1] = atof(get_value(r,"_GRID_NS",0));
 			ret      = ppout("grid",n,array,0);
@@ -1761,7 +1758,6 @@ err ppinit(const request *r, postproc *proc)
 		}
 
 		/* set area */
-
 		if(get_value(r,"_AREA_N",0))
 		{
 			array[0] = atof(get_value(r,"_AREA_N",0));
@@ -1779,7 +1775,7 @@ err ppinit(const request *r, postproc *proc)
 			}
 		}
 
-		/* set frame */
+		/* frame */
 		if(get_value(r,"FRAME",0))
 		{
 			n = atoi(get_value(r,"FRAME",0));
@@ -1787,7 +1783,7 @@ err ppinit(const request *r, postproc *proc)
 			if(ret) return ret;
 		}
 
-		/* set bitmap */
+		/* bitmap */
 		if(get_value(r,"BITMAP",0))
 		{
 			const char *bitmap = no_quotes(get_value(r,"BITMAP",0));
@@ -1796,8 +1792,7 @@ err ppinit(const request *r, postproc *proc)
 			if(ret) return ret;
 		}
 
-        /* Interpolation */
-		
+		/* interpolation */
 		if(get_value(r,"INTERPOLATION",0))
 		{
 			const char *method  = get_value(r,"INTERPOLATION",0);
@@ -1822,7 +1817,6 @@ err ppinit(const request *r, postproc *proc)
 		}
 
 		/* Auto Resolution */
-
 		if(get_value(r,"RESOL",0))
 		{
 			const char *trunc = get_value(r,"RESOL",0);
@@ -1837,19 +1831,17 @@ err ppinit(const request *r, postproc *proc)
 						if(ret) marslog(LOG_EROR,"Auto Resolution error %d",ret);
 					}
 				}
-                if(trunc[0] == 'N' || trunc[0] == 'O')
-                {
-                    n    = atoi(trunc+1);
-                    marslog(LOG_DBUG,"Using GG double interpolation to %s", trunc);
-                    ret = ppout("intermediate_gaussian",n,array,trunc);
-                    if(ret) marslog(LOG_EROR,"Double interpolation error %d",ret);
-                }
-            }
-
+				if(trunc[0] == 'N' || trunc[0] == 'O')
+				{
+					n    = atoi(trunc+1);
+					marslog(LOG_DBUG,"Using GG double interpolation to %s", trunc);
+					ret = ppout("intermediate_gaussian",n,array,trunc);
+					if(ret) marslog(LOG_EROR,"Double interpolation error %d",ret);
+				}
+			}
 		}
 
 		/* truncation */
-
 		if(get_value(r,"_TRUNCATION",0))
 		{
 			long guess;
@@ -1876,14 +1868,11 @@ err ppinit(const request *r, postproc *proc)
 		{
 			ret = pprotation(r);
 			if(ret) return ret;
-
 			if(vector)
 				*proc = grib_vector_postproc;
-
 		}
 
 		/* accuracy */
-
 		if(mars.accuracy > 0)
 		{
 			marslog(LOG_DBUG,"ppout: Using %d bit packing",mars.accuracy);
@@ -1891,23 +1880,6 @@ err ppinit(const request *r, postproc *proc)
 			if(ret) return ret;
 		}
 
-#if 0
-		/* land-sea mask */
-		if(get_value(r,"LSM",0))
-		{
-			const char *lsm = no_quotes(get_value(r,"LSM",0));
-			marslog(LOG_DBUG,"Using LSM from '%s'",lsm);
-			ret  = ppin("islscp",n,array,lsm);
-			if(ret) return ret;
-		}
-		else
-		{
-			 marslog(LOG_DBUG,"Setting LSM to 'off'");	
-			 ret  = ppin("islscp",n,array,"off");
-			 if(ret) return ret;
-		}
-#endif
-
 		/* packing */
 		if(get_value(r,"PACKING",0))
 		{
@@ -1927,9 +1899,27 @@ err ppinit(const request *r, postproc *proc)
 			if(ret) return ret;
 		}
 
-		/* ppdata.estimate contains the number of point, we need 
-		the header and sizeof(fortint) bytes per value */
+		/* warnings for unsupported keywords */
+		{
+			static const char *warnings[] = {
+				"LSM_MODE",
+				"LSM_FILE_IN",
+				"LSM_FILE_OUT",
+				"LSM_WEIGHT",
+				"SPECTRAL_ORDER",
+				"SPECTRAL_GRID",
+				0
+			};
+
+			for (i = 0; warnings[i]; i++) {
+				if(get_value(r, warnings[i], 0)) {
+					marslog(LOG_WARN,"Ignoring unsupported keyword '%s'", warnings[i]);
+				}
+			}
+		}
 
+		/* ppdata.estimate contains the number of point, we need
+		the header and sizeof(fortint) bytes per value */
 		if(ppdata.estimate)
 			ppdata.estimate = ppdata.estimate * sizeof(fortint) + 4096;
 
diff --git a/src/libMarsClient/proto.h b/src/libMarsClient/proto.h
index e1d2897..30952ac 100644
--- a/src/libMarsClient/proto.h
+++ b/src/libMarsClient/proto.h
@@ -1,5 +1,5 @@
 /*
- * © Copyright 1996-2013 ECMWF.
+ * © Copyright 1996-2017 ECMWF.
  * 
  * This software is licensed under the terms of the Apache Licence Version 2.0
  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. 
@@ -695,8 +695,9 @@ err add_field(fieldset *v, field *g);
 err set_field(fieldset *v, field *g, int pos);
 err check_fieldset(fieldset *v, int expect);
 field *copy_field(field *gx, boolean copydata);
-void copy_bitmap(field *gc, field *ga, field *gb);
+void copy_missing_vals(field *gc, field *ga, field *gb);
 void remove_bitmap(field *gc);
+void set_bitmap(field *gc);
 fieldset *copy_fieldset(fieldset *x, int count, boolean copydata);
 fieldset *merge_fieldsets(fieldset *x, fieldset *y);
 fieldset *sub_fieldset(fieldset *v, int from, int to, int step);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/metview.git



More information about the debian-science-commits mailing list