Skip to content

Commit

Permalink
Check if "ClimaCore version" is already attribute
Browse files Browse the repository at this point in the history
HDF5.jl complains if you try writing an attribute that already exists
  • Loading branch information
Sbozzolo committed Sep 19, 2023
1 parent 72c1063 commit c3dc7c5
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 c3dc7c5

Please sign in to comment.