Merge branch 'develop' into feature/ECC-1296-uerra-mapping

This commit is contained in:
Shahram Najm 2021-11-08 15:17:40 +00:00
commit d6764a3abe
56 changed files with 155 additions and 228 deletions

View File

@ -79,10 +79,6 @@ int main(int argc, char* argv[])
codes_set_long_array(ho, "unexpandedDescriptors", ud, size); codes_set_long_array(ho, "unexpandedDescriptors", ud, size);
while ((h = codes_handle_new_from_file(0, f, PRODUCT_BUFR, &err)) != NULL) { while ((h = codes_handle_new_from_file(0, f, PRODUCT_BUFR, &err)) != NULL) {
if (!h) {
fprintf(stderr, "Error: Unable to create BUFR handle\n");
return 1;
}
/* codes_copy_key(h,ho,"unexpandedDescriptors",0); */ /* codes_copy_key(h,ho,"unexpandedDescriptors",0); */
err = codes_set_long(h, "unpack", 1); err = codes_set_long(h, "unpack", 1);
if (err) { if (err) {
@ -97,7 +93,7 @@ int main(int argc, char* argv[])
printf("Copied %s\n", keys[i]); printf("Copied %s\n", keys[i]);
free(keys[i]); free(keys[i]);
} }
printf("Total number of copied keys = %lu\n", nkeys); printf("Total number of copied keys = %lu\n", (unsigned long)nkeys);
free(keys); free(keys);
codes_handle_delete(h); codes_handle_delete(h);

View File

@ -57,7 +57,7 @@ int main(int argc, char* argv[])
/* get the size of the values array*/ /* get the size of the values array*/
CODES_CHECK(codes_get_size(h, "numericValues", &values_len), 0); CODES_CHECK(codes_get_size(h, "numericValues", &values_len), 0);
printf(" number of expanded values: %lu\n", values_len); printf(" number of expanded values: %lu\n", (unsigned long)values_len);
/* allocate array for data values */ /* allocate array for data values */
values = (double*)malloc(values_len * sizeof(double)); values = (double*)malloc(values_len * sizeof(double));

View File

@ -92,7 +92,7 @@ int main(int argc, char* argv[])
} }
else { else {
/* for arrays */ /* for arrays */
printf("(array of %lu)\n", klen); printf("(array of %lu)\n", (unsigned long)klen);
} }
} }

View File

@ -140,7 +140,7 @@ int main(int argc, char* argv[])
for (i = 0; i < sigt_len; i++) { for (i = 0; i < sigt_len; i++) {
printf("%3lu %6.0f %6.0f %.1f %.1f\n", printf("%3lu %6.0f %6.0f %.1f %.1f\n",
i + 1, sigt_pres[i], sigt_geo[i], sigt_t[i], sigt_td[i]); (unsigned long)(i + 1), sigt_pres[i], sigt_geo[i], sigt_t[i], sigt_td[i]);
} }
/* Delete handle */ /* Delete handle */

View File

@ -38,11 +38,13 @@ int main(int argc, char* argv[])
} }
in = fopen(argv[1], "rb"); in = fopen(argv[1], "rb");
if (!in) {
perror("ERROR: unable to open input file");
return 1;
}
out = fopen(argv[2], "wb"); out = fopen(argv[2], "wb");
if (!out) {
if (!in || !out) { perror("ERROR: unable to open output file");
perror("ERROR: unable to open files");
fclose(out);
fclose(in); fclose(in);
return 1; return 1;
} }

View File

@ -39,7 +39,7 @@ int main(int argc, char* argv[])
/* get size of "paramId" list */ /* get size of "paramId" list */
CODES_CHECK(codes_index_get_size(index, "paramId", &paramIdSize), 0); CODES_CHECK(codes_index_get_size(index, "paramId", &paramIdSize), 0);
printf("grib contains %lu different parameters\n", paramIdSize); printf("grib contains %lu different parameters\n", (unsigned long)paramIdSize);
/* allocate memory for "paramId" list */ /* allocate memory for "paramId" list */
paramId = (char**)malloc(paramIdSize * sizeof(char*)); paramId = (char**)malloc(paramIdSize * sizeof(char*));
/* get list of "paramId" */ /* get list of "paramId" */
@ -47,7 +47,7 @@ int main(int argc, char* argv[])
/* get size of ensemble number list */ /* get size of ensemble number list */
CODES_CHECK(codes_index_get_size(index, "number", &numberSize), 0); CODES_CHECK(codes_index_get_size(index, "number", &numberSize), 0);
printf("GRIB contains %lu different ensemble members\n", numberSize); printf("GRIB contains %lu different ensemble members\n", (unsigned long)numberSize);
/* allocate memory for ensemble number list */ /* allocate memory for ensemble number list */
number = (long*)malloc(numberSize * sizeof(long)); number = (long*)malloc(numberSize * sizeof(long));
/* get list of ensemble numbers */ /* get list of ensemble numbers */

View File

@ -55,7 +55,7 @@ int main(int argc, char** argv)
CODES_CHECK(codes_get_size(h, "bitmap", &bmp_len), 0); CODES_CHECK(codes_get_size(h, "bitmap", &bmp_len), 0);
bitmap = (long*)malloc(bmp_len * sizeof(long)); bitmap = (long*)malloc(bmp_len * sizeof(long));
CODES_CHECK(codes_get_long_array(h, "bitmap", bitmap, &bmp_len), 0); CODES_CHECK(codes_get_long_array(h, "bitmap", bitmap, &bmp_len), 0);
printf("Bitmap is present. Num = %lu\n", bmp_len); printf("Bitmap is present. Num = %lu\n", (unsigned long)bmp_len);
} }
/* Sanity check. Number of values must match number in bitmap */ /* Sanity check. Number of values must match number in bitmap */
CODES_CHECK(codes_get_size(h, "values", &values_len), 0); CODES_CHECK(codes_get_size(h, "values", &values_len), 0);

View File

