mirror of https://github.com/ecmwf/eccodes.git
Compiler warnings and error with grib2ppm on reduced grids
This commit is contained in:
parent
886697912d
commit
399f7b4194
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include "tigge_tools.h"
|
||||
void validate(const char* path);
|
||||
|
||||
#define CHECK(a) check(#a,a)
|
||||
#define WARN(a) warn(#a,a)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
#include "grib_api.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define CMAP_MAX 20480
|
||||
|
||||
|
@ -69,7 +70,7 @@ int main(int argc, char *argv[])
|
|||
int centred = 0;
|
||||
unsigned r, g, b;
|
||||
int cmap_entries = 0;
|
||||
double min, max;
|
||||
double min0, max0;
|
||||
int j;
|
||||
char buf[1024];
|
||||
double lcap = -1e+100, ucap = 1e+100;
|
||||
|
@ -104,9 +105,9 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
while (next(f, buf))
|
||||
{
|
||||
min = atof(buf);
|
||||
min0 = atof(buf);
|
||||
next(f, buf);
|
||||
max = atof(buf);
|
||||
max0 = atof(buf);
|
||||
next(f, buf);
|
||||
r = atol(buf);
|
||||
next(f, buf);
|
||||
|
@ -118,8 +119,8 @@ int main(int argc, char *argv[])
|
|||
fprintf(stderr, "%s\n", "colour map is too large");
|
||||
exit(1);
|
||||
}
|
||||
cmap[cmap_entries].min = min;
|
||||
cmap[cmap_entries].max = max;
|
||||
cmap[cmap_entries].min = min0;
|
||||
cmap[cmap_entries].max = max0;
|
||||
cmap[cmap_entries].r = r;
|
||||
cmap[cmap_entries].g = g;
|
||||
cmap[cmap_entries].b = b;
|
||||
|
@ -150,8 +151,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
GRIB_CHECK(grib_get_size(h, "values", &count), 0);
|
||||
values = (double *)malloc(sizeof(double) * count);
|
||||
if (!values) { fprintf(stderr, "Failed to allocate memory for values\n"); exit(1); }
|
||||
indices = (unsigned long *)malloc(sizeof(unsigned long) * count);
|
||||
if (!indices) { fprintf(stderr, "Failed to allocate memory for indices\n"); exit(1); }
|
||||
|
||||
if (grib_is_missing(h, "Ni", &err)) {
|
||||
fprintf(stderr, "Key Ni cannot be missing. Reduced grids are not supported\n");
|
||||
exit(1);
|
||||
}
|
||||
GRIB_CHECK(grib_get_long(h, "Ni", &width), 0);
|
||||
GRIB_CHECK(grib_get_long(h, "Nj", &height), 0);
|
||||
GRIB_CHECK(grib_get_double_array(h, "values", values, &count), 0);
|
||||
|
@ -185,12 +192,13 @@ int main(int argc, char *argv[])
|
|||
/* assume first column in Greenwich meridian
|
||||
assume scanning mode
|
||||
*/
|
||||
int k = 0, j;
|
||||
for (j = 0; j < height; j++)
|
||||
int k = 0, jj;
|
||||
for (jj = 0; jj < height; jj++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
int m = (i + width / 2) % width + j * width;
|
||||
int m = (i + width / 2) % width + jj * width;
|
||||
assert(k<count);
|
||||
indices[k++] = m;
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +239,7 @@ int main(int argc, char *argv[])
|
|||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
unsigned long c;
|
||||
unsigned char h, l;
|
||||
unsigned char hh, l;
|
||||
double v = values[indices[i]];
|
||||
if (v < lcap)
|
||||
{
|
||||
|
@ -242,9 +250,9 @@ int main(int argc, char *argv[])
|
|||
v = ucap;
|
||||
}
|
||||
c = ( v - min) * 65535 / (max - min);
|
||||
h = c >> 8;
|
||||
hh = c >> 8;
|
||||
l = c & 0xff;
|
||||
printf("%c", h);
|
||||
printf("%c", hh);
|
||||
printf("%c", l);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,6 @@ static int blacklisted(const char* name)
|
|||
static double relative_error(double a,double b,double err)
|
||||
{
|
||||
double relativeError;
|
||||
double maxAbsoluteError = 1e-19;
|
||||
|
||||
if(fabs(a) <= maxAbsoluteError || fabs(b) <= maxAbsoluteError)
|
||||
relativeError = fabs(a-b);
|
||||
|
@ -176,7 +175,7 @@ grib_option grib_options[]={
|
|||
};
|
||||
|
||||
grib_handle* global_handle=NULL;
|
||||
int counter=0;
|
||||
int global_counter=0;
|
||||
int start=-1;
|
||||
int end=-1;
|
||||
|
||||
|
@ -245,7 +244,6 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
|
||||
if (grib_options_on("b:")) {
|
||||
grib_string_list *next=0;
|
||||
int i=0;
|
||||
blacklist=(grib_string_list*)grib_context_malloc_clear(context,sizeof(grib_string_list));
|
||||
blacklist->value=grib_context_strdup(context,options->set_values[0].name);
|
||||
next=blacklist;
|
||||
|
@ -376,10 +374,10 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
if (options->through_index) {
|
||||
grib_index* idx1=options->index1;
|
||||
verbose=0;
|
||||
counter++;
|
||||
global_counter++;
|
||||
|
||||
if ( start>0 && counter < start ) return 0;
|
||||
if ( end>0 && counter > end ) {
|
||||
if ( start>0 && global_counter < start ) return 0;
|
||||
if ( end>0 && global_counter > end ) {
|
||||
options->stop=1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -392,12 +390,12 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
printf("file1=\"%s\" ",filename);
|
||||
filename=grib_get_field_file(options->index1,&offset);
|
||||
printf("file2=\"%s\" \n",filename);
|
||||
print_index_key_values(options->index1,counter,NULL);
|
||||
print_index_key_values(options->index1,global_counter,NULL);
|
||||
}
|
||||
|
||||
if (!global_handle) {
|
||||
if (!options->verbose)
|
||||
print_index_key_values(idx1,counter,"NOT FOUND ");
|
||||
print_index_key_values(idx1,global_counter,"NOT FOUND ");
|
||||
}
|
||||
|
||||
if (!global_handle || err!= GRIB_SUCCESS ) {
|
||||
|
@ -742,7 +740,6 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
}
|
||||
if(err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1==len2)
|
||||
{
|
||||
int i;
|
||||
countdiff=0;
|
||||
for(i = 0; i < len1; i++)
|
||||
if(lval1[i] != lval2[i]) countdiff++;
|
||||
|
@ -836,7 +833,7 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
}
|
||||
if(err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1==len2)
|
||||
{
|
||||
int i,imaxdiff;
|
||||
int imaxdiff;
|
||||
double diff;
|
||||
double *pv1,*pv2,dnew1,dnew2;
|
||||
maxdiff=0;
|
||||
|
@ -932,7 +929,6 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
{
|
||||
if(memcmp(uval1,uval2,len1) != 0)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < len1; i++)
|
||||
if(uval1[i] != uval2[i])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue