Skip to content

Commit b533d4a

Browse files
authored
Merge pull request #2292 from edwardhartnett/ejh_mpi_file_2
ensuring that MPI_File_close() is only called on open MPI file handle
2 parents cf1a0b8 + 9ffc8d6 commit b533d4a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libdispatch/dinfermodel.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ openmagic(struct MagicFile* file)
12541254
else
12551255
#endif
12561256
status = NC_EPARINIT;
1257+
file->fh = MPI_FILE_NULL;
12571258
goto done;
12581259
}
12591260
/* Get its length */
@@ -1390,7 +1391,8 @@ closemagic(struct MagicFile* file)
13901391
#ifdef USE_PARALLEL
13911392
if (file->use_parallel) {
13921393
int retval;
1393-
if((retval = MPI_File_close(&file->fh)) != MPI_SUCCESS)
1394+
if(file->fh != MPI_FILE_NULL
1395+
&& (retval = MPI_File_close(&file->fh)) != MPI_SUCCESS)
13941396
{status = NC_EPARINIT; return status;}
13951397
} else
13961398
#endif

0 commit comments

Comments
 (0)