mirror of https://github.com/ecmwf/eccodes.git
Dead code removal
This commit is contained in:
parent
f7c5c47e94
commit
546f1d8cf3
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Enrico Fucile - 19.06.2007 *
|
* Enrico Fucile - 19.06.2007 *
|
||||||
* *
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "grib_bits_any_endian_simple.h"
|
#include "grib_bits_any_endian_simple.h"
|
||||||
|
@ -84,7 +83,7 @@ int grib_decode_long_array(const unsigned char* p, long* bitp, long bitsPerValue
|
||||||
// unsigned long lvalue = 0;
|
// unsigned long lvalue = 0;
|
||||||
// double x;
|
// double x;
|
||||||
|
|
||||||
//#if 0
|
//#if OLD_REF_CODE
|
||||||
// [> slow reference code <]
|
// [> slow reference code <]
|
||||||
// int j=0;
|
// int j=0;
|
||||||
// for(i=0;i < n_vals;i++) {
|
// for(i=0;i < n_vals;i++) {
|
||||||
|
|
|
@ -191,34 +191,31 @@ static void binary_search_gaussian_latitudes(const double array[], const unsigne
|
||||||
*j = -1; /* Not found */
|
*j = -1; /* Not found */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
// static void binary_search_old(const double xx[], const unsigned long n, double x, long* j)
|
||||||
static void binary_search_old(const double xx[], const unsigned long n, double x, long* j)
|
// {
|
||||||
{
|
// /*This routine works only on descending ordered arrays*/
|
||||||
/*This routine works only on descending ordered arrays*/
|
// unsigned long ju, jm, jl;
|
||||||
unsigned long ju, jm, jl;
|
// jl = 0;
|
||||||
jl = 0;
|
// ju = n;
|
||||||
ju = n;
|
// if (fabs(x - xx[0]) < EPSILON) {
|
||||||
if (fabs(x - xx[0]) < EPSILON) {
|
// *j = 0;
|
||||||
*j = 0;
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
// if (fabs(x - xx[n]) < EPSILON) {
|
||||||
if (fabs(x - xx[n]) < EPSILON) {
|
// *j = n;
|
||||||
*j = n;
|
// return;
|
||||||
return;
|
// }
|
||||||
}
|
// while (ju - jl > 1) {
|
||||||
|
// jm = (ju + jl) >> 1;
|
||||||
while (ju - jl > 1) {
|
// if (fabs(x - xx[jm]) < EPSILON) {
|
||||||
jm = (ju + jl) >> 1;
|
// /* found something close enough. We're done */
|
||||||
if (fabs(x - xx[jm]) < EPSILON) {
|
// *j = jm;
|
||||||
/* found something close enough. We're done */
|
// return;
|
||||||
*j = jm;
|
// }
|
||||||
return;
|
// if (x < xx[jm])
|
||||||
}
|
// jl = jm;
|
||||||
if (x < xx[jm])
|
// else
|
||||||
jl = jm;
|
// ju = jm;
|
||||||
else
|
// }
|
||||||
ju = jm;
|
// *j = jl;
|
||||||
}
|
// }
|
||||||
*j = jl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -208,26 +208,20 @@ static void* fast_realloc(void* p, size_t s, mempool* pool)
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
/*
|
||||||
void fast_memory_info(const char *title,mempool *pool)
|
void fast_memory_info(const char *title,mempool *pool) {
|
||||||
{
|
|
||||||
memblk *m = (memblk*)pool->priv;
|
memblk *m = (memblk*)pool->priv;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
while(m)
|
while(m) {
|
||||||
{
|
|
||||||
count++;
|
count++;
|
||||||
size += m->size;
|
size += m->size;
|
||||||
m = m->next;
|
m = m->next;
|
||||||
}
|
}
|
||||||
marslog(LOG_INFO,"%s : %sbytes %d blocks",
|
marslog(LOG_INFO,"%s : %sbytes %d blocks", title, bytename(size),count);
|
||||||
title,
|
|
||||||
bytename(size),count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void memory_info()
|
void memory_info() {
|
||||||
{
|
|
||||||
memblk *r = reserve;
|
memblk *r = reserve;
|
||||||
long size = 0;
|
long size = 0;
|
||||||
while(r)
|
while(r)
|
||||||
|
@ -237,13 +231,11 @@ static void* fast_realloc(void* p, size_t s, mempool* pool)
|
||||||
size += r->size;
|
size += r->size;
|
||||||
r = r->next;
|
r = r->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
marslog(LOG_INFO,"Total large : %sbytes",bytename(size));
|
marslog(LOG_INFO,"Total large : %sbytes",bytename(size));
|
||||||
fast_memory_info("Transient memory",transient_mem);
|
fast_memory_info("Transient memory",transient_mem);
|
||||||
fast_memory_info("Permanent memory",permanent_mem);
|
fast_memory_info("Permanent memory",permanent_mem);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
#endif
|
|
||||||
|
|
||||||
void* grib_transient_malloc(const grib_context* c, size_t s)
|
void* grib_transient_malloc(const grib_context* c, size_t s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,15 +158,15 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una
|
||||||
else if (uname[i] == '[')
|
else if (uname[i] == '[')
|
||||||
mode = 0;
|
mode = 0;
|
||||||
else {
|
else {
|
||||||
#if 0
|
// Old way: Slow; The strlen cost is too high
|
||||||
int llen=strlen(fname); /* The strlen cost is too high */
|
//int llen=strlen(fname);
|
||||||
fname[llen]=uname[i];
|
//fname[llen]=uname[i];
|
||||||
fname[llen+1]='\0';
|
//fname[llen+1]='\0';
|
||||||
#else
|
|
||||||
/* Performance: faster to avoid call to strlen. Append to end */
|
// Faster to avoid call to strlen. Append to end
|
||||||
*ptrEnd_fname++ = uname[i];
|
*ptrEnd_fname++ = uname[i];
|
||||||
*ptrEnd_fname = '\0';
|
*ptrEnd_fname = '\0';
|
||||||
#endif
|
|
||||||
type = GRIB_TYPE_STRING;
|
type = GRIB_TYPE_STRING;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -175,131 +175,129 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
// int grib_accessor_print(grib_accessor* a, const char* name, int type, const char* format,
|
||||||
int grib_accessor_print(grib_accessor* a, const char* name, int type, const char* format,
|
// const char* separator, int maxcols, int* newline, FILE* out)
|
||||||
const char* separator, int maxcols, int* newline, FILE* out)
|
// {
|
||||||
{
|
// size_t size = 0;
|
||||||
size_t size = 0;
|
// char* sval = NULL;
|
||||||
char* sval = NULL;
|
// char* p = NULL;
|
||||||
char* p = NULL;
|
// double* dval = 0;
|
||||||
double* dval = 0;
|
// long* lval = 0;
|
||||||
long* lval = 0;
|
// char sbuf[1024] = {0,};
|
||||||
char sbuf[1024] = {0,};
|
// size_t replen = 0;
|
||||||
size_t replen = 0;
|
// int ret = 0;
|
||||||
int ret = 0;
|
// char* myformat = NULL;
|
||||||
char* myformat = NULL;
|
// char* myseparator = NULL;
|
||||||
char* myseparator = NULL;
|
// char double_format[] = "%.12g"; /* default format for printing double keys */
|
||||||
char double_format[] = "%.12g"; /* default format for printing double keys */
|
// char long_format[] = "%ld"; /* default format for printing integer keys */
|
||||||
char long_format[] = "%ld"; /* default format for printing integer keys */
|
// char default_separator[] = " ";
|
||||||
char default_separator[] = " ";
|
// grib_handle* h = grib_handle_of_accessor(a);
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
|
||||||
|
|
||||||
if (type == -1)
|
// if (type == -1)
|
||||||
type = grib_accessor_get_native_type(a);
|
// type = grib_accessor_get_native_type(a);
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case GRIB_TYPE_STRING:
|
// case GRIB_TYPE_STRING:
|
||||||
replen = sizeof(sbuf) / sizeof(*sbuf);
|
// replen = sizeof(sbuf) / sizeof(*sbuf);
|
||||||
ret = grib_unpack_string(a, sbuf, &replen);
|
// ret = grib_unpack_string(a, sbuf, &replen);
|
||||||
fprintf(out, "%s", sbuf);
|
// fprintf(out, "%s", sbuf);
|
||||||
break;
|
// break;
|
||||||
case GRIB_TYPE_DOUBLE:
|
// case GRIB_TYPE_DOUBLE:
|
||||||
myformat = format ? (char*)format : double_format;
|
// myformat = format ? (char*)format : double_format;
|
||||||
myseparator = separator ? (char*)separator : default_separator;
|
// myseparator = separator ? (char*)separator : default_separator;
|
||||||
if (name[0] == '/' || name[0] == '#') {
|
// if (name[0] == '/' || name[0] == '#') {
|
||||||
long count;
|
// long count;
|
||||||
ret = grib_value_count(a, &count);
|
// ret = grib_value_count(a, &count);
|
||||||
size = count;
|
// size = count;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
ret = ecc__grib_get_size(h, a, &size);
|
// ret = ecc__grib_get_size(h, a, &size);
|
||||||
}
|
// }
|
||||||
if (ret) return ret;
|
// if (ret) return ret;
|
||||||
dval = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size);
|
// dval = (double*)grib_context_malloc_clear(h->context, sizeof(double) * size);
|
||||||
if (name[0] == '/' || name[0] == '#') {
|
// if (name[0] == '/' || name[0] == '#') {
|
||||||
replen = size;
|
// replen = size;
|
||||||
ret = grib_unpack_double(a, dval, &replen);
|
// ret = grib_unpack_double(a, dval, &replen);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
replen = 0;
|
// replen = 0;
|
||||||
ret = ecc__grib_get_double_array_internal(h, a, dval, size, &replen);
|
// ret = ecc__grib_get_double_array_internal(h, a, dval, size, &replen);
|
||||||
}
|
// }
|
||||||
if (replen == 1)
|
// if (replen == 1)
|
||||||
fprintf(out, myformat, dval[0]);
|
// fprintf(out, myformat, dval[0]);
|
||||||
else {
|
// else {
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
int cols = 0;
|
// int cols = 0;
|
||||||
for (i = 0; i < replen; i++) {
|
// for (i = 0; i < replen; i++) {
|
||||||
*newline = 1;
|
// *newline = 1;
|
||||||
fprintf(out, myformat, dval[i]);
|
// fprintf(out, myformat, dval[i]);
|
||||||
if (i < replen - 1)
|
// if (i < replen - 1)
|
||||||
fprintf(out, "%s", myseparator);
|
// fprintf(out, "%s", myseparator);
|
||||||
cols++;
|
// cols++;
|
||||||
if (cols >= maxcols) {
|
// if (cols >= maxcols) {
|
||||||
fprintf(out, "\n");
|
// fprintf(out, "\n");
|
||||||
*newline = 1;
|
// *newline = 1;
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
grib_context_free(h->context, dval);
|
// grib_context_free(h->context, dval);
|
||||||
break;
|
// break;
|
||||||
case GRIB_TYPE_LONG:
|
// case GRIB_TYPE_LONG:
|
||||||
myformat = format ? (char*)format : long_format;
|
// myformat = format ? (char*)format : long_format;
|
||||||
myseparator = separator ? (char*)separator : default_separator;
|
// myseparator = separator ? (char*)separator : default_separator;
|
||||||
if (name[0] == '/' || name[0] == '#') {
|
// if (name[0] == '/' || name[0] == '#') {
|
||||||
long count;
|
// long count;
|
||||||
ret = grib_value_count(a, &count);
|
// ret = grib_value_count(a, &count);
|
||||||
size = count;
|
// size = count;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
ret = ecc__grib_get_size(h, a, &size);
|
// ret = ecc__grib_get_size(h, a, &size);
|
||||||
}
|
// }
|
||||||
if (ret) return ret;
|
// if (ret) return ret;
|
||||||
lval = (long*)grib_context_malloc_clear(h->context, sizeof(long) * size);
|
// lval = (long*)grib_context_malloc_clear(h->context, sizeof(long) * size);
|
||||||
if (name[0] == '/' || name[0] == '#') {
|
// if (name[0] == '/' || name[0] == '#') {
|
||||||
replen = size;
|
// replen = size;
|
||||||
ret = grib_unpack_long(a, lval, &replen);
|
// ret = grib_unpack_long(a, lval, &replen);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
replen = 0;
|
// replen = 0;
|
||||||
ret = ecc__grib_get_long_array_internal(h, a, lval, size, &replen);
|
// ret = ecc__grib_get_long_array_internal(h, a, lval, size, &replen);
|
||||||
}
|
// }
|
||||||
if (replen == 1)
|
// if (replen == 1)
|
||||||
fprintf(out, myformat, lval[0]);
|
// fprintf(out, myformat, lval[0]);
|
||||||
else {
|
// else {
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
int cols = 0;
|
// int cols = 0;
|
||||||
for (i = 0; i < replen; i++) {
|
// for (i = 0; i < replen; i++) {
|
||||||
*newline = 1;
|
// *newline = 1;
|
||||||
fprintf(out, myformat, lval[i]);
|
// fprintf(out, myformat, lval[i]);
|
||||||
if (i < replen - 1)
|
// if (i < replen - 1)
|
||||||
fprintf(out, "%s", myseparator);
|
// fprintf(out, "%s", myseparator);
|
||||||
cols++;
|
// cols++;
|
||||||
if (cols >= maxcols) {
|
// if (cols >= maxcols) {
|
||||||
fprintf(out, "\n");
|
// fprintf(out, "\n");
|
||||||
*newline = 1;
|
// *newline = 1;
|
||||||
cols = 0;
|
// cols = 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
grib_context_free(h->context, lval);
|
// grib_context_free(h->context, lval);
|
||||||
break;
|
// break;
|
||||||
case GRIB_TYPE_BYTES:
|
// case GRIB_TYPE_BYTES:
|
||||||
replen = a->length;
|
// replen = a->length;
|
||||||
sval = (char*)grib_context_malloc(h->context, replen * sizeof(char));
|
// sval = (char*)grib_context_malloc(h->context, replen * sizeof(char));
|
||||||
ret = grib_unpack_string(a, sval, &replen);
|
// ret = grib_unpack_string(a, sval, &replen);
|
||||||
p = sval;
|
// p = sval;
|
||||||
while ((replen--) > 0)
|
// while ((replen--) > 0)
|
||||||
fprintf(out, "%c", *(p++));
|
// fprintf(out, "%c", *(p++));
|
||||||
grib_context_free(h->context, sval);
|
// grib_context_free(h->context, sval);
|
||||||
*newline = 0;
|
// *newline = 0;
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
grib_context_log(h->context, GRIB_LOG_WARNING, "grib_accessor_print: Problem to print \"%s\", invalid type %d", a->name, type);
|
// grib_context_log(h->context, GRIB_LOG_WARNING, "grib_accessor_print: Problem to print \"%s\", invalid type %d", a->name, type);
|
||||||
}
|
// }
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
// }
|
||||||
#endif
|
|
||||||
|
|
||||||
int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const char* name,
|
int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const char* name,
|
||||||
int type, const char* format, const char* separator, int maxcols, int* newline, FILE* out)
|
int type, const char* format, const char* separator, int maxcols, int* newline, FILE* out)
|
||||||
|
|
Loading…
Reference in New Issue