mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
added new tests to cmake, also additional test development
This commit is contained in:
parent
f86c0fb8f9
commit
6d2d92ddec
@ -86,6 +86,7 @@ IF(TEST_PARALLEL4)
|
|||||||
build_bin_test(tst_parallel4)
|
build_bin_test(tst_parallel4)
|
||||||
build_bin_test(tst_parallel5)
|
build_bin_test(tst_parallel5)
|
||||||
build_bin_test(tst_parallel_zlib)
|
build_bin_test(tst_parallel_zlib)
|
||||||
|
build_bin_test(tst_parallel_zlib2)
|
||||||
build_bin_test(tst_nc4perf)
|
build_bin_test(tst_nc4perf)
|
||||||
build_bin_test(tst_mode)
|
build_bin_test(tst_mode)
|
||||||
build_bin_test(tst_simplerw_coll_r)
|
build_bin_test(tst_simplerw_coll_r)
|
||||||
|
@ -45,3 +45,8 @@ echo
|
|||||||
echo "Parallel I/O test with zlib."
|
echo "Parallel I/O test with zlib."
|
||||||
@MPIEXEC@ -n 1 ./tst_parallel_zlib
|
@MPIEXEC@ -n 1 ./tst_parallel_zlib
|
||||||
@MPIEXEC@ -n 4 ./tst_parallel_zlib
|
@MPIEXEC@ -n 4 ./tst_parallel_zlib
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Parallel I/O more tests with zlib."
|
||||||
|
@MPIEXEC@ -n 1 ./tst_parallel_zlib2
|
||||||
|
@MPIEXEC@ -n 4 ./tst_parallel_zlib2
|
||||||
|
@ -11,7 +11,7 @@ Ed Hartnett, 12/19/2019
|
|||||||
#include "err_macros.h"
|
#include "err_macros.h"
|
||||||
#include <mpi.h>
|
#include <mpi.h>
|
||||||
|
|
||||||
#define FILE "tst_parallel_zlib2.nc"
|
#define FILE_NAME "tst_parallel_zlib2.nc"
|
||||||
#define NDIMS 3
|
#define NDIMS 3
|
||||||
#define DIMSIZE 24
|
#define DIMSIZE 24
|
||||||
#define QTR_DATA (DIMSIZE * DIMSIZE / 4)
|
#define QTR_DATA (DIMSIZE * DIMSIZE / 4)
|
||||||
@ -32,68 +32,65 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
int i, res;
|
int i, res;
|
||||||
int slab_data[DIMSIZE * DIMSIZE / 4]; /* one slab */
|
int slab_data[DIMSIZE * DIMSIZE / 4]; /* one slab */
|
||||||
char file_name[NC_MAX_NAME + 1];
|
|
||||||
|
|
||||||
/* Initialize MPI. */
|
/* Initialize MPI. */
|
||||||
MPI_Init(&argc, &argv);
|
MPI_Init(&argc, &argv);
|
||||||
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
|
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
|
||||||
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
|
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
|
||||||
|
|
||||||
if (mpi_rank == 0)
|
|
||||||
{
|
|
||||||
printf("\n*** Testing parallel writes with zlib some more.\n");
|
|
||||||
printf("*** testing simple write with zlib...");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create phony data. We're going to write a 24x24 array of ints,
|
/* Create phony data. We're going to write a 24x24 array of ints,
|
||||||
in 4 sets of 144. */
|
in 4 sets of 144. */
|
||||||
for (i = 0; i < DIMSIZE * DIMSIZE / 4; i++)
|
for (i = 0; i < DIMSIZE * DIMSIZE / 4; i++)
|
||||||
slab_data[i] = mpi_rank;
|
slab_data[i] = mpi_rank;
|
||||||
|
|
||||||
/* Create a parallel netcdf-4 file. */
|
if (!mpi_rank)
|
||||||
/*nc_set_log_level(3);*/
|
{
|
||||||
/* sprintf(file_name, "%s/%s", TEMP_LARGE, FILE); */
|
printf("\n*** Testing parallel writes with zlib some more.\n");
|
||||||
sprintf(file_name, "%s", FILE);
|
printf("*** testing simple write with zlib...");
|
||||||
if ((res = nc_create_par(file_name, NC_NETCDF4, comm, info, &ncid))) ERR;
|
}
|
||||||
|
{
|
||||||
|
/* Create a parallel netcdf-4 file. */
|
||||||
|
if ((res = nc_create_par(FILE_NAME, NC_NETCDF4, comm, info, &ncid))) ERR;
|
||||||
|
|
||||||
/* Create three dimensions. */
|
/* Create three dimensions. */
|
||||||
if (nc_def_dim(ncid, "d1", DIMSIZE, dimids)) ERR;
|
if (nc_def_dim(ncid, "d1", DIMSIZE, dimids)) ERR;
|
||||||
if (nc_def_dim(ncid, "d2", DIMSIZE, &dimids[1])) ERR;
|
if (nc_def_dim(ncid, "d2", DIMSIZE, &dimids[1])) ERR;
|
||||||
if (nc_def_dim(ncid, "d3", NUM_SLABS, &dimids[2])) ERR;
|
if (nc_def_dim(ncid, "d3", NUM_SLABS, &dimids[2])) ERR;
|
||||||
|
|
||||||
/* Create one var. */
|
/* Create one var. Turn on deflation. */
|
||||||
if ((res = nc_def_var(ncid, "v1", NC_INT, NDIMS, dimids, &v1id))) ERR;
|
if ((res = nc_def_var(ncid, "v1", NC_INT, NDIMS, dimids, &v1id))) ERR;
|
||||||
if ((res = nc_def_var_deflate(ncid, 0, 0, 1, 1))) ERR;
|
if ((res = nc_def_var_deflate(ncid, 0, 0, 1, 1))) ERR;
|
||||||
|
|
||||||
/* Write metadata to file. */
|
/* Write metadata to file. */
|
||||||
if ((res = nc_enddef(ncid))) ERR;
|
if ((res = nc_enddef(ncid))) ERR;
|
||||||
|
|
||||||
/* Set up slab for this process. */
|
/* Set up slab for this process. */
|
||||||
start[0] = mpi_rank * DIMSIZE/mpi_size;
|
start[0] = mpi_rank * DIMSIZE/mpi_size;
|
||||||
start[1] = 0;
|
start[1] = 0;
|
||||||
count[0] = DIMSIZE/mpi_size;
|
count[0] = DIMSIZE/mpi_size;
|
||||||
count[1] = DIMSIZE;
|
count[1] = DIMSIZE;
|
||||||
count[2] = 1;
|
count[2] = 1;
|
||||||
/*printf("mpi_rank=%d start[0]=%d start[1]=%d count[0]=%d count[1]=%d\n",
|
/*printf("mpi_rank=%d start[0]=%d start[1]=%d count[0]=%d count[1]=%d\n",
|
||||||
mpi_rank, start[0], start[1], count[0], count[1]);*/
|
mpi_rank, start[0], start[1], count[0], count[1]);*/
|
||||||
|
|
||||||
if (nc_var_par_access(ncid, v1id, NC_COLLECTIVE)) ERR;
|
if (nc_var_par_access(ncid, v1id, NC_COLLECTIVE)) ERR;
|
||||||
/* if (nc_var_par_access(ncid, v1id, NC_INDEPENDENT)) ERR;*/
|
/* if (nc_var_par_access(ncid, v1id, NC_INDEPENDENT)) ERR;*/
|
||||||
|
|
||||||
/* Write slabs of phoney data. */
|
/* Write slabs of data. */
|
||||||
for (start[2] = 0; start[2] < NUM_SLABS; start[2]++)
|
for (start[2] = 0; start[2] < NUM_SLABS; start[2]++)
|
||||||
if (nc_put_vara_int(ncid, v1id, start, count, slab_data)) ERR;
|
if (nc_put_vara_int(ncid, v1id, start, count, slab_data)) ERR;
|
||||||
|
|
||||||
/* Close the netcdf file. */
|
/* Close the netcdf file. */
|
||||||
if ((res = nc_close(ncid))) ERR;
|
if ((res = nc_close(ncid))) ERR;
|
||||||
|
}
|
||||||
|
if (!mpi_rank)
|
||||||
|
SUMMARIZE_ERR;
|
||||||
|
|
||||||
/* Shut down MPI. */
|
/* Shut down MPI. */
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
|
|
||||||
if (mpi_rank == 0)
|
if (!mpi_rank)
|
||||||
{
|
|
||||||
SUMMARIZE_ERR;
|
|
||||||
FINAL_RESULTS;
|
FINAL_RESULTS;
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user