mirror of https://github.com/ecmwf/eccodes.git
Tests: do both decoding and encoding of data values
This commit is contained in:
parent
6900ce19b9
commit
d9a9ce5fe4
|
@ -27,8 +27,6 @@ static int encode_file(char *template_file, char *output_file)
|
||||||
/* loop over the messages in the source GRIB and clone them */
|
/* loop over the messages in the source GRIB and clone them */
|
||||||
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
|
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
|
||||||
int i;
|
int i;
|
||||||
long count;
|
|
||||||
double d,e;
|
|
||||||
size_t values_len = 0;
|
size_t values_len = 0;
|
||||||
size_t str_len = 20;
|
size_t str_len = 20;
|
||||||
|
|
||||||
|
@ -39,15 +37,10 @@ static int encode_file(char *template_file, char *output_file)
|
||||||
GRIB_CHECK(grib_get_size(clone_handle, "values", &values_len),0);
|
GRIB_CHECK(grib_get_size(clone_handle, "values", &values_len),0);
|
||||||
|
|
||||||
values = (double*)malloc(values_len*sizeof(double));
|
values = (double*)malloc(values_len*sizeof(double));
|
||||||
d=10e-8;
|
GRIB_CHECK(grib_get_double_array(clone_handle, "values", values, &values_len),0);
|
||||||
e=d;
|
|
||||||
count=1;
|
|
||||||
for (i=0;i<values_len;i++) {
|
for (i=0;i<values_len;i++) {
|
||||||
if (count>100) {e*=10; count=1;}
|
values[i] *= 0.9;
|
||||||
values[i]=d;
|
|
||||||
d+=e;
|
|
||||||
if (d > 10000) d = 0;
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);
|
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);
|
||||||
|
|
|
@ -29,8 +29,6 @@ static int encode_file(char *template_file, char *output_file)
|
||||||
/* loop over the messages in the source GRIB */
|
/* loop over the messages in the source GRIB */
|
||||||
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
|
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
|
||||||
int i;
|
int i;
|
||||||
long count;
|
|
||||||
double d,e;
|
|
||||||
size_t values_len = 0;
|
size_t values_len = 0;
|
||||||
size_t str_len = 20;
|
size_t str_len = 20;
|
||||||
|
|
||||||
|
@ -38,15 +36,10 @@ static int encode_file(char *template_file, char *output_file)
|
||||||
GRIB_CHECK(grib_get_size(source_handle, "values", &values_len),0);
|
GRIB_CHECK(grib_get_size(source_handle, "values", &values_len),0);
|
||||||
|
|
||||||
values = (double*)malloc(values_len*sizeof(double));
|
values = (double*)malloc(values_len*sizeof(double));
|
||||||
d=10e-8;
|
GRIB_CHECK(grib_get_double_array(source_handle, "values", values, &values_len),0);
|
||||||
e=d;
|
|
||||||
count=1;
|
|
||||||
for (i=0;i<values_len;i++) {
|
for (i=0;i<values_len;i++) {
|
||||||
if (count>100) {e*=10; count=1;}
|
values[i] *= 0.9;
|
||||||
values[i]=d;
|
|
||||||
d+=e;
|
|
||||||
if (d > 10000) d = 0;
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GRIB_CHECK(grib_set_string(source_handle,"stepUnits", "s", &str_len),0);
|
GRIB_CHECK(grib_set_string(source_handle,"stepUnits", "s", &str_len),0);
|
||||||
|
|
|
@ -27,8 +27,6 @@ static int decode_file(char *template_file)
|
||||||
/* loop over the messages in the source GRIB and clone them */
|
/* loop over the messages in the source GRIB and clone them */
|
||||||
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
|
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
|
||||||
int i;
|
int i;
|
||||||
long count;
|
|
||||||
double d,e;
|
|
||||||
size_t values_len = 0;
|
size_t values_len = 0;
|
||||||
size_t str_len = 20;
|
size_t str_len = 20;
|
||||||
|
|
||||||
|
@ -39,15 +37,10 @@ static int decode_file(char *template_file)
|
||||||
GRIB_CHECK(grib_get_size(clone_handle, "values", &values_len),0);
|
GRIB_CHECK(grib_get_size(clone_handle, "values", &values_len),0);
|
||||||
|
|
||||||
values = (double*)malloc(values_len*sizeof(double));
|
values = (double*)malloc(values_len*sizeof(double));
|
||||||
d=10e-8;
|
GRIB_CHECK(grib_get_double_array(clone_handle, "values", values, &values_len),0);
|
||||||
e=d;
|
|
||||||
count=1;
|
|
||||||
for (i=0;i<values_len;i++) {
|
for (i=0;i<values_len;i++) {
|
||||||
if (count>100) {e*=10; count=1;}
|
values[i] *= 0.9;
|
||||||
values[i]=d;
|
|
||||||
d+=e;
|
|
||||||
if (d > 10000) d = 0;
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);
|
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);
|
||||||
|
|
Loading…
Reference in New Issue