diff --git a/tests/cunit/test_async_mpi.c b/tests/cunit/test_async_mpi.c index 058213840fd..de8222417e6 100644 --- a/tests/cunit/test_async_mpi.c +++ b/tests/cunit/test_async_mpi.c @@ -238,7 +238,6 @@ int main(int argc, char **argv) int ntasks; /* Number of processors involved in current execution. */ MPI_Comm test_comm; /* Communicator for tasks running tests. */ int mpierr; /* Return code from MPI functions. */ - int verbose = 0; /* Non-zero to turn on printf statements. */ int ret; /* Return code from function calls. */ /* Initialize MPI. */ @@ -246,10 +245,10 @@ int main(int argc, char **argv) MPIERR(ret); /* Learn my rank and the total number of processors. */ - if ((ret = MPI_Comm_rank(MPI_COMM_WORLD, &my_rank))) - MPIERR(ret); - if ((ret = MPI_Comm_size(MPI_COMM_WORLD, &ntasks))) - MPIERR(ret); + if ((mpierr = MPI_Comm_rank(MPI_COMM_WORLD, &my_rank))) + MPIERR(mpierr); + if ((mpierr = MPI_Comm_size(MPI_COMM_WORLD, &ntasks))) + MPIERR(mpierr); /* Get test_comm. */ if ((ret = get_test_comm(my_rank, ntasks, TARGET_NTASKS, TARGET_NTASKS, &test_comm))) @@ -275,6 +274,7 @@ int main(int argc, char **argv) MPI_Comm union_comm[COMPONENT_COUNT]; MPI_Comm intercomm[COMPONENT_COUNT]; int in_cmp[COMPONENT_COUNT] = {0, 0}; /* Is this process in this computation component? */ + int verbose = 0; /* Non-zero to turn on printf statements. */ /* Create group for world. */ if ((ret = MPI_Comm_group(test_comm, &world_group))) @@ -411,23 +411,25 @@ int main(int argc, char **argv) } /* next computation component. */ /* Now launch IO message processing on the IO task. */ - int comproot[COMPONENT_COUNT] = {1, 1}; if (in_io) + { + int comproot[COMPONENT_COUNT] = {1, 1}; + if ((ret = msg_handler(verbose, my_rank, 0, COMPONENT_COUNT, union_comm, comp_comm, comproot, io_comm))) ERR(ret); + } /* Send exit messages. */ if (!in_io) { for (int cmp = 0; cmp < COMPONENT_COUNT; cmp++) { - - int msg = MSG_EXIT; - int ioroot = 0; - if (in_cmp[cmp]) { + int ioroot = 0; + int msg = MSG_EXIT; + if (verbose) printf("my_rank %d sending exit message on union_comm %d\n", my_rank, union_comm[cmp]); if ((mpierr = MPI_Send(&msg, 1, MPI_INT, ioroot, 1, union_comm[cmp]))) diff --git a/tests/cunit/test_decomp_uneven.c b/tests/cunit/test_decomp_uneven.c index aee53f55263..cfca3efc38d 100644 --- a/tests/cunit/test_decomp_uneven.c +++ b/tests/cunit/test_decomp_uneven.c @@ -17,7 +17,7 @@ #define MIN_NTASKS 4 /* The name of this test. */ -#define TEST_NAME "test_darray_uneven" +#define TEST_NAME "test_decomp_uneven" /* Number of processors that will do IO. */ #define NUM_IO_PROCS 1 @@ -122,15 +122,16 @@ int test_decomp_read_write(int iosysid, int ioid, int num_flavors, int *flavor, char title_in[PIO_MAX_NAME + 1]; char history_in[PIO_MAX_NAME + 1]; int fortran_order_in; /* Indicates fortran vs. c order. */ - int ret; /* Return code. */ /* Use PIO to create the decomp file in one of the four * available ways. */ for (int fmt = 0; fmt < 1; fmt++) { + int ret; /* Return code. */ + /* Create the filename. */ - sprintf(filename, "decomp_%s_pio_type_%d_dims_%d_x_%d_x_%d.nc", TEST_NAME, pio_type, - dim_len[0], dim_len[1], dim_len[2]); + snprintf(filename, PIO_MAX_NAME, "decomp_%s_pio_type_%d_dims_%d_x_%d_x_%d.nc", + TEST_NAME, pio_type, dim_len[0], dim_len[1], dim_len[2]); /* Create history string. */ strncat(history, filename, NC_MAX_NAME - strlen(TEST_DECOMP_HISTORY)); @@ -264,11 +265,8 @@ int main(int argc, char **argv) /* #define NUM_TYPES_TO_TEST 3 */ /* int test_type[NUM_TYPES_TO_TEST] = {PIO_INT, PIO_FLOAT, PIO_DOUBLE}; */ #define NUM_TYPES_TO_TEST 1 - int test_type[NUM_TYPES_TO_TEST] = {PIO_INT}; int my_rank; int ntasks; - int num_flavors; /* Number of PIO netCDF flavors in this build. */ - int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */ MPI_Comm test_comm; /* A communicator for this test. */ int ret; /* Return code. */ @@ -307,6 +305,8 @@ int main(int argc, char **argv) {3, 2, 2, 2}, {2, 2, 1, 1}}; int *expected_map[NUM_DIM_COMBOS_TO_TEST] = {map_1x4x4, map_2x4x4, map_3x4x4, map_1x3x3, map_1x2x3}; + 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. */ /* Figure out iotypes. */ @@ -328,6 +328,8 @@ int main(int argc, char **argv) { for (int dc = 0; dc < NUM_DIM_COMBOS_TO_TEST; dc++) { + int test_type[NUM_TYPES_TO_TEST] = {PIO_INT}; + /* What is length of map for this combo? */ int full_maplen = 1; for (int d = 0; d < NDIM3; d++) diff --git a/tests/cunit/test_iosystem3.c b/tests/cunit/test_iosystem3.c index 61ca0e24e59..ecd59b03655 100644 --- a/tests/cunit/test_iosystem3.c +++ b/tests/cunit/test_iosystem3.c @@ -56,7 +56,8 @@ int create_file(MPI_Comm comm, int iosysid, int format, char *filename, return ret; /* Write an attribute. */ - if ((ret = PIOc_put_att_text(ncid, varid, attname, strlen(filename), filename))) + if ((ret = PIOc_put_att_text(ncid, varid, attname, strnlen(filename, PIO_TF_MAX_STR_LEN), + filename))) return ret; /* End define mode. */ @@ -93,11 +94,11 @@ int check_file(MPI_Comm comm, int iosysid, int format, int ncid, char *filename, /* Check the attribute. Null terminating byte deliberately ignored * to match fortran code. */ - if (!(att_data = malloc(strlen(filename) * sizeof(char)))) + if (!(att_data = malloc(strnlen(filename, PIO_TF_MAX_STR_LEN) * sizeof(char)))) return PIO_ENOMEM; if ((ret = PIOc_get_att(ncid, varid, attname, att_data))) return ret; - if (strncmp(att_data, filename, strlen(filename))) + if (strncmp(att_data, filename, strnlen(filename, PIO_TF_MAX_STR_LEN))) return ERR_WRONG; free(att_data); @@ -142,10 +143,7 @@ int main(int argc, char **argv) MPI_Comm overlap_comm = MPI_COMM_NULL; /* Communicator for tasks 0, 1, 2. */ int even_rank = -1, overlap_rank = -1; /* Tasks rank in communicator. */ int even_size = 0, overlap_size = 0; /* Size of communicator. */ - int num_flavors; /* Number of PIO netCDF flavors in this build. */ - int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */ MPI_Comm test_comm; - int rearranger[NUM_REARRANGERS] = {PIO_REARR_BOX, PIO_REARR_SUBSET}; int ret; /* Return code. */ /* Initialize test. */ @@ -157,6 +155,10 @@ int main(int argc, char **argv) * nothing. */ if (my_rank < TARGET_NTASKS) { + int num_flavors; /* Number of PIO netCDF flavors in this build. */ + int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */ + int rearranger[NUM_REARRANGERS] = {PIO_REARR_BOX, PIO_REARR_SUBSET}; + /* Figure out iotypes. */ if ((ret = get_iotypes(&num_flavors, flavor))) ERR(ret); diff --git a/tests/cunit/test_pioc_putget.c b/tests/cunit/test_pioc_putget.c index fea2af1fea1..5b01fd424e1 100644 --- a/tests/cunit/test_pioc_putget.c +++ b/tests/cunit/test_pioc_putget.c @@ -777,15 +777,10 @@ int test_read_att(int ncid, int *varid, int flavor) char text_in[ATT_LEN]; signed char byte_array_in[ATT_LEN]; short short_array_in[ATT_LEN]; - unsigned char ubyte_array_in[ATT_LEN]; int int_array_in[ATT_LEN]; long int long_array_in[ATT_LEN]; float float_array_in[ATT_LEN]; double double_array_in[ATT_LEN]; - unsigned short ushort_array_in[ATT_LEN]; - unsigned int uint_array_in[ATT_LEN]; - long long int64_array_in[ATT_LEN]; - unsigned long long uint64_array_in[ATT_LEN]; int x; int ret; @@ -823,6 +818,12 @@ int test_read_att(int ncid, int *varid, int flavor) if (flavor == PIO_IOTYPE_NETCDF4C || flavor == PIO_IOTYPE_NETCDF4P) { + unsigned char ubyte_array_in[ATT_LEN]; + unsigned short ushort_array_in[ATT_LEN]; + unsigned int uint_array_in[ATT_LEN]; + long long int64_array_in[ATT_LEN]; + unsigned long long uint64_array_in[ATT_LEN]; + if ((ret = PIOc_get_att_uchar(ncid, varid[7], UCHAR_ATT_NAME, ubyte_array_in))) return ret; if ((ret = PIOc_get_att_ushort(ncid, varid[8], USHORT_ATT_NAME, ushort_array_in)))