From 9e6115f29a3cd487afe7d79a2ddcf2210ddadd4c Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 15 May 2019 05:31:32 -0600 Subject: [PATCH 1/2] changes as suggested by Jayesh --- examples/c/darray_async.c | 6 +++--- examples/c/darray_no_async.c | 6 +++--- examples/c/example2.c | 8 ++++---- src/clib/pio_darray_int.c | 2 +- src/clib/pioc_support.c | 26 +++++++++++++------------- tests/cunit/test_async_3proc.c | 4 ++-- tests/cunit/test_async_4proc.c | 4 ++-- tests/cunit/test_async_simple.c | 4 ++-- tests/cunit/test_common.c | 30 +++++++++++++++--------------- tests/cunit/test_darray.c | 4 ++-- tests/cunit/test_darray_multi.c | 2 +- tests/cunit/test_decomp_uneven.c | 2 +- tests/cunit/test_intercomm2.c | 20 ++++++++++---------- tests/cunit/test_iosystem2.c | 6 ++++++ 14 files changed, 65 insertions(+), 59 deletions(-) diff --git a/examples/c/darray_async.c b/examples/c/darray_async.c index d00b6991682..aa7e57760ef 100644 --- a/examples/c/darray_async.c +++ b/examples/c/darray_async.c @@ -117,7 +117,7 @@ int resultlen; /* nc_type xtype; /\* NetCDF data type of this variable. *\/ */ /* int ret; /\* Return code for function calls. *\/ */ /* int dimids[NDIM3]; /\* Dimension ids for this variable. *\/ */ -/* char var_name[NC_MAX_NAME]; /\* Name of the variable. *\/ */ +/* char var_name[PIO_MAX_NAME]; /\* Name of the variable. *\/ */ /* /\* size_t start[NDIM3]; /\\* Zero-based index to start read. *\\/ *\/ */ /* /\* size_t count[NDIM3]; /\\* Number of elements to read. *\\/ *\/ */ /* /\* int buffer[DIM_LEN_X]; /\\* Buffer to read in data. *\\/ *\/ */ @@ -137,7 +137,7 @@ int resultlen; /* return ERR_BAD; */ /* for (int d = 0; d < NDIM3; d++) */ /* { */ -/* char my_dim_name[NC_MAX_NAME]; */ +/* char my_dim_name[PIO_MAX_NAME]; */ /* PIO_Offset dimlen; */ /* if ((ret = PIOc_inq_dim(ncid, d, my_dim_name, &dimlen))) */ @@ -222,7 +222,7 @@ int main(int argc, char* argv[]) /* int ncid; /\* The ncid of the netCDF file. *\/ */ /* int dimid[NDIM3]; /\* The dimension ID. *\/ */ /* int varid; /\* The ID of the netCDF varable. *\/ */ - /* char filename[NC_MAX_NAME + 1]; /\* Test filename. *\/ */ + /* char filename[PIO_MAX_NAME + 1]; /\* Test filename. *\/ */ /* int num_flavors = 0; /\* Number of iotypes available in this build. *\/ */ /* int format[NUM_NETCDF_FLAVORS]; /\* Different output flavors. *\/ */ int ret; /* Return value. */ diff --git a/examples/c/darray_no_async.c b/examples/c/darray_no_async.c index 784612acdcf..1403018f1a3 100644 --- a/examples/c/darray_no_async.c +++ b/examples/c/darray_no_async.c @@ -110,7 +110,7 @@ int check_file(int iosysid, int ntasks, char *filename, int iotype, nc_type xtype; /* NetCDF data type of this variable. */ int ret; /* Return code for function calls. */ int dimids[NDIM3]; /* Dimension ids for this variable. */ - char var_name[NC_MAX_NAME]; /* Name of the variable. */ + char var_name[PIO_MAX_NAME]; /* Name of the variable. */ /* size_t start[NDIM3]; /\* Zero-based index to start read. *\/ */ /* size_t count[NDIM3]; /\* Number of elements to read. *\/ */ /* int buffer[DIM_LEN_X]; /\* Buffer to read in data. *\/ */ @@ -130,7 +130,7 @@ int check_file(int iosysid, int ntasks, char *filename, int iotype, return ERR_BAD; for (int d = 0; d < NDIM3; d++) { - char my_dim_name[NC_MAX_NAME]; + char my_dim_name[PIO_MAX_NAME]; PIO_Offset dimlen; if ((ret = PIOc_inq_dim(ncid, d, my_dim_name, &dimlen))) @@ -227,7 +227,7 @@ int main(int argc, char* argv[]) int dimid[NDIM3]; /* The dimension ID. */ int varid; /* The ID of the netCDF varable. */ int ioid; /* The I/O description ID. */ - char filename[NC_MAX_NAME + 1]; /* Test filename. */ + char filename[PIO_MAX_NAME + 1]; /* Test filename. */ int num_flavors = 0; /* Number of iotypes available in this build. */ int format[NUM_NETCDF_FLAVORS]; /* Different output flavors. */ int ret; /* Return value. */ diff --git a/examples/c/example2.c b/examples/c/example2.c index becbcaccd29..fc05e61aa8b 100644 --- a/examples/c/example2.c +++ b/examples/c/example2.c @@ -92,7 +92,7 @@ char err_buffer[MPI_MAX_ERROR_STRING]; int resultlen; /** The dimension names. */ -char dim_name[NDIM][NC_MAX_NAME + 1] = {"timestep", "x", "y"}; +char dim_name[NDIM][PIO_MAX_NAME + 1] = {"timestep", "x", "y"}; /** Length of the dimensions in the sample data. */ int dim_len[NDIM] = {NC_UNLIMITED, X_DIM_LEN, Y_DIM_LEN}; @@ -228,8 +228,8 @@ int check_file(int ntasks, char *filename) { nc_type xtype; /**< NetCDF data type of this variable. */ int ret; /**< Return code for function calls. */ int dimids[NDIM]; /**< Dimension ids for this variable. */ - char my_dim_name[NC_MAX_NAME + 1]; /**< Name of the dimension. */ - char var_name[NC_MAX_NAME + 1]; /**< Name of the variable. */ + char my_dim_name[PIO_MAX_NAME + 1]; /**< Name of the dimension. */ + char var_name[PIO_MAX_NAME + 1]; /**< Name of the variable. */ size_t start[NDIM]; /**< Zero-based index to start read. */ size_t count[NDIM]; /**< Number of elements to read. */ int buffer[X_DIM_LEN]; /**< Buffer to read in data. */ @@ -359,7 +359,7 @@ int main(int argc, char* argv[]) * (serial4 and parallel4) will be in netCDF-4/HDF5 * format. All four can be read by the netCDF library, and all * will contain the same contents. */ - char filename[NUM_NETCDF_FLAVORS][NC_MAX_NAME + 1] = {"example2_pnetcdf.nc", + char filename[NUM_NETCDF_FLAVORS][PIO_MAX_NAME + 1] = {"example2_pnetcdf.nc", "example2_classic.nc", "example2_serial4.nc", "example2_parallel4.nc"}; diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index 531a41e0b4f..15ddf335be2 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -264,7 +264,7 @@ int get_vard_mpidatatype(io_desc_t *iodesc, MPI_Offset gdim0, PIO_Offset unlimdi /** * Fill start/count arrays for write_darray_multi_par(). This is an - * internal funciton. + * internal function. * * @param ndims the number of dims in the decomposition. * @param fndims the number of dims in the file. diff --git a/src/clib/pioc_support.c b/src/clib/pioc_support.c index ecf52c862a5..1d4b1d9c681 100644 --- a/src/clib/pioc_support.c +++ b/src/clib/pioc_support.c @@ -63,11 +63,11 @@ int PIOc_strerror(int pioerr, char *errmsg) strcpy(errmsg, "No error"); #if defined(_NETCDF) else if (pioerr <= NC2_ERR && pioerr >= NC4_LAST_ERROR) /* NetCDF error? */ - strncpy(errmsg, nc_strerror(pioerr), NC_MAX_NAME); + strncpy(errmsg, nc_strerror(pioerr), PIO_MAX_NAME); #endif /* endif defined(_NETCDF) */ #if defined(_PNETCDF) else if (pioerr > PIO_FIRST_ERROR_CODE) /* pNetCDF error? */ - strncpy(errmsg, ncmpi_strerror(pioerr), NC_MAX_NAME); + strncpy(errmsg, ncmpi_strerror(pioerr), PIO_MAX_NAME); #endif /* defined( _PNETCDF) */ else /* Handle PIO errors. */ @@ -129,7 +129,7 @@ int PIOc_set_log_level(int level) void pio_init_logging(void) { #if PIO_ENABLE_LOGGING - char log_filename[NC_MAX_NAME]; + char log_filename[PIO_MAX_NAME]; if (!LOG_FILE) { @@ -990,9 +990,9 @@ int PIOc_readmap_from_f90(const char *file, int *ndims, int **gdims, PIO_Offset * @param cmode for PIOc_create(). Will be bitwise or'd with NC_WRITE. * @param ioid the ID of the IO description. * @param title optial title attribute for the file. Must be less than - * NC_MAX_NAME + 1 if provided. Ignored if NULL. + * PIO_MAX_NAME + 1 if provided. Ignored if NULL. * @param history optial history attribute for the file. Must be less - * than NC_MAX_NAME + 1 if provided. Ignored if NULL. + * than PIO_MAX_NAME + 1 if provided. Ignored if NULL. * @param fortran_order set to non-zero if fortran array ordering is * used, or to zero if C array ordering is used. * @returns 0 for success, error code otherwise. @@ -1093,10 +1093,10 @@ int PIOc_write_nc_decomp(int iosysid, const char *filename, int cmode, int ioid, * @param comm an MPI communicator. * @param pio_type the PIO type to be used as the type for the data. * @param title pointer that will get optial title attribute for the - * file. Will be less than NC_MAX_NAME + 1 if provided. Ignored if + * file. Will be less than PIO_MAX_NAME + 1 if provided. Ignored if * NULL. * @param history pointer that will get optial history attribute for - * the file. Will be less than NC_MAX_NAME + 1 if provided. Ignored if + * the file. Will be less than PIO_MAX_NAME + 1 if provided. Ignored if * NULL. * @param fortran_order pointer that gets set to 1 if fortran array * ordering is used, or to zero if C array ordering is used. @@ -1281,8 +1281,8 @@ int pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmo for (int b = 0; b < bt_size; b++) if (strlen(bt_strings[b]) > max_bt_size) max_bt_size = strlen(bt_strings[b]); - if (max_bt_size > NC_MAX_NAME) - max_bt_size = NC_MAX_NAME; + if (max_bt_size > PIO_MAX_NAME) + max_bt_size = PIO_MAX_NAME; /* Copy the backtrace into one long string. */ char full_bt[max_bt_size * bt_size + bt_size + 1]; @@ -1453,7 +1453,7 @@ int pioc_read_nc_decomp_int(int iosysid, const char *filename, int *ndims, int * *max_maplen = max_maplen_in; /* Read title attribute, if it is in the file. */ - char title_in[NC_MAX_NAME + 1]; + char title_in[PIO_MAX_NAME + 1]; ret = PIOc_get_att_text(ncid, NC_GLOBAL, DECOMP_TITLE_ATT_NAME, title_in); if (ret == PIO_NOERR) { @@ -1471,7 +1471,7 @@ int pioc_read_nc_decomp_int(int iosysid, const char *filename, int *ndims, int * return pio_err(ios, NULL, ret, __FILE__, __LINE__); /* Read history attribute, if it is in the file. */ - char history_in[NC_MAX_NAME + 1]; + char history_in[PIO_MAX_NAME + 1]; ret = PIOc_get_att_text(ncid, NC_GLOBAL, DECOMP_HISTORY_ATT_NAME, history_in); if (ret == PIO_NOERR) { @@ -1489,7 +1489,7 @@ int pioc_read_nc_decomp_int(int iosysid, const char *filename, int *ndims, int * return pio_err(ios, NULL, ret, __FILE__, __LINE__); /* Read source attribute. */ - char source_in[NC_MAX_NAME + 1]; + char source_in[PIO_MAX_NAME + 1]; if ((ret = PIOc_get_att_text(ncid, NC_GLOBAL, DECOMP_SOURCE_ATT_NAME, source_in))) return pio_err(ios, NULL, ret, __FILE__, __LINE__); if (source) @@ -1751,7 +1751,7 @@ int PIOc_createfile_int(int iosysid, int *ncidp, int *iotype, const char *filena return pio_err(NULL, NULL, PIO_EBADID, __FILE__, __LINE__); /* User must provide valid input for these parameters. */ - if (!ncidp || !iotype || !filename || strlen(filename) > NC_MAX_NAME) + if (!ncidp || !iotype || !filename || strlen(filename) > PIO_MAX_NAME) return pio_err(ios, NULL, PIO_EINVAL, __FILE__, __LINE__); /* A valid iotype must be specified. */ diff --git a/tests/cunit/test_async_3proc.c b/tests/cunit/test_async_3proc.c index 20c42d1ce83..bc7090e3e40 100644 --- a/tests/cunit/test_async_3proc.c +++ b/tests/cunit/test_async_3proc.c @@ -71,12 +71,12 @@ int main(int argc, char **argv) { for (int flv = 0; flv < num_flavors; flv++) { - char filename[NC_MAX_NAME + 1]; /* Test filename. */ + char filename[PIO_MAX_NAME + 1]; /* Test filename. */ int my_comp_idx = 0; /* Index in iosysid array. */ for (int sample = 0; sample < NUM_SAMPLES; sample++) { - char iotype_name[NC_MAX_NAME + 1]; + char iotype_name[PIO_MAX_NAME + 1]; /* Create a filename. */ if ((ret = get_iotype_name(flavor[flv], iotype_name))) diff --git a/tests/cunit/test_async_4proc.c b/tests/cunit/test_async_4proc.c index 5eb23472db4..5b32d284581 100644 --- a/tests/cunit/test_async_4proc.c +++ b/tests/cunit/test_async_4proc.c @@ -69,12 +69,12 @@ int main(int argc, char **argv) { for (int flv = 0; flv < num_flavors; flv++) { - char filename[NC_MAX_NAME + 1]; /* Test filename. */ + char filename[PIO_MAX_NAME + 1]; /* Test filename. */ int my_comp_idx = 0; /* Index in iosysid array. */ for (int sample = 0; sample < NUM_SAMPLES; sample++) { - char iotype_name[NC_MAX_NAME + 1]; + char iotype_name[PIO_MAX_NAME + 1]; /* Create a filename. */ if ((ret = get_iotype_name(flavor[flv], iotype_name))) diff --git a/tests/cunit/test_async_simple.c b/tests/cunit/test_async_simple.c index a0659966e8b..c5d4839cb9c 100644 --- a/tests/cunit/test_async_simple.c +++ b/tests/cunit/test_async_simple.c @@ -90,8 +90,8 @@ int main(int argc, char **argv) for (int sample = 0; sample < NUM_SAMPLES; sample++) { - char filename[NC_MAX_NAME + 1]; /* Test filename. */ - char iotype_name[NC_MAX_NAME + 1]; + char filename[PIO_MAX_NAME + 1]; /* Test filename. */ + char iotype_name[PIO_MAX_NAME + 1]; /* Create a filename. */ if ((ret = get_iotype_name(flavor[flv], iotype_name))) diff --git a/tests/cunit/test_common.c b/tests/cunit/test_common.c index 0396bce1753..0b89fe2d3d4 100644 --- a/tests/cunit/test_common.c +++ b/tests/cunit/test_common.c @@ -160,13 +160,13 @@ get_iotypes(int *num_flavors, int *flavors) * * @param iotype the IO type * @param name pointer that will get name of IO type. Must have enough - * memory allocated (NC_MAX_NAME + 1 works.) + * memory allocated (PIO_MAX_NAME + 1 works.) * @returns 0 for success, error code otherwise. * @internal */ int get_iotype_name(int iotype, char *name) { - char flavor_name[NUM_FLAVORS][NC_MAX_NAME + 1] = {"pnetcdf", "classic", + char flavor_name[NUM_FLAVORS][PIO_MAX_NAME + 1] = {"pnetcdf", "classic", "serial4", "parallel4"}; /* Check inputs. */ @@ -313,7 +313,7 @@ int test_inq_type(int ncid, int format) { #define NUM_TYPES 11 - char type_name[NC_MAX_NAME + 1]; + char type_name[PIO_MAX_NAME + 1]; PIO_Offset type_size; nc_type xtype[NUM_TYPES] = {NC_CHAR, NC_BYTE, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE, NC_UBYTE, NC_USHORT, NC_UINT, NC_INT64, NC_UINT64}; @@ -540,9 +540,9 @@ check_nc_sample_1(int iosysid, int format, char *filename, int my_rank, int *nci int ret; int ndims, nvars, ngatts, unlimdimid; int ndims2, nvars2, ngatts2, unlimdimid2; - char dimname[NC_MAX_NAME + 1]; + char dimname[PIO_MAX_NAME + 1]; PIO_Offset dimlen; - char varname[NC_MAX_NAME + 1]; + char varname[PIO_MAX_NAME + 1]; nc_type vartype; int varndims, vardimids, varnatts; @@ -636,7 +636,7 @@ create_nc_sample_2(int iosysid, int format, char *filename, int my_rank, int *nc return ret; /* Define a dimension. */ - char dimname2[NC_MAX_NAME + 1]; + char dimname2[PIO_MAX_NAME + 1]; if ((ret = PIOc_def_dim(ncid, FIRST_DIM_NAME_S2, DIM_LEN_S2, &dimid))) return ret; if ((ret = PIOc_inq_dimname(ncid, 0, dimname2))) @@ -647,7 +647,7 @@ create_nc_sample_2(int iosysid, int format, char *filename, int my_rank, int *nc return ret; /* Define a 1-D variable. */ - char varname2[NC_MAX_NAME + 1]; + char varname2[PIO_MAX_NAME + 1]; if ((ret = PIOc_def_var(ncid, FIRST_VAR_NAME_S2, NC_INT, NDIM_S2, &dimid, &varid))) return ret; if ((ret = PIOc_inq_varname(ncid, 0, varname2))) @@ -662,7 +662,7 @@ create_nc_sample_2(int iosysid, int format, char *filename, int my_rank, int *nc short short_att_data = ATT_VALUE_S2; float float_att_data = ATT_VALUE_S2; double double_att_data = ATT_VALUE_S2; - char attname2[NC_MAX_NAME + 1]; + char attname2[PIO_MAX_NAME + 1]; /* Write an att and rename it. */ if ((ret = PIOc_put_att_int(ncid, NC_GLOBAL, FIRST_ATT_NAME_S2, NC_INT, 1, &att_data))) return ret; @@ -732,14 +732,14 @@ check_nc_sample_2(int iosysid, int format, char *filename, int my_rank, int *nci int ndims, nvars, ngatts, unlimdimid; int ndims2, nvars2, ngatts2, unlimdimid2; int dimid2; - char dimname[NC_MAX_NAME + 1]; + char dimname[PIO_MAX_NAME + 1]; PIO_Offset dimlen; - char dimname2[NC_MAX_NAME + 1]; + char dimname2[PIO_MAX_NAME + 1]; PIO_Offset dimlen2; - char varname[NC_MAX_NAME + 1]; + char varname[PIO_MAX_NAME + 1]; nc_type vartype; int varndims, vardimids, varnatts; - char varname2[NC_MAX_NAME + 1]; + char varname2[PIO_MAX_NAME + 1]; nc_type vartype2; int varndims2, vardimids2, varnatts2; int varid2; @@ -749,7 +749,7 @@ check_nc_sample_2(int iosysid, int format, char *filename, int my_rank, int *nci double double_att_data; nc_type atttype; PIO_Offset attlen; - char myattname[NC_MAX_NAME + 1]; + char myattname[PIO_MAX_NAME + 1]; int myid; PIO_Offset start[NDIM_S2] = {0}, count[NDIM_S2] = {DIM_LEN_S2}; int data_in[DIM_LEN_S2]; @@ -969,7 +969,7 @@ int create_nc_sample_3(int iosysid, int iotype, int my_rank, int my_comp_idx, char *filename, char *test_name, int verbose, int use_darray, int ioid) { - char iotype_name[NC_MAX_NAME + 1]; + char iotype_name[PIO_MAX_NAME + 1]; int ncid; signed char my_char_comp_idx = my_comp_idx; int varid[NVAR]; @@ -1225,7 +1225,7 @@ int check_nc_sample_3(int iosysid, int iotype, int my_rank, int my_comp_idx, int create_nc_sample_4(int iosysid, int iotype, int my_rank, int my_comp_idx, char *filename, char *test_name, int verbose, int num_types) { - char iotype_name[NC_MAX_NAME + 1]; + char iotype_name[PIO_MAX_NAME + 1]; int ncid; int scalar_varid[num_types]; int varid[num_types]; diff --git a/tests/cunit/test_darray.c b/tests/cunit/test_darray.c index 22f7a2366a0..37766fab1fc 100644 --- a/tests/cunit/test_darray.c +++ b/tests/cunit/test_darray.c @@ -212,7 +212,7 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank } else { - int varid_big = NC_MAX_VARS + TEST_VAL_42; + int varid_big = PIO_MAX_VARS + TEST_VAL_42; /* These will not work. */ if (PIOc_write_darray_multi(ncid + TEST_VAL_42, &varid, ioid, 1, arraylen, test_data, &frame, @@ -338,7 +338,7 @@ int test_all_darray(int iosysid, int num_flavors, int *flavor, int my_rank, { #define NUM_TYPES_TO_TEST 3 int ioid; - char filename[NC_MAX_NAME + 1]; + char filename[PIO_MAX_NAME + 1]; int pio_type[NUM_TYPES_TO_TEST] = {PIO_INT, PIO_FLOAT, PIO_DOUBLE}; int dim_len_2d[NDIM2] = {X_DIM_LEN, Y_DIM_LEN}; int ret; /* Return code. */ diff --git a/tests/cunit/test_darray_multi.c b/tests/cunit/test_darray_multi.c index 5f8f93c5163..a32e1e8f101 100644 --- a/tests/cunit/test_darray_multi.c +++ b/tests/cunit/test_darray_multi.c @@ -392,7 +392,7 @@ int test_all_darray(int iosysid, int num_flavors, int *flavor, int my_rank, int pio_type[NUM_TYPES_TO_TEST] = {PIO_BYTE, PIO_CHAR, PIO_SHORT, PIO_INT, PIO_FLOAT, PIO_DOUBLE}; #endif /* _NETCDF4 */ int ioid; - char filename[NC_MAX_NAME + 1]; + char filename[PIO_MAX_NAME + 1]; int dim_len_2d[NDIM2] = {X_DIM_LEN, Y_DIM_LEN}; int ret; /* Return code. */ diff --git a/tests/cunit/test_decomp_uneven.c b/tests/cunit/test_decomp_uneven.c index cfca3efc38d..74cb0b4ddc9 100644 --- a/tests/cunit/test_decomp_uneven.c +++ b/tests/cunit/test_decomp_uneven.c @@ -134,7 +134,7 @@ int test_decomp_read_write(int iosysid, int ioid, int num_flavors, int *flavor, 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)); + strncat(history, filename, PIO_MAX_NAME - strlen(TEST_DECOMP_HISTORY)); if ((ret = PIOc_write_nc_decomp(iosysid, filename, 0, ioid, title, history, 0))) return ret; diff --git a/tests/cunit/test_intercomm2.c b/tests/cunit/test_intercomm2.c index 115761b9ffd..e28d2316d89 100644 --- a/tests/cunit/test_intercomm2.c +++ b/tests/cunit/test_intercomm2.c @@ -61,14 +61,14 @@ int check_file(int iosysid, int format, char *filename, int my_rank) int ndims, nvars, ngatts, unlimdimid; int ndims2, nvars2, ngatts2, unlimdimid2; int dimid2; - char dimname[NC_MAX_NAME + 1]; + char dimname[PIO_MAX_NAME + 1]; PIO_Offset dimlen; - char dimname2[NC_MAX_NAME + 1]; + char dimname2[PIO_MAX_NAME + 1]; PIO_Offset dimlen2; - char varname[NC_MAX_NAME + 1]; + char varname[PIO_MAX_NAME + 1]; nc_type vartype; int varndims, vardimids, varnatts; - char varname2[NC_MAX_NAME + 1]; + char varname2[PIO_MAX_NAME + 1]; nc_type vartype2; int varndims2, vardimids2, varnatts2; int varid2; @@ -205,7 +205,7 @@ int check_file(int iosysid, int format, char *filename, int my_rank) /* Check out the global attributes. */ nc_type atttype; PIO_Offset attlen; - char myattname[NC_MAX_NAME + 1]; + char myattname[PIO_MAX_NAME + 1]; int myid; if ((ret = PIOc_inq_att(ncid, NC_GLOBAL, ATT_NAME, &atttype, &attlen))) ERR(ret); @@ -280,7 +280,7 @@ int main(int argc, char **argv) int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */ /* Names for the output files. */ - char filename[NUM_FLAVORS][NC_MAX_NAME + 1]; + char filename[NUM_FLAVORS][PIO_MAX_NAME + 1]; /* The ID for the parallel I/O system. */ int iosysid[COMPONENT_COUNT]; @@ -362,7 +362,7 @@ int main(int argc, char **argv) ERR(ERR_AWFUL); /* Test the inq_type function for atomic types. */ - char type_name[NC_MAX_NAME + 1]; + char type_name[PIO_MAX_NAME + 1]; PIO_Offset type_size; nc_type xtype[NUM_TYPES] = {NC_CHAR, NC_BYTE, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE, NC_UBYTE, NC_USHORT, NC_UINT, NC_INT64, NC_UINT64}; @@ -383,7 +383,7 @@ int main(int argc, char **argv) } /* Define a dimension. */ - char dimname2[NC_MAX_NAME + 1]; + char dimname2[PIO_MAX_NAME + 1]; if ((ret = PIOc_def_dim(ncid, FIRST_DIM_NAME, DIM_LEN, &dimid))) ERR(ret); if ((ret = PIOc_inq_dimname(ncid, 0, dimname2))) @@ -402,7 +402,7 @@ int main(int argc, char **argv) ERR(ERR_WRONG); /* Define a 1-D variable. */ - char varname2[NC_MAX_NAME + 1]; + char varname2[PIO_MAX_NAME + 1]; if ((ret = PIOc_def_var(ncid, FIRST_VAR_NAME, NC_INT, NDIM, &dimid, &varid))) ERR(ret); if ((ret = PIOc_inq_varname(ncid, 0, varname2))) @@ -425,7 +425,7 @@ int main(int argc, char **argv) short short_att_data = ATT_VALUE; float float_att_data = ATT_VALUE; double double_att_data = ATT_VALUE; - char attname2[NC_MAX_NAME + 1]; + char attname2[PIO_MAX_NAME + 1]; /* Write an att and rename it. */ if ((ret = PIOc_put_att_int(ncid, NC_GLOBAL, FIRST_ATT_NAME, NC_INT, 1, &att_data))) diff --git a/tests/cunit/test_iosystem2.c b/tests/cunit/test_iosystem2.c index 32324e553dd..2a0abe5d019 100644 --- a/tests/cunit/test_iosystem2.c +++ b/tests/cunit/test_iosystem2.c @@ -190,7 +190,13 @@ int main(int argc, char **argv) ERR(ret); if ((ret = PIOc_closefile(ncid2))) ERR(ret); + + /* Wait for everyone to finish. */ + if ((ret = MPI_Barrier(test_comm))) + MPIERR(ret); + } /* next iotype */ + if ((ret = MPI_Comm_free(&newcomm))) MPIERR(ret); From b1d38e368d078b21eff523e66a1a10918ea3ab6b Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Wed, 15 May 2019 06:11:50 -0600 Subject: [PATCH 2/2] changes as suggested by Jayesh --- tests/cunit/test_iosystem2_simple.c | 6 +++--- tests/cunit/test_iosystem2_simple2.c | 4 ++-- tests/cunit/test_iosystem3_simple2.c | 2 +- tests/cunit/test_pioc.c | 14 +++++++------- tests/cunit/test_pioc_unlim.c | 2 +- tests/general/test_memleak.c | 10 +++++----- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/cunit/test_iosystem2_simple.c b/tests/cunit/test_iosystem2_simple.c index db94bf0ed41..065e181e324 100644 --- a/tests/cunit/test_iosystem2_simple.c +++ b/tests/cunit/test_iosystem2_simple.c @@ -152,8 +152,8 @@ int main(int argc, char **argv) int ncid2; for (int i = 0; i < num_flavors; i++) { - char fn[NUM_FILES][NC_MAX_NAME + 1]; - char dimname[NUM_FILES][NC_MAX_NAME + 1]; + char fn[NUM_FILES][PIO_MAX_NAME + 1]; + char dimname[NUM_FILES][PIO_MAX_NAME + 1]; /* Create the test files. */ for (int f = 0; f < NUM_FILES; f++) @@ -193,7 +193,7 @@ int main(int argc, char **argv) return ret; /* Check the first file. */ - char dimname_in[NC_MAX_NAME + 1]; + char dimname_in[PIO_MAX_NAME + 1]; if ((ret = PIOc_inq_dimname(ncid, 0, dimname_in))) return ret; if (strcmp(dimname_in, dimname[0])) diff --git a/tests/cunit/test_iosystem2_simple2.c b/tests/cunit/test_iosystem2_simple2.c index fe3b2388a87..00ebc7cdd6c 100644 --- a/tests/cunit/test_iosystem2_simple2.c +++ b/tests/cunit/test_iosystem2_simple2.c @@ -76,12 +76,12 @@ int main(int argc, char **argv) for (int flv = 0; flv < num_flavors; flv++) { - char filename[NUM_SAMPLES][NC_MAX_NAME + 1]; /* Test filename. */ + char filename[NUM_SAMPLES][PIO_MAX_NAME + 1]; /* Test filename. */ int sample_ncid[NUM_SAMPLES]; for (int sample = 0; sample < NUM_SAMPLES; sample++) { - char iotype_name[NC_MAX_NAME + 1]; + char iotype_name[PIO_MAX_NAME + 1]; /* Create a filename. */ if ((ret = get_iotype_name(flavor[flv], iotype_name))) diff --git a/tests/cunit/test_iosystem3_simple2.c b/tests/cunit/test_iosystem3_simple2.c index 7253412557c..7f43f64aad7 100644 --- a/tests/cunit/test_iosystem3_simple2.c +++ b/tests/cunit/test_iosystem3_simple2.c @@ -29,7 +29,7 @@ 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_world; /* The ID for the parallel I/O system. */ - char fname0[NC_MAX_NAME + 1]; + char fname0[PIO_MAX_NAME + 1]; int ncid; int num_flavors; /* Number of PIO netCDF flavors in this build. */ int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */ diff --git a/tests/cunit/test_pioc.c b/tests/cunit/test_pioc.c index 7509db9f54d..4e44e31fcd5 100644 --- a/tests/cunit/test_pioc.c +++ b/tests/cunit/test_pioc.c @@ -1903,8 +1903,8 @@ int test_decomp_internal(int my_test_size, int my_rank, int iosysid, int dim_len MPI_Comm test_comm, int async) { int ioid; - char filename[NC_MAX_NAME + 1]; /* Test decomp filename. */ - char nc_filename[NC_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ + char filename[PIO_MAX_NAME + 1]; /* Test decomp filename. */ + char nc_filename[PIO_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ iosystem_desc_t *ios; /* IO system info. */ int ret; @@ -2092,7 +2092,7 @@ int test_decomp_public(int my_test_size, int my_rank, int iosysid, int dim_len, MPI_Comm test_comm, int async) { int ioid; - char nc_filename[NC_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ + char nc_filename[PIO_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ int ret; /* This will be our file name for writing out decompositions. */ @@ -2237,7 +2237,7 @@ int test_decomp_public_2(int my_test_size, int my_rank, int iosysid, int dim_len MPI_Comm test_comm, int async) { int ioid; - char nc_filename[NC_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ + char nc_filename[PIO_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ int ret; /* This will be our file name for writing out decompositions. */ @@ -2263,7 +2263,7 @@ int test_decomp_2(int my_test_size, int my_rank, int iosysid, int dim_len, MPI_Comm test_comm, int async) { int ioid; - char nc_filename[NC_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ + char nc_filename[PIO_MAX_NAME + 1]; /* Test decomp filename (netcdf version). */ int ret; /* This will be our file name for writing out decompositions. */ @@ -2317,8 +2317,8 @@ int test_all(int iosysid, int num_flavors, int *flavor, int my_rank, MPI_Comm te { int ioid; int my_test_size; - char filename[NC_MAX_NAME + 1]; - char nc_filename[NC_MAX_NAME + 1]; + char filename[PIO_MAX_NAME + 1]; + char nc_filename[PIO_MAX_NAME + 1]; int ret; /* Return code. */ if ((ret = MPI_Comm_size(test_comm, &my_test_size))) diff --git a/tests/cunit/test_pioc_unlim.c b/tests/cunit/test_pioc_unlim.c index 725132cdfce..115b30bca7f 100644 --- a/tests/cunit/test_pioc_unlim.c +++ b/tests/cunit/test_pioc_unlim.c @@ -236,7 +236,7 @@ int test_all(int iosysid, int num_flavors, int *flavor, int my_rank, MPI_Comm te int ncid; int varid; int my_test_size; - char filename[NC_MAX_NAME + 1]; + char filename[PIO_MAX_NAME + 1]; int ret; /* Return code. */ if ((ret = MPI_Comm_size(test_comm, &my_test_size))) diff --git a/tests/general/test_memleak.c b/tests/general/test_memleak.c index f9ecbd720df..48abc4a00a2 100644 --- a/tests/general/test_memleak.c +++ b/tests/general/test_memleak.c @@ -66,7 +66,7 @@ char err_buffer[MPI_MAX_ERROR_STRING]; int resultlen; /** The dimension names. */ -char dim_name[NDIM][NC_MAX_NAME + 1] = {"timestep", "x", "y"}; +char dim_name[NDIM][PIO_MAX_NAME + 1] = {"timestep", "x", "y"}; /** Length of the dimensions in the sample data. */ int dim_len[NDIM] = {NC_UNLIMITED, X_DIM_LEN, Y_DIM_LEN}; @@ -109,10 +109,10 @@ main(int argc, char **argv) * (serial4 and parallel4) will be in netCDF-4/HDF5 * format. All four can be read by the netCDF library, and all * will contain the same contents. */ - char filename[NUM_NETCDF_FLAVORS][NC_MAX_NAME + 1] = {"test_nc4_pnetcdf.nc", - "test_nc4_classic.nc", - "test_nc4_serial4.nc", - "test_nc4_parallel4.nc"}; + char filename[NUM_NETCDF_FLAVORS][PIO_MAX_NAME + 1] = {"test_nc4_pnetcdf.nc", + "test_nc4_classic.nc", + "test_nc4_serial4.nc", + "test_nc4_parallel4.nc"}; /** Number of processors that will do IO. In this example we * will do IO from all processors. */