Skip to content

Commit

Permalink
Merge #1464
Browse files Browse the repository at this point in the history
1464: Check if "ClimaCore version" is already attribute r=simonbyrne a=Sbozzolo

HDF5.jl complains if you try writing an attribute that already exists, so that appending to `ClimaCore`-generated files can be a problem 



Co-authored-by: Gabriele Bozzola <[email protected]>
  • Loading branch information
bors[bot] and Sbozzolo authored Oct 5, 2023
2 parents 6e07029 + c3dc7c5 commit 2706600
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/InputOutput/writers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ function HDF5Writer(
else
file = h5open(filename, mode, context.mpicomm)
end
write_attribute(file, "ClimaCore version", string(VERSION))
# Add an attribute to the file if it doesn't already exist
if haskey(attributes(file), "ClimaCore version")
file_version = VersionNumber(attrs(file)["ClimaCore version"])
current_version = VERSION
if file_version != current_version
@warn "$filename was written using a different version of ClimaCore than is currently loaded" file_version current_version
end
else
write_attribute(file, "ClimaCore version", string(VERSION))
end
cache = Dict{String, String}()
return HDF5Writer(file, context, cache)
end
Expand Down

0 comments on commit 2706600

Please sign in to comment.