Skip to content

Commit c4f788b

Browse files
committed
Make masking out duplicate points for bump more generic.
1 parent 3177845 commit c4f788b

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/orca-jedi/geometry/Geometry.cc

+18-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "atlas/meshgenerator.h"
1616
#include "atlas/parallel/mpi/mpi.h"
1717

18+
#include "atlas-orca/grid/OrcaGrid.h"
19+
1820
#include "eckit/mpi/Comm.h"
1921
#include "eckit/config/Configuration.h"
2022
#include "eckit/exception/Exceptions.h"
@@ -114,6 +116,13 @@ Geometry::Geometry(const eckit::Configuration & config,
114116
mesh_, atlas::option::halo(halo));
115117
log_status();
116118

119+
atlas::OrcaGrid orcaGrid = mesh_.grid();
120+
nx_ = orcaGrid.nx() + orcaGrid.haloWest() + orcaGrid.haloEast();
121+
ny_ = orcaGrid.ny() + orcaGrid.haloNorth();
122+
123+
oops::Log::debug() << "nx_ " << nx_ << " ny_ " << ny_
124+
<< std::endl;
125+
117126
// Fill extra geometry fields for BUMP / SABER
118127
// these are area (DJL needed?), vunit, hmask, gmask
119128
extraFields_ = atlas::FieldSet();
@@ -138,10 +147,10 @@ Geometry::Geometry(const eckit::Configuration & config,
138147
for (atlas::idx_t j = 0; j < field_view1.shape(0); ++j) {
139148
for (atlas::idx_t k = 0; k < field_view1.shape(1); ++k) {
140149
int x, y;
141-
std::tie(x, y) = xypt(j);
142-
// DJL hardwired to orca2 needs generalising
150+
std::tie(x, y) = xypt(j, nx_);
143151
// 0 mask, 1 ocean
144-
if (ghost(j) || x >= 181 || y >= 147 ) {field_view1(j, k) = 0;
152+
// if (ghost(j) || x >= 181 || y >= 147 ) {field_view1(j, k) = 0; // DJL
153+
if (ghost(j) || x >= nx_-1 || y >= ny_-1 ) {field_view1(j, k) = 0; // DJL
145154
} else {field_view1(j, k) = 1;}
146155
}
147156
}
@@ -158,9 +167,10 @@ Geometry::Geometry(const eckit::Configuration & config,
158167
for (atlas::idx_t j = 0; j < field_view2.shape(0); ++j) {
159168
for (atlas::idx_t k = 0; k < field_view2.shape(1); ++k) {
160169
int x, y;
161-
std::tie(x, y) = xypt(j);
170+
std::tie(x, y) = xypt(j, nx_);
162171
// DJL hardwired to orca2 needs generalising
163-
if (ghost(j) || x >= 181 || y >= 147 ) {field_view2(j, k) = 0;
172+
// if (ghost(j) || x >= 181 || y >= 147 ) {field_view2(j, k) = 0; // DJL
173+
if (ghost(j) || x >= nx_-1 || y >= ny_-1 ) {field_view2(j, k) = 0; // DJL
164174
// 0 mask, 1 ocean
165175
} else {field_view2(j, k) = 1;}
166176
}
@@ -384,9 +394,8 @@ void Geometry::set_gmask(atlas::Field & field) const {
384394
}
385395

386396
// Determine x,y location from jpt
387-
// DJL hardwired to orca2 needs generalising
388-
std::tuple<int, int> xypt(int jpt) {
389-
int xwid = 182; int y = jpt / xwid;
390-
int x = jpt - y*xwid;
397+
std::tuple<int, int> xypt(int jpt, int nx) {
398+
int y = jpt / nx;
399+
int x = jpt - y*nx;
391400
return std::make_tuple(x, y); }
392401
} // namespace orcamodel

src/orca-jedi/geometry/Geometry.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ class Geometry : public util::Printable {
8989
atlas::FieldSet nofields_;
9090
std::shared_ptr<eckit::Timer> eckit_timer_;
9191
atlas::FieldSet extraFields_;
92+
int nx_;
93+
int ny_;
9294
};
9395

94-
std::tuple<int, int> xypt(int jpt);
96+
std::tuple<int, int> xypt(int, int);
9597

9698
// -----------------------------------------------------------------------------
9799

src/tests/testoutput/test_3dvar_sic.ref

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ CostFunction::addIncrement: Analysis:
2121

2222

2323

24-
CostJb : Nonlinear Jb = -2.51949e-03
24+
CostJb : Nonlinear Jb = 0.00000e+00
2525
CostJo : Nonlinear Jo(Sea Ice) = 1.00960e+08, nobs = 48, Jo/n = 2.10333e+06, err = 2.00000e+00
2626
CostFunction: Nonlinear J = 1.00960e+08

0 commit comments

Comments
 (0)