Skip to content

Commit

Permalink
Merge pull request ESMCI#1419 from NCAR/ejh_max_name
Browse files Browse the repository at this point in the history
Changes from Jayesh's PR...
  • Loading branch information
edhartnett authored May 15, 2019
2 parents 230fadd + b1d38e3 commit af3cab2
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 78 deletions.
6 changes: 3 additions & 3 deletions examples/c/darray_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. *\\/ *\/ */
Expand All @@ -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))) */
Expand Down Expand Up @@ -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. */
Expand Down
6 changes: 3 additions & 3 deletions examples/c/darray_no_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. *\/ */
Expand All @@ -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)))
Expand Down Expand Up @@ -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. */
Expand Down
8 changes: 4 additions & 4 deletions examples/c/example2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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"};
Expand Down
2 changes: 1 addition & 1 deletion src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 13 additions & 13 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_async_3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_async_4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_async_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
30 changes: 15 additions & 15 deletions tests/cunit/test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)))
Expand All @@ -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)))
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions tests/cunit/test_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_darray_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down
2 changes: 1 addition & 1 deletion tests/cunit/test_decomp_uneven.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit af3cab2

Please sign in to comment.