Commit e9bcd99e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

change code/tabnum to param

parent 27282276
......@@ -94,7 +94,7 @@ void *Arithdays(void *argument)
streamDefTimestep(streamID2, tsID);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( operfunc2 == func_month )
rconst = days_per_month(calendar, year, month);
......
......@@ -78,7 +78,7 @@ void *Del29feb(void *argument)
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( month == 2 && day == 29 )
{
......
......@@ -251,9 +251,9 @@ void *Filter(void *argument)
int lperiod, incperiod;
int year, month, day;
decode_date(vdate[tsID], &year, &month, &day);
cdiDecodeDate(vdate[tsID], &year, &month, &day);
decode_date(vdate[tsID-1], &year0, &month0, &day0);
cdiDecodeDate(vdate[tsID-1], &year0, &month0, &day0);
juldate0 = juldate_encode(calendar, vdate[tsID-1], vtime[tsID-1]);
juldate = juldate_encode(calendar, vdate[tsID], vtime[tsID]);
......
......@@ -185,8 +185,8 @@ void *Fldstat(void *argument)
yval = gridInqYval(field.grid, j);
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
decode_date(vdate, &year, &month, &day);
decode_time(vtime, &hour, &minute, &second);
cdiDecodeDate(vdate, &year, &month, &day);
cdiDecodeTime(vtime, &hour, &minute, &second);
code = vlistInqVarCode(vlistID1, varID);
level = zaxisInqLevel(vlistInqVarZaxis(vlistID1, varID), levelID);
if ( tsID == 0 && recID == 0 )
......
......@@ -610,8 +610,8 @@ void *Gradsdes(void *argument)
if ( tsID == 0 )
{
decode_date(vdate, &iyys, &imms, &idds);
decode_time(vtime, &ihhs, &imns, &isds);
cdiDecodeDate(vdate, &iyys, &imms, &idds);
cdiDecodeTime(vtime, &ihhs, &imns, &isds);
if ( imms < 1 || imms > 12 ) imms=1;
......@@ -624,8 +624,8 @@ void *Gradsdes(void *argument)
if ( tsID == 1 )
{
decode_date(vdate, &iyy, &imm, &idd);
decode_time(vtime, &ihh, &imn, &isd);
cdiDecodeDate(vdate, &iyy, &imm, &idd);
cdiDecodeTime(vtime, &ihh, &imn, &isd);
idmn = imn - imns;
idhh = ihh - ihhs;
......@@ -663,8 +663,8 @@ void *Gradsdes(void *argument)
if ( tsID > 0 && tsID < 6 && iik != 3 && (monavg == TRUE || monavg == -1) )
{
decode_date(vdate, &iyy, &imm, &idd);
decode_time(vtime, &ihh, &imn, &isd);
cdiDecodeDate(vdate, &iyy, &imm, &idd);
cdiDecodeTime(vtime, &ihh, &imn, &isd);
idmn = imn - imns;
idhh = ihh - ihhs;
......
......@@ -388,8 +388,8 @@ void *Importbinary(void *argument)
for ( tsID = tmin-1; tsID < tmax; ++tsID )
{
gr2t(pfi.grvals[3], (gadouble)(tsID+1), &dtim);
vdate = encode_date(dtim.yr, dtim.mo, dtim.dy);
vtime = encode_time(dtim.hr, dtim.mn, 0);
vdate = cdiEncodeDate(dtim.yr, dtim.mo, dtim.dy);
vtime = cdiEncodeTime(dtim.hr, dtim.mn, 0);
date2str(vdate, vdatestr, sizeof(vdatestr));
time2str(vtime, vtimestr, sizeof(vtimestr));
......
......@@ -217,38 +217,13 @@ void printMap(int nlon, int nlat, double *array, double missval, double min, dou
}
void decode_param(int param, int *dis, int *cat, int *num)
{
int iparam;
*dis = param / 1000000;
iparam = param - *dis*1000000;
if ( iparam < 0 ) iparam = -iparam;
*cat = iparam / 1000;
*num = iparam - *cat*1000;
}
int encode_param(int dis, int cat, int num)
{
int param;
int inum;
inum = num;
if ( num < 0 ) inum = -num;
param = dis*1000000 + cat*1000 + inum;
if ( num < 0 ) param = -param;
return (param);
}
void param2str(int param, char *paramstr, int maxlen)
{
static char func[] = "param2str";
int dis, cat, num;
int len;
decode_param(param, &dis, &cat, &num);
cdiDecodeParam(param, &dis, &cat, &num);
if ( dis == 255 && (cat == 255 || cat == 0 ) )
len = sprintf(paramstr, "%d", num);
......@@ -268,7 +243,7 @@ void date2str(int date, char *datestr, int maxlen)
int year, month, day;
int len;
decode_date(date, &year, &month, &day);
cdiDecodeDate(date, &year, &month, &day);
len = sprintf(datestr, DATE_FORMAT, year, month, day);
......@@ -283,7 +258,7 @@ void time2str(int time, char *timestr, int maxlen)
int hour, minute, second;
int len;
decode_time(time, &hour, &minute, &second);
cdiDecodeTime(time, &hour, &minute, &second);
len = sprintf(timestr, TIME_FORMAT, hour, minute, second);
......
......@@ -46,8 +46,8 @@ int readnextpos(FILE *fp, int calendar, juldate_t *juldate, double *xpos, double
if ( stat != EOF )
{
date = encode_date(year, month, day);
time = encode_time(hour, minute, second);
date = cdiEncodeDate(year, month, day);
time = cdiEncodeTime(hour, minute, second);
*juldate = juldate_encode(calendar, date, time);
}
......
......@@ -72,7 +72,7 @@ void *Inttime(void *argument)
{
year = 1; month = 1; day = 1;
sscanf(datestr, "%d-%d-%d", &year, &month, &day);
vdate = encode_date(year, month, day);
vdate = cdiEncodeDate(year, month, day);
}
if ( strchr(timestr, ':') == NULL )
......@@ -83,7 +83,7 @@ void *Inttime(void *argument)
{
hour = 0; minute = 0; second = 0;
sscanf(timestr, "%d:%d:%d", &hour, &minute, &second);
vtime = encode_time(hour, minute, second);
vtime = cdiEncodeTime(hour, minute, second);
}
if ( operatorArgc() == 3 )
......@@ -286,14 +286,14 @@ void *Inttime(void *argument)
{
juldate_decode(calendar, juldate, &vdate, &vtime);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
month += ijulinc;
while ( month > 12 ) { month -= 12; year++; }
while ( month < 1 ) { month += 12; year--; }
vdate = encode_date(year, month, day);
vdate = cdiEncodeDate(year, month, day);
juldate = juldate_encode(calendar, vdate, vtime);
}
......
......@@ -79,7 +79,7 @@ void *Ninfo(void *argument)
{
vdate = taxisInqVdate(taxisID);
decode_date(vdate, &year, &mon, &day);
cdiDecodeDate(vdate, &year, &mon, &day);
if ( tsID == 0 || year0 != year )
{
......@@ -99,7 +99,7 @@ void *Ninfo(void *argument)
{
vdate = taxisInqVdate(taxisID);
decode_date(vdate, &year, &mon, &day);
cdiDecodeDate(vdate, &year, &mon, &day);
if ( tsID == 0 || mon0 != mon )
{
......
......@@ -244,7 +244,7 @@ void *Output(void *argument)
else if ( operatorID == OUTPUTFLD )
{
int hour, minute, second;
decode_time(vtime, &hour, &minute, &second);
cdiDecodeTime(vtime, &hour, &minute, &second);
xdate = vdate - (vdate/100)*100 + (hour*3600 + minute*60 + second)/86400.;
for ( i = 0; i < gridsize; i++ )
if ( !DBL_IS_EQUAL(array[i], missval) )
......
......@@ -118,7 +118,7 @@ void *Seascount(void *argument)
{
vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( month < 0 || month > 16 )
cdoAbort("Month %d out of range!", month);
......
......@@ -168,7 +168,7 @@ void *Seaspctl(void *argument)
{
vdate1 = taxisInqVdate(taxisID1);
vtime1 = taxisInqVtime(taxisID1);
decode_date(vdate1, &year, &month, &day);
cdiDecodeDate(vdate1, &year, &month, &day);
if ( month < 0 || month > 16 )
cdoAbort("Month %d out of range!", month);
......
......@@ -215,16 +215,16 @@ void *Seltime(void *argument)
{
status = sscanf(operatorArgv()[i], "%d-%d-%dT%d:%d:%d",
&year, &month, &day, &hour, &minute, &second);
fval = encode_time(hour, minute, second);
fval = cdiEncodeTime(hour, minute, second);
if ( fabs(fval) > 0 ) fval /= 1000000;
fval += encode_date(year, month, day);
fval += cdiEncodeDate(year, month, day);
listSetFlt(flist, i, fval);
set2 = FALSE;
}
else
{
status = sscanf(operatorArgv()[i], "%d-%d-%d", &year, &month, &day);
fval = encode_date(year, month, day);
fval = cdiEncodeDate(year, month, day);
if ( nsel > 1 && i > 0 ) fval += 0.999;
......@@ -249,7 +249,7 @@ void *Seltime(void *argument)
if ( strchr(operatorArgv()[i], ':') )
{
sscanf(operatorArgv()[i], "%d:%d:%d", &hour, &minute, &second);
listSetInt(ilist, i, encode_time(hour, minute, second));
listSetInt(ilist, i, cdiEncodeTime(hour, minute, second));
}
else
{
......
......@@ -112,7 +112,7 @@ void *Settime(void *argument)
if ( strchr(datestr, '-') )
{
sscanf(datestr, "%d-%d-%d", &year, &month, &day);
sdate = encode_date(year, month, day);
sdate = cdiEncodeDate(year, month, day);
}
else
{
......@@ -122,7 +122,7 @@ void *Settime(void *argument)
if ( strchr(timestr, ':') )
{
sscanf(timestr, "%d:%d:%d", &hour, &minute, &second);
stime = encode_time(hour, minute, second);
stime = cdiEncodeTime(hour, minute, second);
}
else
{
......@@ -147,7 +147,7 @@ void *Settime(void *argument)
if ( strchr(datestr, '-') )
{
sscanf(datestr, "%d-%d-%d", &year, &month, &day);
newval = encode_date(year, month, day);
newval = cdiEncodeDate(year, month, day);
}
else
{
......@@ -162,7 +162,7 @@ void *Settime(void *argument)
if ( strchr(timestr, ':') )
{
sscanf(timestr, "%d:%d:%d", &hour, &minute, &second);
newval = encode_time(hour, minute, second);
newval = cdiEncodeTime(hour, minute, second);
}
else
{
......@@ -317,7 +317,7 @@ void *Settime(void *argument)
if ( tsID1 == 0 )
{
vdate = sdate;
decode_date(vdate, &year, &month, &day0);
cdiDecodeDate(vdate, &year, &month, &day0);
}
else
{
......@@ -331,7 +331,7 @@ void *Settime(void *argument)
else
day = day0;
vdate = encode_date(year, month, day);
vdate = cdiEncodeDate(year, month, day);
}
}
else
......@@ -344,14 +344,14 @@ void *Settime(void *argument)
{
if ( tunit == TUNIT_MONTH || tunit == TUNIT_YEAR )
{
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
month += ijulinc;
while ( month > 12 ) { month -= 12; year++; }
while ( month < 1 ) { month += 12; year--; }
vdate = encode_date(year, month, day);
vdate = cdiEncodeDate(year, month, day);
}
else
{
......@@ -369,13 +369,13 @@ void *Settime(void *argument)
}
else
{
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( operatorID == SETYEAR ) year = newval;
if ( operatorID == SETMON ) month = newval;
if ( operatorID == SETDAY ) day = newval;
vdate = encode_date(year, month, day);
vdate = cdiEncodeDate(year, month, day);
if ( operatorID == SETDATE ) vdate = newval;
if ( operatorID == SETTIME ) vtime = newval;
......
......@@ -93,7 +93,7 @@ void *Showinfo(void *argument)
{
vdate = taxisInqVdate(taxisID);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( tsID == 0 || year0 != year )
{
......@@ -116,7 +116,7 @@ void *Showinfo(void *argument)
{
vdate = taxisInqVdate(taxisID);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( tsID == 0 || month0 != month )
{
......
......@@ -98,7 +98,7 @@ void *Sinfo(void *argument)
gridID = vlistInqVarGrid(vlistID, varID);
zaxisID = vlistInqVarZaxis(vlistID, varID);
if ( param == -1 ) param = 255*1000000+tabnum*1000+code;
if ( param == CDI_UNDEFPARAM ) param = cdiEncodeParam(255, tabnum, code);
param2str(param, paramstr, sizeof(paramstr));
if ( operatorID == SINFOV ) vlistInqVarName(vlistID, varID, varname);
......
......@@ -96,7 +96,7 @@ void *Splityear(void *argument)
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{
vdate = taxisInqVdate(taxisID1);
decode_date(vdate, &year2, &mon2, &day);
cdiDecodeDate(vdate, &year2, &mon2, &day);
if ( tsID == 0 || year1 != year2 || (year1 == year2 && mon1 > mon2) )
{
......
......@@ -137,8 +137,8 @@ void printBounds(int taxisID, int calendar)
taxisInqVdateBounds(taxisID, &vdate0, &vdate1);
taxisInqVtimeBounds(taxisID, &vtime0, &vtime1);
decode_date(vdate0, &year0, &month0, &day0);
decode_date(vdate1, &year1, &month1, &day1);
cdiDecodeDate(vdate0, &year0, &month0, &day0);
cdiDecodeDate(vdate1, &year1, &month1, &day1);
date2str(vdate0, vdatestr, sizeof(vdatestr));
time2str(vtime0, vtimestr, sizeof(vtimestr));
......@@ -185,7 +185,7 @@ int fill_gap(int ngaps, int ntsm[MAX_NTSM], int rangetsm[MAX_GAPS][2],
ndate = vdate0;
while ( TRUE )
{
decode_date(ndate, &year, &month, &day);
cdiDecodeDate(ndate, &year, &month, &day);
month += ijulinc;
......@@ -195,7 +195,7 @@ int fill_gap(int ngaps, int ntsm[MAX_NTSM], int rangetsm[MAX_GAPS][2],
if ( day0 == 31 )
day = days_per_month(calendar, year, month);
ndate = encode_date(year, month, day);
ndate = cdiEncodeDate(year, month, day);
ntime = vtime0;
if ( ndate >= vdate ) break;
/* printf("\n1 %d %d\n", ndate, ntime); */
......@@ -313,7 +313,7 @@ void *Tinfo(void *argument)
vdate = taxisInqVdate(taxisID);
vtime = taxisInqVtime(taxisID);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
date2str(vdate, vdatestr, sizeof(vdatestr));
time2str(vtime, vtimestr, sizeof(vtimestr));
......@@ -324,7 +324,7 @@ void *Tinfo(void *argument)
{
int deltam, deltay;
decode_date(vdate0, &year0, &month0, &day0);
cdiDecodeDate(vdate0, &year0, &month0, &day0);
juldate0 = juldate_encode(calendar, vdate0, vtime0);
juldate = juldate_encode(calendar, vdate, vtime);
......
......@@ -129,7 +129,7 @@ void *Ydaypctl(void *argument)
if ( cdoVerbose ) cdoPrint("process timestep: %d %d %d", tsID+1, vdate, vtime);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( month >= 1 && month <= 12 )
dayoy = (month-1)*31 + day;
......@@ -195,7 +195,7 @@ void *Ydaypctl(void *argument)
if ( cdoVerbose ) cdoPrint("process timestep: %d %d %d", tsID+1, vdate, vtime);
decode_date(vdate, &year, &month, &day);
cdiDecodeDate(vdate, &year, &month, &day);
if ( month >= 1 && month <= 12 )
dayoy = (month-1)*31 + day;
......
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