summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/H5F.c b/src/H5F.c
index a99c3e7..44e56fb 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -3102,36 +3102,39 @@ H5F_close(H5F_t *f)
H5AC_debug(f);
H5F_istore_stats(f, FALSE);
+ /* Only try to flush the file if it was opened with write access */
+ if(f->intent&H5F_ACC_RDWR) {
#ifdef H5_HAVE_FPHDF5
- /*
- * We only want the captain to perform the flush of the metadata
- * to the file.
- */
- if (!H5FD_is_fphdf5_driver(f->shared->lf) ||
- H5FD_fphdf5_is_captain(f->shared->lf)) {
+ /*
+ * We only want the captain to perform the flush of the metadata
+ * to the file.
+ */
+ if (!H5FD_is_fphdf5_driver(f->shared->lf) ||
+ H5FD_fphdf5_is_captain(f->shared->lf)) {
#endif /* H5_HAVE_FPHDF5 */
- /* Flush and destroy all caches */
- if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
- H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache");
+ /* Flush and destroy all caches */
+ if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
+ H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache");
#ifdef H5_HAVE_FPHDF5
- } else {
- /*
- * If this isn't the captain process, flush but only clear
- * the flags.
- */
- if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
- H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING | H5F_FLUSH_CLEAR_ONLY) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache");
+ } else {
+ /*
+ * If this isn't the captain process, flush but only clear
+ * the flags.
+ */
+ if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
+ H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING | H5F_FLUSH_CLEAR_ONLY) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache");
- }
+ }
- /* Let's all meet up now... */
- if (H5FD_is_fphdf5_driver(f->shared->lf))
- MPI_Barrier(H5FP_SAP_BARRIER_COMM);
+ /* Let's all meet up now... */
+ if (H5FD_is_fphdf5_driver(f->shared->lf))
+ MPI_Barrier(H5FP_SAP_BARRIER_COMM);
#endif /* H5_HAVE_FPHDF5 */
+ } /* end if */
} /* end if */
/*