Skip to content

Commit

Permalink
working on netcdf integration layer!
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 3, 2019
1 parent df9d5ed commit fb66aa3
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 30 deletions.
27 changes: 15 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,6 @@ test "x$enable_pnetcdf" = xno || enable_pnetcdf=yes
AC_MSG_RESULT([$enable_pnetcdf])
AM_CONDITIONAL(BUILD_PNETCDF, [test "x$enable_pnetcdf" = xyes])

# Does the user want to build netcdf-c integration layer?
AC_MSG_CHECKING([whether netcdf-c integration layer should be build])
AC_ARG_ENABLE([netcdf-integration],
[AS_HELP_STRING([--enable-netcdf-integration],
[enable building of netCDF C API integration.])])
test "x$enable_netcdf_integration" = xyes || enable_netcdf_integration=no
AC_MSG_RESULT([$enable_netcdf_integration])
if test "x$enable_netcdf_integration" = xyes -a "x$enable_timing" = xyes; then
AC_MSG_ERROR([Cannot use GPTL timing library with netCDF interation.])
fi
AM_CONDITIONAL(BUILD_NCINT, [test "x$enable_netcdf_integration" = xyes])

# Does the user want to build documentation?
AC_MSG_CHECKING([whether documentation should be build (requires doxygen)])
AC_ARG_ENABLE([docs],
Expand Down Expand Up @@ -274,6 +262,21 @@ if test "x$enable_timing" = xyes; then
fi
AM_CONDITIONAL([HAVE_PAPI], [test "x$have_papi" = xyes])

# Does the user want to build netcdf-c integration layer?
AC_MSG_CHECKING([whether netcdf-c integration layer should be build])
AC_ARG_ENABLE([netcdf-integration],
[AS_HELP_STRING([--enable-netcdf-integration],
[enable building of netCDF C API integration.])])
test "x$enable_netcdf_integration" = xyes || enable_netcdf_integration=no
AC_MSG_RESULT([$enable_netcdf_integration])
if test "x$enable_netcdf_integration" = xyes -a "x$enable_timing" = xyes; then
AC_MSG_ERROR([Cannot use GPTL timing library with netCDF interation.])
fi
if test "x$enable_netcdf_integration" = xyes -a "x$have_netcdf_par" = xno; then
AC_MSG_ERROR([Cannot use netCDF integration unless netCDF library was built for parallel I/O.])
fi
AM_CONDITIONAL(BUILD_NCINT, [test "x$enable_netcdf_integration" = xyes])

AC_CONFIG_FILES([tests/general/pio_tutil.F90:tests/general/util/pio_tutil.F90])

AC_CONFIG_LINKS([tests/unit/input.nl:tests/unit/input.nl])
Expand Down
22 changes: 4 additions & 18 deletions src/ncint/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,8 @@
## layer.
# Ed Hartnett 7/3/19

# The library we are building.
#lib_LTLIBRARIES = libpioc.la
# This is our output. The ncint convenience library.
noinst_LTLIBRARIES = libncint.la

# These linker flags specify libtool version info.
# See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
# for information regarding incrementing `-version-info`.
#libpioc_la_LDFLAGS = -version-info 2:0:1

# The library header file will be installed in include dir.
#include_HEADERS = pio.h uthash.h

# The library soure files.
# libpioc_la_SOURCES = bget.c pioc_sc.c pio_darray.c pio_file.c \
# pio_getput_int.c pio_msg.c pio_nc.c pio_rearrange.c pioc.c \
# pioc_support.c pio_darray_int.c pio_get_nc.c pio_lists.c pio_nc4.c \
# pio_put_nc.c pio_spmd.c pio_get_vard.c pio_put_vard.c pio_internal.h \
# bget.h uthash.h pio_error.h

EXTRA_DIST = Makefile.am
# The source files.
libncint_la_SOURCES = ncintdispatch.c ncintdispatch.h
129 changes: 129 additions & 0 deletions src/ncint/ncintdispatch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* @file
* @internal Dispatch layer for netcdf PIO integration.
*
* @author Ed Hartnett
*/

#include "config.h"
#include <stdlib.h>
#include "ncintdispatch.h"

/* This is the dispatch object that holds pointers to all the
* functions that make up the NCINT dispatch interface. */
static const NC_Dispatch NCINT_dispatcher = {

NC_FORMATX_NC_HDF4,

NC_RO_create,
NC_NCINT_open,

NC_RO_redef,
NC_RO__enddef,
NC_RO_sync,
NC_NCINT_abort,
NC_NCINT_close,
NC_RO_set_fill,
NC_NOTNC3_inq_base_pe,
NC_NOTNC3_set_base_pe,
NC_NCINT_inq_format,
NC_NCINT_inq_format_extended,

NC4_inq,
NC4_inq_type,

NC_RO_def_dim,
NC4_inq_dimid,
NC4_inq_dim,
NC4_inq_unlimdim,
NC_RO_rename_dim,

NC4_inq_att,
NC4_inq_attid,
NC4_inq_attname,
NC_RO_rename_att,
NC_RO_del_att,
NC4_get_att,
NC_RO_put_att,

NC_RO_def_var,
NC4_inq_varid,
NC_RO_rename_var,
NC_NCINT_get_vara,
NC_RO_put_vara,
NCDEFAULT_get_vars,
NCDEFAULT_put_vars,
NCDEFAULT_get_varm,
NCDEFAULT_put_varm,

NC4_inq_var_all,

NC_NOTNC4_var_par_access,
NC_RO_def_var_fill,

NC4_show_metadata,
NC4_inq_unlimdims,

NC4_inq_ncid,
NC4_inq_grps,
NC4_inq_grpname,
NC4_inq_grpname_full,
NC4_inq_grp_parent,
NC4_inq_grp_full_ncid,
NC4_inq_varids,
NC4_inq_dimids,
NC4_inq_typeids,
NC4_inq_type_equal,
NC_NOTNC4_def_grp,
NC_NOTNC4_rename_grp,
NC4_inq_user_type,
NC4_inq_typeid,

NC_NOTNC4_def_compound,
NC_NOTNC4_insert_compound,
NC_NOTNC4_insert_array_compound,
NC_NOTNC4_inq_compound_field,
NC_NOTNC4_inq_compound_fieldindex,
NC_NOTNC4_def_vlen,
NC_NOTNC4_put_vlen_element,
NC_NOTNC4_get_vlen_element,
NC_NOTNC4_def_enum,
NC_NOTNC4_insert_enum,
NC_NOTNC4_inq_enum_member,
NC_NOTNC4_inq_enum_ident,
NC_NOTNC4_def_opaque,
NC_NOTNC4_def_var_deflate,
NC_NOTNC4_def_var_fletcher32,
NC_NOTNC4_def_var_chunking,
NC_NOTNC4_def_var_endian,
NC_NOTNC4_def_var_filter,
NC_NOTNC4_set_var_chunk_cache,
NC_NOTNC4_get_var_chunk_cache
};

const NC_Dispatch* NCINT_dispatch_table = NULL;

/**
* @internal Initialize NCINT dispatch layer.
*
* @return ::NC_NOERR No error.
* @author Ed Hartnett
*/
int
NC_NCINT_initialize(void)
{
NCINT_dispatch_table = &NCINT_dispatcher;
return NC_NOERR;
}

/**
* @internal Finalize NCINT dispatch layer.
*
* @return ::NC_NOERR No error.
* @author Ed Hartnett
*/
int
NC_NCINT_finalize(void)
{
return NC_NOERR;
}
62 changes: 62 additions & 0 deletions src/ncint/ncintdispatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @file @internal This header file contains the prototypes for the
* PIO netCDF integration layer.
*
* Ed Hartnett
*/
#ifndef _NCINTDISPATCH_H
#define _NCINTDISPATCH_H

#include "config.h"
#include "ncdispatch.h"
#include "nc4dispatch.h"

/** This is the max size of an SD dataset name in HDF4 (from HDF4
* documentation).*/
#define NC_MAX_HDF4_NAME 64

/** This is the max number of dimensions for a HDF4 SD dataset (from
* HDF4 documentation). */
#define NC_MAX_HDF4_DIMS 32

/* Stuff below is for hdf4 files. */
typedef struct NC_VAR_HDF4_INFO
{
int sdsid;
int hdf4_data_type;
} NC_VAR_HDF4_INFO_T;

typedef struct NC_HDF4_FILE_INFO
{
int sdid;
} NC_HDF4_FILE_INFO_T;

#if defined(__cplusplus)
extern "C" {
#endif

extern int
NC_NCINT_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void *parameters, const NC_Dispatch *, NC *);

extern int
NC_NCINT_abort(int ncid);

extern int
NC_NCINT_close(int ncid, void *ignore);

extern int
NC_NCINT_inq_format(int ncid, int *formatp);

extern int
NC_NCINT_inq_format_extended(int ncid, int *formatp, int *modep);

extern int
NC_NCINT_get_vara(int ncid, int varid, const size_t *start, const size_t *count,
void *value, nc_type);

#if defined(__cplusplus)
}
#endif

#endif /*_NCINTDISPATCH_H */

0 comments on commit fb66aa3

Please sign in to comment.