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

Added cdf_config.h.

parent b8baf916
......@@ -75,8 +75,8 @@ static int datamode = DP_MODE;
static
void version(void)
{
int filetypes[] = {CDI_FILETYPE_SRV, CDI_FILETYPE_EXT, CDI_FILETYPE_IEG, CDI_FILETYPE_GRB, CDI_FILETYPE_GRB2, CDI_FILETYPE_NC, CDI_FILETYPE_NC2, CDI_FILETYPE_NC4, CDI_FILETYPE_NC4C};
const char *typenames[] = { "srv", "ext", "ieg", "grb", "grb2", "nc", "nc2", "nc4", "nc4c"};
int filetypes[] = {CDI_FILETYPE_SRV, CDI_FILETYPE_EXT, CDI_FILETYPE_IEG, CDI_FILETYPE_GRB, CDI_FILETYPE_GRB2, CDI_FILETYPE_NC, CDI_FILETYPE_NC2, CDI_FILETYPE_NC4, CDI_FILETYPE_NC4C, CDI_FILETYPE_NC5};
const char *typenames[] = { "srv", "ext", "ieg", "grb", "grb2", "nc", "nc2", "nc4", "nc4c", "nc5"};
fprintf(stderr, "CDI version 1.8\n");
#if defined (COMPILER)
......@@ -164,7 +164,7 @@ void usage(void)
fprintf(stderr, "\n");
fprintf(stderr, " Options:\n");
fprintf(stderr, " -d Print debugging information\n");
fprintf(stderr, " -f <format> Format of the output file. (grb, grb2, nc, nc2, nc4, nc4c, src, ext or ieg)\n");
fprintf(stderr, " -f <format> Format of the output file. (grb, grb2, nc, nc2, nc4, nc4c, nc5, srv, ext or ieg)\n");
fprintf(stderr, " -s give short information if ofile is missing\n");
fprintf(stderr, " -t <table> Parameter table name/file\n");
fprintf(stderr, " Predefined tables: ");
......@@ -560,7 +560,7 @@ void setDefaultDataType(char *datatypestr)
else
{
fprintf(stderr, "Unsupported number of bits %d!\n", nbits);
fprintf(stderr, "Use I8/I16/I32/F32/F64 for nc/nc2/nc4/nc4c; F32/F64 for grb2/srv/ext/ieg; P1 - P24 for grb/grb2.\n");
fprintf(stderr, "Use I8/I16/I32/F32/F64 for nc/nc2/nc4/nc4c/nc5; F32/F64 for grb2/srv/ext/ieg; P1 - P24 for grb/grb2.\n");
exit(EXIT_FAILURE);
}
}
......@@ -644,6 +644,7 @@ void setDefaultFileType(char *filetypestr)
else if ( memcmp(filetypestr, "nc2", 3) == 0 ) { ftstr += 3; DefaultFileType = CDI_FILETYPE_NC2; }
else if ( memcmp(filetypestr, "nc4c", 4) == 0 ) { ftstr += 4; DefaultFileType = CDI_FILETYPE_NC4C;}
else if ( memcmp(filetypestr, "nc4", 3) == 0 ) { ftstr += 3; DefaultFileType = CDI_FILETYPE_NC4; }
else if ( memcmp(filetypestr, "nc5", 3) == 0 ) { ftstr += 3; DefaultFileType = CDI_FILETYPE_NC5; }
else if ( memcmp(filetypestr, "nc1", 3) == 0 ) { ftstr += 3; DefaultFileType = CDI_FILETYPE_NC; }
else if ( memcmp(filetypestr, "nc", 2) == 0 ) { ftstr += 2; DefaultFileType = CDI_FILETYPE_NC2; }
else if ( memcmp(filetypestr, "srv", 3) == 0 ) { ftstr += 3; DefaultFileType = CDI_FILETYPE_SRV; }
......@@ -652,7 +653,7 @@ void setDefaultFileType(char *filetypestr)
else
{
fprintf(stderr, "Unsupported filetype %s!\n", filetypestr);
fprintf(stderr, "Available filetypes: grb, grb2, nc, nc2, nc4, nc4c, srv, ext and ieg\n");
fprintf(stderr, "Available filetypes: grb, grb2, nc, nc2, nc4, nc4c, nc5, srv, ext and ieg\n");
exit(EXIT_FAILURE);
}
......@@ -668,8 +669,8 @@ void setDefaultFileType(char *filetypestr)
{
fprintf(stderr, "Unexpected character >%c< in file type >%s<!\n", *ftstr, filetypestr);
fprintf(stderr, "Use format[_nbits] with:\n");
fprintf(stderr, " format = grb, grb2, nc, nc2, nc4, nc4c, srv, ext or ieg\n");
fprintf(stderr, " nbits = 32/64 for grb2/nc/nc2/nc4/nc4c/srv/ext/ieg; 1 - 24 for grb/grb2\n");
fprintf(stderr, " format = grb, grb2, nc, nc2, nc4, nc4c, nc5, srv, ext or ieg\n");
fprintf(stderr, " nbits = 32/64 for grb2/nc/nc2/nc4/nc4c/nc5/srv/ext/ieg; 1 - 24 for grb/grb2\n");
exit(EXIT_FAILURE);
}
}
......
......@@ -22,6 +22,7 @@ libcdi_la_SOURCES = \
calendar.h \
cdf.c \
cdf.h \
cdf_config.h \
cdf_int.c \
cdf_int.h \
cdf_util.c \
......
......@@ -169,8 +169,8 @@ LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
am__DEPENDENCIES_1 =
libcdi_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__libcdi_la_SOURCES_DIST = basetime.c basetime.h binary.c binary.h \
calendar.c calendar.h cdf.c cdf.h cdf_int.c cdf_int.h \
cdf_util.c cdf_util.h cdi.h cdi_error.c cdi_limits.h \
calendar.c calendar.h cdf.c cdf.h cdf_config.h cdf_int.c \
cdf_int.h cdf_util.c cdf_util.h cdi.h cdi_error.c cdi_limits.h \
cdi_util.c cgribex.h cgribexlib.c datetime.h dmemory.c \
dmemory.h cksum.c cksum.h cdi_cksum.c cdi_cksum.h cdi_uuid.h \
dtypes.h error.c error.h exse.h extra.h extralib.c file.c \
......@@ -512,18 +512,18 @@ noinst_LTLIBRARIES = libcdiresunpack.la $(am__append_1) \
@ENABLE_CDI_LIB_TRUE@include_HEADERS = cdi.h cdi.inc $(am__append_5)
AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS) $(MPI_C_INCLUDE)
libcdi_la_SOURCES = basetime.c basetime.h binary.c binary.h calendar.c \
calendar.h cdf.c cdf.h cdf_int.c cdf_int.h cdf_util.c \
cdf_util.h cdi.h cdi_error.c cdi_limits.h cdi_util.c cgribex.h \
cgribexlib.c datetime.h dmemory.c dmemory.h cksum.c cksum.h \
cdi_cksum.c cdi_cksum.h cdi_uuid.h dtypes.h error.c error.h \
exse.h extra.h extralib.c file.c file.h gaussgrid.c \
gaussgrid.h gribapi.c gribapi.h gribapi_utilities.h grid.c \
grid.h ieg.h ieglib.c input_file.c input_file.h institution.c \
institution.h model.c model.h namespace.c namespace.h \
serialize.h serialize.c referenceCounting.c \
referenceCounting.h resource_handle.c resource_handle.h \
service.h servicelib.c stream_cdf_i.c stream_cdf_o.c \
stream_cdf_time.c stream_cdf.h stream_cgribex.c \
calendar.h cdf.c cdf.h cdf_config.h cdf_int.c cdf_int.h \
cdf_util.c cdf_util.h cdi.h cdi_error.c cdi_limits.h \
cdi_util.c cgribex.h cgribexlib.c datetime.h dmemory.c \
dmemory.h cksum.c cksum.h cdi_cksum.c cdi_cksum.h cdi_uuid.h \
dtypes.h error.c error.h exse.h extra.h extralib.c file.c \
file.h gaussgrid.c gaussgrid.h gribapi.c gribapi.h \
gribapi_utilities.h grid.c grid.h ieg.h ieglib.c input_file.c \
input_file.h institution.c institution.h model.c model.h \
namespace.c namespace.h serialize.h serialize.c \
referenceCounting.c referenceCounting.h resource_handle.c \
resource_handle.h service.h servicelib.c stream_cdf_i.c \
stream_cdf_o.c stream_cdf_time.c stream_cdf.h stream_cgribex.c \
stream_cgribex.h stream_ext.c stream_ext.h stream_grb.c \
stream_grb.h stream_gribapi.h stream_history.c stream_ieg.c \
stream_ieg.h cdi_int.c cdi_int.h stream_record.c stream_srv.c \
......
#ifndef CDF_CONFIG_H_
#define CDF_CONFIG_H_
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_LIBNETCDF
#include <netcdf.h>
#ifdef NC_FORMAT_64BIT_DATA
#define HAVE_NETCDF5 1
#endif
#endif
#endif
#ifndef _CDF_INT_H
#define _CDF_INT_H
#ifndef CDF_INT_H
#define CDF_INT_H
#if defined (HAVE_LIBNETCDF)
......@@ -97,7 +97,7 @@ typedef void (*cdi_cdf_def_var_funcp)(int ncid, const char *name,
#endif
#endif /* _CDF_INT_H */
#endif /* CDF_INT_H */
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -50,12 +50,13 @@ extern "C" {
#define CDI_FILETYPE_GRB 1 // File type GRIB
#define CDI_FILETYPE_GRB2 2 // File type GRIB version 2
#define CDI_FILETYPE_NC 3 // File type NetCDF
#define CDI_FILETYPE_NC2 4 // File type NetCDF version 2 (64-bit)
#define CDI_FILETYPE_NC2 4 // File type NetCDF version 2 (64-bit offset)
#define CDI_FILETYPE_NC4 5 // File type NetCDF version 4
#define CDI_FILETYPE_NC4C 6 // File type NetCDF version 4 (classic)
#define CDI_FILETYPE_SRV 7 // File type SERVICE
#define CDI_FILETYPE_EXT 8 // File type EXTRA
#define CDI_FILETYPE_IEG 9 // File type IEG
#define CDI_FILETYPE_NC5 7 // File type NetCDF version 5 (64-bit data)
#define CDI_FILETYPE_SRV 8 // File type SERVICE
#define CDI_FILETYPE_EXT 9 // File type EXTRA
#define CDI_FILETYPE_IEG 10 // File type IEG
#define FILETYPE_GRB 1
#define FILETYPE_GRB2 2
......
#if defined (HAVE_CONFIG_H)
# include "config.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdarg.h>
......@@ -12,13 +12,13 @@
#include "dmemory.h"
#include "file.h"
#include "gribapi.h"
#ifdef HAVE_LIBNETCDF
#ifdef HAVE_LIBNETCDF
#include "stream_cdf.h"
#endif
#include "namespace.h"
#include "resource_handle.h"
#if defined (HAVE_LIBCGRIBEX)
#ifdef HAVE_LIBCGRIBEX
#include "cgribex.h"
#endif
......@@ -57,6 +57,7 @@ static const char Filetypes[][9] = {
"NetCDF2",
"NetCDF4",
"NetCDF4c",
"NetCDF5",
"SERVICE",
"EXTRA",
"IEG",
......@@ -76,18 +77,14 @@ int cdiHaveMissval = 0;
static long cdiGetenvInt(const char *envName)
{
char *envString;
long envValue = -1;
long fact = 1;
envString = getenv(envName);
char *envString = getenv(envName);
if ( envString )
{
int loop, len;
len = (int) strlen(envString);
for ( loop = 0; loop < len; loop++ )
long fact = 1;
int len = (int) strlen(envString);
for ( int loop = 0; loop < len; loop++ )
{
if ( ! isdigit((int) envString[loop]) )
{
......@@ -111,7 +108,7 @@ static long cdiGetenvInt(const char *envName)
if ( CDI_Debug ) Message("set %s to %ld", envName, envValue);
}
return (envValue);
return envValue;
}
static void
......@@ -127,25 +124,25 @@ cdiPrintDefaults(void)
void cdiPrintVersion(void)
{
fprintf(stderr, " CDI library version : %s\n", cdiLibraryVersion());
#if defined (HAVE_LIBCGRIBEX)
#ifdef HAVE_LIBCGRIBEX
fprintf(stderr, " CGRIBEX library version : %s\n", cgribexLibraryVersion());
#endif
#if defined (HAVE_LIBGRIB_API)
#ifdef HAVE_LIBGRIB_API
fprintf(stderr, "GRIB_API library version : %s\n", gribapiLibraryVersionString());
#endif
#if defined (HAVE_LIBNETCDF)
#ifdef HAVE_LIBNETCDF
fprintf(stderr, " NetCDF library version : %s\n", cdfLibraryVersion());
#endif
#if defined (HAVE_NC4HDF5)
#ifdef HAVE_NC4HDF5
fprintf(stderr, " HDF5 library version : %s\n", hdfLibraryVersion());
#endif
#if defined (HAVE_LIBSERVICE)
#ifdef HAVE_LIBSERVICE
fprintf(stderr, " SERVICE library version : %s\n", srvLibraryVersion());
#endif
#if defined (HAVE_LIBEXTRA)
#ifdef HAVE_LIBEXTRA
fprintf(stderr, " EXTRA library version : %s\n", extLibraryVersion());
#endif
#if defined (HAVE_LIBIEG)
#ifdef HAVE_LIBIEG
fprintf(stderr, " IEG library version : %s\n", iegLibraryVersion());
#endif
fprintf(stderr, " FILE library version : %s\n", fileLibraryVersion());
......@@ -193,6 +190,7 @@ static void cdiPrintDatatypes(void)
#undef XSTRING
}
void cdiDebug(int level)
{
if ( level == 1 || (level & 2) ) CDI_Debug = 1;
......@@ -236,37 +234,40 @@ int cdiHaveFiletype(int filetype)
switch (filetype)
{
#if defined (HAVE_LIBSERVICE)
case CDI_FILETYPE_SRV: { status = 1; break; }
#ifdef HAVE_LIBSERVICE
case CDI_FILETYPE_SRV: status = 1; break;
#endif
#if defined (HAVE_LIBEXTRA)
case CDI_FILETYPE_EXT: { status = 1; break; }
#ifdef HAVE_LIBEXTRA
case CDI_FILETYPE_EXT: status = 1; break;
#endif
#if defined (HAVE_LIBIEG)
case CDI_FILETYPE_IEG: { status = 1; break; }
#ifdef HAVE_LIBIEG
case CDI_FILETYPE_IEG: status = 1; break;
#endif
#if defined (HAVE_LIBGRIB)
#ifdef HAVE_LIBGRIB
#if defined (HAVE_LIBGRIB_API) || defined (HAVE_LIBCGRIBEX)
case CDI_FILETYPE_GRB: { status = 1; break; }
case CDI_FILETYPE_GRB: status = 1; break;
#endif
#if defined (HAVE_LIBGRIB_API)
case CDI_FILETYPE_GRB2: { status = 1; break; }
#ifdef HAVE_LIBGRIB_API
case CDI_FILETYPE_GRB2: status = 1; break;
#endif
#endif
#if defined (HAVE_LIBNETCDF)
case CDI_FILETYPE_NC: { status = 1; break; }
#if defined (HAVE_NETCDF2)
case CDI_FILETYPE_NC2: { status = 1; break; }
#ifdef HAVE_LIBNETCDF
case CDI_FILETYPE_NC: status = 1; break;
#ifdef HAVE_NETCDF2
case CDI_FILETYPE_NC2: status = 1; break;
#endif
#ifdef HAVE_NETCDF4
case CDI_FILETYPE_NC4: status = 1; break;
case CDI_FILETYPE_NC4C: status = 1; break;
#endif
#if defined (HAVE_NETCDF4)
case CDI_FILETYPE_NC4: { status = 1; break; }
case CDI_FILETYPE_NC4C: { status = 1; break; }
#ifdef HAVE_NETCDF5
case CDI_FILETYPE_NC5: status = 1; break;
#endif
#endif
default: { status = 0; break; }
default: status = 0; break;
}
return (status);
return status;
}
void cdiDefTableID(int tableID)
......@@ -323,7 +324,7 @@ void cdiInitialize(void)
char *envstr;
long value;
#if defined (HAVE_LIBCGRIBEX)
#ifdef HAVE_LIBCGRIBEX
gribFixZSE(1); // 1: Fix ZeroShiftError of simple packed spherical harmonics
gribSetConst(1); // 1: Don't pack constant fields on regular grids
#endif
......@@ -442,7 +443,7 @@ void cdiInitialize(void)
if ( CDI_Debug )
Message("Default calendar set to %s!", envstr);
}
#if defined (HAVE_LIBCGRIBEX)
#ifdef HAVE_LIBCGRIBEX
gribSetCalendar(cdiDefaultCalendar);
#endif
......@@ -457,15 +458,10 @@ void cdiInitialize(void)
const char *strfiletype(int filetype)
{
const char *name;
int size = (int) (sizeof(Filetypes)/sizeof(char *));
const char *name = (filetype > 0 && filetype < size) ? Filetypes[filetype] : Filetypes[0];
if ( filetype > 0 && filetype < size )
name = Filetypes[filetype];
else
name = Filetypes[0];
return (name);
return name;
}
......@@ -498,7 +494,7 @@ double cdiInqMissval(void)
{
cdiInitialize();
return (cdiDefaultMissval);
return cdiDefaultMissval;
}
/*
......
#ifndef _CDI_INT_H
#define _CDI_INT_H
#ifndef CDI_INT_H
#define CDI_INT_H
#if defined (HAVE_CONFIG_H)
#include "config.h"
......@@ -14,6 +14,7 @@
#include <sys/types.h>
#include "cdi.h"
#include "cdf_config.h"
/* dummy use of unused parameters to silence compiler warnings */
#ifndef UNUSED
......@@ -484,7 +485,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
}
#endif
#endif /* _CDI_INT_H */
#endif /* CDI_INT_H */
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -7,8 +7,6 @@
#include <stdio.h>
#include <string.h>
#include <netcdf.h>
#include "cdi.h"
#include "cdi_int.h"
#include "stream_cdf.h"
......
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