Skip to content

Commit c8bc6e2

Browse files
committed
test/testcases/flexible2.c add verbose mode to print array sizes
1 parent 26b7e0b commit c8bc6e2

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

test/testcases/flexible2.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ int main(int argc, char** argv)
9090
{
9191
char filename[256];
9292
int i, j, rank, nprocs, err, nerrs=0, req, status, ghost_len=3;
93-
int ncid, cmode, varid0, varid1, dimid[3], *buf_zy;
93+
int ncid, cmode, varid0, varid1, dimid[3], *buf_zy, verbose=0;
9494
int array_of_sizes[2], array_of_subsizes[2], array_of_starts[2];
9595
double *buf_yx;
9696
MPI_Offset start[2], count[2];
@@ -143,6 +143,14 @@ int main(int argc, char** argv)
143143
array_of_starts, MPI_ORDER_C, MPI_INT, &subarray);
144144
MPI_Type_commit(&subarray);
145145

146+
if (verbose && rank == 0) {
147+
printf("ghost_len = %d\n", ghost_len);
148+
printf("local array size = %d x %d\n", array_of_sizes[0], array_of_sizes[1]);
149+
printf("local array subsize = %d x %d\n", array_of_subsizes[0], array_of_subsizes[1]);
150+
printf("local array start = %d x %d\n", array_of_starts[0], array_of_starts[1]);
151+
printf("local array end = %d x %d\n", array_of_starts[0]+array_of_subsizes[0], array_of_starts[1]+array_of_subsizes[1]);
152+
}
153+
146154
int buffer_len = (NZ+2*ghost_len) * (NY+2*ghost_len);
147155
buf_zy = (int*) malloc(sizeof(int) * buffer_len);
148156
for (i=0; i<buffer_len; i++) buf_zy[i] = rank+10;
@@ -234,21 +242,17 @@ int main(int argc, char** argv)
234242
/* check the contents of iget buffer */
235243
for (i=0; i<array_of_sizes[0]; i++) {
236244
for (j=0; j<array_of_sizes[1]; j++) {
245+
double exp;
237246
int index = i*array_of_sizes[1] + j;
238247
if (i < ghost_len || ghost_len+array_of_subsizes[0] <= i ||
239-
j < ghost_len || ghost_len+array_of_subsizes[1] <= j) {
240-
if (buf_yx[index] != -1) {
241-
printf("Unexpected get buffer[%d][%d]=%f\n",
242-
i,j,buf_yx[index]);
243-
nerrs++;
244-
}
245-
}
246-
else {
247-
if (buf_yx[index] != rank+10) {
248-
printf("Unexpected get buffer[%d][%d]=%f\n",
249-
i,j,buf_yx[index]);
250-
nerrs++;
251-
}
248+
j < ghost_len || ghost_len+array_of_subsizes[1] <= j)
249+
exp = -1;
250+
else
251+
exp = rank+10;
252+
if (buf_yx[index] != exp) {
253+
printf("Error at %d: expect buffer[%d][%d]=%.1f but got %.1f\n",
254+
__LINE__,i,j,exp,buf_yx[index]);
255+
nerrs++;
252256
}
253257
}
254258
}

0 commit comments

Comments
 (0)