Commit 7aea91d3 authored by Uwe Schulzweida's avatar Uwe Schulzweida

add suffix .sz for SZIP compressed files

parent 5ed8c4c0
......@@ -8,6 +8,7 @@
* Wind.c: define name, longname and units [report: Chiara Cagnazzo]
* add env CDO_DISABLE_HISTORY [request: Bjrge Solli]
* add env CDO_DISABLE_FILESUFFIX [request: Heiner Widmann]
* add suffix .sz for SZIP compressed files [request: Monika Esch]
* input: bug fix
* pstreamFindID: check pstreamptr->name before use (bug fix)
* operatorInqModID: speed up
......
......@@ -48,7 +48,7 @@ void *Intyear(void *argument)
int nmiss1, nmiss2, nmiss3;
int *iyears, nyears = 0, *streamIDs = NULL;
int nchars;
char *filesuffix;
char filesuffix[32];
char filename[1024];
double fac1, fac2;
double missval1, missval2;
......@@ -92,12 +92,20 @@ void *Intyear(void *argument)
strcpy(filename, cdoStreamName(2));
nchars = strlen(filename);
filesuffix = streamFilesuffix(cdoDefaultFileType);
filesuffix[0] = 0;
if ( cdoDisableFilesuffix == FALSE )
{
strcat(filesuffix, streamFilesuffix(cdoDefaultFileType));
if ( cdoDefaultFileType == FILETYPE_GRB )
if ( vlistIsSzipped(vlistID1) || cdoCompress == COMPRESS_SZIP )
strcat(filesuffix, ".sz");
}
for ( iy = 0; iy < nyears; iy++ )
{
sprintf(filename+nchars, "%04d", iyears[iy]);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+4, "%s", filesuffix);
/* printf("filename %s\n", filename); */
streamIDs[iy] = streamOpenWrite(filename, cdoFiletype());
......
......@@ -50,7 +50,7 @@ void *Split(void *argument)
int *vlistIDs = NULL, *streamIDs = NULL;
int itmp[999];
double ftmp[999];
char *filesuffix;
char filesuffix[32];
char filename[1024];
int nsplit = 0;
int index;
......@@ -83,7 +83,15 @@ void *Split(void *argument)
strcpy(filename, cdoStreamName(1));
nchars = strlen(filename);
filesuffix = streamFilesuffix(cdoDefaultFileType);
filesuffix[0] = 0;
if ( cdoDisableFilesuffix == FALSE )
{
strcat(filesuffix, streamFilesuffix(cdoDefaultFileType));
if ( cdoDefaultFileType == FILETYPE_GRB )
if ( vlistIsSzipped(vlistID1) || cdoCompress == COMPRESS_SZIP )
strcat(filesuffix, ".sz");
}
if ( operatorID == SPLITCODE )
{
......@@ -129,7 +137,7 @@ void *Split(void *argument)
vlistIDs[index] = vlistID2;
sprintf(filename+nchars, "%03d", codes[index]);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+3, "%s", filesuffix);
streamIDs[index] = streamOpenWrite(filename, cdoFiletype());
if ( streamIDs[index] < 0 ) cdiError(streamIDs[index], "Open failed on %s", filename);
......@@ -165,7 +173,7 @@ void *Split(void *argument)
filename[nchars] = '\0';
vlistInqVarName(vlistID1, varID, varname);
strcat(filename, varname);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
strcat(filename, filesuffix);
streamIDs[index] = streamOpenWrite(filename, cdoFiletype());
if ( streamIDs[index] < 0 ) cdiError(streamIDs[index], "Open failed on %s", filename);
......@@ -219,7 +227,7 @@ void *Split(void *argument)
vlistIDs[index] = vlistID2;
sprintf(filename+nchars, "%06g", levels[index]);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+6, "%s", filesuffix);
streamIDs[index] = streamOpenWrite(filename, cdoFiletype());
if ( streamIDs[index] < 0 ) cdiError(streamIDs[index], "Open failed on %s", filename);
......@@ -263,7 +271,7 @@ void *Split(void *argument)
vlistIDs[index] = vlistID2;
sprintf(filename+nchars, "%02d", gridIDs[index]+1);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+2, "%s", filesuffix);
streamIDs[index] = streamOpenWrite(filename, cdoFiletype());
if ( streamIDs[index] < 0 ) cdiError(streamIDs[index], "Open failed on %s", filename);
......@@ -306,7 +314,7 @@ void *Split(void *argument)
vlistIDs[index] = vlistID2;
sprintf(filename+nchars, "%02d", zaxisIDs[index]+1);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+2, "%s", filesuffix);
streamIDs[index] = streamOpenWrite(filename, cdoFiletype());
if ( streamIDs[index] < 0 ) cdiError(streamIDs[index], "Open failed on %s", filename);
......
......@@ -40,7 +40,7 @@ void *Splitrec(void *argument)
int tsID, recID, levelID;
int varID2, levelID2;
int vlistID1, vlistID2;
char *filesuffix;
char filesuffix[32];
char filename[4096];
int index;
int lcopy = FALSE;
......@@ -61,7 +61,15 @@ void *Splitrec(void *argument)
strcpy(filename, cdoStreamName(1));
nchars = strlen(filename);
filesuffix = streamFilesuffix(cdoDefaultFileType);
filesuffix[0] = 0;
if ( cdoDisableFilesuffix == FALSE )
{
strcat(filesuffix, streamFilesuffix(cdoDefaultFileType));
if ( cdoDefaultFileType == FILETYPE_GRB )
if ( vlistIsSzipped(vlistID1) || cdoCompress == COMPRESS_SZIP )
strcat(filesuffix, ".sz");
}
if ( ! lcopy )
{
......@@ -85,7 +93,7 @@ void *Splitrec(void *argument)
index++;
sprintf(filename+nchars, "%06d", index);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+6, "%s", filesuffix);
if ( cdoVerbose ) cdoPrint("create file %s", filename);
......
......@@ -48,7 +48,7 @@ void *Splittime(void *argument)
int tsID, recID, levelID;
int vlistID1, vlistID2;
int streamIDs[MAX_STREAMS], tsIDs[MAX_STREAMS];
char *filesuffix;
char filesuffix[32];
char filename[1024];
char *Seas[4] = {"DJF", "MAM", "JJA", "SON"};
int index = 0;
......@@ -88,7 +88,15 @@ void *Splittime(void *argument)
strcpy(filename, cdoStreamName(1));
nchars = strlen(filename);
filesuffix = streamFilesuffix(cdoDefaultFileType);
filesuffix[0] = 0;
if ( cdoDisableFilesuffix == FALSE )
{
strcat(filesuffix, streamFilesuffix(cdoDefaultFileType));
if ( cdoDefaultFileType == FILETYPE_GRB )
if ( vlistIsSzipped(vlistID1) || cdoCompress == COMPRESS_SZIP )
strcat(filesuffix, ".sz");
}
if ( ! lcopy )
{
......@@ -134,13 +142,13 @@ void *Splittime(void *argument)
if ( operatorID == SPLITSEAS )
{
sprintf(filename+nchars, "%3s", Seas[index]);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+3, "%s", filesuffix);
}
else
{
sprintf(filename+nchars, "%02d", index);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+nchars+2, "%s", filesuffix);
}
......
......@@ -41,7 +41,7 @@ void *Splityear(void *argument)
int nrecs;
int tsID, tsID2, recID, levelID;
int vlistID1, vlistID2;
char *filesuffix;
char filesuffix[32];
char filename[1024];
int vdate;
int year1, year2;
......@@ -68,7 +68,15 @@ void *Splityear(void *argument)
strcpy(filename, cdoStreamName(1));
nchars = strlen(filename);
filesuffix = streamFilesuffix(cdoDefaultFileType);
filesuffix[0] = 0;
if ( cdoDisableFilesuffix == FALSE )
{
strcat(filesuffix, streamFilesuffix(cdoDefaultFileType));
if ( cdoDefaultFileType == FILETYPE_GRB )
if ( vlistIsSzipped(vlistID1) || cdoCompress == COMPRESS_SZIP )
strcat(filesuffix, ".sz");
}
if ( ! lcopy )
{
......@@ -109,7 +117,7 @@ void *Splityear(void *argument)
sprintf(filename+nchars, "%04d", year1);
if ( ic > 0 ) sprintf(filename+strlen(filename), "_%d", ic+1);
if ( cdoDisableFilesuffix == FALSE )
if ( filesuffix[0] )
sprintf(filename+strlen(filename), "%s", filesuffix);
if ( cdoVerbose ) cdoPrint("create file %s", filename);
......
......@@ -67,6 +67,7 @@ int cdoDefaultTableID = CDI_UNDEFID;
int cdoDisableFilesuffix = FALSE;
int cdoDisableHistory = FALSE;
int cdoCompress = 0;
int cdoLogOff = FALSE;
int cdoSilentMode = FALSE;
int cdoRegulargrid = FALSE;
......@@ -445,9 +446,15 @@ void defineCompress(const char *arg)
size_t len = strlen(arg);
if ( strncmp(arg, "szip", len) == 0 )
cdiDefCompress(COMPRESS_SZIP, 0);
{
cdoCompress = COMPRESS_SZIP;
cdiDefCompress(COMPRESS_SZIP, 0);
}
else if ( strncmp(arg, "gzip", len) == 0 )
cdiDefCompress(COMPRESS_GZIP, 6);
{
cdoCompress = COMPRESS_GZIP;
cdiDefCompress(COMPRESS_GZIP, 6);
}
else
fprintf(stderr, "Compression %s unsupported!\n", arg);
}
......
......@@ -58,8 +58,12 @@ extern int cdoTimer;
extern int cdoVerbose;
extern int cdoDebug;
extern int cdoCompress;
extern int cdoExpMode;
extern int cdoDisableFilesuffix;
void cdiError(int cdiErrno, const char *fmt, ...);
void cdoAbort(const char *fmt, ...);
void cdoWarning(const char *fmt, ...);
......@@ -103,6 +107,7 @@ void cdoDefHistory(int fileID, char *histstring);
int cdoDefineGrid(const char *gridfile);
int cdoDefineZaxis(const char *zaxisfile);
int vlistIsSzipped(int vlistID);
void vlistCompare(int vlistID1, int vlistID2, int function);
void gridWeights(int gridID, double *weights);
......
......@@ -122,6 +122,4 @@ void printFiletype(int streamID, int vlistID);
void job_submit(const char *expname, const char *jobfilename, const char *jobname);
extern int cdoDisableFilesuffix;
#endif /* _CDO_INT_H */
......@@ -65,3 +65,25 @@ void vlistCompare(int vlistID1, int vlistID2, int function)
else
cdoAbort("Internal problem! Invalid function %d", function);
}
int vlistIsSzipped(int vlistID)
{
int lszip = FALSE;
int nvars, varID;
nvars = vlistNvars(vlistID);
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarSzip(vlistID, varID) )
{
lszip = TRUE;
break;
}
}
return (lszip);
}
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