Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputOutput does not support PointSpaces #2171

Open
imreddyTeja opened this issue Jan 31, 2025 · 0 comments
Open

InputOutput does not support PointSpaces #2171

imreddyTeja opened this issue Jan 31, 2025 · 0 comments
Assignees
Labels

Comments

@imreddyTeja
Copy link
Contributor

imreddyTeja commented Jan 31, 2025

Describe the bug

The write(::HDF5Writer, ::Fields.Field, ::AbstractString) method does not work for Fields with a PointSpace because
the method expects the input field's space to have a grid and topology. Similarly, read_field cannot recreate the space of a Field with a PointSpace

To Reproduce

using Test
import ClimaCore

using ClimaComms
const comms_ctx = ClimaComms.context(ClimaComms.CPUSingleThreaded())

@testset "HDF5 write/read test for 0d PointSpace" begin
    FT = Float32

    # instead of directly constructing a PointSpace, we construct Field with a ColumnSpace,
    # and call the level function to get a Field with a PointSpace
    column_space = ClimaCore.CommonSpaces.ColumnSpace(;
        z_min = FT(0),
        z_max = FT(100),
        z_elem = 10,
        staggering = ClimaCore.Grids.CellCenter(),
    )

    field_1d = ClimaCore.Fields.local_geometry_field(column_space)
    field_0d = ClimaCore.Fields.level(field_1d, 5)

    filename = tempname()

    writer = ClimaCore.InputOutput.HDF5Writer(filename, comms_ctx)
    ClimaCore.InputOutput.write!(writer, field_0d, "field_0d")
    close(writer)

    reader = ClimaCore.InputOutput.HDF5Reader(filename, comms_ctx)
    restart_field_0d = ClimaCore.InputOutput.read_field(reader, "field_0d")
    close(reader)
    @test restart_field_0d == field_0d
end

Related issues / PRs

Needed to close : PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant