mirror of https://github.com/ecmwf/eccodes.git
GRIB-588: compile grib_api with a C++ compiler
This commit is contained in:
parent
613d279799
commit
47fff95d0b
|
@ -55,7 +55,7 @@ int main(int argc, char** argv) {
|
|||
/* get the size of the values array*/
|
||||
GRIB_CHECK(grib_get_size(h,"values",&values_len),0);
|
||||
|
||||
values = malloc(values_len*sizeof(double));
|
||||
values = (double*)malloc(values_len*sizeof(double));
|
||||
|
||||
/* get data values*/
|
||||
GRIB_CHECK(grib_get_double_array(h,"values",values,&values_len),0);
|
||||
|
|
|
@ -72,7 +72,7 @@ int main(int argc, char** argv) {
|
|||
/* get the size of the values array*/
|
||||
GRIB_CHECK(grib_get_size(h,"values",&values_len),0);
|
||||
|
||||
values = malloc(values_len*sizeof(double));
|
||||
values = (double*)malloc(values_len*sizeof(double));
|
||||
|
||||
err = grib_get_double_array(h,"values",values,&values_len);
|
||||
|
||||
|
@ -98,7 +98,7 @@ int main(int argc, char** argv) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
values = malloc(values_len*sizeof(double));
|
||||
values = (double*)malloc(values_len*sizeof(double));
|
||||
err = grib_get_double_array(h,"values",values,&values_len);
|
||||
|
||||
/*
|
||||
|
|
|
@ -56,7 +56,7 @@ int main(int argc, char** argv) {
|
|||
/* get the size of the values array*/
|
||||
GRIB_CHECK(grib_get_size(h,"values",&values_len),0);
|
||||
|
||||
values = malloc(values_len*sizeof(double));
|
||||
values = (double*)malloc(values_len*sizeof(double));
|
||||
|
||||
/* get data values*/
|
||||
GRIB_CHECK(grib_get_double_array(h,"values",values,&values_len),0);
|
||||
|
|
|
@ -57,11 +57,11 @@ int main(int argc, char* argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
GRIB_CHECK(grib_get_size(h1,"values",&size1),0);
|
||||
v1=malloc(size1*sizeof(double));
|
||||
v1=(double*)malloc(size1*sizeof(double));
|
||||
if (!v1) {printf("unable to allocate v1\n");exit(1);}
|
||||
lat1=malloc(size1*sizeof(double));
|
||||
lat1=(double*)malloc(size1*sizeof(double));
|
||||
if (!lat1) {printf("unable to allocate lat1\n");exit(1);}
|
||||
lon1=malloc(size1*sizeof(double));
|
||||
lon1=(double*)malloc(size1*sizeof(double));
|
||||
if (!lon1) {printf("unable to allocate lon1\n");exit(1);}
|
||||
GRIB_CHECK(grib_get_double(h1,"packingError",&err1),0);
|
||||
|
||||
|
@ -69,11 +69,11 @@ int main(int argc, char* argv[]) {
|
|||
GRIB_CHECK(ret,0);
|
||||
|
||||
GRIB_CHECK(grib_get_size(h2,"values",&size2),0);
|
||||
v2=malloc(size2*sizeof(double));
|
||||
v2=(double*)malloc(size2*sizeof(double));
|
||||
if (!v2) {printf("unable to allocate v2\n");exit(1);}
|
||||
lat2=malloc(size2*sizeof(double));
|
||||
lat2=(double*)malloc(size2*sizeof(double));
|
||||
if (!lat2) {printf("unable to allocate lat2\n");exit(1);}
|
||||
lon2=malloc(size2*sizeof(double));
|
||||
lon2=(double*)malloc(size2*sizeof(double));
|
||||
if (!lon2) {printf("unable to allocate lon2\n");exit(1);}
|
||||
GRIB_CHECK(grib_get_double(h2,"packingError",&err2),0);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ int main(int argc,char* argv[])
|
|||
|
||||
/* get the number of distinct values of "step" in the index */
|
||||
GRIB_CHECK(grib_index_get_size(index,"step",&stepSize),0);
|
||||
step=malloc(sizeof(long)*stepSize);
|
||||
step=(long*)malloc(sizeof(long)*stepSize);
|
||||
if (!step) exit(1);
|
||||
/* get the list of distinct steps from the index */
|
||||
/* the list is in ascending order */
|
||||
|
@ -58,7 +58,7 @@ int main(int argc,char* argv[])
|
|||
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_size(index,"level",&levelSize),0);
|
||||
level=malloc(sizeof(long)*levelSize);
|
||||
level=(long*)malloc(sizeof(long)*levelSize);
|
||||
if (!level) exit(1);
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_long(index,"level",level,&levelSize),0);
|
||||
|
@ -68,7 +68,7 @@ int main(int argc,char* argv[])
|
|||
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_size(index,"number",&numberSize),0);
|
||||
number=malloc(sizeof(long)*numberSize);
|
||||
number=(long*)malloc(sizeof(long)*numberSize);
|
||||
if (!number) exit(1);
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_long(index,"number",number,&numberSize),0);
|
||||
|
|
|
@ -23,60 +23,59 @@
|
|||
void usage(char* prog) {printf("usage: %s [-m] file.grib\n",prog);exit(1);}
|
||||
|
||||
int main(int argc,char* argv[]) {
|
||||
struct stat finfo;
|
||||
char shortName[20]={0,};
|
||||
size_t len=20;
|
||||
grib_handle* h=NULL;
|
||||
size_t fsize;
|
||||
unsigned char* data=NULL;
|
||||
unsigned char* p=NULL;
|
||||
void* pdata=NULL;
|
||||
int error=0;
|
||||
int count=0;
|
||||
char* filename=NULL;
|
||||
FILE* f=NULL;
|
||||
long level=0;
|
||||
grib_context* c=grib_context_get_default();
|
||||
struct stat finfo;
|
||||
char shortName[20]={0,};
|
||||
size_t len=20;
|
||||
grib_handle* h=NULL;
|
||||
size_t fsize;
|
||||
unsigned char* data=NULL;
|
||||
unsigned char* p=NULL;
|
||||
void* pdata=NULL;
|
||||
int error=0;
|
||||
int count=0;
|
||||
char* filename=NULL;
|
||||
FILE* f=NULL;
|
||||
long level=0;
|
||||
grib_context* c=grib_context_get_default();
|
||||
|
||||
if (argc==3 && !strcmp(argv[1],"-m")) {
|
||||
grib_multi_support_on(0);
|
||||
filename=argv[2];
|
||||
}
|
||||
else if (argc==2) filename=argv[1];
|
||||
else usage(argv[0]);
|
||||
if (argc==3 && !strcmp(argv[1],"-m")) {
|
||||
grib_multi_support_on(0);
|
||||
filename=argv[2];
|
||||
}
|
||||
else if (argc==2) filename=argv[1];
|
||||
else usage(argv[0]);
|
||||
|
||||
f=fopen(filename,"r");
|
||||
if (!f) {perror(filename);exit(1);}
|
||||
f=fopen(filename,"r");
|
||||
if (!f) {perror(filename);exit(1);}
|
||||
|
||||
fstat(fileno((FILE*)f),&finfo);
|
||||
fsize=finfo.st_size;
|
||||
fstat(fileno((FILE*)f),&finfo);
|
||||
fsize=finfo.st_size;
|
||||
|
||||
data=(unsigned char*)malloc(fsize);
|
||||
p=data;
|
||||
data=(unsigned char*)malloc(fsize);
|
||||
p=data;
|
||||
|
||||
if (!data) {
|
||||
fprintf(stderr,"unable to allocate %ld bytes\n",(long)fsize);
|
||||
exit(1);
|
||||
}
|
||||
if (!data) {
|
||||
fprintf(stderr,"unable to allocate %ld bytes\n",(long)fsize);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if( fread(data, 1, fsize, f) != fsize) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
fclose(f);
|
||||
pdata=&data;
|
||||
|
||||
if( fread(data, 1, fsize, f) != fsize) {
|
||||
perror(filename);
|
||||
exit(1);
|
||||
}
|
||||
fclose(f);
|
||||
pdata=&data;
|
||||
while ((h=grib_handle_new_from_multi_message(c,(void**)pdata,&fsize,&error))!=NULL) {
|
||||
count++;
|
||||
len=20;
|
||||
GRIB_CHECK(grib_get_string(h,"shortName",shortName,&len),"shortName");
|
||||
GRIB_CHECK(grib_get_long(h,"level",&level),"level");
|
||||
printf("%d %s %ld\n",count,shortName,level);
|
||||
grib_handle_delete(h);
|
||||
}
|
||||
|
||||
while ((h=grib_handle_new_from_multi_message(c,pdata,&fsize,&error))!=NULL) {
|
||||
count++;
|
||||
len=20;
|
||||
GRIB_CHECK(grib_get_string(h,"shortName",shortName,&len),"shortName");
|
||||
GRIB_CHECK(grib_get_long(h,"level",&level),"level");
|
||||
printf("%d %s %ld\n",count,shortName,level);
|
||||
grib_handle_delete(h);
|
||||
}
|
||||
free(p);
|
||||
|
||||
free(p);
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int main(int argc,char* argv[]) {
|
|||
|
||||
/* get the number of distinct values of "step" in the index */
|
||||
GRIB_CHECK(grib_index_get_size(index,"step",&stepSize),0);
|
||||
step=malloc(sizeof(long)*stepSize);
|
||||
step=(long*)malloc(sizeof(long)*stepSize);
|
||||
if (!step) exit(1);
|
||||
/* get the list of distinct steps from the index */
|
||||
/* the list is in ascending order */
|
||||
|
@ -54,7 +54,7 @@ int main(int argc,char* argv[]) {
|
|||
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_size(index,"level",&levelSize),0);
|
||||
level=malloc(sizeof(long)*levelSize);
|
||||
level=(long*)malloc(sizeof(long)*levelSize);
|
||||
if (!level) exit(1);
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_long(index,"level",level,&levelSize),0);
|
||||
|
@ -64,7 +64,7 @@ int main(int argc,char* argv[]) {
|
|||
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_size(index,"number",&numberSize),0);
|
||||
number=malloc(sizeof(long)*numberSize);
|
||||
number=(long*)malloc(sizeof(long)*numberSize);
|
||||
if (!number) exit(1);
|
||||
/*same as for "step"*/
|
||||
GRIB_CHECK(grib_index_get_long(index,"number",number,&numberSize),0);
|
||||
|
|
|
@ -60,11 +60,11 @@ int main(int argc, char* argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
GRIB_CHECK(grib_get_size(h1,"values",&size1),0);
|
||||
v1=malloc(size1*sizeof(double));
|
||||
v1=(double*)malloc(size1*sizeof(double));
|
||||
if (!v1) {printf("unable to allocate v1\n");exit(1);}
|
||||
lat1=malloc(size1*sizeof(double));
|
||||
lat1=(double*)malloc(size1*sizeof(double));
|
||||
if (!lat1) {printf("unable to allocate lat1\n");exit(1);}
|
||||
lon1=malloc(size1*sizeof(double));
|
||||
lon1=(double*)malloc(size1*sizeof(double));
|
||||
if (!lon1) {printf("unable to allocate lon1\n");exit(1);}
|
||||
GRIB_CHECK(grib_get_double(h1,"packingError",&err1),0);
|
||||
|
||||
|
@ -72,11 +72,11 @@ int main(int argc, char* argv[]) {
|
|||
GRIB_CHECK(ret,0);
|
||||
|
||||
GRIB_CHECK(grib_get_size(h2,"values",&size2),0);
|
||||
v2=malloc(size2*sizeof(double));
|
||||
v2=(double*)malloc(size2*sizeof(double));
|
||||
if (!v2) {printf("unable to allocate v2\n");exit(1);}
|
||||
lat2=malloc(size2*sizeof(double));
|
||||
lat2=(double*)malloc(size2*sizeof(double));
|
||||
if (!lat2) {printf("unable to allocate lat2\n");exit(1);}
|
||||
lon2=malloc(size2*sizeof(double));
|
||||
lon2=(double*)malloc(size2*sizeof(double));
|
||||
if (!lon2) {printf("unable to allocate lon2\n");exit(1);}
|
||||
GRIB_CHECK(grib_get_double(h2,"packingError",&err2),0);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ void usage(char* progname) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
extern int errno;
|
||||
/*extern int errno;*/
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int err=0,count=0,ret1=0,ret2=0;
|
||||
|
|
|
@ -206,11 +206,11 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
if (grib_options_on("b:")) {
|
||||
grib_string_list *next=0;
|
||||
int i=0;
|
||||
blacklist=grib_context_malloc_clear(context,sizeof(grib_string_list));
|
||||
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;
|
||||
for (i=1;i<options->set_values_count;i++) {
|
||||
next->next=grib_context_malloc_clear(context,sizeof(grib_string_list));
|
||||
next->next=(grib_string_list*)grib_context_malloc_clear(context,sizeof(grib_string_list));
|
||||
next->next->value=grib_context_strdup(context,options->set_values[i].name);
|
||||
next=next->next;
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ static void save_error(grib_context* c,const char* key)
|
|||
int saved=0;
|
||||
|
||||
if (!error_summary) {
|
||||
error_summary=grib_context_malloc_clear(c,sizeof(grib_error));
|
||||
error_summary=(grib_error*)grib_context_malloc_clear(c,sizeof(grib_error));
|
||||
error_summary->count=1;
|
||||
error_summary->key=grib_context_strdup(c,key);
|
||||
return;
|
||||
|
@ -507,7 +507,7 @@ static void save_error(grib_context* c,const char* key)
|
|||
}
|
||||
|
||||
if (!saved) {
|
||||
e->next=grib_context_malloc_clear(c,sizeof(grib_error));
|
||||
e->next=(grib_error*)grib_context_malloc_clear(c,sizeof(grib_error));
|
||||
e->next->count=1;
|
||||
e->next->key=grib_context_strdup(c,key);
|
||||
}
|
||||
|
@ -645,8 +645,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
if (verbose) printf(" as string\n");
|
||||
grib_get_string_length(h1,name,&len1);
|
||||
grib_get_string_length(h2,name,&len2);
|
||||
sval1 = grib_context_malloc(h1->context,len1*sizeof(char));
|
||||
sval2 = grib_context_malloc(h2->context,len2*sizeof(char));
|
||||
sval1 = (char*)grib_context_malloc(h1->context,len1*sizeof(char));
|
||||
sval2 = (char*)grib_context_malloc(h2->context,len2*sizeof(char));
|
||||
|
||||
if((err1 = grib_get_string(h1,name,sval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
@ -687,8 +687,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
case GRIB_TYPE_LONG:
|
||||
if (verbose) printf(" as long\n");
|
||||
|
||||
lval1 = grib_context_malloc(h1->context,len1*sizeof(long));
|
||||
lval2 = grib_context_malloc(h2->context,len2*sizeof(long));
|
||||
lval1 = (long*)grib_context_malloc(h1->context,len1*sizeof(long));
|
||||
lval2 = (long*)grib_context_malloc(h2->context,len2*sizeof(long));
|
||||
|
||||
if((err1 = grib_get_long_array(h1,name,lval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
@ -742,8 +742,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
|
||||
case GRIB_TYPE_DOUBLE:
|
||||
if (verbose) printf(" as double");
|
||||
dval1 = grib_context_malloc(h1->context,len1*sizeof(double));
|
||||
dval2 = grib_context_malloc(h2->context,len2*sizeof(double));
|
||||
dval1 = (double*)grib_context_malloc(h1->context,len1*sizeof(double));
|
||||
dval2 = (double*)grib_context_malloc(h2->context,len2*sizeof(double));
|
||||
|
||||
isangle=0;
|
||||
value_tolerance=global_tolerance;
|
||||
|
@ -884,8 +884,8 @@ static int compare_values(grib_runtime_options* options,grib_handle* h1,grib_han
|
|||
if (verbose) printf(" as bytes\n");
|
||||
if (len1<2) len1=512;
|
||||
if (len2<2) len2=512;
|
||||
uval1 = grib_context_malloc(h1->context,len1*sizeof(unsigned char));
|
||||
uval2 = grib_context_malloc(h2->context,len2*sizeof(unsigned char));
|
||||
uval1 = (unsigned char*)grib_context_malloc(h1->context,len1*sizeof(unsigned char));
|
||||
uval2 = (unsigned char*)grib_context_malloc(h2->context,len2*sizeof(unsigned char));
|
||||
|
||||
if((err1 = grib_get_bytes(h1,name,uval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
|
|
@ -122,8 +122,8 @@ static int compare_values(grib_handle* h1,grib_handle *h2,const char *name)
|
|||
{
|
||||
case GRIB_TYPE_STRING:
|
||||
|
||||
sval1 = grib_context_malloc(h1->context,len1*sizeof(char));
|
||||
sval2 = grib_context_malloc(h2->context,len2*sizeof(char));
|
||||
sval1 = (char*)grib_context_malloc(h1->context,len1*sizeof(char));
|
||||
sval2 = (char*)grib_context_malloc(h2->context,len2*sizeof(char));
|
||||
|
||||
if((err1 = grib_get_string(h1,name,sval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
@ -157,8 +157,8 @@ static int compare_values(grib_handle* h1,grib_handle *h2,const char *name)
|
|||
|
||||
case GRIB_TYPE_LONG:
|
||||
|
||||
lval1 = grib_context_malloc(h1->context,len1*sizeof(long));
|
||||
lval2 = grib_context_malloc(h2->context,len2*sizeof(long));
|
||||
lval1 = (long*)grib_context_malloc(h1->context,len1*sizeof(long));
|
||||
lval2 = (long*)grib_context_malloc(h2->context,len2*sizeof(long));
|
||||
|
||||
if((err1 = grib_get_long_array(h1,name,lval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
@ -198,8 +198,8 @@ static int compare_values(grib_handle* h1,grib_handle *h2,const char *name)
|
|||
break;
|
||||
|
||||
case GRIB_TYPE_DOUBLE:
|
||||
dval1 = grib_context_malloc(h1->context,len1*sizeof(double));
|
||||
dval2 = grib_context_malloc(h2->context,len2*sizeof(double));
|
||||
dval1 = (double*)grib_context_malloc(h1->context,len1*sizeof(double));
|
||||
dval2 = (double*)grib_context_malloc(h2->context,len2*sizeof(double));
|
||||
|
||||
if((err1 = grib_get_double_array(h1,name,dval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
@ -240,8 +240,8 @@ static int compare_values(grib_handle* h1,grib_handle *h2,const char *name)
|
|||
|
||||
case GRIB_TYPE_BYTES:
|
||||
|
||||
uval1 = grib_context_malloc(h1->context,len1*sizeof(unsigned char));
|
||||
uval2 = grib_context_malloc(h2->context,len2*sizeof(unsigned char));
|
||||
uval1 = (unsigned char*)grib_context_malloc(h1->context,len1*sizeof(unsigned char));
|
||||
uval2 = (unsigned char*)grib_context_malloc(h2->context,len2*sizeof(unsigned char));
|
||||
|
||||
if((err1 = grib_get_bytes(h1,name,uval1,&len1)) != GRIB_SUCCESS)
|
||||
{
|
||||
|
|
|
@ -95,10 +95,10 @@ static void compare_handles(int n,grib_handle* h1,grib_handle* h2,FILE* out)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
dval1 = grib_context_malloc(h1->context,len1*sizeof(double)); Assert(dval1);
|
||||
dval2 = grib_context_malloc(h2->context,len2*sizeof(double)); Assert(dval2);
|
||||
dval1 = (double*)grib_context_malloc(h1->context,len1*sizeof(double)); Assert(dval1);
|
||||
dval2 = (double*)grib_context_malloc(h2->context,len2*sizeof(double)); Assert(dval2);
|
||||
if(out)
|
||||
dval3 = grib_context_malloc(h2->context,len2*sizeof(double)); Assert(dval2);
|
||||
dval3 = (double*)grib_context_malloc(h2->context,len2*sizeof(double)); Assert(dval2);
|
||||
|
||||
GRIB_CHECK(grib_get_double_array(h1,"values",dval1,&len1),NULL);
|
||||
GRIB_CHECK(grib_get_double_array(h2,"values",dval2,&len2),NULL);
|
||||
|
|
|
@ -72,7 +72,7 @@ int grib_tool_new_file_action(grib_runtime_options* options,grib_tools_file* fil
|
|||
int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
||||
{
|
||||
int err=0;
|
||||
|
||||
|
||||
int skip_missing=1;
|
||||
char *missing_string=NULL;
|
||||
int i=0;
|
||||
|
@ -132,10 +132,10 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
|||
if (bitmapPresent)
|
||||
{
|
||||
GRIB_CHECK(grib_get_size(h,"bitmap",&bmp_len),0);
|
||||
bitmap = malloc(bmp_len*sizeof(long));
|
||||
bitmap = (long*)malloc(bmp_len*sizeof(long));
|
||||
GRIB_CHECK(grib_get_long_array(h,"bitmap",bitmap,&bmp_len),0);
|
||||
}
|
||||
|
||||
|
||||
skip_missing=1;
|
||||
if (grib_options_on("m:")) {
|
||||
/* User wants to see missing values */
|
||||
|
|
|
@ -67,13 +67,13 @@ int main(int argc, char* argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
m1=grib_context_malloc_clear(c,sizeof(double)*order*order);
|
||||
m2=grib_context_malloc_clear(c,sizeof(double)*order*order);
|
||||
dm=grib_context_malloc_clear(c,sizeof(double)*order*order);
|
||||
east=grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
south=grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
north=grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
west=grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
m1=(double*)grib_context_malloc_clear(c,sizeof(double)*order*order);
|
||||
m2=(double*)grib_context_malloc_clear(c,sizeof(double)*order*order);
|
||||
dm=(double*)grib_context_malloc_clear(c,sizeof(double)*order*order);
|
||||
east=(double*)grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
south=(double*)grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
north=(double*)grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
west=(double*)grib_context_malloc_clear(c,sizeof(double)*split);
|
||||
|
||||
count=0;
|
||||
while ((h1=grib_handle_new_from_file(0,f1,&ret))!=NULL && (h2=grib_handle_new_from_file(0,f2,&ret))!=NULL) {
|
||||
|
|
|
@ -36,7 +36,7 @@ double unpack(unsigned long v,double ref,long bscale,long dscale)
|
|||
return (v*b+ref)*d;
|
||||
}
|
||||
|
||||
void try(const char* txt,double v,double ref,long bscale,long dscale)
|
||||
void try_this(const char* txt,double v,double ref,long bscale,long dscale)
|
||||
{
|
||||
double x;
|
||||
if(txt) printf("%-18s : ",txt);
|
||||
|
@ -134,11 +134,11 @@ int main(int argc, char *argv[])
|
|||
printf("\n");
|
||||
printf("Packing/unpacking :\n");
|
||||
printf("\n");
|
||||
try("Minimum",min,ref,bscale,dscale);
|
||||
try("Maximum",max,ref,bscale,dscale);
|
||||
try_this("Minimum",min,ref,bscale,dscale);
|
||||
try_this("Maximum",max,ref,bscale,dscale);
|
||||
|
||||
for(;optind < argc; optind++)
|
||||
try(argv[optind],atof(argv[optind]),ref,bscale,dscale);
|
||||
try_this(argv[optind],atof(argv[optind]),ref,bscale,dscale);
|
||||
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -129,7 +129,7 @@ int main(int argc, char *argv[])
|
|||
/*========== data *============*/
|
||||
size=0;
|
||||
GRIB_CHECK(grib_get_size(h,"values",&size),0);
|
||||
values = malloc(sizeof(double)*size);
|
||||
values = (double*)malloc(sizeof(double)*size);
|
||||
|
||||
if (!values) {
|
||||
fprintf(stderr,"%s: out of memory\n", argv[0]);
|
||||
|
|
|
@ -44,8 +44,8 @@ typedef int boolean;
|
|||
typedef int err;
|
||||
typedef off_t file_offset;
|
||||
|
||||
static int false = 0;
|
||||
static int true = 1;
|
||||
static int FALSE = 0;
|
||||
static int TRUE = 1;
|
||||
|
||||
static int files = 0;
|
||||
|
||||
|
@ -80,59 +80,59 @@ static boolean eq_string(const char *l, const char *r)
|
|||
{
|
||||
if(l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean eq_integer(const char *l, const char *r)
|
||||
{
|
||||
if(l && r)
|
||||
return atol(l) == atol(r);
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean eq_null(const char *l, const char *r)
|
||||
{
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static boolean eq_coord(const char *l, const char *r)
|
||||
{
|
||||
if(l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean eq_range(const char *l, const char *r)
|
||||
{
|
||||
if(l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean eq_date(const char *l, const char *r)
|
||||
{
|
||||
if(l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean eq_param(const char *l, const char *r)
|
||||
{
|
||||
if(l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static boolean eq_time(const char *l, const char *r)
|
||||
{
|
||||
if(l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static value *new_value(const char *name)
|
||||
{
|
||||
value *v = calloc(sizeof(value), 1);
|
||||
value *v = (value*)calloc(sizeof(value), 1);
|
||||
Assert(v);
|
||||
v->name = grib_context_strdup(ctx, name);
|
||||
return v;
|
||||
|
@ -167,13 +167,13 @@ static void _reqmerge(parameter *pa, const parameter *pb, request *a)
|
|||
value *va = pa->values;
|
||||
value *last = 0;
|
||||
const char *nb = vb->name;
|
||||
boolean add = true;
|
||||
boolean add = TRUE;
|
||||
|
||||
while(va)
|
||||
{
|
||||
if(strcmp(va->name, nb) == 0)
|
||||
{
|
||||
add = false;
|
||||
add = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ static boolean _reqmerge1(request *a, const request *b)
|
|||
while(pa && pb)
|
||||
{
|
||||
if(strcmp(pa->name, pb->name) != 0)
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
_reqmerge(pa, pb, a);
|
||||
|
||||
|
@ -253,7 +253,7 @@ static boolean is_number(const char *name)
|
|||
int x, n;
|
||||
|
||||
if(p == 0 || *p == 0)
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
if(*p == '-')
|
||||
p++;
|
||||
|
@ -262,7 +262,7 @@ static boolean is_number(const char *name)
|
|||
|
||||
p = parse1(p, &x, &n);
|
||||
if(n == 0 && *p != '.')
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
if(*p == '.')
|
||||
{
|
||||
|
@ -279,14 +279,14 @@ static boolean is_number(const char *name)
|
|||
p++;
|
||||
p = parse1(p, &x, &n);
|
||||
if(n == 0)
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return *p == 0 ? true : false;
|
||||
return *p == 0 ? TRUE : FALSE;
|
||||
}
|
||||
static parameter *new_parameter(char *name, value *v)
|
||||
{
|
||||
parameter *p = calloc(sizeof(parameter), 1);
|
||||
parameter *p = (parameter*)calloc(sizeof(parameter), 1);
|
||||
Assert(p);
|
||||
p->name = grib_context_strdup(ctx, name);
|
||||
p->values = v;
|
||||
|
@ -411,7 +411,7 @@ static void add_value(request *r, const char *parname, const char *fmt, ...)
|
|||
vsprintf(buffer, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
put_value(r, parname, buffer, true, false, false);
|
||||
put_value(r, parname, buffer, TRUE, FALSE, FALSE);
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ static void _reqmerge2(request *a, const request *b)
|
|||
value *v = pb->values;
|
||||
while(v)
|
||||
{
|
||||
put_value(a, pb->name, v->name, true, true, false);
|
||||
put_value(a, pb->name, v->name, TRUE, TRUE, FALSE);
|
||||
v = v->next;
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ static void set_value(request *r, const char *parname, const char *fmt, ...)
|
|||
vsprintf(buffer, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
put_value(r, parname, buffer, false, false, false);
|
||||
put_value(r, parname, buffer, FALSE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
static err handle_to_request(request *r, grib_handle* g)
|
||||
|
@ -753,7 +753,7 @@ static int _cube_position(const hypercube *h, const request *r, boolean remove_h
|
|||
|
||||
static value *clone_one_value(const value *p)
|
||||
{
|
||||
value *q = calloc(sizeof(value), 1);
|
||||
value *q = (value*)calloc(sizeof(value), 1);
|
||||
Assert(q);
|
||||
q->next = NULL;
|
||||
q->name = grib_context_strdup(ctx, p->name);
|
||||
|
@ -774,7 +774,7 @@ static value *clone_all_values(const value *p)
|
|||
|
||||
static parameter *clone_one_parameter(const parameter *p)
|
||||
{
|
||||
parameter *q = calloc(sizeof(parameter), 1);
|
||||
parameter *q = (parameter*)calloc(sizeof(parameter), 1);
|
||||
Assert(q);
|
||||
q->next = NULL;
|
||||
q->name = grib_context_strdup(ctx, p->name);
|
||||
|
@ -797,7 +797,7 @@ static request *clone_one_request(const request *r)
|
|||
{
|
||||
if(r)
|
||||
{
|
||||
request *p = calloc(sizeof(request), 1);
|
||||
request *p = (request*)calloc(sizeof(request), 1);
|
||||
Assert(p);
|
||||
p->name = grib_context_strdup(ctx, r->name);
|
||||
|
||||
|
@ -810,7 +810,7 @@ static request *clone_one_request(const request *r)
|
|||
|
||||
static request *new_request(const char *name, parameter *p)
|
||||
{
|
||||
request *r = calloc(sizeof(request), 1);
|
||||
request *r = (request *)calloc(sizeof(request), 1);
|
||||
Assert(r);
|
||||
r->name = grib_context_strdup(ctx, name);
|
||||
r->params = p;
|
||||
|
@ -824,7 +824,7 @@ static request *empty_request(const char *name)
|
|||
|
||||
static field_request* new_field_request(request *r)
|
||||
{
|
||||
field_request* g = grib_context_malloc_clear(ctx, sizeof(field_request));
|
||||
field_request* g = (field_request*)grib_context_malloc_clear(ctx, sizeof(field_request));
|
||||
g->r = clone_one_request(r);
|
||||
return g;
|
||||
}
|
||||
|
@ -877,7 +877,7 @@ static void free_fieldset(fieldset *v)
|
|||
|
||||
static field *new_field()
|
||||
{
|
||||
return grib_context_malloc_clear(ctx, sizeof(field));
|
||||
return (field*)grib_context_malloc_clear(ctx, sizeof(field));
|
||||
}
|
||||
|
||||
#define INIT_SIZE 1024
|
||||
|
@ -922,7 +922,7 @@ static void grow_fieldset(fieldset *v, int n)
|
|||
|
||||
static fieldset *new_fieldset(int n)
|
||||
{
|
||||
fieldset *f = calloc(sizeof(fieldset), 1);
|
||||
fieldset *f = (fieldset*)calloc(sizeof(fieldset), 1);
|
||||
Assert(f);
|
||||
grow_fieldset(f, n);
|
||||
return f;
|
||||
|
@ -1287,7 +1287,7 @@ static namecmp comparator(const char *name)
|
|||
if(first)
|
||||
{
|
||||
dontcompare = getenv("MARS_DONT_CHECK");
|
||||
first = false;
|
||||
first = FALSE;
|
||||
}
|
||||
|
||||
if(dontcompare != NULL)
|
||||
|
@ -1344,7 +1344,7 @@ static void set_index(hypercube *h, int index, int value)
|
|||
while(index >= h->max)
|
||||
h->max += 4096;
|
||||
|
||||
h->set = h->set ? grib_context_realloc(ctx, h->set, h->max) : grib_context_malloc(ctx, h->max);
|
||||
h->set = h->set ? (char*)grib_context_realloc(ctx, h->set, h->max) : (char*)grib_context_malloc(ctx, h->max);
|
||||
Assert(h->set);
|
||||
memset(h->set + old, 0, h->max - old);
|
||||
}
|
||||
|
@ -1419,12 +1419,12 @@ static void valcpy(request *a, request *b, char *aname, char *bname)
|
|||
parameter *p;
|
||||
if(a && b && (p = find_parameter(b, bname)))
|
||||
{
|
||||
boolean z = false;
|
||||
boolean z = FALSE;
|
||||
value *v = p->values;
|
||||
while(v)
|
||||
{
|
||||
put_value(a, aname, v->name, z, false, false);
|
||||
z = true;
|
||||
put_value(a, aname, v->name, z, FALSE, FALSE);
|
||||
z = TRUE;
|
||||
v = v->next;
|
||||
}
|
||||
}
|
||||
|
@ -1495,12 +1495,12 @@ static int count_hypercube(const request *r)
|
|||
|
||||
static int cube_order(const hypercube *h, const request *r)
|
||||
{
|
||||
return _cube_position(h, r, true);
|
||||
return _cube_position(h, r, TRUE);
|
||||
}
|
||||
|
||||
static int cube_position(const hypercube *h, const request *r)
|
||||
{
|
||||
return _cube_position(h, r, false);
|
||||
return _cube_position(h, r, FALSE);
|
||||
}
|
||||
|
||||
static void reserve_index_cache(hypercube *h, int size)
|
||||
|
@ -1511,7 +1511,7 @@ static void reserve_index_cache(hypercube *h, int size)
|
|||
if(h->index_cache != 0)
|
||||
grib_context_free(ctx, h->index_cache);
|
||||
grib_context_log(ctx, GRIB_LOG_DEBUG, "grib_to_netcdf: Allocating hypercube index_cache: %d entries", size);
|
||||
h->index_cache = calloc(sizeof(int), size);
|
||||
h->index_cache = (int*)calloc(sizeof(int), size);
|
||||
Assert(h->index_cache);
|
||||
h->index_cache_size = size;
|
||||
}
|
||||
|
@ -1728,7 +1728,7 @@ static hypercube *new_hypercube_from_mars_request(const request *r)
|
|||
|
||||
n = count_values(s.c->cube, "axis");
|
||||
if(n)
|
||||
s.c->compare = calloc(sizeof(namecmp), n);
|
||||
s.c->compare = (namecmp*)calloc(sizeof(namecmp), n);
|
||||
|
||||
for(i = 0; i < n; i++)
|
||||
s.c->compare[i] = comparator(get_value(s.c->cube, "axis", i));
|
||||
|
@ -1753,7 +1753,7 @@ static hypercube *new_simple_hypercube_from_mars_request(const request *r)
|
|||
free_one_request(s.r);
|
||||
n = count_values(s.c->cube, "axis");
|
||||
if(n)
|
||||
s.c->compare = calloc(sizeof(namecmp), n);
|
||||
s.c->compare = (namecmp*)calloc(sizeof(namecmp), n);
|
||||
|
||||
for(i = 0; i < n; i++)
|
||||
s.c->compare[i] = comparator(get_value(s.c->cube, "axis", i));
|
||||
|
@ -1798,7 +1798,7 @@ typedef struct filter {
|
|||
double missing;
|
||||
boolean bitmap;
|
||||
ncatt_t att;
|
||||
request *request;
|
||||
request *filter_request;
|
||||
boolean scale;
|
||||
} dataset_t;
|
||||
|
||||
|
@ -1957,9 +1957,9 @@ static void validation_time(request *r)
|
|||
{
|
||||
if(setup.usevalidtime)
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "Climatology data. Setting usevalidtime=OFF");
|
||||
setup.auto_refdate = false;
|
||||
setup.usevalidtime = false;
|
||||
setup.climatology = true;
|
||||
setup.auto_refdate = FALSE;
|
||||
setup.usevalidtime = FALSE;
|
||||
setup.climatology = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2017,9 +2017,9 @@ static void get_nc_options(const request *user_r)
|
|||
const char *history = get_value(user_r, "history", 0);
|
||||
const char *unlimited = get_value(user_r, "unlimited", 0);
|
||||
|
||||
setup.usevalidtime = validtime ? (strcmp(validtime, "true") == 0) : false;
|
||||
setup.usevalidtime = validtime ? (strcmp(validtime, "true") == 0) : FALSE;
|
||||
setup.refdate = refdate ? atol(refdate) : 19000101;
|
||||
setup.auto_refdate = refdate ? (strcmp(get_value(user_r, "referencedate", 0), "AUTOMATIC") == 0) : false;
|
||||
setup.auto_refdate = refdate ? (strcmp(get_value(user_r, "referencedate", 0), "AUTOMATIC") == 0) : FALSE;
|
||||
|
||||
setup.title = title ? grib_context_strdup(ctx, (title)) : NULL;
|
||||
setup.history = history ? grib_context_strdup(ctx, (history)) : NULL;
|
||||
|
@ -2308,7 +2308,7 @@ static int compute_scale(dataset_t *subset)
|
|||
|
||||
if(g->bitmap)
|
||||
{
|
||||
subset->bitmap = true;
|
||||
subset->bitmap = TRUE;
|
||||
for(j = 0; j < len; ++j)
|
||||
{
|
||||
if(vals[j] != (double) missing_value)
|
||||
|
@ -2753,7 +2753,7 @@ static void set_always_a_time(hypercube *h, request *data_r)
|
|||
int n = count_values(h->cube, "axis");
|
||||
if(n)
|
||||
{
|
||||
h->compare = calloc(sizeof(namecmp), n);
|
||||
h->compare = (namecmp*)calloc(sizeof(namecmp), n);
|
||||
Assert(h->compare);
|
||||
}
|
||||
|
||||
|
@ -3192,7 +3192,7 @@ static void find_nc_attributes(const request *subset_r, const request *user_r, n
|
|||
{
|
||||
const char *split = NULL;
|
||||
int j = 0;
|
||||
boolean set_param_as_name = true;
|
||||
boolean set_param_as_name = TRUE;
|
||||
long datatable = 0; /* = atol(get_value(data_r,"_CODETABLE2",0)); */
|
||||
|
||||
if(count_values(user_r, "split") == 0)
|
||||
|
@ -3203,14 +3203,14 @@ static void find_nc_attributes(const request *subset_r, const request *user_r, n
|
|||
if(strcmp(split, "param") != 0)
|
||||
{
|
||||
if(count_values(data_r, split) > 1)
|
||||
set_param_as_name = false;
|
||||
set_param_as_name = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while((split = get_value(user_r, "split", j++)) != NULL)
|
||||
{
|
||||
boolean found = false;
|
||||
boolean found = FALSE;
|
||||
request *cfg = (request *) config_r;
|
||||
boolean is_param = strcmp(split, "param") == 0;
|
||||
/* Only use this parameter in the name if there is more
|
||||
|
@ -3233,7 +3233,7 @@ static void find_nc_attributes(const request *subset_r, const request *user_r, n
|
|||
|
||||
long cfgparam = atol(cfgval);
|
||||
long dataparam = atol(dataval);
|
||||
paramtable(dataval, &dataparam, &datatable, false);
|
||||
paramtable(dataval, &dataparam, &datatable, FALSE);
|
||||
|
||||
/* If it is not param and they're EXACTLY equal or
|
||||
being param, they're the same parameter and table */
|
||||
|
@ -3269,7 +3269,7 @@ static void find_nc_attributes(const request *subset_r, const request *user_r, n
|
|||
strcat(att->name, "_");
|
||||
strcat(att->name, pname);
|
||||
}
|
||||
found = true;
|
||||
found = TRUE;
|
||||
|
||||
grib_context_log(ctx, GRIB_LOG_DEBUG, "grib_to_netcdf: Var. name found: '%s'", att->name);
|
||||
}
|
||||
|
@ -3318,7 +3318,7 @@ static void reqcb(const request *r, int count, axis_t *names, char *vals[], void
|
|||
{
|
||||
|
||||
if(vals[i])
|
||||
put_value(w, names[i].name, vals[i], false, false, false);
|
||||
put_value(w, names[i].name, vals[i], FALSE, FALSE, FALSE);
|
||||
}
|
||||
|
||||
if(first == NULL)
|
||||
|
@ -3330,7 +3330,7 @@ static void reqcb(const request *r, int count, axis_t *names, char *vals[], void
|
|||
|
||||
static boolean chk_152(int count, axis_t *names, char *vals[])
|
||||
{
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void loop(const request *r, boolean ml, int index, int count, axis_t* strings, char *values[], loopproc callback, void *data)
|
||||
|
@ -3376,7 +3376,7 @@ static void values_loop(const request *r, int count, axis_t *parnames, loopproc
|
|||
{
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "EXPECT provided, special treatment of LNSP");
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "and other single level parameters disabled");
|
||||
ml = false;
|
||||
ml = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3424,7 +3424,7 @@ static int split_fieldset(fieldset *fs, request *data_r, dataset_t **subsets, co
|
|||
|
||||
free_all_requests(s);
|
||||
|
||||
filters = calloc(sizeof(dataset_t), count);
|
||||
filters = (dataset_t*)calloc(sizeof(dataset_t), count);
|
||||
Assert(filters);
|
||||
|
||||
s = u;
|
||||
|
@ -3434,8 +3434,8 @@ static int split_fieldset(fieldset *fs, request *data_r, dataset_t **subsets, co
|
|||
filters[i].filter = new_hypercube_from_mars_request(s);
|
||||
filters[i].fset = new_fieldset(1);
|
||||
filters[i].count = 0;
|
||||
filters[i].request = clone_one_request(s);
|
||||
filters[i].bitmap = false;
|
||||
filters[i].filter_request = clone_one_request(s);
|
||||
filters[i].bitmap = FALSE;
|
||||
/* filters[i].mmeans = false; */
|
||||
|
||||
s = s->next;
|
||||
|
@ -3443,7 +3443,7 @@ static int split_fieldset(fieldset *fs, request *data_r, dataset_t **subsets, co
|
|||
|
||||
for(i = 0; i < fs->count; ++i)
|
||||
{
|
||||
boolean ok = false;
|
||||
boolean ok = FALSE;
|
||||
field *f = get_field(fs, i, packed_mem);
|
||||
request *g = field_to_request(f);
|
||||
int j = 0;
|
||||
|
@ -3487,9 +3487,9 @@ static int split_fieldset(fieldset *fs, request *data_r, dataset_t **subsets, co
|
|||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
filters[i].att.nctype = nctype;
|
||||
filters[i].scale = true;
|
||||
filters[i].scale = TRUE;
|
||||
filters[i].missing = nc_type_values[nctype].missing;
|
||||
find_nc_attributes(filters[i].request, user_r, &(filters[i].att), config_r, data_r);
|
||||
find_nc_attributes(filters[i].filter_request, user_r, &(filters[i].att), config_r, data_r);
|
||||
grib_context_log(ctx, GRIB_LOG_DEBUG, "grib_to_netcdf: filter[%d] found.- Var. name '%s', nctype: %d, found nctype: %d", i, filters[i].att.name, nctype, filters[i].att.nctype);
|
||||
|
||||
if(strlen(filters[i].att.name) == 0)
|
||||
|
@ -3503,10 +3503,10 @@ static int split_fieldset(fieldset *fs, request *data_r, dataset_t **subsets, co
|
|||
{
|
||||
case NC_FLOAT:
|
||||
case NC_DOUBLE:
|
||||
filters[i].scale = false;
|
||||
filters[i].scale = FALSE;
|
||||
break;
|
||||
default:
|
||||
filters[i].scale = true;
|
||||
filters[i].scale = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3529,7 +3529,7 @@ static void free_subsets(dataset_t *subsets, int count)
|
|||
free_all_requests(subsets[i].att.metadata);
|
||||
free_hypercube(subsets[i].filter);
|
||||
free_fieldset(subsets[i].fset);
|
||||
free_all_requests(subsets[i].request);
|
||||
free_all_requests(subsets[i].filter_request);
|
||||
}
|
||||
grib_context_free(ctx, subsets);
|
||||
}
|
||||
|
@ -3559,10 +3559,10 @@ static boolean parsedate(const char *name, long* julian, long *second, boolean*
|
|||
int y = 0, m = 0, d = 0, H = 0, M = 0, S = 0;
|
||||
|
||||
*julian = *second = 0;
|
||||
*isjul = false;
|
||||
*isjul = FALSE;
|
||||
|
||||
if(p == 0 || *p == 0)
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
/* Special ERA Interim grib1 date format: jul-21, sep-02 etc
|
||||
* See GRIB-416
|
||||
|
@ -3576,19 +3576,19 @@ static boolean parsedate(const char *name, long* julian, long *second, boolean*
|
|||
if (n == 2 && strlen(month) == 3) {
|
||||
y = 1900; /* no year specified */
|
||||
m = convert_month(month);
|
||||
if (m == -1) return false;
|
||||
if (m == -1) return FALSE;
|
||||
*julian = grib_date_to_julian(y * 10000 + m * 100 + day);
|
||||
*second = 0;
|
||||
return true;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* year */
|
||||
p = parse1(p, &y, &n);
|
||||
if(n != 2 && n != 4) /* year string must be 2 or 4 characters long: 93 or 1993 */
|
||||
return false;
|
||||
return FALSE;
|
||||
if(*p++ != '-')
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
/* month */
|
||||
p = parse1(p, &m, &n);
|
||||
|
@ -3596,10 +3596,10 @@ static boolean parsedate(const char *name, long* julian, long *second, boolean*
|
|||
{
|
||||
/* day */
|
||||
if(*p++ != '-')
|
||||
return false;
|
||||
return FALSE;
|
||||
p = parse1(p, &d, &n);
|
||||
if(n != 2)
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
else if(n == 3)
|
||||
{
|
||||
|
@ -3608,13 +3608,13 @@ static boolean parsedate(const char *name, long* julian, long *second, boolean*
|
|||
/* julian day */;
|
||||
d = j % 100;
|
||||
m = (j % 10000) / 100;
|
||||
*isjul = true;
|
||||
*isjul = TRUE;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
if (m == 0 || m > 12) {
|
||||
return false; /* month out of range */
|
||||
return FALSE; /* month out of range */
|
||||
}
|
||||
|
||||
while(*p && isspace(*p))
|
||||
|
@ -3625,31 +3625,31 @@ static boolean parsedate(const char *name, long* julian, long *second, boolean*
|
|||
if(n != 0)
|
||||
{
|
||||
if(n != 2)
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
/* minute */
|
||||
if(*p++ != ':')
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
p = parse1(p, &M, &n);
|
||||
if(n != 2)
|
||||
return false;
|
||||
return FALSE;
|
||||
|
||||
if(*p != 0)
|
||||
{
|
||||
/* second */
|
||||
if(*p++ != ':')
|
||||
return false;
|
||||
return FALSE;
|
||||
p = parse1(p, &S, &n);
|
||||
if(n != 2)
|
||||
return false;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
*julian = grib_date_to_julian(y * 10000 + m * 100 + d);
|
||||
*second = H * 3600 + M * 60 + S;
|
||||
|
||||
return *p == 0 ? true : false;
|
||||
return *p == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/*=====================================================================*/
|
||||
|
@ -3760,7 +3760,7 @@ int grib_tool_init(grib_runtime_options* options)
|
|||
set_value(user_r, "usevalidtime", "true");
|
||||
|
||||
if(grib_options_on("L"))
|
||||
create_64bit_offset_format = true; /* Switch to large file format */
|
||||
create_64bit_offset_format = TRUE; /* Switch to large file format */
|
||||
|
||||
if(grib_options_on("R:"))
|
||||
{
|
||||
|
@ -3829,7 +3829,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
|
|||
if(i == 1)
|
||||
{
|
||||
const char *mmeans = get_value(r, "_MONTHLY_MEANS", 0);
|
||||
setup.mmeans = mmeans ? (atol(mmeans) == 1) : false;
|
||||
setup.mmeans = mmeans ? (atol(mmeans) == 1) : FALSE;
|
||||
}
|
||||
fcmonth2nbmonths(r);
|
||||
|
||||
|
|
Loading…
Reference in New Issue