Skip to content

Commit

Permalink
added nc_init_decomp
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 5, 2019
1 parent 1205baa commit 746f327
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,10 @@ extern "C" {

int nc_free_iosystem(int iosysid);

int nc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen,
int maplen, const size_t *compmap, int *ioidp,
int rearranger, const size_t *iostart,
const size_t *iocount);
#if defined(__cplusplus)
}
#endif
Expand Down
17 changes: 17 additions & 0 deletions src/ncint/ncint_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,20 @@ nc_free_iosystem(int iosysid)
{
return PIOc_free_iosystem(iosysid);
}

/**
* Same as PIOc_init_decomp()
*
* @author Ed Hartnett
*/
int
nc_init_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen,
int maplen, const size_t *compmap, int *ioidp,
int rearranger, const size_t *iostart,
const size_t *iocount)
{
return PIOc_init_decomp(iosysid, pio_type, ndims, gdimlen, maplen,
(const PIO_Offset *)compmap, ioidp, rearranger,
(const PIO_Offset *)iostart,
(const PIO_Offset *)iocount);
}
29 changes: 22 additions & 7 deletions tests/ncint/tst_pio_udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ main(int argc, char **argv)
printf("\n*** Testing netCDF integration layer.\n");
printf("*** testing simple use of netCDF integration layer format...");
{
int ncid;
int ncid, ioid;
int dimid[NDIM2], varid;
int dimlen[NDIM2] = {DIM_LEN_X, DIM_LEN_Y};
int iosysid;
NC_Dispatch *disp_in;
size_t elements_per_pe;
size_t *compdof; /* The decomposition mapping. */
int i;

/* Create an empty file to play with. */
/* if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR; */
/* if (nc_close(ncid)) ERR; */

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

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

Expand All @@ -55,9 +57,22 @@ main(int argc, char **argv)

/* Create a file to play with. */
if (nc_create(FILE_NAME, NC_UDF0, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME_X, DIM_LEN_X, &dimid[0])) ERR;
if (nc_def_dim(ncid, DIM_NAME_Y, DIM_LEN_Y, &dimid[1])) ERR;
if (nc_def_dim(ncid, DIM_NAME_X, dimlen[0], &dimid[0])) ERR;
if (nc_def_dim(ncid, DIM_NAME_Y, dimlen[1], &dimid[1])) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_INT, NDIM2, dimid, &varid)) ERR;

/* Create a decomposition for distributed arrays. */
elements_per_pe = DIM_LEN_X * DIM_LEN_Y / ntasks;
if (!(compdof = malloc(elements_per_pe * sizeof(size_t))))
ERR;
for (i = 0; i < elements_per_pe; i++)
compdof[i] = my_rank * elements_per_pe + i;

/* Create the PIO decomposition for this test. */
if (nc_init_decomp(iosysid, PIO_INT, NDIM2, dimlen, elements_per_pe,
compdof, &ioid, 0, NULL, NULL)) ERR;
free(compdof);

if (nc_close(ncid)) ERR;

/* Check that our user-defined format has been added. */
Expand Down

0 comments on commit 746f327

Please sign in to comment.