From 4bb508035dbaa1f09b8f110e2dcc2a228a250bdb Mon Sep 17 00:00:00 2001 From: Aaron Date: Wed, 14 Jul 2021 09:28:52 -0400 Subject: [PATCH] Configure.c will now exit_failure if there are issues with accessing the configuration file for workloads int configuration_load (const char *filepath, MPI_Comm comm, ConfigHandle *handle): If any of the file access functions return a nonsuccess status, then a char* variable named error is set describing the status. If the error variable is assigned a value, the system will EXIT_FAILURE. --- src/modelconfig/configuration.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modelconfig/configuration.c b/src/modelconfig/configuration.c index 831493fc..54712c8a 100644 --- a/src/modelconfig/configuration.c +++ b/src/modelconfig/configuration.c @@ -36,7 +36,8 @@ int configuration_load (const char *filepath, char *error = NULL; int rc = 0; char *tmp_path = NULL; - + int len; + rc = MPI_File_open(comm, (char*)filepath, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); if (rc != MPI_SUCCESS) goto finalize; @@ -54,10 +55,14 @@ int configuration_load (const char *filepath, #else f = fmemopen(txtdata, txtsize, "rb"); #endif - if (!f) { rc = 1; goto finalize; } + if (!f) { + rc = -1; + error = strdup("Could not access data in \'rb\' mode"); + goto finalize; + } *handle = txtfile_openStream(f, &error); - if (error) { rc = 1; goto finalize; } + if (error) { rc = -1; goto finalize; } /* NOTE: posix version overwrites argument :(. */ tmp_path = strdup(filepath); @@ -72,11 +77,17 @@ int configuration_load (const char *filepath, if (f) fclose(f); free(txtdata); free(tmp_path); + + if (rc != MPI_SUCCESS && !error) { + error = (char*) malloc(MPI_MAX_ERROR_STRING); + MPI_Error_string(rc, error, &len); + } + if (error) { fprintf(stderr, "config error: %s\n", error); free(error); + exit(EXIT_FAILURE); } - return rc; }