Skip to content

Commit

Permalink
BCreader and MPI BCReader unit tests: add allow mismatched spaces war…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
valeriabarra committed Feb 13, 2023
1 parent c2c1db7 commit 38ecc7e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions experiments/AMIP/moist_mpi_earth/coupler_driver_modular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ using ClimaCore.Utilities: half, PlusHalf
using ClimaCore: InputOutput, Fields

# Set allow_mismatched_diagonalized_spaces = true() as a temporary workaround to make `swap_space` not allocating
ClimaCore.Fields.allow_mismatched_diagonalized_spaces() = true
Fields.allow_mismatched_diagonalized_spaces() = true


if !(@isdefined parsed_args)
Expand Down Expand Up @@ -441,7 +441,7 @@ end #hide
## run the coupled simulation
solve_coupler!(cs);

ClimaCore.Fields.allow_mismatched_diagonalized_spaces() = false
Fields.allow_mismatched_diagonalized_spaces() = false

#=
## Postprocessing
Expand Down
11 changes: 9 additions & 2 deletions test/bcreader_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#=
#=
Unit tests for ClimaCoupler BCReader module
=#

Expand Down Expand Up @@ -120,6 +120,10 @@ for FT in (Float32, Float64)
# `bcf_info_init` uses TR via a call to `hdwrite_regridfile_rll_to_cgll`
if !Sys.iswindows()
@testset "test update_midmonth_data! for FT=$FT" begin

# Set allow_mismatched_diagonalized_spaces = true() as a temporary workaround to make `swap_space` not allocating (needed by update_midmonth_data! with no_scaling)
Fields.allow_mismatched_diagonalized_spaces() = true

# setup for test
date0 = date1 = DateTime(1979, 01, 01, 01, 00, 00)
date = DateTime(1979, 01, 01, 00, 00, 00)
Expand All @@ -130,7 +134,7 @@ for FT in (Float32, Float64)
Nq = 4
domain = Domains.SphereDomain(radius)
mesh = Meshes.EquiangularCubedSphere(domain, 4)
topology = Topologies.Topology2D(mesh)
topology = Topologies.DistributedTopology2D(comms_ctx, mesh, Topologies.spacefillingcurve(mesh))
quad = Spaces.Quadratures.GLL{Nq}()
boundary_space_t = Spaces.SpectralElementSpace2D(topology, quad)

Expand Down Expand Up @@ -265,6 +269,9 @@ for FT in (Float32, Float64)
@test_throws ErrorException BCReader.update_midmonth_data!(date, bcf_info)

rm(regrid_dir; recursive = true, force = true)

# Clean-up: Reset flag
Fields.allow_mismatched_diagonalized_spaces() = false
end

@testset "test bcf_info_init for FT=$FT" begin
Expand Down
7 changes: 7 additions & 0 deletions test/mpi_tests/bcreader_mpi_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ end

@testset "test update_midmonth_data! with MPI" begin
for FT in (Float32, Float64)

# Set allow_mismatched_diagonalized_spaces = true() as a temporary workaround to make `swap_space` not allocating (needed by update_midmonth_data! with no_scaling)
Fields.allow_mismatched_diagonalized_spaces() = true

# setup for test
date0 = date1 = DateTime(1979, 01, 01, 01, 00, 00)
date = DateTime(1979, 01, 01, 00, 00, 00)
Expand Down Expand Up @@ -240,5 +244,8 @@ end
@test_throws ErrorException BCReader.update_midmonth_data!(date, bcf_info)

rm(regrid_dir; recursive = true, force = true)

# Clean-up: Reset flag
Fields.allow_mismatched_diagonalized_spaces() = false
end
end

0 comments on commit 38ecc7e

Please sign in to comment.