2018-11-26 20:35:44 +08:00
|
|
|
/* Copyright 2005-2018 University Corporation for Atmospheric
|
|
|
|
Research/Unidata. */
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @internal This header file contains libsrc4 dispatch
|
|
|
|
* initialization, user-defined format, and logging prototypes and
|
|
|
|
* macros.
|
|
|
|
*
|
|
|
|
* @author Dennis Heimbigner, Ed Hartnett
|
2019-02-19 20:55:36 +08:00
|
|
|
*/
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2011-09-26 18:14:55 +08:00
|
|
|
#include "config.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
#include <stdlib.h>
|
2020-02-17 03:59:33 +08:00
|
|
|
#include "netcdf.h"
|
2018-10-31 10:48:12 +08:00
|
|
|
#include "nc4internal.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
#include "nc4dispatch.h"
|
2017-03-09 08:01:10 +08:00
|
|
|
#include "nc.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2018-06-03 20:14:23 +08:00
|
|
|
/* If user-defined formats are in use, we need to declare their
|
|
|
|
* dispatch tables. */
|
|
|
|
#ifdef USE_UDF0
|
|
|
|
extern NC_Dispatch UDF0_DISPATCH;
|
|
|
|
#endif /* USE_UDF0 */
|
|
|
|
#ifdef USE_UDF1
|
|
|
|
extern NC_Dispatch UDF1_DISPATCH;
|
|
|
|
#endif /* USE_UDF1 */
|
|
|
|
|
2018-06-02 22:43:34 +08:00
|
|
|
#ifdef USE_NETCDF4
|
2018-06-03 20:14:23 +08:00
|
|
|
/* Pointers to dispatch tables for user-defined formats. */
|
2018-06-02 22:43:34 +08:00
|
|
|
extern NC_Dispatch *UDF0_dispatch_table;
|
|
|
|
extern NC_Dispatch *UDF1_dispatch_table;
|
|
|
|
#endif /* USE_NETCDF4 */
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2011-09-21 01:30:02 +08:00
|
|
|
|
2017-12-05 03:21:14 +08:00
|
|
|
/**
|
2018-06-02 22:43:34 +08:00
|
|
|
* @internal Initialize netCDF-4. If user-defined format(s) have been
|
|
|
|
* specified in configure, load their dispatch table(s).
|
2017-12-05 03:21:14 +08:00
|
|
|
*
|
|
|
|
* @return ::NC_NOERR No error.
|
|
|
|
* @author Dennis Heimbigner
|
|
|
|
*/
|
2010-06-03 21:24:43 +08:00
|
|
|
int
|
|
|
|
NC4_initialize(void)
|
|
|
|
{
|
2019-02-19 20:55:36 +08:00
|
|
|
int ret = NC_NOERR;
|
2018-10-31 10:48:12 +08:00
|
|
|
|
2018-06-02 22:43:34 +08:00
|
|
|
#ifdef USE_UDF0
|
2019-02-19 20:55:36 +08:00
|
|
|
/* If user-defined format 0 was specified during configure, set up
|
|
|
|
* it's dispatch table. */
|
|
|
|
if ((ret = nc_def_user_format(NC_UDF0, UDF0_DISPATCH_FUNC, NULL)))
|
|
|
|
return ret;
|
2018-06-02 22:43:34 +08:00
|
|
|
#endif /* USE_UDF0 */
|
2019-02-19 20:55:36 +08:00
|
|
|
|
2018-06-02 22:43:34 +08:00
|
|
|
#ifdef USE_UDF1
|
2019-02-19 20:55:36 +08:00
|
|
|
/* If user-defined format 0 was specified during configure, set up
|
|
|
|
* it's dispatch table. */
|
|
|
|
if ((ret = nc_def_user_format(NC_UDF1F, &UDF1_DISPATCH_FUNC, NULL)))
|
|
|
|
return ret;
|
2018-06-02 22:43:34 +08:00
|
|
|
#endif /* USE_UDF0 */
|
2019-02-19 20:55:36 +08:00
|
|
|
|
2018-03-17 01:46:18 +08:00
|
|
|
#ifdef LOGGING
|
2019-02-19 20:55:36 +08:00
|
|
|
if(getenv(NCLOGLEVELENV) != NULL) {
|
|
|
|
char* slevel = getenv(NCLOGLEVELENV);
|
|
|
|
long level = atol(slevel);
|
|
|
|
if(level >= 0)
|
|
|
|
nc_set_log_level((int)level);
|
|
|
|
}
|
2018-03-17 01:46:18 +08:00
|
|
|
#endif
|
2019-02-19 20:55:36 +08:00
|
|
|
return ret;
|
2010-06-03 21:24:43 +08:00
|
|
|
}
|
2015-08-16 06:26:35 +08:00
|
|
|
|
2017-12-05 03:21:14 +08:00
|
|
|
/**
|
|
|
|
* @internal Finalize netCDF-4.
|
|
|
|
*
|
|
|
|
* @return ::NC_NOERR No error.
|
|
|
|
* @author Dennis Heimbigner
|
|
|
|
*/
|
2015-08-16 06:26:35 +08:00
|
|
|
int
|
|
|
|
NC4_finalize(void)
|
|
|
|
{
|
|
|
|
return NC_NOERR;
|
|
|
|
}
|