@ -65,10 +65,6 @@ int main(int argc, char* argv[])
codes_keys_iterator* kiter = NULL; codes_keys_iterator* kiter = NULL;
msg_count++; msg_count++;
printf("-- GRIB N. %d --\n", msg_count); printf("-- GRIB N. %d --\n", msg_count);
if (!h) {
fprintf(stderr, "Error: Unable to create grib handle\n");
exit(1);
}
kiter = codes_keys_iterator_new(h, key_iterator_filter_flags, name_space); kiter = codes_keys_iterator_new(h, key_iterator_filter_flags, name_space);
if (!kiter) { if (!kiter) {

View File

@ -35,7 +35,6 @@ int main(int argc, char** argv)
{ {
int err = 0, i; int err = 0, i;
double* values = NULL; double* values = NULL;
double max, min, average;
size_t values_len = 0; size_t values_len = 0;
FILE* in = NULL; FILE* in = NULL;

View File

@ -35,7 +35,7 @@ static void read_data(FILE* fp, int num_msgs)
long stepRange = 0; long stepRange = 0;
codes_handle* h = NULL; codes_handle* h = NULL;
printf("File offset start = %lu\n", ftello(fp)); printf("File offset start = %ld\n", ftello(fp));
for (i = 0; i < num_msgs; ++i) { for (i = 0; i < num_msgs; ++i) {
h = codes_handle_new_from_file(0, fp, PRODUCT_GRIB, &err); h = codes_handle_new_from_file(0, fp, PRODUCT_GRIB, &err);
CODES_CHECK(err, 0); CODES_CHECK(err, 0);

View File

@ -232,7 +232,7 @@ int main(int argc, char** argv)
size = 496; size = 496;
vdouble = (double*)calloc(size, sizeof(double)); vdouble = (double*)calloc(size, sizeof(double));
if (!vdouble) { if (!vdouble) {
fprintf(stderr, "failed to allocate %lu bytes\n", size * sizeof(double)); fprintf(stderr, "failed to allocate %lu bytes\n", (unsigned long)(size * sizeof(double)));
exit(1); exit(1);
} }

View File

@ -21,7 +21,7 @@ static void encode_double_array_common(int numBits, long packStart, long datasiz
unsigned int ival; unsigned int ival;
int cbits, jbits; int cbits, jbits;
unsigned int c; unsigned int c;
static unsigned int mask[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; static const unsigned int mask[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
/* code from gribw routine flist2bitstream */ /* code from gribw routine flist2bitstream */

View File

@ -789,7 +789,7 @@ grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al)
return al->last; return al->last;
} }
grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, grib_accessor* a) grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a)
{ {
grib_accessors_list* last = al; grib_accessors_list* last = al;
grib_accessors_list* next = al->next; grib_accessors_list* next = al->next;

View File

@ -259,7 +259,7 @@ static int get_native_type(grib_accessor* a)
return type; return type;
} }
size_t compute_size_AO(long* descriptors, size_t numberOfDescriptors) size_t compute_size_AO(const long* descriptors, size_t numberOfDescriptors)
{ {
int i = 0; int i = 0;
size_t sizeAO = numberOfDescriptors; size_t sizeAO = numberOfDescriptors;

View File

@ -225,7 +225,7 @@ static int unpack_long(grib_accessor* a, long* v, size_t* len)
return err; return err;
i = 0; i = 0;
while (val[i] == ' ' && val[i] != 0 && i < l - 1) while (i < l - 1 && val[i] == ' ')
i++; i++;
if (val[i] == 0) { if (val[i] == 0) {

View File

@ -1839,7 +1839,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
sizebits = lengthOfSecondOrderValues; sizebits = lengthOfSecondOrderValues;
/* padding section 4 to an even number of octets */ /* padding section 4 to an even number of octets */
size = (size + offsetBeforeData - offsetSection4) % 2 ? size + 1 : size; size = ((size + offsetBeforeData - offsetSection4) % 2) ? size + 1 : size;
half_byte = 8 * size - sizebits; half_byte = 8 * size - sizebits;
if ((ret = grib_set_long_internal(handle, self->half_byte, half_byte)) != GRIB_SUCCESS) if ((ret = grib_set_long_internal(handle, self->half_byte, half_byte)) != GRIB_SUCCESS)
return ret; return ret;

View File

@ -219,8 +219,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
double* values = (double*)val; double* values = (double*)val;
size_t inlen = *len; size_t inlen = *len;
int free_buffer = 0; /*int free_buffer = 0;
int free_values = 0; *int free_values = 0;*/
int code = GRIB_SUCCESS; int code = GRIB_SUCCESS;
@ -261,10 +261,11 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
code = grib_ieee_encode_array(a->context, values, inlen, bytes, buffer); code = grib_ieee_encode_array(a->context, values, inlen, bytes, buffer);
clean_up: clean_up:
if (free_buffer) /*if (free_buffer)
free(buffer); * free(buffer);
if (free_values) * if (free_values)
free(values); * free(values);
*/
grib_buffer_replace(a, buffer, bufsize, 1, 1); grib_buffer_replace(a, buffer, bufsize, 1, 1);

View File

@ -532,7 +532,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a; grib_accessor_data_simple_packing* self = (grib_accessor_data_simple_packing*)a;
grib_handle* gh = grib_handle_of_accessor(a); grib_handle* gh = grib_handle_of_accessor(a);
size_t i; size_t i = 0;
size_t n_vals = *len; size_t n_vals = *len;
int err = 0; int err = 0;
int last; int last;

View File

@ -161,7 +161,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
char verifyingMonth[7] = {0,}; char verifyingMonth[7] = {0,};
size_t slen = 7; size_t slen = 7;
long year = 0, month = 0, date = 0; long year = 0, month = 0, date = 0;
long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
long days = 0; long days = 0;
if (!a->dirty) if (!a->dirty)

View File

@ -248,7 +248,7 @@ static int unpack_long(grib_accessor* a, long* v, size_t* len)
return err; return err;
i = 0; i = 0;
while (val[i] == ' ' && val[i] != 0 && i < l - 1) while (i < l - 1 && val[i] == ' ')
i++; i++;
if (val[i] == 0) { if (val[i] == 0) {

View File

@ -223,7 +223,7 @@ static int unpack_long(grib_accessor* a, long* v, size_t* len)
return err; return err;
i = 0; i = 0;
while (i < l - 1 && val[i] == ' ' && val[i] != 0) while (i < l - 1 && val[i] == ' ')
i++; i++;
if (val[i] == 0) { if (val[i] == 0) {

View File

@ -160,7 +160,7 @@ static size_t preferred_size(grib_accessor* a, int from_handle)
/* printf("EVEN %ld %ld\n",(long) a->offset,(long) offset);*/ /* printf("EVEN %ld %ld\n",(long) a->offset,(long) offset);*/
seclen = a->offset - offset; seclen = a->offset - offset;
return seclen % 2 ? 1 : 0; return (seclen % 2) ? 1 : 0;
} }
static void init(grib_accessor* a, const long len, grib_arguments* args) static void init(grib_accessor* a, const long len, grib_arguments* args)

View File

@ -159,7 +159,7 @@ grib_accessor* grib_accessor_get_attribute(grib_accessor* a, const char* name);
grib_accessors_list* grib_accessors_list_create(grib_context* c); grib_accessors_list* grib_accessors_list_create(grib_context* c);
void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank); void grib_accessors_list_push(grib_accessors_list* al, grib_accessor* a, int rank);
grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al); grib_accessors_list* grib_accessors_list_last(grib_accessors_list* al);
grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, grib_accessor* a); grib_accessors_list* grib_accessors_list_find(grib_accessors_list* al, const grib_accessor* a);
void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al); void grib_accessors_list_delete(grib_context* c, grib_accessors_list* al);
/* grib_concept.c */ /* grib_concept.c */
@ -317,7 +317,7 @@ bufr_descriptor* accessor_bufr_elements_table_get_descriptor(grib_accessor* a, i
/* grib_accessor_class_bufr_has_delayed_replication.c */ /* grib_accessor_class_bufr_has_delayed_replication.c */
/* grib_accessor_class_apply_operators.c */ /* grib_accessor_class_apply_operators.c */
size_t compute_size_AO(long* descriptors, size_t numberOfDescriptors); size_t compute_size_AO(const long* descriptors, size_t numberOfDescriptors);
/* grib_accessor_class_non_alpha.c */ /* grib_accessor_class_non_alpha.c */
@ -1380,11 +1380,11 @@ grib_box* grib_box_factory(grib_handle* h, grib_arguments* args);
int grib_nearest_find(grib_nearest* nearest, const grib_handle* h, double inlat, double inlon, unsigned long flags, double* outlats, double* outlons, double* values, double* distances, int* indexes, size_t* len); int grib_nearest_find(grib_nearest* nearest, const grib_handle* h, double inlat, double inlon, unsigned long flags, double* outlats, double* outlons, double* values, double* distances, int* indexes, size_t* len);
int grib_nearest_init(grib_nearest* i, grib_handle* h, grib_arguments* args); int grib_nearest_init(grib_nearest* i, grib_handle* h, grib_arguments* args);
int grib_nearest_delete(grib_nearest* i); int grib_nearest_delete(grib_nearest* i);
int grib_nearest_get_radius(grib_handle* h, double* radiusInKm);
void grib_binary_search(double xx[], const unsigned long n, double x, int* ju, int* jl); void grib_binary_search(double xx[], const unsigned long n, double x, int* ju, int* jl);
int grib_nearest_find_multiple(const grib_handle* h, int is_lsm, const double* inlats, const double* inlons, long npoints, double* outlats, double* outlons, double* values, double* distances, int* indexes); int grib_nearest_find_multiple(const grib_handle* h, int is_lsm, const double* inlats, const double* inlons, long npoints, double* outlats, double* outlons, double* values, double* distances, int* indexes);
int grib_nearest_find_generic(grib_nearest* nearest, grib_handle* h, double inlat, double inlon, unsigned long flags, int grib_nearest_find_generic(grib_nearest* nearest, grib_handle* h, double inlat, double inlon, unsigned long flags,
const char* values_keyname, const char* radius_keyname, const char* values_keyname, const char* Ni_keyname, const char* Nj_keyname,
const char* Ni_keyname, const char* Nj_keyname,
double** out_lats, double** out_lats,
int* out_lats_count, int* out_lats_count,
double** out_lons, double** out_lons,

View File

@ -176,14 +176,13 @@ int grib_encode_signed_longb(unsigned char* p, long val, long* bitp, long nb)
Assert(nb <= max_nbits); Assert(nb <= max_nbits);
if (sign) if (sign) {
val = -val; val = -val;
if (sign)
grib_set_bit_on(p, bitp); grib_set_bit_on(p, bitp);
else }
else {
grib_set_bit_off(p, bitp); grib_set_bit_off(p, bitp);
}
return grib_encode_unsigned_longb(p, val, bitp, nb - 1); return grib_encode_unsigned_longb(p, val, bitp, nb - 1);
} }

View File

@ -97,7 +97,7 @@ int grib_encode_string(unsigned char* bitStream, long* bitOffset, size_t numberO
int remainder = *bitOffset % 8; int remainder = *bitOffset % 8;
unsigned char c; unsigned char c;
unsigned char* p; unsigned char* p;
unsigned char mask[] = { 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; const unsigned char mask[] = { 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
int remainderComplement = 8 - remainder; int remainderComplement = 8 - remainder;
char str[512] = {0,}; char str[512] = {0,};
char* s = str; char* s = str;
@ -139,7 +139,7 @@ char* grib_decode_string(const unsigned char* bitStream, long* bitOffset, size_t
unsigned char c; unsigned char c;
unsigned char* p; unsigned char* p;
char* s = string; char* s = string;
unsigned char mask[] = { 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; const unsigned char mask[] = { 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
int remainderComplement = 8 - remainder; int remainderComplement = 8 - remainder;
if (numberOfCharacters == 0) if (numberOfCharacters == 0)

View File

@ -90,7 +90,7 @@ char* grib_decode_string(const unsigned char* bitStream, long* bitOffset, size_t
unsigned char c; unsigned char c;
unsigned char* p; unsigned char* p;
char* s = string; char* s = string;
unsigned char mask[] = { 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE }; const unsigned char mask[] = { 0, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE };
int remainderComplement = 8 - remainder; int remainderComplement = 8 - remainder;
if (numberOfCharacters == 0) if (numberOfCharacters == 0)

View File

@ -17,7 +17,7 @@ int grib_decode_long_array(const unsigned char* p, long* bitp, long nbits, size_
{ {
long i = 0; long i = 0;
long countOfLeftmostBits = 0, leftmostBits = 0; long countOfLeftmostBits = 0, leftmostBits = 0;
long startBit, startByte; long startBit;
long remainingBits = nbits; long remainingBits = nbits;
long* pp = (long*)p; long* pp = (long*)p;
int inited = 0; int inited = 0;
@ -84,7 +84,7 @@ int grib_decode_double_array(const unsigned char* p, long* bitp, long nbits, dou
{ {
long i = 0; long i = 0;
long countOfLeftmostBits = 0, leftmostBits = 0; long countOfLeftmostBits = 0, leftmostBits = 0;
long startBit, startByte; long startBit;
long remainingBits = nbits; long remainingBits = nbits;
long* pp = (long*)p; long* pp = (long*)p;
int inited = 0; int inited = 0;

View File

@ -638,7 +638,7 @@ static grib_order_by* grib_db_new_order_by(grib_context* c, char* obstr)
p++; p++;
mode = mode_default; mode = mode_default;
if (p != t2) { if (p != t2) {
while (*p == ' ' && *p != '\0') while (*p == ' ')
p++; p++;
if (*p != '\0') { if (*p != '\0') {
*(p - 1) = '\0'; *(p - 1) = '\0';
@ -906,7 +906,7 @@ static void grib_db_delete_fields(grib_fieldset* set)
static void grib_trim(char** x) static void grib_trim(char** x)
{ {
char* p = 0; char* p = 0;
while (**x == ' ' && **x != '\0') while (**x == ' ')
(*x)++; (*x)++;
if (**x == '\0') if (**x == '\0')
return; return;

View File

@ -44,9 +44,9 @@ static grib_handle* handle_of(grib_accessor* observed)
void grib_dependency_add(grib_accessor* observer, grib_accessor* observed) void grib_dependency_add(grib_accessor* observer, grib_accessor* observed)
{ {
grib_handle* h = handle_of(observed); grib_handle* h = NULL;
grib_dependency* d = h->dependencies; grib_dependency* d = NULL;
grib_dependency* last = 0; grib_dependency* last = NULL;
/*printf("grib_dependency_add: observe %p %p observed=%s observer=%s\n", /*printf("grib_dependency_add: observe %p %p observed=%s observer=%s\n",
(void*)observed, (void*)observer, (void*)observed, (void*)observer,
@ -56,6 +56,8 @@ void grib_dependency_add(grib_accessor* observer, grib_accessor* observed)
if (!observer || !observed) { if (!observer || !observed) {
return; return;
} }
h = handle_of(observed);
d = h->dependencies;
/* Assert(h == handle_of(observer)); */ /* Assert(h == handle_of(observer)); */
@ -164,12 +166,15 @@ int _grib_dependency_notify_change(grib_handle* h, grib_accessor* observed)
void grib_dependency_remove_observer(grib_accessor* observer) void grib_dependency_remove_observer(grib_accessor* observer)
{ {
grib_handle* h = handle_of(observer); grib_handle* h = NULL;
grib_dependency* d = h->dependencies; grib_dependency* d = NULL;
if (!observer) if (!observer)
return; return;
h = handle_of(observer);
d = h->dependencies;
while (d) { while (d) {
if (d->observer == observer) { if (d->observer == observer) {
d->observer = 0; d->observer = 0;

View File

@ -109,14 +109,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}

View File

@ -108,14 +108,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}

View File

@ -109,14 +109,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}

View File

@ -109,14 +109,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}

View File

@ -109,14 +109,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}

View File

@ -110,14 +110,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}

View File

@ -109,14 +109,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}
@ -704,15 +696,13 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
fprintf(self->dumper.out, " \"%s\" /)\n", values[size - 1]); fprintf(self->dumper.out, " \"%s\" /)\n", values[size - 1]);
if (self->isLeaf == 0) { if (self->isLeaf == 0) {
char* prefix;
int dofree = 0;
if ((r = compute_bufr_key_rank(h, self->keys, a->name)) != 0) if ((r = compute_bufr_key_rank(h, self->keys, a->name)) != 0)
fprintf(self->dumper.out, " call codes_set_string_array(ibufr,'#%d#%s',svalues)\n", r, a->name); fprintf(self->dumper.out, " call codes_set_string_array(ibufr,'#%d#%s',svalues)\n", r, a->name);
else else
fprintf(self->dumper.out, " call codes_set_string_array(ibufr,'%s',svalues)\n", a->name); fprintf(self->dumper.out, " call codes_set_string_array(ibufr,'%s',svalues)\n", a->name);
}
if (self->isLeaf == 0) {
char* prefix;
int dofree = 0;
if (r != 0) { if (r != 0) {
prefix = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + 10)); prefix = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + 10));

View File

@ -109,14 +109,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static int depth = 0; static int depth = 0;
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}
@ -648,15 +640,13 @@ static void dump_string_array(grib_dumper* d, grib_accessor* a, const char* comm
fprintf(self->dumper.out, " \"%s\", )\n", values[i]); fprintf(self->dumper.out, " \"%s\", )\n", values[i]);
if (self->isLeaf == 0) { if (self->isLeaf == 0) {
char* prefix;
int dofree = 0;
if ((r = compute_bufr_key_rank(h, self->keys, a->name)) != 0) if ((r = compute_bufr_key_rank(h, self->keys, a->name)) != 0)
fprintf(self->dumper.out, " codes_set_array(ibufr, '#%d#%s', svalues)\n", r, a->name); fprintf(self->dumper.out, " codes_set_array(ibufr, '#%d#%s', svalues)\n", r, a->name);
else else
fprintf(self->dumper.out, " codes_set_array(ibufr, '%s', svalues)\n", a->name); fprintf(self->dumper.out, " codes_set_array(ibufr, '%s', svalues)\n", a->name);
}
if (self->isLeaf == 0) {
char* prefix;
int dofree = 0;
if (r != 0) { if (r != 0) {
prefix = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + 10)); prefix = (char*)grib_context_malloc_clear(c, sizeof(char) * (strlen(a->name) + 10));

View File

@ -108,14 +108,6 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef struct string_count string_count;
struct string_count
{
char* value;
int count;
string_count* next;
};
static void init_class(grib_dumper_class* c) {} static void init_class(grib_dumper_class* c) {}
static int init(grib_dumper* d) static int init(grib_dumper* d)

View File

@ -593,7 +593,7 @@ static grib_order_by* grib_fieldset_new_order_by(grib_context* c, const char* ob
p++; p++;
mode = mode_default; mode = mode_default;
if (p != t2) { if (p != t2) {
while (*p == ' ' && *p != '\0') while (*p == ' ')
p++; p++;
if (*p != '\0') { if (*p != '\0') {
*(p - 1) = '\0'; *(p - 1) = '\0';
@ -683,12 +683,12 @@ int grib_fieldset_add(grib_fieldset* set, char* filename)
return ret; return ret;
} }
offset = 0; offset = 0;
ret = grib_get_double(h, "offset", &offset); grib_get_double(h, "offset", &offset);
set->fields[set->size] = (grib_field*)grib_context_malloc_clear(c, sizeof(grib_field)); set->fields[set->size] = (grib_field*)grib_context_malloc_clear(c, sizeof(grib_field));
set->fields[set->size]->file = file; set->fields[set->size]->file = file;
file->refcount++; file->refcount++;
set->fields[set->size]->offset = (off_t)offset; set->fields[set->size]->offset = (off_t)offset;
ret = grib_get_long(h, "totalLength", &length); grib_get_long(h, "totalLength", &length);
set->fields[set->size]->length = length; set->fields[set->size]->length = length;
set->filter->el[set->size] = set->size; set->filter->el[set->size] = set->size;
set->order->el[set->size] = set->size; set->order->el[set->size] = set->size;
@ -897,7 +897,7 @@ static void grib_fieldset_delete_fields(grib_fieldset* set)
static void grib_trim(char** x) static void grib_trim(char** x)
{ {
char* p = 0; char* p = 0;
while (**x == ' ' && **x != '\0') while (**x == ' ')
(*x)++; (*x)++;
if (**x == '\0') if (**x == '\0')
return; return;

View File

@ -89,7 +89,7 @@ static void init_table_if_needed()
GRIB_MUTEX_UNLOCK(&mutex) GRIB_MUTEX_UNLOCK(&mutex)
} }
static void binary_search(double xx[], const unsigned long n, double x, unsigned long* j) static void binary_search(const double xx[], const unsigned long n, double x, unsigned long* j)
{ {
/*These routine works only on ascending ordered arrays*/ /*These routine works only on ascending ordered arrays*/
unsigned long ju, jm, jl; unsigned long ju, jm, jl;

View File

@ -95,7 +95,7 @@ static void init_table_if_needed()
GRIB_MUTEX_UNLOCK(&mutex) GRIB_MUTEX_UNLOCK(&mutex)
} }
static void binary_search(double xx[], const unsigned long n, double x, unsigned long* j) static void binary_search(const double xx[], const unsigned long n, double x, unsigned long* j)
{ {
/*These routine works only on ascending ordered arrays*/ /*These routine works only on ascending ordered arrays*/
unsigned long ju, jm, jl; unsigned long ju, jm, jl;
@ -522,8 +522,10 @@ int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes
unsigned char* buf) unsigned char* buf)
{ {
int err = 0, i = 0, j = 0; int err = 0, i = 0, j = 0;
#if IEEE_LE
unsigned char s4[4]; unsigned char s4[4];
unsigned char s8[8]; unsigned char s8[8];
#endif
float fval = 0; float fval = 0;
double* pval = val; double* pval = val;

View File

@ -91,7 +91,7 @@ static void init_class(grib_iterator_class* c)
} }
/* END_CLASS_IMP */ /* END_CLASS_IMP */
static void binary_search(double xx[], const unsigned long n, double x, unsigned long* j); static void binary_search(const double xx[], const unsigned long n, double x, unsigned long* j);
static int init(grib_iterator* i, grib_handle* h, grib_arguments* args) static int init(grib_iterator* i, grib_handle* h, grib_arguments* args)
{ {
@ -164,7 +164,7 @@ static int init(grib_iterator* i, grib_handle* h, grib_arguments* args)
return ret; return ret;
} }
static void binary_search(double xx[], const unsigned long n, double x, unsigned long* j) static void binary_search(const double xx[], const unsigned long n, double x, unsigned long* j)
{ {
/*This routine works only on descending ordered arrays*/ /*This routine works only on descending ordered arrays*/
#define EPSILON 1e-3 #define EPSILON 1e-3

View File

@ -131,7 +131,7 @@ static void pj_authset(double es, double* APA)
APA[1] += t * P11; APA[1] += t * P11;
APA[2] = t * P20; APA[2] = t * P20;
} }
static double pj_authlat(double beta, double* APA) static double pj_authlat(double beta, const double* APA)
{ {
double t = beta + beta; double t = beta + beta;
return (beta + APA[0] * sin(t) + APA[1] * sin(t + t) + APA[2] * sin(t + t + t)); return (beta + APA[0] * sin(t) + APA[1] * sin(t + t) + APA[2] * sin(t + t + t));

View File

@ -97,6 +97,37 @@ int grib_nearest_delete(grib_nearest* i)
return 0; return 0;
} }
/* Get the radius in kilometres for nearest neighbour distance calculations */
/* For an ellipsoid, approximate the radius using the average of the semimajor and semiminor axes */
int grib_nearest_get_radius(grib_handle* h, double* radiusInKm)
{
int err = 0;
long lRadiusInMetres;
double result = 0;
const char* s_radius = "radius";
const char* s_minor = "earthMinorAxisInMetres";
const char* s_major = "earthMajorAxisInMetres";
if ((err = grib_get_long(h, s_radius, &lRadiusInMetres)) == GRIB_SUCCESS) {
if (grib_is_missing(h, s_radius, &err) || lRadiusInMetres == GRIB_MISSING_LONG) {
grib_context_log(h->context, GRIB_LOG_DEBUG, "Key 'radius' is missing");
return GRIB_GEOCALCULUS_PROBLEM;
}
result = ((double)lRadiusInMetres) / 1000.0;
}
else {
double minor = 0, major = 0;
if ((err = grib_get_double_internal(h, s_minor, &minor)) != GRIB_SUCCESS) return err;
if ((err = grib_get_double_internal(h, s_major, &major)) != GRIB_SUCCESS) return err;
if (grib_is_missing(h, s_minor, &err)) return GRIB_GEOCALCULUS_PROBLEM;
if (grib_is_missing(h, s_major, &err)) return GRIB_GEOCALCULUS_PROBLEM;
result = (major + minor) / 2.0;
result = result / 1000.0;
}
*radiusInKm = result;
return GRIB_SUCCESS;
}
void grib_binary_search(double xx[], const unsigned long n, double x, void grib_binary_search(double xx[], const unsigned long n, double x,
int* ju, int* jl) int* ju, int* jl)
{ {
@ -264,7 +295,6 @@ int grib_nearest_find_generic(
double inlat, double inlon, unsigned long flags, double inlat, double inlon, unsigned long flags,
const char* values_keyname, const char* values_keyname,
const char* radius_keyname,
const char* Ni_keyname, const char* Ni_keyname,
const char* Nj_keyname, const char* Nj_keyname,
double** out_lats, double** out_lats,
@ -278,7 +308,7 @@ int grib_nearest_find_generic(
{ {
int ret = 0, i = 0; int ret = 0, i = 0;
size_t nvalues = 0, nneighbours = 0; size_t nvalues = 0, nneighbours = 0;
double radiusInMetres, radiusInKm; double radiusInKm;
grib_iterator* iter = NULL; grib_iterator* iter = NULL;
double lat = 0, lon = 0; double lat = 0, lon = 0;
@ -291,21 +321,8 @@ int grib_nearest_find_generic(
return ret; return ret;
nearest->values_count = nvalues; nearest->values_count = nvalues;
/* We need the radius to calculate the nearest distance. For an oblate earth if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
approximate this using the average of the semimajor and semiminor axes */ return ret;
if ((ret = grib_get_double(h, radius_keyname, &radiusInMetres)) == GRIB_SUCCESS &&
!grib_is_missing(h, radius_keyname, &ret)) {
radiusInKm = radiusInMetres / 1000.0;
}
else {
double minor = 0, major = 0;
if ((ret = grib_get_double_internal(h, "earthMinorAxisInMetres", &minor)) != GRIB_SUCCESS) return ret;
if ((ret = grib_get_double_internal(h, "earthMajorAxisInMetres", &major)) != GRIB_SUCCESS) return ret;
if (grib_is_missing(h, "earthMinorAxisInMetres", &ret)) return GRIB_GEOCALCULUS_PROBLEM;
if (grib_is_missing(h, "earthMajorAxisInMetres", &ret)) return GRIB_GEOCALCULUS_PROBLEM;
radiusInMetres = (major + minor) / 2;
radiusInKm = radiusInMetres / 1000.0;
}
neighbours = (PointStore*)grib_context_malloc(nearest->context, nvalues * sizeof(PointStore)); neighbours = (PointStore*)grib_context_malloc(nearest->context, nvalues * sizeof(PointStore));
for (i = 0; i < nvalues; ++i) { for (i = 0; i < nvalues; ++i) {

View File

@ -110,7 +110,6 @@ static int find(grib_nearest* nearest, grib_handle* h,
nearest, h, inlat, inlon, flags, /* inputs */ nearest, h, inlat, inlon, flags, /* inputs */
self->values_key, /* outputs to set the 'self' object */ self->values_key, /* outputs to set the 'self' object */
self->radius,
self->Ni, self->Ni,
self->Nj, self->Nj,
&(self->lats), &(self->lats),

View File

@ -110,7 +110,6 @@ static int find(grib_nearest* nearest, grib_handle* h,
nearest, h, inlat, inlon, flags, /* inputs */ nearest, h, inlat, inlon, flags, /* inputs */
self->values_key, /* outputs to set the 'self' object */ self->values_key, /* outputs to set the 'self' object */
self->radius,
self->Ni, self->Ni,
self->Nj, self->Nj,
&(self->lats), &(self->lats),

View File

@ -119,22 +119,15 @@ static int find(grib_nearest* nearest, grib_handle* h,
size_t nvalues = 0; size_t nvalues = 0;
grib_iterator* iter = NULL; grib_iterator* iter = NULL;
double lat = 0, lon = 0; double lat = 0, lon = 0;
long iradius; double radiusInKm;
double radius;
int ilat = 0, ilon = 0; int ilat = 0, ilon = 0;
if ((ret = grib_get_size(h, self->values_key, &nvalues)) != GRIB_SUCCESS) if ((ret = grib_get_size(h, self->values_key, &nvalues)) != GRIB_SUCCESS)
return ret; return ret;
nearest->values_count = nvalues; nearest->values_count = nvalues;
if (grib_is_missing(h, self->radius, &ret)) { if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_DEBUG, "Key '%s' is missing", self->radius);
return ret ? ret : GRIB_GEOCALCULUS_PROBLEM;
}
if ((ret = grib_get_long(h, self->radius, &iradius)) != GRIB_SUCCESS)
return ret; return ret;
radius = ((double)iradius) / 1000.0;
/* Compute lat/lon info, create iterator etc if it's the 1st time or different grid. /* Compute lat/lon info, create iterator etc if it's the 1st time or different grid.
* This is for performance: if the grid has not changed, we only do this once * This is for performance: if the grid has not changed, we only do this once
@ -352,7 +345,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
kk = 0; kk = 0;
for (jj = 0; jj < 2; jj++) { for (jj = 0; jj < 2; jj++) {
for (ii = 0; ii < 2; ii++) { for (ii = 0; ii < 2; ii++) {
self->distances[kk] = geographic_distance_spherical(radius, inlon, inlat, self->distances[kk] = geographic_distance_spherical(radiusInKm, inlon, inlat,
self->lons[self->k[kk]], self->lats[self->j[jj]]); self->lons[self->k[kk]], self->lats[self->j[jj]]);
kk++; kk++;
} }

View File

@ -112,7 +112,6 @@ static int find(grib_nearest* nearest, grib_handle* h,
nearest, h, inlat, inlon, flags, /* inputs */ nearest, h, inlat, inlon, flags, /* inputs */
self->values_key, /* outputs to set the 'self' object */ self->values_key, /* outputs to set the 'self' object */
self->radius,
self->Ni, self->Ni,
self->Nj, self->Nj,
&(self->lats), &(self->lats),

View File

@ -110,7 +110,6 @@ static int find(grib_nearest* nearest, grib_handle* h,
nearest, h, inlat, inlon, flags, /* inputs */ nearest, h, inlat, inlon, flags, /* inputs */
self->values_key, /* outputs to set the 'self' object */ self->values_key, /* outputs to set the 'self' object */
self->radius,
self->Ni, self->Ni,
self->Nj, self->Nj,
&(self->lats), &(self->lats),

View File

@ -148,8 +148,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
size_t nvalues = 0; size_t nvalues = 0;
grib_iterator* iter = NULL; grib_iterator* iter = NULL;
double lat = 0, lon = 0; double lat = 0, lon = 0;
long iradius; double radiusInKm;
double radius;
int ilat = 0, ilon = 0; int ilat = 0, ilon = 0;
get_reduced_row_proc get_reduced_row_func = &grib_get_reduced_row; get_reduced_row_proc get_reduced_row_func = &grib_get_reduced_row;
@ -164,14 +163,8 @@ static int find(grib_nearest* nearest, grib_handle* h,
return ret; return ret;
nearest->values_count = nvalues; nearest->values_count = nvalues;
if (grib_is_missing(h, self->radius, &ret)) { if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
grib_context_log(h->context, GRIB_LOG_DEBUG, "Key '%s' is missing", self->radius);
return ret ? ret : GRIB_GEOCALCULUS_PROBLEM;
}
if ((ret = grib_get_long(h, self->radius, &iradius)) != GRIB_SUCCESS)
return ret; return ret;
radius = ((double)iradius) / 1000.0;
/* Compute lat/lon info, create iterator etc if it's the 1st time or different grid. /* Compute lat/lon info, create iterator etc if it's the 1st time or different grid.
* This is for performance: if the grid has not changed, we only do this once * This is for performance: if the grid has not changed, we only do this once
@ -421,7 +414,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
kk = 0; kk = 0;
for (jj = 0; jj < 2; jj++) { for (jj = 0; jj < 2; jj++) {
for (ii = 0; ii < 2; ii++) { for (ii = 0; ii < 2; ii++) {
self->distances[kk] = geographic_distance_spherical(radius, inlon, inlat, self->distances[kk] = geographic_distance_spherical(radiusInKm, inlon, inlat,
self->lons[self->k[kk]], self->lats[self->j[jj]]); self->lons[self->k[kk]], self->lats[self->j[jj]]);
kk++; kk++;
} }

View File

@ -108,13 +108,10 @@ static int find(grib_nearest* nearest, grib_handle* h,
grib_nearest_regular* self = (grib_nearest_regular*) nearest; grib_nearest_regular* self = (grib_nearest_regular*) nearest;
int ret=0,kk=0,ii=0,jj=0; int ret=0,kk=0,ii=0,jj=0;
size_t nvalues=0; size_t nvalues=0;
double radiusInKm;
long iradius; if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
double radius;
if( (ret = grib_get_long(h,self->radius,&iradius))!= GRIB_SUCCESS)
return ret; return ret;
radius=((double)iradius)/1000.0;
if (!nearest->h || (flags & GRIB_NEAREST_SAME_DATA)==0 || nearest->h!=h) { if (!nearest->h || (flags & GRIB_NEAREST_SAME_DATA)==0 || nearest->h!=h) {
grib_iterator* iter=NULL; grib_iterator* iter=NULL;
@ -231,8 +228,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
grib_nearest_regular* self = (grib_nearest_regular*)nearest; grib_nearest_regular* self = (grib_nearest_regular*)nearest;
int ret = 0, kk = 0, ii = 0, jj = 0; int ret = 0, kk = 0, ii = 0, jj = 0;
size_t nvalues = 0; size_t nvalues = 0;
long iradius; double radiusInKm;
double radius; /* radius in km */
grib_iterator* iter = NULL; grib_iterator* iter = NULL;
double lat = 0, lon = 0; double lat = 0, lon = 0;
@ -248,24 +244,8 @@ static int find(grib_nearest* nearest, grib_handle* h,
return ret; return ret;
nearest->values_count = nvalues; nearest->values_count = nvalues;
/* We need the radius to calculate the nearest distance. For an oblate earth if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
approximate this using the average of the semimajor and semiminor axes */ return ret;
if ((ret = grib_get_long(h, self->radius, &iradius)) == GRIB_SUCCESS) {
if (grib_is_missing(h, self->radius, &ret) || iradius == GRIB_MISSING_LONG) {
grib_context_log(h->context, GRIB_LOG_DEBUG, "Key '%s' is missing", self->radius);
return GRIB_GEOCALCULUS_PROBLEM;
}
radius = ((double)iradius) / 1000.0;
}
else {
double minor = 0, major = 0;
if ((ret = grib_get_double_internal(h, "earthMinorAxisInMetres", &minor)) != GRIB_SUCCESS) return ret;
if ((ret = grib_get_double_internal(h, "earthMajorAxisInMetres", &major)) != GRIB_SUCCESS) return ret;
if (grib_is_missing(h, "earthMinorAxisInMetres", &ret)) return GRIB_GEOCALCULUS_PROBLEM;
if (grib_is_missing(h, "earthMajorAxisInMetres", &ret)) return GRIB_GEOCALCULUS_PROBLEM;
radius = (major + minor) / 2.0;
radius = radius / 1000.0;
}
/* Compute lat/lon info, create iterator etc if it's the 1st time or different grid. /* Compute lat/lon info, create iterator etc if it's the 1st time or different grid.
* This is for performance: if the grid has not changed, we only do this once * This is for performance: if the grid has not changed, we only do this once
@ -424,7 +404,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
for (jj = 0; jj < 2; jj++) { for (jj = 0; jj < 2; jj++) {
for (ii = 0; ii < 2; ii++) { for (ii = 0; ii < 2; ii++) {
self->k[kk] = self->i[ii] + self->lons_count * self->j[jj]; self->k[kk] = self->i[ii] + self->lons_count * self->j[jj];
self->distances[kk] = geographic_distance_spherical(radius, inlon, inlat, self->distances[kk] = geographic_distance_spherical(radiusInKm, inlon, inlat,
self->lons[self->i[ii]], self->lats[self->j[jj]]); self->lons[self->i[ii]], self->lats[self->j[jj]]);
kk++; kk++;
} }

View File

@ -110,7 +110,6 @@ static int find(grib_nearest* nearest, grib_handle* h,
nearest, h, inlat, inlon, flags, /* inputs */ nearest, h, inlat, inlon, flags, /* inputs */
self->values_key, /* outputs to set the 'self' object */ self->values_key, /* outputs to set the 'self' object */
self->radius,
self->Ni, self->Ni,
self->Nj, self->Nj,
&(self->lats), &(self->lats),

View File

@ -54,10 +54,35 @@ diff $tempRef $temp
# ECC-1295: regular lat/lon on ellipsoid # ECC-1295: regular lat/lon on ellipsoid
# ---------------------------------------- # ----------------------------------------
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -s shapeOfTheEarth=2 $sample2 $temp
grib_check_key_equals $sample2 earthIsOblate 0
grib_check_key_equals $temp earthIsOblate 1
${tools_dir}/grib_ls -l 0,0 $temp
# reduced lat/lon on ellipsoid
# ----------------------------------------
sample2=$ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib2.tmpl
${tools_dir}/grib_set -s shapeOfTheEarth=4 $sample2 $temp
grib_check_key_equals $sample2 earthIsOblate 0
grib_check_key_equals $temp earthIsOblate 1
${tools_dir}/grib_ls -l 0,0 $temp
# regular gaussian on ellipsoid
# ----------------------------------------
sample2=$ECCODES_SAMPLES_PATH/regular_gg_pl_grib2.tmpl
${tools_dir}/grib_set -s shapeOfTheEarth=5 $sample2 $temp ${tools_dir}/grib_set -s shapeOfTheEarth=5 $sample2 $temp
grib_check_key_equals $sample2 earthIsOblate 0 grib_check_key_equals $sample2 earthIsOblate 0
grib_check_key_equals $temp earthIsOblate 1 grib_check_key_equals $temp earthIsOblate 1
${tools_dir}/grib_ls -l 0,0 $temp ${tools_dir}/grib_ls -l 0,0 $temp
# reduced gaussian on ellipsoid
# ----------------------------------------
sample2=$ECCODES_SAMPLES_PATH/reduced_gg_pl_48_grib2.tmpl
${tools_dir}/grib_set -s shapeOfTheEarth=5 $sample2 $temp
grib_check_key_equals $sample2 earthIsOblate 0
grib_check_key_equals $temp earthIsOblate 1
${tools_dir}/grib_ls -l 0,0 $temp
# Clean up # Clean up
rm -f $temp $tempRef rm -f $temp $tempRef

View File

@ -59,7 +59,7 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef double (*compare_double_proc)(double*, double*, double*); typedef double (*compare_double_proc)(const double*, const double*, const double*);
typedef struct grib_error grib_error; typedef struct grib_error grib_error;
struct grib_error struct grib_error
@ -136,7 +136,7 @@ static void release_keys_list()
} }
} }
GRIB_INLINE static double compare_double_absolute(double* a, double* b, double* err) GRIB_INLINE static double compare_double_absolute(const double* a, const double* b, const double* err)
{ {
double ret = 0; double ret = 0;
double d = fabs(*a - *b); double d = fabs(*a - *b);
@ -183,7 +183,7 @@ static void write_messages(grib_handle* handle1, grib_handle* handle2)
write_message(handle2, "error2"); write_message(handle2, "error2");
} }
static double compare_double_relative(double* a, double* b, double* err) static double compare_double_relative(const double* a, const double* b, const double* err)
{ {
double relativeError; double relativeError;

View File

@ -46,7 +46,7 @@ const char* tool_description =
const char* tool_name = "grib_compare"; const char* tool_name = "grib_compare";
const char* tool_usage = "[options] grib_file1 grib_file2"; const char* tool_usage = "[options] grib_file1 grib_file2";
typedef double (*compare_double_proc)(double*, double*, double); typedef double (*compare_double_proc)(const double*, const double*, double);
static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_options* options); static int compare_handles(grib_handle* h1, grib_handle* h2, grib_runtime_options* options);
typedef struct grib_error grib_error; typedef struct grib_error grib_error;
@ -124,7 +124,7 @@ GRIB_INLINE static int grib_inline_rstrcmp(const char* a, const char* b)
} }
/* Returns 0 when the values are considered the same */ /* Returns 0 when the values are considered the same */
static double compare_double_absolute(double* a, double* b, double tolerance) static double compare_double_absolute(const double* a, const double* b, double tolerance)
{ {
double ret = 0; double ret = 0;
double d = fabs(*a - *b); double d = fabs(*a - *b);
@ -136,7 +136,7 @@ static double compare_double_absolute(double* a, double* b, double tolerance)
} }
/* Returns 0 when the values are considered the same */ /* Returns 0 when the values are considered the same */
static double compare_double_relative(double* a, double* b, double tolerance) static double compare_double_relative(const double* a, const double* b, double tolerance)
{ {
double relativeError; double relativeError;

View File

@ -60,7 +60,7 @@ GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
return (*a == 0 && *b == 0) ? 0 : 1; return (*a == 0 && *b == 0) ? 0 : 1;
} }
typedef double (*compare_double_proc)(double*, double*, double*); typedef double (*compare_double_proc)(const double*, const double*, const double*);
typedef struct grib_error grib_error; typedef struct grib_error grib_error;
struct grib_error struct grib_error
@ -97,7 +97,7 @@ static int start = -1;
static int end = -1; static int end = -1;
static int write_count = 0; static int write_count = 0;
GRIB_INLINE static double compare_double_absolute(double* a, double* b, double* err) GRIB_INLINE static double compare_double_absolute(const double* a, const double* b, const double* err)
{ {
double ret = 0; double ret = 0;
double d = fabs(*a - *b); double d = fabs(*a - *b);
@ -144,7 +144,7 @@ static void write_messages(grib_handle* h1, grib_handle* h2)
write_message(h2, "error2"); write_message(h2, "error2");
} }
static double compare_double_relative(double* a, double* b, double* err) static double compare_double_relative(const double* a, const double* b, const double* err)
{ {
double relativeError; double relativeError;