Commit 88713abc authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdoDefineGrid: lock call to streamOpenRead

parent 8c958f19
......@@ -78,6 +78,8 @@ void *Arith(void *argument)
vlistIDx1 = vlistID1;
vlistIDx2 = vlistID2;
if ( cdoVerbose ) vlistPrint(vlistID1);
taxisID1 = vlistInqTaxis(vlistID1);
taxisID2 = vlistInqTaxis(vlistID2);
taxisIDx1 = taxisID1;
......
......@@ -130,7 +130,7 @@ int import_e5ml(const char *filename, VAR **vars)
/* open file and check file type */
/* nce(nc_open(filename, NC_NOWRITE, &nc_file_id)); */
nc_file_id = pcdf_openread(filename);
nc_file_id = cdf_openread(filename);
nce(nc_get_att_text(nc_file_id, NC_GLOBAL, "file_type", filetype));
nce(nc_inq_attlen(nc_file_id, NC_GLOBAL, "file_type", &attlen));
......@@ -717,7 +717,7 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
/* open file and check file type */
/* nce(nc_open(filename, NC_NOWRITE, &nc_file_id)); */
nc_file_id = pcdf_openread(filename);
nc_file_id = cdf_openread(filename);
nce(nc_get_att_text(nc_file_id, NC_GLOBAL, "file_type", filetype));
nce(nc_inq_attlen(nc_file_id, NC_GLOBAL, "file_type", &attlen));
......
......@@ -51,6 +51,8 @@ void *Enlarge(void *argument)
xsize2 = gridInqXsize(gridID2);
ysize2 = gridInqYsize(gridID2);
if ( cdoVerbose ) fprintf(stderr, "gridID2 %d, xsize2 %d, ysize2 %d\n", gridID2, xsize2, ysize2);
streamID1 = streamOpenRead(cdoStreamName(0));
vlistID1 = streamInqVlist(streamID1);
......
......@@ -176,13 +176,13 @@ void *Sinfo(void *argument)
levelsize = zaxisInqSize(zaxisID);
/* zaxisInqLongname(zaxisID, longname); */
zaxisName(zaxistype, longname);
longname[16] = 0;
longname[17] = 0;
zaxisInqUnits(zaxisID, units);
units[12] = 0;
if ( zaxistype == ZAXIS_GENERIC && ltype != 0 )
nbyte0 = fprintf(stdout, " %4d : %-10s (ltype=%3d) : ", vlistZaxisIndex(vlistID, zaxisID)+1, longname, ltype);
nbyte0 = fprintf(stdout, " %4d : %-11s (ltype=%3d) : ", vlistZaxisIndex(vlistID, zaxisID)+1, longname, ltype);
else
nbyte0 = fprintf(stdout, " %4d : %-16s %5s : ", vlistZaxisIndex(vlistID, zaxisID)+1, longname, units);
nbyte0 = fprintf(stdout, " %4d : %-17s %5s : ", vlistZaxisIndex(vlistID, zaxisID)+1, longname, units);
nbyte = nbyte0;
for ( levelID = 0; levelID < levelsize; levelID++ )
{
......
......@@ -177,8 +177,10 @@ void cdologo(int noper);
void nospec(int vlistID);
void gridWrite(FILE *fp, int gridID);
void openLock(void);
void openUnlock(void);
int cdf_openread(const char *filename);
int pcdf_openread(const char *filename);
void printFiletype(int streamID, int vlistID);
......
......@@ -1753,7 +1753,9 @@ int cdoDefineGrid(const char *gridfile)
{
int streamID;
if ( cdoDebug ) cdoPrint("Grid from CDI file");
openLock();
streamID = streamOpenRead(gridfile);
openUnlock();
if ( streamID >= 0 )
{
int vlistID;
......
......@@ -33,7 +33,9 @@ int cdf_openread(const char *filename)
#if defined (HAVE_LIBNETCDF)
int nc_file_id; /* netCDF grid file id */
openLock();
nce(nc_open(filename, NC_NOWRITE, &nc_file_id));
openUnlock();
fileID = nc_file_id;
#else
cdoWarning("netCDF support not compiled in!");
......@@ -69,7 +71,7 @@ int gridFromNCfile(const char *gridfile)
/* open grid file and read grid size/name data */
nc_file_id = pcdf_openread(gridfile);
nc_file_id = cdf_openread(gridfile);
if ( nc_inq_dimid(nc_file_id, "grid_size", &nc_gridsize_id) == NC_NOERR &&
nc_inq_dimid(nc_file_id, "grid_rank", &nc_gridrank_id) == NC_NOERR &&
......
......@@ -1514,19 +1514,17 @@ int pstreamInqFiletype(int pstreamID)
}
int pcdf_openread(const char *filename)
void openLock(void)
{
int fileID;
#if defined (HAVE_LIBPTHREAD)
pthread_mutex_lock(&streamOpenReadMutex);
#endif
#endif
}
fileID = cdf_openread(filename);
void openUnlock(void)
{
#if defined (HAVE_LIBPTHREAD)
pthread_mutex_unlock(&streamOpenReadMutex);
#endif
return (fileID);
}
......@@ -6990,7 +6990,7 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
/* Open file and read some global information */
/* nce(nc_open(interp_file, NC_NOWRITE, &nc_file_id)); */
nc_file_id = pcdf_openread(interp_file);
nc_file_id = cdf_openread(interp_file);
/* Map name */
......
Supports Markdown
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