Skip to content

Commit

Permalink
moved init of UDF to nc_init_intercomm()
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 6, 2019
1 parent 4d3e937 commit 974ed66
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
21 changes: 0 additions & 21 deletions src/ncint/ncint_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@
/* The default io system id. */
extern int diosysid;

/**
* Same as PIOc_Init_Intracomm().
*
* @author Ed Hartnett
*/
int
nc_init_intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int rearr,
int *iosysidp)
{
int ret;

if ((ret = PIOc_Init_Intracomm(comp_comm, num_iotasks, stride, base, rearr,
iosysidp)))
return ret;

/* Remember the io system id. */
diosysid = *iosysidp;

return PIO_NOERR;
}

/**
* Same as PIOc_free_iosystem().
*
Expand Down
32 changes: 32 additions & 0 deletions src/ncint/ncintdispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/** Default iosysid. */
int diosysid;

/** Did we initialize user-defined format? */
int ncint_initialized = 0;

/* This is the dispatch object that holds pointers to all the
* functions that make up the NCINT dispatch interface. */
NC_Dispatch NCINT_dispatcher = {
Expand Down Expand Up @@ -110,6 +113,35 @@ NC_Dispatch NCINT_dispatcher = {

const NC_Dispatch* NCINT_dispatch_table = NULL;

/**
* Same as PIOc_Init_Intracomm().
*
* @author Ed Hartnett
*/
int
nc_init_intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int base, int rearr,
int *iosysidp)
{
int ret;

/* Add our user defined format, if necessary. */
if (!ncint_initialized)
{
if ((ret = nc_def_user_format(NC_UDF0, &NCINT_dispatcher, NULL)))
return ret;
ncint_initialized++;
}

if ((ret = PIOc_Init_Intracomm(comp_comm, num_iotasks, stride, base, rearr,
iosysidp)))
return ret;

/* Remember the io system id. */
diosysid = *iosysidp;

return PIO_NOERR;
}

/**
* @internal Initialize NCINT dispatch layer.
*
Expand Down
3 changes: 0 additions & 3 deletions tests/ncint/tst_pio_udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ main(int argc, char **argv)
/* Initialize the intracomm. */
if (nc_init_intracomm(MPI_COMM_WORLD, 1, 1, 0, 0, &iosysid)) ERR;

/* Add our user defined format. */
if (nc_def_user_format(NC_UDF0, &NCINT_dispatcher, NULL)) ERR;

/* Create a file with a 3D record var. */
if (nc_create(FILE_NAME, NC_UDF0, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME_UNLIMITED, dimlen[0], &dimid[0])) ERR;
Expand Down

0 comments on commit 974ed66

Please sign in to comment.