Commit 119b1a0c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

grbEncode: convert float array to tmp double array

parent 0241edb6
......@@ -38,33 +38,43 @@ size_t grbEncode(int filetype, int memtype, int varID, int levelID, int vlistID,
#endif
#ifdef HAVE_LIBGRIB_API
{
if ( memtype == MEMTYPE_FLOAT ) Error("gribapiEncode() not implemented for memtype float!");
const void *datap = data;
if ( memtype == MEMTYPE_FLOAT )
{
const float *dataf = (const float*) data;
double *datad = (double*) Malloc(datasize*sizeof(double));
for ( size_t i = 0; i < datasize; ++i ) datad[i] = (double) dataf[i];
datap = (const void*) datad;
}
size_t gribbuffersize;
nbytes = gribapiEncode(varID, levelID, vlistID, gridID, zaxisID,
date, time, tsteptype, numavg,
(long)datasize, data, nmiss, gribbuffer, &gribbuffersize,
comptype, gribContainer);
if ( memtype == MEMTYPE_FLOAT ) free((void*)datap);
}
#else
Error("GRIB_API support not compiled in!");
(void)gribContainer;
(void)comptype;
{
Error("GRIB_API support not compiled in!");
(void)gribContainer;
(void)comptype;
}
#endif
return nbytes;
}
static
size_t grbSzip(int filetype, void *gribbuffer, size_t gribbuffersize)
{
size_t nbytes = 0;
size_t buffersize = gribbuffersize + 1000; /* compressed record can be greater than source record */
void *buffer = Malloc(buffersize);
void *buffer = Malloc(buffersize);
/* memcpy(buffer, gribbuffer, gribbuffersize); */
size_t nbytes = 0;
if ( filetype == FILETYPE_GRB )
{
nbytes = (size_t)gribZip(gribbuffer, (long) gribbuffersize, buffer, (long) buffersize);
......
......@@ -4,7 +4,6 @@
#include <limits.h>
#include <stdio.h>
// #include <float.h> /* FLT_EPSILON */
#include "dmemory.h"
#include "cdi.h"
......@@ -1721,8 +1720,6 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
ISEC2_LonIncr = (int)lround(xinc*1000);
}
// if ( fabs(xinc*1000 - ISEC2_LonIncr) > FLT_EPSILON ) ISEC2_LonIncr = 0;
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
{
int np = gridInqNP(gridID);
......@@ -1732,8 +1729,6 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
else
{
ISEC2_LatIncr = (int)lround(yinc*1000);
// if ( fabs(yinc*1000 - ISEC2_LatIncr) > FLT_EPSILON ) ISEC2_LatIncr = 0;
if ( ISEC2_LatIncr < 0 ) ISEC2_LatIncr = -ISEC2_LatIncr;
}
......@@ -2123,9 +2118,7 @@ void cgribexDefaultSec1(int *isec1)
static
void cgribexDefaultSec4(int *isec4)
{
long i;
for ( i = 2; i <= 10; ++i ) isec4[i] = 0;
for ( int i = 2; i <= 10; ++i ) isec4[i] = 0;
}
static
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment