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

Renamed cdfOpen64() to cdf2Open().

parent b5c2c08d
#if defined (HAVE_CONFIG_H)
# include "config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
......@@ -16,32 +16,32 @@
const char *cdfLibraryVersion(void)
{
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
return nc_inq_libvers();
#else
return "library undefined";
#endif
}
#if defined(HAVE_H5GET_LIBVERSION)
#if defined(__cplusplus)
#ifdef HAVE_H5GET_LIBVERSION
#ifdef __cplusplus
extern "C" {
#endif
int H5get_libversion(unsigned *, unsigned *, unsigned *);
#if defined(__cplusplus)
#ifdef __cplusplus
}
#endif
#endif
const char *hdfLibraryVersion(void)
{
#if defined(HAVE_H5GET_LIBVERSION)
#ifdef HAVE_H5GET_LIBVERSION
static char hdf_libvers[256];
unsigned majnum, minnum, relnum;
H5get_libversion(&majnum, &minnum, &relnum);
#if defined(HAVE_NC4HDF5_THREADSAFE)
#ifdef HAVE_NC4HDF5_THREADSAFE
sprintf(hdf_libvers, "%u.%u.%u threadsafe", majnum, minnum, relnum);
#else
sprintf(hdf_libvers, "%u.%u.%u", majnum, minnum, relnum);
......@@ -64,7 +64,7 @@ void cdfDebug(int debug)
Message("debug level %d", debug);
}
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
static
void cdfComment(int ncid)
{
......@@ -92,11 +92,10 @@ void cdfComment(int ncid)
static int cdfOpenFile(const char *filename, const char *mode, int *filetype)
{
int ncid = -1;
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
int fmode = tolower(*mode);
int writemode = NC_CLOBBER;
int readmode = NC_NOWRITE;
int status;
if ( filename == NULL )
ncid = CDI_EINVAL;
......@@ -105,25 +104,27 @@ static int cdfOpenFile(const char *filename, const char *mode, int *filetype)
switch (fmode)
{
case 'r':
status = cdf_open(filename, readmode, &ncid);
if ( status > 0 && ncid < 0 ) ncid = CDI_ESYSTEM;
#if defined (HAVE_NETCDF4)
else
{
int format;
(void) nc_inq_format(ncid, &format);
if ( format == NC_FORMAT_NETCDF4_CLASSIC )
{
*filetype = CDI_FILETYPE_NC4C;
}
}
{
int status = cdf_open(filename, readmode, &ncid);
if ( status > 0 && ncid < 0 ) ncid = CDI_ESYSTEM;
#ifdef HAVE_NETCDF4
else
{
int format;
(void) nc_inq_format(ncid, &format);
if ( format == NC_FORMAT_NETCDF4_CLASSIC )
{
*filetype = CDI_FILETYPE_NC4C;
}
}
}
#endif
break;
case 'w':
#if defined (NC_64BIT_OFFSET)
#ifdef NC_64BIT_OFFSET
if ( *filetype == CDI_FILETYPE_NC2 ) writemode |= NC_64BIT_OFFSET;
#endif
#if defined (HAVE_NETCDF4)
#ifdef HAVE_NETCDF4
if ( *filetype == CDI_FILETYPE_NC4 ) writemode |= NC_NETCDF4;
else if ( *filetype == CDI_FILETYPE_NC4C ) writemode |= NC_NETCDF4 | NC_CLASSIC_MODEL;
#endif
......@@ -160,7 +161,7 @@ int cdfOpen(const char *filename, const char *mode)
}
int cdfOpen64(const char *filename, const char *mode)
int cdf2Open(const char *filename, const char *mode)
{
int fileID = -1;
int filetype = CDI_FILETYPE_NC2;
......@@ -169,8 +170,8 @@ int cdfOpen64(const char *filename, const char *mode)
if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode);
#if defined (HAVE_LIBNETCDF)
#if ! defined (NC_64BIT_OFFSET)
#ifdef HAVE_LIBNETCDF
#ifndef NC_64BIT_OFFSET
open_file = false;
#endif
#endif
......@@ -199,7 +200,7 @@ int cdf4Open(const char *filename, const char *mode, int *filetype)
if ( CDF_Debug )
Message("Open %s with mode %c", filename, *mode);
#if defined (HAVE_NETCDF4)
#ifdef HAVE_NETCDF4
open_file = true;
#endif
......@@ -221,7 +222,7 @@ int cdf4Open(const char *filename, const char *mode, int *filetype)
static void cdfCloseFile(int fileID)
{
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
cdf_close(fileID);
#endif
}
......
#ifndef _CDF_H
#define _CDF_H
#ifndef CDF_H
#define CDF_H
void cdfDebug(int debug);
......@@ -9,11 +9,11 @@ const char *cdfLibraryVersion(void);
const char *hdfLibraryVersion(void);
int cdfOpen(const char *filename, const char *mode);
int cdfOpen64(const char *filename, const char *mode);
int cdf2Open(const char *filename, const char *mode);
int cdf4Open(const char *filename, const char *mode, int *filetype);
void cdfClose(int fileID);
#endif /* _CDF_H */
#endif /* CDF_H */
/*
* Local Variables:
* c-file-style: "Java"
......
#if defined (HAVE_CONFIG_H)
# include "config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef _XOPEN_SOURCE
......@@ -131,7 +131,7 @@ int cdiGetFiletype(const char *filename, int *byteorder)
}
else if ( memcmp(buffer, "CDF\005", 4) == 0 )
{
filetype = CDI_FILETYPE_NC2;
filetype = CDI_FILETYPE_NC5;
if ( CDI_Debug ) Message("found CDF5 file = %s", filename);
}
else if ( memcmp(buffer+1, "HDF", 3) == 0 )
......@@ -190,7 +190,7 @@ The function @func{streamInqFiletype} returns the filetype of a stream.
@func{streamInqFiletype} returns the type of the file format,
one of the set of predefined CDI file format types.
The valid CDI file format types are @func{CDI_FILETYPE_GRB}, @func{CDI_FILETYPE_GRB2}, @func{CDI_FILETYPE_NC}, @func{CDI_FILETYPE_NC2},
@func{CDI_FILETYPE_NC4}, @func{CDI_FILETYPE_NC4C}, @func{CDI_FILETYPE_SRV}, @func{CDI_FILETYPE_EXT} and @func{CDI_FILETYPE_IEG}.
@func{CDI_FILETYPE_NC4}, @func{CDI_FILETYPE_NC4C}, @func{CDI_FILETYPE_NC5}, @func{CDI_FILETYPE_SRV}, @func{CDI_FILETYPE_EXT} and @func{CDI_FILETYPE_IEG}.
@EndFunction
*/
......@@ -245,7 +245,7 @@ void streamDefByteorder(int streamID, int byteorder)
switch (filetype)
{
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV:
{
srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
......@@ -254,7 +254,7 @@ void streamDefByteorder(int streamID, int byteorder)
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT:
{
extrec_t *extp = (extrec_t*) streamptr->record->exsep;
......@@ -263,7 +263,7 @@ void streamDefByteorder(int streamID, int byteorder)
break;
}
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG:
{
iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
......@@ -345,7 +345,7 @@ int cdiInqContents(stream_t *streamptr)
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
#ifdef HAVE_LIBGRIB
case CDI_FILETYPE_GRB:
case CDI_FILETYPE_GRB2:
{
......@@ -353,32 +353,33 @@ int cdiInqContents(stream_t *streamptr)
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV:
{
status = srvInqContents(streamptr);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT:
{
status = extInqContents(streamptr);
break;
}
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG:
{
status = iegInqContents(streamptr);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5:
{
status = cdfInqContents(streamptr);
break;
......@@ -416,9 +417,9 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
int fileID;
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
#ifdef HAVE_LIBGRIB
case CDI_FILETYPE_GRB:
#if defined (HAVE_LIBGRIB_API)
#ifdef HAVE_LIBGRIB_API
case CDI_FILETYPE_GRB2:
#endif
{
......@@ -437,7 +438,7 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV:
{
#ifndef __cplusplus
......@@ -456,7 +457,7 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT:
{
#ifndef __cplusplus
......@@ -476,7 +477,7 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
break;
}
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG:
{
#ifndef __cplusplus
......@@ -495,7 +496,7 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
{
#ifndef __cplusplus
......@@ -507,12 +508,13 @@ int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
break;
}
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC5:
{
#ifndef __cplusplus
fileID = cdfOpen64(filename, (char [2]){filemode, 0});
fileID = cdf2Open(filename, (char [2]){filemode, 0});
#else
char temp[2] = { filemode, 0 };
fileID = cdfOpen64(filename, temp);
fileID = cdf2Open(filename, temp);
#endif
break;
}
......@@ -662,9 +664,9 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
#ifdef HAVE_LIBGRIB
case CDI_FILETYPE_GRB:
#if defined (HAVE_LIBGRIB_API)
#ifdef HAVE_LIBGRIB_API
case CDI_FILETYPE_GRB2:
#endif
{
......@@ -673,28 +675,28 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV:
{
fileID = fileOpen(filename, filemode);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT:
{
fileID = fileOpen(filename, filemode);
break;
}
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG:
{
fileID = fileOpen(filename, filemode);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
{
fileID = cdfOpen(filename, filemode);
......@@ -702,8 +704,9 @@ int streamOpenA(const char *filename, const char *filemode, int filetype)
break;
}
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC5:
{
fileID = cdfOpen64(filename, filemode);
fileID = cdf2Open(filename, filemode);
streamptr->ncmode = 2;
break;
}
......@@ -818,7 +821,7 @@ int streamOpenAppend(const char *filename)
@Item path The name of the new dataset.
@Item filetype The type of the file format, one of the set of predefined CDI file format types.
The valid CDI file format types are @func{CDI_FILETYPE_GRB}, @func{CDI_FILETYPE_GRB2}, @func{CDI_FILETYPE_NC},
@func{CDI_FILETYPE_NC2}, @func{CDI_FILETYPE_NC4}, @func{CDI_FILETYPE_NC4C}, @func{CDI_FILETYPE_SRV},
@func{CDI_FILETYPE_NC2}, @func{CDI_FILETYPE_NC4}, @func{CDI_FILETYPE_NC4C}, @func{CDI_FILETYPE_NC5}, @func{CDI_FILETYPE_SRV},
@func{CDI_FILETYPE_EXT} and @func{CDI_FILETYPE_IEG}.
@Description
......@@ -942,7 +945,7 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
else
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
#ifdef HAVE_LIBGRIB
case CDI_FILETYPE_GRB:
case CDI_FILETYPE_GRB2:
{
......@@ -951,7 +954,7 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV:
{
fileClose(fileID);
......@@ -959,7 +962,7 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT:
{
fileClose(fileID);
......@@ -967,7 +970,7 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
break;
}
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG:
{
fileClose(fileID);
......@@ -975,11 +978,12 @@ void cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDelet
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5:
{
cdfClose(fileID);
if (streamptr->ntsteps == 0)
......@@ -1122,11 +1126,12 @@ void cdiStreamSync_(stream_t *streamptr)
{
switch (filetype)
{
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5:
{
void cdf_sync(int ncid);
if ( streamptr->ncmode == 2 ) cdf_sync(fileID);
......@@ -1204,6 +1209,7 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
#ifdef HAVE_LIBNETCDF
if ((streamptr->filetype == CDI_FILETYPE_NC ||
streamptr->filetype == CDI_FILETYPE_NC2 ||
streamptr->filetype == CDI_FILETYPE_NC5 ||
streamptr->filetype == CDI_FILETYPE_NC4 ||
streamptr->filetype == CDI_FILETYPE_NC4C)
&& time_is_varying)
......@@ -1302,7 +1308,7 @@ int streamInqTimestep(int streamID, int tsID)
switch (filetype)
{
#if defined (HAVE_LIBGRIB)
#ifdef HAVE_LIBGRIB
case CDI_FILETYPE_GRB:
case CDI_FILETYPE_GRB2:
{
......@@ -1310,32 +1316,33 @@ int streamInqTimestep(int streamID, int tsID)
break;
}
#endif
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV:
{
nrecs = srvInqTimestep(streamptr, tsID);
break;
}
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT:
{
nrecs = extInqTimestep(streamptr, tsID);
break;
}
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG:
{
nrecs = iegInqTimestep(streamptr, tsID);
break;
}
#endif
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC:
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5:
{
nrecs = cdfInqTimestep(streamptr, tsID);
break;
......@@ -1630,6 +1637,7 @@ void cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5:
{
taxis_t *taxisptr = taxisPtr(taxisID);
if ( taxisptr->rdate == -1 ) taxisDefRdate(taxisID, 10101);
......@@ -1649,6 +1657,7 @@ void cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
case CDI_FILETYPE_NC2:
case CDI_FILETYPE_NC4:
case CDI_FILETYPE_NC4C:
case CDI_FILETYPE_NC5:
{
/* calls cdfDefVars in serial mode but
* cdiPioClientStreamNOP (i.e. nothing) on client ranks
......
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