Skip to content

Commit f6eca64

Browse files
author
Scott Wales
committed
Print argument errors only on root node
Fixes #35
1 parent 3b80162 commit f6eca64

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

mppnccombine-fast.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -448,21 +448,23 @@ int main(int argc, char ** argv) {
448448
}
449449

450450
error_t argp_error = argp_parse(&argp, argc, argv, argp_flags, &arg_index, &args);
451-
if (args.output == NULL) {
452-
fprintf(stderr, "ERROR: No output file specified\n");
453-
exit(-1);
454-
}
455-
if (arg_index == argc) {
456-
fprintf(stderr, "ERROR: No input files specified\n");
457-
exit(-1);
458-
}
459-
if (comm_size < 2) {
460-
fprintf(stderr, "ERROR: Please run with at least 2 MPI processes\n");
461-
exit(-1);
462-
}
463-
if (argp_error != 0) {
464-
log_message(LOG_ERROR, "ERROR parsing arguments");
465-
MPI_Abort(MPI_COMM_WORLD, argp_error);
451+
if (comm_rank == 0) {
452+
if (args.output == NULL) {
453+
log_message(LOG_ERROR, "No output file specified");
454+
MPI_Abort(MPI_COMM_WORLD, -1);
455+
}
456+
if (arg_index == argc) {
457+
log_message(LOG_ERROR, "No input files specified");
458+
MPI_Abort(MPI_COMM_WORLD, -1);
459+
}
460+
if (comm_size < 2) {
461+
log_message(LOG_ERROR, "Please run with at least 2 MPI processes");
462+
MPI_Abort(MPI_COMM_WORLD, -1);
463+
}
464+
if (argp_error != 0) {
465+
log_message(LOG_ERROR, "ERROR parsing arguments");
466+
MPI_Abort(MPI_COMM_WORLD, argp_error);
467+
}
466468
}
467469

468470
const char * in_path = argv[arg_index];
@@ -476,7 +478,7 @@ int main(int argc, char ** argv) {
476478
glob_flags |= GLOB_APPEND;
477479
}
478480

479-
if (globs.gl_pathc < 1) {
481+
if (globs.gl_pathc < 1 && comm_rank == 0) {
480482
log_message(LOG_ERROR, "No matching input files found");
481483
MPI_Abort(MPI_COMM_WORLD, -1);
482484
}

0 commit comments

Comments
 (0)