Commit c2ce442d authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

merged trunk into cdi_conversion_c++ and changed type of len in function...

merged trunk into cdi_conversion_c++ and changed type of len in function serializeStrTabGetSize() to int, removed anonymous function in serializeStrTabGetSize() and replaced it with &len
parent 858666a9
......@@ -516,7 +516,7 @@ int vlistInqModel(int vlistID);
/* VLIST VAR routines */
/* vlistDefVar: Create a new tile-based variable */
/* vlistDefVarTiles: Create a new tile-based variable */
int vlistDefVarTiles(int vlistID, int gridID, int zaxisID, int tsteptype, int tilesetID);
/* vlistDefVar: Create a new variable */
......
......@@ -19,7 +19,7 @@ const char *cdiStringError(int cdiErrno)
switch (cdiErrno) {
case CDI_ESYSTEM:
{
char *cp = (char *) strerror(errno);
const char *cp = strerror(errno);
if ( cp == NULL ) break;
return cp;
}
......
......@@ -426,9 +426,6 @@ void zaxisGetIndexList(int nzaxis, int *zaxisIndexList);
void zaxisDefLtype2(int zaxisID, int ltype2);
int zaxisInqLtype2(int zaxisID);
void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
const char *container_name);
#endif /* _CDI_INT_H */
/*
* Local Variables:
......
! This file was automatically generated, don't edit!
!
! Fortran interface for CDI library version 1.6.8
! Fortran interface for CDI library version 1.7.0
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, March 2015
! Uwe Schulzweida, MPI-MET, Hamburg, June 2015
!
!
......
......@@ -5,8 +5,6 @@
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
#pragma GCC diagnostic push
#endif
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic warning "-Wstrict-overflow"
......@@ -12159,7 +12157,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
if ( sizeof(T) == sizeof(double) )
{
grib_encode_array_2byte_double(datasize, lGrib, (const double * restrict) data, zref, factor, &z);
grib_encode_array_2byte_double(datasize, lGrib, (const double *) data, zref, factor, &z);
}
else
{
......@@ -12630,7 +12628,7 @@ void TEMPLATE(encode_array,T)(int numBits, size_t packStart, size_t datasize,
if ( sizeof(T) == sizeof(double) )
{
grib_encode_array_2byte_double(datasize, lGrib, (const double * restrict) data, zref, factor, &z);
grib_encode_array_2byte_double(datasize, lGrib, (const double *) data, zref, factor, &z);
}
else
{
......
......@@ -76,7 +76,7 @@ grid_t;
void grid_init(grid_t *gridptr);
void grid_free(grid_t *gridptr);
int gridSize(void);
unsigned cdiGridCount(void);
const double *gridInqXvalsPtr(int gridID);
const double *gridInqYvalsPtr(int gridID);
......@@ -88,7 +88,7 @@ const double *gridInqAreaPtr(int gridID);
int gridCompare(int gridID, const grid_t *grid);
int gridGenerate(const grid_t *grid);
void gridGetIndexList( int, int * );
void cdiGridGetIndexList(unsigned, int * );
void
gridUnpack(char * unpackBuffer, int unpackBufferSize,
......
! >>> Warning: This is a generated file. If you modify it, you get what you deserve. <<<
!
! Generated by "../interfaces/f2003/bindGen.rb" from input file "../src/cdi.h".
! Generated by "interfaces/f2003/bindGen.rb" from input file "src/cdi.h".
module mo_cdi
use iso_c_binding
......
......@@ -95,64 +95,3 @@ void serializeUnpackInCore(const void *buf, int buf_size, int *position,
pos += size;
*position = pos;
}
/*
* (de-)marshalling function for common data structures
*/
inline int
serializeStrTabGetPackSize(const char **strTab, int numStr,
void *context)
{
xassert(numStr >= 0);
int packBuffSize = 0;
for (size_t i = 0; i < (size_t)numStr; ++i)
{
size_t len = strlen(strTab[i]);
packBuffSize +=
serializeGetSize(1, DATATYPE_INT, context)
+ serializeGetSize((int)len, DATATYPE_TXT, context);
}
packBuffSize +=
serializeGetSize(1, DATATYPE_UINT32, context);
return packBuffSize;
}
inline void
serializeStrTabPack(const char **strTab, int numStr,
void *buf, int buf_size, int *position, void *context)
{
uint32_t d = 0;
xassert(numStr >= 0);
for (size_t i = 0; i < (size_t)numStr; ++i)
{
int len = (int)strlen(strTab[i]);
serializePack(&len, 1, DATATYPE_INT,
buf, buf_size, position, context);
serializePack(strTab[i], len, DATATYPE_TXT,
buf, buf_size, position, context);
d ^= cdiCheckSum(DATATYPE_TXT, len, strTab[i]);
}
serializePack(&d, 1, DATATYPE_UINT32,
buf, buf_size, position, context);
}
inline void
serializeStrTabUnpack(const void *buf, int buf_size, int *position,
char **strTab, int numStr, void *context)
{
uint32_t d, d2 = 0;
xassert(numStr >= 0);
for (size_t i = 0; i < (size_t)numStr; ++i)
{
int len;
serializeUnpack(buf, buf_size, position,
&len, 1, DATATYPE_INT, context);
serializeUnpack(buf, buf_size, position,
strTab[i], len, DATATYPE_TXT, context);
strTab[i][len] = '\0';
d2 ^= cdiCheckSum(DATATYPE_TXT, (size_t)len, strTab[i]);
}
serializeUnpack(buf, buf_size, position,
&d, 1, DATATYPE_UINT32, context);
xassert(d == d2);
}
......@@ -27,17 +27,63 @@ void serializeUnpack(const void *buf, int buf_size, int *position,
/*
* (de-)marshalling function for common data structures
*/
int serializeStrTabGetPackSize(const char **strTab, int numStr, void *context);
static inline int
serializeStrTabGetPackSize(const char **strTab, int numStr,
void *context)
{
xassert(numStr >= 0);
int packBuffSize = 0;
for (size_t i = 0; i < (size_t)numStr; ++i)
{
size_t len = strlen(strTab[i]);
packBuffSize +=
serializeGetSize(1, DATATYPE_INT, context)
+ serializeGetSize((int)len, DATATYPE_TXT, context);
}
packBuffSize +=
serializeGetSize(1, DATATYPE_UINT32, context);
return packBuffSize;
}
static inline void
serializeStrTabPack(const char **strTab, int numStr,
void *buf, int buf_size, int *position, void *context)
{
uint32_t d = 0;
xassert(numStr >= 0);
for (size_t i = 0; i < (size_t)numStr; ++i)
{
int len = (int)strlen(strTab[i]);
serializePack(&len, 1, DATATYPE_INT,
buf, buf_size, position, context);
serializePack(strTab[i], len, DATATYPE_TXT,
buf, buf_size, position, context);
d ^= cdiCheckSum(DATATYPE_TXT, len, strTab[i]);
}
serializePack(&d, 1, DATATYPE_UINT32,
buf, buf_size, position, context);
}
void serializeStrTabPack(const char **strTab, int numStr,
void *buf, int buf_size, int *position, void *context);
void serializeStrTabUnpack(const void *buf, int buf_size, int *position,
char **strTab, int numStr, void *context);
static inline void
serializeStrTabUnpack(const void *buf, int buf_size, int *position,
char **strTab, int numStr, void *context)
{
uint32_t d, d2 = 0;
xassert(numStr >= 0);
for (size_t i = 0; i < (size_t)numStr; ++i)
{
int len;
serializeUnpack(buf, buf_size, position,
&len, 1, DATATYPE_INT, context);
serializeUnpack(buf, buf_size, position,
strTab[i], len, DATATYPE_TXT, context);
strTab[i][len] = '\0';
d2 ^= cdiCheckSum(DATATYPE_TXT, (size_t)len, strTab[i]);
}
serializeUnpack(buf, buf_size, position,
&d, 1, DATATYPE_UINT32, context);
xassert(d == d2);
}
/*
* Interfaces for marshalling within a single memory domain
......
......@@ -959,9 +959,8 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted)
}
void deallocate_sleveltable_t(sleveltable_t *entry)
static void deallocate_sleveltable_t(sleveltable_t *entry)
{
if (entry == NULL) return;
if (entry->recordID) free(entry->recordID);
if (entry->lindex) free(entry->lindex);
entry->recordID = NULL;
......@@ -1014,14 +1013,14 @@ void streamClose(int streamID)
for ( index = 0; index < streamptr->nvars; index++ )
{
for (int isub=0; isub<streamptr->vars[index].subtypeSize; isub++)
sleveltable_t *pslev = streamptr->vars[index].recordTable;
unsigned nsub = streamptr->vars[index].subtypeSize >= 0
? (unsigned)streamptr->vars[index].subtypeSize : 0U;
for (size_t isub=0; isub < nsub; isub++)
{
/* fprintf(stderr, "deallocate subtype %d / %d\n", */
/* isub+1, streamptr->vars[index].subtypeSize); */
deallocate_sleveltable_t(&streamptr->vars[index].recordTable[isub]);
deallocate_sleveltable_t(pslev + isub);
}
if (streamptr->vars[index].recordTable) free(streamptr->vars[index].recordTable);
streamptr->vars[index].recordTable = NULL;
if (pslev) free(pslev);
}
free(streamptr->vars);
streamptr->vars = NULL;
......
......@@ -7867,8 +7867,6 @@ int cdfInqContents(stream_t *streamptr)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
#pragma GCC diagnostic push
#endif
#ifdef __GNUC__
#pragma GCC diagnostic warning "-Wstrict-overflow"
#endif
if ( calendar != UNDEFID )
......
#ifndef STREAM_FCOMMON_H
#define STREAM_FCOMMON_H
#ifndef _CDI_INT_H
#include "cdi_int.h"
#endif
enum {
SINGLE_PRECISION = 4,
DOUBLE_PRECISION = 8,
};
void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
const char *container_name);
#endif
/*
......
......@@ -28,7 +28,7 @@
extern int cdiInventoryMode;
#if defined (HAVE_LIBGRIB_API)
static var_tile_t dummy_tiles = { -1, -1, -1, -1, -1, -1 };
static const var_tile_t dummy_tiles = { -1, -1, -1, -1, -1, -1 };
#endif
typedef struct {
......
......@@ -206,25 +206,17 @@ static
void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ysize,
size_t recsize, off_t position, int prec)
{
int leveltype;
int gridID = CDI_UNDEFID;
int levelID = 0;
int tsID, recID, varID;
int datatype;
record_t *record;
grid_t grid;
int vlistID;
vlistID = streamptr->vlistID;
tsID = streamptr->curTsID;
recID = recordNewEntry(streamptr, tsID);
record = &streamptr->tsteps[tsID].records[recID];
int vlistID = streamptr->vlistID;
int tsID = streamptr->curTsID;
int recID = recordNewEntry(streamptr, tsID);
record_t *record = &streamptr->tsteps[tsID].records[recID];
(*record).size = recsize;
(*record).position = position;
(*record).param = param;
(*record).ilevel = level;
record->size = recsize;
record->position = position;
record->param = param;
record->ilevel = level;
grid_t grid;
memset(&grid, 0, sizeof(grid_t));
grid.type = GRID_GENERIC;
grid.size = xsize*ysize;
......@@ -232,22 +224,24 @@ void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ys
grid.ysize = ysize;
grid.xvals = NULL;
grid.yvals = NULL;
gridID = varDefGrid(vlistID, &grid, 0);
int gridID = varDefGrid(vlistID, &grid, 0);
/*
if ( level == 0 ) leveltype = ZAXIS_SURFACE;
else leveltype = ZAXIS_GENERIC;
*/
leveltype = ZAXIS_GENERIC;
int leveltype = ZAXIS_GENERIC;
datatype = srvInqDatatype(prec);
int datatype = srvInqDatatype(prec);
int levelID = 0;
int varID;
varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
NULL, NULL, NULL, NULL, NULL, NULL);
xassert(varID <= SHRT_MAX && levelID <= SHRT_MAX);
(*record).varID = (short)varID;
(*record).levelID = (short)levelID;
record->varID = (short)varID;
record->levelID = (short)levelID;
streamptr->tsteps[tsID].nallrecs++;
streamptr->nrecs++;
......
......@@ -103,7 +103,8 @@ int streamvar_new_entry(stream_t *streamptr)
}
void allocate_record_table_entry(stream_t *streamptr, int varID, int subID, int nlevs)
static void
allocate_record_table_entry(stream_t *streamptr, int varID, int subID, int nlevs)
{
int *level = (int *)xmalloc((size_t)nlevs * sizeof (int));
int *lindex = (int *)xmalloc((size_t)nlevs * sizeof (int));
......
......@@ -876,34 +876,37 @@ void cdi_generate_vars(stream_t *streamptr)
for ( unsigned index = 0; index < nvars; index++ )
{
int varID = (int)index;
int varid = varids[index];
unsigned nlevels = vartable[varid].recordTable[0].nlevels;
/*
for ( levelID = 0; levelID < nlevels; levelID++ )
{
printf("%d %d %d %d %d\n", varID, levelID,
printf("%d %d %d %d %d\n", varid, levelID,
vartable[varid].levelTable[levelID].lindex,
vartable[varid].levelTable[levelID].recID,
vartable[varid].levelTable[levelID].level1);
}
*/
for (int isub=0; isub<vartable[varid].nsubtypes; isub++)
unsigned nsub = vartable[varid].nsubtypes >= 0
? (unsigned)vartable[varid].nsubtypes : 0U;
for (size_t isub=0; isub < nsub; isub++)
{
sleveltable_t *restrict streamRecordTable
= streamptr->vars[index].recordTable + isub;
leveltable_t *restrict vartableLevelTable
= vartable[varid].recordTable[isub].levelTable;
for (unsigned levelID = 0; levelID < nlevels; levelID++)
{
if ( CDI_Debug )
Message("streamptr->vars[%d].recordTable[%d].recordID[%d]=%d",
varID,isub,levelID);
streamptr->vars[varID].recordTable[isub].recordID[levelID] =
vartable[varid].recordTable[isub].levelTable[levelID].recID;
streamRecordTable->recordID[levelID]
= vartableLevelTable[levelID].recID;
unsigned lindex;
for (lindex = 0; lindex < nlevels; lindex++ )
if ( levelID == (unsigned)vartable[varid].recordTable[isub].levelTable[lindex].lindex ) break;
if ( levelID == (unsigned)vartableLevelTable[lindex].lindex )
break;
if ( lindex == nlevels )
Error("Internal problem! lindex not found.");
streamptr->vars[varID].recordTable[isub].lindex[levelID] = (int)lindex;
streamRecordTable->lindex[levelID] = (int)lindex;
}
}
}
......
......@@ -3,8 +3,6 @@
void zaxisGetTypeDescription(int zaxisType, int* outPositive, const char** outName, const char** outLongName, const char** outStdName, const char** outUnit); //The returned const char* point to static storage. Don't free or modify them.
int zaxisSize(void);
unsigned cdiZaxisCount(void);
void cdiZaxisGetIndexList(unsigned numIDs, int *IDs);
......
Markdown is supported
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