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

added call to cdiInitialize() in all streamOpen functions (bug fix)

parent e0e5be73
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
2012-07-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2012-07-13 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added call to cdiInitialize() in all streamOpen functions (bug fix)
* added support for environment variable NC_CHUNKSIZEHINT [Feature #2142] * added support for environment variable NC_CHUNKSIZEHINT [Feature #2142]
2012-07-04 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de> 2012-07-04 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
...@@ -67,13 +67,11 @@ void cdf_create(const char *path, int cmode, int *ncidp) ...@@ -67,13 +67,11 @@ void cdf_create(const char *path, int cmode, int *ncidp)
if ( CDF_Debug || status != NC_NOERR ) if ( CDF_Debug || status != NC_NOERR )
Message("chunksizehint %d", chunksizehint); Message("chunksizehint %d", chunksizehint);
if ( status != NC_NOERR ) if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
Error("%s", nc_strerror(status));
status = nc_set_fill(*ncidp, NC_NOFILL, &oldfill); status = nc_set_fill(*ncidp, NC_NOFILL, &oldfill);
if ( status != NC_NOERR ) if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
Error("%s", nc_strerror(status));
} }
...@@ -102,17 +100,17 @@ int cdf_open(const char *path, int omode, int *ncidp) ...@@ -102,17 +100,17 @@ int cdf_open(const char *path, int omode, int *ncidp)
/* /*
if ( chunksizehint < ChunkSizeMin ) chunksizehint = ChunkSizeMin; if ( chunksizehint < ChunkSizeMin ) chunksizehint = ChunkSizeMin;
*/ */
if ( cdiNcChunksizehint != CDI_UNDEFID ) chunksizehint = cdiNcChunksizehint;
status = nc__open(path, omode, &chunksizehint, ncidp); status = nc__open(path, omode, &chunksizehint, ncidp);
if ( CDF_Debug ) if ( CDF_Debug ) Message("chunksizehint %d", chunksizehint);
Message("chunksizehint %d", chunksizehint);
} }
if ( CDF_Debug ) if ( CDF_Debug )
Message("ncid = %d mode = %d file = %s", *ncidp, omode, path); Message("ncid = %d mode = %d file = %s", *ncidp, omode, path);
if ( CDF_Debug && status != NC_NOERR ) if ( CDF_Debug && status != NC_NOERR ) Message("%s", nc_strerror(status));
Message("%s", nc_strerror(status));
return (status); return (status);
} }
......
...@@ -29,10 +29,10 @@ int pclose(FILE *stream); ...@@ -29,10 +29,10 @@ int pclose(FILE *stream);
void cdiPrintDefaults(void) void cdiPrintDefaults(void)
{ {
fprintf (stderr, "default instID : %d\n", cdiDefaultInstID); fprintf (stderr, "default instID : %d\n", cdiDefaultInstID);
fprintf (stderr, "default modelID : %d\n", cdiDefaultModelID); fprintf (stderr, "default modelID : %d\n", cdiDefaultModelID);
fprintf (stderr, "default tableID : %d\n", cdiDefaultTableID); fprintf (stderr, "default tableID : %d\n", cdiDefaultTableID);
fprintf (stderr, "default missval : %g\n", cdiDefaultMissval); fprintf (stderr, "default missval : %g\n", cdiDefaultMissval);
} }
...@@ -232,7 +232,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames) ...@@ -232,7 +232,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{ {
pch = &argument[i+1]; pch = &argument[i+1];
len -= (i+1); len -= (i+1);
if ( len && ( memcmp(argument, "filelist:", i) == 0 || if ( len && ( memcmp(argument, "filelist:", i) == 0 ||
memcmp(argument, "flist:", i) == 0 ) ) memcmp(argument, "flist:", i) == 0 ) )
{ {
for ( i = 0; i < len; ++i ) if ( pch[i] == ',' ) nfiles++; for ( i = 0; i < len; ++i ) if ( pch[i] == ',' ) nfiles++;
...@@ -253,7 +253,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames) ...@@ -253,7 +253,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{ {
if ( line[0] == '#' || line[0] == '\0' || if ( line[0] == '#' || line[0] == '\0' ||
line[0] == ' ' ) continue; line[0] == ' ' ) continue;
if ( nfiles >= max_fnames ) if ( nfiles >= max_fnames )
{ {
Warning("Too many input files (limit: %d)", max_fnames); Warning("Too many input files (limit: %d)", max_fnames);
...@@ -262,7 +262,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames) ...@@ -262,7 +262,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
fnames[nfiles] = strdupx(line); fnames[nfiles] = strdupx(line);
nfiles++; nfiles++;
} }
fclose(fp); fclose(fp);
if ( nfiles == 0 ) Error("No input file found in %s", pch); if ( nfiles == 0 ) Error("No input file found in %s", pch);
...@@ -270,10 +270,10 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames) ...@@ -270,10 +270,10 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
else else
{ {
char xline[65536]; char xline[65536];
strcpy(xline, pch); strcpy(xline, pch);
for ( i = 0; i < len; i++ ) if ( xline[i] == ',' ) xline[i] = 0; for ( i = 0; i < len; i++ ) if ( xline[i] == ',' ) xline[i] = 0;
nfiles++; nfiles++;
if ( nfiles >= max_fnames ) if ( nfiles >= max_fnames )
{ {
...@@ -293,14 +293,13 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames) ...@@ -293,14 +293,13 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
{ {
char command[4096]; char command[4096];
FILE *pfp; FILE *pfp;
strcpy(command, "ls "); strcpy(command, "ls ");
strcat(command, pch); strcat(command, pch);
pfp = popen(command, "r"); pfp = popen(command, "r");
if ( pfp == NULL ) if ( pfp == NULL ) SysError("popen %s failed", command);
SysError("popen %s failed", command);
nfiles = 0; nfiles = 0;
while ( _readline_(pfp, line, MAX_LINE) ) while ( _readline_(pfp, line, MAX_LINE) )
{ {
...@@ -321,7 +320,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames) ...@@ -321,7 +320,7 @@ int get_fnames(const char *argument, char *fnames[], int max_fnames)
} }
num_fnames = nfiles; num_fnames = nfiles;
return (num_fnames); return (num_fnames);
} }
...@@ -701,7 +700,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype) ...@@ -701,7 +700,7 @@ int streamOpen(const char *filename, const char *filemode, int filetype)
vlistptr->ntsteps = streamNtsteps(streamID); vlistptr->ntsteps = streamNtsteps(streamID);
} }
} }
return (streamID); return (streamID);
} }
...@@ -973,6 +972,8 @@ int streamOpenRead(const char *filenames) ...@@ -973,6 +972,8 @@ int streamOpenRead(const char *filenames)
const char *filename; const char *filename;
stream_t *streamptr = NULL; stream_t *streamptr = NULL;
cdiInitialize();
//num_fnames = get_fnames(filenames, fnames, MAX_FNAMES); //num_fnames = get_fnames(filenames, fnames, MAX_FNAMES);
if ( num_fnames == 0 ) if ( num_fnames == 0 )
...@@ -1015,6 +1016,8 @@ int streamOpenAppend(const char *filename) ...@@ -1015,6 +1016,8 @@ int streamOpenAppend(const char *filename)
int streamID; int streamID;
stream_t *streamptr; stream_t *streamptr;
cdiInitialize();
filetype = getFiletype(filename, &byteorder); filetype = getFiletype(filename, &byteorder);
if ( filetype < 0 ) return (filetype); if ( filetype < 0 ) return (filetype);
...@@ -1073,6 +1076,8 @@ if ( streamID < 0 ) handle_error(streamID); ...@@ -1073,6 +1076,8 @@ if ( streamID < 0 ) handle_error(streamID);
*/ */
int streamOpenWrite(const char *filename, int filetype) int streamOpenWrite(const char *filename, int filetype)
{ {
cdiInitialize();
return (streamOpen(filename, "w", filetype)); return (streamOpen(filename, "w", filetype));
} }
...@@ -2112,7 +2117,7 @@ int streamInqVlist(int streamID) ...@@ -2112,7 +2117,7 @@ int streamInqVlist(int streamID)
stream_t *streamptr; stream_t *streamptr;
streamptr = stream_to_pointer(streamID); streamptr = stream_to_pointer(streamID);
stream_check_ptr(__func__, streamptr); stream_check_ptr(__func__, streamptr);
return (streamptr->vlistID); return (streamptr->vlistID);
......
...@@ -191,7 +191,9 @@ void cdiInitialize(void) ...@@ -191,7 +191,9 @@ void cdiInitialize(void)
if ( CDI_Debug ) if ( CDI_Debug )
Message("Default calendar set to %s!", envString); Message("Default calendar set to %s!", envString);
} }
#if defined (HAVE_LIBCGRIBEX)
gribSetCalendar(cdiDefaultCalendar); gribSetCalendar(cdiDefaultCalendar);
#endif
envString = getenv("PARTAB_INTERN"); envString = getenv("PARTAB_INTERN");
if ( envString ) cdiPartabIntern = atoi(envString); if ( envString ) cdiPartabIntern = atoi(envString);
...@@ -581,7 +583,6 @@ void cdiCheckContents(int streamID) ...@@ -581,7 +583,6 @@ void cdiCheckContents(int streamID)
if ( zaxisInqType(zaxisID) == ZAXIS_GENERIC ) if ( zaxisInqType(zaxisID) == ZAXIS_GENERIC )
cdiCheckZaxis(zaxisID); cdiCheckZaxis(zaxisID);
} }
} }
......
...@@ -311,6 +311,7 @@ int streamInqDimgroupID(int streamID); ...@@ -311,6 +311,7 @@ int streamInqDimgroupID(int streamID);
int getByteswap(int byteorder); int getByteswap(int byteorder);
void cdiInitialize(void);
void stream_write_record(int streamID, int memtype, const void *data, int nmiss); void stream_write_record(int streamID, int memtype, const void *data, int nmiss);
......
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