Skip to content

Commit

Permalink
Do not fail when p.start_date is not available
Browse files Browse the repository at this point in the history
This commits makes having "start_date" in the cache optional. When it is
available, the calendar dates will be saved to the NetCDF file.
Otherwise, only the simulation time will be stored
  • Loading branch information
Sbozzolo committed May 21, 2024
1 parent 0707357 commit 96eb613
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/netcdf_writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ function write_field!(writer::NetCDFWriter, field, diagnostic, u, p, t)
v.attrib["long_name"] = output_long_name(diagnostic)::String
v.attrib["units"] = var.units::String
v.attrib["comments"] = var.comments::String
# FIXME: We are hardcoding p.start_date !
v.attrib["start_date"] = string(p.start_date)::String
if haskey(p, :start_date)
# FIXME: We are hardcoding p.start_date !
v.attrib["start_date"] = string(p.start_date)::String
end
temporal_size = 0
end

Expand All @@ -355,7 +357,9 @@ function write_field!(writer::NetCDFWriter, field, diagnostic, u, p, t)

# FIXME: We are hardcoding p.start_date !
# FIXME: We are rounding t
nc["date"][time_index] = string(p.start_date + Dates.Second(round(t)))
if haskey(p, :start_date)
nc["date"][time_index] = string(p.start_date + Dates.Second(round(t)))
end

# TODO: It would be nice to find a cleaner way to do this
if length(dim_names) == 3
Expand Down

0 comments on commit 96eb613

Please sign in to comment.