Explicit error message when trying to append to non-existant file

Previous behavior would print "at keyword requires use of 'append yes'" when
trying to append to non-existant file.
This commit is contained in:
Lucas Frérot
2021-01-26 11:21:57 -05:00
parent a77bb30730
commit f3d974e5a3
2 changed files with 8 additions and 6 deletions

View File

@ -17,8 +17,6 @@
#if defined(LMP_HAS_NETCDF)
#include <unistd.h>
#include <cstring>
#include <netcdf.h>
#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;