@@ -49,29 +49,16 @@ function OceananigansSimulation(area_fraction, start_date, stop_date; output_dir
4949 download_dataset (en4_temperature)
5050 download_dataset (en4_salinity)
5151
52- # Set up ocean grid (1 degree)
53- resolution_points = (360 , 160 , 32 )
54- Nz = last (resolution_points)
52+ # Set up tripolar ocean grid (1 degree)
53+ Nx = 360
54+ Ny = 180
55+ Nz = 40
5556 depth = 4000 # meters
5657 z = OC. ExponentialCoordinate (Nz, - depth, 0 ; scale = 0.85 * depth)
5758
58- # Regular LatLong because we know how to do interpolation there
59-
60- # TODO : When moving to TripolarGrid, note that we need to be careful about
61- # ensuring the coordinate systems align (ie, rotate vectors on the OC grid)
62-
63- underlying_grid = OC. LatitudeLongitudeGrid (
64- arch;
65- size = resolution_points,
66- longitude = (- 180 , 180 ),
67- latitude = (- 80 , 80 ), # NOTE: Don't goo to high up when using LatLongGrid, or the cells will be too small
68- z,
69- halo = (7 , 7 , 7 ),
70- )
71-
59+ underlying_grid = OC. TripolarGrid (arch; size = (Nx, Ny, Nz), halo = (7 , 7 , 4 ), z)
7260 bottom_height =
7361 CO. regrid_bathymetry (underlying_grid; minimum_depth = 30 , interpolation_passes = 20 , major_basins = 1 )
74-
7562 grid = OC. ImmersedBoundaryGrid (underlying_grid, OC. GridFittedBottom (bottom_height); active_cells_map = true )
7663
7764 use_restoring = start_date + Dates. Month (1 ) < stop_date
@@ -95,17 +82,19 @@ function OceananigansSimulation(area_fraction, start_date, stop_date; output_dir
9582 # Set initial condition to EN4 state estimate at start_date
9683 OC. set! (ocean. model, T = en4_temperature[1 ], S = en4_salinity[1 ])
9784
85+ # Construct a remapper from the exchange grid to `Center, Center` fields
9886 long_cc = OC. λnodes (grid, OC. Center (), OC. Center (), OC. Center ())
9987 lat_cc = OC. φnodes (grid, OC. Center (), OC. Center (), OC. Center ())
10088
101- # TODO : Go from 0 to Nx+1, Ny+1 (for halos) (for LatLongGrid)
89+ # Create a 2D matrix containing each lat/long combination as a LatLongPoint
90+ # Note this must be done on CPU since the CC.Remapper module is not GPU-compatible
91+ target_points_cc = Array (CC. Geometry. LatLongPoint .(lat_cc, long_cc))
10292
103- # Construct a remapper from the exchange grid to `Center, Center` fields
104- long_cc = reshape (long_cc, length (long_cc), 1 )
105- lat_cc = reshape (lat_cc, 1 , length (lat_cc))
106- target_points_cc = @. CC. Geometry. LatLongPoint (lat_cc, long_cc)
107- # TODO : We can remove the `nothing` after CC > 0.14.33
108- remapper_cc = CC. Remapping. Remapper (axes (area_fraction), target_points_cc, nothing )
93+ if pkgversion (CC) >= v " 0.14.34"
94+ remapper_cc = CC. Remapping. Remapper (axes (area_fraction), target_points_cc)
95+ else
96+ remapper_cc = CC. Remapping. Remapper (axes (area_fraction), target_points_cc, nothing )
97+ end
10998
11099 # Construct two 2D Center/Center fields to use as scratch space while remapping
111100 scratch_cc1 = OC. Field {OC.Center, OC.Center, Nothing} (grid)
0 commit comments