Skip to content

Commit

Permalink
Merge pull request ESMCI#1379 from NCAR/ejh_next_fix_3
Browse files Browse the repository at this point in the history
More codacy warning fixes
  • Loading branch information
edhartnett authored Mar 28, 2019
2 parents 8a095f1 + 437541a commit 5a9c0ef
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 100 deletions.
21 changes: 9 additions & 12 deletions tests/cunit/test_async_manyproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,9 @@ 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[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int num_iotypes; /* Number of PIO netCDF iotypes in this build. */
int iotype[NUM_IOTYPES]; /* iotypes for the supported netCDF IO iotypes. */
int num_procs[COMPONENT_COUNT] = {NUM_COMP_PROCS, NUM_COMP_PROCS}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS];
int comp_proc_list1[NUM_COMP_PROCS] = {NUM_IO_PROCS, NUM_IO_PROCS + 1};
int comp_proc_list2[NUM_COMP_PROCS] = {NUM_IO_PROCS + 2, NUM_IO_PROCS + 3};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list1, comp_proc_list2};
MPI_Comm test_comm;
int verbose = 0;
int ret; /* Return code. */

/* Initialize our list of IO tasks. */
Expand All @@ -61,6 +54,13 @@ int main(int argc, char **argv)
/* Only do something on TARGET_NTASKS tasks. */
if (my_rank < TARGET_NTASKS)
{
int iosysid[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int iotype[NUM_IOTYPES]; /* iotypes for the supported netCDF IO iotypes. */
int num_procs[COMPONENT_COUNT] = {NUM_COMP_PROCS, NUM_COMP_PROCS}; /* Num procs for IO and computation. */
int comp_proc_list1[NUM_COMP_PROCS] = {NUM_IO_PROCS, NUM_IO_PROCS + 1};
int comp_proc_list2[NUM_COMP_PROCS] = {NUM_IO_PROCS + 2, NUM_IO_PROCS + 3};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list1, comp_proc_list2};

/* Figure out iotypes. */
if ((ret = get_iotypes(&num_iotypes, iotype)))
ERR(ret);
Expand All @@ -71,9 +71,6 @@ int main(int argc, char **argv)
if ((ret = PIOc_init_async(test_comm, NUM_IO_PROCS, io_proc_list, COMPONENT_COUNT,
num_procs, (int **)proc_list, NULL, NULL, PIO_REARR_BOX, iosysid)))
ERR(ERR_INIT);
if (verbose)
for (int c = 0; c < COMPONENT_COUNT; c++)
printf("my_rank %d cmp %d iosysid[%d] %d\n", my_rank, c, c, iosysid[c]);

/* All the netCDF calls are only executed on the computation
* tasks. */
Expand All @@ -88,12 +85,12 @@ int main(int argc, char **argv)

/* /\* Create sample file. *\/ */
/* if ((ret = create_nc_sample_3(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx, */
/* filename, TEST_NAME, verbose, 0, 0))) */
/* filename, TEST_NAME, 0, 0, 0))) */
/* ERR(ret); */

/* /\* Check the file for correctness. *\/ */
/* if ((ret = check_nc_sample_3(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx, */
/* filename, verbose, 0, 0))) */
/* filename, 0, 0, 0))) */
/* ERR(ret); */
} /* next netcdf iotype */

Expand Down
23 changes: 10 additions & 13 deletions tests/cunit/test_async_multi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,8 @@ 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[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int num_iotypes; /* Number of PIO netCDF iotypes in this build. */
int iotype[NUM_IOTYPES]; /* iotypes for the supported netCDF IO iotypes. */
int num_procs[COMPONENT_COUNT] = {1, 1}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS] = {0};
int comp_proc_list1[NUM_COMP_PROCS] = {1};
int comp_proc_list2[NUM_COMP_PROCS] = {2};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list1, comp_proc_list2};
MPI_Comm test_comm;
int verbose = 0;
int ret; /* Return code. */

/* Initialize test. */
Expand All @@ -55,6 +47,14 @@ int main(int argc, char **argv)
/* Only do something on TARGET_NTASKS tasks. */
if (my_rank < TARGET_NTASKS)
{
int iosysid[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int iotype[NUM_IOTYPES]; /* iotypes for the supported netCDF IO iotypes. */
int num_procs[COMPONENT_COUNT] = {1, 1}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS] = {0};
int comp_proc_list1[NUM_COMP_PROCS] = {1};
int comp_proc_list2[NUM_COMP_PROCS] = {2};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list1, comp_proc_list2};

/* Figure out iotypes. */
if ((ret = get_iotypes(&num_iotypes, iotype)))
ERR(ret);
Expand All @@ -65,9 +65,6 @@ int main(int argc, char **argv)
if ((ret = PIOc_init_async(test_comm, NUM_IO_PROCS, io_proc_list, COMPONENT_COUNT,
num_procs, (int **)proc_list, NULL, NULL, PIO_REARR_BOX, iosysid)))
ERR(ERR_INIT);
if (verbose)
for (int c = 0; c < COMPONENT_COUNT; c++)
printf("my_rank %d cmp %d iosysid[%d] %d\n", my_rank, c, c, iosysid[c]);

/* All the netCDF calls are only executed on the computation
* tasks. */
Expand All @@ -89,12 +86,12 @@ int main(int argc, char **argv)

/* Create sample file. */
if ((ret = create_nc_sample_4(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx,
filename, TEST_NAME, verbose, num_types)))
filename, TEST_NAME, 0, num_types)))
ERR(ret);

/* Check the file for correctness. */
if ((ret = check_nc_sample_4(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx,
filename, verbose, num_types)))
filename, 0, num_types)))
ERR(ret);

/* Free the decompositions. */
Expand Down
23 changes: 10 additions & 13 deletions tests/cunit/test_async_multicomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,8 @@ 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[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int num_iotypes; /* Number of PIO netCDF iotypes in this build. */
int iotype[NUM_IOTYPES]; /* iotypes for the supported netCDF IO iotypes. */
int num_procs[COMPONENT_COUNT] = {1, 1}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS] = {0};
int comp_proc_list1[NUM_COMP_PROCS] = {1};
int comp_proc_list2[NUM_COMP_PROCS] = {2};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list1, comp_proc_list2};
MPI_Comm test_comm;
int verbose = 0;
int ret; /* Return code. */

/* Initialize test. */
Expand All @@ -61,6 +53,14 @@ int main(int argc, char **argv)
/* Only do something on TARGET_NTASKS tasks. */
if (my_rank < TARGET_NTASKS)
{
int iosysid[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int iotype[NUM_IOTYPES]; /* iotypes for the supported netCDF IO iotypes. */
int num_procs[COMPONENT_COUNT] = {1, 1}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS] = {0};
int comp_proc_list1[NUM_COMP_PROCS] = {1};
int comp_proc_list2[NUM_COMP_PROCS] = {2};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list1, comp_proc_list2};

/* Figure out iotypes. */
if ((ret = get_iotypes(&num_iotypes, iotype)))
ERR(ret);
Expand All @@ -76,9 +76,6 @@ int main(int argc, char **argv)
if ((ret = PIOc_init_async(test_comm, NUM_IO_PROCS, io_proc_list, COMPONENT_COUNT,
num_procs, (int **)proc_list, NULL, NULL, PIO_REARR_BOX, iosysid)))
ERR(ERR_INIT);
if (verbose)
for (int c = 0; c < COMPONENT_COUNT; c++)
printf("my_rank %d cmp %d iosysid[%d] %d\n", my_rank, c, c, iosysid[c]);

/* All the netCDF calls are only executed on the computation
* tasks. */
Expand All @@ -101,12 +98,12 @@ int main(int argc, char **argv)

/* Create sample file. */
if ((ret = create_nc_sample_3(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx,
filename, TEST_NAME, verbose, use_darray, ioid)))
filename, TEST_NAME, 0, use_darray, ioid)))
ERR(ret);

/* Check the file for correctness. */
if ((ret = check_nc_sample_3(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx,
filename, verbose, 0, ioid)))
filename, 0, 0, ioid)))
ERR(ret);
} /* next use_darray */

