Skip to content

Commit a6fe2f1

Browse files
committed
break loop when encountering first error
stop checking collectively when error occurs in one of processes break 2nd loop when encountering first error
1 parent 30834bc commit a6fe2f1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

test/testcases/flexible.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ int main(int argc, char **argv) {
135135
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
136136
__FILE__,__LINE__,j,i,j+rank+10,buf[j][i]);
137137
nerrs++;
138+
j = NY;
138139
break;
139140
}
140141

@@ -147,6 +148,7 @@ int main(int argc, char **argv) {
147148
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
148149
__FILE__,__LINE__,j,i,j+rank+10,buf[j][i]);
149150
nerrs++;
151+
j = NY;
150152
break;
151153
}
152154

@@ -169,10 +171,12 @@ int main(int argc, char **argv) {
169171
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
170172
__FILE__,__LINE__,j,i,j+rank+10,schar_buf[j*NX+i]);
171173
nerrs++;
174+
j = NY;
172175
break;
173176
}
174177

175178
for (j=0; j<NY; j++) for (i=0; i<NX; i++) schar_buf[j*NX+i] = -1;
179+
176180
err = ncmpi_get_vara_all(ncid, varid3, start, count, schar_buf+NX, 1, buftype); CHECK_ERR
177181

178182
/* check read contents */
@@ -181,6 +185,7 @@ int main(int argc, char **argv) {
181185
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
182186
__FILE__,__LINE__,j,i,j+rank+10,schar_buf[j*NX+i]);
183187
nerrs++;
188+
j = NY;
184189
break;
185190
}
186191

@@ -259,6 +264,7 @@ int main(int argc, char **argv) {
259264
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
260265
__FILE__,__LINE__,j,i,buf[j][i],getValue);
261266
nerrs++;
267+
j = (int)count[0];
262268
break;
263269
}
264270
}
@@ -272,6 +278,7 @@ int main(int argc, char **argv) {
272278
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
273279
__FILE__,__LINE__,j,i,buf[j][i],getValue);
274280
nerrs++;
281+
j = (int)count[0];
275282
break;
276283
}
277284
}
@@ -288,6 +295,7 @@ int main(int argc, char **argv) {
288295
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
289296
__FILE__,__LINE__,j,i,buf[j][i],getValue);
290297
nerrs++;
298+
j = (int)count[0];
291299
break;
292300
}
293301
}
@@ -304,6 +312,7 @@ int main(int argc, char **argv) {
304312
printf("Error at %s line %d: expect buf[%d][%d]=%d but got %d\n",
305313
__FILE__,__LINE__,j,i,buf[j][i],getValue);
306314
nerrs++;
315+
j = (int)count[0];
307316
break;
308317
}
309318
}

test/testcases/tst_vars_fill.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ test_vars_$1(char *filename)
5555
{
5656
char var_name[32];
5757
int i, j, k, nprocs, rank, err, nerrs=0, ncid, dimid[2], varid[NVARS];
58+
int max_nerrs;
5859
MPI_Offset start[2], count[2], stride[2];
5960
$1 buf[NY][NX];
6061

@@ -123,9 +124,11 @@ test_vars_$1(char *filename)
123124
}
124125
}
125126
}
127+
fn_exit:
128+
MPI_Allreduce(&nerrs, &max_nerrs, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
129+
if (max_nerrs > 0) break;
126130
}
127131

128-
fn_exit:
129132
err = ncmpi_close(ncid); CHECK_ERR
130133
return nerrs;
131134
}

0 commit comments

Comments
 (0)