2015-08-16 06:26:35 +08:00
|
|
|
/*********************************************************************
|
|
|
|
* Copyright 2010, UCAR/Unidata
|
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifdef USE_PARALLEL
|
|
|
|
#include <mpi.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ncdispatch.h"
|
|
|
|
|
2018-06-03 20:14:23 +08:00
|
|
|
|
2015-08-16 06:26:35 +08:00
|
|
|
extern int NC3_initialize(void);
|
|
|
|
extern int NC3_finalize(void);
|
|
|
|
|
|
|
|
#ifdef USE_NETCDF4
|
2016-06-09 01:26:37 +08:00
|
|
|
#include "nc4internal.h"
|
2015-08-16 06:26:35 +08:00
|
|
|
extern int NC4_initialize(void);
|
|
|
|
extern int NC4_finalize(void);
|
|
|
|
#endif
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifdef ENABLE_DAP2
|
2015-08-16 06:26:35 +08:00
|
|
|
extern int NCD2_initialize(void);
|
|
|
|
extern int NCD2_finalize(void);
|
|
|
|
#endif
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifdef ENABLE_DAP4
|
|
|
|
extern int NCD4_initialize(void);
|
|
|
|
extern int NCD4_finalize(void);
|
|
|
|
#endif
|
|
|
|
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef USE_PNETCDF
|
|
|
|
extern int NCP_initialize(void);
|
|
|
|
extern int NCP_finalize(void);
|
|
|
|
#endif
|
|
|
|
|
2018-02-08 21:20:58 +08:00
|
|
|
#ifdef USE_HDF4
|
2018-04-05 04:11:44 +08:00
|
|
|
extern int NC_HDF4_initialize(void);
|
|
|
|
extern int NC_HDF4_finalize(void);
|
2018-02-08 21:20:58 +08:00
|
|
|
#endif
|
|
|
|
|
2017-07-18 08:58:45 +08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <io.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
2015-08-16 06:26:35 +08:00
|
|
|
int NC_argc = 1;
|
|
|
|
char* NC_argv[] = {"nc_initialize",NULL};
|
|
|
|
|
|
|
|
int NC_initialized = 0;
|
|
|
|
int NC_finalized = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
This procedure invokes all defined
|
|
|
|
initializers, and there is an initializer
|
|
|
|
for every known dispatch table.
|
|
|
|
So if you modify the format of NC_Dispatch,
|
|
|
|
then you need to fix it everywhere.
|
|
|
|
It also initializes appropriate external libraries.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
nc_initialize()
|
|
|
|
{
|
|
|
|
int stat = NC_NOERR;
|
|
|
|
|
|
|
|
if(NC_initialized) return NC_NOERR;
|
|
|
|
NC_initialized = 1;
|
|
|
|
NC_finalized = 0;
|
|
|
|
|
|
|
|
/* Do general initialization */
|
2016-05-04 11:17:06 +08:00
|
|
|
if((stat = NCDISPATCH_initialize())) goto done;
|
2015-08-16 06:26:35 +08:00
|
|
|
|
|
|
|
/* Initialize each active protocol */
|
2016-05-04 11:17:06 +08:00
|
|
|
if((stat = NC3_initialize())) goto done;
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifdef ENABLE_DAP
|
2016-05-04 11:17:06 +08:00
|
|
|
if((stat = NCD2_initialize())) goto done;
|
2015-08-16 06:26:35 +08:00
|
|
|
#endif
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifdef ENABLE_DAP4
|
|
|
|
if((stat = NCD4_initialize())) goto done;
|
|
|
|
#endif
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef USE_PNETCDF
|
2016-05-04 11:17:06 +08:00
|
|
|
if((stat = NCP_initialize())) goto done;
|
2015-08-16 06:26:35 +08:00
|
|
|
#endif
|
2018-02-08 21:20:58 +08:00
|
|
|
#ifdef USE_HDF4
|
2018-04-05 04:11:44 +08:00
|
|
|
if((stat = NC_HDF4_initialize())) goto done;
|
2018-02-08 21:20:58 +08:00
|
|
|
#endif
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef USE_NETCDF4
|
2016-05-04 11:17:06 +08:00
|
|
|
if((stat = NC4_initialize())) goto done;
|
2018-08-26 11:44:41 +08:00
|
|
|
stat = NC4_provenance_init();
|
2016-08-08 23:24:19 +08:00
|
|
|
#endif /* USE_NETCDF4 */
|
2016-05-04 11:17:06 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return stat;
|
2015-08-16 06:26:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
This procedure invokes all defined
|
|
|
|
finalizers, and there should be one
|
|
|
|
for every known dispatch table.
|
|
|
|
So if you modify the format of NC_Dispatch,
|
|
|
|
then you need to fix it everywhere.
|
|
|
|
It also finalizes appropriate external libraries.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
|
|
|
nc_finalize(void)
|
|
|
|
{
|
|
|
|
int stat = NC_NOERR;
|
|
|
|
|
|
|
|
if(NC_finalized) return NC_NOERR;
|
|
|
|
NC_initialized = 0;
|
|
|
|
NC_finalized = 1;
|
|
|
|
|
|
|
|
/* Finalize each active protocol */
|
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifdef ENABLE_DAP2
|
2015-08-16 06:26:35 +08:00
|
|
|
if((stat = NCD2_finalize())) return stat;
|
|
|
|
#endif
|
2017-03-09 08:01:10 +08:00
|
|
|
#ifdef ENABLE_DAP4
|
|
|
|
if((stat = NCD4_finalize())) return stat;
|
|
|
|
#endif
|
2015-08-16 06:26:35 +08:00
|
|
|
|
|
|
|
#ifdef USE_PNETCDF
|
|
|
|
if((stat = NCP_finalize())) return stat;
|
|
|
|
#endif
|
|
|
|
|
2018-04-05 04:11:44 +08:00
|
|
|
#ifdef USE_HDF4
|
|
|
|
if((stat = NC_HDF4_finalize())) return stat;
|
|
|
|
#endif /* USE_HDF4 */
|
|
|
|
|
2015-08-16 06:26:35 +08:00
|
|
|
#ifdef USE_NETCDF4
|
|
|
|
if((stat = NC4_finalize())) return stat;
|
|
|
|
#endif /* USE_NETCDF4 */
|
|
|
|
|
|
|
|
if((stat = NC3_finalize())) return stat;
|
|
|
|
|
|
|
|
/* Do general finalization */
|
|
|
|
if((stat = NCDISPATCH_finalize())) return stat;
|
|
|
|
|
|
|
|
return NC_NOERR;
|
|
|
|
}
|