Commit 0a0b7d9e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

No commit message

No commit message
parent 559c8d4a
......@@ -534,7 +534,7 @@ void cgribexAddRecord(int streamID, int code, int *isec1, int *isec2, double *fs
if ( prec < 0 ) prec = DATATYPE_PACK;
varAddRecord(recID, code, gridID, zaxistype, lbounds, level1, level2,
prec, &varID, &levelID, numavg, ISEC1_CodeTable, ISEC1_LevelType);
prec, &varID, &levelID, numavg, ISEC1_CodeTable, ISEC1_LevelType, NULL, NULL, NULL);
(*record).varID = varID;
(*record).levelID = levelID;
......
......@@ -293,7 +293,7 @@ void extAddRecord(int streamID, int code, int level, int xysize,
datatype = extInqDatatype(prec);
varAddRecord(recID, code, gridID, leveltype, 0, level, 0,
datatype, &varID, &levelID, 0, 0, 0);
datatype, &varID, &levelID, 0, 0, 0, NULL, NULL, NULL);
(*record).varID = varID;
(*record).levelID = levelID;
......
......@@ -4,6 +4,7 @@
#include <stdio.h>
#include "dmemory.h"
#include "cdi.h"
#include "stream_int.h"
#include "file.h"
......@@ -202,6 +203,8 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
long numberOfPoints;
size_t datasize;
int discip = 0;
char name[256], longname[256], units[256];
size_t vlen;
streamptr = stream_to_pointer(streamID);
......@@ -472,11 +475,14 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0);
vctsize = lpar;
vctptr = (double *) malloc(vctsize*sizeof(double));
dummy = vctsize;
GRIB_CHECK(grib_get_double_array(gh, "pv", vctptr, &dummy), 0);
varDefVCT(vctsize, vctptr);
free(vctptr);
if ( vctsize > 0 )
{
vctptr = (double *) malloc(vctsize*sizeof(double));
dummy = vctsize;
GRIB_CHECK(grib_get_double_array(gh, "pv", vctptr, &dummy), 0);
varDefVCT(vctsize, vctptr);
free(vctptr);
}
}
//lbounds = cgribexGetZaxisHasBounds(ISEC1_LevelType);
......@@ -484,8 +490,20 @@ void gribapiAddRecord(int streamID, int code, grib_handle *gh,
if ( prec > 32 ) prec = DATATYPE_PACK32;
if ( prec < 0 ) prec = DATATYPE_PACK;
vlen = 256;
GRIB_CHECK(grib_get_string(gh, "shortName", name, &vlen), 0);
if ( vlen == 8 && memcmp(name, "unknown", vlen) == 0 ) name[0] = 0;
vlen = 256;
GRIB_CHECK(grib_get_string(gh, "name", longname, &vlen), 0);
if ( vlen == 8 && memcmp(longname, "unknown", vlen) == 0 ) longname[0] = 0;
vlen = 256;
GRIB_CHECK(grib_get_string(gh, "units", units, &vlen), 0);
if ( vlen == 8 && memcmp(units, "unknown", vlen) == 0 ) units[0] = 0;
// fprintf(stderr, "code %d name %s %s %s\n", code, name, longname, units);
varAddRecord(recID, code, gridID, zaxistype, lbounds, level1, level2,
prec, &varID, &levelID, numavg, table_num, leveltype);
prec, &varID, &levelID, numavg, table_num, leveltype,
name, longname, units);
(*record).varID = varID;
(*record).levelID = levelID;
......
......@@ -759,7 +759,7 @@ void iegAddRecord(int streamID, int code, int *pdb, int *gdb, double *vct,
datatype = iegInqDatatype(prec);
varAddRecord(recID, code, gridID, leveltype, lbounds, level1, level2,
datatype, &varID, &levelID, 0, 0, 0);
datatype, &varID, &levelID, 0, 0, 0, NULL, NULL, NULL);
(*record).varID = varID;
(*record).levelID = levelID;
......
......@@ -311,7 +311,7 @@ void srvAddRecord(int streamID, int code, int level, int xsize, int ysize,
datatype = srvInqDatatype(prec);
varAddRecord(recID, code, gridID, leveltype, 0, level, 0,
datatype, &varID, &levelID, 0, 0, 0);
datatype, &varID, &levelID, 0, 0, 0, NULL, NULL, NULL);
(*record).varID = varID;
(*record).levelID = levelID;
......
......@@ -46,6 +46,9 @@ typedef struct
int codetable;
int ztype;
int zlevel;
char *name;
char *longname;
char *units;
}
VARTABLE;
......@@ -56,7 +59,8 @@ static int varTablesize = 0;
int nvars = 0;
static void codeInitEntry(int varID, int code)
static
void codeInitEntry(int varID, int code)
{
vartable[varID].code = code;
vartable[varID].prec = 0;
......@@ -73,10 +77,14 @@ static void codeInitEntry(int varID, int code)
vartable[varID].tableID = UNDEFID;
vartable[varID].ztype = COMPRESS_NONE;
vartable[varID].zlevel = 1;
vartable[varID].name = NULL;
vartable[varID].longname = NULL;
vartable[varID].units = NULL;
}
static int varGetEntry(int code, int zaxistype, int codetable, int ltype)
static
int varGetEntry(int code, int zaxistype, int codetable, int ltype)
{
int varID;
......@@ -102,6 +110,10 @@ void varFree(void)
{
if ( vartable[varID].levelTable )
free(vartable[varID].levelTable);
if ( vartable[varID].name ) free(vartable[varID].name);
if ( vartable[varID].longname ) free(vartable[varID].longname);
if ( vartable[varID].units ) free(vartable[varID].units);
}
if ( vartable )
......@@ -223,7 +235,7 @@ int codeNewEntry (int code)
/*
If the table overflows, double its size.
*/
if( varID == varTablesize )
if ( varID == varTablesize )
{
int i;
......@@ -248,7 +260,8 @@ int codeNewEntry (int code)
void varAddRecord(int recID, int code, int gridID, int zaxistype, int lbounds,
int level1, int level2, int prec, int *pvarID, int *plevelID,
int numavg, int codetable, int ltype)
int numavg, int codetable, int ltype,
const char *name, const char *longname, const char *units)
{
static char func[] = "varAddRecord";
int varID = UNDEFID;
......@@ -268,6 +281,10 @@ void varAddRecord(int recID, int code, int gridID, int zaxistype, int lbounds,
vartable[varID].lbounds = lbounds;
if ( numavg ) vartable[varID].timave = 1;
vartable[varID].codetable = codetable;
if ( name ) if ( name[0] ) vartable[varID].name = strdup(name);
if ( longname ) if ( longname[0] ) vartable[varID].longname = strdup(longname);
if ( units ) if ( units[0] ) vartable[varID].units = strdup(units);
}
else
{
......@@ -438,6 +455,10 @@ void cdiGenVars(int streamID)
vlistDefVarTimaccu(vlistID, varID, timaccu);
vlistDefVarZtype(vlistID, varID, ztype);
if ( vartable[varID].name ) vlistDefVarName(vlistID, varID, vartable[varID].name);
if ( vartable[varID].longname ) vlistDefVarLongname(vlistID, varID, vartable[varID].longname);
if ( vartable[varID].units ) vlistDefVarUnits(vlistID, varID, vartable[varID].units);
if ( cdiDefaultTableID != UNDEFID )
{
if ( tableInqParNamePtr(cdiDefaultTableID, code) )
......
......@@ -8,7 +8,8 @@
void varAddRecord(int recID, int code, int gridID, int zaxistype, int lbounds,
int level1, int level2, int prec, int *pvarID, int *plevelID,
int numavg, int codetable, int ltype);
int numavg, int codetable, int ltype,
const char *name, const char *longname, const char *units);
void varDefVCT(size_t vctsize, double *vctptr);
......
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