diff --git a/src/USER-NETCDF/dump_netcdf.cpp b/src/USER-NETCDF/dump_netcdf.cpp index e1a8dfab69..a34c0e0488 100644 --- a/src/USER-NETCDF/dump_netcdf.cpp +++ b/src/USER-NETCDF/dump_netcdf.cpp @@ -17,8 +17,6 @@ #if defined(LMP_HAS_NETCDF) -#include - #include #include #include "dump_netcdf.h" @@ -286,9 +284,12 @@ void DumpNetCDF::openfile() } if (filewriter) { - if (append_flag && !multifile && access(filecurrent, F_OK) != -1) { + if (append_flag && !multifile) { // Fixme! Perform checks if dimensions and variables conform with // data structure standard. + if (not utils::file_is_readable(filecurrent)) + error->all(FLERR, fmt::format("cannot append to a non-existant file {}", + filecurrent)); if (singlefile_opened) return; singlefile_opened = 1; diff --git a/src/USER-NETCDF/dump_netcdf_mpiio.cpp b/src/USER-NETCDF/dump_netcdf_mpiio.cpp index 2067e14c22..7b98f26283 100644 --- a/src/USER-NETCDF/dump_netcdf_mpiio.cpp +++ b/src/USER-NETCDF/dump_netcdf_mpiio.cpp @@ -17,8 +17,6 @@ #if defined(LMP_HAS_PNETCDF) -#include - #include #include #include "dump_netcdf_mpiio.h" @@ -282,9 +280,12 @@ void DumpNetCDFMPIIO::openfile() vector_dim[i] = -1; } - if (append_flag && !multifile && access(filecurrent, F_OK) != -1) { + if (append_flag && !multifile) { // Fixme! Perform checks if dimensions and variables conform with // data structure standard. + if (not utils::file_is_readable(filecurrent)) + error->all(FLERR, fmt::format("cannot append to a non-existant file {}", + filecurrent)); MPI_Offset index[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS]; double d[1];