Skip to content

Commit

Permalink
changed example
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed May 1, 2019
1 parent 6d7a936 commit f395aa9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 30 deletions.
73 changes: 46 additions & 27 deletions examples/c/darray_no_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* (one unlimited) and one variable. It first writes, then reads the
* sample file using distributed arrays.
*
* This example can be run in parallel for 4 processors.
* This example can be run in parallel for 16 processors.
*/

#include "config.h"
Expand All @@ -32,10 +32,10 @@
#define NUM_TIMESTEPS 2

/* The length of our sample data in X dimension.*/
#define DIM_LEN_X 4
#define DIM_LEN_X 8

/* The length of our sample data in Y dimension.*/
#define DIM_LEN_Y 4
#define DIM_LEN_Y 8

/* The name of the variable in the netCDF output file. */
#define VAR_NAME "foo"
Expand All @@ -48,7 +48,7 @@
#define START_DATA_VAL 42

/* Number of tasks this example runs on. */
#define TARGET_NTASKS 4
#define TARGET_NTASKS 16

/* Logging level. */
#define LOG_LEVEL -1
Expand All @@ -59,6 +59,11 @@ int dim_len[NDIM3] = {NC_UNLIMITED, DIM_LEN_X, DIM_LEN_Y};
/* Names of dimensions. */
char dim_name[NDIM3][PIO_MAX_NAME + 1] = {"unlimted", "x", "y"};

/* These are used when writing the decomposition file. */
#define DECOMP_FILENAME "darray_no_async_decomp.nc"
#define DECOMP_TITLE "Example Decomposition from darray_no_async.c"
#define DECOMP_HISTORY "This file is created by the program darray_no_async in the PIO C library"

/* Handle MPI errors. This should only be used with MPI library
* function calls. */
#define MPIERR(e) do { \
Expand Down Expand Up @@ -180,25 +185,33 @@ int check_file(int iosysid, int ntasks, char *filename, int iotype,
has the following contents (as shown by ncdump):
<pre>
netcdf darray_no_async_iotype_1 {
dimensions:
unlimted = UNLIMITED ; // (2 currently)
x = 4 ;
y = 4 ;
variables:
int foo(unlimted, x, y) ;
data:
foo =
42, 42, 42, 42,
43, 43, 43, 43,
44, 44, 44, 44,
45, 45, 45, 45,
142, 142, 142, 142,
143, 143, 143, 143,
144, 144, 144, 144,
145, 145, 145, 145 ;
}
netcdf darray_no_async_iotype_1 {
dimensions:
unlimted = UNLIMITED ; // (2 currently)
x = 8 ;
y = 8 ;
variables:
int foo(unlimted, x, y) ;
data:
foo =
42, 42, 42, 42, 43, 43, 43, 43,
44, 44, 44, 44, 45, 45, 45, 45,
46, 46, 46, 46, 47, 47, 47, 47,
48, 48, 48, 48, 49, 49, 49, 49,
50, 50, 50, 50, 51, 51, 51, 51,
52, 52, 52, 52, 53, 53, 53, 53,
54, 54, 54, 54, 55, 55, 55, 55,
56, 56, 56, 56, 57, 57, 57, 57,
142, 142, 142, 142, 143, 143, 143, 143,
144, 144, 144, 144, 145, 145, 145, 145,
146, 146, 146, 146, 147, 147, 147, 147,
148, 148, 148, 148, 149, 149, 149, 149,
150, 150, 150, 150, 151, 151, 151, 151,
152, 152, 152, 152, 153, 153, 153, 153,
154, 154, 154, 154, 155, 155, 155, 155,
156, 156, 156, 156, 157, 157, 157, 157 ;
}
</pre>
*/
Expand Down Expand Up @@ -239,7 +252,7 @@ int main(int argc, char* argv[])

/* Check that a valid number of processors was specified. */
if (ntasks != TARGET_NTASKS)
fprintf(stderr, "Number of processors must be 4!\n");
fprintf(stderr, "Number of processors must be 16!\n");
printf("%d: ParallelIO Library darray_no_async example running on %d processors.\n",
my_rank, ntasks);

Expand All @@ -253,7 +266,7 @@ int main(int argc, char* argv[])

/* Initialize the PIO IO system. This specifies how many and
* which processors are involved in I/O. */
if ((ret = PIOc_Init_Intracomm(MPI_COMM_WORLD, 1, ioproc_stride,
if ((ret = PIOc_Init_Intracomm(MPI_COMM_WORLD, 4, ioproc_stride,
ioproc_start, PIO_REARR_BOX, &iosysid)))
ERR(ret);

Expand All @@ -268,9 +281,15 @@ int main(int argc, char* argv[])
/* Create the PIO decomposition for this example. Since this
* is a variable with an unlimited dimension, we want to
* create a 2-D composition which represents one record. */
printf("rank: %d Creating decomposition...\n", my_rank);
printf("rank: %d Creating decomposition, elements_per_pe %lld...\n", my_rank,
elements_per_pe);
if ((ret = PIOc_init_decomp(iosysid, PIO_INT, NDIM3 - 1, &dim_len[1], elements_per_pe,
compdof, &ioid, 0, NULL, NULL)))
compdof, &ioid, PIO_REARR_SUBSET, NULL, NULL)))
ERR(ret);

/* Write the decomposition file. */
if ((ret = PIOc_write_nc_decomp(iosysid, DECOMP_FILENAME, NC_CLOBBER,
ioid, DECOMP_TITLE, DECOMP_HISTORY, 0)))
ERR(ret);

/* The number of favors may change with the build parameters. */
Expand Down
12 changes: 10 additions & 2 deletions examples/c/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ trap exit INT TERM
printf 'running PIO examples...\n'

#PIO_EXAMPLES='examplePio'
PIO_EXAMPLES='example1 examplePio darray_no_async'
PIO_EXAMPLES='example1 examplePio'
PIO_EXAMPLES_16='darray_no_async'

success1=true
for EXAMPLE in $PIO_EXAMPLES
Expand All @@ -20,9 +21,16 @@ do
echo "running ${EXAMPLE}"
mpiexec -n 4 ./${EXAMPLE} && success1=true || break
done
success2=true
for EXAMPLE in $PIO_EXAMPLES_16
do
success2=false
echo "running ${EXAMPLE}"
mpiexec -n 16 ./${EXAMPLE} && success2=true || break
done

# Did we succeed?
if test x$success1 = xtrue; then
if test x$success1 = xtrue -a x$success2 = xtrue; then
exit 0
fi
exit 1
2 changes: 1 addition & 1 deletion src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ typedef struct iosystem_desc_t
MPI_Comm comp_comm;

/** This is an MPI inter communicator between IO communicator and
* computation communicator. */
* computation communicator, only used for async mode. */
MPI_Comm intercomm;

/** This is a copy (but not an MPI copy) of either the comp (for
Expand Down

0 comments on commit f395aa9

Please sign in to comment.