-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GPU tests, plus tests for bathymetry module (#147)
* add test bathymetry * some tests * test bathymetry * Update test/test_bathymetry.jl Co-authored-by: Gregory L. Wagner <[email protected]> * Update test/test_bathymetry.jl Co-authored-by: Gregory L. Wagner <[email protected]> * adding gpu tests * Update test/test_bathymetry.jl Co-authored-by: Gregory L. Wagner <[email protected]> * more understandable * correct keys * correct the pipeline * add a small change * fixing the tests * test fix * Update test/test_bathymetry.jl Co-authored-by: Gregory L. Wagner <[email protected]> * what is the problem here? * fixed bathymetry tests * comment * retest bathymetry * save fts on the CPU * fix tests * this shouldn't be failing... * using on_architecture * hopefully final fix * why would test simulations not find the cuda driver? --------- Co-authored-by: Gregory L. Wagner <[email protected]>
- Loading branch information
1 parent
b3b44b7
commit ddea939
Showing
9 changed files
with
210 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Oceananigans | ||
using ClimaOcean | ||
using ClimaOcean.Bathymetry: remove_minor_basins! | ||
using Statistics | ||
|
||
@testset "Availability of Bathymetry" begin | ||
@info "Testing Bathymetry utils..." | ||
for arch in test_architectures | ||
grid = LatitudeLongitudeGrid(arch; | ||
size = (100, 100, 10), | ||
longitude = (0, 100), | ||
latitude = (0, 50), | ||
z = (-6000, 0)) | ||
|
||
# Test that remove_minor_basins!(Z, Inf) does nothing | ||
control_bottom_height = regrid_bathymetry(grid) | ||
bottom_height = deepcopy(control_bottom_height) | ||
@test_throws ArgumentError remove_minor_basins!(bottom_height, Inf) | ||
|
||
# A fictitiously large number which should presumably keep all the basins | ||
remove_minor_basins!(bottom_height, 10000000) | ||
@test parent(bottom_height) == parent(control_bottom_height) | ||
|
||
# Test that remove_minor_basins!(Z, 2) remove the correct number of Basins | ||
bottom_height = Field{Center, Center, Nothing}(grid) | ||
control_bottom_height = Field{Center, Center, Nothing}(grid) | ||
|
||
# A two basins bathymetry | ||
bottom(x, y) = - 1000 * Int((x < 10) | (x > 50)) | ||
|
||
set!(bottom_height, bottom) | ||
set!(control_bottom_height, bottom) | ||
|
||
# This should have not changed anything | ||
remove_minor_basins!(bottom_height, 2) | ||
@test parent(bottom_height) == parent(control_bottom_height) | ||
|
||
# This should have removed the left basin | ||
remove_minor_basins!(bottom_height, 1) | ||
|
||
# The remaning bottom cells that are not immersed should be only on the right hand side | ||
# The left half of the domain should be fully immersed i.e. bottom == 0 | ||
@test sum(view(bottom_height, 1:50, :, 1)) == 0 | ||
|
||
# While the right side should be not immersed, with a mean bottom depth | ||
# of -1000 meters | ||
@test mean(view(bottom_height, 51:100, :, 1)) == -1000 | ||
|
||
grid = LatitudeLongitudeGrid(arch; | ||
size = (200, 200, 10), | ||
longitude = (0, 2), | ||
latitude = (-10, 50), | ||
z = (-6000, 0)) | ||
|
||
control_bottom_height = regrid_bathymetry(grid) | ||
interpolated_bottom_height = regrid_bathymetry(grid; interpolation_passes = 100) | ||
|
||
# Testing that multiple passes do not change the solution when refining the grid | ||
@test parent(control_bottom_height) == parent(interpolated_bottom_height) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters