Skip to content

Commit

Permalink
more test code for test_async_1d.c
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Sep 4, 2019
1 parent e6b40bc commit 9682bb2
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions tests/cunit/test_async_1d.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,33 @@
/* The name of this test. */
#define TEST_NAME "test_async_1d"

/* The name of the output of the test. */
#define FILE_NAME "test_async_1d.nc"

/* Number of different combonations of IO and computation processor
* numbers we will try in this test. */
#define NUM_COMBOS 3

/* Number of computational components to create. */
#define COMPONENT_COUNT 1

#define NDIM1 1
#define NDIM2 2
#define DIM_NAME_0 "unlim"
#define DIM_NAME_1 "dim_1"
#define DIM_LEN_1 3
#define VAR_NAME "async_var"
#define MAPLEN 1

/* Run async tests. */
int main(int argc, char **argv)
{
int my_rank; /* Zero-based rank of processor. */
int ntasks; /* Number of processors involved in current execution. */
int iosysid; /* The ID for the parallel I/O system. */
int num_procs_per_comp[COMPONENT_COUNT] = {3};
int num_flavors; /* Number of PIO netCDF flavors in this build. */
int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */
/* int num_flavors; /\* Number of PIO netCDF flavors in this build. *\/ */
/* int flavor[NUM_FLAVORS]; /\* iotypes for the supported netCDF IO flavors. *\/ */
int ret; /* Return code. */

/* Initialize MPI. */
Expand All @@ -55,7 +66,8 @@ int main(int argc, char **argv)
PIOc_set_log_level(4);

/* Set up IO system. Task 0 will do IO, tasks 1-3 will be a single
* computational unit. */
* computational unit. Task 0 will stay in this function until the
* computational component calls PIOc_finalize(). */
if ((ret = PIOc_init_async(MPI_COMM_WORLD, NUM_IO_TASKS, NULL, COMPONENT_COUNT,
num_procs_per_comp, NULL, NULL, NULL,
PIO_REARR_BOX, &iosysid)))
Expand All @@ -64,6 +76,41 @@ int main(int argc, char **argv)
/* Only computational processors run this code. */
if (my_rank)
{
int ncid;
int iotype = PIO_IOTYPE_NETCDF4C;
int dimid[NDIM2];
int gdimlen[NDIM1] = {DIM_LEN_1};
PIO_Offset compmap[MAPLEN];
int varid;
int ioid;

/* Create a file. */
if ((ret = PIOc_createfile(iosysid, &ncid, &iotype, FILE_NAME, 0)))
ERR(ret);
if ((ret = PIOc_def_dim(ncid, DIM_NAME_0, PIO_UNLIMITED, &dimid[0])))
ERR(ret);
if ((ret = PIOc_def_dim(ncid, DIM_NAME_1, DIM_LEN_1, &dimid[1])))
ERR(ret);
if ((ret = PIOc_def_var(ncid, VAR_NAME, PIO_INT, NDIM2, dimid, &varid)))
ERR(ret);
if ((ret = PIOc_enddef(ncid)))
ERR(ret);

/* Set up a decomposition. Each of the 3 computational procs
* will write one value, to get the 3-values of each
* record. */
compmap[0] = my_rank - 1;
if ((ret = PIOc_init_decomp(iosysid, PIO_INT, NDIM1, gdimlen, MAPLEN,
compmap, &ioid, PIO_REARR_BOX, NULL, NULL)))
ERR(ret);
if ((ret = PIOc_freedecomp(iosysid, ioid)))
ERR(ret);

/* Close the file. */
if ((ret = PIOc_closefile(ncid)))
ERR(ret);

/* Shut down the IO system. */
if ((ret = PIOc_finalize(iosysid)))
ERR(ret);
}
Expand Down

0 comments on commit 9682bb2

Please sign in to comment.