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

CDI: changed compression type from Ztype to CompType

parent ec22c66a
2011-06-01 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* CDI: changed compression type from Ztype to CompType
2011-05-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* gridGenYvals: changed delta eps to 0.002 for gaussian grids [report: John Lillibridge]
......
......@@ -35,9 +35,7 @@ int vlistInqVarMissvalUsed(int vlistID, int varID);
#include "printinfo.h"
void cdiDecodeDate(int date, int *year, int *month, int *day);
void cdiDecodeTime(int time, int *hour, int *minute, int *second);
void cdiDefTableID(int tableID);
int getopt(int argc, char *const argv[], const char *optstring);
......@@ -51,7 +49,7 @@ int DefaultFileType = CDI_UNDEFID;
int DefaultDataType = CDI_UNDEFID;
int DefaultByteorder = CDI_UNDEFID;
int Ztype = COMPRESS_NONE;
int comptype = COMPRESS_NONE;
int Zlevel = 0;
......@@ -308,7 +306,7 @@ void printShortinfo(int streamID, int vlistID, int vardis)
fprintf(stdout, " %-3s", pstr);
if ( vlistInqVarZtype(vlistID, varID) == COMPRESS_NONE )
if ( vlistInqVarCompType(vlistID, varID) == COMPRESS_NONE )
fprintf(stdout, " ");
else
fprintf(stdout, "z");
......@@ -644,20 +642,20 @@ void defineCompress(const char *arg)
if ( strncmp(arg, "szip", len) == 0 )
{
Ztype = COMPRESS_SZIP;
comptype = COMPRESS_SZIP;
}
else if ( strncmp(arg, "jpeg", len) == 0 )
{
Ztype = COMPRESS_JPEG;
comptype = COMPRESS_JPEG;
}
else if ( strncmp(arg, "gzip", len) == 0 )
{
Ztype = COMPRESS_GZIP;
comptype = COMPRESS_GZIP;
Zlevel = 6;
}
else if ( strncmp(arg, "zip", len) == 0 )
{
Ztype = COMPRESS_ZIP;
comptype = COMPRESS_ZIP;
Zlevel = 1;
}
else
......@@ -844,9 +842,9 @@ int main(int argc, char *argv[])
if ( DefaultByteorder != CDI_UNDEFID )
streamDefByteorder(streamID2, DefaultByteorder);
if ( Ztype != COMPRESS_NONE )
if ( comptype != COMPRESS_NONE )
{
streamDefZtype(streamID2, Ztype);
streamDefCompType(streamID2, comptype);
streamDefZlevel(streamID2, Zlevel);
}
......
......@@ -84,18 +84,18 @@ void printFiletype(int streamID, int vlistID)
if ( filetype == FILETYPE_GRB || filetype == FILETYPE_NC4 || filetype == FILETYPE_NC4C )
{
int nvars, varID;
int ztype;
int comptype;
nvars = vlistNvars(vlistID);
for ( varID = 0; varID < nvars; varID++ )
{
ztype = vlistInqVarZtype(vlistID, varID);
if ( ztype )
comptype = vlistInqVarCompType(vlistID, varID);
if ( comptype )
{
if ( ztype == COMPRESS_SZIP )
if ( comptype == COMPRESS_SZIP )
printf(" SZIP");
else if ( ztype == COMPRESS_ZIP )
else if ( comptype == COMPRESS_ZIP )
printf(" ZIP");
break;
......@@ -106,16 +106,16 @@ void printFiletype(int streamID, int vlistID)
if ( filetype == FILETYPE_GRB2 )
{
int nvars, varID;
int ztype;
int comptype;
nvars = vlistNvars(vlistID);
for ( varID = 0; varID < nvars; varID++ )
{
ztype = vlistInqVarZtype(vlistID, varID);
if ( ztype )
comptype = vlistInqVarCompType(vlistID, varID);
if ( comptype )
{
if ( ztype == COMPRESS_JPEG )
if ( comptype == COMPRESS_JPEG )
printf(" JPEG");
break;
......
......@@ -355,6 +355,15 @@ Close an open dataset.
Define the byteorder.
\section*{\tt \htmlref{streamDefCompType}{streamDefCompType}}
\begin{verbatim}
void streamDefCompType (intstreamID, intcomptype);
\end{verbatim}
Define compression type.
\section*{\tt \htmlref{streamDefTimestep}{streamDefTimestep}}
\begin{verbatim}
......@@ -382,22 +391,22 @@ Define the Vlist for a stream.
Define compression level.
\section*{\tt \htmlref{streamDefZtype}{streamDefZtype}}
\section*{\tt \htmlref{streamInqByteorder}{streamInqByteorder}}
\begin{verbatim}
void streamDefZtype (intstreamID, intztype);
int streamInqByteorder (intstreamID);
\end{verbatim}
Define compression type.
Get the byteorder.
\section*{\tt \htmlref{streamInqByteorder}{streamInqByteorder}}
\section*{\tt \htmlref{streamInqCompType}{streamInqCompType}}
\begin{verbatim}
int streamInqByteorder (intstreamID);
int streamInqCompType (intstreamID);
\end{verbatim}
Get the byteorder.
Get compression type.
\section*{\tt \htmlref{streamInqFiletype}{streamInqFiletype}}
......@@ -436,15 +445,6 @@ Get the Vlist of a stream.
Get compression level.
\section*{\tt \htmlref{streamInqZtype}{streamInqZtype}}
\begin{verbatim}
int streamInqZtype (intstreamID);
\end{verbatim}
Get compression type.
\section*{\tt \htmlref{streamOpenRead}{streamOpenRead}}
\begin{verbatim}
......
......@@ -355,6 +355,15 @@ Close an open dataset.
Define the byteorder.
\section*{\tt \htmlref{streamDefCompType}{streamDefCompType}}
\begin{verbatim}
SUBROUTINE streamDefCompType (INTEGER streamID, INTEGER comptype)
\end{verbatim}
Define compression type.
\section*{\tt \htmlref{streamDefTimestep}{streamDefTimestep}}
\begin{verbatim}
......@@ -382,22 +391,22 @@ Define the Vlist for a stream.
Define compression level.
\section*{\tt \htmlref{streamDefZtype}{streamDefZtype}}
\section*{\tt \htmlref{streamInqByteorder}{streamInqByteorder}}
\begin{verbatim}
SUBROUTINE streamDefZtype (INTEGER streamID, INTEGER ztype)
INTEGER FUNCTION streamInqByteorder (INTEGER streamID)
\end{verbatim}
Define compression type.
Get the byteorder.
\section*{\tt \htmlref{streamInqByteorder}{streamInqByteorder}}
\section*{\tt \htmlref{streamInqCompType}{streamInqCompType}}
\begin{verbatim}
INTEGER FUNCTION streamInqByteorder (INTEGER streamID)
INTEGER FUNCTION streamInqCompType (INTEGER streamID)
\end{verbatim}
Get the byteorder.
Get compression type.
\section*{\tt \htmlref{streamInqFiletype}{streamInqFiletype}}
......@@ -436,15 +445,6 @@ Get the Vlist of a stream.
Get compression level.
\section*{\tt \htmlref{streamInqZtype}{streamInqZtype}}
\begin{verbatim}
INTEGER FUNCTION streamInqZtype (INTEGER streamID)
\end{verbatim}
Get compression type.
\section*{\tt \htmlref{streamOpenRead}{streamOpenRead}}
\begin{verbatim}
......
......@@ -256,14 +256,14 @@ void streamDefByteorder(int streamID, int byteorder);
/* streamInqByteorder: Get the byteorder */
int streamInqByteorder(int streamID);
/* streamDefZtype: Define compression type */
void streamDefZtype(int streamID, int ztype);
/* streamDefCompType: Define compression type */
void streamDefCompType(int streamID, int comptype);
/* streamDefZlevel: Define compression level */
void streamDefZlevel(int streamID, int zlevel);
/* streamInqZtype: Get compression type */
int streamInqZtype(int streamID);
/* streamInqCompType: Get compression type */
int streamInqCompType(int streamID);
/* streamInqZlevel: Get compression level */
int streamInqZlevel(int streamID);
......@@ -384,8 +384,8 @@ int vlistInqVarGrid(int vlistID, int varID);
int vlistInqVarZaxis(int vlistID, int varID);
int vlistInqVarTime(int vlistID, int varID);
void vlistDefVarZtype(int vlistID, int varID, int ztype);
int vlistInqVarZtype(int vlistID, int varID);
void vlistDefVarCompType(int vlistID, int varID, int comptype);
int vlistInqVarCompType(int vlistID, int varID);
void vlistDefVarZlevel(int vlistID, int varID, int zlevel);
int vlistInqVarZlevel(int vlistID, int varID);
......
......@@ -4,7 +4,7 @@
!
! Author:
! -------
! Uwe Schulzweida, MPI-MET, Hamburg, May 2011
! Uwe Schulzweida, MPI-MET, Hamburg, June 2011
!
INTEGER CDI_MAX_NAME
......@@ -214,6 +214,8 @@
PARAMETER (GRID_SINUSOIDAL = 14)
INTEGER GRID_REFERENCE
PARAMETER (GRID_REFERENCE = 15)
INTEGER GRID_PROJECTION
PARAMETER (GRID_PROJECTION = 16)
!
! ZAXIS types
!
......@@ -442,19 +444,19 @@
! (INTEGER streamID)
EXTERNAL streamInqByteorder
! streamDefZtype
! streamDefCompType
! (INTEGER streamID,
! INTEGER ztype)
EXTERNAL streamDefZtype
! INTEGER comptype)
EXTERNAL streamDefCompType
! streamDefZlevel
! (INTEGER streamID,
! INTEGER zlevel)
EXTERNAL streamDefZlevel
INTEGER streamInqZtype
INTEGER streamInqCompType
! (INTEGER streamID)
EXTERNAL streamInqZtype
EXTERNAL streamInqCompType
INTEGER streamInqZlevel
! (INTEGER streamID)
......@@ -747,16 +749,16 @@
! INTEGER varID)
EXTERNAL vlistInqVarTime
! vlistDefVarZtype
! vlistDefVarCompType
! (INTEGER vlistID,
! INTEGER varID,
! INTEGER ztype)
EXTERNAL vlistDefVarZtype
! INTEGER comptype)
EXTERNAL vlistDefVarCompType
INTEGER vlistInqVarZtype
INTEGER vlistInqVarCompType
! (INTEGER vlistID,
! INTEGER varID)
EXTERNAL vlistInqVarZtype
EXTERNAL vlistInqVarCompType
! vlistDefVarZlevel
! (INTEGER vlistID,
......
......@@ -89,9 +89,9 @@ FCALLSCFUN1 (INT, streamInqVlist, STREAMINQVLIST, streaminqvlist, INT)
FCALLSCFUN1 (INT, streamInqFiletype, STREAMINQFILETYPE, streaminqfiletype, INT)
FCALLSCSUB2 (streamDefByteorder, STREAMDEFBYTEORDER, streamdefbyteorder, INT, INT)
FCALLSCFUN1 (INT, streamInqByteorder, STREAMINQBYTEORDER, streaminqbyteorder, INT)
FCALLSCSUB2 (streamDefZtype, STREAMDEFZTYPE, streamdefztype, INT, INT)
FCALLSCSUB2 (streamDefCompType, STREAMDEFCOMPTYPE, streamdefcomptype, INT, INT)
FCALLSCSUB2 (streamDefZlevel, STREAMDEFZLEVEL, streamdefzlevel, INT, INT)
FCALLSCFUN1 (INT, streamInqZtype, STREAMINQZTYPE, streaminqztype, INT)
FCALLSCFUN1 (INT, streamInqCompType, STREAMINQCOMPTYPE, streaminqcomptype, INT)
FCALLSCFUN1 (INT, streamInqZlevel, STREAMINQZLEVEL, streaminqzlevel, INT)
FCALLSCFUN2 (INT, streamDefTimestep, STREAMDEFTIMESTEP, streamdeftimestep, INT, INT)
FCALLSCFUN2 (INT, streamInqTimestep, STREAMINQTIMESTEP, streaminqtimestep, INT, INT)
......@@ -159,8 +159,8 @@ FCALLSCSUB5 (vlistInqVar, VLISTINQVAR, vlistinqvar, INT, INT, PINT, PINT, PINT)
FCALLSCFUN2 (INT, vlistInqVarGrid, VLISTINQVARGRID, vlistinqvargrid, INT, INT)
FCALLSCFUN2 (INT, vlistInqVarZaxis, VLISTINQVARZAXIS, vlistinqvarzaxis, INT, INT)
FCALLSCFUN2 (INT, vlistInqVarTime, VLISTINQVARTIME, vlistinqvartime, INT, INT)
FCALLSCSUB3 (vlistDefVarZtype, VLISTDEFVARZTYPE, vlistdefvarztype, INT, INT, INT)
FCALLSCFUN2 (INT, vlistInqVarZtype, VLISTINQVARZTYPE, vlistinqvarztype, INT, INT)
FCALLSCSUB3 (vlistDefVarCompType, VLISTDEFVARCOMPTYPE, vlistdefvarcomptype, INT, INT, INT)
FCALLSCFUN2 (INT, vlistInqVarCompType, VLISTINQVARCOMPTYPE, vlistinqvarcomptype, INT, INT)
FCALLSCSUB3 (vlistDefVarZlevel, VLISTDEFVARZLEVEL, vlistdefvarzlevel, INT, INT, INT)
FCALLSCFUN2 (INT, vlistInqVarZlevel, VLISTINQVARZLEVEL, vlistinqvarzlevel, INT, INT)
FCALLSCSUB3 (vlistDefVarParam, VLISTDEFVARPARAM, vlistdefvarparam, INT, INT, INT)
......
......@@ -2052,7 +2052,7 @@ int streamInqVlist(int streamID)
}
void streamDefZtype(int streamID, int ztype)
void streamDefCompType(int streamID, int comptype)
{
stream_t *streamptr;
......@@ -2060,7 +2060,7 @@ void streamDefZtype(int streamID, int ztype)
stream_check_ptr(__func__, streamptr);
streamptr->ztype = ztype;
streamptr->comptype = comptype;
}
......@@ -2076,7 +2076,7 @@ void streamDefZlevel(int streamID, int zlevel)
}
int streamInqZtype(int streamID)
int streamInqCompType(int streamID)
{
stream_t *streamptr;
......@@ -2084,7 +2084,7 @@ int streamInqZtype(int streamID)
stream_check_ptr(__func__, streamptr);
return (streamptr->ztype);
return (streamptr->comptype);
}
......
......@@ -2754,7 +2754,7 @@ int cdfDefVar(int streamID, int varID)
}
#endif
if ( streamptr->ztype == COMPRESS_ZIP )
if ( streamptr->comptype == COMPRESS_ZIP )
{
if ( lchunk && (streamptr->filetype == FILETYPE_NC4 || streamptr->filetype == FILETYPE_NC4C) )
{
......@@ -2772,7 +2772,7 @@ int cdfDefVar(int streamID, int varID)
}
}
if ( streamptr->ztype == COMPRESS_SZIP )
if ( streamptr->comptype == COMPRESS_SZIP )
{
if ( lchunk && (streamptr->filetype == FILETYPE_NC4 || streamptr->filetype == FILETYPE_NC4C) )
{
......@@ -6109,7 +6109,7 @@ int cdfInqContents(int streamID)
#if defined (HAVE_NETCDF4)
if ( ncvars[ncvarid].deflate )
vlistDefVarZtype(vlistID, varID, COMPRESS_ZIP);
vlistDefVarCompType(vlistID, varID, COMPRESS_ZIP);
#endif
streamptr->vars[varID1].level = NULL;
......
......@@ -348,7 +348,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid)
#if defined (HAVE_LIBCGRIBEX)
static
void cgribexAddRecord(int streamID, int param, int *isec1, int *isec2, double *fsec2, double *fsec3,
int *isec4, long recsize, off_t position, int prec, int ztype, int lmv)
int *isec4, long recsize, off_t position, int prec, int comptype, int lmv)
{
int zaxistype;
int gridID = CDI_UNDEFID, varID;
......@@ -410,7 +410,7 @@ void cgribexAddRecord(int streamID, int param, int *isec1, int *isec2, double *f
(*record).varID = varID;
(*record).levelID = levelID;
varDefZtype(varID, ztype);
varDefCompType(varID, comptype);
if ( lmv ) varDefMissval(varID, FSEC3_MissVal);
......@@ -531,7 +531,7 @@ int cgribexScanTimestep1(int streamID)
int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
taxis_t *taxis;
int vlistID;
int ztype;
int comptype;
long unzipsize;
compvar_t compVar, compVar0;
stream_t *streamptr;
......@@ -592,10 +592,10 @@ int cgribexScanTimestep1(int streamID)
rstatus = gribRead(fileID, gribbuffer, &readsize);
if ( rstatus ) break;
ztype = COMPRESS_NONE;
comptype = COMPRESS_NONE;
if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
{
ztype = COMPRESS_SZIP;
comptype = COMPRESS_SZIP;
unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
if ( (long) buffersize < unzipsize )
{
......@@ -693,7 +693,7 @@ int cgribexScanTimestep1(int streamID)
Message("%4d %8d %4d %8d %8d %6d", nrecs, (int)recpos, param, level1, vdate, vtime);
cgribexAddRecord(streamID, param, isec1, isec2, fsec2, fsec3,
isec4, recsize, recpos, prec, ztype, lmv);
isec4, recsize, recpos, prec, comptype, lmv);
}
streamptr->rtsteps = 1;
......
......@@ -549,7 +549,7 @@ int grbWriteVarSliceDP(int streamID, int varID, int levelID, const double *data,
gc = (void *) &gribContainers[varID];
}
if ( streamptr->ztype == COMPRESS_JPEG )
if ( streamptr->comptype == COMPRESS_JPEG )
{
if ( filetype == FILETYPE_GRB2 )
{
......@@ -565,7 +565,7 @@ int grbWriteVarSliceDP(int streamID, int varID, int levelID, const double *data,
nbytes = grbEncode(filetype, varID, levelID, vlistID, gridID, zaxisID, date, time, tsteptype, numavg,
datasize, data, nmiss, gribbuffer, gribbuffersize, ljpeg, gc);
if ( streamptr->ztype == COMPRESS_SZIP )
if ( streamptr->comptype == COMPRESS_SZIP )
nbytes = grbSzip(filetype, gribbuffer, nbytes);
nwrite = fileWrite(fileID, gribbuffer, nbytes);
......@@ -641,7 +641,7 @@ int grbCopyRecord(int streamID2, int streamID1)
izip = gribGetZip(recsize, gribbuffer, &unzipsize);
if ( izip == 0 )
if ( streamptr2->ztype == COMPRESS_SZIP )
if ( streamptr2->comptype == COMPRESS_SZIP )
nbytes = grbSzip(filetype, gribbuffer, nbytes);
while ( nbytes & 7 ) gribbuffer[nbytes++] = 0;
......
......@@ -536,7 +536,7 @@ double grib2GetLevel(grib_handle *gh, int leveltype)
static
void gribapiAddRecord(int streamID, int param, grib_handle *gh,
long recsize, off_t position, int prec, int ztype)
long recsize, off_t position, int prec, int comptype)
{
long editionNumber;
int zaxistype;
......@@ -670,7 +670,7 @@ void gribapiAddRecord(int streamID, int param, grib_handle *gh,
(*record).varID = varID;
(*record).levelID = levelID;
varDefZtype(varID, ztype);
varDefCompType(varID, comptype);
if ( varInqInst(varID) == CDI_UNDEFID )
{
......@@ -753,7 +753,7 @@ int gribapiScanTimestep1(int streamID)
int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
taxis_t *taxis;
int vlistID;
int ztype;
int comptype;
long unzipsize;
compvar2_t compVar, compVar0;
stream_t *streamptr;
......@@ -800,10 +800,10 @@ int gribapiScanTimestep1(int streamID)
rstatus = gribRead(fileID, gribbuffer, &readsize);
if ( rstatus ) break;
ztype = COMPRESS_NONE;
comptype = COMPRESS_NONE;
if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
{
ztype = COMPRESS_SZIP;
comptype = COMPRESS_SZIP;
unzipsize += 100;
if ( (long) buffersize < unzipsize )
{
......@@ -848,7 +848,7 @@ int gribapiScanTimestep1(int streamID)
if ( status == 0 )
{
// fprintf(stderr, "packingType %d %s\n", len, typeOfPacking);
if ( strncmp(typeOfPacking, "grid_jpeg", len) == 0 ) ztype = COMPRESS_JPEG;
if ( strncmp(typeOfPacking, "grid_jpeg", len) == 0 ) comptype = COMPRESS_JPEG;
}
GRIB_CHECK(grib_get_long(gh, "discipline", &lpar), 0);
......@@ -971,7 +971,7 @@ int gribapiScanTimestep1(int streamID)
if ( CDI_Debug )
Message("%4d %8d %4d %8d %8d %6d", nrecs, (int)recpos, param, level1, vdate, vtime);
gribapiAddRecord(streamID, param, gh, recsize, recpos, prec, ztype);
gribapiAddRecord(streamID, param, gh, recsize, recpos, prec, comptype);
grib_handle_delete(gh);
gh = NULL;
......
......@@ -409,7 +409,7 @@ void stream_init_entry(stream_t *streamptr)
streamptr->unreduced = cdiDataUnreduced;
streamptr->sortname = cdiSortName;
streamptr->have_missval = cdiHaveMissval;
streamptr->ztype = COMPRESS_NONE;
streamptr->comptype = COMPRESS_NONE;
streamptr->zlevel = 0;
basetimeInit(&streamptr->basetime);
......
......@@ -238,7 +238,7 @@ typedef struct {
int unreduced;
int sortname;
int have_missval;
int ztype;
int comptype; /* compression type */
int zlevel;
int curfile;
int nfiles;
......
......@@ -44,7 +44,7 @@ typedef struct
int instID;
int modelID;
int tableID;
int ztype;
int comptype; // compression type
int zlevel;
int lmissval;
double missval;
......@@ -78,7 +78,7 @@ void paramInitEntry(int varID, int param)
vartable[varID].instID = UNDEFID;
vartable[varID].modelID = UNDEFID;
vartable[varID].tableID = UNDEFID;
vartable[varID].ztype = COMPRESS_NONE;
vartable[varID].comptype = COMPRESS_NONE;
vartable[varID].zlevel = 1;
vartable[varID].lmissval = 0;
vartable[varID].missval = 0;
......@@ -387,7 +387,7 @@ void cdiGenVars(int streamID)
int tsteptype;
int timave, timaccu;
int lbounds;
int ztype;
int comptype;
char name[256], longname[256], units[256];
double *dlevels = NULL;
double *dlevels1 = NULL;
......@@ -448,7 +448,7 @@ void cdiGenVars(int streamID)
tsteptype = vartable[varid].tsteptype;
timave = vartable[varid].timave;
timaccu = vartable[varid].timaccu;
ztype = vartable[varid].ztype;
comptype = vartable[varid].comptype;
zaxisID = UNDEFID;
......@@ -529,7 +529,7 @@ void cdiGenVars(int streamID)
vlistDefVarTsteptype(vlistID, varID, tsteptype);
vlistDefVarTimave(vlistID, varID, timave);
vlistDefVarTimaccu(vlistID, varID, timaccu);
vlistDefVarZtype(vlistID, varID, ztype);
vlistDefVarCompType(vlistID, varID, comptype);
if ( vartable[varid].lmissval ) vlistDefVarMissval(vlistID, varID, vartable[varid].missval);
......@@ -827,10 +827,10 @@ void varDefMissval(int varID, double missval)
}