Skip to content

Commit

Permalink
Merge pull request #1162 from CliMA/ali/smart-mode-a
Browse files Browse the repository at this point in the history
Append to NetCDF file if it already exists
  • Loading branch information
ali-ramadhan committed Nov 10, 2020
2 parents 4b972b5 + 635bd43 commit bd6cb93
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/OutputWriters/netcdf_output_writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@ function NetCDFOutputWriter(model, outputs; filepath, schedule,
compression = 0,
verbose = false)

if isfile(filepath) && mode == "c"
@warn "$filepath already exists but no NetCDFOutputWriter mode was explicitly specified. " *
"Will default to mode = \"a\" to append to existing file. You might experience errors " *
"when writing output if the existing file belonged to a different simulation!"
mode = "a"
end

# We need to convert to a Dict with String keys if user provides a named tuple.
outputs = dictify(outputs)
output_attributes = dictify(output_attributes)
Expand Down

0 comments on commit bd6cb93

Please sign in to comment.