Skip to content

Commit

Permalink
Per #1439, add check_mask_names() utility function which errors out i…
Browse files Browse the repository at this point in the history
…f the list of masking region names is non-unique. Update Point-Stat and Grid-Stat to call it. (#1679)
  • Loading branch information
JohnHalleyGotway authored Feb 23, 2021
1 parent 5e3d6d1 commit 6231c1e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions met/src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2170,6 +2170,22 @@ void parse_conf_range_double(Dictionary *dict, double &beg, double &end) {

///////////////////////////////////////////////////////////////////////////////

void check_mask_names(const StringArray &sa) {
StringArray sa_uniq = sa.uniq();

// Check for unique mask names
if(sa_uniq.n() < sa.n()) {
mlog << Error << "\ncheck_mask_names() -> "
<< "found non-unique strings in the list of masking region names ("
<< write_css(sa) << ")!\n\n";
exit(1);
}

return;
}

///////////////////////////////////////////////////////////////////////////////

void check_climo_n_vx(Dictionary *dict, const int n_vx) {
int n;

Expand Down
2 changes: 2 additions & 0 deletions met/src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ extern map<ConcatString,ThreshArray>
extern void parse_conf_range_int(Dictionary *dict, int &beg, int &end);
extern void parse_conf_range_double(Dictionary *dict, double &beg, double &end);

extern void check_mask_names(const StringArray &);

extern void check_climo_n_vx(Dictionary *dict, const int);

extern InterpMthd int_to_interpmthd(int);
Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_log/string_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ return;
////////////////////////////////////////////////////////////////////////


StringArray StringArray::uniq()
StringArray StringArray::uniq() const

{

Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_log/string_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class StringArray {
// return a unique subset of strings
//

StringArray uniq();
StringArray uniq() const;

};

Expand Down
3 changes: 3 additions & 0 deletions met/src/tools/core/grid_stat/grid_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ void GridStatConfInfo::process_masks(const Grid &grid) {
exit(1);
}

// Check for unique mask names
check_mask_names(vx_opt[i].mask_name);

} // end for i

return;
Expand Down
3 changes: 3 additions & 0 deletions met/src/tools/core/point_stat/point_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ void PointStatConfInfo::process_masks(const Grid &grid) {

} // end for j

// Check for unique mask names
check_mask_names(vx_opt[i].mask_name);

} // end for i

return;
Expand Down

0 comments on commit 6231c1e

Please sign in to comment.