Skip to content

Commit

Permalink
test_vard_rec.c: add verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wkliao committed Nov 26, 2024
1 parent a6fe2f1 commit a704cc0
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/testcases/test_vard_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main(int argc, char **argv) {

char filename[256];
int i, j, err, nerrs=0, ncid, varid, dimids[2], unlimit_dimid;
int rank, nprocs, array_of_blocklengths[2], buf[NY][NX];
int rank, nprocs, verbose, array_of_blocklengths[2], buf[NY][NX];
MPI_Offset recsize, len;
MPI_Aint array_of_displacements[2];
MPI_Datatype rec_filetype;
Expand All @@ -54,6 +54,8 @@ int main(int argc, char **argv) {
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

verbose = 0;

if (argc > 2) {
if (!rank) printf("Usage: %s [filename]\n",argv[0]);
MPI_Finalize();
Expand Down Expand Up @@ -94,6 +96,10 @@ int main(int argc, char **argv) {
MPI_INT, &rec_filetype);
MPI_Type_commit(&rec_filetype);

if (verbose)
printf("%d: %s line %d: displacements=%ld blocklengths=%d\n",rank,
__func__,__LINE__, array_of_displacements[0], array_of_blocklengths[0]);

/* write the record variable */
err = ncmpi_put_vard_all(ncid, varid, rec_filetype, buf, NX, MPI_INT);
CHECK_ERR
Expand All @@ -113,6 +119,10 @@ int main(int argc, char **argv) {
MPI_INT, &rec_filetype);
MPI_Type_commit(&rec_filetype);

if (verbose)
printf("%d: %s line %d: displacements=%ld blocklengths=%d\n",rank,
__func__,__LINE__, array_of_displacements[0], array_of_blocklengths[0]);

/* write the record variable */
err = ncmpi_put_vard_all(ncid, varid, rec_filetype, buf[1], NX, MPI_INT);
CHECK_ERR
Expand Down Expand Up @@ -142,6 +152,12 @@ int main(int argc, char **argv) {
MPI_INT, &rec_filetype);
MPI_Type_commit(&rec_filetype);

if (verbose)
printf("%d: %s line %d: displacements=%ld %ld blocklengths=%d %d\n",rank,
__func__,__LINE__,
array_of_displacements[0], array_of_displacements[1],
array_of_blocklengths[0], array_of_blocklengths[1]);

/* reset contents of buf before read */
for (j=0; j<NY; j++) for (i=0; i<NX; i++) buf[j][i] = -1;

Expand Down

0 comments on commit a704cc0

Please sign in to comment.