Skip to content

Commit

Permalink
better handling of netcdf integration in C lirbary
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 12, 2019
1 parent 2469a2b commit d2add2e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
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 d2add2e

Please sign in to comment.