Skip to content

Commit

Permalink
Ensure that MPI_COMM_SPLIT is valid before freeing
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSimpson committed Nov 9, 2015
1 parent 10be4fb commit 9955f8b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/split.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ THE SOFTWARE.
#include "print_macros.h"
#include "mpi.h"

static MPI_Comm MPI_COMM_SPLIT;
static MPI_Comm MPI_COMM_SPLIT = MPI_COMM_NULL;

// Reads in rank line of WRAPRUN_FILE
// space seperated values are parsed to set color, work_dir, and env_vars
Expand Down Expand Up @@ -254,9 +254,11 @@ int MPI_Init_thread(int *argc, char ***argv, int required, int *provided) {
}

int MPI_Finalize() {
const int err = PMPI_Comm_free(&MPI_COMM_SPLIT);
if(err != MPI_SUCCESS)
EXIT_PRINT("Failed to free split communicator: %d !\n", err);
if(MPI_COMM_SPLIT != MPI_COMM_NULL) {
const int err = PMPI_Comm_free(&MPI_COMM_SPLIT);
if(err != MPI_SUCCESS)
EXIT_PRINT("Failed to free split communicator: %d !\n", err);
}

// Allow MPI_Finalize to be called directly
int return_value;
Expand Down

0 comments on commit 9955f8b

Please sign in to comment.