Expand Down
15 changes: 8 additions & 7 deletions tests/cunit/test_async_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@ int main(int argc, char **argv)
#define NUM_COMP_PROCS 1
int my_rank; /* Zero-based rank of processor. */
int ntasks; /* Number of processors involved in current execution. */
int iosysid[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
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. */
int num_procs[COMPONENT_COUNT] = {1}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS] = {0};
int comp_proc_list[NUM_COMP_PROCS] = {1};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list};
MPI_Comm test_comm;
int ret; /* Return code. */

/* Initialize test. */
if ((ret = pio_test_init2(argc, argv, &my_rank, &ntasks, TARGET_NTASKS, TARGET_NTASKS,
Expand All @@ -52,6 +46,13 @@ int main(int argc, char **argv)
/* Only do something on TARGET_NTASKS tasks. */
if (my_rank < TARGET_NTASKS)
{
int iosysid[COMPONENT_COUNT]; /* The ID for the parallel I/O system. */
int flavor[NUM_FLAVORS]; /* iotypes for the supported netCDF IO flavors. */
int num_procs[COMPONENT_COUNT] = {1}; /* Num procs for IO and computation. */
int io_proc_list[NUM_IO_PROCS] = {0};
int comp_proc_list[NUM_COMP_PROCS] = {1};
int *proc_list[COMPONENT_COUNT] = {comp_proc_list};

/* Figure out iotypes. */
if ((ret = get_iotypes(&num_flavors, flavor)))
ERR(ret);
Expand Down
46 changes: 23 additions & 23 deletions tests/cunit/test_darray_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int main(int argc, char **argv)
* numbers, like in Fortran! */
for (int i = 0; i < MAPLEN; i++)
{
wcompmap[i] = i % 2 ? my_rank * MAPLEN + i + 1 : 0; /* Even values missing. */
wcompmap[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : 0; /* Even values missing. */
rcompmap[i] = my_rank * MAPLEN + i + 1;
}

Expand Down Expand Up @@ -173,18 +173,18 @@ int main(int argc, char **argv)
* values. */
for (int i = 0; i < MAPLEN; i++)
{
byte_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
char_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
short_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
int_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
float_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
double_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
byte_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
char_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
short_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
int_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
float_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
double_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
#ifdef _NETCDF4
ubyte_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
ushort_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
uint_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
int64_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
uint64_data[i] = i % 2 ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
ubyte_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
ushort_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
uint_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
int64_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
uint64_data[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : TEST_VAL_42;
#endif /* _NETCDF4 */
}

Expand All @@ -193,18 +193,18 @@ int main(int argc, char **argv)
* it may be custom or default fill value. */
for (int i = 0; i < MAPLEN; i++)
{
byte_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? byte_default_fill : byte_fill);
char_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? char_default_fill : char_fill);
short_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? short_default_fill : short_fill);
int_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? int_default_fill : int_fill);
float_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? float_default_fill : float_fill);
double_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? double_default_fill : double_fill);
byte_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? byte_default_fill : byte_fill);
char_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? char_default_fill : char_fill);
short_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? short_default_fill : short_fill);
int_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? int_default_fill : int_fill);
float_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? float_default_fill : float_fill);
double_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? double_default_fill : double_fill);
#ifdef _NETCDF4
ubyte_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? ubyte_default_fill : ubyte_fill);
ushort_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? ushort_default_fill : ushort_fill);
uint_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? uint_default_fill : uint_fill);
int64_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? int64_default_fill : int64_fill);
uint64_expected[i] = i % 2 ? my_rank * MAPLEN + i + 1 : (fv ? uint64_default_fill : uint64_fill);
ubyte_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? ubyte_default_fill : ubyte_fill);
ushort_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? ushort_default_fill : ushort_fill);
uint_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? uint_default_fill : uint_fill);
int64_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? int64_default_fill : int64_fill);
uint64_expected[i] = (i % 2) ? my_rank * MAPLEN + i + 1 : (fv ? uint64_default_fill : uint64_fill);
#endif /* _NETCDF4 */
}

Expand Down
Loading

0 comments on commit 5a9c0ef

Please sign in to comment.