From eccbb38e94e4dbadd7124b167ef5fcc34265ffd7 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 24 Feb 2022 22:27:15 -0700 Subject: [PATCH 1/6] #1996 simplify the retrun statement (no effect with tf_left at the second return --- met/src/basic/vx_config/threshold.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/met/src/basic/vx_config/threshold.cc b/met/src/basic/vx_config/threshold.cc index 214cecaf94..5fd41723b0 100644 --- a/met/src/basic/vx_config/threshold.cc +++ b/met/src/basic/vx_config/threshold.cc @@ -139,7 +139,7 @@ if ( tf_left ) return ( true ); const bool tf_right = right_child->check(x, cmn, csd); -return ( tf_left || tf_right ); +return ( tf_right ); } From 37aef739982c936410df941e3141daea1ea3dbb8 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 24 Feb 2022 22:28:27 -0700 Subject: [PATCH 2/6] #1996 Add null terminator only if the pointer is not NULL --- met/src/basic/vx_util/ascii_table.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/met/src/basic/vx_util/ascii_table.cc b/met/src/basic/vx_util/ascii_table.cc index fa6845521f..0074c28071 100644 --- a/met/src/basic/vx_util/ascii_table.cc +++ b/met/src/basic/vx_util/ascii_table.cc @@ -1002,9 +1002,10 @@ if ( DoCommaString ) { p = strchr(junk, '.'); - if ( p ) *p = (char) 0; - - ++p; + if ( p ) { + *p = (char) 0; + ++p; + } X = atol(junk); @@ -1014,7 +1015,7 @@ if ( DoCommaString ) { s << j2; - if ( Precision > 0 ) s << '.' << p; + if ( Precision > 0 && p ) s << '.' << p; set_entry(r, c, s.string()); From 543370eae7a5367d739120622c05102e9fb6dac8 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 24 Feb 2022 22:30:50 -0700 Subject: [PATCH 3/6] #1996 Reduced duplicated for loops --- met/src/libcode/vx_shapedata/interest.cc | 33 ++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/met/src/libcode/vx_shapedata/interest.cc b/met/src/libcode/vx_shapedata/interest.cc index e3072a842d..c3557f33f5 100644 --- a/met/src/libcode/vx_shapedata/interest.cc +++ b/met/src/libcode/vx_shapedata/interest.cc @@ -601,23 +601,33 @@ void get_percentiles(DistributionPercentiles &ptile, const int perc, const bool precip_flag) { - int i, x, y, count, n_values; + int i, x, y, n_values; int nx, ny; double *v = (double *) 0; + double *v_tmp = (double *) 0; + const char *method_name = "get_percentiles() -> "; nx = raw.data.nx(); ny = raw.data.ny(); + v_tmp = new double[nx*ny]; + if(!v_tmp) { + mlog << Error << "\n" << method_name << "memory allocation error, v_tmp\n\n"; + exit(1); + } + // // Count values. - // Only check precipitation for values greater than zero. + // Only collect precipitation values greater than zero. // n_values = 0; for(x=0; x 0))) ++n_values; + (!precip_flag || (precip_flag && raw.data(x, y) > 0))) { + v_tmp[n_values++] = (double)(raw.data(x, y)); + } } } @@ -627,25 +637,15 @@ void get_percentiles(DistributionPercentiles &ptile, v = new double [n_values]; if(!v) { - mlog << Error << "\nget_percentiles() -> " - << "memory allocation error\n\n"; + mlog << Error << "\n" << method_name << "memory allocation error\n\n"; exit(1); } // // Fill values // - count = 0; - for(x=0; x 0))) { - - v[count++] = (double) (raw.data(x, y)); - } - } - } + for(x=0; x Date: Thu, 24 Feb 2022 22:31:45 -0700 Subject: [PATCH 4/6] #1996 Removed IsSet which is defined at the base class --- met/src/libcode/vx_tc_util/genesis_info.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/met/src/libcode/vx_tc_util/genesis_info.h b/met/src/libcode/vx_tc_util/genesis_info.h index c203334c3d..36e36b0d18 100644 --- a/met/src/libcode/vx_tc_util/genesis_info.h +++ b/met/src/libcode/vx_tc_util/genesis_info.h @@ -53,8 +53,6 @@ class GenesisInfo : public TrackInfo { void assign(const GenesisInfo &); - bool IsSet; - // Genesis Information int GenesisIndex; unixtime GenesisTime; From c5a80d57992124499471ec8c40b2d8d8cfef509f Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 24 Feb 2022 22:32:24 -0700 Subject: [PATCH 5/6] #1996 Initialize the variable --- met/src/libcode/vx_nc_obs/met_point_data.cc | 1 + met/src/libcode/vx_nc_obs/nc_obs_util.cc | 2 ++ 2 files changed, 3 insertions(+) diff --git a/met/src/libcode/vx_nc_obs/met_point_data.cc b/met/src/libcode/vx_nc_obs/met_point_data.cc index 8eb762b008..d512fd8d91 100644 --- a/met/src/libcode/vx_nc_obs/met_point_data.cc +++ b/met/src/libcode/vx_nc_obs/met_point_data.cc @@ -403,6 +403,7 @@ void MetPointHeader::reset_counters() { strl_len = 0; strll_len = 0; hdr_count = 0; + hdr_type_count = 0; min_vld_time = -1; max_vld_time = -1; diff --git a/met/src/libcode/vx_nc_obs/nc_obs_util.cc b/met/src/libcode/vx_nc_obs/nc_obs_util.cc index 42c14fd747..036122b8a3 100644 --- a/met/src/libcode/vx_nc_obs/nc_obs_util.cc +++ b/met/src/libcode/vx_nc_obs/nc_obs_util.cc @@ -63,6 +63,7 @@ void NcDataBuffer::reset_counters() { hdr_data_offset = 0; pb_hdr_count = 0; pb_hdr_data_offset = 0; + prev_hdr_vld = 0; } /////////////////////////////////////////////////////////////////////////////// @@ -988,6 +989,7 @@ void NetcdfObsVars::reset(bool _use_var_id) { deflate_level = 0; hdr_cnt = 0; // header array length (fixed dimension if hdr_cnt > 0) obs_cnt = 0; // obs. array length (fixed dimension if obs_cnt > 0) + raw_hdr_cnt = 0; //hdr_str_len = 0; // string length for header (message) type header } From 40569fff3f2859277c942a1d5cfc8e85ceaa3691 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 24 Feb 2022 22:32:58 -0700 Subject: [PATCH 6/6] #1996 ci-run-test Initialize the variable, nxy --- met/src/tools/other/gen_ens_prod/gen_ens_prod.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/met/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/met/src/tools/other/gen_ens_prod/gen_ens_prod.cc index 83c4e5d1a4..e0c16fc022 100644 --- a/met/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/met/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -451,6 +451,7 @@ void get_ens_mean_stdev(GenEnsProdVarInfo *ens_info, << "Computing the ensemble mean and standard deviation for " << ens_info->raw_magic_str << ".\n"; + nxy = 0; // Loop over the ensemble inputs for(i_ens=0; i_ens < ens_info->inputs_n(); i_ens++) {