Skip to content

Commit

Permalink
Merge pull request ESMCI#1560 from NCAR/ejh_ncint_fortran_2
Browse files Browse the repository at this point in the history
Further development of netCDF integration in C library, to support Fortran
  • Loading branch information
edhartnett authored Jul 12, 2019
2 parents 08e7b2b + d2add2e commit b1ffbf1
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 10 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ fi
if test "x$enable_netcdf_integration" = xyes; then
AC_DEFINE([HDF5_PARALLEL],[1],[Does HDF5 library provide parallel access])
AC_DEFINE([USE_NETCDF4],[1],[Does HDF5 library provide parallel access])
AC_DEFINE([NETCDF_INTEGRATION],[1],[Are we building with netCDF integration])
fi

AM_CONDITIONAL(BUILD_NCINT, [test "x$enable_netcdf_integration" = xyes])
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Does the user want to build fortran?
if BUILD_FORTRAN
FLIB = flib
endif
endif # BUILD_FORTRAN

# Are we building with the GPTL timing library?
if USE_GPTL
Expand Down
1 change: 1 addition & 0 deletions src/clib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lib_LTLIBRARIES = libpioc.la
# Are we building with netCDF integration?
if BUILD_NCINT
libpioc_la_LIBADD = ../ncint/libncint.la
libpioc_la_CPPFLAGS = -I${top_srcdir}/src/ncint
endif # BUILD_NCINT

# These linker flags specify libtool version info.
Expand Down
1 change: 1 addition & 0 deletions src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,7 @@ extern "C" {
int nc_init_intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int rearr,
int *iosysidp);

int nc_set_iosystem(int iosysid);
int nc_free_iosystem(int iosysid);

int nc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen,
Expand Down
15 changes: 15 additions & 0 deletions src/clib/pioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@
#include <config.h>
#include <pio.h>
#include <pio_internal.h>
#ifdef NETCDF_INTEGRATION
#include "ncintdispatch.h"
#endif /* NETCDF_INTEGRATION */

#ifdef USE_MPE
/* The event numbers for MPE logging. */
extern int event_num[2][NUM_EVENTS];
#endif /* USE_MPE */

#ifdef NETCDF_INTEGRATION
/* Have we initialized? */
extern int ncint_initialized;
#endif /* NETCDF_INTEGRATION */

/**
* @defgroup PIO_init_c Initialize the IO System
* Initialize the IOSystem, including specifying number of IO and
Expand Down Expand Up @@ -934,6 +942,13 @@ PIOc_Init_Intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base,
if ((ret = pio_init_logging()))
return pio_err(NULL, NULL, ret, __FILE__, __LINE__);

#ifdef NETCDF_INTEGRATION
PLOG((1, "Initializing netcdf integration"));
/* Initialize netCDF integration layer if we need to. */
if (!ncint_initialized)
PIO_NCINT_initialize();
#endif /* NETCDF_INTEGRATION */

#ifdef USE_MPE
pio_start_mpe_log(INIT);
#endif /* USE_MPE */
Expand Down
18 changes: 14 additions & 4 deletions src/ncint/ncint_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ nc_init_intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int
{
int ret;

/* Initialize if we need to. */
if (!ncint_initialized)
PIO_NCINT_initialize();

/* Call the PIOc_ function to initialize the intracomm. */
if ((ret = PIOc_Init_Intracomm(comp_comm, num_iotasks, stride, base, rearr,
iosysidp)))
Expand All @@ -42,6 +38,20 @@ nc_init_intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int
return PIO_NOERR;
}

/**
* Set the default iosystemID.
*
* @author Ed Hartnett
*/
int
nc_set_iosystem(int iosysid)
{
/* Remember the io system id. */
diosysid = iosysid;

return PIO_NOERR;
}

/**
* Same as PIOc_free_iosystem().
*
Expand Down
13 changes: 10 additions & 3 deletions src/ncint/ncintdispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ PIO_NCINT_initialize(void)

NCINT_dispatch_table = &NCINT_dispatcher;

PLOG((1, "Adding user-defined format for netCDF PIO integration"));

/* Add our user defined format. */
if ((ret = nc_def_user_format(NC_UDF0, &NCINT_dispatcher, NULL)))
return ret;
Expand All @@ -148,16 +150,21 @@ PIO_NCINT_finalize(void)
return NC_NOERR;
}

/**
* Create a file using PIO via netCDF's nc_create().
*
* @author Ed Hartnett
*/
int
PIO_NCINT_create(const char* path, int cmode, size_t initialsz, int basepe,
PIO_NCINT_create(const char *path, int cmode, size_t initialsz, int basepe,
size_t *chunksizehintp, void *parameters,
const NC_Dispatch *dispatch, NC *nc_file)
{
int iotype;
iosystem_desc_t *ios; /* Pointer to io system information. */
int ret;

LOG((1, "PIO_NCINT_create path = %s mode = %x", path, mode));
PLOG((1, "PIO_NCINT_create path = %s mode = %x", path, cmode));

/* Get the IO system info from the id. */
if (!(ios = pio_get_iosystem_from_id(diosysid)))
Expand Down Expand Up @@ -191,7 +198,7 @@ PIO_NCINT_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
iosystem_desc_t *ios; /* Pointer to io system information. */
int ret;

LOG((1, "PIO_NCINT_open path = %s mode = %x", path, mode));
PLOG((1, "PIO_NCINT_open path = %s mode = %x", path, mode));

/* Get the IO system info from the id. */
if (!(ios = pio_get_iosystem_from_id(diosysid)))
Expand Down
2 changes: 1 addition & 1 deletion tests/ncint/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ endif # RUN_TESTS
EXTRA_DIST = run_tests.sh

# Clean up files produced during testing.
#CLEANFILES = *.nc *.log
CLEANFILES = *.nc *.log
2 changes: 1 addition & 1 deletion tests/ncint/tst_pio_udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ main(int argc, char **argv)
int i;

/* Turn on logging for PIO library. */
PIOc_set_log_level(3);
/* PIOc_set_log_level(3); */

/* Initialize the intracomm. */
if (nc_init_intracomm(MPI_COMM_WORLD, 1, 1, 0, 0, &iosysid)) ERR;
Expand Down

0 comments on commit b1ffbf1

Please sign in to comment.