Commit 23ff4feb authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

srv and ext param update

parent 54342b41
......@@ -415,7 +415,7 @@ int vlistInqVarTimave(int vlistID, int varID);
void vlistDefVarTimaccu(int vlistID, int varID, int timaccu);
int vlistInqVarTimaccu(int vlistID, int varID);
int vlistInqVarSize(int vlistID, int varID);
int vlistInqVarID(int vlistID, int param);
int vlistInqVarID(int vlistID, int code);
void vlistDefIndex(int vlistID, int varID, int levID, int index);
int vlistInqIndex(int vlistID, int varID, int levID);
......
......@@ -62,7 +62,7 @@ int extInqRecord(int streamID, int *varID, int *levelID)
static char func[] = "extInqRecord";
int status;
int fileID;
int iparam, ilevel;
int icode, ilevel;
int zaxisID = -1;
int header[4];
int vlistID;
......@@ -85,12 +85,12 @@ int extInqRecord(int streamID, int *varID, int *levelID)
extInqHeader(extp, header);
iparam = header[1];
icode = header[1];
ilevel = header[2];
*varID = vlistInqVarID(vlistID, iparam);
*varID = vlistInqVarID(vlistID, icode);
if ( *varID == UNDEFID ) Error(func, "param %d undefined", iparam);
if ( *varID == UNDEFID ) Error(func, "Code %d undefined", icode);
zaxisID = vlistInqVarZaxis(vlistID, *varID);
......@@ -202,6 +202,7 @@ int extDefRecord(int streamID)
int header[4];
int status = 0;
int datatype;
int pdis, pcat, pnum;
EXTREC *extp;
stream_t *streamptr;
......@@ -213,8 +214,9 @@ int extDefRecord(int streamID)
gridID = streamptr->record->gridID;
extp = streamptr->record->extp;
cdiDecodeParam(streamptr->record->param, &pdis, &pcat, &pnum);
header[0] = streamptr->record->date;
header[1] = streamptr->record->param;
header[1] = pnum;
header[2] = streamptr->record->level;
header[3] = gridInqSize(gridID);
......@@ -346,7 +348,8 @@ void extScanTimestep1(int streamID)
int status;
int fileID;
int rxysize = 0;
int rparam = 0, rlevel = 0, vdate = 0, vtime = 0;
int param = 0;
int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
DateTime datetime, datetime0;
int tsID;
int varID;
......@@ -392,10 +395,12 @@ void extScanTimestep1(int streamID)
prec = extp->dprec;
vdate = header[0];
vtime = 0;
rparam = header[1];
rcode = header[1];
rlevel = header[2];
rxysize = header[3];
param = cdiEncodeParam(255, 255, rcode);
if ( nrecs == 0 )
{
datetime0.date = vdate;
......@@ -405,7 +410,7 @@ void extScanTimestep1(int streamID)
{
datetime.date = vdate;
datetime.time = vtime;
compVar.param = rparam;
compVar.param = param;
compVar.level = rlevel;
for ( recID = 0; recID < nrecs; recID++ )
{
......@@ -416,15 +421,15 @@ void extScanTimestep1(int streamID)
}
if ( recID < nrecs ) break;
if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
Warning(func, "Inconsistent verification time for param %d level %d", rparam, rlevel);
Warning(func, "Inconsistent verification time for code %d level %d", rcode, rlevel);
}
nrecs++;
if ( CDI_Debug )
Message(func, "%4d%8d%4d%8d%8d%6d", nrecs, (int)recpos, rparam, rlevel, vdate, vtime);
Message(func, "%4d%8d%4d%8d%8d%6d", nrecs, (int)recpos, rcode, rlevel, vdate, vtime);
extAddRecord(streamID, rparam, rlevel, rxysize, recsize, recpos, prec);
extAddRecord(streamID, param, rlevel, rxysize, recsize, recpos, prec);
}
streamptr->rtsteps = 1;
......@@ -485,7 +490,8 @@ int extScanTimestep2(int streamID)
int status;
int fileID;
int rxysize = 0;
int rparam = 0, rlevel = 0, vdate = 0, vtime = 0;
int param = 0;
int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
int tsID;
int varID;
long recsize;
......@@ -548,10 +554,12 @@ int extScanTimestep2(int streamID)
vdate = header[0];
vtime = 0;
rparam = header[1];
rcode = header[1];
rlevel = header[2];
rxysize = header[3];
param = cdiEncodeParam(255, 255, rcode);
if ( rindex == 0 )
{
taxis->type = TAXIS_ABSOLUTE;
......@@ -559,7 +567,7 @@ int extScanTimestep2(int streamID)
taxis->vtime = vtime;
}
compVar.param = rparam;
compVar.param = param;
compVar.level = rlevel;
nextstep = FALSE;
for ( recID = 0; recID < nrecords; recID++ )
......@@ -583,14 +591,14 @@ int extScanTimestep2(int streamID)
}
if ( recID == nrecords )
{
Warning(func, "param %d level %d not found at timestep %d", rparam, rlevel, tsID+1);
Warning(func, "Code %d level %d not found at timestep %d", rcode, rlevel, tsID+1);
return (CDI_EUFSTRUCT);
}
if ( nextstep ) break;
if ( CDI_Debug )
Message(func, "%4d%8d%4d%8d%8d%6d", rindex+1, (int)recpos, rparam, rlevel, vdate, vtime);
Message(func, "%4d%8d%4d%8d%8d%6d", rindex+1, (int)recpos, rcode, rlevel, vdate, vtime);
streamptr->tsteps[tsID].records[recID].size = recsize;
......@@ -601,7 +609,7 @@ int extScanTimestep2(int streamID)
{
Message(func, "tsID = %d recID = %d param = %3d new %3d level = %3d new %3d",
tsID, recID,
streamptr->tsteps[tsID].records[recID].param, rparam,
streamptr->tsteps[tsID].records[recID].param, param,
streamptr->tsteps[tsID].records[recID].ilevel, rlevel);
return (CDI_EUFSTRUCT);
}
......@@ -673,7 +681,8 @@ int extScanTimestep(int streamID)
int fileID;
int tsID;
int rxysize = 0;
int rparam = 0, rlevel = 0, vdate = 0, vtime = 0;
int param = 0;
int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
long recsize = 0;
off_t recpos = 0;
int recID;
......@@ -732,10 +741,12 @@ int extScanTimestep(int streamID)
vdate = header[0];
vtime = 0;
rparam = header[1];
rcode = header[1];
rlevel = header[2];
rxysize = header[3];
param = cdiEncodeParam(255, 255, rcode);
if ( rindex == nrecs ) break;
recID = streamptr->tsteps[tsID].recIDs[rindex];
......@@ -746,18 +757,18 @@ int extScanTimestep(int streamID)
taxis->vtime = vtime;
}
/*
extCmpRecord(streamID, tsID, nrecs, recpos, rparam, rlevel, rxysize);
extCmpRecord(streamID, tsID, nrecs, recpos, param, rlevel, rxysize);
*/
compVar.param = rparam;
compVar.level = rlevel;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar.param = param;
compVar.level = rlevel;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar0.level = streamptr->tsteps[tsID].records[recID].ilevel;
if ( memcmp(&compVar0, &compVar, sizeof(EXTCOMPVAR)) != 0 )
{
Message(func, "tsID = %d recID = %d param = %3d new %3d level = %3d new %3d",
tsID, recID,
streamptr->tsteps[tsID].records[recID].param, rparam,
streamptr->tsteps[tsID].records[recID].param, param,
streamptr->tsteps[tsID].records[recID].ilevel, rlevel);
Error(func, "Invalid, unsupported or inconsistent record structure");
}
......@@ -766,7 +777,7 @@ int extScanTimestep(int streamID)
streamptr->tsteps[tsID].records[recID].size = recsize;
if ( CDI_Debug )
Message(func, "%4d%8d%4d%8d%8d%6d", rindex, (int)recpos, rparam, rlevel, vdate, vtime);
Message(func, "%4d%8d%4d%8d%8d%6d", rindex, (int)recpos, rcode, rlevel, vdate, vtime);
}
streamptr->rtsteps++;
......@@ -943,6 +954,7 @@ void extWriteVarDP(int streamID, int varID, const double *data)
int datatype;
int tsID;
int vlistID;
int pdis, pcat, pnum;
EXTREC *extp;
stream_t *streamptr;
......@@ -963,8 +975,10 @@ void extWriteVarDP(int streamID, int varID, const double *data)
if ( CDI_Debug )
Message(func, "nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
cdiDecodeParam(vlistInqVarParam(vlistID, varID), &pdis, &pcat, &pnum);
header[0] = streamptr->tsteps[tsID].taxis.vdate;
header[1] = vlistInqVarParam(vlistID, varID);
header[1] = pnum;
header[3] = gridInqSize(gridID);
datatype = vlistInqVarDatatype(vlistID, varID);
......@@ -994,6 +1008,7 @@ void extWriteVarSliceDP(int streamID, int varID, int levID, const double *data)
int datatype;
int tsID;
int vlistID;
int pdis, pcat, pnum;
EXTREC *extp;
stream_t *streamptr;
......@@ -1010,8 +1025,10 @@ void extWriteVarSliceDP(int streamID, int varID, int levID, const double *data)
if ( CDI_Debug )
Message(func, "gridID = %d zaxisID = %d", gridID, zaxisID);
cdiDecodeParam(vlistInqVarParam(vlistID, varID), &pdis, &pcat, &pnum);
header[0] = streamptr->tsteps[tsID].taxis.vdate;
header[1] = vlistInqVarParam(vlistID, varID);
header[1] = pnum;
header[2] = (int) level;
header[3] = gridInqSize(gridID);
......
......@@ -64,7 +64,7 @@ int iegInqRecord(int streamID, int *varID, int *levelID)
static char func[] = "iegInqRecord";
int status;
int fileID;
int iparam, ilevel;
int icode, ilevel;
int zaxisID = -1;
int vlistID;
IEGREC *iegp;
......@@ -84,15 +84,15 @@ int iegInqRecord(int streamID, int *varID, int *levelID)
status = iegRead(fileID, iegp);
if ( status != 0 ) return (0);
iparam = IEG_P_Parameter(iegp->ipdb);
icode = IEG_P_Parameter(iegp->ipdb);
if ( IEG_P_LevelType(iegp->ipdb) == IEG_LTYPE_HYBRID_LAYER )
ilevel = IEG_P_Level1(iegp->ipdb);
else
ilevel = IEG_P_Level2(iegp->ipdb);
*varID = vlistInqVarID(vlistID, iparam);
*varID = vlistInqVarID(vlistID, icode);
if ( *varID == UNDEFID ) Error(func, "param %d undefined", iparam);
if ( *varID == UNDEFID ) Error(func, "Code %d undefined", icode);
zaxisID = vlistInqVarZaxis(vlistID, *varID);
......@@ -1063,7 +1063,7 @@ int iegScanTimestep2(int streamID)
nextstep = FALSE;
for ( recID = 0; recID < nrecords; recID++ )
{
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar0.level = streamptr->tsteps[tsID].records[recID].ilevel;
if ( memcmp(&compVar0, &compVar, sizeof(IEGCOMPVAR)) == 0 )
......@@ -1093,7 +1093,7 @@ int iegScanTimestep2(int streamID)
streamptr->tsteps[tsID].records[recID].size = recsize;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar0.level = streamptr->tsteps[tsID].records[recID].ilevel;
if ( memcmp(&compVar0, &compVar, sizeof(IEGCOMPVAR)) != 0 )
......
......@@ -62,7 +62,7 @@ int srvInqRecord(int streamID, int *varID, int *levelID)
static char func[] = "srvInqRecord";
int status;
int fileID;
int iparam, ilevel;
int icode, ilevel;
int zaxisID = -1;
int header[8];
int vlistID;
......@@ -85,12 +85,12 @@ int srvInqRecord(int streamID, int *varID, int *levelID)
srvInqHeader(srvp, header);
iparam = header[0];
icode = header[0];
ilevel = header[1];
*varID = vlistInqVarID(vlistID, iparam);
*varID = vlistInqVarID(vlistID, icode);
if ( *varID == UNDEFID ) Error(func, "param %d undefined", iparam);
if ( *varID == UNDEFID ) Error(func, "Code %d undefined", icode);
zaxisID = vlistInqVarZaxis(vlistID, *varID);
......@@ -203,6 +203,7 @@ int srvDefRecord(int streamID)
int status = 0;
int xsize, ysize;
int datatype;
int pdis, pcat, pnum;
SRVREC *srvp;
stream_t *streamptr;
......@@ -214,7 +215,8 @@ int srvDefRecord(int streamID)
gridID = streamptr->record->gridID;
srvp = streamptr->record->srvp;
header[0] = streamptr->record->param;
cdiDecodeParam(streamptr->record->param, &pdis, &pcat, &pnum);
header[0] = pnum;
header[1] = streamptr->record->level;
header[2] = streamptr->record->date;
header[3] = streamptr->record->time;
......@@ -364,7 +366,8 @@ void srvScanTimestep1(int streamID)
int status;
int fileID;
int rxsize = 0, rysize = 0;
int rparam = 0, rlevel = 0, vdate = 0, vtime = 0;
int param = 0;
int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
DateTime datetime, datetime0;
int tsID;
int varID;
......@@ -408,13 +411,15 @@ void srvScanTimestep1(int streamID)
srvInqHeader(srvp, header);
prec = srvp->dprec;
rparam = header[0];
rcode = header[0];
rlevel = header[1];
vdate = header[2];
vtime = header[3];
rxsize = header[4];
rysize = header[5];
param = cdiEncodeParam(255, 255, rcode);
if ( nrecs == 0 )
{
datetime0.date = vdate;
......@@ -424,7 +429,7 @@ void srvScanTimestep1(int streamID)
{
datetime.date = vdate;
datetime.time = vtime;
compVar.param = rparam;
compVar.param = param;
compVar.level = rlevel;
for ( recID = 0; recID < nrecs; recID++ )
{
......@@ -435,15 +440,15 @@ void srvScanTimestep1(int streamID)
}
if ( recID < nrecs ) break;
if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
Warning(func, "Inconsistent verification time for param %d level %d", rparam, rlevel);
Warning(func, "Inconsistent verification time for code %d level %d", rcode, rlevel);
}
nrecs++;
if ( CDI_Debug )
Message(func, "%4d%8d%4d%8d%8d%6d", nrecs, (int)recpos, rparam, rlevel, vdate, vtime);
Message(func, "%4d%8d%4d%8d%8d%6d", nrecs, (int)recpos, rcode, rlevel, vdate, vtime);
srvAddRecord(streamID, rparam, rlevel, rxsize, rysize, recsize, recpos, prec);
srvAddRecord(streamID, param, rlevel, rxsize, rysize, recsize, recpos, prec);
}
streamptr->rtsteps = 1;
......@@ -503,7 +508,8 @@ int srvScanTimestep2(int streamID)
int header[8];
int status;
int fileID;
int rparam = 0, rlevel = 0, vdate = 0, vtime = 0;
int param = 0;
int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
int tsID;
int varID;
long recsize;
......@@ -564,11 +570,13 @@ int srvScanTimestep2(int streamID)
srvInqHeader(srvp, header);
rparam = header[0];
rcode = header[0];
rlevel = header[1];
vdate = header[2];
vtime = header[3];
param = cdiEncodeParam(255, 255, rcode);
if ( rindex == 0 )
{
taxis->type = TAXIS_ABSOLUTE;
......@@ -576,7 +584,7 @@ int srvScanTimestep2(int streamID)
taxis->vtime = vtime;
}
compVar.param = rparam;
compVar.param = param;
compVar.level = rlevel;
nextstep = FALSE;
for ( recID = 0; recID < nrecords; recID++ )
......@@ -600,14 +608,14 @@ int srvScanTimestep2(int streamID)
}
if ( recID == nrecords )
{
Warning(func, "param %d level %d not found at timestep %d", rparam, rlevel, tsID+1);
Warning(func, "Code %d level %d not found at timestep %d", rcode, rlevel, tsID+1);
return (CDI_EUFSTRUCT);
}
if ( nextstep ) break;
if ( CDI_Debug )
Message(func, "%4d%8d%4d%8d%8d%6d", rindex+1, (int)recpos, rparam, rlevel, vdate, vtime);
Message(func, "%4d%8d%4d%8d%8d%6d", rindex+1, (int)recpos, rcode, rlevel, vdate, vtime);
streamptr->tsteps[tsID].records[recID].size = recsize;
......@@ -618,7 +626,7 @@ int srvScanTimestep2(int streamID)
{
Message(func, "tsID = %d recID = %d param = %3d new %3d level = %3d new %3d",
tsID, recID,
streamptr->tsteps[tsID].records[recID].param, rparam,
streamptr->tsteps[tsID].records[recID].param, param,
streamptr->tsteps[tsID].records[recID].ilevel, rlevel);
return (CDI_EUFSTRUCT);
}
......@@ -690,7 +698,8 @@ int srvScanTimestep(int streamID)
int fileID;
int tsID;
int rxsize = 0, rysize = 0;
int rparam = 0, rlevel = 0, vdate = 0, vtime = 0;
int param = 0;
int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
long recsize = 0;
off_t recpos = 0;
int recID;
......@@ -747,13 +756,15 @@ int srvScanTimestep(int streamID)
srvInqHeader(srvp, header);
rparam = header[0];
rcode = header[0];
rlevel = header[1];
vdate = header[2];
vtime = header[3];
rxsize = header[4];
rysize = header[5];
param = cdiEncodeParam(255, 255, rcode);
if ( rindex == nrecs ) break;
recID = streamptr->tsteps[tsID].recIDs[rindex];
......@@ -764,18 +775,18 @@ int srvScanTimestep(int streamID)
taxis->vtime = vtime;
}
/*
srvCmpRecord(streamID, tsID, nrecs, recpos, rparam, rlevel, rxsize, rysize);
srvCmpRecord(streamID, tsID, nrecs, recpos, param, rlevel, rxsize, rysize);
*/
compVar.param = rparam;
compVar.level = rlevel;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar.param = param;
compVar.level = rlevel;
compVar0.param = streamptr->tsteps[tsID].records[recID].param;
compVar0.level = streamptr->tsteps[tsID].records[recID].ilevel;
if ( memcmp(&compVar0, &compVar, sizeof(SRVCOMPVAR)) != 0 )
{
Message(func, "tsID = %d recID = %d param = %3d new %3d level = %3d new %3d",
tsID, recID,
streamptr->tsteps[tsID].records[recID].param, rparam,
streamptr->tsteps[tsID].records[recID].param, param,
streamptr->tsteps[tsID].records[recID].ilevel, rlevel);
Error(func, "Invalid, unsupported or inconsistent record structure");
}
......@@ -784,7 +795,7 @@ int srvScanTimestep(int streamID)
streamptr->tsteps[tsID].records[recID].size = recsize;
if ( CDI_Debug )
Message(func, "%4d%8d%4d%8d%8d%6d", rindex, (int)recpos, rparam, rlevel, vdate, vtime);
Message(func, "%4d%8d%4d%8d%8d%6d", rindex, (int)recpos, rcode, rlevel, vdate, vtime);
}
streamptr->rtsteps++;
......@@ -962,6 +973,7 @@ void srvWriteVarDP(int streamID, int varID, const double *data)
int datatype;
int tsID;
int vlistID;
int pdis, pcat, pnum;
SRVREC *srvp;
stream_t *streamptr;
......@@ -982,7 +994,9 @@ void srvWriteVarDP(int streamID, int varID, const double *data)
if ( CDI_Debug )
Message(func, "nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
header[0] = vlistInqVarParam(vlistID, varID);
cdiDecodeParam(vlistInqVarParam(vlistID, varID), &pdis, &pcat, &pnum);
header[0] = pnum;
header[2] = streamptr->tsteps[tsID].taxis.vdate;
header[3] = streamptr->tsteps[tsID].taxis.vtime;
......@@ -1030,6 +1044,7 @@ void srvWriteVarSliceDP(int streamID, int varID, int levID, const double *data)
int datatype;
int tsID;
int vlistID;
int pdis, pcat, pnum;
SRVREC *srvp;
stream_t *streamptr;
......@@ -1046,7 +1061,9 @@ void srvWriteVarSliceDP(int streamID, int varID, int levID, const double *data)
if ( CDI_Debug )
Message(func, "gridID = %d zaxisID = %d", gridID, zaxisID);
header[0] = vlistInqVarParam(vlistID, varID);
cdiDecodeParam(vlistInqVarParam(vlistID, varID), &pdis, &pcat, &pnum);
header[0] = pnum;
header[1] = (int) level;
header[2] = streamptr->tsteps[tsID].taxis.vdate;
header[3] = streamptr->tsteps[tsID].taxis.vtime;
......
......@@ -684,15 +684,20 @@ void vlistInqVarUnits(int vlistID, int varID, char *units)
}
int vlistInqVarID(int vlistID, int param)
int vlistInqVarID(int vlistID, int code)
{
int varID;
vlist_t *vlistptr;
int param, pdis, pcat, pnum;
vlistptr = vlist_to_pointer(vlistID);
for ( varID = 0; varID < vlistptr->nvars; varID++ )
if ( vlistptr->vars[varID].param == param ) break;
{
param = vlistptr->vars[varID].param;
cdiDecodeParam(param, &pdis, &pcat, &pnum);
if ( pnum == code ) break;
}
if ( varID == vlistptr->nvars )
{
......
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