Commit 9683749e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

New operator: XXXvar

parent a96a2eea
2006-12-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CDI library version 1.0.5
* New operator: vertvar, timvar, yearvar, monvar, dayvar, hourvar
* New operator: runvar, seasvar, selvar, ydayvar, ydrunvar, ymonvar, yseasvar
* eca: Titles update
* remap: set norm_opt after read_remap_scrip (bug fix) [report: Andreas Sterl]
* cdo: FP_FAST_FMA bug fix [report: Sunpoet]
......
......@@ -23,6 +23,7 @@
Runstat runsum Running sum
Runstat runmean Running mean
Runstat runavg Running average
Runstat runvar Running variance
Runstat runstd Running standard deviation
*/
......@@ -111,6 +112,7 @@ void *Runstat(void *argument)
cdoOperatorAdd("runsum", func_sum, 0, NULL);
cdoOperatorAdd("runmean", func_mean, 0, NULL);
cdoOperatorAdd("runavg", func_avg, 0, NULL);
cdoOperatorAdd("runvar", func_var, 0, NULL);
cdoOperatorAdd("runstd", func_std, 0, NULL);
operatorID = cdoOperatorID();
......@@ -146,13 +148,13 @@ void *Runstat(void *argument)
datetime = (DATETIME *) malloc((ndates+1)*sizeof(DATETIME));
vars1 = (FIELD ***) malloc((ndates+1)*sizeof(FIELD **));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2 = (FIELD ***) malloc((ndates+1)*sizeof(FIELD **));
for ( its = 0; its < ndates; its++ )
{
vars1[its] = (FIELD **) malloc(nvars*sizeof(FIELD *));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[its] = (FIELD **) malloc(nvars*sizeof(FIELD *));
for ( varID = 0; varID < nvars; varID++ )
......@@ -163,7 +165,7 @@ void *Runstat(void *argument)
missval = vlistInqVarMissval(vlistID1, varID);
vars1[its][varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[its][varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
for ( levelID = 0; levelID < nlevel; levelID++ )
......@@ -172,7 +174,7 @@ void *Runstat(void *argument)
vars1[its][varID][levelID].nmiss = 0;
vars1[its][varID][levelID].missval = missval;
vars1[its][varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
vars2[its][varID][levelID].grid = gridID;
vars2[its][varID][levelID].nmiss = 0;
......@@ -205,7 +207,7 @@ void *Runstat(void *argument)
streamReadRecord(streamID1, vars1[tsID][varID][levelID].ptr, &nmiss);
vars1[tsID][varID][levelID].nmiss = nmiss;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
farmoq(&vars2[tsID][varID][levelID], vars1[tsID][varID][levelID]);
for ( inp = 0; inp < tsID; inp++ )
......@@ -235,13 +237,16 @@ void *Runstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
farcmul(&vars1[0][varID][levelID], 1.0/ndates);
}
else if ( operfunc == func_std )
else if ( operfunc == func_std || operfunc == func_var )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevel; levelID++ )
farcstd(&vars1[0][varID][levelID], vars2[0][varID][levelID], 1.0/ndates);
if ( operfunc == func_std )
farcstd(&vars1[0][varID][levelID], vars2[0][varID][levelID], 1.0/ndates);
else
farcvar(&vars1[0][varID][levelID], vars2[0][varID][levelID], 1.0/ndates);
}
datetime_avg(dpy, ndates, datetime);
......@@ -264,14 +269,14 @@ void *Runstat(void *argument)
datetime[ndates] = datetime[0];
vars1[ndates] = vars1[0];
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[ndates] = vars2[0];
for ( inp = 0; inp < ndates; inp++ )
{
datetime[inp] = datetime[inp+1];
vars1[inp] = vars1[inp+1];
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[inp] = vars2[inp+1];
}
......@@ -288,7 +293,7 @@ void *Runstat(void *argument)
streamReadRecord(streamID1, vars1[ndates-1][varID][levelID].ptr, &nmiss);
vars1[ndates-1][varID][levelID].nmiss = nmiss;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
for ( inp = 0; inp < ndates-1; inp++ )
{
......@@ -317,21 +322,20 @@ void *Runstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
free(vars1[its][varID][levelID].ptr);
if ( operfunc == func_std ) free(vars2[its][varID][levelID].ptr);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[its][varID][levelID].ptr);
}
free(vars1[its][varID]);
if ( operfunc == func_std ) free(vars2[its][varID]);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[its][varID]);
}
/* RQ */
free(vars1[its]);
if ( operfunc == func_std ) free(vars2[its]);
/* QR */
if ( operfunc == func_std || operfunc == func_var ) free(vars2[its]);
}
free(datetime);
free(vars1);
if ( operfunc == func_std ) free(vars2);
if ( operfunc == func_std || operfunc == func_var ) free(vars2);
if ( recVarID ) free(recVarID);
if ( recLevelID ) free(recLevelID);
......
......@@ -23,6 +23,7 @@
Seasstat seassum Seasonal sum
Seasstat seasmean Seasonal mean
Seasstat seasavg Seasonal average
Seasstat seasvar Seasonal variance
Seasstat seasstd Seasonal standard deviation
*/
......@@ -66,6 +67,7 @@ void *Seasstat(void *argument)
cdoOperatorAdd("seassum", func_sum, 0, NULL);
cdoOperatorAdd("seasmean", func_mean, 0, NULL);
cdoOperatorAdd("seasavg", func_avg, 0, NULL);
cdoOperatorAdd("seasvar", func_var, 0, NULL);
cdoOperatorAdd("seasstd", func_std, 0, NULL);
operatorID = cdoOperatorID();
......@@ -98,7 +100,7 @@ void *Seasstat(void *argument)
vars1 = (FIELD **) malloc(nvars*sizeof(FIELD *));
samp1 = (FIELD **) malloc(nvars*sizeof(FIELD *));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2 = (FIELD **) malloc(nvars*sizeof(FIELD *));
for ( varID = 0; varID < nvars; varID++ )
......@@ -110,7 +112,7 @@ void *Seasstat(void *argument)
vars1[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
samp1[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
for ( levelID = 0; levelID < nlevel; levelID++ )
......@@ -123,7 +125,7 @@ void *Seasstat(void *argument)
samp1[varID][levelID].nmiss = 0;
samp1[varID][levelID].missval = missval;
samp1[varID][levelID].ptr = NULL;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
vars2[varID][levelID].grid = gridID;
vars2[varID][levelID].nmiss = 0;
......@@ -220,7 +222,7 @@ void *Seasstat(void *argument)
samp1[varID][levelID].ptr[i]++;
}
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
farsumq(&vars2[varID][levelID], field);
farsum(&vars1[varID][levelID], field);
......@@ -232,7 +234,7 @@ void *Seasstat(void *argument)
}
}
if ( nsets == 0 && operfunc == func_std )
if ( nsets == 0 && (operfunc == func_std || operfunc == func_var) )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
......@@ -262,7 +264,7 @@ void *Seasstat(void *argument)
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
}
else if ( operfunc == func_std )
else if ( operfunc == func_std || operfunc == func_var )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
......@@ -270,11 +272,19 @@ void *Seasstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
{
if ( operfunc == func_std )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
else
farcvar(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
}
else
{
farinv(&samp1[varID][levelID]);
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
if ( operfunc == func_std )
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
else
farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
}
}
}
......@@ -305,17 +315,17 @@ void *Seasstat(void *argument)
{
free(vars1[varID][levelID].ptr);
if ( samp1[varID][levelID].ptr ) free(samp1[varID][levelID].ptr);
if ( operfunc == func_std ) free(vars2[varID][levelID].ptr);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID][levelID].ptr);
}
free(vars1[varID]);
free(samp1[varID]);
if ( operfunc == func_std ) free(vars2[varID]);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID]);
}
free(vars1);
free(samp1);
if ( operfunc == func_std ) free(vars2);
if ( operfunc == func_std || operfunc == func_var ) free(vars2);
if ( field.ptr ) free(field.ptr);
......
......@@ -23,6 +23,7 @@
Selstat selsum Time range sum
Selstat selmean Time range mean
Selstat selavg Time range average
Selstat selvar Time range variance
Selstat selstd Time range standard deviation
*/
......@@ -65,6 +66,7 @@ void *Selstat(void *argument)
cdoOperatorAdd("selsum", func_sum, 0, NULL);
cdoOperatorAdd("selmean", func_mean, 0, NULL);
cdoOperatorAdd("selavg", func_avg, 0, NULL);
cdoOperatorAdd("selvar", func_var, 0, NULL);
cdoOperatorAdd("selstd", func_std, 0, NULL);
operatorID = cdoOperatorID();
......@@ -107,7 +109,7 @@ void *Selstat(void *argument)
vars1 = (FIELD **) malloc(nvars*sizeof(FIELD *));
samp1 = (FIELD **) malloc(nvars*sizeof(FIELD *));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2 = (FIELD **) malloc(nvars*sizeof(FIELD *));
for ( varID = 0; varID < nvars; varID++ )
......@@ -119,7 +121,7 @@ void *Selstat(void *argument)
vars1[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
samp1[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
for ( levelID = 0; levelID < nlevel; levelID++ )
......@@ -132,7 +134,7 @@ void *Selstat(void *argument)
samp1[varID][levelID].nmiss = 0;
samp1[varID][levelID].missval = missval;
samp1[varID][levelID].ptr = NULL;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
vars2[varID][levelID].grid = gridID;
vars2[varID][levelID].nmiss = 0;
......@@ -212,7 +214,7 @@ void *Selstat(void *argument)
samp1[varID][levelID].ptr[i]++;
}
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
farsumq(&vars2[varID][levelID], field);
farsum(&vars1[varID][levelID], field);
......@@ -224,7 +226,7 @@ void *Selstat(void *argument)
}
}
if ( nsets == 0 && operfunc == func_std )
if ( nsets == 0 && (operfunc == func_std || operfunc == func_var) )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
......@@ -253,7 +255,7 @@ void *Selstat(void *argument)
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
}
else if ( operfunc == func_std )
else if ( operfunc == func_std || operfunc == func_var )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
......@@ -261,11 +263,19 @@ void *Selstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
{
if ( operfunc == func_std )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
else
farcvar(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
}
else
{
farinv(&samp1[varID][levelID]);
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
if ( operfunc == func_std )
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
else
farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
}
}
}
......@@ -307,17 +317,17 @@ void *Selstat(void *argument)
{
free(vars1[varID][levelID].ptr);
if ( samp1[varID][levelID].ptr ) free(samp1[varID][levelID].ptr);
if ( operfunc == func_std ) free(vars2[varID][levelID].ptr);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID][levelID].ptr);
}
free(vars1[varID]);
free(samp1[varID]);
if ( operfunc == func_std ) free(vars2[varID]);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID]);
}
free(vars1);
free(samp1);
if ( operfunc == func_std ) free(vars2);
if ( operfunc == func_std || operfunc == func_var ) free(vars2);
if ( field.ptr ) free(field.ptr);
......
......@@ -23,30 +23,35 @@
Timstat timsum Time sum
Timstat timmean Time mean
Timstat timavg Time average
Timstat timvar Time variance
Timstat timstd Time standard deviation
Hourstat hourmin Hourly minimum
Hourstat hourmax Hourly maximum
Hourstat hoursum Hourly sum
Hourstat hourmean Hourly mean
Hourstat houravg Hourly average
Hourstat hourvar Hourly variance
Hourstat hourstd Hourly standard deviation
Daystat daymin Daily minimum
Daystat daymax Daily maximum
Daystat daysum Daily sum
Daystat daymean Daily mean
Daystat dayavg Daily average
Daystat dayvar Daily variance
Daystat daystd Daily standard deviation
Monstat monmin Monthly minimum
Monstat monmax Monthly maximum
Monstat monsum Monthly sum
Monstat monmean Monthly mean
Monstat monavg Monthly average
Monstat monvar Monthly variance
Monstat monstd Monthly standard deviation
Yearstat yearmin Yearly minimum
Yearstat yearmax Yearly maximum
Yearstat yearsum Yearly sum
Yearstat yearmean Yearly mean
Yearstat yearavg Yearly average
Yearstat yearvar Yearly variance
Yearstat yearstd Yearly standard deviation
*/
......@@ -90,30 +95,35 @@ void *Timstat(void *argument)
cdoOperatorAdd("timsum", func_sum, 17, NULL);
cdoOperatorAdd("timmean", func_mean, 17, NULL);
cdoOperatorAdd("timavg", func_avg, 17, NULL);
cdoOperatorAdd("timvar", func_var, 17, NULL);
cdoOperatorAdd("timstd", func_std, 17, NULL);
cdoOperatorAdd("yearmin", func_min, 8, NULL);
cdoOperatorAdd("yearmax", func_max, 8, NULL);
cdoOperatorAdd("yearsum", func_sum, 8, NULL);
cdoOperatorAdd("yearmean", func_mean, 8, NULL);
cdoOperatorAdd("yearavg", func_avg, 8, NULL);
cdoOperatorAdd("yearvar", func_var, 8, NULL);
cdoOperatorAdd("yearstd", func_std, 8, NULL);
cdoOperatorAdd("monmin", func_min, 6, NULL);
cdoOperatorAdd("monmax", func_max, 6, NULL);
cdoOperatorAdd("monsum", func_sum, 6, NULL);
cdoOperatorAdd("monmean", func_mean, 6, NULL);
cdoOperatorAdd("monavg", func_avg, 6, NULL);
cdoOperatorAdd("monvar", func_var, 6, NULL);
cdoOperatorAdd("monstd", func_std, 6, NULL);
cdoOperatorAdd("daymin", func_min, 4, NULL);
cdoOperatorAdd("daymax", func_max, 4, NULL);
cdoOperatorAdd("daysum", func_sum, 4, NULL);
cdoOperatorAdd("daymean", func_mean, 4, NULL);
cdoOperatorAdd("dayavg", func_avg, 4, NULL);
cdoOperatorAdd("dayvar", func_var, 4, NULL);
cdoOperatorAdd("daystd", func_std, 4, NULL);
cdoOperatorAdd("hourmin", func_min, 2, NULL);
cdoOperatorAdd("hourmax", func_max, 2, NULL);
cdoOperatorAdd("hoursum", func_sum, 2, NULL);
cdoOperatorAdd("hourmean", func_mean, 2, NULL);
cdoOperatorAdd("houravg", func_avg, 2, NULL);
cdoOperatorAdd("hourvar", func_var, 2, NULL);
cdoOperatorAdd("hourstd", func_std, 2, NULL);
operatorID = cdoOperatorID();
......@@ -150,7 +160,7 @@ void *Timstat(void *argument)
vars1 = (FIELD **) malloc(nvars*sizeof(FIELD *));
samp1 = (FIELD **) malloc(nvars*sizeof(FIELD *));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2 = (FIELD **) malloc(nvars*sizeof(FIELD *));
for ( varID = 0; varID < nvars; varID++ )
......@@ -162,7 +172,7 @@ void *Timstat(void *argument)
vars1[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
samp1[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2[varID] = (FIELD *) malloc(nlevel*sizeof(FIELD));
for ( levelID = 0; levelID < nlevel; levelID++ )
......@@ -175,7 +185,7 @@ void *Timstat(void *argument)
samp1[varID][levelID].nmiss = 0;
samp1[varID][levelID].missval = missval;
samp1[varID][levelID].ptr = NULL;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
vars2[varID][levelID].grid = gridID;
vars2[varID][levelID].nmiss = 0;
......@@ -250,7 +260,7 @@ void *Timstat(void *argument)
samp1[varID][levelID].ptr[i]++;
}
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
farsumq(&vars2[varID][levelID], field);
farsum(&vars1[varID][levelID], field);
......@@ -262,7 +272,7 @@ void *Timstat(void *argument)
}
}
if ( nsets == 0 && operfunc == func_std )
if ( nsets == 0 && (operfunc == func_std || operfunc == func_var) )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
......@@ -292,7 +302,7 @@ void *Timstat(void *argument)
fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
}
}
else if ( operfunc == func_std )
else if ( operfunc == func_std || operfunc == func_var )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTime(vlistID1, varID) == TIME_CONSTANT ) continue;
......@@ -300,11 +310,21 @@ void *Timstat(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ )
{
if ( samp1[varID][levelID].ptr == NULL )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
{
printf("farcstd\n");
if ( operfunc == func_std )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
else
farcvar(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
}
else
{
printf("farstd\n");
farinv(&samp1[varID][levelID]);
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
if ( operfunc == func_std )
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
else
farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
}
}
}
......@@ -335,17 +355,17 @@ void *Timstat(void *argument)
{
free(vars1[varID][levelID].ptr);
if ( samp1[varID][levelID].ptr ) free(samp1[varID][levelID].ptr);
if ( operfunc == func_std ) free(vars2[varID][levelID].ptr);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID][levelID].ptr);
}
free(vars1[varID]);
free(samp1[varID]);
if ( operfunc == func_std ) free(vars2[varID]);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID]);
}
free(vars1);
free(samp1);
if ( operfunc == func_std ) free(vars2);
if ( operfunc == func_std || operfunc == func_var ) free(vars2);
if ( field.ptr ) free(field.ptr);
......
......@@ -23,6 +23,7 @@
Vertstat vertsum Vertical sum
Vertstat vertmean Vertical mean
Vertstat vertavg Vertical average
Vertstat vertvar Vertical variance
Vertstat vertstd Vertical standard deviation
*/
......@@ -60,6 +61,7 @@ void *Vertstat(void *argument)
cdoOperatorAdd("vertsum", func_sum, 0, NULL);
cdoOperatorAdd("vertmean", func_mean, 0, NULL);
cdoOperatorAdd("vertavg", func_avg, 0, NULL);
cdoOperatorAdd("vertvar", func_var, 0, NULL);
cdoOperatorAdd("vertstd", func_std, 0, NULL);
operatorID = cdoOperatorID();
......@@ -99,7 +101,7 @@ void *Vertstat(void *argument)
vars1 = (FIELD *) malloc(nvars*sizeof(FIELD));
samp1 = (FIELD *) malloc(nvars*sizeof(FIELD));
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
vars2 = (FIELD *) malloc(nvars*sizeof(FIELD));
for ( varID = 0; varID < nvars; varID++ )
......@@ -117,7 +119,7 @@ void *Vertstat(void *argument)
samp1[varID].nmiss = 0;
samp1[varID].missval = missval;
samp1[varID].ptr = NULL;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
vars2[varID].grid = gridID;
vars2[varID].nmiss = 0;
......@@ -143,7 +145,7 @@ void *Vertstat(void *argument)
streamReadRecord(streamID1, vars1[varID].ptr, &nmiss);
vars1[varID].nmiss = nmiss;
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
farmoq(&vars2[varID], vars1[varID]);
if ( nmiss > 0 || samp1[varID].ptr )
......@@ -178,7 +180,7 @@ void *Vertstat(void *argument)
samp1[varID].ptr[i]++;
}
if ( operfunc == func_std )
if ( operfunc == func_std || operfunc == func_var )
{
farsumq(&vars2[varID], field);
farsum(&vars1[varID], field);
......@@ -198,15 +200,23 @@ void *Vertstat(void *argument)
else
fardiv(&vars1[varID], samp1[varID]);
}
else if ( operfunc == func_std )
else if ( operfunc == func_std || operfunc == func_var )
for ( varID = 0; varID < nvars; varID++ )
{
if ( samp1[varID].ptr == NULL )
farcstd(&vars1[varID], vars2[varID], 1.0/vars1[varID].nsamp);
{
if ( operfunc == func_std )
farcstd(&vars1[varID], vars2[varID], 1.0/vars1[varID].nsamp);
else
farcvar(&vars1[varID], vars2[varID], 1.0/vars1[varID].nsamp);
}
else
{
farinv(&samp1[varID]);
farstd(&vars1[varID], vars2[varID], samp1[varID]);
if ( operfunc == func_std )
farstd(&vars1[varID], vars2[varID], samp1[varID]);
else
farvar(&vars1[varID], vars2[varID], samp1[varID]);
}
}
......@@ -224,12 +234,12 @@ void *Vertstat(void *argument)
{
free(vars1[varID].ptr);
if ( samp1[varID].ptr ) free(samp1[varID].ptr);
if ( operfunc == func_std ) free(vars2[varID].ptr);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID].ptr);
}
free(vars1);
free(samp1);
if ( operfunc == func_std ) free(vars2);
if ( operfunc == func_std || operfunc == func_var ) free(vars2);