no longer allow default communicator of MPI_COMM_WORLD for open
@@ -2691,62 +2691,47 @@ exit:
* @param nc_file Pointer to an instance of NC.
*
* @return ::NC_NOERR No error.
+ * @return ::NC_EINVAL Invalid inputs.
* @author Ed Hartnett
*/
int
NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
int use_parallel, void *parameters, NC_Dispatch *dispatch, NC *nc_file)
{
- int res;
-#ifdef USE_PARALLEL4
- NC_MPI_INFO mpidfalt = {MPI_COMM_WORLD, MPI_INFO_NULL};
-#endif
-#if defined USE_PARALLEL4
- int inmemory = ((mode & NC_INMEMORY) == NC_INMEMORY);
-#endif
-
- assert(nc_file && path);
+ assert(nc_file && path && dispatch && nc_file &&
+ nc_file->model == NC_FORMATX_NC4);
LOG((1, "%s: path %s mode %d params %x",
__func__, path, mode, parameters));
#ifdef USE_PARALLEL4
- if (!inmemory && use_parallel && parameters == NULL)
- parameters = &mpidfalt;
-#endif /* USE_PARALLEL4 */
-
- /* If this is our first file, initialize HDF5. */
- if (!nc4_hdf5_initialized)
- nc4_hdf5_initialize();
-
- /* Check the mode for validity */
- if((mode & ILLEGAL_OPEN_FLAGS) != 0)
- {res = NC_EINVAL; goto done;}
-
- /* Cannot have both */
- if((mode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
- {res = NC_EINVAL; goto done;}
+ /* User must provide MPI communicator for parallel I/O. */
+ if (use_parallel && !parameters)
+ return NC_EINVAL;
#ifndef USE_PARALLEL_POSIX
-/* If the HDF5 library has been compiled without the MPI-POSIX VFD, alias
- * the NC_MPIPOSIX flag to NC_MPIIO. -QAK
- */
+ /* If the HDF5 library has been compiled without the MPI-POSIX VFD,
+ * alias the NC_MPIPOSIX flag to NC_MPIIO. -QAK */
if (mode & NC_MPIPOSIX)
{
mode &= ~NC_MPIPOSIX;
mode |= NC_MPIIO;
}
#endif /* USE_PARALLEL_POSIX */
+#endif /* USE_PARALLEL4 */
+
+ /* Check the mode for validity */
+ if (mode & ILLEGAL_OPEN_FLAGS)
+ return NC_EINVAL;
- /* This is a hdf5 file. */
- assert(nc_file->model == NC_FORMATX_NC4);
+ /* If this is our first file, initialize HDF5. */
+ if (!nc4_hdf5_initialized)
+ nc4_hdf5_initialize();
- /* Open the file. */
nc_file->int_ncid = nc_file->ext_ncid;
- res = nc4_open_file(path, mode, parameters, nc_file);
-done:
- return res;
+ /* Open the file. */
+ return nc4_open_file(path, mode, parameters, nc_file);
}
/**
