15
15
#include " atlas/meshgenerator.h"
16
16
#include " atlas/parallel/mpi/mpi.h"
17
17
18
+ #include " atlas-orca/grid/OrcaGrid.h"
19
+
18
20
#include " eckit/mpi/Comm.h"
19
21
#include " eckit/config/Configuration.h"
20
22
#include " eckit/exception/Exceptions.h"
@@ -114,6 +116,13 @@ Geometry::Geometry(const eckit::Configuration & config,
114
116
mesh_, atlas::option::halo (halo));
115
117
log_status ();
116
118
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
+
117
126
// Fill extra geometry fields for BUMP / SABER
118
127
// these are area (DJL needed?), vunit, hmask, gmask
119
128
extraFields_ = atlas::FieldSet ();
@@ -138,10 +147,10 @@ Geometry::Geometry(const eckit::Configuration & config,
138
147
for (atlas::idx_t j = 0 ; j < field_view1.shape (0 ); ++j) {
139
148
for (atlas::idx_t k = 0 ; k < field_view1.shape (1 ); ++k) {
140
149
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_);
143
151
// 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
145
154
} else {field_view1 (j, k) = 1 ;}
146
155
}
147
156
}
@@ -158,9 +167,10 @@ Geometry::Geometry(const eckit::Configuration & config,
158
167
for (atlas::idx_t j = 0 ; j < field_view2.shape (0 ); ++j) {
159
168
for (atlas::idx_t k = 0 ; k < field_view2.shape (1 ); ++k) {
160
169
int x, y;
161
- std::tie (x, y) = xypt (j);
170
+ std::tie (x, y) = xypt (j, nx_ );
162
171
// 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
164
174
// 0 mask, 1 ocean
165
175
} else {field_view2 (j, k) = 1 ;}
166
176
}
@@ -384,9 +394,8 @@ void Geometry::set_gmask(atlas::Field & field) const {
384
394
}
385
395
386
396
// 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;
391
400
return std::make_tuple (x, y); }
392
401
} // namespace orcamodel
0 commit comments