Commit 10839ee5 authored by Florian Prill's avatar Florian Prill
Browse files

[cdi-tiles] Made branch compile again after merge from trunk.

parent ed7475ba
......@@ -422,6 +422,7 @@ int cdiUUIDIsNull(const unsigned char* uuid)
return !memcmp(uuid, uuid_nil, CDI_UUID_SIZE);
}
/*
* Local Variables:
* c-file-style: "Java"
......@@ -431,3 +432,4 @@ int cdiUUIDIsNull(const unsigned char* uuid)
* require-trailing-newline: t
* End:
*/
......@@ -400,11 +400,7 @@ void cdiInitialize(void);
void uuid2str(const unsigned char *uuid, char *uuidstr);
int str2uuid(const char *uuidstr, unsigned char *uuid);
static inline int cdiUUIDIsNull(const unsigned char uuid[CDI_UUID_SIZE])
{
static const unsigned char uuid_nil[CDI_UUID_SIZE];
return !memcmp(uuid, uuid_nil, CDI_UUID_SIZE);
}
int cdiUUIDIsNull(const unsigned char *uuid);
char* cdiEscapeSpaces(const char* string);
char* cdiUnescapeSpaces(const char* string, const char** outStringEnd);
......
......@@ -8,6 +8,10 @@
#endif
#endif
#ifndef _CDI_INT_H
#include "cdi_int.h"
#endif
#define GRIBAPI_MISSVAL -9.E33
/* GRIB2 Level Types */
......
......@@ -16,6 +16,10 @@
#include "resource_unpack.h"
#include "namespace.h"
#include "serialize.h"
#include "vlist.h"
#undef UNDEFID
#define UNDEFID -1
#ifndef RAD2DEG
#define RAD2DEG (180./M_PI) /* conversion for rad to deg */
......@@ -4440,6 +4444,83 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
#undef GRID_STR_SERIALIZE
struct varDefGridSearchState
{
int resIDValue;
const grid_t *queryKey;
};
static enum cdiApplyRet
varDefGridSearch(int id, void *res, void *data)
{
struct varDefGridSearchState *state = data;
(void)res;
if (gridCompare(id, state->queryKey) == 0)
{
state->resIDValue = id;
return CDI_APPLY_STOP;
}
else
return CDI_APPLY_GO_ON;
}
int varDefGrid(int vlistID, const grid_t *grid, int mode)
{
/*
mode: 0 search in vlist and grid table
1 search in grid table
*/
int gridglobdefined = FALSE;
int griddefined;
int gridID = CDI_UNDEFID;
vlist_t *vlistptr = vlist_to_pointer(vlistID);
griddefined = FALSE;
unsigned ngrids = (unsigned)vlistptr->ngrids;
if ( mode == 0 )
for (unsigned index = 0; index < ngrids; index++ )
{
gridID = vlistptr->gridIDs[index];
if ( gridID == UNDEFID )
Error("Internal problem: undefined gridID %d!", gridID);
if ( gridCompare(gridID, grid) == 0 )
{
griddefined = TRUE;
break;
}
}
if ( ! griddefined )
{
struct varDefGridSearchState query = { .queryKey = grid };
if ((gridglobdefined
= (cdiResHFilterApply(&gridOps, varDefGridSearch, &query)
== CDI_APPLY_STOP)))
gridID = query.resIDValue;
if ( mode == 1 && gridglobdefined)
for (unsigned index = 0; index < ngrids; index++ )
if ( vlistptr->gridIDs[index] == gridID )
{
gridglobdefined = FALSE;
break;
}
}
if ( ! griddefined )
{
if ( ! gridglobdefined ) gridID = gridGenerate(grid);
ngrids = (unsigned)vlistptr->ngrids;
vlistptr->gridIDs[ngrids] = gridID;
vlistptr->ngrids++;
}
return (gridID);
}
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -95,6 +95,8 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
int * unpackBufferPos, int originNamespace, void *context,
int force_id);
int varDefGrid(int vlistID, const grid_t *grid, int mode);
#endif
/*
* Local Variables:
......
......@@ -649,7 +649,7 @@ void cdi_generate_vars(stream_t *streamptr)
{
fprintf(stderr, "var \"%s\": isub = %d / %d :: "
"nlevels = %d, vartable[varid].recordTable[isub].nlevels = %d\n",
vartable[varID].name, isub, vartable[varid].nsubtypes,
vartable[varid].name, isub, vartable[varid].nsubtypes,
nlevels, vartable[varid].recordTable[isub].nlevels);
Error("zaxis size must not change for same parameter!");
}
......@@ -898,82 +898,6 @@ void varDefZAxisReference(int nhlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZ
memcpy(uuidVGrid, uuid, CDI_UUID_SIZE);
}
struct varDefGridSearchState
{
int resIDValue;
const grid_t *queryKey;
};
static enum cdiApplyRet
varDefGridSearch(int id, void *res, void *data)
{
struct varDefGridSearchState *state = data;
(void)res;
if (gridCompare(id, state->queryKey) == 0)
{
state->resIDValue = id;
return CDI_APPLY_STOP;
}
else
return CDI_APPLY_GO_ON;
}
int varDefGrid(int vlistID, const grid_t *grid, int mode)
{
/*
mode: 0 search in vlist and grid table
1 search in grid table
*/
int gridglobdefined = FALSE;
int griddefined;
int gridID = CDI_UNDEFID;
vlist_t *vlistptr = vlist_to_pointer(vlistID);
griddefined = FALSE;
unsigned ngrids = (unsigned)vlistptr->ngrids;
if ( mode == 0 )
for (unsigned index = 0; index < ngrids; index++ )
{
gridID = vlistptr->gridIDs[index];
if ( gridID == UNDEFID )
Error("Internal problem: undefined gridID %d!", gridID);
if ( gridCompare(gridID, grid) == 0 )
{
griddefined = TRUE;
break;
}
}
if ( ! griddefined )
{
struct varDefGridSearchState query = { .queryKey = grid };
if ((gridglobdefined
= (cdiResHFilterApply(&gridOps, varDefGridSearch, &query)
== CDI_APPLY_STOP)))
gridID = query.resIDValue;
if ( mode == 1 && gridglobdefined)
for (unsigned index = 0; index < ngrids; index++ )
if ( vlistptr->gridIDs[index] == gridID )
{
gridglobdefined = FALSE;
break;
}
}
if ( ! griddefined )
{
if ( ! gridglobdefined ) gridID = gridGenerate(grid);
ngrids = (unsigned)vlistptr->ngrids;
vlistptr->gridIDs[ngrids] = gridID;
vlistptr->ngrids++;
}
return (gridID);
}
int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, char *longname, char *units, int ltype1)
{
......
......@@ -15,7 +15,6 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
void varDefVCT(size_t vctsize, double *vctptr);
void varDefZAxisReference(int nlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZE]);
int varDefGrid(int vlistID, const grid_t *grid, int mode);
int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbounds,
double *levels1, double *levels2, int vctsize, double *vct, char *name,
char *longname, char *units, int prec, int mode, int ltype);
......
......@@ -289,29 +289,16 @@ void var_copy_entries(var_t *var2, var_t *var1)
memcpy(var2->ensdata, var1->ensdata, sizeof(ensinfo_t));
}
#if defined (HAVE_LIBGRIB_API)
/* ---------------------------------- */
/* Local change: 2013-01-28, FP (DWD) */
/* ---------------------------------- */
var2->opt_grib_int_nentries = var1->opt_grib_int_nentries;
for ( int i = 0; i < var1->opt_grib_int_nentries; i++ )
{
if ( var1->opt_grib_int_keyword[i] )
{
var2->opt_grib_int_keyword[i] = strdupx(var1->opt_grib_int_keyword[i]);
var2->opt_grib_int_val[i] = var1->opt_grib_int_val[i];
var2->opt_grib_int_update[i] = TRUE;
}
}
var2->opt_grib_dbl_nentries = var1->opt_grib_dbl_nentries;
for ( int i = 0; i < var1->opt_grib_dbl_nentries; i++ )
{
if ( var1->opt_grib_dbl_keyword[i] )
{
var2->opt_grib_dbl_keyword[i] = strdupx(var1->opt_grib_dbl_keyword[i]);
var2->opt_grib_dbl_val[i] = var1->opt_grib_dbl_val[i];
var2->opt_grib_dbl_update[i] = TRUE;
}
var2->opt_grib_nentries = var1->opt_grib_nentries;
for (int i=0; i<var1->opt_grib_nentries; i++) {
if ( var1->opt_grib_kvpair[i].keyword ) {
var2->opt_grib_kvpair[i] =
var1->opt_grib_kvpair[i];
var2->opt_grib_kvpair[i].keyword =
strdupx(var1->opt_grib_kvpair[i].keyword);
var2->opt_grib_kvpair[i].update = TRUE;
}
}
#endif
}
......
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