mirror of https://github.com/ecmwf/eccodes.git
Enable single-Precision
This commit is contained in:
parent
8e9e9c59ce
commit
85e6d58a6a
|
@ -2783,38 +2783,41 @@ int grib_f_get_real4(int* gid, char* key, float* val, int len){
|
|||
|
||||
int grib_f_get_real4_array_(int* gid, char* key, float *val, int* size, int len)
|
||||
{
|
||||
/* See ECC-1579:
|
||||
* Ideally we should be calling:
|
||||
* err = grib_get_float_array(h, cast_char(buf,key,len), val, &lsize);
|
||||
*
|
||||
*/
|
||||
|
||||
/*See ECC-1579:*/
|
||||
/*Ideally we should be calling:*/
|
||||
|
||||
size_t lsize = *size;
|
||||
char buf[1024];
|
||||
grib_handle *h = get_handle(*gid);
|
||||
int err = GRIB_SUCCESS;
|
||||
char buf[1024];
|
||||
size_t lsize = *size;
|
||||
double* val8 = NULL;
|
||||
size_t i;
|
||||
err = grib_get_float_array(h, cast_char(buf,key,len), val, &lsize);
|
||||
|
||||
if(!h) return GRIB_INVALID_GRIB;
|
||||
/*grib_handle *h = get_handle(*gid);*/
|
||||
/*int err = GRIB_SUCCESS;*/
|
||||
/*char buf[1024];*/
|
||||
/*size_t lsize = *size;*/
|
||||
/*double* val8 = NULL;*/
|
||||
/*size_t i;*/
|
||||
|
||||
if(*size)
|
||||
val8 = (double*)grib_context_malloc(h->context,(*size)*(sizeof(double)));
|
||||
else
|
||||
val8 = (double*)grib_context_malloc(h->context,sizeof(double));
|
||||
/*if(!h) return GRIB_INVALID_GRIB;*/
|
||||
|
||||
if(!val8) return GRIB_OUT_OF_MEMORY;
|
||||
/*if(*size)*/
|
||||
/* val8 = (double*)grib_context_malloc(h->context,(*size)*(sizeof(double)));*/
|
||||
/*else*/
|
||||
/* val8 = (double*)grib_context_malloc(h->context,sizeof(double));*/
|
||||
|
||||
err = grib_get_double_array(h, cast_char(buf,key,len), val8, &lsize);
|
||||
if (err) {
|
||||
grib_context_free(h->context,val8);
|
||||
return err;
|
||||
}
|
||||
/*if(!val8) return GRIB_OUT_OF_MEMORY;*/
|
||||
|
||||
for(i=0;i<lsize;i++)
|
||||
val[i] = val8[i];
|
||||
/*err = grib_get_double_array(h, cast_char(buf,key,len), val8, &lsize);*/
|
||||
/*if (err) {*/
|
||||
/* grib_context_free(h->context,val8);*/
|
||||
/* return err;*/
|
||||
/*}*/
|
||||
|
||||
grib_context_free(h->context,val8);
|
||||
/*for(i=0;i<lsize;i++)*/
|
||||
/* val[i] = val8[i];*/
|
||||
|
||||
/*grib_context_free(h->context,val8);*/
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -3157,6 +3160,7 @@ int grib_f_get_real8_array_(int* gid, char* key, double*val, int* size, int len)
|
|||
return GRIB_INVALID_GRIB;
|
||||
}else{
|
||||
err = grib_get_double_array(h, cast_char(buf,key,len), val, &lsize);
|
||||
printf("%30s - %0.60f\n", __PRETTY_FUNCTION__, val[40]);
|
||||
*size = lsize;
|
||||
return err;
|
||||
}
|
||||
|
@ -3166,6 +3170,7 @@ int grib_f_get_real8_array__(int* gid, char* key, double*val, int* size, int len
|
|||
}
|
||||
int grib_f_get_real8_array(int* gid, char* key, double*val, int* size, int len){
|
||||
return grib_f_get_real8_array_( gid, key, val, size, len);
|
||||
printf("%s - %0.60f\n", __PRETTY_FUNCTION__, val[40]);
|
||||
}
|
||||
|
||||
int grib_f_set_force_real8_array__(int* gid, char* key, double *val, int* size, int len){
|
||||
|
|
|
@ -755,6 +755,7 @@ static int unpack(grib_accessor* a, T* val, size_t* len)
|
|||
|
||||
if ((ret = grib_get_double_internal(gh, self->laplacianOperator, &laplacianOperator)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if ((ret = grib_get_long_internal(gh, self->sub_j, &sub_j)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(gh, self->sub_k, &sub_k)) != GRIB_SUCCESS)
|
||||
|
@ -905,24 +906,24 @@ static int unpack_float(grib_accessor* a, float* val, size_t* len)
|
|||
// TODO(maee): See ECC-1579
|
||||
// Investigate why results are not bit-identical
|
||||
|
||||
// return unpack<float>(a, val, len);
|
||||
return unpack<float>(a, val, len);
|
||||
|
||||
int err = 0;
|
||||
size_t i = 0;
|
||||
size_t size = *len;
|
||||
double* val8 = NULL;
|
||||
val8 = (double*)grib_context_malloc(a->context, size*(sizeof(double)));
|
||||
if (!val8)
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
err = unpack<double>(a, val8, len);
|
||||
if (err) {
|
||||
grib_context_free(a->context,val8);
|
||||
return err;
|
||||
}
|
||||
//int err = 0;
|
||||
//size_t i = 0;
|
||||
//size_t size = *len;
|
||||
//double* val8 = NULL;
|
||||
//val8 = (double*)grib_context_malloc(a->context, size*(sizeof(double)));
|
||||
//if (!val8)
|
||||
// return GRIB_OUT_OF_MEMORY;
|
||||
//err = unpack<double>(a, val8, len);
|
||||
//if (err) {
|
||||
// grib_context_free(a->context,val8);
|
||||
// return err;
|
||||
//}
|
||||
|
||||
for(i=0; i<size; i++)
|
||||
val[i] = val8[i];
|
||||
grib_context_free(a->context,val8);
|
||||
//for(i=0; i<size; i++)
|
||||
// val[i] = val8[i];
|
||||
//grib_context_free(a->context,val8);
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue