Commit 31bf5054 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cleanup memory allocation and use field_malloc()

parent 81de265e
...@@ -58,6 +58,7 @@ case "${HOSTNAME}" in ...@@ -58,6 +58,7 @@ case "${HOSTNAME}" in
--with-netcdf=/opt/local \ --with-netcdf=/opt/local \
--with-szlib=$HOME/local \ --with-szlib=$HOME/local \
--with-proj=/opt/local \ --with-proj=/opt/local \
--with-curl=/opt/local \
--with-libxml2=/usr \ --with-libxml2=/usr \
--with-magics=/Users/m214003/local/Magics-2.18.14nio \ --with-magics=/Users/m214003/local/Magics-2.18.14nio \
CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O3 -march=native -fopenmp -DHAVE_LIBYAC -I/Users/m214003/cdt/work/YAC/src" \ CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O3 -march=native -fopenmp -DHAVE_LIBYAC -I/Users/m214003/cdt/work/YAC/src" \
......
...@@ -95,6 +95,10 @@ void *Fldrms(void *argument) ...@@ -95,6 +95,10 @@ void *Fldrms(void *argument)
streamDefVlist(streamID3, vlistID3); streamDefVlist(streamID3, vlistID3);
field_init(&field1);
field_init(&field2);
field_init(&field3);
lim = vlistGridsizeMax(vlistID1); lim = vlistGridsizeMax(vlistID1);
field1.ptr = (double *) malloc(lim*sizeof(double)); field1.ptr = (double *) malloc(lim*sizeof(double));
field1.weight = NULL; field1.weight = NULL;
......
...@@ -161,6 +161,8 @@ void *Fldstat(void *argument) ...@@ -161,6 +161,8 @@ void *Fldstat(void *argument)
streamDefVlist(streamID2, vlistID2); streamDefVlist(streamID2, vlistID2);
field_init(&field);
lim = vlistGridsizeMax(vlistID1); lim = vlistGridsizeMax(vlistID1);
field.ptr = (double *) malloc(lim*sizeof(double)); field.ptr = (double *) malloc(lim*sizeof(double));
field.weight = NULL; field.weight = NULL;
......
...@@ -682,6 +682,9 @@ void *Gridboxstat(void *argument) ...@@ -682,6 +682,9 @@ void *Gridboxstat(void *argument)
streamDefVlist(streamID2, vlistID2); streamDefVlist(streamID2, vlistID2);
field_init(&field1);
field_init(&field2);
gridsize1 = gridInqSize(gridID1); gridsize1 = gridInqSize(gridID1);
field1.ptr = (double *) malloc(gridsize1*sizeof(double)); field1.ptr = (double *) malloc(gridsize1*sizeof(double));
field1.weight = NULL; field1.weight = NULL;
......
...@@ -120,6 +120,9 @@ void *Hi(void *argument) ...@@ -120,6 +120,9 @@ void *Hi(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
field_init(&field1);
field_init(&field2);
field_init(&field3);
field1.ptr = (double *) malloc(gridsize*sizeof(double)); field1.ptr = (double *) malloc(gridsize*sizeof(double));
field2.ptr = (double *) malloc(gridsize*sizeof(double)); field2.ptr = (double *) malloc(gridsize*sizeof(double));
field3.ptr = (double *) malloc(gridsize*sizeof(double)); field3.ptr = (double *) malloc(gridsize*sizeof(double));
...@@ -173,8 +176,7 @@ void *Hi(void *argument) ...@@ -173,8 +176,7 @@ void *Hi(void *argument)
if ( varID1 != varID2 || varID1 != varID3 || levelID1 != levelID2 || levelID1 != levelID3 ) if ( varID1 != varID2 || varID1 != varID3 || levelID1 != levelID2 || levelID1 != levelID3 )
cdoAbort("Input streams have different structure!"); cdoAbort("Input streams have different structure!");
if ( varID1 != FIRST_VAR ) if ( varID1 != FIRST_VAR ) continue;
continue;
field1.grid = vlistInqVarGrid(vlistID1, varID1); field1.grid = vlistInqVarGrid(vlistID1, varID1);
field1.missval = vlistInqVarMissval(vlistID1, varID1); field1.missval = vlistInqVarMissval(vlistID1, varID1);
......
...@@ -33,12 +33,11 @@ int genThinoutGrid(int gridID1, int xinc, int yinc) ...@@ -33,12 +33,11 @@ int genThinoutGrid(int gridID1, int xinc, int yinc)
{ {
int ilon, ilat, olon, olat; int ilon, ilat, olon, olat;
int gridID2, gridtype; int gridID2, gridtype;
int gridsize1, nlon1, nlat1; int nlon1, nlat1;
int gridsize2, nlon2, nlat2; int gridsize2, nlon2, nlat2;
double *xvals1, *yvals1, *xvals2, *yvals2; double *xvals1, *yvals1, *xvals2, *yvals2;
gridtype = gridInqType(gridID1); gridtype = gridInqType(gridID1);
gridsize1 = gridInqSize(gridID1);
nlon1 = gridInqXsize(gridID1); nlon1 = gridInqXsize(gridID1);
nlat1 = gridInqYsize(gridID1); nlat1 = gridInqYsize(gridID1);
...@@ -91,14 +90,13 @@ int genBoxavgGrid(int gridID1, int xinc, int yinc) ...@@ -91,14 +90,13 @@ int genBoxavgGrid(int gridID1, int xinc, int yinc)
{ {
int i, j, i1; int i, j, i1;
int gridID2, gridtype; int gridID2, gridtype;
int gridsize1, nlon1, nlat1; int nlon1, nlat1;
int gridsize2, nlon2, nlat2; int gridsize2, nlon2, nlat2;
double *xvals1, *yvals1, *xvals2, *yvals2; double *xvals1, *yvals1, *xvals2, *yvals2;
double *grid1_corner_lon = NULL, *grid1_corner_lat = NULL; double *grid1_corner_lon = NULL, *grid1_corner_lat = NULL;
double *grid2_corner_lon = NULL, *grid2_corner_lat = NULL; double *grid2_corner_lon = NULL, *grid2_corner_lat = NULL;
gridtype = gridInqType(gridID1); gridtype = gridInqType(gridID1);
gridsize1 = gridInqSize(gridID1);
nlon1 = gridInqXsize(gridID1); nlon1 = gridInqXsize(gridID1);
nlat1 = gridInqYsize(gridID1); nlat1 = gridInqYsize(gridID1);
...@@ -415,6 +413,9 @@ void *Intgrid(void *argument) ...@@ -415,6 +413,9 @@ void *Intgrid(void *argument)
gridsize = gridInqSize(gridID2); gridsize = gridInqSize(gridID2);
array2 = (double *) malloc(gridsize*sizeof(double)); array2 = (double *) malloc(gridsize*sizeof(double));
field_init(&field1);
field_init(&field2);
tsID = 0; tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) ) while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
{ {
......
...@@ -94,6 +94,9 @@ void *Intgridtraj(void *argument) ...@@ -94,6 +94,9 @@ void *Intgridtraj(void *argument)
vlistID1 = streamInqVlist(streamID1); vlistID1 = streamInqVlist(streamID1);
field_init(&field1);
field_init(&field2);
nvars = vlistNvars(vlistID1); nvars = vlistNvars(vlistID1);
nrecords = vlistNrecs(vlistID1); nrecords = vlistNrecs(vlistID1);
......
...@@ -149,6 +149,7 @@ void *Isosurface(void *argument) ...@@ -149,6 +149,7 @@ void *Isosurface(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
field_init(&field);
field.ptr = (double *) malloc(gridsize*sizeof(double)); field.ptr = (double *) malloc(gridsize*sizeof(double));
nvars = vlistNvars(vlistID1); nvars = vlistNvars(vlistID1);
...@@ -170,6 +171,7 @@ void *Isosurface(void *argument) ...@@ -170,6 +171,7 @@ void *Isosurface(void *argument)
else else
liso[varID] = FALSE; liso[varID] = FALSE;
field_init(&vars1[varID]);
vars1[varID].grid = gridID; vars1[varID].grid = gridID;
vars1[varID].zaxis = zaxisID; vars1[varID].zaxis = zaxisID;
vars1[varID].nmiss = 0; vars1[varID].nmiss = 0;
......
...@@ -129,6 +129,9 @@ void *Merstat(void *argument) ...@@ -129,6 +129,9 @@ void *Merstat(void *argument)
gridID1 = vlistInqVarGrid(vlistID1, 0); gridID1 = vlistInqVarGrid(vlistID1, 0);
nlonmax = gridInqXsize(gridID1); /* max nlon ? */ nlonmax = gridInqXsize(gridID1); /* max nlon ? */
field_init(&field1);
field_init(&field2);
lim = vlistGridsizeMax(vlistID1); lim = vlistGridsizeMax(vlistID1);
field1.ptr = (double *) malloc(lim*sizeof(double)); field1.ptr = (double *) malloc(lim*sizeof(double));
field1.weight = NULL; field1.weight = NULL;
......
...@@ -69,6 +69,9 @@ void *Monarith(void *argument) ...@@ -69,6 +69,9 @@ void *Monarith(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
field_init(&field1);
field_init(&field2);
field1.ptr = (double *) malloc(gridsize*sizeof(double)); field1.ptr = (double *) malloc(gridsize*sizeof(double));
field2.ptr = (double *) malloc(gridsize*sizeof(double)); field2.ptr = (double *) malloc(gridsize*sizeof(double));
......
...@@ -40,7 +40,6 @@ void *Regres(void *argument) ...@@ -40,7 +40,6 @@ void *Regres(void *argument)
int streamID1,/* streamID2, */streamID3; int streamID1,/* streamID2, */streamID3;
int vlistID1, vlistID2, taxisID1, taxisID2; int vlistID1, vlistID2, taxisID1, taxisID2;
int nmiss; int nmiss;
int nvars, nlevel;
int *recVarID, *recLevelID; int *recVarID, *recLevelID;
int nwork = 5; int nwork = 5;
double temp1, temp2; double temp1, temp2;
...@@ -69,7 +68,6 @@ void *Regres(void *argument) ...@@ -69,7 +68,6 @@ void *Regres(void *argument)
streamDefVlist(streamID3, vlistID2); streamDefVlist(streamID3, vlistID2);
nvars = vlistNvars(vlistID1);
nrecords = vlistNrecs(vlistID1); nrecords = vlistNrecs(vlistID1);
recVarID = (int *) malloc(nrecords*sizeof(int)); recVarID = (int *) malloc(nrecords*sizeof(int));
......
...@@ -261,6 +261,9 @@ void *Rhopot(void *argument) ...@@ -261,6 +261,9 @@ void *Rhopot(void *argument)
cdoPrint("%5d %g", i+1, pressure[i]); cdoPrint("%5d %g", i+1, pressure[i]);
} }
field_init(&to);
field_init(&sao);
field_init(&rho);
to.ptr = (double *) malloc(gridsize*nlevel*sizeof(double)); to.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
sao.ptr = (double *) malloc(gridsize*nlevel*sizeof(double)); sao.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
rho.ptr = (double *) malloc(gridsize*nlevel*sizeof(double)); rho.ptr = (double *) malloc(gridsize*nlevel*sizeof(double));
......
...@@ -77,6 +77,7 @@ void *Seascount(void *argument) ...@@ -77,6 +77,7 @@ void *Seascount(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2; if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
field_init(&field);
field.ptr = (double *) malloc(gridsize*sizeof(double)); field.ptr = (double *) malloc(gridsize*sizeof(double));
vars1 = field_malloc(vlistID1, FIELD_PTR); vars1 = field_malloc(vlistID1, FIELD_PTR);
......
...@@ -29,10 +29,8 @@ ...@@ -29,10 +29,8 @@
void *Splitsel(void *argument) void *Splitsel(void *argument)
{ {
int operatorID;
int operfunc;
int gridsize; int gridsize;
int vdate = 0, vtime = 0; //int vdate = 0, vtime = 0;
int nrecs = 0; int nrecs = 0;
int varID, levelID, recID; int varID, levelID, recID;
int tsID, tsID2; int tsID, tsID2;
...@@ -62,9 +60,6 @@ void *Splitsel(void *argument) ...@@ -62,9 +60,6 @@ void *Splitsel(void *argument)
cdoOperatorAdd("splitsel", 0, 0, NULL); cdoOperatorAdd("splitsel", 0, 0, NULL);
operatorID = cdoOperatorID();
operfunc = cdoOperatorF1(operatorID);
if ( UNCHANGED_RECORD ) lcopy = TRUE; if ( UNCHANGED_RECORD ) lcopy = TRUE;
/* operatorInputArg("nsets <noffset <nskip>>"); */ /* operatorInputArg("nsets <noffset <nskip>>"); */
...@@ -130,6 +125,7 @@ void *Splitsel(void *argument) ...@@ -130,6 +125,7 @@ void *Splitsel(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ ) for ( levelID = 0; levelID < nlevel; levelID++ )
{ {
field_init(&vars[varID][levelID]);
vars[varID][levelID].grid = gridID; vars[varID][levelID].grid = gridID;
vars[varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double)); vars[varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double));
} }
...@@ -178,9 +174,11 @@ void *Splitsel(void *argument) ...@@ -178,9 +174,11 @@ void *Splitsel(void *argument)
nrecs = streamInqTimestep(streamID1, tsID); nrecs = streamInqTimestep(streamID1, tsID);
if ( nrecs == 0 ) break; if ( nrecs == 0 ) break;
/*
vdate = taxisInqVdate(taxisID1); vdate = taxisInqVdate(taxisID1);
vtime = taxisInqVtime(taxisID1); vtime = taxisInqVtime(taxisID1);
/* printf("vdate: %d vtime: %d\n", vdate, vtime); */ printf("vdate: %d vtime: %d\n", vdate, vtime);
*/
taxisCopyTimestep(taxisID2, taxisID1); taxisCopyTimestep(taxisID2, taxisID1);
streamDefTimestep(streamID2, tsID2); streamDefTimestep(streamID2, tsID2);
......
...@@ -126,6 +126,7 @@ void *Splittime(void *argument) ...@@ -126,6 +126,7 @@ void *Splittime(void *argument)
for ( levelID = 0; levelID < nlevel; levelID++ ) for ( levelID = 0; levelID < nlevel; levelID++ )
{ {
field_init(&vars[varID][levelID]);
vars[varID][levelID].grid = gridID; vars[varID][levelID].grid = gridID;
vars[varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double)); vars[varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double));
} }
......
...@@ -92,6 +92,7 @@ void *Timcount(void *argument) ...@@ -92,6 +92,7 @@ void *Timcount(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2; if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
field_init(&field);
field.ptr = (double *) malloc(gridsize*sizeof(double)); field.ptr = (double *) malloc(gridsize*sizeof(double));
vars1 = field_malloc(vlistID1, FIELD_PTR); vars1 = field_malloc(vlistID1, FIELD_PTR);
......
...@@ -53,7 +53,6 @@ void timpctl(int operatorID) ...@@ -53,7 +53,6 @@ void timpctl(int operatorID)
int nmiss; int nmiss;
int nvars, nlevels; int nvars, nlevels;
int *recVarID, *recLevelID; int *recVarID, *recLevelID;
double missval;
field_t **vars1 = NULL; field_t **vars1 = NULL;
field_t field; field_t field;
double pn; double pn;
...@@ -101,28 +100,18 @@ void timpctl(int operatorID) ...@@ -101,28 +100,18 @@ void timpctl(int operatorID)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
field_init(&field);
field.ptr = (double *) malloc(gridsize * sizeof(double)); field.ptr = (double *) malloc(gridsize * sizeof(double));
vars1 = (field_t **) malloc(nvars * sizeof(field_t *)); vars1 = field_malloc(vlistID1, FIELD_PTR);
hset = hsetCreate(nvars); hset = hsetCreate(nvars);
for ( varID = 0; varID < nvars; varID++ ) for ( varID = 0; varID < nvars; varID++ )
{ {
gridID = vlistInqVarGrid(vlistID1, varID); gridID = vlistInqVarGrid(vlistID1, varID);
gridsize = gridInqSize(gridID);
nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID)); nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
missval = vlistInqVarMissval(vlistID1, varID);
vars1[varID] = (field_t *) malloc(nlevels*sizeof(field_t));
hsetCreateVarLevels(hset, varID, nlevels, gridID); hsetCreateVarLevels(hset, varID, nlevels, gridID);
for ( levelID = 0; levelID < nlevels; levelID++ )
{
vars1[varID][levelID].grid = gridID;
vars1[varID][levelID].nmiss = 0;
vars1[varID][levelID].missval = missval;
vars1[varID][levelID].ptr = (double *) malloc(gridsize * sizeof(double));
}
} }
tsID = 0; tsID = 0;
...@@ -227,15 +216,7 @@ void timpctl(int operatorID) ...@@ -227,15 +216,7 @@ void timpctl(int operatorID)
otsID++; otsID++;
} }
for ( varID = 0; varID < nvars; varID++ ) field_free(vars1, vlistID1);
{
nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevels; levelID++ )
free(vars1[varID][levelID].ptr);
free(vars1[varID]);
}
free(vars1);
hsetDestroy(hset); hsetDestroy(hset);
if ( field.ptr ) free(field.ptr); if ( field.ptr ) free(field.ptr);
......
...@@ -48,7 +48,6 @@ void *Timselpctl(void *argument) ...@@ -48,7 +48,6 @@ void *Timselpctl(void *argument)
int nvars, nlevels; int nvars, nlevels;
int ndates = 0, noffset = 0, nskip = 0, nargc; int ndates = 0, noffset = 0, nskip = 0, nargc;
int *recVarID, *recLevelID; int *recVarID, *recLevelID;
double missval;
field_t **vars1 = NULL; field_t **vars1 = NULL;
field_t field; field_t field;
double pn; double pn;
...@@ -106,28 +105,18 @@ void *Timselpctl(void *argument) ...@@ -106,28 +105,18 @@ void *Timselpctl(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
field_init(&field);
field.ptr = (double *) malloc(gridsize * sizeof(double)); field.ptr = (double *) malloc(gridsize * sizeof(double));
vars1 = (field_t **) malloc(nvars * sizeof(field_t *)); vars1 = field_malloc(vlistID1, FIELD_PTR);
hset = hsetCreate(nvars); hset = hsetCreate(nvars);
for ( varID = 0; varID < nvars; varID++ ) for ( varID = 0; varID < nvars; varID++ )
{ {
gridID = vlistInqVarGrid(vlistID1, varID); gridID = vlistInqVarGrid(vlistID1, varID);
gridsize = gridInqSize(gridID);
nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID)); nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
missval = vlistInqVarMissval(vlistID1, varID);
vars1[varID] = (field_t *) malloc(nlevels * sizeof(field_t));
hsetCreateVarLevels(hset, varID, nlevels, gridID); hsetCreateVarLevels(hset, varID, nlevels, gridID);
for ( levelID = 0; levelID < nlevels; levelID++ )
{
vars1[varID][levelID].grid = gridID;
vars1[varID][levelID].nmiss = 0;
vars1[varID][levelID].missval = missval;
vars1[varID][levelID].ptr = (double *) malloc(gridsize * sizeof(double));
}
} }
for ( tsID = 0; tsID < noffset; tsID++ ) for ( tsID = 0; tsID < noffset; tsID++ )
...@@ -262,15 +251,7 @@ void *Timselpctl(void *argument) ...@@ -262,15 +251,7 @@ void *Timselpctl(void *argument)
LABEL_END: LABEL_END:
for ( varID = 0; varID < nvars; varID++ ) field_free(vars1, vlistID1);
{
nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevels; levelID++ )
free(vars1[varID][levelID].ptr);
free(vars1[varID]);
}
free(vars1);
hsetDestroy(hset); hsetDestroy(hset);
if ( field.ptr ) free(field.ptr); if ( field.ptr ) free(field.ptr);
......
...@@ -115,6 +115,7 @@ void *Timselstat(void *argument) ...@@ -115,6 +115,7 @@ void *Timselstat(void *argument)
gridsize = vlistGridsizeMax(vlistID1); gridsize = vlistGridsizeMax(vlistID1);
field_init(&field);
field.ptr = (double *) malloc(gridsize*sizeof(double)); field.ptr = (double *) malloc(gridsize*sizeof(double));
vars1 = field_malloc(vlistID1, FIELD_PTR); vars1 = field_malloc(vlistID1, FIELD_PTR);
......
...@@ -65,7 +65,6 @@ void *Timsort(void *argument) ...@@ -65,7 +65,6 @@ void *Timsort(void *argument)
int nvars, nlevel; int nvars, nlevel;
int *vdate = NULL, *vtime = NULL; int *vdate = NULL, *vtime = NULL;
int ompthID; int ompthID;
double missval;
double **sarray = NULL; double **sarray = NULL;
field_t ***vars = NULL; field_t ***vars = NULL;
...@@ -100,23 +99,7 @@ void *Timsort(void *argument) ...@@ -100,23 +99,7 @@ void *Timsort(void *argument)
vdate[tsID] = taxisInqVdate(taxisID1); vdate[tsID] = taxisInqVdate(taxisID1);
vtime[tsID] = taxisInqVtime(taxisID1); vtime[tsID] = taxisInqVtime(taxisID1);
vars[tsID] = (field_t **) malloc(nvars*sizeof(field_t *)); vars[tsID] = field_malloc(vlistID1, FIELD_NONE);
for ( varID = 0; varID < nvars; varID++ )
{
gridID = vlistInqVarGrid(vlistID1, varID);
missval = vlistInqVarMissval(vlistID1, varID);
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
vars[tsID][varID] = (field_t *) malloc(nlevel*sizeof(field_t));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
vars[tsID][varID][levelID].grid = gridID;
vars[tsID][varID][levelID].missval = missval;
vars[tsID][varID][levelID].ptr = NULL;
}
}
for ( recID = 0; recID < nrecs; recID++ ) for ( recID = 0; recID < nrecs; recID++ )
{ {
...@@ -188,12 +171,11 @@ void *Timsort(void *argument) ...@@ -188,12 +171,11 @@ void *Timsort(void *argument)
nmiss = vars[tsID][varID][levelID].nmiss; nmiss = vars[tsID][varID][levelID].nmiss;
streamDefRecord(streamID2, varID, levelID); streamDefRecord(streamID2, varID, levelID);
streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss); streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
free(vars[tsID][varID][levelID].ptr);
} }
} }
free(vars[tsID][varID]);
} }
free(vars[tsID]);
field_free(vars[tsID], vlistID1);
} }
if ( vars ) free(vars); if ( vars ) free(vars);
......