diff --git a/data/config/GridStatConfig_default b/data/config/GridStatConfig_default
index adbb9a214b..4bec5ecf4b 100644
--- a/data/config/GridStatConfig_default
+++ b/data/config/GridStatConfig_default
@@ -264,12 +264,6 @@ nc_pairs_flag = {
////////////////////////////////////////////////////////////////////////////////
-ugrid_dataset = "";
-ugrid_max_distance_km = 30;
-ugrid_coordinates_file = "";
-
-////////////////////////////////////////////////////////////////////////////////
-
grid_weight_flag = NONE;
tmp_dir = "/tmp";
output_prefix = "";
diff --git a/data/config/PointStatConfig_default b/data/config/PointStatConfig_default
index 9a8132dccc..d4b277c6a3 100644
--- a/data/config/PointStatConfig_default
+++ b/data/config/PointStatConfig_default
@@ -299,12 +299,6 @@ output_flag = {
////////////////////////////////////////////////////////////////////////////////
-ugrid_dataset = "";
-ugrid_max_distance_km = 30;
-ugrid_coordinates_file = "";
-
-////////////////////////////////////////////////////////////////////////////////
-
tmp_dir = "/tmp";
output_prefix = "";
version = "V12.0.0";
diff --git a/data/config/UGridConfig_lfric b/data/config/UGridConfig_lfric
index 7c5e164643..8b12f429f5 100644
--- a/data/config/UGridConfig_lfric
+++ b/data/config/UGridConfig_lfric
@@ -2,7 +2,7 @@
//
// Unstructured grid configuration file.
//
-// UGridConfig_lfric at the current working directory overrides the settings here.
+// UGridConfig_lfric at the current working directory replaces the settings here.
// For additional or updated information, please see the MET User's Guide.
//
////////////////////////////////////////////////////////////////////////////////
@@ -12,23 +12,14 @@
//
ugrid_metadata_map = [
{ key = "dim_face"; val = "nMesh2d_face"; },
- { key = "dim_node"; val = "nMesh2d_node"; },
- { key = "dim_edge"; val = "nMesh2d_edge"; },
{ key = "dim_time"; val = "time_counter"; },
- { key = "dim_vert"; val = "nVertLevels"; },
- { key = "cell_id"; val = "indexToCellID"; },
+ { key = "dim_vert"; val = ""; }, // optional
{ key = "lat_face"; val = "Mesh2d_face_y"; },
{ key = "lon_face"; val = "Mesh2d_face_x"; },
- { key = "vert_face"; val = "zCell"; },
- { key = "lat_edge"; val = "Mesh2d_edge_y"; },
- { key = "lon_edge"; val = "Mesh2d_edge_x"; },
- { key = "lat_node"; val = "Mesh2d_node_y"; },
- { key = "lon_node"; val = "Mesh2d_node_x"; },
- { key = "time"; val = "time_centered"; }
+ { key = "vert_face"; val = ""; }, // optional
+ { key = "time"; val = "time_instant"; }
];
-ugrid_max_distance_km = 30;
-
////////////////////////////////////////////////////////////////////////////////
version = "V12.0.0";
diff --git a/data/config/UGridConfig_mpas b/data/config/UGridConfig_mpas
index 803daf6767..70fca86f98 100644
--- a/data/config/UGridConfig_mpas
+++ b/data/config/UGridConfig_mpas
@@ -2,7 +2,7 @@
//
// Unstructured grid configuration file.
//
-// UGridConfig_mpas at the current working directory overrides the settings here.
+// UGridConfig_mpas at the current working directory replaces the settings here.
// For additional or updated information, please see the MET User's Guide.
//
////////////////////////////////////////////////////////////////////////////////
@@ -12,23 +12,14 @@
//
ugrid_metadata_map = [
{ key = "dim_face"; val = "nCells"; },
- { key = "dim_node"; val = "nVertices"; },
- { key = "dim_edge"; val = "nEdges"; },
{ key = "dim_time"; val = "Time"; },
- { key = "dim_vert"; val = "nVertLevels"; },
- { key = "cell_id"; val = "indexToCellID"; },
+ { key = "dim_vert"; val = "nVertLevels"; }, // optional
{ key = "lat_face"; val = "latCell"; },
{ key = "lon_face"; val = "lonCell"; },
- { key = "vert_face"; val = "zCell"; },
- { key = "lat_edge"; val = "latEdge"; },
- { key = "lon_edge"; val = "lonEdge"; },
- { key = "lat_node"; val = "latVertex"; },
- { key = "lon_node"; val = "lonVertex"; },
+ { key = "vert_face"; val = "zCell"; }, // optional
{ key = "time"; val = "xtime"; }
];
-ugrid_max_distance_km = 30;
-
////////////////////////////////////////////////////////////////////////////////
version = "V12.0.0";
diff --git a/internal/test_unit/config/PointStatConfig_ugrid_no_dataset b/internal/test_unit/config/PointStatConfig_ugrid_no_dataset
new file mode 100644
index 0000000000..e70a3af9ee
--- /dev/null
+++ b/internal/test_unit/config/PointStatConfig_ugrid_no_dataset
@@ -0,0 +1,167 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Point-Stat configuration file.
+//
+// For additional information, please see the MET User's Guide.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+model = "WRF";
+
+//
+// Output description to be written
+// May be set separately in each "obs.field" entry
+//
+desc = "NA";
+
+////////////////////////////////////////////////////////////////////////////////
+
+regrid = {
+ to_grid = NONE;
+ method = NEAREST;
+ width = 1;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+obs_window = {
+ beg = ${BEG_DS};
+ end = ${END_DS};
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+mpr_column = [];
+mpr_thresh = [];
+cnt_thresh = [ NA ];
+cnt_logic = UNION;
+wind_thresh = [ NA ];
+wind_logic = UNION;
+eclv_points = 0.05;
+
+
+fcst = {
+ sid_inc = [];
+ sid_exc = [];
+ obs_quality_inc = [];
+ obs_quality_exc = [];
+
+ field = [
+ { name = "theta"; level = "L2"; message_type = "ADPSFC"; }
+ ];
+
+}
+
+obs = {
+ sid_inc = [];
+ sid_exc = [];
+ obs_quality_inc = [];
+ obs_quality_exc = [];
+
+ field = [
+ { name = "TMP"; level = "P1000-500"; message_type = "ADPSFC"; }
+ ];
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+climo_mean = obs;
+climo_mean = {
+ file_name = [];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+mask = {
+ grid = [];
+ poly = [];
+ sid = [];
+ llpnt = [{ name = "ALLLATLON"; lat_thresh = NA; lon_thresh = NA; }];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+ci_alpha = [ 0.05 ];
+
+boot = {
+ interval = PCTILE;
+ rep_prop = 1.0;
+ n_rep = 200;
+ rng = "mt19937";
+ seed = "1";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+interp = {
+ vld_thresh = 1.0;
+
+ type = [
+ {
+ method = NEAREST;
+ width = 1;
+ }
+ ];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+hira = {
+ flag = FALSE;
+ width = [ 2, 3, 4, 5 ];
+ vld_thresh = 1.0;
+ cov_thresh = [ ==0.25 ];
+ shape = SQUARE;
+ prob_cat_thresh = [];
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+output_flag = {
+ fho = BOTH;
+ ctc = BOTH;
+ cts = BOTH;
+ mctc = NONE;
+ mcts = NONE;
+ cnt = BOTH;
+ sl1l2 = NONE;
+ sal1l2 = NONE;
+ vl1l2 = NONE;
+ val1l2 = NONE;
+ vcnt = BOTH;
+ pct = NONE;
+ pstd = NONE;
+ pjc = NONE;
+ prc = NONE;
+ ecnt = NONE;
+ orank = NONE;
+ rps = NONE;
+ eclv = BOTH;
+ mpr = BOTH;
+ seeps = NONE;
+ seeps_mpr = NONE;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Threshold for SEEPS p1 (Probability of being dry)
+
+seeps_p1_thresh = NA;
+
+////////////////////////////////////////////////////////////////////////////////
+// Unstructured Grid (optional ecept ugrid_dataset)
+
+//ugrid_dataset = "mpas";
+ugrid_max_distance_km = 35;
+//ugrid_map_config = "";
+ugrid_coordinates_file = "${MET_TEST_INPUT}/ugrid_data/mpas/static.40962_reduced.nc";
+
+////////////////////////////////////////////////////////////////////////////////
+
+duplicate_flag = NONE;
+rank_corr_flag = TRUE;
+tmp_dir = "/tmp";
+output_prefix = "${OUTPUT_PREFIX}";
+version = "V12.0.0";
+
+////////////////////////////////////////////////////////////////////////////////
diff --git a/internal/test_unit/xml/unit_ugrid.xml b/internal/test_unit/xml/unit_ugrid.xml
index a77d95d886..80211fdc2f 100644
--- a/internal/test_unit/xml/unit_ugrid.xml
+++ b/internal/test_unit/xml/unit_ugrid.xml
@@ -111,4 +111,30 @@
+
+ &MET_BIN;/point_stat
+
+ BEG_DS -1800
+ END_DS 1800
+ OUTPUT_PREFIX UGRID_MPAS_CFG_OUT_TEMP
+ CONFIG_DIR &CONFIG_DIR;
+
+ \
+ &DATA_DIR_UGRID;/mpas/mpasout.2012-04-09_12.00.00_reduced.nc \
+ &OUTPUT_DIR;/pb2nc/gdas1.20120409.t12z.prepbufr.nc \
+ &CONFIG_DIR;/PointStatConfig_ugrid_no_dataset \
+ -ugrid_config ${MET_BASE}/config/UGridConfig_mpas \
+ -outdir &OUTPUT_DIR;/point_stat_ugrid -v 1
+
+
+
+
diff --git a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc
index 25e5f3ef6f..7b9ea3b25f 100644
--- a/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc
+++ b/src/libcode/vx_data2d_ugrid/data2d_ugrid.cc
@@ -322,27 +322,6 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo,
mlog << Error << "\n" << method_name
<< "LevelType_Time for unstructured grid is not enabled\n\n";
exit(1);
- /* Not enabled
- const int debug_level = 7;
- LongArray time_offsets = collect_time_offsets(vinfo);
- if (0 < time_offsets.n_elements()) {
- for (int idx=0; idx= debug_level) {
- for (int idx=0; idx< time_offsets.n_elements(); idx++ ) {
- mlog << Debug(debug_level) << method_name << "time: "
- << unix_to_yyyymmdd_hhmmss(_file->ValidTime[time_offsets[idx]])
- << " from index " << time_offsets[idx] << "\n";
- }
- }
- }
- */
}
else if (level.type() == LevelType_Pres) {
if (nullptr == data_vinfo) {
@@ -353,7 +332,7 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo,
if (vlevel >= lvl_lower && vlevel <= lvl_upper) {
vinfo.set_req_name(vinfo_list[idx]->name.c_str());
if (data_plane(vinfo, plane, vinfo_list[idx])) {
- plane_array.add(plane, lvl_lower, lvl_upper);
+ plane_array.add(plane, vlevel, vlevel);
n_rec++;
}
mlog << Debug(5) << method_name
diff --git a/src/libcode/vx_data2d_ugrid/ugrid_file.cc b/src/libcode/vx_data2d_ugrid/ugrid_file.cc
index f85a6ea0ea..d157f75f0c 100644
--- a/src/libcode/vx_data2d_ugrid/ugrid_file.cc
+++ b/src/libcode/vx_data2d_ugrid/ugrid_file.cc
@@ -940,6 +940,9 @@ void UGridFile::read_netcdf_grid()
}
}
+ // Convert longitude from degrees east to west
+ for (int idx=0; idxNedge = data.Nedge;
-D->Nnode = data.Nnode;
+D->n_edge = data.n_edge;
+D->n_node = data.n_node;
D->max_distance_km = data.max_distance_km;
-D->set_points(data.Nface, data.pointLonLat);
+D->set_points(data.n_face, data.point_lonlat);
us = D;
D = (UnstructuredData *)nullptr;
@@ -1690,11 +1690,11 @@ bool is_eq(const UnstructuredData * us1, const UnstructuredData * us2)
bool status = false;
if (us1 && us2) {
if (us1 == us2) status = true;
- else status = us1->Nface == us2->Nface
- && us1->Nnode == us2->Nnode
- && us1->Nedge == us2->Nedge
- && us1->pointLonLat[0] == us2->pointLonLat[0]
- && (us1->Nface > 0 && us1->pointLonLat[us1->Nface-1] == us2->pointLonLat[us2->Nface-1])
+ else status = us1->n_face == us2->n_face
+ && us1->n_node == us2->n_node
+ && us1->n_edge == us2->n_edge
+ && us1->point_lonlat[0] == us2->point_lonlat[0]
+ && (us1->n_face > 0 && us1->point_lonlat[us1->n_face-1] == us2->point_lonlat[us2->n_face-1])
&& is_eq(us1->lat_checksum, us2->lat_checksum)
&& is_eq(us1->lon_checksum, us2->lon_checksum);
}
diff --git a/src/libcode/vx_grid/unstructured_grid.cc b/src/libcode/vx_grid/unstructured_grid.cc
index 9af740a233..d1a56ff9f0 100644
--- a/src/libcode/vx_grid/unstructured_grid.cc
+++ b/src/libcode/vx_grid/unstructured_grid.cc
@@ -96,14 +96,14 @@ void UnstructuredGrid::set_from_data(const UnstructuredData &data) {
clear();
if (data.name) Name = data.name;
- Nx = data.Nface;
+ Nx = data.n_face;
- Data.Nface = Nx;
- Data.Nedge = data.Nedge;
- Data.Nnode = data.Nnode;
+ Data.n_face = Nx;
+ Data.n_edge = data.n_edge;
+ Data.n_node = data.n_node;
Data.max_distance_km = data.max_distance_km;
- Data.set_points(Nx, data.pointLonLat);
+ Data.set_points(Nx, data.point_lonlat);
}
@@ -120,9 +120,9 @@ void UnstructuredGrid::set_max_distance_km(double max_distance) {
void UnstructuredGrid::latlon_to_xy(double lat, double lon, double &x, double &y) const {
- PointLonLat _pointLonLat(lon, lat);
+ PointLonLat _point_lonlat(lon, lat);
- IndexKDTree::ValueList neighbor = Data.kdtree->closestPoints(_pointLonLat, 1);
+ IndexKDTree::ValueList neighbor = Data.kdtree->closestPoints(_point_lonlat, 1);
size_t index(neighbor[0].payload());
double distance_km(neighbor[0].distance()/1000.);
bool in_distance = Data.is_in_distance(distance_km);
@@ -130,16 +130,12 @@ void UnstructuredGrid::latlon_to_xy(double lat, double lon, double &x, double &y
x = in_distance ? index : -1.0;
y = 0;
- //PointLonLat r_lonlat;
- //if(_distance > 180.0) atlas_geometry.xyz2lonlat(neighbor[0].point(), r_lonlat);
- //else r_lonlat.assign(neighbor[0].point()[0], neighbor[0].point()[1]);
-
if(mlog.verbosity_level() >= UGRID_DEBUG_LEVEL) mlog
<< Debug(UGRID_DEBUG_LEVEL) << "UnstructuredGrid::latlon_to_xy() "
<< "input=(" << lon << ", " << lat << ") ==> (" << x << ", " << y << ") == ("
- << Data.pointLonLat[index].x() << ", " << Data.pointLonLat[index].y()
+ << Data.point_lonlat[index].x() << ", " << Data.point_lonlat[index].y()
<< ") distance= " << distance_km << "km, "
- << _pointLonLat.distance(Data.pointLonLat[index])
+ << _point_lonlat.distance(Data.point_lonlat[index])
<< " degree" << (in_distance ? " " : ", rejected") << "\n";
}
@@ -149,8 +145,8 @@ void UnstructuredGrid::latlon_to_xy(double lat, double lon, double &x, double &y
void UnstructuredGrid::xy_to_latlon(double x, double y, double &lat, double &lon) const {
- lat = Data.pointLonLat[x].y();
- lon = Data.pointLonLat[x].x();
+ lat = Data.point_lonlat[x].y();
+ lon = Data.point_lonlat[x].x();
if(mlog.verbosity_level() >= UGRID_DEBUG_LEVEL) mlog
<< Debug(UGRID_DEBUG_LEVEL) << "UnstructuredGrid::xy_to_latlon() "
@@ -213,7 +209,7 @@ else out << "(nul)\n";
out << '\n';
-out << prefix << "Nface = " << Nx << "\n";
+out << prefix << "n_face = " << Nx << "\n";
//
// done
@@ -234,7 +230,7 @@ ConcatString a;
a << "Projection: UnstructuredGrid" << sep;
-a << "Nface: " << Nx << sep;
+a << "n_face: " << Nx << sep;
//
// done
//
@@ -352,13 +348,13 @@ void UnstructuredData::build_tree() {
atlas::idx_t n = 0;
kdtree = new IndexKDTree(atlas_geometry);
- kdtree->reserve(Nface);
- for (int i=0; ireserve(n_face);
+ for (int i=0; iinsert(pointLL, n++);
- lat_checksum += (i+1) * pointLonLat[i].y();
- lon_checksum += (i+1) * pointLonLat[i].x();
+ lat_checksum += (i+1) * point_lonlat[i].y();
+ lon_checksum += (i+1) * point_lonlat[i].x();
}
kdtree->build();
@@ -368,18 +364,18 @@ void UnstructuredData::build_tree() {
////////////////////////////////////////////////////////////////////////
void UnstructuredData::copy_from(const UnstructuredData &us_data) {
- set_points(us_data.Nface, us_data.pointLonLat);
- Nedge = us_data.Nedge;
- Nnode = us_data.Nnode;
+ set_points(us_data.n_face, us_data.point_lonlat);
+ n_edge = us_data.n_edge;
+ n_node = us_data.n_node;
max_distance_km = us_data.max_distance_km;
}
////////////////////////////////////////////////////////////////////////
void UnstructuredData::copy_from(const UnstructuredData *us_data) {
- set_points(us_data->Nface, us_data->pointLonLat);
- Nedge = us_data->Nedge;
- Nnode = us_data->Nnode;
+ set_points(us_data->n_face, us_data->point_lonlat);
+ n_edge = us_data->n_edge;
+ n_node = us_data->n_node;
max_distance_km = us_data->max_distance_km;
}
@@ -400,15 +396,15 @@ void UnstructuredData::set_points(int count, double *_lon, double *_lat) {
clear_data();
- Nface = count;
- pointLonLat.reserve(count);
+ n_face = count;
+ point_lonlat.reserve(count);
for (int i=0; i= UGRID_DEBUG_LEVEL) mlog
<< Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(int, double *, double *) first ("
- << pointLonLat[0].x() << ", " << pointLonLat[0].y() << ") and last ("
- << pointLonLat[count-1].x() << ", " << pointLonLat[count-1].y() << ") from ("
+ << point_lonlat[0].x() << ", " << point_lonlat[0].y() << ") and last ("
+ << point_lonlat[count-1].x() << ", " << point_lonlat[count-1].y() << ") from ("
<< _lon[0] << ", " << _lat[0] << ") and ("
<< _lon[count-1] << ", " << _lat[count-1] << ")\n";
@@ -422,15 +418,15 @@ void UnstructuredData::set_points(int count, const std::vector &ptL
clear_data();
- Nface = count;
- pointLonLat.reserve(count);
+ n_face = count;
+ point_lonlat.reserve(count);
for (int i=0; i= UGRID_DEBUG_LEVEL) mlog
- << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(std::vector &) first: ("
- << pointLonLat[0].x() << ", " << pointLonLat[0].y() << ") and last ("
- << pointLonLat[count-1].x() << ", " << pointLonLat[count-1].y() << ") from ("
+ << Debug(UGRID_DEBUG_LEVEL) << "UnstructuredData::set_points(int, std::vector &) first: ("
+ << point_lonlat[0].x() << ", " << point_lonlat[0].y() << ") and last ("
+ << point_lonlat[count-1].x() << ", " << point_lonlat[count-1].y() << ") from ("
<< ptLonLat[0].x() << ", " << ptLonLat[0].y() << ") and ("
<< ptLonLat[count-1].x() << ", " << ptLonLat[count-1].y() << ")\n";
diff --git a/src/libcode/vx_grid/unstructured_grid_defs.h b/src/libcode/vx_grid/unstructured_grid_defs.h
index a363bbab6d..68456d0d35 100644
--- a/src/libcode/vx_grid/unstructured_grid_defs.h
+++ b/src/libcode/vx_grid/unstructured_grid_defs.h
@@ -36,14 +36,14 @@ struct UnstructuredData {
const char * name; // not allocated
- int Nface;
- int Nedge;
- int Nnode;
+ int n_face;
+ int n_edge;
+ int n_node;
double max_distance_km; // This should be set after calling set_points()
double lat_checksum;
double lon_checksum;
- std::vector pointLonLat;
+ std::vector point_lonlat;
atlas::util::IndexKDTree *kdtree;
UnstructuredData();
diff --git a/src/libcode/vx_regrid/vx_regrid.cc b/src/libcode/vx_regrid/vx_regrid.cc
index 7abfee78b4..5fcc970601 100644
--- a/src/libcode/vx_regrid/vx_regrid.cc
+++ b/src/libcode/vx_regrid/vx_regrid.cc
@@ -133,7 +133,6 @@ to_data.set_accum (from_data.accum());
//
// copy data
//
-
for (xt=0; xt<(to_grid.nx()); ++xt) {
for (yt=0; yt<(to_grid.ny()); ++yt) {
diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc
index 89ac9c8385..6d8e13864d 100644
--- a/src/tools/core/grid_stat/grid_stat.cc
+++ b/src/tools/core/grid_stat/grid_stat.cc
@@ -192,11 +192,13 @@ static void finish_txt_files();
static void clean_up();
static void usage();
-static void set_config(const StringArray &);
static void set_outdir(const StringArray &);
static void set_compress(const StringArray &);
static bool read_data_plane(VarInfo* info, DataPlane& dp, Met2dDataFile* mtddf,
const ConcatString &filename);
+#ifdef WITH_UGRID
+static void set_ugrid_config(const StringArray &);
+#endif
////////////////////////////////////////////////////////////////////////
@@ -248,6 +250,9 @@ void process_command_line(int argc, char **argv) {
// Add the options function calls
cline.add(set_outdir, "-outdir", 1);
cline.add(set_compress, "-compress", 1);
+#ifdef WITH_UGRID
+ cline.add(set_ugrid_config, "-ugrid_config", 1);
+#endif
// Parse the command line
cline.parse();
@@ -271,7 +276,9 @@ void process_command_line(int argc, char **argv) {
// Read the config files
conf_info.read_config(default_config_file.c_str(), config_file.c_str());
- conf_info.read_configs(config_files);
+#ifdef WITH_UGRID
+ conf_info.read_ugrid_configs(ugrid_config_files, config_file.c_str());
+#endif
// Get the forecast and observation file types from config, if present
ftype = parse_conf_file_type(conf_info.conf.lookup_dictionary(conf_key_fcst));
@@ -3094,6 +3101,9 @@ void usage() {
<< "\tfcst_file\n"
<< "\tobs_file\n"
<< "\tconfig_file\n"
+#ifdef WITH_UGRID
+ << "\t[-ugrid_config config_file]\n"
+#endif
<< "\t[-outdir path]\n"
<< "\t[-log file]\n"
<< "\t[-v level]\n"
@@ -3108,8 +3118,10 @@ void usage() {
<< "\t\t\"config_file\" is a GridStatConfig file containing "
<< "the desired configuration settings (required).\n"
- << "\t\t\"-config config_file\" specifies additional PointStatConfig file containing "
- << "the configuration settings for unstructured grid (optional).\n"
+#ifdef WITH_UGRID
+ << "\t\t\"-ugrid_config ugrid_config_file\" is a UGridConfig file containing "
+ << "the desired configuration settings for unstructured grid (required only for UGrid)\n"
+#endif
<< "\t\t\"-outdir path\" overrides the default output directory "
<< "(" << out_dir << ") (optional).\n"
@@ -3128,10 +3140,12 @@ void usage() {
////////////////////////////////////////////////////////////////////////
-void set_config(const StringArray & a)
+#ifdef WITH_UGRID
+void set_ugrid_config(const StringArray & a)
{
- config_files.add(a[0]);
+ ugrid_config_files.add(a[0]);
}
+#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/tools/core/grid_stat/grid_stat.h b/src/tools/core/grid_stat/grid_stat.h
index b5db513b57..ccd85c82ac 100644
--- a/src/tools/core/grid_stat/grid_stat.h
+++ b/src/tools/core/grid_stat/grid_stat.h
@@ -113,7 +113,7 @@ static ConcatString obs_file;
// Input Config file
static ConcatString config_file;
-static StringArray config_files;
+static StringArray ugrid_config_files;
static GridStatConfInfo conf_info;
// Optional arguments
diff --git a/src/tools/core/grid_stat/grid_stat_conf_info.cc b/src/tools/core/grid_stat/grid_stat_conf_info.cc
index d277783684..db34b15925 100644
--- a/src/tools/core/grid_stat/grid_stat_conf_info.cc
+++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc
@@ -49,6 +49,9 @@ void GridStatConfInfo::init_from_scratch() {
// Initialize pointers
vx_opt = (GridStatVxOpt *) nullptr;
+#ifdef WITH_UGRID
+ ignore_ugrid_dataset = false;
+#endif
clear();
return;
@@ -69,7 +72,7 @@ void GridStatConfInfo::clear() {
version.clear();
#ifdef WITH_UGRID
ugrid_nc.clear();
- ugrid_dataset.clear();
+ if (!ignore_ugrid_dataset) ugrid_dataset.clear();
ugrid_map_config.clear();
ugrid_max_distance_km = bad_data_double;
#endif
@@ -109,18 +112,25 @@ void GridStatConfInfo::read_config(const char *default_file_name,
////////////////////////////////////////////////////////////////////////
-void GridStatConfInfo::read_configs(StringArray user_file_names) {
-
- const char *file_name;
- for (int i=0; i "
- << "The configuration file \"" << user_file_names[i]<< "\" does not exist.\n\n";
+#ifdef WITH_UGRID
+void GridStatConfInfo::read_ugrid_configs(StringArray ugrid_config_names, const char * user_config) {
+
+ ConcatString file_name;
+ for (int i=0; i "
+ << "The configuration file \"" << ugrid_config_names[i]<< "\" does not exist.\n\n";
}
+ if (file_exists(user_config)) conf.read(user_config); /* to avoid overriding by ugrid_config_names */
return;
}
+#endif
////////////////////////////////////////////////////////////////////////
@@ -154,7 +164,7 @@ void GridStatConfInfo::process_config(GrdFileType ftype,
#ifdef WITH_UGRID
// Conf: ugrid_dataset
- ugrid_dataset = parse_conf_ugrid_dataset(&conf);
+ if (!ignore_ugrid_dataset) ugrid_dataset = parse_conf_ugrid_dataset(&conf);
// Conf: ugrid_nc
ugrid_nc = parse_conf_ugrid_coordinates_file(&conf);
diff --git a/src/tools/core/grid_stat/grid_stat_conf_info.h b/src/tools/core/grid_stat/grid_stat_conf_info.h
index 33418fbfbb..ca529a27e1 100644
--- a/src/tools/core/grid_stat/grid_stat_conf_info.h
+++ b/src/tools/core/grid_stat/grid_stat_conf_info.h
@@ -284,6 +284,7 @@ class GridStatConfInfo {
ConcatString output_prefix; // String to customize output file name
ConcatString version; // Config file version
#ifdef WITH_UGRID
+ bool ignore_ugrid_dataset;
ConcatString ugrid_nc; // NetCDF for coordinate variables of unstructured grid
ConcatString ugrid_dataset; // UGRid dataset name (mpas, lfric etc)
ConcatString ugrid_map_config; // User's configuration file which contains ugrid metadata mapping
@@ -299,7 +300,9 @@ class GridStatConfInfo {
void clear();
void read_config (const char *, const char *);
- void read_configs (StringArray user_file_names);
+#ifdef WITH_UGRID
+ void read_ugrid_configs(StringArray ugrid_config_names, const char * user_config);
+#endif
void process_config(GrdFileType, GrdFileType);
void process_flags ();
void process_masks (const Grid &);
diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc
index 38cbc28f40..313db804b8 100644
--- a/src/tools/core/point_stat/point_stat.cc
+++ b/src/tools/core/point_stat/point_stat.cc
@@ -175,12 +175,14 @@ static void finish_txt_files();
static void clean_up();
static void usage();
-static void set_config(const StringArray &);
static void set_point_obs(const StringArray &);
static void set_ncfile(const StringArray &);
static void set_obs_valid_beg_time(const StringArray &);
static void set_obs_valid_end_time(const StringArray &);
static void set_outdir(const StringArray &);
+#ifdef WITH_UGRID
+static void set_ugrid_config(const StringArray &);
+#endif
////////////////////////////////////////////////////////////////////////
@@ -240,7 +242,9 @@ void process_command_line(int argc, char **argv) {
cline.set_usage(usage);
// Add the options function calls
- cline.add(set_config, "-config", 1);
+#ifdef WITH_UGRID
+ cline.add(set_ugrid_config, "-ugrid_config", 1);
+#endif
cline.add(set_point_obs, "-point_obs", 1);
cline.add(set_ncfile, "-ncfile", 1);
cline.add(set_obs_valid_beg_time, "-obs_valid_beg", 1);
@@ -283,7 +287,9 @@ void process_command_line(int argc, char **argv) {
// Read the config files
conf_info.read_config(default_config_file.c_str(), config_file.c_str());
- conf_info.read_configs(config_files);
+#ifdef WITH_UGRID
+ conf_info.read_ugrid_configs(ugrid_config_files, config_file.c_str());
+#endif
// Get the forecast file type from config, if present
ftype = parse_conf_file_type(conf_info.conf.lookup_dictionary(conf_key_fcst));
@@ -2203,7 +2209,9 @@ void usage() {
<< "\tfcst_file\n"
<< "\tobs_file\n"
<< "\tconfig_file\n"
- << "\t[-config config_file]\n"
+#ifdef WITH_UGRID
+ << "\t[-ugrid_config config_file]\n"
+#endif
<< "\t[-point_obs file]\n"
<< "\t[-obs_valid_beg time]\n"
<< "\t[-obs_valid_end time]\n"
@@ -2220,8 +2228,10 @@ void usage() {
<< "\t\t\"config_file\" is a PointStatConfig file containing "
<< "the desired configuration settings (required).\n"
- << "\t\t\"-config config_file\" specifies additional PointStatConfig file containing "
- << "the configuration settings for unstructured grid (optional).\n"
+#ifdef WITH_UGRID
+ << "\t\t\"-ugrid_config ugrid_config_file\" is a UGridConfig file containing "
+ << "the desired configuration settings for unstructured grid (required only for UGrid)\n"
+#endif
<< "\t\t\"-point_obs file\" specifies additional NetCDF point "
<< "observation files to be used (optional).\n"
@@ -2246,10 +2256,12 @@ void usage() {
////////////////////////////////////////////////////////////////////////
-void set_config(const StringArray & a)
+#ifdef WITH_UGRID
+void set_ugrid_config(const StringArray & a)
{
- config_files.add(a[0]);
+ ugrid_config_files.add(a[0]);
}
+#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/tools/core/point_stat/point_stat.h b/src/tools/core/point_stat/point_stat.h
index 7d69a62b62..0804650b0a 100644
--- a/src/tools/core/point_stat/point_stat.h
+++ b/src/tools/core/point_stat/point_stat.h
@@ -108,7 +108,7 @@ static StringArray obs_file;
// Input Config file
static ConcatString config_file;
-static StringArray config_files;
+static StringArray ugrid_config_files;
static PointStatConfInfo conf_info;
// Optional arguments
diff --git a/src/tools/core/point_stat/point_stat_conf_info.cc b/src/tools/core/point_stat/point_stat_conf_info.cc
index ce7a0035f7..e05157d5bc 100644
--- a/src/tools/core/point_stat/point_stat_conf_info.cc
+++ b/src/tools/core/point_stat/point_stat_conf_info.cc
@@ -49,6 +49,9 @@ void PointStatConfInfo::init_from_scratch() {
// Initialize pointers
vx_opt = (PointStatVxOpt *) nullptr;
+#ifdef WITH_UGRID
+ ignore_ugrid_dataset = false;
+#endif
clear();
return;
@@ -73,7 +76,7 @@ void PointStatConfInfo::clear() {
version.clear();
#ifdef WITH_UGRID
ugrid_nc.clear();
- ugrid_dataset.clear();
+ if (!ignore_ugrid_dataset) ugrid_dataset.clear();
ugrid_map_config.clear();
ugrid_max_distance_km = bad_data_double;
#endif
@@ -105,18 +108,25 @@ void PointStatConfInfo::read_config(const char *default_file_name,
////////////////////////////////////////////////////////////////////////
-void PointStatConfInfo::read_configs(StringArray user_file_names) {
-
- const char *file_name;
- for (int i=0; i "
- << "The configuration file \"" << user_file_names[i]<< "\" does not exist.\n\n";
+#ifdef WITH_UGRID
+void PointStatConfInfo::read_ugrid_configs(StringArray ugrid_config_names, const char * user_config) {
+
+ ConcatString file_name;
+ for (int i=0; i "
+ << "The configuration file \"" << ugrid_config_names[i]<< "\" does not exist.\n\n";
}
+ if (file_exists(user_config)) conf.read(user_config); /* to avoid overriding by ugrid_config_names */
return;
}
+#endif
////////////////////////////////////////////////////////////////////////
@@ -143,7 +153,7 @@ void PointStatConfInfo::process_config(GrdFileType ftype) {
#ifdef WITH_UGRID
// Conf: ugrid_dataset
- ugrid_dataset = parse_conf_ugrid_dataset(&conf);
+ if (!ignore_ugrid_dataset) ugrid_dataset = parse_conf_ugrid_dataset(&conf);
// Conf: ugrid_nc
ugrid_nc = parse_conf_ugrid_coordinates_file(&conf);
diff --git a/src/tools/core/point_stat/point_stat_conf_info.h b/src/tools/core/point_stat/point_stat_conf_info.h
index 5e3db2184a..befde20349 100644
--- a/src/tools/core/point_stat/point_stat_conf_info.h
+++ b/src/tools/core/point_stat/point_stat_conf_info.h
@@ -247,6 +247,7 @@ class PointStatConfInfo {
ConcatString output_prefix; // String to customize output file name
ConcatString version; // Config file version
#ifdef WITH_UGRID
+ bool ignore_ugrid_dataset;
ConcatString ugrid_nc; // NetCDF for coordinate variables of unstructured grid
ConcatString ugrid_dataset; // UGRid dataset name (mpas, lfric etc)
ConcatString ugrid_map_config; // User's configuration file which contains ugrid metadata mapping
@@ -261,7 +262,9 @@ class PointStatConfInfo {
void clear();
void read_config(const char *, const char *);
- void read_configs(StringArray user_file_names);
+#ifdef WITH_UGRID
+ void read_ugrid_configs(StringArray ugrid_config_names, const char * user_config);
+#endif
void process_config(GrdFileType);
void process_grib_codes();