Tests: do both decoding and encoding of data values

This commit is contained in:
Shahram Najm 2018-05-18 14:36:06 +01:00
parent 6900ce19b9
commit d9a9ce5fe4
3 changed files with 9 additions and 30 deletions

View File

@ -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 */
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
int i;
long count;
double d,e;
size_t values_len = 0;
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);
values = (double*)malloc(values_len*sizeof(double));
d=10e-8;
e=d;
count=1;
GRIB_CHECK(grib_get_double_array(clone_handle, "values", values, &values_len),0);
for (i=0;i<values_len;i++) {
if (count>100) {e*=10; count=1;}
values[i]=d;
d+=e;
if (d > 10000) d = 0;
count++;
values[i] *= 0.9;
}
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);

View File

@ -29,8 +29,6 @@ static int encode_file(char *template_file, char *output_file)
/* loop over the messages in the source GRIB */
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
int i;
long count;
double d,e;
size_t values_len = 0;
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);
values = (double*)malloc(values_len*sizeof(double));
d=10e-8;
e=d;
count=1;
GRIB_CHECK(grib_get_double_array(source_handle, "values", values, &values_len),0);
for (i=0;i<values_len;i++) {
if (count>100) {e*=10; count=1;}
values[i]=d;
d+=e;
if (d > 10000) d = 0;
count++;
values[i] *= 0.9;
}
GRIB_CHECK(grib_set_string(source_handle,"stepUnits", "s", &str_len),0);

View File

@ -27,8 +27,6 @@ static int decode_file(char *template_file)
/* loop over the messages in the source GRIB and clone them */
while ((source_handle = grib_handle_new_from_file(0, in, &err))!=NULL) {
int i;
long count;
double d,e;
size_t values_len = 0;
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);
values = (double*)malloc(values_len*sizeof(double));
d=10e-8;
e=d;
count=1;
GRIB_CHECK(grib_get_double_array(clone_handle, "values", values, &values_len),0);
for (i=0;i<values_len;i++) {
if (count>100) {e*=10; count=1;}
values[i]=d;
d+=e;
if (d > 10000) d = 0;
count++;
values[i] *= 0.9;
}
GRIB_CHECK(grib_set_string(clone_handle,"stepUnits", "s", &str_len),0);