Input/Output

Writers

ClimaCore.InputOutput.HDF5WriterType
HDF5Writer(filename::AbstractString[,
           context::ClimaComms.AbstractCommsContext];
           overwrite::Bool = true)
HDF5Writer(::Function,
           filename::AbstractString[,
           context::ClimaComms.AbstractCommsContext];
           overwrite::Bool = true)

An AbstractWriter for writing to HDF5-formatted files using the ClimaCore storage conventions. An internal cache is used to avoid writing duplicate domains, meshes, topologies and spaces to the file. Use HDF5Reader to load the data from the file.

The optional context can be used for writing distributed fields: in this case, the MPICommsContext used passed as an argument: this must match the context used for distributing the Field.

The writer overwrites or appends to existing files depending on the value of the overwrite keyword argument. When overwrite is false, the writer appends to filename if the file already exists, otherwise it creates a new one.

Note

The default Julia HDF5 binaries are not built with MPI support. To use the distributed functionality, you will need to configure HDF5.jl with an MPI-enabled HDF5 library, see the HDF5.jl documentation.

Interface

write!

Usage

InputOutput.HDF5Writer(filename) do writer
    InputOutput.write!(writer, Y, "Y")
end
source
ClimaCore.InputOutput.write!Function
write!(writer::AbstractWriter, obj[, preferredname])

Write the object obj using writer. An optional preferredname can be provided, otherwise defaultname will be used to generate a name. The name of the object will be returned.

A cache of domains, meshes, topologies and spaces is kept: if one of these objects has already been written, then the file will not be modified: instead the name under which the object was first written will be returned. Note that Fields and FieldVectors are not cached, and so can be written multiple times.

source
write!(writer::HDF5Writer, field::Fields.Field, name::AbstractString)

Write the field to the HDF5 in writer and assign it the given name.

source
write!(
    writer::HDF5Writer,
    field::Fields.Field,
    name::AbstractString,
    space::Spaces.AbstractPointSpace,
)

Write a Field, with axes of type PointSpace, to the HDF5 file. The field is written to the fields group in the file, with the name name. The local geometry data of the PointSpace is written to the local_geometry_data group with name name.

source
write!(
    writer::HDF5Writer,
    values::DataLayouts.AbstractData,
    name::AbstractString,
    topology::Topologies.AbstractTopology,
)

Write an object of type AbstractData and name name to the HDF5 file.

The values should belong to a Field whose space's topology is topology(axes(field)).

source
write!(
    writer::HDF5Writer,
    field::Fields.Field,
    name::AbstractString,
    space::Spaces.AbstractSpace,
)

Write an object of type 'Field' and name 'name' to the HDF5 file.

source
write!(writer::HDF5Writer, name => value...)

Write one or more name => value pairs to writer.

source
write!(filename::AbstractString, name => value...)

Write one or more name => value pairs to the HDF5 file filename.

source

Readers

ClimaCore.InputOutput.HDF5ReaderType
HDF5Reader(filename::AbstractString[, context::ClimaComms.AbstractCommsContext])
HDF5Reader(::Function, filename::AbstractString[, context::ClimaComms.AbstractCommsContext])

An AbstractReader for reading from HDF5 files created by HDF5Writer. The reader object contains an internal cache of domains, meshes, topologies and spaces that are read so that duplicate objects are not created.

The optional context can be used for reading distributed fields: in this case, the MPICommsContext used passed as an argument: resulting Fields will be distributed using this context. As with HDF5Writer, this requires a HDF5 library with MPI support.

Interface

Usage

InputOutput.HDF5Reader(filename) do reader
    Y = read_field(reader, "Y")
    Y.c |> propertynames
    Y.f |> propertynames
    ρ_field = read_field(reader, "Y.c.ρ")
    w_field = read_field(reader, "Y.f.w")
end

To explore the contents of the reader, use either

julia> reader |> propertynames

e.g, to explore the components of the space,

julia> reader.space_cache
Dict{Any, Any} with 3 entries:
  "center_extruded_finite_difference_space" => CenterExtrudedFiniteDifferenceSpace:…
  "horizontal_space"                        => SpectralElementSpace2D:…
  "face_extruded_finite_difference_space"   => FaceExtrudedFiniteDifferenceSpace:…

Once "unpacked" as shown above, ClimaCorePlots or ClimaCoreMakie can be used to visualise fields. ClimaCoreTempestRemap supports interpolation onto user-specified grids if necessary.

source
ClimaCore.InputOutput.read_domainFunction
read_domain(reader::AbstractReader, name)

Reads a domain named name from reader. Domain objects are cached in the reader to avoid creating duplicate objects.

source
ClimaCore.InputOutput.read_fieldFunction
read_field(reader, name)

Reads a Field or FieldVector named name from reader. Fields are not cached, so that reading the same field multiple times will create multiple distinct objects.

source