From 8fd7d94bd0226cb73e1f0c7cc93f0854611d1cbc Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 03:22:51 -0600 Subject: [PATCH 01/39] #2521 Move down using statement after include --- src/basic/enum_to_string/code.cc | 6 +++--- src/basic/vx_cal/day_dif.cc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/basic/enum_to_string/code.cc b/src/basic/enum_to_string/code.cc index eb9066929b..d9d7ee84ae 100644 --- a/src/basic/enum_to_string/code.cc +++ b/src/basic/enum_to_string/code.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -29,6 +26,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_cal/day_dif.cc b/src/basic/vx_cal/day_dif.cc index a520f7b744..4f1a237beb 100644 --- a/src/basic/vx_cal/day_dif.cc +++ b/src/basic/vx_cal/day_dif.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// From 93a11c743c0ce3bb0b6bf4b8dbbb802235b5da70 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 03:26:48 -0600 Subject: [PATCH 02/39] #2521 Remove these useless parentheses --- src/basic/vx_cal/time_array.h | 4 ++-- src/basic/vx_config/config_file.h | 4 ++-- src/basic/vx_config/config_funcs.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/basic/vx_cal/time_array.h b/src/basic/vx_cal/time_array.h index e64e5f5f69..c1f4a7d164 100644 --- a/src/basic/vx_cal/time_array.h +++ b/src/basic/vx_cal/time_array.h @@ -92,8 +92,8 @@ class TimeArray { //////////////////////////////////////////////////////////////////////// -inline int TimeArray::n_elements() const { return ( Nelements ); } -inline int TimeArray::n() const { return ( Nelements ); } +inline int TimeArray::n_elements() const { return Nelements; } +inline int TimeArray::n() const { return Nelements; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/config_file.h b/src/basic/vx_config/config_file.h index 310741f5b8..03e0eb47f7 100644 --- a/src/basic/vx_config/config_file.h +++ b/src/basic/vx_config/config_file.h @@ -90,9 +90,9 @@ class MetConfig : public Dictionary { //////////////////////////////////////////////////////////////////////// -inline StringArray MetConfig::filename() const { return ( Filename ); } +inline StringArray MetConfig::filename() const { return Filename; } -inline bool MetConfig::debug() const { return ( Debug ); } +inline bool MetConfig::debug() const { return Debug; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/config_funcs.h b/src/basic/vx_config/config_funcs.h index e28a9dd6ae..0eb86fb67c 100644 --- a/src/basic/vx_config/config_funcs.h +++ b/src/basic/vx_config/config_funcs.h @@ -81,13 +81,13 @@ class UserFunc_1Arg { //////////////////////////////////////////////////////////////////////// -inline ConcatString UserFunc_1Arg::name() const { return ( Name ); } +inline ConcatString UserFunc_1Arg::name() const { return Name; } -inline int UserFunc_1Arg::n_args() const { return ( NArgs ); } +inline int UserFunc_1Arg::n_args() const { return NArgs; } inline bool UserFunc_1Arg::is_set() const { return ( NArgs >= 0 ); }; -inline const IcodeVector * UserFunc_1Arg::program() const { return ( &V ); } +inline const IcodeVector * UserFunc_1Arg::program() const { return &V; } //////////////////////////////////////////////////////////////////////// From ed9a5e69c4f6a5d386ac0855eab333c1d55bd4fd Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 03:27:28 -0600 Subject: [PATCH 03/39] #2521 Move #include statement to the top of the file --- src/basic/vx_cal/vx_cal.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/basic/vx_cal/vx_cal.h b/src/basic/vx_cal/vx_cal.h index 6ee3ee564c..0464836314 100644 --- a/src/basic/vx_cal/vx_cal.h +++ b/src/basic/vx_cal/vx_cal.h @@ -20,6 +20,10 @@ #include "concat_string.h" +typedef long long unixtime; + +#include "time_array.h" + //////////////////////////////////////////////////////////////////////// @@ -36,12 +40,6 @@ //////////////////////////////////////////////////////////////////////// -typedef long long unixtime; - - -//////////////////////////////////////////////////////////////////////// - - static const int mjd_ut0 = 40587; // mjd of Jan 1, 1970 @@ -212,12 +210,6 @@ extern ConcatString unixtime_to_string(const unixtime); //////////////////////////////////////////////////////////////////////// -#include "time_array.h" - - -//////////////////////////////////////////////////////////////////////// - - #endif // __VX_CAL_H__ From 3138e3c606ac07bd8c5c11710a3d851404b2a871 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 03:28:55 -0600 Subject: [PATCH 04/39] #2521 Move #include statement to the top of the file and removed these useless parentheses --- src/basic/enum_to_string/enum_to_string.cc | 17 +- src/basic/enum_to_string/my_enum_scanner.cc | 49 +++--- src/basic/enum_to_string/scope.cc | 15 +- src/basic/vx_cal/date_to_mjd.cc | 12 +- src/basic/vx_cal/day_of_week.cc | 8 +- src/basic/vx_cal/doyhms_to_unix.cc | 58 ++++--- src/basic/vx_cal/is_dst.cc | 29 ++-- src/basic/vx_cal/is_leap_year.cc | 41 ++--- src/basic/vx_cal/mdyhms_to_unix.cc | 13 +- src/basic/vx_cal/time_array.cc | 88 +++++----- src/basic/vx_cal/time_strings.cc | 156 ++++++++++++------ src/basic/vx_cal/unix_string.cc | 10 +- src/basic/vx_config/calculator.cc | 47 +++--- src/basic/vx_config/config_file.cc | 48 +++--- src/basic/vx_config/config_funcs.cc | 17 +- .../vx_config/configobjecttype_to_string.cc | 8 +- src/basic/vx_config/grdfiletype_to_string.cc | 10 +- src/basic/vx_config/icode.cc | 124 ++++++-------- src/basic/vx_config/idstack.cc | 65 +++----- src/basic/vx_config/my_config_scanner.cc | 116 ++++++------- src/basic/vx_config/number_stack.cc | 10 +- src/basic/vx_config/temp_file.cc | 6 +- src/basic/vx_config/threshold.cc | 44 ++--- 23 files changed, 520 insertions(+), 471 deletions(-) diff --git a/src/basic/enum_to_string/enum_to_string.cc b/src/basic/enum_to_string/enum_to_string.cc index bd0e03dc19..30284b209a 100644 --- a/src/basic/enum_to_string/enum_to_string.cc +++ b/src/basic/enum_to_string/enum_to_string.cc @@ -16,8 +16,6 @@ static const int debug = 0; //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include @@ -35,6 +33,9 @@ using namespace std; #include "enum_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -157,7 +158,7 @@ if ( parse_status != 0 ) { } -return ( 0 ); +return 0; } @@ -171,13 +172,13 @@ void parse_command_line(int &argc, char **argv) if ( argc == 1 ) { usage(); exit ( 1 ); } -int j, found; +int found; do { found = 0; - for (j=1; j #include #include @@ -22,6 +19,10 @@ using namespace std; #include "str_wrappers.h" + +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -155,7 +156,7 @@ while ( 1 ) { // // cout << "\n\n" << flush; -return ( t ); +return t; } @@ -266,7 +267,7 @@ if ( is_id() ) { if ( do_id() ) return ( token(ID) ); } -return ( skip ); +return skip; } @@ -330,7 +331,7 @@ if ( k == char_class_digit ) return ( true ); if ( k == char_class_alpha ) return ( true ); -return ( false ); +return false; } @@ -378,9 +379,9 @@ bool is_id() if ( char_class[lexeme[0]] != char_class_alpha ) return ( false ); -int j, k; +int k; -for (j=0; j #include #include @@ -23,6 +20,8 @@ using namespace std; #include "str_wrappers.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// @@ -83,7 +82,7 @@ if ( this == &e ) return ( *this ); assign(e); -return ( *this ); +return *this; } @@ -239,7 +238,7 @@ if ( this == &ss ) return ( *this ); assign(ss); -return ( *this ); +return *this; } @@ -313,7 +312,7 @@ if ( (pos < 0) || (pos >= N) ) { } -return ( s[pos] ); +return s[pos]; } @@ -437,7 +436,7 @@ s << " level = " << (sse.level()) << "\n"; s.flush(); -return ( s ); +return s; } @@ -474,7 +473,7 @@ for (j=0; j #include #include @@ -23,6 +20,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -30,7 +30,9 @@ int date_to_mjd(int month, int day, int year) { -int g, b, answer; +int g; +int b; +int answer; b = (month - 14)/12; @@ -42,7 +44,7 @@ b = month - 2 - 12*b; answer = (1461*(g - 100))/4 + (367*b)/12 - (3*(g/100))/4 + day - 2432076; -return ( answer ); +return answer; } diff --git a/src/basic/vx_cal/day_of_week.cc b/src/basic/vx_cal/day_of_week.cc index d8a5121d9d..a1fa8145ad 100644 --- a/src/basic/vx_cal/day_of_week.cc +++ b/src/basic/vx_cal/day_of_week.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ w = 1 + (w + 2)%7; // 1 = Mon, 2 = Tue, 3 = Wed, 4 = Thu, 5 = Fri, 6 = Sat, 7 = Sun // -return ( w ); +return w; } diff --git a/src/basic/vx_cal/doyhms_to_unix.cc b/src/basic/vx_cal/doyhms_to_unix.cc index 39bc298d10..67993a4f15 100644 --- a/src/basic/vx_cal/doyhms_to_unix.cc +++ b/src/basic/vx_cal/doyhms_to_unix.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,14 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + +//////////////////////////////////////////////////////////////////////// + +constexpr int sec_per_day = 60 * 60 * 24; +constexpr int day_per_year = 365; + //////////////////////////////////////////////////////////////////////// @@ -30,7 +35,9 @@ unixtime doyhms_to_unix(int doy, int year, int hour, int minute, int second) { unixtime answer; -int mjd, month, day; +int mjd; +int month; +int day; mjd = date_to_mjd(1, 0, year) + doy; @@ -40,7 +47,7 @@ mjd_to_date(mjd, month, day, year); answer = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( answer ); +return answer; } @@ -77,7 +84,7 @@ int out_sec; out_sec = hour*3600 + minute*60 + second; -return ( out_sec ); +return out_sec; } @@ -87,13 +94,19 @@ return ( out_sec ); int unix_to_sec_of_day(unixtime u) { -int s, mon, day, yr, hr, min, sec; +int s; +int mon; +int day; +int yr; +int hr; +int min; +int sec; unix_to_mdyhms(u, mon, day, yr, hr, min, sec); s = hms_to_sec(hr, min, sec); -return ( s ); +return s; } @@ -103,13 +116,16 @@ return ( s ); int unix_to_day_of_year(unixtime u) { -int mon, day, yr, hr, min, sec; +int mon; +int day; +int yr; +int hr; +int min; +int sec; unix_to_mdyhms(u, mon, day, yr, hr, min, sec); -int sec_of_year = mdyhms_to_unix(mon, day, 1970, 0, 0, 0); - -int sec_per_day = 60 * 60 * 24; +int sec_of_year = (int)mdyhms_to_unix(mon, day, 1970, 0, 0, 0); return ( sec_of_year / sec_per_day ); @@ -121,14 +137,19 @@ return ( sec_of_year / sec_per_day ); long unix_to_long_yyyymmddhh(unixtime u) { -int mon, day, yr, hr, min, sec; +int mon; +int day; +int yr; +int hr; +int min; +int sec; long yyyymmddhh; unix_to_mdyhms(u, mon, day, yr, hr, min, sec); yyyymmddhh = 1000000 * yr + 10000 * mon + 100 * day + hr; -return ( yyyymmddhh ); +return yyyymmddhh; } @@ -138,8 +159,6 @@ return ( yyyymmddhh ); int sec_of_day_diff(unixtime ut1, unixtime ut2) { -int sec_per_day = 60 * 60 * 24; - int s1 = unix_to_sec_of_day(ut1); int s2 = unix_to_sec_of_day(ut2); @@ -149,7 +168,7 @@ int dt = s2 - s1; if ( dt < -1 * sec_per_day/2 ) dt += sec_per_day; else if ( dt > sec_per_day/2 ) dt -= sec_per_day; -return ( dt ); +return dt; } @@ -160,9 +179,6 @@ return ( dt ); int day_of_year_diff(unixtime ut1, unixtime ut2) { -int sec_per_day = 60 * 60 * 24; -int day_per_year = 365; - int d1 = unix_to_day_of_year(ut1); int d2 = unix_to_day_of_year(ut2); @@ -172,7 +188,7 @@ int dt = d2 - d1; if ( dt < -1 * day_per_year/2.0 ) dt += day_per_year; else if ( dt > day_per_year/2.0 ) dt -= day_per_year; -return ( dt ); +return dt; } diff --git a/src/basic/vx_cal/is_dst.cc b/src/basic/vx_cal/is_dst.cc index d142481bb1..fbe41e58a0 100644 --- a/src/basic/vx_cal/is_dst.cc +++ b/src/basic/vx_cal/is_dst.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -69,8 +69,12 @@ int is_dst(int month, int day, int year, int hour, int minute, int second) { -int mjd0, ly, year_type; -unixtime T, dst_start, dst_stop; +int mjd0; +int ly; +int year_type; +unixtime T; +unixtime dst_start; +unixtime dst_stop; ly = is_leap_year(year); @@ -87,7 +91,7 @@ dst_start = mdyhms_to_unix(dst_info[year_type].month_start, dst_info[year_type].day_start, year, 2, 0, 0); -if ( T < dst_start ) return ( 0 ); +if ( T < dst_start ) return 0; @@ -95,11 +99,11 @@ dst_stop = mdyhms_to_unix(dst_info[year_type].month_stop, dst_info[year_type].day_stop, year, 2, 0, 0); -if ( T > dst_stop ) return ( 0 ); +if ( T > dst_stop ) return 0; -return ( 1 ); +return 1; } @@ -112,13 +116,18 @@ int is_dst(unixtime T) { int a; -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unix_to_mdyhms(T, month, day, year, hour, minute, second); a = is_dst(month, day, year, hour, minute, second); -return ( a ); +return a; } diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index 4dde4de925..1cd567a0ae 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -34,14 +34,14 @@ int is_leap_year(int year) year = abs(year); -if ( year%4 ) return ( 0 ); +if ( year%4 ) return 0; -if ( year%100 ) return ( 1 ); +if ( year%100 ) return 1; -if ( year%400 ) return ( 0 ); +if ( year%400 ) return 0; -return ( 1 ); +return 1; } @@ -92,12 +92,17 @@ void increase_one_month(int &year, int &month) { #define SEC_MONTH (86400*30) #define SEC_YEAR (86400*30*12) -#define DAY_EPSILON 0.00002 +static const double DAY_EPSILON = 0.00002; unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, double time_value, bool no_leap) { + int month; + int day; + int year; + int hour; + int minute; + int second; unixtime ut; - int month, day, year, hour, minute, second; unixtime time_value_ut = (unixtime)time_value; double time_fraction = time_value - time_value_ut; const char *method_name = "add_to_unixtime() -->"; @@ -117,10 +122,10 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, if (sec_per_unit == SEC_YEAR) { year += time_value_ut; time_fraction *= 12; // 12 months/year - month_offset = (unixtime)time_fraction; + month_offset = (int)time_fraction; time_fraction -= month_offset; } - else month_offset = time_value_ut; + else month_offset = (int)time_value_ut; for (int idx=0; idx 0.5) day++; + day += (int)(day_offset + 0.5); } } else { day_offset = time_fraction * 30; time_value_ut = (int)day_offset; - day += time_value_ut; - if (day_offset - time_value_ut > 0.5) day++; + day += (int)(time_value_ut + 0.5); if (day > 30) { day -= 30; increase_one_month(year, month); @@ -169,8 +172,8 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, // Other cases are as floating number if ((1.0 - time_fraction) < TIME_EPSILON) time_value_ut += 1; else if (time_fraction > TIME_EPSILON) use_ut = false; - if (use_ut) ut = (unixtime)(base_unixtime + sec_per_unit * time_value_ut); - else ut = (unixtime)(base_unixtime + sec_per_unit * time_value); + if (use_ut) ut = base_unixtime + sec_per_unit * time_value_ut; + else ut = base_unixtime + (unixtime)(sec_per_unit * time_value); } else { // no_leap year && unit = day unix_to_mdyhms(base_unixtime, month, day, year, hour, minute, second); @@ -190,8 +193,8 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, day = day_offset; if (day == 0) day = 1; ut = mdyhms_to_unix(month, day, year, hour, minute, second); - if (time_fraction > (1-TIME_EPSILON) ) ut += sec_per_unit; - else if (time_fraction > TIME_EPSILON) ut += (time_fraction * sec_per_unit); + if (time_fraction > (1-TIME_EPSILON) ) ut += (unixtime)sec_per_unit; + else if (time_fraction > TIME_EPSILON) ut += (unixtime)(time_fraction * sec_per_unit); } mlog << Debug(5) << method_name << unix_to_yyyymmdd_hhmmss(base_unixtime) diff --git a/src/basic/vx_cal/mdyhms_to_unix.cc b/src/basic/vx_cal/mdyhms_to_unix.cc index 23b9a8b2f6..8d59bba64a 100644 --- a/src/basic/vx_cal/mdyhms_to_unix.cc +++ b/src/basic/vx_cal/mdyhms_to_unix.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -29,7 +29,10 @@ unixtime mdyhms_to_unix(int month, int day, int year, int hour, int minute, int { -unixtime b, g, mjd, answer; +unixtime b; +unixtime g; +unixtime mjd; +unixtime answer; b = (month - 14)/12; @@ -43,7 +46,7 @@ mjd = (1461*(g - 100))/4 + (367*b)/12 - (3*(g/100))/4 + day - 2432076; answer = 86400*(mjd - 40587) + 3600*hour + 60*minute + second; -return ( answer ); +return answer; } diff --git a/src/basic/vx_cal/time_array.cc b/src/basic/vx_cal/time_array.cc index 0cc068d350..c49ad9a7d8 100644 --- a/src/basic/vx_cal/time_array.cc +++ b/src/basic/vx_cal/time_array.cc @@ -11,8 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -82,11 +83,11 @@ TimeArray & TimeArray::operator=(const TimeArray & a) { -if ( this == &a ) return ( * this ); +if ( this == &a ) return *this; assign(a); -return ( * this ); +return *this; } @@ -98,11 +99,11 @@ bool TimeArray::operator==(const TimeArray & a) const { -if ( Nelements != a.Nelements ) return ( false ); +if ( Nelements != a.Nelements ) return false; bool status = true; -for (int j=0; j<(Nelements); ++j) { +for (int j=0; j= Nelements) ) { } -return ( e[n] ); +return e[n]; } @@ -331,15 +326,15 @@ int TimeArray::index(unixtime u) const { -int j, match = -1; +int match = -1; -for (j=0; j u) u = e[j]; } -return(u); +return u; } @@ -490,14 +481,12 @@ ConcatString TimeArray::serialize() const ConcatString s; - if(n_elements() == 0) return(s); - - int j; + if(n_elements() == 0) return s; s << e[0]; - for(j=1; j= Nelements || // Store subset for(int i=beg; i<=end; i++) subset_ta.add(e[i]); -return ( subset_ta ); +return subset_ta; } @@ -602,12 +592,12 @@ const unixtime *a = (const unixtime *) p1; const unixtime *b = (const unixtime *) p2; -if ( (*a) < (*b) ) return ( -1 ); +if ( (*a) < (*b) ) return -1; -if ( (*a) > (*b) ) return ( 1 ); +if ( (*a) > (*b) ) return 1; -return ( 0 ); +return 0; } @@ -627,7 +617,7 @@ for ( int i=0; i #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -31,7 +31,9 @@ void sec_to_hhmmss(int in_sec, ConcatString& str) { -int hour, minute, second; +int hour; +int minute; +int second; if ( in_sec == bad_data_int ) { str = na_str; @@ -64,7 +66,7 @@ ConcatString str; sec_to_hhmmss(in_sec, str); -return ( str ); +return str; } @@ -77,7 +79,9 @@ ConcatString sec_to_hhmmss_colon(int in_sec) { ConcatString s; -int hour, minute, second; +int hour; +int minute; +int second; if ( in_sec == bad_data_int ) { s = na_str; @@ -94,7 +98,7 @@ else { } } -return(s); +return s; } @@ -106,7 +110,10 @@ int hhmmss_to_sec(const char * text) { -int i, hour, minute, second; +int i; +int hour; +int minute; +int second; i = atoi(text); @@ -118,7 +125,7 @@ second = i%100; i = hms_to_sec(hour, minute, second); -return ( i ); +return i; } @@ -130,7 +137,12 @@ void unix_to_yyyymmdd_hhmmss(unixtime u, ConcatString& str) { -int year, month, day, hour, minute, second; +int year; +int month; +int day; +int hour; +int minute; +int second; unix_to_mdyhms(u, month, day, year, hour, minute, second); @@ -148,7 +160,12 @@ void unix_to_yyyymmdd_hhmmss(unixtime u, char * junk, size_t len) { -int year, month, day, hour, minute, second; +int year; +int month; +int day; +int hour; +int minute; +int second; unix_to_mdyhms(u, month, day, year, hour, minute, second); @@ -171,7 +188,7 @@ ConcatString str; unix_to_yyyymmdd_hhmmss(u, str); -return ( str ); +return str; } @@ -183,7 +200,12 @@ unixtime yyyymmdd_hhmmss_to_unix(const char * text) { -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unixtime t; char junk[32]; @@ -215,7 +237,7 @@ second = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -227,7 +249,12 @@ unixtime yyyymmddThhmmss_to_unix(const char * text) { -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unixtime t; char junk[32]; @@ -259,7 +286,7 @@ second = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -271,7 +298,10 @@ unixtime yyyymmdd_hh_to_unix(const char * text) { -int month, day, year, hour; +int month; +int day; +int year; +int hour; unixtime t; char junk[32]; @@ -300,7 +330,7 @@ hour = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, 0, 0); -return ( t ); +return t; } @@ -312,7 +342,9 @@ unixtime yyyymmdd_to_unix(const char * text) { -int month, day, year; +int month; +int day; +int year; unixtime t; char junk[32]; @@ -332,7 +364,7 @@ day = atoi(junk); t = mdyhms_to_unix(month, day, year, 0, 0, 0); -return ( t ); +return t; } @@ -344,7 +376,12 @@ void unix_to_yyyymmddhh(unixtime u, ConcatString& str) { -int year, month, day, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unix_to_mdyhms(u, month, day, year, hour, minute, second); @@ -366,7 +403,7 @@ ConcatString str; unix_to_yyyymmddhh(u, str); -return ( str ); +return str; } @@ -382,7 +419,7 @@ ConcatString str; str << text << "0000"; - return ( yyyymmddhhmmss_to_unix(str.c_str()) ); +return yyyymmddhhmmss_to_unix(str.c_str()); } @@ -397,7 +434,7 @@ ConcatString str; str << text << "00"; - return ( yyyymmddhhmmss_to_unix(str.c_str()) ); +return yyyymmddhhmmss_to_unix(str.c_str()); } @@ -408,7 +445,12 @@ unixtime yyyymmddhhmmss_to_unix(const char * text) { -int month, day, year, hour, minute, second; +int month; +int day; +int year; +int hour; +int minute; +int second; unixtime t; char junk[32]; @@ -439,7 +481,7 @@ second = atoi(junk); t = mdyhms_to_unix(month, day, year, hour, minute, second); -return ( t ); +return t; } @@ -459,11 +501,11 @@ if ( first > last ) { } -int j, n; +int n; n = last - first + 1; -for (j=0; j #include #include @@ -24,6 +21,9 @@ using namespace std; #include "vx_log.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -46,7 +46,7 @@ if ( j != 1 ) { } -return ( t ); +return t; } @@ -62,7 +62,7 @@ ConcatString junk; junk.format("%lld", t); -return ( junk ); +return junk; } diff --git a/src/basic/vx_config/calculator.cc b/src/basic/vx_config/calculator.cc index deda926e4d..d3e10d1566 100644 --- a/src/basic/vx_config/calculator.cc +++ b/src/basic/vx_config/calculator.cc @@ -15,8 +15,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,9 @@ using namespace std; #include "celltype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -83,14 +84,14 @@ Calculator & Calculator::operator=(const Calculator & c) { -if ( this == &c ) return ( * this ); +if ( this == &c ) return *this; NumberStack::operator=(c); dict_stack = c.dict_stack; -return ( * this ); +return *this; } @@ -119,7 +120,8 @@ void Calculator::do_add() { -Number a, b; +Number a; +Number b; Number result; @@ -151,7 +153,8 @@ void Calculator::do_subtract() { -Number a, b; +Number a; +Number b; Number result; @@ -183,7 +186,8 @@ void Calculator::do_multiply() { -Number a, b; +Number a; +Number b; Number result; @@ -215,7 +219,8 @@ void Calculator::do_divide() { -Number a, b; +Number a; +Number b; Number result; @@ -266,7 +271,8 @@ void Calculator::do_power() { -Number a, b; +Number a; +Number b; Number result; @@ -418,10 +424,9 @@ void Calculator::do_builtin(int which, const Number * n) { -int j; const BuiltinInfo & info = binfo[which]; -for (j=0; j<(info.n_args); ++j) push(n[j]); +for (int j=0; j<(info.n_args); ++j) push(n[j]); do_builtin(which); @@ -437,7 +442,8 @@ void Calculator::do_builtin_1_arg(const BuiltinInfo & info) { -Number a, result; +Number a; +Number result; a = pop(); @@ -463,7 +469,8 @@ if ( (info.i1) && (a.is_int) ) { // nope, do a double // -double x, y; +double x; +double y; x = as_double(a); @@ -491,7 +498,8 @@ void Calculator::do_builtin_2_arg(const BuiltinInfo & info) { -Number a, b; +Number a; +Number b; Number result; @@ -520,12 +528,10 @@ if ( (info.i2) && (a.is_int) && (b.is_int) ) { // nope, do a double // -double x, y, z; - -x = as_double(a); -y = as_double(b); +double x = as_double(a); +double y = as_double(b); -z = info.d2(x, y); +double z = info.d2(x, y); set_double(result, z); @@ -549,7 +555,6 @@ void Calculator::do_user_func(const DictionaryEntry * cur_e) { -int j; Number locals [max_user_function_args]; const int n_args = cur_e->n_args(); @@ -559,7 +564,7 @@ const int n_args = cur_e->n_args(); // we just need to pop them off and load them in to the local vars // -for (j=0; j #include #include @@ -30,6 +28,9 @@ using namespace std; #include "config_constants.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -256,7 +257,7 @@ ConcatString MetConfig::get_tmp_dir() else tmp_dir = default_tmp_dir; } - return ( tmp_dir ); + return tmp_dir; } @@ -276,7 +277,7 @@ int MetConfig::nc_compression() if ( !LastLookupStatus ) n = default_nc_compression; } - return ( n ); + return n; } //////////////////////////////////////////////////////////////////////// @@ -289,7 +290,7 @@ int n = lookup_int(conf_key_output_precision, false); if ( !LastLookupStatus ) n = default_precision; -return ( n ); +return n; } @@ -318,7 +319,7 @@ temp_filename = make_temp_file_name(temp_filename.c_str(), 0); recursive_envs(name, temp_filename.c_str()); -bison_input_filename = (const char *) temp_filename.c_str(); +bison_input_filename = temp_filename.c_str(); dict_stack = &DS; @@ -348,13 +349,13 @@ parse_status = configparse(); if ( configin ) { fclose(configin); - configin = (FILE *) 0; + configin = (FILE *) nullptr; } if ( parse_status != 0 ) { - return ( false ); + return false; } @@ -380,9 +381,9 @@ if ( DS.n_elements() != 1 ) { patch_parents(); -bison_input_filename = (const char *) 0; +bison_input_filename = (const char *) nullptr; -dict_stack = (DictionaryStack *) 0; +dict_stack = (DictionaryStack *) nullptr; LineNumber = 1; @@ -394,7 +395,7 @@ set_exit_on_warning(); unlink(temp_filename.c_str()); -return ( true ); +return true; } @@ -424,7 +425,7 @@ ofstream out; ConcatString temp_filename = get_tmp_dir(); temp_filename << "/" << "met_config"; -temp_filename = make_temp_file_name(temp_filename.c_str(), 0); +temp_filename = make_temp_file_name(temp_filename.c_str(), nullptr); out.open(temp_filename.c_str()); @@ -446,7 +447,7 @@ bool status = read(temp_filename.c_str()); remove_temp_file(temp_filename); -return ( status ); +return status; } @@ -458,13 +459,13 @@ const DictionaryEntry * MetConfig::lookup(const char * name) { -const DictionaryEntry * _e = (const DictionaryEntry *) 0; +const DictionaryEntry * _e = (const DictionaryEntry *) nullptr; _e = Dictionary::lookup(name); -LastLookupStatus = (_e != 0); +LastLookupStatus = (_e != nullptr); -return ( _e ); +return _e; } @@ -476,7 +477,7 @@ const DictionaryEntry * MetConfig::lookup(const char * name, const ConfigObjectT { -const DictionaryEntry * _e = (const DictionaryEntry *) 0; +const DictionaryEntry * _e = (const DictionaryEntry *) nullptr; _e = Dictionary::lookup(name); @@ -484,11 +485,11 @@ if ( !_e || (_e->type() != expected_type) ) { LastLookupStatus = false; - _e = 0; + _e = nullptr; } -return ( _e ); +return _e; } @@ -574,7 +575,8 @@ bool replace_env(string & line) { -size_t pos1, pos2; +size_t pos1; +size_t pos2; string out; // @@ -593,7 +595,7 @@ if ( (pos1 = line.find("//")) != string::npos ) { pos1 = line.find("${"); -if ( pos1 == string::npos ) return ( false ); +if ( pos1 == string::npos ) return false; // // replace the environment variable @@ -609,7 +611,7 @@ if ( (pos2 = line.find('}', pos1)) == string::npos ) { } string env; -char * env_value = 0; +char * env_value = nullptr; env = line.substr(pos1 + 2, pos2 - pos1 - 2); @@ -637,7 +639,7 @@ out += line.substr(pos2 + 1); line = out; -return ( true ); +return true; } diff --git a/src/basic/vx_config/config_funcs.cc b/src/basic/vx_config/config_funcs.cc index 2da959d7e7..7419761953 100644 --- a/src/basic/vx_config/config_funcs.cc +++ b/src/basic/vx_config/config_funcs.cc @@ -14,8 +14,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -26,6 +24,9 @@ using namespace std; #include "configobjecttype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -85,11 +86,11 @@ UserFunc_1Arg & UserFunc_1Arg::operator=(const UserFunc_1Arg & f) { -if ( this == &f ) return ( * this ); +if ( this == &f ) return *this; assign(f); -return ( * this ); +return *this; } @@ -198,7 +199,7 @@ hp.run( V, &n); n = hp.pop(); -return ( as_double(n) ); +return as_double(n); } @@ -256,11 +257,11 @@ UserFunc_MultiArg & UserFunc_MultiArg::operator=(const UserFunc_MultiArg & f) { -if ( this == &f ) return ( * this ); +if ( this == &f ) return *this; assign(f); -return ( * this ); +return *this; } @@ -361,7 +362,7 @@ Number UserFunc_MultiArg::operator()(const Number * n) const hp.run( V, n); -return ( hp.pop() ); +return hp.pop(); } diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index 4bf98a16a6..facee7dfda 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "configobjecttype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -63,7 +63,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString (s); } diff --git a/src/basic/vx_config/grdfiletype_to_string.cc b/src/basic/vx_config/grdfiletype_to_string.cc index bdeaa2bf52..8c192183a1 100644 --- a/src/basic/vx_config/grdfiletype_to_string.cc +++ b/src/basic/vx_config/grdfiletype_to_string.cc @@ -24,14 +24,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include "grdfiletype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString (s); } @@ -93,7 +93,7 @@ else if ( strcmp(text, "FileType_Python_Xarray" ) == 0 ) { t = FileType_Python // nope // -return ( false ); +return false; } diff --git a/src/basic/vx_config/icode.cc b/src/basic/vx_config/icode.cc index 6dc7e2e600..bc8d8aadc7 100644 --- a/src/basic/vx_config/icode.cc +++ b/src/basic/vx_config/icode.cc @@ -14,9 +14,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -31,6 +28,9 @@ using namespace std; #include "celltype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -90,13 +90,13 @@ IcodeCell & IcodeCell::operator=(const IcodeCell & icc) { -if ( this == &icc ) return ( * this ); +if ( this == &icc ) return *this; assign(icc); -return ( * this ); +return *this; } @@ -137,9 +137,9 @@ i = 0; d = 0.0; -if ( name ) { delete [] name; name = (char *) 0; } +if ( name ) { delete [] name; name = (char *) nullptr; } -if ( text ) { delete [] text; text = (char *) 0; } +if ( text ) { delete [] text; text = (char *) nullptr; } e = 0; @@ -262,7 +262,7 @@ switch ( type ) { } // switch -return ( x ); +return x; } @@ -287,7 +287,7 @@ switch ( type ) { } // switch -return ( k ); +return k; } @@ -578,13 +578,13 @@ IcodeVector & IcodeVector::operator=(const IcodeVector & i) { -if ( this == &i ) return ( *this ); +if ( this == &i ) return *this; assign(i); -return ( *this ); +return *this; } @@ -621,9 +621,7 @@ extend(i.Ncells); Ncells = i.Ncells; -int j; - -for (j=0; j= Ncells) ) { } -return ( Cell[n] ); +return Cell[n]; } @@ -742,7 +740,7 @@ if ( (n < 0) || (n >= Ncells) ) { } -return ( Cell[n] ); +return Cell[n]; } @@ -867,9 +865,9 @@ bool IcodeVector::is_mark() const { -if ( Ncells != 1 ) return ( false ); +if ( Ncells != 1 ) return false; -return ( Cell[0].is_mark() ); +return Cell[0].is_mark(); } @@ -881,9 +879,9 @@ bool IcodeVector::is_mark(int k) const { -if ( Ncells != 1 ) return ( false ); +if ( Ncells != 1 ) return false; -return ( Cell[0].is_mark(k) ); +return Cell[0].is_mark(k); } @@ -895,9 +893,9 @@ bool IcodeVector::is_numeric() const { -if ( Ncells != 1 ) return ( false ); +if ( Ncells != 1 ) return false; -return ( Cell[0].is_numeric() ); +return Cell[0].is_numeric(); } @@ -953,13 +951,13 @@ CellStack & CellStack::operator=(const CellStack & c) { -if ( this == &c ) return ( *this ); +if ( this == &c ) return *this; assign(c); -return ( *this ); +return *this; } @@ -1040,7 +1038,7 @@ if ( Depth <= 0 ) { } -return ( cell[--Depth] ); +return cell[--Depth]; } @@ -1061,7 +1059,7 @@ if ( Depth <= 0 ) { } -return ( cell[Depth - 1] ); +return cell[Depth - 1]; } @@ -1082,7 +1080,7 @@ if ( Depth <= 0 ) { } -return ( cell[Depth - 1].type ); +return cell[Depth - 1].type; } @@ -1118,12 +1116,11 @@ void CellStack::dump(ostream & out, int indent_depth) const { -int j; Indent prefix(indent_depth); out << prefix << "Depth = " << Depth << '\n'; -for (j=(Depth - 1); j>=0; --j) { +for (int j=(Depth - 1); j>=0; --j) { out << prefix << "Level = " << j << '\n'; @@ -1158,9 +1155,7 @@ ICVStack::ICVStack() { -int j; - -for (j=0; j= Nelements) ) { } -return ( v[k] ); +return v[k]; } diff --git a/src/basic/vx_config/idstack.cc b/src/basic/vx_config/idstack.cc index d57ba978ad..b18b961262 100644 --- a/src/basic/vx_config/idstack.cc +++ b/src/basic/vx_config/idstack.cc @@ -15,9 +15,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -27,6 +24,9 @@ using namespace std; #include "idstack.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -84,11 +84,11 @@ Identifier & Identifier::operator=(const Identifier & i) { -if ( this == &i ) return ( * this ); +if ( this == &i ) return *this; assign(i); -return ( * this ); +return *this; } @@ -220,11 +220,11 @@ IdentifierQueue & IdentifierQueue::operator=(const IdentifierQueue & iq) { -if ( this == &iq ) return ( * this ); +if ( this == &iq ) return *this; assign(iq); -return ( * this ); +return *this; } @@ -252,9 +252,7 @@ void IdentifierQueue::clear() { -int j; - -for (j=0; j Nalloc) extend(a.Nelements); Nelements = a.Nelements; -for (j=0; j n ) return; -int j, k; +int k; Identifier * inew = (Identifier *) 0; @@ -515,7 +505,7 @@ if ( !inew ) { } -for (j=0; j= Nelements) ) { } -return ( i[k] ); +return i[k]; } @@ -572,13 +562,12 @@ void IdentifierArray::dump(ostream & out, int indent_depth) const { -int j; Indent prefix(indent_depth); out << prefix << "Nelements = " << Nelements << "\n"; -for (j=0; j #include #include @@ -36,6 +33,9 @@ using namespace std; #include "config.tab.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -209,7 +209,7 @@ while ( 1 ) { // // cout << "\n\n" << flush; -return ( t ); +return t; } @@ -381,7 +381,7 @@ if ( is_id() ) { t = do_id(); return ( token(t) ); } -return ( skip ); +return skip; } @@ -450,16 +450,16 @@ bool char_ok(int c) const int k = char_class[c]; -if ( k == char_class_digit ) return ( true ); +if ( k == char_class_digit ) return true; -if ( k == char_class_alpha ) return ( true ); +if ( k == char_class_alpha ) return true; -if ( k == char_class_sign ) return ( true ); +if ( k == char_class_sign ) return true; -if ( c == '.' ) return ( true ); +if ( c == '.' ) return true; -return ( false ); +return false; } @@ -473,7 +473,7 @@ bool is_int() bool status = is_int((char *) lexeme, max_id_length); -return ( status ); +return status; } @@ -487,7 +487,7 @@ bool is_float_v2 () bool status = is_float_v2((char *) lexeme, max_id_length); -return ( status ); +return status; } @@ -499,21 +499,21 @@ bool is_id() { -if ( char_class[lexeme[0]] != char_class_alpha ) return ( false ); +if ( char_class[lexeme[0]] != char_class_alpha ) return false; -int j, k; +int k; -for (j=0; jis_number()) && (! is_lhs) ) { set_int(configlval.nval, e->i_value()); - return ( INTEGER ); + return INTEGER; } else { set_double(configlval.nval, e->d_value()); - return ( FLOAT ); + return FLOAT; } @@ -607,7 +607,7 @@ if ( e && (! is_lhs) && (e->type() == UserFunctionType) ) { configlval.entry = e; - return ( USER_FUNCTION ); + return USER_FUNCTION; } @@ -621,7 +621,7 @@ for (j=0; j= max_id_length ) { configtext[pos++] = (char) c; -return ( c ); +return c; } @@ -1103,7 +1103,7 @@ int token(int t) // else cout << "(nul)\n"; // cout.flush(); -return ( t ); +return t; } @@ -1143,7 +1143,7 @@ else { // done // -return ( return_value ); +return return_value; } @@ -1158,7 +1158,7 @@ int do_fort_thresh() const char *method_name = "do_fort_thresh() -> "; m_strncpy(configlval.text, configtext, sizeof(configlval.text), method_name); -return ( FORTRAN_THRESHOLD ); +return FORTRAN_THRESHOLD; } @@ -1238,7 +1238,7 @@ for (j=0; j #include #include @@ -30,6 +27,9 @@ using namespace std; #include "number_stack.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -94,7 +94,7 @@ if ( this == &a ) return ( * this ); assign(a); -return ( * this ); +return *this; } @@ -378,7 +378,7 @@ if ( Nelements <= 0 ) { } -return ( e[Nelements - 1] ); +return e[Nelements - 1]; } diff --git a/src/basic/vx_config/temp_file.cc b/src/basic/vx_config/temp_file.cc index 11d2d4e55f..98683a1c5b 100644 --- a/src/basic/vx_config/temp_file.cc +++ b/src/basic/vx_config/temp_file.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,6 +19,8 @@ using namespace std; #include "file_exists.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// ConcatString make_temp_file_name(const char *prefix, const char *suffix) { @@ -59,7 +59,7 @@ ConcatString make_temp_file_name(const char *prefix, const char *suffix) { } while(file_exists(s.c_str())); - return(s); + return s; } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/threshold.cc b/src/basic/vx_config/threshold.cc index 5194d2cfbe..da057355e3 100644 --- a/src/basic/vx_config/threshold.cc +++ b/src/basic/vx_config/threshold.cc @@ -8,7 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -27,6 +26,9 @@ using namespace std; #include "is_bad_data.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -121,7 +123,7 @@ bool Or_Node::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } @@ -135,11 +137,11 @@ bool Or_Node::check(double x, double cmn, double csd) const const bool tf_left = left_child->check(x, cmn, csd); -if ( tf_left ) return ( true ); +if ( tf_left ) return true; const bool tf_right = right_child->check(x, cmn, csd); -return ( tf_right ); +return tf_right; } @@ -158,7 +160,7 @@ if ( right_child ) n->right_child = right_child->copy(); n->threshnode_assign(this); -return ( n ); +return n; } @@ -189,7 +191,7 @@ if ( !is_bad_data(prob_left) && !is_bad_data(prob_right) ) { } -return ( prob ); +return prob; } @@ -356,7 +358,7 @@ bool And_Node::check(double x, double cmn, double csd) const const bool tf_left = left_child->check(x, cmn, csd); -if ( ! tf_left ) return ( false ); +if ( ! tf_left ) return false; const bool tf_right = right_child->check(x, cmn, csd); @@ -379,7 +381,7 @@ if ( right_child ) n->right_child = right_child->copy(); n->threshnode_assign(this); -return ( n ); +return n; } @@ -428,7 +430,7 @@ if ( !is_bad_data(prob_left) && !is_bad_data(prob_right) ) { } } -return ( prob ); +return prob; } @@ -580,7 +582,7 @@ bool Not_Node::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } @@ -612,7 +614,7 @@ if ( child ) n->child = child->copy(); n->threshnode_assign(this); -return ( n ); +return n; } @@ -629,7 +631,7 @@ double prob_child = child->climo_prob(); if ( !is_bad_data(prob_child) ) prob = 1.0 - prob_child; -return ( prob ); +return prob; } @@ -650,7 +652,7 @@ if ( !child ) { } -return ( child->need_perc() ); +return child->need_perc(); } @@ -782,7 +784,7 @@ bool Simple_Node::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } @@ -860,7 +862,7 @@ switch ( op ) { } // switch -return ( tf ); +return tf; } @@ -884,7 +886,7 @@ n->Ptype = Ptype; n->threshnode_assign(this); -return ( n ); +return n; } @@ -1258,7 +1260,7 @@ if ( Ptype == perc_thresh_climo_dist ) { } // switch } -return ( prob ); +return prob; } @@ -1373,7 +1375,7 @@ if ( this == &c ) return ( * this ); assign(c); -return ( * this ); +return *this; } @@ -1715,7 +1717,7 @@ ConcatString t; if ( node ) t = node->s; else t = na_str; -return(t); +return t; } @@ -1736,7 +1738,7 @@ ConcatString t; if ( node ) t = node->abbr_s; else t = na_str; -return(t); +return t; } @@ -1798,7 +1800,7 @@ bool SingleThresh::check(double x) const { -return ( check(x, bad_data_double, bad_data_double) ); +return check(x, bad_data_double, bad_data_double); } From 54f2abbf64f40545f6071a556c791dc9528e2943 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 03:29:36 -0600 Subject: [PATCH 05/39] #2521 Move #include statement to the top of the file and removed these useless parentheses. used nullptr --- src/basic/vx_config/builtin.cc | 122 ++++++----- src/basic/vx_config/celltype_to_string.cc | 56 ++--- src/basic/vx_config/config_util.cc | 250 +++++++++++----------- src/basic/vx_config/dictionary.cc | 233 ++++++++++---------- 4 files changed, 321 insertions(+), 340 deletions(-) diff --git a/src/basic/vx_config/builtin.cc b/src/basic/vx_config/builtin.cc index 37a0a26ed5..2d4c76446e 100644 --- a/src/basic/vx_config/builtin.cc +++ b/src/basic/vx_config/builtin.cc @@ -16,9 +16,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "builtin.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -75,54 +75,54 @@ static double my_C_to_F (double); const BuiltinInfo binfo[] = { - { "sin", 1, builtin_sin, 0, 0, sin, 0 }, - { "cos", 1, builtin_cos, 0, 0, cos, 0 }, - { "tan", 1, builtin_tan, 0, 0, tan, 0 }, + { "sin", 1, builtin_sin, nullptr, nullptr, sin, nullptr }, + { "cos", 1, builtin_cos, nullptr, nullptr, cos, nullptr }, + { "tan", 1, builtin_tan, nullptr, nullptr, tan, nullptr }, - { "sind", 1, builtin_sind, 0, 0, sin_deg, 0 }, - { "cosd", 1, builtin_cosd, 0, 0, cos_deg, 0 }, - { "tand", 1, builtin_tand, 0, 0, tan_deg, 0 }, + { "sind", 1, builtin_sind, nullptr, nullptr, sin_deg, nullptr }, + { "cosd", 1, builtin_cosd, nullptr, nullptr, cos_deg, nullptr }, + { "tand", 1, builtin_tand, nullptr, nullptr, tan_deg, nullptr }, - { "asin", 1, builtin_asin, 0, 0, asin, 0 }, - { "acos", 1, builtin_acos, 0, 0, acos, 0 }, - { "atan", 1, builtin_atan, 0, 0, atan, 0 }, + { "asin", 1, builtin_asin, nullptr, nullptr, asin, nullptr }, + { "acos", 1, builtin_acos, nullptr, nullptr, acos, nullptr }, + { "atan", 1, builtin_atan, nullptr, nullptr, atan, nullptr }, - { "asind", 1, builtin_sind, 0, 0, arc_sin_deg, 0 }, - { "acosd", 1, builtin_cosd, 0, 0, arc_cos_deg, 0 }, - { "atand", 1, builtin_tand, 0, 0, arc_tan_deg, 0 }, + { "asind", 1, builtin_sind, nullptr, nullptr, arc_sin_deg, nullptr }, + { "acosd", 1, builtin_cosd, nullptr, nullptr, arc_cos_deg, nullptr }, + { "atand", 1, builtin_tand, nullptr, nullptr, arc_tan_deg, nullptr }, - { "atan2", 2, builtin_atan2, 0, 0, 0, atan2 }, - { "atan2d", 2, builtin_atan2d, 0, 0, 0, atan2_deg }, + { "atan2", 2, builtin_atan2, nullptr, nullptr, nullptr, atan2 }, + { "atan2d", 2, builtin_atan2d, nullptr, nullptr, nullptr, atan2_deg }, - { "arg", 2, builtin_arg, 0, 0, 0, my_arg }, - { "argd", 2, builtin_argd, 0, 0, 0, my_arg_deg }, + { "arg", 2, builtin_arg, nullptr, nullptr, nullptr, my_arg }, + { "argd", 2, builtin_argd, nullptr, nullptr, nullptr, my_arg_deg }, - { "log", 1, builtin_log, 0, 0, log, 0 }, - { "exp", 1, builtin_exp, 0, 0, exp, 0 }, + { "log", 1, builtin_log, nullptr, nullptr, log, nullptr }, + { "exp", 1, builtin_exp, nullptr, nullptr, exp, nullptr }, - { "log10", 1, builtin_log10, 0, 0, log10, 0 }, - { "exp10", 1, builtin_exp10, 0, 0, my_exp10, 0 }, + { "log10", 1, builtin_log10, nullptr, nullptr, log10, nullptr }, + { "exp10", 1, builtin_exp10, nullptr, nullptr, my_exp10, nullptr }, - { "sqrt", 1, builtin_sqrt, 0, 0, sqrt, 0 }, + { "sqrt", 1, builtin_sqrt, nullptr, nullptr, sqrt, nullptr }, - { "abs", 1, builtin_abs, abs, 0, fabs, 0 }, + { "abs", 1, builtin_abs, abs, nullptr, fabs, nullptr }, - { "min", 2, builtin_min, 0, my_imin, 0, my_dmin }, - { "max", 2, builtin_max, 0, my_imax, 0, my_dmax }, + { "min", 2, builtin_min, nullptr, my_imin, nullptr, my_dmin }, + { "max", 2, builtin_max, nullptr, my_imax, nullptr, my_dmax }, - { "mod", 2, builtin_mod, 0, my_imod, 0, my_dmod }, + { "mod", 2, builtin_mod, nullptr, my_imod, nullptr, my_dmod }, - { "floor", 1, builtin_floor, 0, 0, floor, 0 }, - { "ceil", 1, builtin_ceil, 0, 0, ceil, 0 }, + { "floor", 1, builtin_floor, nullptr, nullptr, floor, nullptr }, + { "ceil", 1, builtin_ceil, nullptr, nullptr, ceil, nullptr }, - { "step", 1, builtin_step, my_istep, 0, my_dstep, 0 }, + { "step", 1, builtin_step, my_istep, nullptr, my_dstep, nullptr }, // Functions defined in ConfigConstants - // { "F_to_C", 1, builtin_F_to_C, 0, 0, my_F_to_C, 0 }, - // { "C_to_F", 1, builtin_C_to_F, 0, 0, my_C_to_F, 0 }, + // { "F_to_C", 1, builtin_F_to_C, nullptr, nullptr, my_F_to_C, nullptr }, + // { "C_to_F", 1, builtin_C_to_F, nullptr, nullptr, my_C_to_F, nullptr }, - { "nint", 1, builtin_nint, 0, 0, 0, 0 }, - { "sign", 1, builtin_sign, 0, 0, 0, 0 }, + { "nint", 1, builtin_nint, nullptr, nullptr, nullptr, nullptr }, + { "sign", 1, builtin_sign, nullptr, nullptr, nullptr, nullptr }, // @@ -156,7 +156,7 @@ double sin_deg(double degrees) { -return ( sin(degrees*rad_per_deg) ); +return sin(degrees*rad_per_deg); } @@ -168,7 +168,7 @@ double cos_deg(double degrees) { -return ( cos(degrees*rad_per_deg) ); +return cos(degrees*rad_per_deg); } @@ -180,7 +180,7 @@ double tan_deg(double degrees) { -return ( tan(degrees*rad_per_deg) ); +return tan(degrees*rad_per_deg); } @@ -192,7 +192,7 @@ double arc_sin_deg(double t) { -return ( deg_per_rad*asin(t) ); +return deg_per_rad*asin(t); } @@ -204,7 +204,7 @@ double arc_cos_deg(double t) { -return ( deg_per_rad*acos(t) ); +return deg_per_rad*acos(t); } @@ -216,7 +216,7 @@ double arc_tan_deg(double t) { -return ( deg_per_rad*atan(t) ); +return deg_per_rad*atan(t); } @@ -228,7 +228,7 @@ double atan2_deg(double y, double x) { -return ( deg_per_rad*atan2(y, x) ); +return deg_per_rad*atan2(y, x); } @@ -240,7 +240,7 @@ double my_arg(double x, double y) { -return ( atan2(y, x) ); +return atan2(y, x); } @@ -252,7 +252,7 @@ double my_arg_deg(double x, double y) { -return ( deg_per_rad*atan2(y, x) ); +return deg_per_rad*atan2(y, x); } @@ -264,7 +264,7 @@ double my_exp10(double t) { -return ( pow(10.0, t) ); +return pow(10.0, t); } @@ -352,7 +352,7 @@ double c; c = a - b*floor(a/b); -return ( c ); +return c; } @@ -373,7 +373,7 @@ a = (int) y; if ( fabs(a - y) > 0.3 ) ++a; -return ( a ); +return a; } @@ -385,12 +385,12 @@ int my_isign(int k) { -if ( k > 0 ) return ( 1 ); +if ( k > 0 ) return 1; -if ( k < 0 ) return ( -1 ); +if ( k < 0 ) return -1; -return ( 0 ); +return 0; } @@ -402,13 +402,13 @@ int my_dsign(double t) { -if ( t > 0.0 ) return ( 1 ); +if ( t > 0.0 ) return 1; -if ( t < 0.0 ) return ( -1 ); +if ( t < 0.0 ) return -1; -return ( 0 ); +return 0; } @@ -420,9 +420,9 @@ int my_istep(int i) { -if ( i >= 0 ) return ( 1 ); +if ( i >= 0 ) return 1; -return ( 0 ); +return 0; } @@ -434,9 +434,9 @@ double my_dstep(double x) { -if ( x >= 0.0 ) return ( 1.0 ); +if ( x >= 0.0 ) return 1.0; -return ( 0.0 ); +return 0.0; } @@ -485,18 +485,16 @@ bool is_builtin(const ConcatString text, int & index) { -int j; - index = -1; -for (j=0; j #include "celltype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ ConcatString celltype_to_string(const CellType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { @@ -73,7 +73,7 @@ switch ( t ) { } // switch -return ( ConcatString (s) ); +return ConcatString (s); } @@ -85,33 +85,33 @@ bool string_to_celltype(const char * text, CellType & t) { - if ( strcmp(text, "integer" ) == 0 ) { t = integer; return ( true ); } -else if ( strcmp(text, "floating_point" ) == 0 ) { t = floating_point; return ( true ); } -else if ( strcmp(text, "boolean" ) == 0 ) { t = boolean; return ( true ); } -else if ( strcmp(text, "cell_mark" ) == 0 ) { t = cell_mark; return ( true ); } -else if ( strcmp(text, "op_add" ) == 0 ) { t = op_add; return ( true ); } - -else if ( strcmp(text, "op_multiply" ) == 0 ) { t = op_multiply; return ( true ); } -else if ( strcmp(text, "op_divide" ) == 0 ) { t = op_divide; return ( true ); } -else if ( strcmp(text, "op_subtract" ) == 0 ) { t = op_subtract; return ( true ); } -else if ( strcmp(text, "op_power" ) == 0 ) { t = op_power; return ( true ); } -else if ( strcmp(text, "op_square" ) == 0 ) { t = op_square; return ( true ); } - -else if ( strcmp(text, "op_negate" ) == 0 ) { t = op_negate; return ( true ); } -else if ( strcmp(text, "op_store" ) == 0 ) { t = op_store; return ( true ); } -else if ( strcmp(text, "op_recall" ) == 0 ) { t = op_recall; return ( true ); } -else if ( strcmp(text, "identifier" ) == 0 ) { t = identifier; return ( true ); } -else if ( strcmp(text, "user_func" ) == 0 ) { t = user_func; return ( true ); } - -else if ( strcmp(text, "builtin_func" ) == 0 ) { t = builtin_func; return ( true ); } -else if ( strcmp(text, "local_var" ) == 0 ) { t = local_var; return ( true ); } -else if ( strcmp(text, "character_string") == 0 ) { t = character_string; return ( true ); } -else if ( strcmp(text, "no_cell_type" ) == 0 ) { t = no_cell_type; return ( true ); } + if ( strcmp(text, "integer" ) == 0 ) { t = integer; return true; } +else if ( strcmp(text, "floating_point" ) == 0 ) { t = floating_point; return true; } +else if ( strcmp(text, "boolean" ) == 0 ) { t = boolean; return true; } +else if ( strcmp(text, "cell_mark" ) == 0 ) { t = cell_mark; return true; } +else if ( strcmp(text, "op_add" ) == 0 ) { t = op_add; return true; } + +else if ( strcmp(text, "op_multiply" ) == 0 ) { t = op_multiply; return true; } +else if ( strcmp(text, "op_divide" ) == 0 ) { t = op_divide; return true; } +else if ( strcmp(text, "op_subtract" ) == 0 ) { t = op_subtract; return true; } +else if ( strcmp(text, "op_power" ) == 0 ) { t = op_power; return true; } +else if ( strcmp(text, "op_square" ) == 0 ) { t = op_square; return true; } + +else if ( strcmp(text, "op_negate" ) == 0 ) { t = op_negate; return true; } +else if ( strcmp(text, "op_store" ) == 0 ) { t = op_store; return true; } +else if ( strcmp(text, "op_recall" ) == 0 ) { t = op_recall; return true; } +else if ( strcmp(text, "identifier" ) == 0 ) { t = identifier; return true; } +else if ( strcmp(text, "user_func" ) == 0 ) { t = user_func; return true; } + +else if ( strcmp(text, "builtin_func" ) == 0 ) { t = builtin_func; return true; } +else if ( strcmp(text, "local_var" ) == 0 ) { t = local_var; return true; } +else if ( strcmp(text, "character_string") == 0 ) { t = character_string; return true; } +else if ( strcmp(text, "no_cell_type" ) == 0 ) { t = no_cell_type; return true; } // // nope // -return ( false ); +return false; } diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 66475afdee..92477d4bd5 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -8,8 +8,6 @@ /////////////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -21,10 +19,12 @@ using namespace std; #include "GridTemplate.h" +using namespace std; + /////////////////////////////////////////////////////////////////////////////// static const double default_vld_thresh = 1.0; -static const char conf_key_prepbufr_map_bad[] = "obs_prefbufr_map"; // for backward compatibility +//static const char conf_key_prepbufr_map_bad[] = "obs_prefbufr_map"; // for backward compatibility /////////////////////////////////////////////////////////////////////////////// @@ -34,7 +34,7 @@ static MetConfig conf_const(replace_path(config_const_filename).c_str()); /////////////////////////////////////////////////////////////////////////////// GaussianInfo::GaussianInfo() -: weights(0) +: weights(nullptr) { clear(); } @@ -45,7 +45,7 @@ void GaussianInfo::clear() { weight_sum = 0.0; if (weights) { delete weights; - weights = (double *)0; + weights = (double *)nullptr; } max_r = weight_cnt = 0; radius = dx = bad_data_double; @@ -67,7 +67,8 @@ int GaussianInfo::compute_max_r() { /////////////////////////////////////////////////////////////////////////////// void GaussianInfo::compute() { - double weight, distance_sq; + double weight; + double distance_sq; const double g_sigma = radius / dx; const double g_sigma_sq = g_sigma * g_sigma; const double f_sigma_exp_divider = (2 * g_sigma_sq); @@ -89,7 +90,7 @@ void GaussianInfo::compute() { distance_sq = (double)idx_x*idx_x + idx_y*idx_y; if (distance_sq <= max_r_sq) { weight_cnt++; - weight = exp(-(distance_sq) / f_sigma_exp_divider) / f_sigma_divider; + weight = exp(-distance_sq / f_sigma_exp_divider) / f_sigma_divider; weight_sum += weight; } weights[index++] = weight; @@ -198,14 +199,12 @@ void RegridInfo::validate() { } // Check the Gaussian filter - if(method == InterpMthd_MaxGauss) { - if(gaussian.radius < gaussian.dx) { - mlog << Error << "\nRegridInfo::validate() -> " - << "The radius of influence (" << gaussian.radius - << ") is less than the delta distance (" << gaussian.dx - << ") for regridding method \"" << interpmthd_to_string(method) << "\".\n\n"; - exit(1); - } + if(method == InterpMthd_MaxGauss && gaussian.radius < gaussian.dx) { + mlog << Error << "\nRegridInfo::validate() -> " + << "The radius of influence (" << gaussian.radius + << ") is less than the delta distance (" << gaussian.dx + << ") for regridding method \"" << interpmthd_to_string(method) << "\".\n\n"; + exit(1); } // Check for equal number of censor thresholds and values @@ -260,7 +259,7 @@ ConcatString parse_conf_version(Dictionary *dict) { check_met_version(s.c_str()); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -295,13 +294,15 @@ ConcatString parse_conf_string(Dictionary *dict, const char *conf_key, } } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// StringArray parse_conf_string_array(Dictionary *dict, const char *conf_key, const char *caller) { - StringArray sa, cur, sid_sa; + StringArray sa; + StringArray cur; + StringArray sid_sa; if(!dict) { mlog << Error << "\n" << caller << "empty dictionary!\n\n"; exit(1); @@ -342,7 +343,7 @@ GrdFileType parse_conf_file_type(Dictionary *dict) { } } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -352,7 +353,7 @@ map parse_conf_output_flag(Dictionary *dict, map output_map; STATOutputType t = STATOutputType_None; ConcatString cs; - int i, v; + int v; if(!dict) { mlog << Error << "\nparse_conf_output_flag() -> " @@ -361,7 +362,7 @@ map parse_conf_output_flag(Dictionary *dict, } // Loop over the requested line types - for(i=0; i parse_conf_output_flag(Dictionary *dict, exit(1); } - return(output_map); + return output_map; } /////////////////////////////////////////////////////////////////////////////// map parse_conf_output_stats(Dictionary *dict) { - Dictionary *out_dict = (Dictionary *) 0; + Dictionary *out_dict = (Dictionary *) nullptr; map output_map; STATLineType line_type; StringArray sa; - int i; if(!dict) { mlog << Error << "\nparse_conf_output_stats() -> " @@ -418,7 +418,7 @@ map parse_conf_output_stats(Dictionary *dict) { out_dict = dict->lookup_dictionary(conf_key_output_stats); // Loop over the output flag dictionary entries - for(i=0; in_entries(); i++) { + for(int i=0; in_entries(); i++) { // Get the line type for the current entry line_type = string_to_statlinetype((*out_dict)[i]->name().c_str()); @@ -433,7 +433,7 @@ map parse_conf_output_stats(Dictionary *dict) { output_map[line_type].add(sa); } - return(output_map); + return output_map; } /////////////////////////////////////////////////////////////////////////////// @@ -444,10 +444,10 @@ map parse_conf_output_stats(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// int parse_conf_n_vx(Dictionary *dict) { - int i, total; + int total = 0; StringArray lvl; - if(!dict) return(0); + if(!dict) return 0; // Check that this dictionary is an array if(!dict->is_array()) { @@ -457,7 +457,7 @@ int parse_conf_n_vx(Dictionary *dict) { } // Loop over the fields to be verified - for(i=0,total=0; in_entries(); i++) { + for(int i=0; in_entries(); i++) { // Get the level array, which may or may not be defined. // If defined, use its length. If not, use a length of 1. @@ -467,7 +467,7 @@ int parse_conf_n_vx(Dictionary *dict) { total += (lvl.n() > 0 ? lvl.n() : 1); } - return(total); + return total; } /////////////////////////////////////////////////////////////////////////////// @@ -480,7 +480,8 @@ Dictionary parse_conf_i_vx_dict(Dictionary *dict, int index) { Dictionary i_dict; DictionaryEntry entry; StringArray lvl; - int i, total, n_lvl; + int n_lvl; + int total; if(!dict) { mlog << Error << "\nparse_conf_i_vx_dict() -> " @@ -496,7 +497,7 @@ Dictionary parse_conf_i_vx_dict(Dictionary *dict, int index) { } // Loop over the fields to be verified - for(i=0,total=0; in_entries(); i++) { + for(int i=0,total=0; in_entries(); i++) { // Get the level array, which may or may not be defined. // If defined, use its length. If not, use a length of 1. @@ -520,7 +521,7 @@ Dictionary parse_conf_i_vx_dict(Dictionary *dict, int index) { } } // end for i - return(i_dict); + return i_dict; } /////////////////////////////////////////////////////////////////////////////// @@ -542,7 +543,7 @@ StringArray parse_conf_tc_model(Dictionary *dict, bool error_out) { } } - return(sa); + return sa; } /////////////////////////////////////////////////////////////////////////////// @@ -559,7 +560,7 @@ StringArray parse_conf_message_type(Dictionary *dict, bool error_out) { exit(1); } - return(sa); + return sa; } /////////////////////////////////////////////////////////////////////////////// @@ -567,13 +568,12 @@ StringArray parse_conf_message_type(Dictionary *dict, bool error_out) { StringArray parse_conf_sid_list(Dictionary *dict, const char *conf_key) { StringArray sa, cur, sid_sa; ConcatString mask_name; - int i; const char *method_name = "parse_conf_sid_list() -> "; sa = parse_conf_string_array(dict, conf_key, method_name); // Parse station ID's to exclude from each entry - for(i=0; i parse_conf_llpnt_mask(Dictionary *dict) { Dictionary *llpnt_dict; vector v; MaskLatLon m; - int i, n_entries; + int n_entries; if(!dict) { mlog << Error << "\nparse_conf_llpnt_mask() -> " @@ -748,7 +748,7 @@ vector parse_conf_llpnt_mask(Dictionary *dict) { } // Loop through the array entries - for(i=0; itype() == ArrayType) { @@ -766,7 +766,7 @@ vector parse_conf_llpnt_mask(Dictionary *dict) { v.push_back(m); } - return(v); + return v; } /////////////////////////////////////////////////////////////////////////////// @@ -791,7 +791,7 @@ StringArray parse_conf_obs_qty_inc(Dictionary *dict) { sa = parse_conf_string_array(dict, conf_key_obs_qty_inc, method_name); } - return(sa); + return sa; } /////////////////////////////////////////////////////////////////////////////// @@ -801,14 +801,13 @@ StringArray parse_conf_obs_qty_exc(Dictionary *dict) { StringArray sa = parse_conf_string_array(dict, conf_key_obs_qty_exc, method_name); - return(sa); + return sa; } /////////////////////////////////////////////////////////////////////////////// NumArray parse_conf_ci_alpha(Dictionary *dict) { NumArray na; - int i; if(!dict) { mlog << Error << "\nparse_conf_ci_alpha() -> " @@ -827,7 +826,7 @@ NumArray parse_conf_ci_alpha(Dictionary *dict) { } // Check that the values for alpha are between 0 and 1 - for(i=0; i= 1.0) { mlog << Error << "\nparse_conf_ci_alpha() -> " << "All confidence interval alpha values (" @@ -837,7 +836,7 @@ NumArray parse_conf_ci_alpha(Dictionary *dict) { } } - return(na); + return na; } /////////////////////////////////////////////////////////////////////////////// @@ -877,7 +876,7 @@ NumArray parse_conf_eclv_points(Dictionary *dict) { } } - return(na); + return na; } /////////////////////////////////////////////////////////////////////////////// @@ -970,7 +969,7 @@ TimeSummaryInfo parse_conf_time_summary(Dictionary *dict) { exit(1); } - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -979,7 +978,6 @@ void parse_add_conf_key_value_map( Dictionary *dict, const char *conf_key_map_name, map *m) { Dictionary *map_dict = (Dictionary *) 0; ConcatString key, val; - int i; if(!dict) { mlog << Error << "\nparse_conf_key_value_type_map() -> " @@ -991,7 +989,7 @@ void parse_add_conf_key_value_map( map_dict = dict->lookup_array(conf_key_map_name); // Loop through the array entries - for(i=0; in_entries(); i++) { + for(int i=0; in_entries(); i++) { // Lookup the key and value key = (*map_dict)[i]->dict_value()->lookup_string(conf_key_key); @@ -1016,7 +1014,6 @@ map parse_conf_key_value_map( Dictionary *map_dict = (Dictionary *) 0; map m; ConcatString key, val; - int i; const char *method_name = (0 != caller) ? caller : "parse_conf_key_value_map() -> "; if(!dict) { @@ -1028,7 +1025,7 @@ map parse_conf_key_value_map( map_dict = dict->lookup_array(conf_key_map_name); // Loop through the array entries - for(i=0; in_entries(); i++) { + for(int i=0; in_entries(); i++) { // Lookup the key and value key = (*map_dict)[i]->dict_value()->lookup_string(conf_key_key); @@ -1044,7 +1041,7 @@ map parse_conf_key_value_map( m.insert(pair(key, val)); } - return(m); + return m; } @@ -1108,8 +1105,7 @@ map parse_conf_obs_to_qc_map(Dictionary *dict) { map parse_conf_key_convert_map( Dictionary *dict, const char *conf_key_map_name, const char *caller) { - Dictionary *map_dict = (Dictionary *) 0; - int i, j; + Dictionary *map_dict = (Dictionary *) nullptr; StringArray sa; ConcatString key; UserFunc_1Arg fx; @@ -1125,7 +1121,7 @@ map parse_conf_key_convert_map( map_dict = dict->lookup_array(conf_key_map_name); // Loop through the array entries - for(i=0; in_entries(); i++) { + for(int i=0; in_entries(); i++) { // Lookup the key and convert function sa = (*map_dict)[i]->dict_value()->lookup_string_array(conf_key_key); @@ -1141,7 +1137,7 @@ map parse_conf_key_convert_map( } // Add map entry for each string - for(j=0; j parse_conf_key_convert_map( } // end for j } // end for i - return(m); + return m; } /////////////////////////////////////////////////////////////////////////////// @@ -1225,7 +1221,7 @@ BootInfo parse_conf_boot(Dictionary *dict) { // Conf: boot_seed info.seed = dict->lookup_string(conf_key_boot_seed); - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -1315,7 +1311,7 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { // Validate the settings info.validate(); - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -1410,19 +1406,22 @@ bool InterpInfo::operator==(const InterpInfo &v) const { match = false; } - return(match); + return match; } /////////////////////////////////////////////////////////////////////////////// InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { - Dictionary *interp_dict = (Dictionary *) 0; - Dictionary *type_dict = (Dictionary *) 0; + Dictionary *interp_dict = (Dictionary *) nullptr; + Dictionary *type_dict = (Dictionary *) nullptr; InterpInfo info; - NumArray mthd_na, wdth_na; + NumArray mthd_na; + NumArray wdth_na; InterpMthd method; - int i, j, k, v, width, n_entries; + int v; + int width; + int n_entries; bool is_correct_type = false; if(!dict) { @@ -1495,7 +1494,8 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { } // Loop over the interpolation type dictionary entries - for(i=0, info.n_interp=0; itype() == ArrayType) { @@ -1508,7 +1508,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { } // Loop over the methods - for(j=0; j 1); - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -1723,7 +1723,8 @@ void NbrhdInfo::clear() { NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { Dictionary *nbrhd_dict = (Dictionary *) 0; NbrhdInfo info; - int i, v; + int i; + int v; if(!dict) { mlog << Error << "\nparse_conf_nbrhd() -> " @@ -1806,7 +1807,7 @@ NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { } } - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -1829,9 +1830,9 @@ HiRAInfo::HiRAInfo() { /////////////////////////////////////////////////////////////////////////////// HiRAInfo parse_conf_hira(Dictionary *dict) { - Dictionary *hira_dict = (Dictionary *) 0; + Dictionary *hira_dict = (Dictionary *) nullptr; HiRAInfo info; - int i,v; + int v; if(!dict) { mlog << Error << "\nparse_conf_hira() -> " @@ -1871,7 +1872,7 @@ HiRAInfo parse_conf_hira(Dictionary *dict) { } // Check for valid widths - for(i=0; i " @@ -1903,7 +1904,7 @@ HiRAInfo parse_conf_hira(Dictionary *dict) { // Conf: prob_cat_thresh info.prob_cat_ta = hira_dict->lookup_thresh_array(conf_key_prob_cat_thresh); - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -1932,7 +1933,7 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -1966,7 +1967,7 @@ DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2000,7 +2001,7 @@ ObsSummary parse_conf_obs_summary(Dictionary *dict) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2025,7 +2026,7 @@ int parse_conf_percentile(Dictionary *dict) { exit(1); } - return(i); + return i; } /////////////////////////////////////////////////////////////////////////////// @@ -2055,7 +2056,7 @@ ConcatString parse_conf_tmp_dir(Dictionary *dict) { met_closedir(odir); } - return(tmp_dir_path); + return tmp_dir_path; } /////////////////////////////////////////////////////////////////////////////// @@ -2085,7 +2086,7 @@ GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2118,7 +2119,7 @@ WaveletType parse_conf_wavelet_type(Dictionary *dict) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2161,7 +2162,7 @@ PlotInfo parse_conf_plot_info(Dictionary *dict) { info.colorbar_flag = dict->lookup_bool(conf_key_colorbar_flag, false); if(!dict->last_lookup_status()) info.colorbar_flag = true; - return(info); + return info; } /////////////////////////////////////////////////////////////////////////////// @@ -2171,8 +2172,8 @@ map parse_conf_filter_attr_map( map m; SingleThresh st; StringArray sa; - ThreshArray ta, ta_entry; - int i; + ThreshArray ta; + ThreshArray ta_entry; if(!dict) { mlog << Error << "\nparse_conf_filter_attr_map() -> " @@ -2210,7 +2211,7 @@ map parse_conf_filter_attr_map( } // Process each array entry - for(i=0; i= 1) { @@ -2224,7 +2225,7 @@ map parse_conf_filter_attr_map( } } - return(m); + return m; } /////////////////////////////////////////////////////////////////////////////// @@ -2357,17 +2358,16 @@ InterpMthd int_to_interpmthd(int i) { exit(1); } - return(m); + return m; } /////////////////////////////////////////////////////////////////////////////// void check_mctc_thresh(const ThreshArray &ta) { - int i; // Check that the threshold values are monotonically increasing // and the threshold types are inequalities that remain the same - for(i=0; i ta[i+1].get_value() || ta[i].get_type() != ta[i+1].get_type() || @@ -2390,7 +2390,7 @@ void check_mctc_thresh(const ThreshArray &ta) { /////////////////////////////////////////////////////////////////////////////// const char * statlinetype_to_string(const STATLineType t) { - const char *s = (const char *) 0; + const char *s = (const char *) nullptr; switch(t) { case(stat_sl1l2): s = stat_sl1l2_str; break; @@ -2441,7 +2441,7 @@ const char * statlinetype_to_string(const STATLineType t) { default: s = stat_na_str; break; } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2505,7 +2505,7 @@ STATLineType string_to_statlinetype(const char *s) { else t = no_stat_line_type; - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2524,7 +2524,7 @@ FieldType int_to_fieldtype(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2545,7 +2545,7 @@ GridTemplateFactory::GridTemplates int_to_gridtemplate(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2565,7 +2565,7 @@ ConcatString fieldtype_to_string(FieldType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2584,7 +2584,7 @@ SetLogic int_to_setlogic(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2613,7 +2613,7 @@ SetLogic string_to_setlogic(const char *s) { exit(1); } - return(t); + return t; } @@ -2634,7 +2634,7 @@ ConcatString setlogic_to_string(SetLogic type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2654,7 +2654,7 @@ ConcatString setlogic_to_abbr(SetLogic type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2674,7 +2674,7 @@ ConcatString setlogic_to_symbol(SetLogic type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2695,7 +2695,7 @@ SetLogic check_setlogic(SetLogic t1, SetLogic t2) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2714,7 +2714,7 @@ TrackType int_to_tracktype(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2733,7 +2733,7 @@ TrackType string_to_tracktype(const char *s) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2753,7 +2753,7 @@ ConcatString tracktype_to_string(TrackType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2769,7 +2769,7 @@ DiagType string_to_diagtype(const char *s) { else if(strcasecmp(s, ships_diag_dev_str) == 0) t = DiagType_SHIPS_Dev; else t = DiagType_None; - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2790,7 +2790,7 @@ ConcatString diagtype_to_string(DiagType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2808,7 +2808,7 @@ Interp12Type int_to_interp12type(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2826,7 +2826,7 @@ Interp12Type string_to_interp12type(const char *s) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2845,7 +2845,7 @@ ConcatString interp12type_to_string(Interp12Type type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2864,7 +2864,7 @@ MergeType int_to_mergetype(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2884,7 +2884,7 @@ ConcatString mergetype_to_string(MergeType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2910,7 +2910,7 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2929,7 +2929,7 @@ MatchType int_to_matchtype(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2949,7 +2949,7 @@ ConcatString matchtype_to_string(MatchType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -2971,7 +2971,7 @@ DistType int_to_disttype(int v) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -2993,7 +2993,7 @@ DistType string_to_disttype(const char *s) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// @@ -3016,7 +3016,7 @@ ConcatString disttype_to_string(DistType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -3037,7 +3037,7 @@ ConcatString dist_to_string(DistType type, const NumArray &parm) { s << ")"; } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -3057,7 +3057,7 @@ ConcatString griddecomptype_to_string(GridDecompType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -3080,7 +3080,7 @@ ConcatString wavelettype_to_string(WaveletType type) { exit(1); } - return(s); + return s; } /////////////////////////////////////////////////////////////////////////////// @@ -3126,7 +3126,7 @@ NormalizeType parse_conf_normalize(Dictionary *dict) { exit(1); } - return(t); + return t; } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/dictionary.cc b/src/basic/vx_config/dictionary.cc index ae93e52b60..a082cbdbd7 100644 --- a/src/basic/vx_config/dictionary.cc +++ b/src/basic/vx_config/dictionary.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -28,6 +26,9 @@ using namespace std; #include "configobjecttype_to_string.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -93,11 +94,11 @@ DictionaryEntry & DictionaryEntry::operator=(const DictionaryEntry & entry) { -if ( this == &entry ) return ( * this ); +if ( this == &entry ) return *this; assign(entry); -return ( * this ); +return *this; } @@ -109,15 +110,15 @@ void DictionaryEntry::init_from_scratch() { -Text = (ConcatString *) 0; +Text = (ConcatString *) nullptr; -Dict = (Dictionary *) 0; +Dict = (Dictionary *) nullptr; -Thresh = (SingleThresh *) 0; +Thresh = (SingleThresh *) nullptr; -PWL = (PiecewiseLinear *) 0; +PWL = (PiecewiseLinear *) nullptr; -v = (IcodeVector *) 0; +v = (IcodeVector *) nullptr; Nargs = 0; @@ -141,15 +142,15 @@ Ival = 0; Dval = 0.0; Bval = false; -if ( Text ) { delete Text; Text = (ConcatString *) 0; } +if ( Text ) { delete Text; Text = (ConcatString *) nullptr; } -if ( Dict ) { delete Dict; Dict = (Dictionary *) 0; } +if ( Dict ) { delete Dict; Dict = (Dictionary *) nullptr; } -if ( Thresh ) { delete Thresh; Thresh = (SingleThresh *) 0; } +if ( Thresh ) { delete Thresh; Thresh = (SingleThresh *) nullptr; } -if ( PWL ) { delete PWL; PWL = (PiecewiseLinear *) 0; } +if ( PWL ) { delete PWL; PWL = (PiecewiseLinear *) nullptr; } -if ( v ) { delete v; v = (IcodeVector *) 0; } +if ( v ) { delete v; v = (IcodeVector *) nullptr; } Nargs = 0; @@ -710,7 +711,7 @@ if ( Type != IntegerType ) { } -return ( Ival ); +return Ival; } @@ -732,7 +733,7 @@ if ( Type != FloatType ) { } -return ( Dval ); +return Dval; } @@ -754,7 +755,7 @@ if ( Type != BooleanType ) { } -return ( Bval ); +return Bval; } @@ -785,7 +786,7 @@ const ConcatString DictionaryEntry::string_value() const } - return ( sub_text ); + return sub_text; } @@ -807,7 +808,7 @@ if ( Type != DictionaryType ) { } -return ( Dict ); +return Dict; } @@ -829,7 +830,7 @@ if ( Type != ArrayType ) { } -return ( Dict ); +return Dict; } @@ -851,7 +852,7 @@ if ( Type != ThresholdType ) { } -return ( Thresh ); +return Thresh; } @@ -873,7 +874,7 @@ if ( Type != PwlFunctionType ) { } -return ( PWL ); +return PWL; } @@ -931,11 +932,11 @@ Dictionary & Dictionary::operator=(const Dictionary & d) { -if ( this == &d ) return ( * this ); +if ( this == &d ) return *this; assign(d); -return ( * this ); +return *this; } @@ -947,9 +948,9 @@ void Dictionary::init_from_scratch() { -e = (DictionaryEntry **) 0; +e = (DictionaryEntry **) nullptr; -Parent = (Dictionary *) 0; +Parent = (Dictionary *) nullptr; Nentries = 0; @@ -972,15 +973,13 @@ void Dictionary::clear() if ( e ) { - int j; - - for (j=0; jdump_config_format(out, depth + 1); @@ -1116,21 +1111,21 @@ if ( Nalloc >= n ) return; n = dictionary_alloc_inc*((n + dictionary_alloc_inc - 1)/dictionary_alloc_inc); int j; -DictionaryEntry ** u = (DictionaryEntry **) 0; +DictionaryEntry ** u = (DictionaryEntry **) nullptr; u = new DictionaryEntry * [n]; -for (j=0; j= Nentries) ) { } -return ( e[n] ); +return e[n]; } @@ -1270,13 +1263,13 @@ if ( Nentries == 0 ) { LastLookupStatus = false; - return ( (const DictionaryEntry *) 0 ); + return (const DictionaryEntry *) nullptr; } int j; StringArray scope; ConcatString Name = name; -const DictionaryEntry * E = (const DictionaryEntry *) 0; +const DictionaryEntry * E = (const DictionaryEntry *) nullptr; Dictionary * D = this; @@ -1300,14 +1293,14 @@ for (j=0; j<(scope.n_elements() - 1); ++j) { LastLookupStatus = false; - return ( (const DictionaryEntry *) 0 ); + return (const DictionaryEntry *) nullptr; } if ( ! E->is_dictionary() ) { LastLookupStatus = false; - return ( (const DictionaryEntry *) 0 ); + return (const DictionaryEntry *) nullptr; } D = E->dict_value(); @@ -1326,7 +1319,7 @@ if ( E ) { LastLookupStatus = (E != 0); - return ( E ); + return E; } // @@ -1345,9 +1338,9 @@ if ( search_parent ) { // done // -LastLookupStatus = (E != 0); +LastLookupStatus = (E != nullptr); -return ( E ); +return E; } @@ -1363,18 +1356,16 @@ if ( Nentries == 0 ) { LastLookupStatus = false; - return ( (const DictionaryEntry *) 0 ); + return (const DictionaryEntry *) nullptr; } -int j; - -for (j=0; jName == name ) { LastLookupStatus = (e[j] != 0); - return ( e[j] ); + return e[j]; } } @@ -1383,7 +1374,7 @@ for (j=0; jtype(); @@ -1519,7 +1509,7 @@ if ( !Entry || !is_correct_type ) { } -return ( Entry->b_value() ); +return Entry->b_value(); } @@ -1564,11 +1554,11 @@ if ( !Entry || !is_correct_type ) { } - return ( bad_data_int ); + return bad_data_int; } -return ( Entry->i_value() ); +return Entry->i_value(); } @@ -1596,7 +1586,7 @@ if ( Entry ) { if ( Entry->type() == ThresholdType && Entry->thresh_value()->get_type() == thresh_na ) { - return ( bad_data_double ); + return bad_data_double; } } @@ -1630,7 +1620,7 @@ if ( !Entry || !is_correct_type ) { } - return ( bad_data_double ); + return bad_data_double; } @@ -1641,7 +1631,7 @@ if ( !Entry || !is_correct_type ) { if ( Entry->type() == FloatType ) v = Entry->d_value(); else if ( Entry->type() == IntegerType ) v = (double) Entry->i_value(); -return ( v ); +return v; } @@ -1657,7 +1647,7 @@ NumArray Dictionary::lookup_num_array(const char * name, { const DictionaryEntry * Entry = lookup(name, search_parent); -const Dictionary * Dict = (const Dictionary *) 0; +const Dictionary * Dict = (const Dictionary *) nullptr; ConfigObjectType Type = no_config_object_type; bool is_correct_type = false; NumArray array; @@ -1693,7 +1683,7 @@ if ( !Entry || !is_correct_type ) { } - return ( array ); + return array; } @@ -1705,7 +1695,7 @@ if ( Entry->type() == IntegerType ) { array.add( Entry->i_value() ); - return ( array ); + return array; } @@ -1717,7 +1707,7 @@ if ( Entry->type() == FloatType ) { array.add( Entry->d_value() ); - return ( array ); + return array; } @@ -1729,7 +1719,7 @@ if ( Entry->type() == BooleanType ) { array.add( Entry->b_value() ); - return ( array ); + return array; } @@ -1766,7 +1756,7 @@ for (int i=0; in_entries(); i++) { } -return ( array ); +return array; } @@ -1787,7 +1777,7 @@ NumArray num_array = lookup_num_array(name, error_out, print_warning, search_par for (int i=0; istring_value() ); +return Entry->string_value(); } @@ -1887,7 +1877,7 @@ if ( !Entry || !is_correct_type ) { } - return ( array ); + return array; } @@ -1899,7 +1889,7 @@ if ( Entry->type() == StringType ) { array.add( Entry->string_value() ); - return ( array ); + return array; } @@ -1938,7 +1928,7 @@ for (int i=0; in_entries(); i++) { } -return ( array ); +return array; } @@ -1988,11 +1978,11 @@ if ( !Entry || !is_correct_type ) { SingleThresh s; - return ( s ); + return s; } -return ( *(Entry->thresh_value()) ); +return *(Entry->thresh_value()); } @@ -2043,7 +2033,7 @@ if ( !Entry || !is_correct_type ) { } - return ( array ); + return array; } @@ -2055,7 +2045,7 @@ if ( Entry->type() == ThresholdType ) { array.add( *(Entry->thresh_value()) ); - return ( array ); + return array; } @@ -2095,7 +2085,7 @@ for (int i=0; in_entries(); i++) { } -return ( array ); +return array; } @@ -2142,11 +2132,11 @@ if ( !Entry || !is_correct_type ) { } - return ( (Dictionary *) 0 ); + return (Dictionary *) nullptr; } -return ( Entry->dict_value() ); +return Entry->dict_value(); } @@ -2191,11 +2181,11 @@ if ( !Entry || !is_correct_type ) { } - return ( (Dictionary *) 0 ); + return (Dictionary *) nullptr; } -return ( Entry->array_value() ); +return Entry->array_value(); } @@ -2217,11 +2207,11 @@ int Dictionary::lookup_seconds(const char * name, ConcatString cs = lookup_string(name, false, true, search_parent); if ( LastLookupStatus ) { - if ( cs.empty() ) return ( bad_data_int ); - else return ( timestring_to_sec( cs.c_str() ) ); + if ( cs.empty() ) return bad_data_int; + else return timestring_to_sec( cs.c_str() ); } -return ( lookup_int(name, error_out, print_warning, search_parent) ); +return lookup_int(name, error_out, print_warning, search_parent); } @@ -2239,11 +2229,9 @@ IntArray Dictionary::lookup_seconds_array(const char * name, StringArray sa = lookup_string_array(name, error_out, print_warning, search_parent); IntArray ia; -int j; +for (int j=0; jpwl_value() ); +return Entry->pwl_value(); } @@ -2437,7 +2423,7 @@ int j; for (j=0; jis_array() ); +return D[Nelements - 1]->is_array(); } @@ -2625,7 +2608,7 @@ const Dictionary * DictionaryStack::top() const if ( Nelements == 0 ) return ( (const Dictionary *) 0 ); -return ( D[Nelements - 1] ); +return D[Nelements - 1]; } @@ -2647,7 +2630,7 @@ if ( Nelements <= 1 ) { } -delete D[Nelements - 1]; D[Nelements - 1] = (Dictionary *) 0; +delete D[Nelements - 1]; D[Nelements - 1] = (Dictionary *) nullptr; --Nelements; @@ -2717,7 +2700,7 @@ entry.set_dict (name, *(D[Nelements - 1])); D[Nelements - 2]->store(entry); -delete D[Nelements - 1]; D[Nelements - 1] = (Dictionary *) 0; +delete D[Nelements - 1]; D[Nelements - 1] = (Dictionary *) nullptr; --Nelements; @@ -2757,7 +2740,7 @@ E.set_name(name); D[Nelements - 2]->store(E); -delete D[Nelements - 1]; D[Nelements - 1] = (Dictionary *) 0; +delete D[Nelements - 1]; D[Nelements - 1] = (Dictionary *) nullptr; --Nelements; @@ -2789,16 +2772,16 @@ const DictionaryEntry * DictionaryStack::lookup(const std::string name) const { -if ( Nelements == 0 ) return ( (const DictionaryEntry *) 0 ); +if ( Nelements == 0 ) return (const DictionaryEntry *) nullptr; int j; -const DictionaryEntry * E = (const DictionaryEntry *) 0; +const DictionaryEntry * E = (const DictionaryEntry *) nullptr; for (j=(Nelements - 1); j>=0; --j) { E = D[j]->lookup(name); - if ( E ) return ( E ); + if ( E ) return E; } @@ -2806,7 +2789,7 @@ for (j=(Nelements - 1); j>=0; --j) { // nope // -return ( (const DictionaryEntry *) 0 ); +return (const DictionaryEntry *) nullptr; } @@ -2830,7 +2813,7 @@ ConcatString config_prefix(int depth) int j; ConcatString s; -if ( depth == 0 ) { s << ' '; return ( s ); } +if ( depth == 0 ) { s << ' '; return s; } for (j=0; j Date: Wed, 10 May 2023 03:30:09 -0600 Subject: [PATCH 06/39] #2521 Used nullptr --- src/basic/vx_config/calculator.h | 2 +- src/basic/vx_config/number_stack.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/vx_config/calculator.h b/src/basic/vx_config/calculator.h index ee15b9e34d..b9863e0345 100644 --- a/src/basic/vx_config/calculator.h +++ b/src/basic/vx_config/calculator.h @@ -68,7 +68,7 @@ class Calculator : public NumberStack { // do stuff // - void run(const IcodeVector &, const Number * local_vars = 0); + void run(const IcodeVector &, const Number * local_vars = nullptr); void store(DictionaryEntry &); diff --git a/src/basic/vx_config/number_stack.h b/src/basic/vx_config/number_stack.h index 7c9fda3cb4..e659df6fc4 100644 --- a/src/basic/vx_config/number_stack.h +++ b/src/basic/vx_config/number_stack.h @@ -60,7 +60,7 @@ class NumberStack { void clear(bool initialize = true); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; // // set stuff From 324d3d0b774d875b2c9f7c78a54c97a5185d8b9b Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 03:30:35 -0600 Subject: [PATCH 07/39] #2521 Move #include statement to the top of the file --- src/basic/vx_cal/mjd_to_date.cc | 14 ++++++++++---- src/basic/vx_cal/unix_to_mdyhms.cc | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/basic/vx_cal/mjd_to_date.cc b/src/basic/vx_cal/mjd_to_date.cc index af7b14996e..755d65f4a8 100644 --- a/src/basic/vx_cal/mjd_to_date.cc +++ b/src/basic/vx_cal/mjd_to_date.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -22,6 +19,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -29,7 +29,13 @@ void mjd_to_date(int mjd, int & month, int & day, int & year) { -int i, j, n, l, d, m, y; +int i; +int j; +int n; +int l; +int d; +int m; +int y; l = mjd + 2468570; diff --git a/src/basic/vx_cal/unix_to_mdyhms.cc b/src/basic/vx_cal/unix_to_mdyhms.cc index f31eeab81b..0fd9ee5e29 100644 --- a/src/basic/vx_cal/unix_to_mdyhms.cc +++ b/src/basic/vx_cal/unix_to_mdyhms.cc @@ -11,9 +11,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -23,6 +20,9 @@ using namespace std; #include "vx_cal.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -131,7 +131,13 @@ void unix_to_mdyhms(unixtime u, int & month, int & day, int & year, int & hour, { -unixtime i, j, n, l, d, m, y; +unixtime i; +unixtime j; +unixtime n; +unixtime l; +unixtime d; +unixtime m; +unixtime y; n = u/86400; From 7f31d653daf0d3275eb8096ec0a4f7288c9157e0 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 08:52:05 -0600 Subject: [PATCH 08/39] #2521 Appended name space std to ostream --- src/basic/enum_to_string/info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/enum_to_string/info.h b/src/basic/enum_to_string/info.h index 3ebb140677..2aae204494 100644 --- a/src/basic/enum_to_string/info.h +++ b/src/basic/enum_to_string/info.h @@ -25,7 +25,7 @@ static const int enuminfo_alloc_increment = 100; class EnumInfo { - friend ostream & operator<<(ostream &, const EnumInfo &); + friend std::ostream & operator<<(std::ostream &, const EnumInfo &); private: From c46b83ce8e5ccfef827e1c17ed6d31b7a25991ee Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 09:21:34 -0600 Subject: [PATCH 09/39] #2521 Appended the namespace std to ostream --- src/basic/enum_to_string/info.h | 2 +- src/basic/enum_to_string/scope.h | 4 ++-- src/libcode/vx_bool_calc/bool_calc.h | 2 +- src/libcode/vx_bool_calc/token.h | 4 ++-- src/libcode/vx_bool_calc/token_stack.h | 4 ++-- src/libcode/vx_data2d_grib2/data2d_grib2.h | 2 +- src/libcode/vx_data2d_grib2/var_info_grib2.h | 2 +- src/libcode/vx_data2d_nccf/data2d_nccf.h | 2 +- src/libcode/vx_data2d_nccf/nccf_file.h | 2 +- src/libcode/vx_data2d_nccf/var_info_nccf.h | 2 +- src/libcode/vx_geodesy/spheroid.h | 2 +- src/libcode/vx_grid/goes_grid.h | 2 +- src/libcode/vx_pointdata_python/pointdata_python.h | 2 +- src/libcode/vx_shapedata/mode_data_field.h | 10 +--------- src/libcode/vx_tc_util/prob_pair_info.h | 2 +- src/tools/other/gsi_tools/rad_record.h | 4 ++-- src/tools/other/mode_time_domain/2d_att.h | 2 +- src/tools/other/mode_time_domain/2d_att_array.h | 2 +- src/tools/other/mode_time_domain/3d_att.h | 4 ++-- src/tools/other/mode_time_domain/3d_att_pair_array.h | 2 +- src/tools/other/mode_time_domain/3d_att_single_array.h | 2 +- src/tools/other/mode_time_domain/fo_graph.h | 2 +- src/tools/other/mode_time_domain/fo_node.h | 2 +- src/tools/other/mode_time_domain/fo_node_array.h | 2 +- src/tools/other/mode_time_domain/mm_engine.h | 2 +- src/tools/other/mode_time_domain/mtd_config_info.h | 2 +- src/tools/other/mode_time_domain/mtd_file_base.h | 2 +- src/tools/other/mode_time_domain/mtd_file_float.h | 2 +- src/tools/other/mode_time_domain/mtd_file_int.h | 2 +- src/tools/other/mode_time_domain/mtd_partition.h | 8 ++++---- src/tools/other/wwmca_tool/ave_interp.h | 2 +- src/tools/other/wwmca_tool/interp_base.h | 4 ++-- src/tools/other/wwmca_tool/max_interp.h | 2 +- src/tools/other/wwmca_tool/min_interp.h | 2 +- src/tools/other/wwmca_tool/nearest_interp.h | 2 +- src/tools/other/wwmca_tool/wwmca_ref.h | 2 +- 36 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/basic/enum_to_string/info.h b/src/basic/enum_to_string/info.h index 2aae204494..644337e4ca 100644 --- a/src/basic/enum_to_string/info.h +++ b/src/basic/enum_to_string/info.h @@ -106,7 +106,7 @@ inline const char * EnumInfo::header() const { return ( Header ); } //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const EnumInfo &); +extern std::ostream & operator<<(std::ostream &, const EnumInfo &); //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/enum_to_string/scope.h b/src/basic/enum_to_string/scope.h index 4fbe23b7d9..4e1467c8a0 100644 --- a/src/basic/enum_to_string/scope.h +++ b/src/basic/enum_to_string/scope.h @@ -65,7 +65,7 @@ inline const char * ScopeStackElement::name() const { return ( Name ); } //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const ScopeStackElement &); +extern std::ostream & operator<<(std::ostream &, const ScopeStackElement &); //////////////////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ inline int ScopeStack::n_elements() const { return ( N ); } //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const ScopeStack &); +extern std::ostream & operator<<(std::ostream &, const ScopeStack &); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/bool_calc.h b/src/libcode/vx_bool_calc/bool_calc.h index e55b746208..7e65b81153 100644 --- a/src/libcode/vx_bool_calc/bool_calc.h +++ b/src/libcode/vx_bool_calc/bool_calc.h @@ -39,7 +39,7 @@ class BoolCalc { void clear(); - void dump_program(ostream &) const; + void dump_program(std::ostream &) const; diff --git a/src/libcode/vx_bool_calc/token.h b/src/libcode/vx_bool_calc/token.h index 1ef22450b9..a63cce075c 100644 --- a/src/libcode/vx_bool_calc/token.h +++ b/src/libcode/vx_bool_calc/token.h @@ -90,7 +90,7 @@ class Token { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; TokenType type; @@ -142,7 +142,7 @@ class Token { //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const Token &); +extern std::ostream & operator<<(std::ostream &, const Token &); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_bool_calc/token_stack.h b/src/libcode/vx_bool_calc/token_stack.h index d1afbe1d18..4f4cd898d4 100644 --- a/src/libcode/vx_bool_calc/token_stack.h +++ b/src/libcode/vx_bool_calc/token_stack.h @@ -47,7 +47,7 @@ class TokenStack { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; void set_alloc_inc(int = 0); // 0 means default value (50) @@ -84,7 +84,7 @@ inline bool TokenStack::nonempty() const { return ( Nelements > 0 ); } //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const TokenStack &); +extern std::ostream & operator<<(std::ostream &, const TokenStack &); //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d_grib2/data2d_grib2.h b/src/libcode/vx_data2d_grib2/data2d_grib2.h index 69fb7121b3..4191e19728 100644 --- a/src/libcode/vx_data2d_grib2/data2d_grib2.h +++ b/src/libcode/vx_data2d_grib2/data2d_grib2.h @@ -150,7 +150,7 @@ class MetGrib2DataFile : public Met2dDataFile { void close (); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; static ConcatString build_magic(Grib2Record *rec); diff --git a/src/libcode/vx_data2d_grib2/var_info_grib2.h b/src/libcode/vx_data2d_grib2/var_info_grib2.h index 9eaeb1ff0e..7f47facf08 100644 --- a/src/libcode/vx_data2d_grib2/var_info_grib2.h +++ b/src/libcode/vx_data2d_grib2/var_info_grib2.h @@ -68,7 +68,7 @@ class VarInfoGrib2 : public VarInfo VarInfoGrib2(const VarInfoGrib2 &); VarInfoGrib2 & operator=(const VarInfoGrib2 &); - void dump(ostream &) const; + void dump(std::ostream &) const; void clear(); // diff --git a/src/libcode/vx_data2d_nccf/data2d_nccf.h b/src/libcode/vx_data2d_nccf/data2d_nccf.h index 6ba37c8607..d9a9a2df9c 100644 --- a/src/libcode/vx_data2d_nccf/data2d_nccf.h +++ b/src/libcode/vx_data2d_nccf/data2d_nccf.h @@ -101,7 +101,7 @@ class MetNcCFDataFile : public Met2dDataFile { void close (); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; }; diff --git a/src/libcode/vx_data2d_nccf/nccf_file.h b/src/libcode/vx_data2d_nccf/nccf_file.h index c22881ba84..c43f4b535b 100644 --- a/src/libcode/vx_data2d_nccf/nccf_file.h +++ b/src/libcode/vx_data2d_nccf/nccf_file.h @@ -51,7 +51,7 @@ class NcCfFile { void close(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; int getNx() const diff --git a/src/libcode/vx_data2d_nccf/var_info_nccf.h b/src/libcode/vx_data2d_nccf/var_info_nccf.h index e37c8918bb..021009f0f4 100644 --- a/src/libcode/vx_data2d_nccf/var_info_nccf.h +++ b/src/libcode/vx_data2d_nccf/var_info_nccf.h @@ -49,7 +49,7 @@ class VarInfoNcCF : public VarInfo VarInfoNcCF(const VarInfoNcCF &); VarInfoNcCF & operator=(const VarInfoNcCF &); - void dump(ostream &) const; + void dump(std::ostream &) const; void clear(); // diff --git a/src/libcode/vx_geodesy/spheroid.h b/src/libcode/vx_geodesy/spheroid.h index b940ce9fb1..bb2949a727 100644 --- a/src/libcode/vx_geodesy/spheroid.h +++ b/src/libcode/vx_geodesy/spheroid.h @@ -61,7 +61,7 @@ class Spheroid { void clear(); - void dump(ostream &, int depth = 0) const; + void dump(std::ostream &, int depth = 0) const; // // set stuff diff --git a/src/libcode/vx_grid/goes_grid.h b/src/libcode/vx_grid/goes_grid.h index 26ec161c5f..b9ef894224 100644 --- a/src/libcode/vx_grid/goes_grid.h +++ b/src/libcode/vx_grid/goes_grid.h @@ -64,7 +64,7 @@ class GoesImagerGrid : public GridRep { ConcatString name() const; - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; ConcatString serialize(const char *sep=" ") const; diff --git a/src/libcode/vx_pointdata_python/pointdata_python.h b/src/libcode/vx_pointdata_python/pointdata_python.h index fc2a481c1e..44148d5c15 100644 --- a/src/libcode/vx_pointdata_python/pointdata_python.h +++ b/src/libcode/vx_pointdata_python/pointdata_python.h @@ -68,7 +68,7 @@ class MetPythonPointDataFile { void close(); - void dump (ostream &, int depth = 0) const; + void dump (std::ostream &, int depth = 0) const; MetPointDataPython *get_met_point_data(); diff --git a/src/libcode/vx_shapedata/mode_data_field.h b/src/libcode/vx_shapedata/mode_data_field.h index 4b8fb1c4c8..76828c55d4 100644 --- a/src/libcode/vx_shapedata/mode_data_field.h +++ b/src/libcode/vx_shapedata/mode_data_field.h @@ -40,15 +40,7 @@ class ModeDataField { void clear(); - void dump(ostream &, int depth = 0) const; - - - - - - - - + void dump(std::ostream &, int depth = 0) const; }; diff --git a/src/libcode/vx_tc_util/prob_pair_info.h b/src/libcode/vx_tc_util/prob_pair_info.h index 2e0c91f5de..e83626527d 100644 --- a/src/libcode/vx_tc_util/prob_pair_info.h +++ b/src/libcode/vx_tc_util/prob_pair_info.h @@ -46,7 +46,7 @@ class ProbPairInfo { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; ConcatString serialize() const; ConcatString serialize_r(int = 0) const; diff --git a/src/tools/other/gsi_tools/rad_record.h b/src/tools/other/gsi_tools/rad_record.h index c76421b127..322d1fefbf 100644 --- a/src/tools/other/gsi_tools/rad_record.h +++ b/src/tools/other/gsi_tools/rad_record.h @@ -54,7 +54,7 @@ struct RadParams { RadParams(); - void dump(ostream &) const; + void dump(std::ostream &) const; }; @@ -76,7 +76,7 @@ struct ChannelParams { ChannelParams(); - void dump(ostream &) const; + void dump(std::ostream &) const; }; diff --git a/src/tools/other/mode_time_domain/2d_att.h b/src/tools/other/mode_time_domain/2d_att.h index e32f80a1c2..055f429eef 100644 --- a/src/tools/other/mode_time_domain/2d_att.h +++ b/src/tools/other/mode_time_domain/2d_att.h @@ -83,7 +83,7 @@ class SingleAtt2D { void clear(); - void dump(ostream &, int depth = 0) const; + void dump(std::ostream &, int depth = 0) const; // // set stuff diff --git a/src/tools/other/mode_time_domain/2d_att_array.h b/src/tools/other/mode_time_domain/2d_att_array.h index d19533cbf7..786397e17e 100644 --- a/src/tools/other/mode_time_domain/2d_att_array.h +++ b/src/tools/other/mode_time_domain/2d_att_array.h @@ -56,7 +56,7 @@ class SingleAtt2DArray { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; void set_alloc_inc(int = 0); // 0 means default value (50) diff --git a/src/tools/other/mode_time_domain/3d_att.h b/src/tools/other/mode_time_domain/3d_att.h index 5ea9c865de..ea32e77c13 100644 --- a/src/tools/other/mode_time_domain/3d_att.h +++ b/src/tools/other/mode_time_domain/3d_att.h @@ -90,7 +90,7 @@ class SingleAtt3D { void clear(); - void dump(ostream &, int depth = 0) const; + void dump(std::ostream &, int depth = 0) const; // // set stuff @@ -306,7 +306,7 @@ class PairAtt3D { void clear(); - void dump(ostream &, int depth = 0) const; + void dump(std::ostream &, int depth = 0) const; // SingleAtt3D Fcst; // SingleAtt3D Obs; diff --git a/src/tools/other/mode_time_domain/3d_att_pair_array.h b/src/tools/other/mode_time_domain/3d_att_pair_array.h index fede5b45a4..25d8c2fa41 100644 --- a/src/tools/other/mode_time_domain/3d_att_pair_array.h +++ b/src/tools/other/mode_time_domain/3d_att_pair_array.h @@ -56,7 +56,7 @@ class PairAtt3DArray { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; // // set stuff diff --git a/src/tools/other/mode_time_domain/3d_att_single_array.h b/src/tools/other/mode_time_domain/3d_att_single_array.h index 431b71b192..feff527cbf 100644 --- a/src/tools/other/mode_time_domain/3d_att_single_array.h +++ b/src/tools/other/mode_time_domain/3d_att_single_array.h @@ -56,7 +56,7 @@ class SingleAtt3DArray { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; void set_alloc_inc(int = 0); // 0 means default value (100) diff --git a/src/tools/other/mode_time_domain/fo_graph.h b/src/tools/other/mode_time_domain/fo_graph.h index 1e5222db1c..44e5d28456 100644 --- a/src/tools/other/mode_time_domain/fo_graph.h +++ b/src/tools/other/mode_time_domain/fo_graph.h @@ -97,7 +97,7 @@ class FO_Graph { void erase_edges(); - void dump_as_table(ostream &) const; + void dump_as_table(std::ostream &) const; void dump_as_table(const int) const; // dumps to mlog with the given verbosity level diff --git a/src/tools/other/mode_time_domain/fo_node.h b/src/tools/other/mode_time_domain/fo_node.h index 76a940469f..8b3bc53e0e 100644 --- a/src/tools/other/mode_time_domain/fo_node.h +++ b/src/tools/other/mode_time_domain/fo_node.h @@ -52,7 +52,7 @@ class FO_Node { void clear(); - void dump(ostream &, int) const; + void dump(std::ostream &, int) const; // // set stuff diff --git a/src/tools/other/mode_time_domain/fo_node_array.h b/src/tools/other/mode_time_domain/fo_node_array.h index 2d0fbdbd4c..5a260cd8c9 100644 --- a/src/tools/other/mode_time_domain/fo_node_array.h +++ b/src/tools/other/mode_time_domain/fo_node_array.h @@ -55,7 +55,7 @@ class FO_Node_Array { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; void set_alloc_inc(int = 0); // 0 means default value (30) diff --git a/src/tools/other/mode_time_domain/mm_engine.h b/src/tools/other/mode_time_domain/mm_engine.h index 640a22ba67..4b48959220 100644 --- a/src/tools/other/mode_time_domain/mm_engine.h +++ b/src/tools/other/mode_time_domain/mm_engine.h @@ -51,7 +51,7 @@ class MM_Engine { void clear(); - void partition_dump(ostream &) const; + void partition_dump(std::ostream &) const; void partition_dump(const int) const; // dump to mlog with the given verbosity InterestCalculator calc; diff --git a/src/tools/other/mode_time_domain/mtd_config_info.h b/src/tools/other/mode_time_domain/mtd_config_info.h index 229d9bd0ab..46161c1cc7 100644 --- a/src/tools/other/mode_time_domain/mtd_config_info.h +++ b/src/tools/other/mode_time_domain/mtd_config_info.h @@ -50,7 +50,7 @@ struct MtdNcOutInfo { void set_all_false(); void set_all_true(); - void dump(ostream &) const; + void dump(std::ostream &) const; }; diff --git a/src/tools/other/mode_time_domain/mtd_file_base.h b/src/tools/other/mode_time_domain/mtd_file_base.h index cf01ba3d65..82f7d40509 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.h +++ b/src/tools/other/mode_time_domain/mtd_file_base.h @@ -103,7 +103,7 @@ class MtdFileBase { virtual void clear(); - virtual void dump(ostream &, int = 0) const; + virtual void dump(std::ostream &, int = 0) const; // // set stuff diff --git a/src/tools/other/mode_time_domain/mtd_file_float.h b/src/tools/other/mode_time_domain/mtd_file_float.h index 8583cf5907..12c226860f 100644 --- a/src/tools/other/mode_time_domain/mtd_file_float.h +++ b/src/tools/other/mode_time_domain/mtd_file_float.h @@ -70,7 +70,7 @@ class MtdFloatFile : public MtdFileBase { virtual void clear(); - virtual void dump(ostream &, int = 0) const; + virtual void dump(std::ostream &, int = 0) const; // // set stuff diff --git a/src/tools/other/mode_time_domain/mtd_file_int.h b/src/tools/other/mode_time_domain/mtd_file_int.h index c331d3ea11..b55135c9ca 100644 --- a/src/tools/other/mode_time_domain/mtd_file_int.h +++ b/src/tools/other/mode_time_domain/mtd_file_int.h @@ -73,7 +73,7 @@ class MtdIntFile : public MtdFileBase { virtual void clear(); - virtual void dump(ostream &, int = 0) const; + virtual void dump(std::ostream &, int = 0) const; // // set stuff diff --git a/src/tools/other/mode_time_domain/mtd_partition.h b/src/tools/other/mode_time_domain/mtd_partition.h index 608451bdb0..9b6d6b2ac1 100644 --- a/src/tools/other/mode_time_domain/mtd_partition.h +++ b/src/tools/other/mode_time_domain/mtd_partition.h @@ -62,7 +62,7 @@ class EquivalenceClass { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; // // set stuff @@ -120,7 +120,7 @@ return ( false ); //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const EquivalenceClass &); +extern std::ostream & operator<<(std::ostream &, const EquivalenceClass &); //////////////////////////////////////////////////////////////////////// @@ -160,9 +160,9 @@ class Mtd_Partition { // disjoint unions of equivalence classes void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; - void specialized_dump(ostream &, const int Nf, const int No) const; + void specialized_dump(std::ostream &, const int Nf, const int No) const; void specialized_dump(const int, const int Nf, const int No) const; // dump to mlog with the given verbosity // diff --git a/src/tools/other/wwmca_tool/ave_interp.h b/src/tools/other/wwmca_tool/ave_interp.h index 6ad0fe6a9c..4b9427191c 100644 --- a/src/tools/other/wwmca_tool/ave_interp.h +++ b/src/tools/other/wwmca_tool/ave_interp.h @@ -49,7 +49,7 @@ class Ave_Interp : public Interpolator { Interpolator * copy() const; - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; }; diff --git a/src/tools/other/wwmca_tool/interp_base.h b/src/tools/other/wwmca_tool/interp_base.h index f165faf9ea..c3d1f3c80f 100644 --- a/src/tools/other/wwmca_tool/interp_base.h +++ b/src/tools/other/wwmca_tool/interp_base.h @@ -56,7 +56,7 @@ class InterpolationValue { //////////////////////////////////////////////////////////////////////// -extern ostream & operator<<(ostream &, const InterpolationValue &); +extern std::ostream & operator<<(std::ostream &, const InterpolationValue &); //////////////////////////////////////////////////////////////////////// @@ -111,7 +111,7 @@ class Interpolator { virtual Interpolator * copy() const = 0; - virtual void dump(ostream &, int = 0) const = 0; + virtual void dump(std::ostream &, int = 0) const = 0; }; diff --git a/src/tools/other/wwmca_tool/max_interp.h b/src/tools/other/wwmca_tool/max_interp.h index 7398a6648f..ee6c4ec686 100644 --- a/src/tools/other/wwmca_tool/max_interp.h +++ b/src/tools/other/wwmca_tool/max_interp.h @@ -49,7 +49,7 @@ class Max_Interp : public Interpolator { Interpolator * copy() const; - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; }; diff --git a/src/tools/other/wwmca_tool/min_interp.h b/src/tools/other/wwmca_tool/min_interp.h index b1084e7777..713b4e6b7f 100644 --- a/src/tools/other/wwmca_tool/min_interp.h +++ b/src/tools/other/wwmca_tool/min_interp.h @@ -49,7 +49,7 @@ class Min_Interp : public Interpolator { Interpolator * copy() const; - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; }; diff --git a/src/tools/other/wwmca_tool/nearest_interp.h b/src/tools/other/wwmca_tool/nearest_interp.h index 6f34e81103..56f88c7d88 100644 --- a/src/tools/other/wwmca_tool/nearest_interp.h +++ b/src/tools/other/wwmca_tool/nearest_interp.h @@ -49,7 +49,7 @@ class Nearest_Interp : public Interpolator { Interpolator * copy() const; - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; }; diff --git a/src/tools/other/wwmca_tool/wwmca_ref.h b/src/tools/other/wwmca_tool/wwmca_ref.h index 82e9217fc1..c57c61f82f 100644 --- a/src/tools/other/wwmca_tool/wwmca_ref.h +++ b/src/tools/other/wwmca_tool/wwmca_ref.h @@ -112,7 +112,7 @@ class WwmcaRegridder { void clear(); - void dump(ostream &, int = 0) const; + void dump(std::ostream &, int = 0) const; void set_cp_nh_file(const char *); void set_cp_sh_file(const char *); From 840c5df3d9d23a10bcb949dbac60dfacddfec5b8 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 10 May 2023 09:35:34 -0600 Subject: [PATCH 10/39] #2521 defined int j out of for loop) --- src/basic/enum_to_string/enum_to_string.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/enum_to_string/enum_to_string.cc b/src/basic/enum_to_string/enum_to_string.cc index 30284b209a..0045f23735 100644 --- a/src/basic/enum_to_string/enum_to_string.cc +++ b/src/basic/enum_to_string/enum_to_string.cc @@ -172,13 +172,14 @@ void parse_command_line(int &argc, char **argv) if ( argc == 1 ) { usage(); exit ( 1 ); } +int j; int found; do { found = 0; - for (int j=1; j Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 11/39] #2521 Added asignment operator with noexcept keyword --- src/basic/vx_config/config_constants.h | 9 ++ src/basic/vx_config/config_util.cc | 152 +++++++++++++++++++++++++ 2 files changed, 161 insertions(+) diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index d9dfd3d225..ffd308deb2 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -246,6 +246,7 @@ struct TimeSummaryInfo { double vld_thresh; // Valid data time window threshold int vld_freq; // Expected observation frequency in seconds // used to compute the ratio of valid data. + TimeSummaryInfo & operator=(const TimeSummaryInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -272,6 +273,7 @@ struct BootInfo { ConcatString seed; // RNG seed value void clear(); + BootInfo & operator=(const BootInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -292,6 +294,7 @@ struct InterpInfo { void clear(); void validate(); // Ensure that width and method are accordant bool operator==(const InterpInfo &) const; + InterpInfo &operator=(const InterpInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -322,6 +325,7 @@ struct RegridInfo { void clear(); void validate(); // ensure that width and method are accordant void validate_point(); // ensure that width and method are accordant + RegridInfo &operator=(const RegridInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -340,6 +344,7 @@ struct ClimoCDFInfo { ClimoCDFInfo(); void clear(); void set_cdf_ta(int, bool &); // Construct equally-likely thresholds + ClimoCDFInfo &operator=(const ClimoCDFInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -356,6 +361,7 @@ struct NbrhdInfo { GridTemplateFactory::GridTemplates shape; // Neighborhood shape void clear(); + NbrhdInfo &operator=(const NbrhdInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -374,6 +380,7 @@ struct HiRAInfo { HiRAInfo(); void clear(); + HiRAInfo &operator=(const HiRAInfo &a) noexcept; // SoanrQube findings }; //////////////////////////////////////////////////////////////////////// @@ -390,6 +397,7 @@ struct PlotInfo { bool colorbar_flag; // Turn on/off plotting the colorbar void clear(); + PlotInfo &operator=(const PlotInfo &a) noexcept; }; //////////////////////////////////////////////////////////////////////// @@ -405,6 +413,7 @@ struct MaskLatLon { void clear(); bool operator==(const MaskLatLon &) const; + MaskLatLon &operator=(const MaskLatLon &a) noexcept; }; //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 92477d4bd5..01a078dd27 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -33,6 +33,7 @@ static MetConfig conf_const(replace_path(config_const_filename).c_str()); /////////////////////////////////////////////////////////////////////////////// + GaussianInfo::GaussianInfo() : weights(nullptr) { @@ -115,8 +116,10 @@ void GaussianInfo::validate() { } } + /////////////////////////////////////////////////////////////////////////////// + void RegridInfo::clear() { enable = false; field = FieldType_None; @@ -244,6 +247,26 @@ void RegridInfo::validate_point() { /////////////////////////////////////////////////////////////////////////////// +RegridInfo &RegridInfo::operator=(const RegridInfo &a) noexcept { + if ( this != &a ) { + enable = a.enable; + field = a.field; + vld_thresh = a.vld_thresh; + name = a.name; + method = a.method; + width = a.width; + gaussian = a.gaussian; + shape = a.shape; + convert_fx = a.convert_fx; + censor_thresh = a.censor_thresh; + censor_val = a.censor_val; + hook = a.hook; + } + return *this; +} + +/////////////////////////////////////////////////////////////////////////////// + ConcatString parse_conf_version(Dictionary *dict) { ConcatString s; @@ -698,6 +721,7 @@ void parse_sid_mask(const ConcatString &mask_sid_str, /////////////////////////////////////////////////////////////////////////////// + void MaskLatLon::clear() { name.clear(); lat_thresh.clear(); @@ -718,6 +742,18 @@ bool MaskLatLon::operator==(const MaskLatLon &v) const { return match; } +/////////////////////////////////////////////////////////////////////////////// + +MaskLatLon &MaskLatLon::operator=(const MaskLatLon &a) noexcept { + if ( this != &a ) { + name = a.name; + lat_thresh = a.lat_thresh; + lon_thresh = a.lon_thresh; + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// vector parse_conf_llpnt_mask(Dictionary *dict) { @@ -1156,6 +1192,44 @@ map parse_conf_key_convert_map( return m; } + +/////////////////////////////////////////////////////////////////////////////// + + +TimeSummaryInfo &TimeSummaryInfo::operator=(const TimeSummaryInfo &a) noexcept { + if ( this != &a ) { + flag = a.flag; + raw_data = a.raw_data; + beg = a.beg; + end = a.end; + step = a.step; + width_beg = a.width_beg; + width_end = a.width_end; + width = a.width; + grib_code = a.grib_code; + obs_var = a.obs_var; + type = a.type; + vld_thresh = a.vld_thresh; + vld_freq = a.vld_freq; + } + return *this; +} + + +/////////////////////////////////////////////////////////////////////////////// + + +BootInfo & BootInfo::operator=(const BootInfo &a) noexcept { + if ( this != &a ) { + interval = a.interval; + rep_prop = a.rep_prop; + n_rep = a.n_rep; + rng = a.rng; + seed = a.seed; + } + return *this; +} + /////////////////////////////////////////////////////////////////////////////// void BootInfo::clear() { @@ -1166,6 +1240,7 @@ void BootInfo::clear() { seed.clear(); } + /////////////////////////////////////////////////////////////////////////////// BootInfo parse_conf_boot(Dictionary *dict) { @@ -1224,6 +1299,7 @@ BootInfo parse_conf_boot(Dictionary *dict) { return info; } + /////////////////////////////////////////////////////////////////////////////// RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { @@ -1409,6 +1485,22 @@ bool InterpInfo::operator==(const InterpInfo &v) const { return match; } +/////////////////////////////////////////////////////////////////////////////// + +InterpInfo & InterpInfo::operator=(const InterpInfo &a) noexcept { + if ( this != &a ) { + field = a.field; + vld_thresh = a.vld_thresh; + n_interp = a.n_interp; + method = a.method; + width = a.width; + gaussian = a.gaussian; + shape = a.shape; + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { @@ -1628,6 +1720,20 @@ void ClimoCDFInfo::set_cdf_ta(int n_bin, bool ¢er) { return; } +/////////////////////////////////////////////////////////////////////////////// + +ClimoCDFInfo &ClimoCDFInfo::operator=(const ClimoCDFInfo &a) noexcept { + if ( this != &a ) { + flag = a.flag; + n_bin = a.n_bin; + cdf_ta = a.cdf_ta; + write_bins = a.write_bins; + direct_prob = a.direct_prob; + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// ClimoCDFInfo parse_conf_climo_cdf(Dictionary *dict) { @@ -1710,6 +1816,7 @@ ClimoCDFInfo parse_conf_climo_cdf(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// + void NbrhdInfo::clear() { field = FieldType_None; vld_thresh = bad_data_double; @@ -1718,6 +1825,20 @@ void NbrhdInfo::clear() { shape = GridTemplateFactory::GridTemplate_None; } +/////////////////////////////////////////////////////////////////////////////// + +NbrhdInfo &NbrhdInfo::operator=(const NbrhdInfo &a) noexcept { + if ( this != &a ) { + field = a.field; + vld_thresh = a.vld_thresh; + width = a.width; + cov_ta = a.cov_ta; + shape = a.shape; + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { @@ -1812,6 +1933,7 @@ NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { /////////////////////////////////////////////////////////////////////////////// + void HiRAInfo::clear() { flag = false; width.clear(); @@ -1821,6 +1943,21 @@ void HiRAInfo::clear() { shape = GridTemplateFactory::GridTemplate_None; } +/////////////////////////////////////////////////////////////////////////////// + +HiRAInfo &HiRAInfo::operator=(const HiRAInfo &a) noexcept { + if ( this != &a ) { + flag = a.flag; + width = a.width; + vld_thresh = a.vld_thresh; + cov_ta = a.cov_ta; + prob_cat_ta = a.prob_cat_ta; + shape = a.shape; + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// HiRAInfo::HiRAInfo() { @@ -2124,6 +2261,7 @@ WaveletType parse_conf_wavelet_type(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// + void PlotInfo::clear() { flag = true; // enabled by default color_table.clear(); @@ -2132,6 +2270,20 @@ void PlotInfo::clear() { colorbar_flag = true; // plot colorbar by default } +/////////////////////////////////////////////////////////////////////////////// + +PlotInfo &PlotInfo::operator=(const PlotInfo &a) noexcept { + if ( this != &a ) { + flag = a.flag; + color_table = a.color_table; + plot_min = a.plot_min; + plot_max = a.plot_max; + colorbar_flag = a.colorbar_flag; + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// PlotInfo parse_conf_plot_info(Dictionary *dict) { From 49f65b86fb648edd9607362c014754dd0df97f40 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 12/39] #2521 Added asignment operator with noexcept keyword to InputInfo --- src/libcode/vx_data2d/var_info.cc | 24 ++++++++++++++++++++++++ src/libcode/vx_data2d/var_info.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/libcode/vx_data2d/var_info.cc b/src/libcode/vx_data2d/var_info.cc index f074b9bc53..3c490bf18e 100644 --- a/src/libcode/vx_data2d/var_info.cc +++ b/src/libcode/vx_data2d/var_info.cc @@ -814,8 +814,32 @@ EnsVarInfo::EnsVarInfo() { ctrl_info = nullptr; } + +/////////////////////////////////////////////////////////////////////////////// + + +InputInfo &InputInfo::operator=(const InputInfo &a) noexcept { + if ( this != &a ) { + file_index = a.file_index; + ens_member_id = a.ens_member_id; + + var_info = (a.var_info == nullptr) ? nullptr : a.var_info; + + if (file_list == nullptr) file_list = new StringArray(); + else file_list->clear(); + if (a.file_list != nullptr) { + for (int i=0; in(); i++) { + file_list->add((*a.file_list)[i]); + } + } + } + return *this; +} + + /////////////////////////////////////////////////////////////////////////////// + EnsVarInfo::~EnsVarInfo() { clear(); } diff --git a/src/libcode/vx_data2d/var_info.h b/src/libcode/vx_data2d/var_info.h index e990c587a2..a40095fd98 100644 --- a/src/libcode/vx_data2d/var_info.h +++ b/src/libcode/vx_data2d/var_info.h @@ -262,6 +262,7 @@ struct InputInfo { int file_index; // Index in file_list of file to read StringArray * file_list; // Array of files (unallocated) ConcatString ens_member_id; // MET_ENS_MEMBER_ID string + InputInfo &operator=(const InputInfo &a) noexcept; }; //////////////////////////////////////////////////////////////////////// From dc5ddfcd17b9f9d369626e1e76bf01d42b8ca772 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 13/39] #2521 Added asignment operator with noexcept keyword to SSIDXData --- src/libcode/vx_statistics/met_stats.cc | 18 ++++++++++++++++++ src/libcode/vx_statistics/met_stats.h | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index 07f11d06c0..d0483c0ac6 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3233,6 +3233,24 @@ void DMAPInfo::set_options(const int _baddeley_p, const double _baddeley_max_dis n_full_points = _n_full_points; } + +//////////////////////////////////////////////////////////////////////// + + +SSIDXData &SSIDXData::operator=(const SSIDXData &a) noexcept { + if ( this != &a ) { + ss_index_name = a.ss_index_name; + fcst_model = a.fcst_model; + ref_model = a.ref_model; + init_time = a.init_time; + n_term = a.n_term; + n_vld = a.n_vld; + ss_index = a.ss_index; + } + return *this; +} + + //////////////////////////////////////////////////////////////////////// // // Begin code for misc functions diff --git a/src/libcode/vx_statistics/met_stats.h b/src/libcode/vx_statistics/met_stats.h index 9ccc2878da..d13df5547d 100644 --- a/src/libcode/vx_statistics/met_stats.h +++ b/src/libcode/vx_statistics/met_stats.h @@ -696,10 +696,13 @@ struct SSIDXData { TimeArray init_time; // Number of terms and number valid - int n_term, n_vld; + int n_term; + int n_vld; // Skill score index value double ss_index; + + SSIDXData &operator=(const SSIDXData &a) noexcept; }; //////////////////////////////////////////////////////////////////////// From 0417e8a89470e0f891099fddae605750f62cbb47 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 14/39] #2521 Added asignment operator with noexcept keyword to ObsErrorInfo --- src/libcode/vx_statistics/obs_error.cc | 12 ++++++++++++ src/libcode/vx_statistics/obs_error.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/libcode/vx_statistics/obs_error.cc b/src/libcode/vx_statistics/obs_error.cc index 8b11635cc9..09d05f0031 100644 --- a/src/libcode/vx_statistics/obs_error.cc +++ b/src/libcode/vx_statistics/obs_error.cc @@ -603,6 +603,7 @@ bool ObsErrorTable::has(const char *cur_var_name, // //////////////////////////////////////////////////////////////////////// + void ObsErrorInfo::clear() { flag = false; entry.clear(); @@ -631,6 +632,17 @@ void ObsErrorInfo::validate() { //////////////////////////////////////////////////////////////////////// +ObsErrorInfo &ObsErrorInfo::operator=(const ObsErrorInfo &a) noexcept { + if ( this != &a ) { + flag = a.flag; + entry = a.entry; + rng_ptr = (a.rng_ptr==nullptr) ? nullptr : a.rng_ptr; + } + return *this; +} + +//////////////////////////////////////////////////////////////////////// + ObsErrorInfo parse_conf_obs_error(Dictionary *dict, gsl_rng *rng_ptr) { Dictionary *err_dict = (Dictionary *) 0; ObsErrorInfo info; diff --git a/src/libcode/vx_statistics/obs_error.h b/src/libcode/vx_statistics/obs_error.h index b6165a0836..aebe13a4bf 100644 --- a/src/libcode/vx_statistics/obs_error.h +++ b/src/libcode/vx_statistics/obs_error.h @@ -171,6 +171,8 @@ struct ObsErrorInfo { void clear(); void validate(); + + ObsErrorInfo &operator=(const ObsErrorInfo &a) noexcept; }; //////////////////////////////////////////////////////////////////////// From ba80c231617d7619dccf38ee95643fae8706b5d9 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 15/39] #2521 Added asignment operator with noexcept keyword to GenesisEventInfo --- src/libcode/vx_tc_util/genesis_info.cc | 13 +++++++++++++ src/libcode/vx_tc_util/genesis_info.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/libcode/vx_tc_util/genesis_info.cc b/src/libcode/vx_tc_util/genesis_info.cc index b6ff638853..72a4ae41bc 100644 --- a/src/libcode/vx_tc_util/genesis_info.cc +++ b/src/libcode/vx_tc_util/genesis_info.cc @@ -61,6 +61,19 @@ bool GenesisEventInfo::is_genesis(const TrackPoint &p) const { return(status); } +//////////////////////////////////////////////////////////////////////// + +GenesisEventInfo &GenesisEventInfo::operator=(const GenesisEventInfo &a) noexcept { + if ( this != &a ) { + Technique = a.Technique; + Category = a.Category; + VMaxThresh = a.VMaxThresh; + MSLPThresh = a.MSLPThresh; + } + return *this; +} + + //////////////////////////////////////////////////////////////////////// GenesisEventInfo parse_conf_genesis_event_info(Dictionary *dict) { diff --git a/src/libcode/vx_tc_util/genesis_info.h b/src/libcode/vx_tc_util/genesis_info.h index 524c9a4301..9b2899edb9 100644 --- a/src/libcode/vx_tc_util/genesis_info.h +++ b/src/libcode/vx_tc_util/genesis_info.h @@ -37,6 +37,7 @@ struct GenesisEventInfo { bool is_genesis(const TrackPoint &) const; void clear(); + GenesisEventInfo &operator=(const GenesisEventInfo &a) noexcept; }; extern GenesisEventInfo parse_conf_genesis_event_info(Dictionary *dict); From a754b74afcebe09ee40f41ff7cf6428ae92c56f4 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 16/39] #2521 Added asignment operator with noexcept keyword to ConvData and RadData --- src/tools/other/gsi_tools/gsi_util.cc | 85 +++++++++++++++++++++++++++ src/tools/other/gsi_tools/gsi_util.h | 2 + 2 files changed, 87 insertions(+) diff --git a/src/tools/other/gsi_tools/gsi_util.cc b/src/tools/other/gsi_tools/gsi_util.cc index 0fea7239f9..ab46548965 100644 --- a/src/tools/other/gsi_tools/gsi_util.cc +++ b/src/tools/other/gsi_tools/gsi_util.cc @@ -25,6 +25,91 @@ using namespace std; #include "rad_record.h" #include "gsi_util.h" +//////////////////////////////////////////////////////////////////////// + + +ConvData &ConvData::operator=(const ConvData &a) noexcept { + if ( this != &a ) { + var = a.var; + obtype = a.obtype; + sid = a.sid; + lat = a.lat; + lon = a.lon; + prs = a.prs; + elv = a.elv; + fcst_ut = a.fcst_ut; + obs_ut = a.obs_ut; + obs = a.obs; + obs_v = a.obs_v; + guess = a.guess; + guess_v = a.guess_v; + obs_qc = a.obs_qc; + hgt = a.hgt; + prep_use = a.prep_use; + anly_use = a.anly_use; + setup_qc = a.setup_qc; + err_in = a.err_in; + err_adj = a.err_adj; + err_fin = a.err_fin; + qc_wght = a.qc_wght; + n_use = a.n_use; + } + return *this; +} + + +//////////////////////////////////////////////////////////////////////// + + +RadData &RadData::operator=(const RadData &a) noexcept { + if ( this != &a ) { + var = a.var; + lat = a.lat; + lon = a.lon; + elv = a.elv; + fcst_ut = a.fcst_ut; + obs_ut = a.obs_ut; + obs = a.obs; + guess = a.guess; + obs_qc = a.obs_qc; + use = a.use; + scan_pos = a.scan_pos; + sat_znth = a.sat_znth; + sat_azmth = a.sat_azmth; + sun_znth = a.sun_znth; + sun_azmth = a.sun_azmth; + sun_glnt = a.sun_glnt; + frac_wtr = a.frac_wtr; + frac_lnd = a.frac_lnd; + frac_ice = a.frac_ice; + frac_snw = a.frac_snw; + sfc_twtr = a.sfc_twtr; + sfc_tlnd = a.sfc_tlnd; + sfc_tice = a.sfc_tice; + sfc_tsnw = a.sfc_tsnw; + tsoil = a.tsoil; + soilm = a.soilm; + land_type = a.land_type; + frac_veg = a.frac_veg; + snw_dpth = a.snw_dpth; + sfc_wind = a.sfc_wind; + frac_cld = a.frac_cld; + ctop_prs = a.ctop_prs; + tfnd = a.tfnd; + twarm = a.twarm; + tcool = a.tcool; + tzfnd = a.tzfnd; + obs_err = a.obs_err; + fcst_nobc = a.fcst_nobc; + sfc_emis = a.sfc_emis; + stability = a.stability; + prs_max_wgt = a.prs_max_wgt; + n_use = a.n_use; + } + return *this; +} + + //////////////////////////////////////////////////////////////////////// ConvData parse_conv_data(const ConvRecord &r, const int i) { diff --git a/src/tools/other/gsi_tools/gsi_util.h b/src/tools/other/gsi_tools/gsi_util.h index d17220c47f..ad9add011d 100644 --- a/src/tools/other/gsi_tools/gsi_util.h +++ b/src/tools/other/gsi_tools/gsi_util.h @@ -53,6 +53,7 @@ struct ConvData { int hgt, prep_use, anly_use, setup_qc; double err_in, err_adj, err_fin, qc_wght; int n_use; + ConvData &operator=(const ConvData &a) noexcept; }; //////////////////////////////////////////////////////////////////////// @@ -77,6 +78,7 @@ struct RadData { double obs_err, fcst_nobc, sfc_emis, stability; double prs_max_wgt; int n_use; + RadData &operator=(const RadData &a) noexcept; }; //////////////////////////////////////////////////////////////////////// From 577dd4f78ebdbaa8792a9e19e7e57673f6509814 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 11 May 2023 14:33:49 -0600 Subject: [PATCH 17/39] #2521 Added asignment operator with noexcept keyword to derive_var_cfg --- src/tools/other/pb2nc/pb2nc.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index ddab9a5e8c..471e02f7b7 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -101,6 +101,7 @@ struct derive_var_cfg { int var_index; ConcatString var_name; derive_var_cfg(ConcatString _var_name); + derive_var_cfg &operator=(const derive_var_cfg &a) noexcept; }; //////////////////////////////////////////////////////////////////////// @@ -409,11 +410,23 @@ static void cleanup_hdr_typ(char *hdr_typ, bool is_prepbufr=false); //////////////////////////////////////////////////////////////////////// + derive_var_cfg::derive_var_cfg(ConcatString _var_name) { var_index = bad_data_int; var_name = _var_name; } +//////////////////////////////////////////////////////////////////////// + +derive_var_cfg &derive_var_cfg::operator=(const derive_var_cfg &a) noexcept { + if ( this != &a ) { + var_index = a.var_index; + var_name = a.var_name; + } + return *this; +} + + //////////////////////////////////////////////////////////////////////// From 5f8d7945daa8eee6bfbf12bf1c511db1986894bc Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 18 May 2023 13:01:47 -0600 Subject: [PATCH 18/39] #2521 Refactoring to reduce the depth of if/for --- src/basic/vx_cal/is_leap_year.cc | 113 ++++++++++++++++++------------- 1 file changed, 66 insertions(+), 47 deletions(-) diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index 1cd567a0ae..d77526a0ba 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -90,6 +90,67 @@ void increase_one_month(int &year, int &month) { //////////////////////////////////////////////////////////////////////// +void adjuste_day_for_month_year_units(int &day, int &month, int &year, double time_fraction) { + // Compute remaining days + bool day_adjusted = false; + double day_offset = 0.; + const char *method_name = "adjuste_day() -->"; + + if (day == 1) { + if (abs(time_fraction-0.5) < DAY_EPSILON) day = 15; + else { + day_offset = time_fraction * 30; + day += (int)(day_offset + 0.5); + } + } + else { + day_offset = time_fraction * 30; + unixtime time_value_ut = (int)day_offset; + day += (int)(time_value_ut + 0.5); + if (day > 30) { + day -= 30; + increase_one_month(year, month); + } + } + + int day_org = day; + int max_day = monthly_days[month-1]; + if (day > max_day) { + day = max_day; + if (month == 2 && is_leap_year(year)) day = 29; + day_adjusted = (day_org != day); + } + + if (day_adjusted) { + mlog << Debug(2) << method_name << "adjusted day " << day_org + << " to " << day << " for " << year << "-" << month << "\n"; + } + +} + +//////////////////////////////////////////////////////////////////////// + +void adjuste_day_for_day_units(int &day, int &month, int &year, double time_value) { + int day_offset = day + (int)time_value; + if (day_offset < 0) { + while (day_offset < 0) { + decrease_one_month(year, month); + day_offset += monthly_days[month-1]; + } + } + else { + while (day_offset > monthly_days[month-1]) { + day_offset -= monthly_days[month-1]; + increase_one_month(year, month); + } + } + day = day_offset; + if (day == 0) day = 1; + +} + +//////////////////////////////////////////////////////////////////////// + #define SEC_MONTH (86400*30) #define SEC_YEAR (86400*30*12) static const double DAY_EPSILON = 0.00002; @@ -117,6 +178,7 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, unix_to_mdyhms(base_unixtime, month, day, year, hour, minute, second); + // Update year and compute remaining months int month_offset; double day_offset; if (sec_per_unit == SEC_YEAR) { @@ -127,42 +189,13 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, } else month_offset = (int)time_value_ut; + // Update month for (int idx=0; idx 30) { - day -= 30; - increase_one_month(year, month); - } - } - - int day_org = day; - bool day_adjusted = false; - int max_day = monthly_days[month-1]; - if (day > max_day) { - day = max_day; - day_adjusted = true; - if (month == 2 && is_leap_year(year)) { - if (day_org == 29) day_adjusted = false; - day = 29; - } - } + // Compute remaining days + adjuste_day_for_month_year_units(day, month, year, time_fraction); ut = mdyhms_to_unix(month, day, year, hour, minute, second); - if (day_adjusted) { - mlog << Debug(2) << method_name << "adjusted day " << day_org - << " to " << day << " for " << year << "-" << month << "\n"; - } } else if (!no_leap || sec_per_unit != 86400) { // seconds, minute, hours, and day unit with leap year @@ -177,21 +210,7 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, } else { // no_leap year && unit = day unix_to_mdyhms(base_unixtime, month, day, year, hour, minute, second); - int day_offset = day + (int)time_value; - if (day_offset < 0) { - while (day_offset < 0) { - decrease_one_month(year, month); - day_offset += monthly_days[month-1]; - } - } - else { - while (day_offset > monthly_days[month-1]) { - day_offset -= monthly_days[month-1]; - increase_one_month(year, month); - } - } - day = day_offset; - if (day == 0) day = 1; + adjuste_day_for_day_units(day, month, year, time_value); ut = mdyhms_to_unix(month, day, year, hour, minute, second); if (time_fraction > (1-TIME_EPSILON) ) ut += (unixtime)sec_per_unit; else if (time_fraction > TIME_EPSILON) ut += (unixtime)(time_fraction * sec_per_unit); From 564f572e3431048403f6555562ca43b598d01bf8 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 18 May 2023 13:08:30 -0600 Subject: [PATCH 19/39] #2521 Refactoring to reduce the depth of if/for --- src/basic/vx_cal/is_leap_year.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index d77526a0ba..5c799d3b39 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -24,6 +24,12 @@ using namespace std; +//////////////////////////////////////////////////////////////////////// + +#define SEC_MONTH (86400*30) +#define SEC_YEAR (86400*30*12) +static const double DAY_EPSILON = 0.00002; + //////////////////////////////////////////////////////////////////////// @@ -151,10 +157,6 @@ void adjuste_day_for_day_units(int &day, int &month, int &year, double time_valu //////////////////////////////////////////////////////////////////////// -#define SEC_MONTH (86400*30) -#define SEC_YEAR (86400*30*12) -static const double DAY_EPSILON = 0.00002; - unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, double time_value, bool no_leap) { int month; From b69d834903d3eb796f1fa3a2db3f4d57e68ac9fb Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Thu, 18 May 2023 13:22:22 -0600 Subject: [PATCH 20/39] #5221 Changed strtok to strtok_r --- src/basic/vx_util/string_fxns.cc | 17 ++------- src/basic/vx_util/thresh_array.cc | 12 +++---- .../vx_analysis_util/analysis_utils.cc | 16 +++------ src/libcode/vx_analysis_util/stat_job.cc | 9 ++--- src/libcode/vx_statistics/met_stats.cc | 36 ++++++++----------- 5 files changed, 29 insertions(+), 61 deletions(-) diff --git a/src/basic/vx_util/string_fxns.cc b/src/basic/vx_util/string_fxns.cc index cfbf1e5861..1d07c1a865 100644 --- a/src/basic/vx_util/string_fxns.cc +++ b/src/basic/vx_util/string_fxns.cc @@ -188,6 +188,7 @@ int num_tokens(const char *test_str, const char *separator) { int n = 0; char *temp_str = (char *) nullptr; + char *temp_ptr = (char *) nullptr; char *c = (char *) nullptr; const char *method_name = "num_tokens() -> "; @@ -208,21 +209,7 @@ int num_tokens(const char *test_str, const char *separator) // // Compute the number of tokens in the string // - //c = strtok(temp_str1.c_str(), separator); - c = strtok(temp_str, separator); - - // - // Check for an empty string - // - if(c) { - n = 1; - - // - // Parse remaining tokens - // - // - while((c = strtok(0, separator)) != nullptr) n++; - } + while((c = strtok_r(temp_str, separator, &temp_ptr)) != nullptr) n++; } diff --git a/src/basic/vx_util/thresh_array.cc b/src/basic/vx_util/thresh_array.cc index 19716163cb..a5063de78f 100644 --- a/src/basic/vx_util/thresh_array.cc +++ b/src/basic/vx_util/thresh_array.cc @@ -267,27 +267,23 @@ void ThreshArray::set(const SingleThresh &st) { //////////////////////////////////////////////////////////////////////// void ThreshArray::parse_thresh_str(const char *thresh_str) { - char *c = (char *) 0; - char *lp = (char *) 0; + char *c = (char *) nullptr; + char *temp_ptr = (char *) nullptr; const char delim [] = " "; const char *method_name = "ThreshArray::parse_thresh_str()"; char *line = m_strcpy2(thresh_str, method_name); if (line) { - lp = line; - - while((c = strtok(lp, delim)) != nullptr ) { + while((c = strtok_r(line, delim, &temp_ptr)) != nullptr ) { add(c); - lp = (char *) 0; } } - if(line) { delete [] line; line = (char *) 0; } - lp = (char *) 0; + if(line) { delete [] line; line = (char *) nullptr; } return; } diff --git a/src/libcode/vx_analysis_util/analysis_utils.cc b/src/libcode/vx_analysis_util/analysis_utils.cc index 3d09c9630d..0c7023d239 100644 --- a/src/libcode/vx_analysis_util/analysis_utils.cc +++ b/src/libcode/vx_analysis_util/analysis_utils.cc @@ -31,9 +31,9 @@ StringArray parse_line(const char * line) StringArray a; const char * delim = " "; -char * c = (char *) 0; -char * lp = (char *) 0; -char * L = (char *) 0; +char * c = (char *) nullptr; +char * L = (char *) nullptr; +char *temp_ptr = (char *) nullptr; const char *method_name = "parse_line() -> "; // // copy the line @@ -45,18 +45,10 @@ L = m_strcpy2(line, method_name); // tokenize the line // -lp = L; - -while ( 1 ) { - - c = strtok(lp, delim); - - if ( !c ) break; +while((c = strtok_r(L, delim, &temp_ptr)) != nullptr) { a.add(c); - lp = (char *) 0; - } diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index 1addf4dfdc..515200d984 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -1065,9 +1065,10 @@ double STATAnalysisJob::get_column_double(const STATLine &L, //////////////////////////////////////////////////////////////////////// void STATAnalysisJob::parse_job_command(const char *jobstring) { - char *line = (char *) 0; - char *c = (char *) 0; - char *lp = (char *) 0; + char *line = (char *)nullptr; + char *c = (char *)nullptr; + char *lp = (char *)nullptr; + char *temp_ptr = (char *)nullptr; const char delim [] = " "; ConcatString col_name; StringArray col_value; @@ -1094,7 +1095,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { // // Parse the command line entries into a StringArray object // - while((c = strtok(lp, delim)) != nullptr) { + while((c = strtok_r(lp, delim, &temp_ptr)) != nullptr) { // Skip newline characters if(strcmp(c, "\n") == 0) continue; diff --git a/src/libcode/vx_statistics/met_stats.cc b/src/libcode/vx_statistics/met_stats.cc index d0483c0ac6..05a0693434 100644 --- a/src/libcode/vx_statistics/met_stats.cc +++ b/src/libcode/vx_statistics/met_stats.cc @@ -3259,8 +3259,9 @@ SSIDXData &SSIDXData::operator=(const SSIDXData &a) noexcept { int parse_message_type(const char *msg_typ_str, char **&msg_typ_arr) { char tmp_str[max_str_len + 1]; - char *c = (char *) 0; - int n, i; + char *c = (char *) nullptr; + char *temp_ptr = (char *) nullptr; + int n; const char *method_name = "parse_message_type() "; // Compute the number of tokens in the string based on " " @@ -3275,14 +3276,11 @@ int parse_message_type(const char *msg_typ_str, char **&msg_typ_arr) { // Initialize the temp string for use in tokenizing m_strncpy(tmp_str, msg_typ_str, max_str_len, method_name); - // Tokenize the string and store the double values - c = strtok(tmp_str, " "); - msg_typ_arr[0] = m_strcpy2(c, method_name, "msg_typ_arr[0]"); - char a_var_name[512+1]; // Parse remaining tokens - for(i=1; i Date: Wed, 7 Jun 2023 16:02:12 -0600 Subject: [PATCH 21/39] #2521 Cast to char --- src/basic/vx_cal/unix_to_mdyhms.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/basic/vx_cal/unix_to_mdyhms.cc b/src/basic/vx_cal/unix_to_mdyhms.cc index 0fd9ee5e29..dd3de3a864 100644 --- a/src/basic/vx_cal/unix_to_mdyhms.cc +++ b/src/basic/vx_cal/unix_to_mdyhms.cc @@ -17,6 +17,8 @@ #include #include +#define EXCLUDE_CONST_UNIX_TO_MDYHMS + #include "vx_cal.h" @@ -38,7 +40,7 @@ const char * day_name[] = { "Saturday", // 6 "Sunday" // 7 - }; +}; const char * short_day_name[] = { @@ -53,7 +55,7 @@ const char * short_day_name[] = { "Sat", // 6 "Sun" // 7 - }; +}; const char * month_name[] = { @@ -107,7 +109,8 @@ int str_len = strlen(month_str); char t_month_str[str_len + 1]; for (int idx=0; idx Date: Wed, 7 Jun 2023 16:03:44 -0600 Subject: [PATCH 22/39] #2521Added explicit to construcore --- src/basic/vx_log/logger.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/basic/vx_log/logger.h b/src/basic/vx_log/logger.h index 7222c02e04..529ffefc1b 100644 --- a/src/basic/vx_log/logger.h +++ b/src/basic/vx_log/logger.h @@ -51,7 +51,7 @@ class MsgLevel MsgLevel(); ~MsgLevel(); - MsgLevel(int); + explicit MsgLevel(int); MsgLevel(const MsgLevel &); MsgLevel & operator=(const MsgLevel &); @@ -148,7 +148,7 @@ class LoggerDebug { LoggerDebug(); ~LoggerDebug(); - LoggerDebug(int); + explicit LoggerDebug(int); LoggerDebug(const LoggerDebug &); LoggerDebug & operator=(const LoggerDebug &); @@ -291,7 +291,7 @@ inline ConcatString Logger::log_filename() const { return (LogFilename); } inline int Logger::verbosity_level() const { return (VerbosityLevel); } -inline bool Logger::is_open() const { return (out != 0); } +inline bool Logger::is_open() const { return (out != nullptr); } ////////////////////////////////////////////////////////////////// From 26ffda30ad8ae1f673d973c009389e408aaaaf1a Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:03:58 -0600 Subject: [PATCH 23/39] #2521Added explicit to construcore --- src/basic/vx_log/indent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/vx_log/indent.h b/src/basic/vx_log/indent.h index e79c1f3da0..a0b6896de7 100644 --- a/src/basic/vx_log/indent.h +++ b/src/basic/vx_log/indent.h @@ -45,7 +45,7 @@ class Indent { public: Indent(); - Indent(int); // depth + explicit Indent(int); // depth ~Indent(); Indent(const Indent &); Indent & operator=(const Indent &); From 305cf341ec1d2015b595b921241566fbff335f70 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:15:16 -0600 Subject: [PATCH 24/39] #2521 USe nullptr instead of 0 --- src/basic/vx_config/calculator.cc | 4 ++-- src/basic/vx_config/config_file.cc | 2 +- src/basic/vx_config/config_util.cc | 18 ++++++++--------- src/basic/vx_config/config_util.h | 6 +++--- .../vx_config/configobjecttype_to_string.cc | 2 +- src/basic/vx_config/dictionary.cc | 20 +++++++++---------- src/basic/vx_log/concat_string.h | 14 ++++++------- src/basic/vx_log/str_wrappers.h | 6 +++--- .../other/plot_data_plane/plot_data_plane.cc | 13 ++++++------ 9 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/basic/vx_config/calculator.cc b/src/basic/vx_config/calculator.cc index d3e10d1566..a87cdf25c1 100644 --- a/src/basic/vx_config/calculator.cc +++ b/src/basic/vx_config/calculator.cc @@ -42,7 +42,7 @@ Calculator::Calculator() { -dict_stack = 0; +dict_stack = nullptr; AllocInc = 100; @@ -56,7 +56,7 @@ Calculator::~Calculator() { -dict_stack = 0; +dict_stack = nullptr; } diff --git a/src/basic/vx_config/config_file.cc b/src/basic/vx_config/config_file.cc index a292df3cee..490a0d6d9b 100644 --- a/src/basic/vx_config/config_file.cc +++ b/src/basic/vx_config/config_file.cc @@ -315,7 +315,7 @@ DictionaryStack DS(*this); ConcatString temp_filename = get_tmp_dir(); temp_filename << "/" << "met_config"; -temp_filename = make_temp_file_name(temp_filename.c_str(), 0); +temp_filename = make_temp_file_name(temp_filename.c_str(), nullptr); recursive_envs(name, temp_filename.c_str()); diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 01a078dd27..0fae12e991 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -918,7 +918,7 @@ NumArray parse_conf_eclv_points(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// TimeSummaryInfo parse_conf_time_summary(Dictionary *dict) { - Dictionary *ts_dict = (Dictionary *) 0; + Dictionary *ts_dict = (Dictionary *) nullptr; TimeSummaryInfo info; bool is_correct_type = false; @@ -1012,7 +1012,7 @@ TimeSummaryInfo parse_conf_time_summary(Dictionary *dict) { void parse_add_conf_key_value_map( Dictionary *dict, const char *conf_key_map_name, map *m) { - Dictionary *map_dict = (Dictionary *) 0; + Dictionary *map_dict = (Dictionary *) nullptr; ConcatString key, val; if(!dict) { @@ -1047,10 +1047,10 @@ void parse_add_conf_key_value_map( map parse_conf_key_value_map( Dictionary *dict, const char *conf_key_map_name, const char *caller) { - Dictionary *map_dict = (Dictionary *) 0; + Dictionary *map_dict = (Dictionary *) nullptr; map m; ConcatString key, val; - const char *method_name = (0 != caller) ? caller : "parse_conf_key_value_map() -> "; + const char *method_name = (nullptr != caller) ? caller : "parse_conf_key_value_map() -> "; if(!dict) { mlog << Error << "\n" << method_name << "empty dictionary!\n\n"; @@ -1089,7 +1089,7 @@ map parse_conf_key_values_map( map cs_map; map::const_iterator it; map sa_map; - const char *method_name = (0 != caller) ? caller : "parse_conf_key_values_map() -> "; + const char *method_name = (nullptr != caller) ? caller : "parse_conf_key_values_map() -> "; cs_map = parse_conf_key_value_map(dict, conf_key, method_name); @@ -1146,7 +1146,7 @@ map parse_conf_key_convert_map( ConcatString key; UserFunc_1Arg fx; map m; - const char *method_name = (0 != caller) ? caller : "parse_conf_key_convert_map() -> "; + const char *method_name = (nullptr != caller) ? caller : "parse_conf_key_convert_map() -> "; if(!dict) { mlog << Error << "\n" << method_name << "empty dictionary!\n\n"; @@ -1303,7 +1303,7 @@ BootInfo parse_conf_boot(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { - Dictionary *regrid_dict = (Dictionary *) 0; + Dictionary *regrid_dict = (Dictionary *) nullptr; RegridInfo info; int v; @@ -1842,7 +1842,7 @@ NbrhdInfo &NbrhdInfo::operator=(const NbrhdInfo &a) noexcept { /////////////////////////////////////////////////////////////////////////////// NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { - Dictionary *nbrhd_dict = (Dictionary *) 0; + Dictionary *nbrhd_dict = (Dictionary *) nullptr; NbrhdInfo info; int i; int v; @@ -3289,7 +3289,7 @@ NormalizeType parse_conf_normalize(Dictionary *dict) { void python_compile_error(const char *caller) { - const char *method_name = (0 != caller) ? caller : "python_compile_error() -> "; + const char *method_name = (nullptr != caller) ? caller : "python_compile_error() -> "; mlog << Error << "\n" << method_name << "Support for Python has not been compiled!\n" diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index a8cc99d1f0..e31f4eb81e 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -52,7 +52,7 @@ extern NumArray parse_conf_eclv_points(Dictionary *dict); extern ClimoCDFInfo parse_conf_climo_cdf(Dictionary *dict); extern TimeSummaryInfo parse_conf_time_summary(Dictionary *dict); extern std::map parse_conf_key_value_map( - Dictionary *dict, const char *conf_key_map_name, const char *caller=0); + Dictionary *dict, const char *conf_key_map_name, const char *caller=nullptr); extern void parse_add_conf_key_value_map( Dictionary *dict, const char *conf_key_map_name, std::map *m); extern std::map @@ -66,7 +66,7 @@ extern std::map parse_conf_obs_to_qc_map(Dictionary *dict); extern std::map parse_conf_key_convert_map( - Dictionary *dict, const char *conf_key_map_name, const char *caller=0); + Dictionary *dict, const char *conf_key_map_name, const char *caller=nullptr); extern BootInfo parse_conf_boot(Dictionary *dict); extern RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out = default_dictionary_error_out); extern InterpInfo parse_conf_interp(Dictionary *dict, const char *); @@ -139,7 +139,7 @@ extern ConcatString wavelettype_to_string(WaveletType); extern int parse_conf_percentile(Dictionary *dict); -extern void python_compile_error(const char *caller=0); +extern void python_compile_error(const char *caller=nullptr); //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index facee7dfda..3b1c3902a3 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -39,7 +39,7 @@ ConcatString configobjecttype_to_string(const ConfigObjectType t) { -const char * s = (const char *) 0; +const char * s = (const char *) nullptr; switch ( t ) { diff --git a/src/basic/vx_config/dictionary.cc b/src/basic/vx_config/dictionary.cc index a082cbdbd7..50bedb809b 100644 --- a/src/basic/vx_config/dictionary.cc +++ b/src/basic/vx_config/dictionary.cc @@ -445,7 +445,7 @@ void DictionaryEntry::set_icodevector (const IcodeVector & _icv) { -if ( v ) { delete v; v = 0; } +if ( v ) { delete v; v = nullptr; } v = new IcodeVector; @@ -668,8 +668,8 @@ Dict = new Dictionary; // int j; -const DictionaryEntry * E = (const DictionaryEntry *) 0; -Dictionary * D = (Dictionary *) 0; +const DictionaryEntry * E = (const DictionaryEntry *) nullptr; +Dictionary * D = (Dictionary *) nullptr; Dictionary & DD = *Dict; for (j=0; j<(Dict->n_entries()); ++j) { @@ -1317,7 +1317,7 @@ E = D->lookup_simple(stub, search_parent); if ( E ) { - LastLookupStatus = (E != 0); + LastLookupStatus = (E != nullptr); return E; } @@ -1326,7 +1326,7 @@ if ( E ) { // try parent // -E = (const DictionaryEntry *) 0; +E = (const DictionaryEntry *) nullptr; if ( search_parent ) { @@ -1363,7 +1363,7 @@ for (int j=0; jName == name ) { - LastLookupStatus = (e[j] != 0); + LastLookupStatus = (e[j] != nullptr); return e[j]; } @@ -1844,7 +1844,7 @@ StringArray Dictionary::lookup_string_array(const char * name, { const DictionaryEntry * Entry = lookup(name, search_parent); -const Dictionary * Dict = (const Dictionary *) 0; +const Dictionary * Dict = (const Dictionary *) nullptr; bool is_correct_type = false; StringArray array; @@ -1998,7 +1998,7 @@ ThreshArray Dictionary::lookup_thresh_array(const char * name, { const DictionaryEntry * Entry = lookup(name, search_parent); -const Dictionary * Dict = (const Dictionary *) 0; +const Dictionary * Dict = (const Dictionary *) nullptr; bool is_correct_type = false; ThreshArray array; @@ -2465,7 +2465,7 @@ void DictionaryStack::assign(const DictionaryStack & s) clear(); -if ( s.Nelements == 0 ) return; +if ( s.Nelements == nullptr ) return; int j; @@ -2606,7 +2606,7 @@ const Dictionary * DictionaryStack::top() const { -if ( Nelements == 0 ) return ( (const Dictionary *) 0 ); +if ( Nelements == 0 ) return ( (const Dictionary *) nullptr ); return D[Nelements - 1]; diff --git a/src/basic/vx_log/concat_string.h b/src/basic/vx_log/concat_string.h index 1f5bb7fa64..112fa35c82 100644 --- a/src/basic/vx_log/concat_string.h +++ b/src/basic/vx_log/concat_string.h @@ -111,7 +111,7 @@ class ConcatString { const std::string & string() const; - const std::string contents(const char *str = 0) const; // returns str or "(nul)" if the string is empty + const std::string contents(const char *str = nullptr) const; // returns str or "(nul)" if the string is empty int length() const; // not including trailing nul @@ -192,20 +192,20 @@ class ConcatString { //////////////////////////////////////////////////////////////////////// -inline const char * ConcatString::text() const { return ( s ? s->c_str() : 0); } -inline const char * ConcatString::c_str() const { return ( s ? s->c_str() : 0); } +inline const char * ConcatString::text() const { return ( s ? s->c_str() : nullptr); } +inline const char * ConcatString::c_str() const { return ( s ? s->c_str() : nullptr); } inline const std::string & ConcatString::string() const { return ( *s ); } -inline int ConcatString::length() const { return ( (int) (s->length()) ); } +inline int ConcatString::length() const { return (int) (s ? s->length() : 0); } -inline int ConcatString::precision() const { return ( Precision ); } +inline int ConcatString::precision() const { return Precision; } -inline const char * ConcatString::float_format() const { return ( FloatFormat ); } +inline const char * ConcatString::float_format() const { return FloatFormat; } inline bool ConcatString::empty() const { return ( s ? s->empty() : true ); } inline bool ConcatString::nonempty() const { return ( s ? !s->empty() : false ); } -inline ConcatString::operator const std::string () const { return ( s ? *s : 0 ); } +inline ConcatString::operator const std::string () const { return ( s ? *s : nullptr ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/str_wrappers.h b/src/basic/vx_log/str_wrappers.h index 568833b573..6cbc2aea19 100644 --- a/src/basic/vx_log/str_wrappers.h +++ b/src/basic/vx_log/str_wrappers.h @@ -20,11 +20,11 @@ extern int m_strlen(const char *str); extern void m_strcpy(char *to_str, const char *from_str, const char *method_name, - const char *extra_msg=(char *)0); + const char *extra_msg=(char *)nullptr); extern char *m_strcpy2(const char *from_str, const char *method_name, - const char *extra_msg=(char *)0); + const char *extra_msg=(char *)nullptr); extern void m_strncpy(char *to_str, const char *from_str, const int buf_len, - const char *method_name, const char *extra_msg=(char *)0, + const char *method_name, const char *extra_msg=(char *)nullptr, bool truncate=false); extern void m_rstrip(char *str_buf, const int buf_len=-1, bool find_white_ch=true); diff --git a/src/tools/other/plot_data_plane/plot_data_plane.cc b/src/tools/other/plot_data_plane/plot_data_plane.cc index e4dfe37a53..890dc1d148 100644 --- a/src/tools/other/plot_data_plane/plot_data_plane.cc +++ b/src/tools/other/plot_data_plane/plot_data_plane.cc @@ -73,7 +73,8 @@ static ConcatString FieldString; static ConcatString ColorTableName; static ConcatString TitleString; -static double PlotRangeMin = 0.0, PlotRangeMax = 0.0; +static double PlotRangeMin = 0.0; +static double PlotRangeMax = 0.0; //////////////////////////////////////////////////////////////////////// @@ -89,9 +90,9 @@ int met_main(int argc, char * argv[]) { program_name = get_short_name(argv[0]); - Met2dDataFile * met_ptr = (Met2dDataFile * ) 0; + Met2dDataFile * met_ptr = (Met2dDataFile * ) nullptr; Met2dDataFileFactory m_factory; - VarInfo * var_ptr = (VarInfo * ) 0; + VarInfo * var_ptr = (VarInfo * ) nullptr; VarInfoFactory v_factory; DataPlane data_plane; Grid grid; @@ -205,14 +206,14 @@ int met_main(int argc, char * argv[]) { // // clean up // - if(met_ptr) { delete met_ptr; met_ptr = 0; } - if(var_ptr) { delete var_ptr; var_ptr = 0; } + if(met_ptr) { delete met_ptr; met_ptr = nullptr; } + if(var_ptr) { delete var_ptr; var_ptr = nullptr; } #ifdef WITH_PYTHON GP.finalize(); #endif - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// From 8ad40acab77d83ad1f3cc1e892cfcdadc9e5b974 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:16:18 -0600 Subject: [PATCH 25/39] #2521 Added explicit to non default constructor --- src/basic/vx_config/calculator.h | 2 +- src/basic/vx_config/config_file.h | 4 ++-- src/basic/vx_util/GridOffset.h | 2 +- src/basic/vx_util/GridPoint.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/basic/vx_config/calculator.h b/src/basic/vx_config/calculator.h index b9863e0345..b21c67edfc 100644 --- a/src/basic/vx_config/calculator.h +++ b/src/basic/vx_config/calculator.h @@ -49,7 +49,7 @@ class Calculator : public NumberStack { public: Calculator(); - Calculator(int); + explicit Calculator(int); ~Calculator(); Calculator(const Calculator &); Calculator & operator=(const Calculator &); diff --git a/src/basic/vx_config/config_file.h b/src/basic/vx_config/config_file.h index 03e0eb47f7..7989e98c3a 100644 --- a/src/basic/vx_config/config_file.h +++ b/src/basic/vx_config/config_file.h @@ -44,9 +44,9 @@ class MetConfig : public Dictionary { ~MetConfig(); MetConfig(const MetConfig &); MetConfig & operator=(const MetConfig &); - MetConfig(const char *filename); + explicit MetConfig(const char *filename); - void clear(); + void clear() override; void dump(std::ostream &, int = 0) const; diff --git a/src/basic/vx_util/GridOffset.h b/src/basic/vx_util/GridOffset.h index fe2a6a2cdd..ec37bf1c3c 100644 --- a/src/basic/vx_util/GridOffset.h +++ b/src/basic/vx_util/GridOffset.h @@ -38,7 +38,7 @@ class GridOffset GridOffset(int x_offset = 0, int y_offset = 0); GridOffset(const GridOffset& rhs); - GridOffset(const GridOffset* rhs); + explicit GridOffset(const GridOffset* rhs); // Destructor diff --git a/src/basic/vx_util/GridPoint.h b/src/basic/vx_util/GridPoint.h index a9f16ea3a9..d5003671cf 100644 --- a/src/basic/vx_util/GridPoint.h +++ b/src/basic/vx_util/GridPoint.h @@ -37,7 +37,7 @@ class GridPoint // Constructors GridPoint(int x = 0, int y = 0); - GridPoint(GridPoint *point); + explicit GridPoint(GridPoint *point); GridPoint(GridPoint *point, GridOffset *offset); // Destructor From cf9e9a2c1e06ba080e7dfee93f5212d75aa8a9f2 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:17:04 -0600 Subject: [PATCH 26/39] #2521 Release allocated memory --- src/tools/other/ioda2nc/ioda2nc.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/other/ioda2nc/ioda2nc.cc b/src/tools/other/ioda2nc/ioda2nc.cc index 4b48cbaf9e..4e77447176 100644 --- a/src/tools/other/ioda2nc/ioda2nc.cc +++ b/src/tools/other/ioda2nc/ioda2nc.cc @@ -1008,8 +1008,11 @@ void process_ioda_file(int i_pb) { delete [] hdr_lat_arr; delete [] hdr_lon_arr; delete [] hdr_elv_arr; + delete [] hdr_time_arr; + delete [] hdr_vld_block; delete [] obs_pres_arr; delete [] obs_hght_arr; + if (hdr_msg_types) delete [] hdr_msg_types; if (hdr_station_ids) delete [] hdr_station_ids; if (nullptr != hdr_msg_types2) { @@ -1025,7 +1028,6 @@ void process_ioda_file(int i_pb) { delete [] hdr_vld_block2; } - delete [] hdr_vld_block; for(idx=0; idx Date: Wed, 7 Jun 2023 16:20:18 -0600 Subject: [PATCH 27/39] #2521 applied constexpr --- src/basic/vx_config/number_stack.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/vx_config/number_stack.cc b/src/basic/vx_config/number_stack.cc index 2e8cf1ae94..c49ea25a03 100644 --- a/src/basic/vx_config/number_stack.cc +++ b/src/basic/vx_config/number_stack.cc @@ -33,7 +33,7 @@ using namespace std; //////////////////////////////////////////////////////////////////////// -static int default_ns_alloc_inc = 100; // default value +constexpr int default_ns_alloc_inc = 100; // default value From 71ba7bec4d07a34b38777a12c62ebced80ce476b Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:22:22 -0600 Subject: [PATCH 28/39] #2521 Excluded three vaiables which are declared at basic/vx_cal/unix_to_mdyhms.cc --- src/basic/vx_cal/vx_cal.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/basic/vx_cal/vx_cal.h b/src/basic/vx_cal/vx_cal.h index 0464836314..1784cfb5d1 100644 --- a/src/basic/vx_cal/vx_cal.h +++ b/src/basic/vx_cal/vx_cal.h @@ -160,6 +160,8 @@ extern bool is_hh(const char * text); //////////////////////////////////////////////////////////////////////// +#ifndef EXCLUDE_CONST_UNIX_TO_MDYHMS + extern const char * day_name[]; extern const char * short_day_name[]; @@ -168,6 +170,7 @@ extern const char * month_name[]; extern const char * short_month_name[]; +#endif //////////////////////////////////////////////////////////////////////// From b5cc588e6005f91540157a7322bf7c2a8b5fe0a5 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:23:05 -0600 Subject: [PATCH 29/39] #2521 Applied explicit & virtual --- src/basic/vx_config/dictionary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/basic/vx_config/dictionary.h b/src/basic/vx_config/dictionary.h index 23c25899a4..a8e70635e7 100644 --- a/src/basic/vx_config/dictionary.h +++ b/src/basic/vx_config/dictionary.h @@ -220,7 +220,7 @@ class Dictionary { Dictionary(const Dictionary &); Dictionary & operator=(const Dictionary &); - void clear(); + virtual void clear(); virtual void dump(std::ostream &, int = 0) const; @@ -379,10 +379,10 @@ class DictionaryStack { public: - DictionaryStack(Dictionary &); + explicit DictionaryStack(Dictionary &); ~DictionaryStack(); - void clear(); + virtual void clear(); void dump(std::ostream &, int = 0) const; From 8c33179633e9bee661dbbb2a0fc07daf06a0cdfe Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 7 Jun 2023 16:24:13 -0600 Subject: [PATCH 30/39] #2521 Fixed code smells --- src/tools/other/pb2nc/pb2nc.cc | 411 ++++++++++++++++++--------------- 1 file changed, 222 insertions(+), 189 deletions(-) diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index 471e02f7b7..b2c571590e 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -59,7 +59,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -74,7 +73,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "pb2nc_conf_info.h" @@ -95,12 +93,15 @@ using namespace netCDF; #include "nc_point_obs_out.h" #include "nc_summary.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// struct derive_var_cfg { int var_index; ConcatString var_name; - derive_var_cfg(ConcatString _var_name); + explicit derive_var_cfg(ConcatString _var_name); derive_var_cfg &operator=(const derive_var_cfg &a) noexcept; }; @@ -115,8 +116,8 @@ static const char * default_config_filename = "MET_BASE/config/PB2NCConfig_defau static const char *program_name = "pb2nc"; static const char *not_assigned = "not_assigned"; -static const float fill_value = -9999.f; -static const int missing_cycle_minute = -1; +constexpr static float fill_value = -9999.f; +constexpr static int missing_cycle_minute = -1; // Constants used to interface to Fortran subroutines @@ -141,39 +142,38 @@ static const int COUNT_THRESHOLD = 16; static const int file_unit = 11; // 2nd file unit number for opening the PrepBufr file static const int dump_unit = 22; -static int msg_typ_ret[n_vld_msg_typ]; // Grib codes corresponding to the variable types -static const int var_gc[mxr8vt] = { +const std::array var_gc = { pres_grib_code, spfh_grib_code, tmp_grib_code, hgt_grib_code, ugrd_grib_code, vgrd_grib_code }; -static int bufr_var_code[mxr8vt]; +static std::array bufr_var_code; // Number of variable types which may be derived -static const int n_derive_gc = 6; +constexpr static int n_derive_gc = 6; // Listing of grib codes for variable types which may be derived -static const int derive_gc[n_derive_gc] = { +const std::array derive_gc = { dpt_grib_code, wdir_grib_code, wind_grib_code, rh_grib_code, mixr_grib_code, prmsl_grib_code }; // The fortran code is hard-coded with 200 levels -#define MAX_CAPE_VALUE 10000 -#define MAX_CAPE_LEVEL 200 -#define CAPE_INPUT_VARS 3 +constexpr int MAX_CAPE_VALUE = 10000; +constexpr int MAX_CAPE_LEVEL = 200; +constexpr int CAPE_INPUT_VARS = 3; static float cape_data_pres[MAX_CAPE_LEVEL]; static float cape_data_temp[MAX_CAPE_LEVEL]; static float cape_data_spfh[MAX_CAPE_LEVEL]; static float static_dummy_200[MAX_CAPE_LEVEL]; static float static_dummy_201[MAX_CAPE_LEVEL+1]; -#define ROG 287.04 -#define MAX_PBL 10000 -#define MAX_PBL_LEVEL 256 -#define PBL_DEBUG_LEVEL 8 +//#define ROG 287.04 +constexpr int MAX_PBL = 10000; +constexpr int MAX_PBL_LEVEL = 256; +constexpr int PBL_DEBUG_LEVEL = 8; static bool IGNORE_Q_PBL = true; static bool IGNORE_Z_PBL = true; static bool USE_LOG_INTERPOLATION = true; @@ -207,7 +207,8 @@ static PB2NCConfInfo conf_info; static MetNcPointObsOut nc_point_obs; // Beginning and ending retention times -static unixtime valid_beg_ut, valid_end_ut; +static unixtime valid_beg_ut; +static unixtime valid_end_ut; // Number of PrepBufr messages to process from the command line static int nmsg = -1; @@ -411,9 +412,183 @@ static void cleanup_hdr_typ(char *hdr_typ, bool is_prepbufr=false); //////////////////////////////////////////////////////////////////////// -derive_var_cfg::derive_var_cfg(ConcatString _var_name) { +void read_bufr_vars(bool is_airnow, bool is_prepbufr, int file_unit, int nlev_max_req, + int obs_hid, float obs_pres, float obs_hgt, + const float hdr_lat, const float hdr_lon, const float hdr_elv, + const unixtime hdr_vld_ut, const char *hdr_typ, + const ConcatString &hdr_sid, + int &n_hdr_obs, int &n_file_obs, + StringArray &variables_big_nlevels) { + int i_ret; + int buf_nlev; + int airnow_nlev = 0; + float obs_arr[OBS_ARRAY_LEN]; + int quality_mark = bad_data_int; + const char *method_name = "read_bufr_vars() ->"; + + obs_arr[0] = obs_hid; + obs_arr[2] = obs_pres; + obs_arr[3] = obs_hgt; + + if (is_airnow) { + int tmp_ret; + for (int index1=0; index1= nlev2) continue; + + buf_nlev = nlev2; + if (nlev2 > mxr8lv) { + buf_nlev = mxr8lv; + if (!variables_big_nlevels.has(var_name, false)) { + mlog << Warning << "\n" << method_name + << "Too many vertical levels (" << nlev2 + << ") for " << var_name + << ". Ignored the vertical levels above " << mxr8lv << ".\n\n"; + variables_big_nlevels.add(var_name); + } + } + mlog << Debug(10) << "var: " << var_name << " nlev2: " << nlev2 + << ", vIdx: " << vIdx << ", obs_data_idx: " + << nc_point_obs.get_obs_index() << ", nlev: " << nlev << "\n"; + // Search through the vertical levels + for(int lv=0; lv conf_info.end_level) break; + + // If the pressure level is not valid, continue to the next level + if (is_prepbufr) { + if ((lv >= nlev) || is_eq(bufr_pres_lv[lv], fill_value)) continue; + } + + if (bufr_obs[lv][0] > r8bfms) continue; + mlog << Debug(10) << " value: bufr_obs[" << lv << "][0]: " << bufr_obs[lv][0] << "\n"; + + obs_arr[1] = (float)vIdx; // BUFR variable index + obs_arr[4] = bufr_obs[lv][0]; // observation value + if(!is_eq(obs_arr[4], fill_value)) { + float scale_factor = 1.; + // Convert pressure from millibars to pascals + if (isMilliBar) scale_factor = pa_per_mb; + // Convert specific humidity from mg/kg to kg/kg + else if(isMgKg) scale_factor = kg_per_mg; + // Convert temperature from celcius to kelvin + else if(isDegC) scale_factor = c_to_k; + obs_arr[4] *= scale_factor; + } + + if (is_airnow) { + if (lv < airnow_nlev) { + obs_arr[2] = abs(bufr_obs_extra[lv][0] * 3600); // hour to second + } + obs_arr[3] = 0; // AIRNOW obs at surface + quality_mark = bufr_obs_extra[lv][1]; + // Convert a special number (1e+11) to NA at addObservation + if(conf_info.quality_mark_thresh < quality_mark) continue; + } + else { + // Retain the pressure in hPa for each observation record + obs_arr[2] = bufr_pres_lv[lv]; + obs_arr[3] = bufr_msl_lv[lv]; + if (is_eq(obs_arr[2], fill_value) && is_eq(obs_arr[3], fill_value) && 0 < nlev2) { + obs_arr[2] = lv; + obs_arr[3] = lv; + } + } + + addObservation(obs_arr, (string)hdr_typ, (string)hdr_sid, hdr_vld_ut, + hdr_lat, hdr_lon, hdr_elv, quality_mark, OBS_BUFFER_SIZE); + + // Increment the current and total observations counts + n_other_file_obs++; + n_other_total_obs++; + + // Increment the number of obs counter for this header + n_other_hdr_obs++; + } + } + n_hdr_obs += n_other_hdr_obs; + n_file_obs += n_other_file_obs; + n_total_obs += n_other_total_obs; +} + +//////////////////////////////////////////////////////////////////////// + +void dump_pb_data( + int unit, + const ConcatString &prefix, + const ConcatString &blk_file, + const char *method_name +) { + int msg_typ_ret[n_vld_msg_typ]; + int len1 = dump_dir.length(); + int len2 = prefix.length(); + + mlog << Debug(1) << "Dumping to ASCII output directory:\t" + << dump_dir << "\n"; + + for(int i=0; i MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { + mlog << Error << "\n" << method_name + << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; + } + dumppb_(blk_file.c_str(), &unit, dump_dir.c_str(), &len1, + prefix.c_str(), &len2, msg_typ_ret); +} + + +//////////////////////////////////////////////////////////////////////// + +derive_var_cfg::derive_var_cfg(ConcatString _var_name): var_name{_var_name} { var_index = bad_data_int; - var_name = _var_name; } //////////////////////////////////////////////////////////////////////// @@ -475,12 +650,12 @@ int met_main(int argc, char *argv[]) { // Deallocate memory and clean up clean_up(); - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// -const string get_tool_name() { +string get_tool_name() { return program_name; } @@ -629,28 +804,29 @@ void process_command_line(int argc, char **argv) { //////////////////////////////////////////////////////////////////////// -ConcatString save_bufr_table_to_file(const char *blk_file, int file_id) { +ConcatString save_bufr_table_to_file(const char *blk_file, int _file_id) { int len; - ConcatString tbl_filename, tbl_prefix; + ConcatString tbl_filename; + ConcatString tbl_prefix; tbl_prefix << conf_info.tmp_dir << "/" << "tmp_pb2nc_bufr"; tbl_filename = make_temp_file_name(tbl_prefix.c_str(), "tbl"); len = tbl_filename.length(); - if (file_id > MAX_FORTRAN_FILE_ID || file_id < MIN_FORTRAN_FILE_ID) { + if (_file_id > MAX_FORTRAN_FILE_ID || _file_id < MIN_FORTRAN_FILE_ID) { mlog << Error << "\nsave_bufr_table_to_file() -> " - << "Invalid file ID [" << file_id << "] between 1 and 99.\n\n"; + << "Invalid file ID [" << _file_id << "] between 1 and 99.\n\n"; } - openpb_(blk_file, &file_id); - dump_tbl_(blk_file, &file_id, tbl_filename.c_str(), &len); - closepb_(&file_id); - //close(file_id); + openpb_(blk_file, &_file_id); + dump_tbl_(blk_file, &_file_id, tbl_filename.c_str(), &len); + closepb_(&_file_id); + //close(_file_id); // Delete the temporary blocked file remove_temp_file((string)blk_file); return tbl_filename; } -bool is_prepbufr_file(StringArray *events) { +bool is_prepbufr_file(const StringArray *events) { bool is_prepbufr = events->has("P__EVENT") && events->has("Q__EVENT") && events->has("T__EVENT") && events->has("Z__EVENT"); return is_prepbufr; @@ -664,7 +840,6 @@ void get_variable_info(const char* tbl_filename) { FILE * fp; char * line = nullptr; size_t len = 1024; - ssize_t read; event_names.clear(); event_members.clear(); @@ -690,7 +865,7 @@ void get_variable_info(const char* tbl_filename) { } // Processing section 1 int var_count1 = 0; - while ((read = getline(&line, &len, fp)) != -1) { + while (getline(&line, &len, fp) != -1) { if (nullptr != strstr(line,"--------")) continue; if (nullptr != strstr(line,"MNEMONIC")) { if (find_mnemonic) break; @@ -725,7 +900,7 @@ void get_variable_info(const char* tbl_filename) { } // Skip section 2 - while ((read = getline(&line, &len, fp)) != -1) { + while (getline(&line, &len, fp) != -1) { if (nullptr != strstr(line,"MNEMONIC")) break; if (nullptr == strstr(line,"EVENT")) continue; @@ -736,7 +911,6 @@ void get_variable_info(const char* tbl_filename) { if (' ' != var_name[idx] ) break; var_name[idx] = '\0'; } - //if (nullptr == strstr(var_name,"EVENT")) continue; m_strncpy(var_desc, (line+BUFR_SEQUENCE_START), BUFR_SEQUENCE_LEN, method_name, "var_desc2", true); @@ -755,7 +929,7 @@ void get_variable_info(const char* tbl_filename) { getline(&line, &len, fp); // Processing section 3 - while ((read = getline(&line, &len, fp)) != -1) { + while (getline(&line, &len, fp) != -1) { if (' ' == line[BUFR_NAME_START]) continue; if ('-' == line[BUFR_NAME_START]) break; @@ -790,8 +964,7 @@ void get_variable_info(const char* tbl_filename) { } fclose(fp); - if (line) - free(line); + if (line) free(line); } return; @@ -905,8 +1078,6 @@ void process_pbfile(int i_pb) { // Dump the contents of the PrepBufr file to ASCII files if(dump_flag) { - mlog << Debug(1) << "Dumping to ASCII output directory:\t" - << dump_dir << "\n"; // Check for multiple PrepBufr files if(pbfile.n_elements() > 1) { @@ -917,22 +1088,12 @@ void process_pbfile(int i_pb) { exit(1); } - for(i=0; i MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { - mlog << Error << "\n" << method_name - << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; - } prefix = get_short_name(pbfile[i_pb].c_str()); - len1 = dump_dir.length(); - len2 = prefix.length(); - dumppb_(blk_file.c_str(), &unit, dump_dir.c_str(), &len1, - prefix.c_str(), &len2, msg_typ_ret); + dump_pb_data((dump_unit+i_pb), prefix, blk_file, method_name); } + // Open the blocked temp PrepBufr file for reading unit = file_unit + i_pb; if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { @@ -1621,7 +1782,7 @@ void process_pbfile(int i_pb) { (IGNORE_Z_PBL || is_valid_pb_data(pqtzuv[3])); if (has_tq || has_uv) { // Allocated memory is deleted after all observations are processed - float *tmp_pqtzuv = new float [mxr8vt]; + auto tmp_pqtzuv = new float [mxr8vt]; for(kk=0; kk= nlev2) continue; - - buf_nlev = nlev2; - if (nlev2 > mxr8lv) { - buf_nlev = mxr8lv; - if (!variables_big_nlevels.has(var_name, false)) { - mlog << Warning << "\n" << method_name - << "Too many vertical levels (" << nlev2 - << ") for " << var_name - << ". Ignored the vertical levels above " << mxr8lv << ".\n\n"; - variables_big_nlevels.add(var_name); - } - } - mlog << Debug(10) << "var: " << var_name << " nlev2: " << nlev2 - << ", vIdx: " << vIdx << ", obs_data_idx: " - << nc_point_obs.get_obs_index() << ", nlev: " << nlev << "\n"; - // Search through the vertical levels - for(lv=0; lv conf_info.end_level) break; - - // If the pressure level is not valid, continue to the next level - if (is_prepbufr) { - if ((lv >= nlev) || is_eq(bufr_pres_lv[lv], fill_value)) continue; - } - - if (bufr_obs[lv][0] > r8bfms) continue; - mlog << Debug(10) << " value: bufr_obs[" << lv << "][0]: " << bufr_obs[lv][0] << "\n"; - - obs_arr[1] = (float)vIdx; // BUFR variable index - obs_arr[4] = bufr_obs[lv][0]; // observation value - if(!is_eq(obs_arr[4], fill_value)) { - // Convert pressure from millibars to pascals - if (isMilliBar) { - obs_arr[4] *= pa_per_mb; - } - // Convert specific humidity from mg/kg to kg/kg - else if(isMgKg) { - obs_arr[4] *= kg_per_mg; - } - // Convert temperature from celcius to kelvin - else if(isDegC) { - obs_arr[4] += c_to_k; - } - } - - if (is_airnow) { - obs_arr[2] = abs(bufr_obs_extra[lv][0] * 3600); // hour to second - obs_arr[3] = 0; // AIRNOW obs at surface - quality_mark = bufr_obs_extra[lv][1]; - // Convert a special number (1e+11) to NA at addObservation - if(conf_info.quality_mark_thresh < quality_mark) continue; - } - else { - // Retain the pressure in hPa for each observation record - obs_arr[2] = bufr_pres_lv[lv]; - obs_arr[3] = bufr_msl_lv[lv]; - if (is_eq(obs_arr[2], fill_value) && is_eq(obs_arr[3], fill_value) && 0 < nlev2) { - obs_arr[2] = lv; - obs_arr[3] = lv; - } - } - - addObservation(obs_arr, (string)hdr_typ, (string)hdr_sid, hdr_vld_ut, - hdr_lat, hdr_lon, hdr_elv, quality_mark, OBS_BUFFER_SIZE); - - // Increment the current and total observations counts - n_other_file_obs++; - n_other_total_obs++; - - // Increment the number of obs counter for this header - n_other_hdr_obs++; - } - } - n_hdr_obs += n_other_hdr_obs; - n_file_obs += n_other_file_obs; - n_total_obs += n_other_total_obs; - } + read_bufr_vars(is_airnow, is_prepbufr, unit, nlev_max_req, + obs_arr[0], obs_arr[2], obs_arr[3], hdr_lat, hdr_lon, hdr_elv, + hdr_vld_ut, hdr_typ, hdr_sid, n_hdr_obs, n_file_obs, + variables_big_nlevels); if (do_pbl) { pbl_level = 0; @@ -3000,7 +3033,7 @@ int combine_tqz_and_uv(map pqtzuv_map_tq, it_tq = pqtzuv_map_tq.begin(); it_uv = pqtzuv_map_uv.begin(); pqtzuv_tq = (float *)it_tq->second; - pqtzuv_uv = (float *)it_uv->second;; + pqtzuv_uv = (float *)it_uv->second; pqtzuv_merged = new float[mxr8vt]; tq_pres = nint(it_tq->first); uv_pres = nint(it_uv->first); From d0ac3f781426b87a2ddf491112a29adcb864be32 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Mon, 12 Jun 2023 16:12:36 -0600 Subject: [PATCH 31/39] #2521 Rolback read_bufr_vars --- src/tools/other/pb2nc/pb2nc.cc | 283 +++++++++++++++------------------ 1 file changed, 131 insertions(+), 152 deletions(-) diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index b2c571590e..84f9a0fd9c 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -411,154 +411,6 @@ static void cleanup_hdr_typ(char *hdr_typ, bool is_prepbufr=false); //////////////////////////////////////////////////////////////////////// - -void read_bufr_vars(bool is_airnow, bool is_prepbufr, int file_unit, int nlev_max_req, - int obs_hid, float obs_pres, float obs_hgt, - const float hdr_lat, const float hdr_lon, const float hdr_elv, - const unixtime hdr_vld_ut, const char *hdr_typ, - const ConcatString &hdr_sid, - int &n_hdr_obs, int &n_file_obs, - StringArray &variables_big_nlevels) { - int i_ret; - int buf_nlev; - int airnow_nlev = 0; - float obs_arr[OBS_ARRAY_LEN]; - int quality_mark = bad_data_int; - const char *method_name = "read_bufr_vars() ->"; - - obs_arr[0] = obs_hid; - obs_arr[2] = obs_pres; - obs_arr[3] = obs_hgt; - - if (is_airnow) { - int tmp_ret; - for (int index1=0; index1= nlev2) continue; - - buf_nlev = nlev2; - if (nlev2 > mxr8lv) { - buf_nlev = mxr8lv; - if (!variables_big_nlevels.has(var_name, false)) { - mlog << Warning << "\n" << method_name - << "Too many vertical levels (" << nlev2 - << ") for " << var_name - << ". Ignored the vertical levels above " << mxr8lv << ".\n\n"; - variables_big_nlevels.add(var_name); - } - } - mlog << Debug(10) << "var: " << var_name << " nlev2: " << nlev2 - << ", vIdx: " << vIdx << ", obs_data_idx: " - << nc_point_obs.get_obs_index() << ", nlev: " << nlev << "\n"; - // Search through the vertical levels - for(int lv=0; lv conf_info.end_level) break; - - // If the pressure level is not valid, continue to the next level - if (is_prepbufr) { - if ((lv >= nlev) || is_eq(bufr_pres_lv[lv], fill_value)) continue; - } - - if (bufr_obs[lv][0] > r8bfms) continue; - mlog << Debug(10) << " value: bufr_obs[" << lv << "][0]: " << bufr_obs[lv][0] << "\n"; - - obs_arr[1] = (float)vIdx; // BUFR variable index - obs_arr[4] = bufr_obs[lv][0]; // observation value - if(!is_eq(obs_arr[4], fill_value)) { - float scale_factor = 1.; - // Convert pressure from millibars to pascals - if (isMilliBar) scale_factor = pa_per_mb; - // Convert specific humidity from mg/kg to kg/kg - else if(isMgKg) scale_factor = kg_per_mg; - // Convert temperature from celcius to kelvin - else if(isDegC) scale_factor = c_to_k; - obs_arr[4] *= scale_factor; - } - - if (is_airnow) { - if (lv < airnow_nlev) { - obs_arr[2] = abs(bufr_obs_extra[lv][0] * 3600); // hour to second - } - obs_arr[3] = 0; // AIRNOW obs at surface - quality_mark = bufr_obs_extra[lv][1]; - // Convert a special number (1e+11) to NA at addObservation - if(conf_info.quality_mark_thresh < quality_mark) continue; - } - else { - // Retain the pressure in hPa for each observation record - obs_arr[2] = bufr_pres_lv[lv]; - obs_arr[3] = bufr_msl_lv[lv]; - if (is_eq(obs_arr[2], fill_value) && is_eq(obs_arr[3], fill_value) && 0 < nlev2) { - obs_arr[2] = lv; - obs_arr[3] = lv; - } - } - - addObservation(obs_arr, (string)hdr_typ, (string)hdr_sid, hdr_vld_ut, - hdr_lat, hdr_lon, hdr_elv, quality_mark, OBS_BUFFER_SIZE); - - // Increment the current and total observations counts - n_other_file_obs++; - n_other_total_obs++; - - // Increment the number of obs counter for this header - n_other_hdr_obs++; - } - } - n_hdr_obs += n_other_hdr_obs; - n_file_obs += n_other_file_obs; - n_total_obs += n_other_total_obs; -} - -//////////////////////////////////////////////////////////////////////// - void dump_pb_data( int unit, const ConcatString &prefix, @@ -1936,10 +1788,137 @@ void process_pbfile(int i_pb) { else cape_cnt_surface_msgs++; } - read_bufr_vars(is_airnow, is_prepbufr, unit, nlev_max_req, - obs_arr[0], obs_arr[2], obs_arr[3], hdr_lat, hdr_lon, hdr_elv, - hdr_vld_ut, hdr_typ, hdr_sid, n_hdr_obs, n_file_obs, - variables_big_nlevels); + { + quality_mark = bad_data_int; + ConcatString quality_mark_str; + + if (is_airnow) { + int tmp_ret, tmp_nlev, tmp_len; + for (int index1=0; index1= nlev2) continue; + + buf_nlev = nlev2; + if (nlev2 > mxr8lv) { + buf_nlev = mxr8lv; + if (!variables_big_nlevels.has(var_name, false)) { + mlog << Warning << "\n" << method_name + << "Too many vertical levels (" << nlev2 + << ") for " << var_name + << ". Ignored the vertical levels above " << mxr8lv << ".\n\n"; + variables_big_nlevels.add(var_name); + } + } + mlog << Debug(10) << "var: " << var_name << " nlev2: " << nlev2 + << ", vIdx: " << vIdx << ", obs_data_idx: " + << nc_point_obs.get_obs_index() << ", nlev: " << nlev << "\n"; + // Search through the vertical levels + for(lv=0; lv conf_info.end_level) break; + + // If the pressure level is not valid, continue to the next level + if (is_prepbufr) { + if ((lv >= nlev) || is_eq(bufr_pres_lv[lv], fill_value)) continue; + } + + if (bufr_obs[lv][0] > r8bfms) continue; + mlog << Debug(10) << " value: bufr_obs[" << lv << "][0]: " << bufr_obs[lv][0] << "\n"; + + obs_arr[1] = (float)vIdx; // BUFR variable index + obs_arr[4] = bufr_obs[lv][0]; // observation value + if(!is_eq(obs_arr[4], fill_value)) { + // Convert pressure from millibars to pascals + if (isMilliBar) { + obs_arr[4] *= pa_per_mb; + } + // Convert specific humidity from mg/kg to kg/kg + else if(isMgKg) { + obs_arr[4] *= kg_per_mg; + } + // Convert temperature from celcius to kelvin + else if(isDegC) { + obs_arr[4] += c_to_k; + } + } + + if (is_airnow) { + obs_arr[2] = abs(bufr_obs_extra[lv][0] * 3600); // hour to second + obs_arr[3] = 0; // AIRNOW obs at surface + quality_mark = bufr_obs_extra[lv][1]; + // Convert a special number (1e+11) to NA at addObservation + if(conf_info.quality_mark_thresh < quality_mark) continue; + } + else { + // Retain the pressure in hPa for each observation record + obs_arr[2] = bufr_pres_lv[lv]; + obs_arr[3] = bufr_msl_lv[lv]; + if (is_eq(obs_arr[2], fill_value) && is_eq(obs_arr[3], fill_value) && 0 < nlev2) { + obs_arr[2] = lv; + obs_arr[3] = lv; + } + } + + addObservation(obs_arr, (string)hdr_typ, (string)hdr_sid, hdr_vld_ut, + hdr_lat, hdr_lon, hdr_elv, quality_mark, OBS_BUFFER_SIZE); + + // Increment the current and total observations counts + n_other_file_obs++; + n_other_total_obs++; + + // Increment the number of obs counter for this header + n_other_hdr_obs++; + } + } + n_hdr_obs += n_other_hdr_obs; + n_file_obs += n_other_file_obs; + n_total_obs += n_other_total_obs; + } if (do_pbl) { pbl_level = 0; From a822271dbefda5d72b832eb5001435339764fb55 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 13 Jun 2023 10:38:00 -0600 Subject: [PATCH 32/39] Per #2521, fix compilation --- src/basic/vx_log/concat_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/vx_log/concat_string.h b/src/basic/vx_log/concat_string.h index 89aeb10651..e26c30d9a8 100644 --- a/src/basic/vx_log/concat_string.h +++ b/src/basic/vx_log/concat_string.h @@ -146,7 +146,7 @@ class ConcatString { void chomp(const char *); // removes trailing suffix, if possible - operator std::string() const; + operator const std::string() const; bool startswith(const char *) const; bool endswith(const char *) const; From 203ec34d18431a834c6ae72b5257fda85141e8ba Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 13 Jun 2023 15:19:23 -0600 Subject: [PATCH 33/39] #2521 Corrected nearest day at adjuste_day_for_month_year_units. Updated the log messages --- src/basic/vx_cal/is_leap_year.cc | 57 ++++++++++++++------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index 5c799d3b39..ec57f2482d 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -26,9 +26,11 @@ using namespace std; //////////////////////////////////////////////////////////////////////// -#define SEC_MONTH (86400*30) -#define SEC_YEAR (86400*30*12) -static const double DAY_EPSILON = 0.00002; +static constexpr int DAYS_PER_MONTH = 30; +static constexpr int NO_OF_MONTHS = 12; +static constexpr double DAY_EPSILON = 0.00002; +#define SEC_MONTH (86400*DAYS_PER_MONTH) +#define SEC_YEAR (86400*DAYS_PER_MONTH*NO_OF_MONTHS) //////////////////////////////////////////////////////////////////////// @@ -54,7 +56,7 @@ return 1; //////////////////////////////////////////////////////////////////////// -const int monthly_days[12] = { +const int monthly_days[NO_OF_MONTHS] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; @@ -79,7 +81,7 @@ int get_days_from_mmdd(int month, int day, bool no_leap) { void decrease_one_month(int &year, int &month) { month--; if (month < 1) { - month = 12; + month = NO_OF_MONTHS; year--; } } @@ -88,7 +90,7 @@ void decrease_one_month(int &year, int &month) { void increase_one_month(int &year, int &month) { month++; - if (month > 12) { + if (month > NO_OF_MONTHS) { month = 1; year++; } @@ -96,27 +98,19 @@ void increase_one_month(int &year, int &month) { //////////////////////////////////////////////////////////////////////// -void adjuste_day_for_month_year_units(int &day, int &month, int &year, double time_fraction) { - // Compute remaining days +void adjuste_day_for_month_year_units(int &day, int &month, int &year, double month_fraction) { + // Compute remaining days from the month fraction bool day_adjusted = false; - double day_offset = 0.; - const char *method_name = "adjuste_day() -->"; - - if (day == 1) { - if (abs(time_fraction-0.5) < DAY_EPSILON) day = 15; - else { - day_offset = time_fraction * 30; - day += (int)(day_offset + 0.5); - } + const double day_offset = month_fraction * DAYS_PER_MONTH; + const char *method_name = "adjuste_day() --> "; + + day += (int)(day_offset + 0.5); + if (day == 1 && abs(month_fraction-0.5) < DAY_EPSILON) { + day = 15; // half month from the first day is 15, not 16 } - else { - day_offset = time_fraction * 30; - unixtime time_value_ut = (int)day_offset; - day += (int)(time_value_ut + 0.5); - if (day > 30) { - day -= 30; - increase_one_month(year, month); - } + else if (day > DAYS_PER_MONTH) { + day -= DAYS_PER_MONTH; + increase_one_month(year, month); } int day_org = day; @@ -166,8 +160,8 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, int minute; int second; unixtime ut; - unixtime time_value_ut = (unixtime)time_value; - double time_fraction = time_value - time_value_ut; + auto time_value_ut = (unixtime)time_value; + double time_fraction = time_value - (double)time_value_ut; const char *method_name = "add_to_unixtime() -->"; if (sec_per_unit == SEC_MONTH || sec_per_unit == SEC_YEAR) { @@ -182,10 +176,9 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, // Update year and compute remaining months int month_offset; - double day_offset; if (sec_per_unit == SEC_YEAR) { year += time_value_ut; - time_fraction *= 12; // 12 months/year + time_fraction *= NO_OF_MONTHS; // 12 months/year month_offset = (int)time_fraction; time_fraction -= month_offset; } @@ -217,10 +210,10 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, if (time_fraction > (1-TIME_EPSILON) ) ut += (unixtime)sec_per_unit; else if (time_fraction > TIME_EPSILON) ut += (unixtime)(time_fraction * sec_per_unit); } - mlog << Debug(5) << method_name + mlog << Debug(5) << method_name << unix_to_yyyymmdd_hhmmss(base_unixtime) - << " plus " << time_value << " days = " - << unix_to_yyyymmdd_hhmmss(ut) << "\n"; + << " plus " << time_value << " times " << sec_per_unit + << " seconds = " << unix_to_yyyymmdd_hhmmss(ut) << "\n"; return ut; } From fa1b34436a2e6b6453bab9cdc27940ff2d172d78 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 13 Jun 2023 16:06:23 -0600 Subject: [PATCH 34/39] #2521 MOved down using namespace below include statements --- src/libcode/vx_grid/laea_grid.cc | 65 ++++++------ src/tools/tc_utils/tc_diag/python_tc_diag.cc | 36 +++---- src/tools/tc_utils/tc_stat/tc_stat_job.cc | 101 +++++++++---------- 3 files changed, 99 insertions(+), 103 deletions(-) diff --git a/src/libcode/vx_grid/laea_grid.cc b/src/libcode/vx_grid/laea_grid.cc index 98a6e750e4..914873662b 100644 --- a/src/libcode/vx_grid/laea_grid.cc +++ b/src/libcode/vx_grid/laea_grid.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -28,6 +25,9 @@ using namespace std; #include "latlon_xyz.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// @@ -366,7 +366,7 @@ sum = uv_closedpolyline_area(u, v, 4); sum *= earth_radius_km*earth_radius_km; -return ( sum ); +return sum; } @@ -378,7 +378,7 @@ int LaeaGrid::nx() const { -return ( Nx ); +return Nx; } @@ -390,7 +390,7 @@ int LaeaGrid::ny() const { -return ( Ny ); +return Ny; } @@ -402,7 +402,7 @@ ConcatString LaeaGrid::name() const { -return ( Name ); +return Name; } @@ -414,7 +414,7 @@ ConcatString LaeaGrid::spheroid_name() const { -return ( SpheroidName ); +return SpheroidName; } @@ -426,7 +426,7 @@ const char * LaeaGrid::projection_name() const { -return ( "Polar Laea" ); +return "Polar Laea"; } @@ -438,13 +438,13 @@ double LaeaGrid::uv_closedpolyline_area(const double *u, const double *v, int n) { -int j, k; +int k; double sum; sum = 0.0; -for (j=0; j " exit ( 1 ); -return; - } @@ -618,7 +615,7 @@ GridInfo i; i.set(Data); -return ( i ); +return i; } @@ -634,7 +631,7 @@ double LaeaGrid::rot_grid_to_earth(int x, int y) const // grid to earth transformation is not just a simple rotation // -return ( 0.0 ); +return 0.0; } @@ -646,11 +643,11 @@ GridRep * LaeaGrid::copy() const { -LaeaGrid * p = 0; +LaeaGrid * p = nullptr; p = new LaeaGrid (Data); -return ( p ); +return p; } @@ -675,7 +672,7 @@ z = C/z; -return ( z ); +return z; } @@ -768,11 +765,11 @@ double laea_segment_area(double u0, double v0, double u1, double v1) { double answer; - + answer = 0.5*( u0*v1 - v0*u1 ); - -return ( answer ); - + +return answer; + } @@ -783,7 +780,7 @@ bool LaeaGrid::wrap_lon() const { -return ( false ); +return false; } @@ -802,8 +799,6 @@ mlog << Error << "\nLaeaGrid::shift_right(int) -> " exit ( 1 ); -return; - } @@ -882,7 +877,7 @@ rep = new LaeaGrid (grib2_data); if ( !rep ) { mlog << Error << "\nGrid::set(const LaeaGrib2Data &) -> " - << "memory allocation error\n\n"; + << "memory allocation error\n\n"; exit ( 1 ); diff --git a/src/tools/tc_utils/tc_diag/python_tc_diag.cc b/src/tools/tc_utils/tc_diag/python_tc_diag.cc index 997f5c6de6..60a7e32e05 100644 --- a/src/tools/tc_utils/tc_diag/python_tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/python_tc_diag.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "vx_config.h" @@ -19,13 +17,15 @@ using namespace std; #include "global_python.h" #include "wchar_argv.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// extern GlobalPython GP; // this needs external linkage //////////////////////////////////////////////////////////////////////// -static const char * user_ppath = 0; +static const char * user_ppath = nullptr; static const char write_tmp_diag [] = "MET_BASE/python/pyembed/write_tmp_tc_diag.py"; static const char read_tmp_diag [] = "pyembed.read_tmp_tc_diag"; // NO ".py" suffix static const char tc_diag_dict_name [] = "tc_diag"; @@ -52,7 +52,7 @@ bool python_tc_diag(const ConcatString &script_name, bool status = false; // Check for MET_PYTHON_EXE - if ((user_ppath = getenv(user_python_path_env)) != 0 ) { + if ((user_ppath = getenv(user_python_path_env)) != nullptr ) { status = tmp_nc_tc_diag(script_name, tmp_file_name, diag_map); } @@ -62,7 +62,7 @@ bool python_tc_diag(const ConcatString &script_name, tmp_file_name, diag_map); } - return(status); + return status; } //////////////////////////////////////////////////////////////////////// @@ -90,7 +90,7 @@ bool straight_python_tc_diag(const ConcatString &script_name, PyErr_Print(); mlog << Warning << "\n" << method_name << " -> " << "an error occurred initializing python\n\n"; - return(false); + return false; } // Set the arguments @@ -125,14 +125,14 @@ bool straight_python_tc_diag(const ConcatString &script_name, mlog << Warning << "\n" << method_name << " -> " << "an error occurred importing module \"" << script_name << "\"\n\n"; - return(false); + return false; } if(!module_obj) { mlog << Warning << "\n" << method_name << " -> " << "error running Python script \"" << script_name << "\"\n\n"; - return(false); + return false; } // Get the namespace for the module (as a dictionary) @@ -144,13 +144,13 @@ bool straight_python_tc_diag(const ConcatString &script_name, mlog << Warning << "\n" << method_name << " -> " << "trouble reading data from \"" << script_name << "\"\n\n"; - return(false); + return false; } // Populate the diagnostics map diag_map_from_python_dict(data_obj, diag_map); - return(true); + return true; } //////////////////////////////////////////////////////////////////////// @@ -163,7 +163,7 @@ bool tmp_nc_tc_diag(const ConcatString &script_name, ConcatString command; ConcatString path; ConcatString tmp_nc_path; - const char * tmp_dir = 0; + const char * tmp_dir = nullptr; Wchar_Argv wa; // TODO: Implement read/write temp tc_diag python functionality @@ -171,6 +171,7 @@ bool tmp_nc_tc_diag(const ConcatString &script_name, << "not yet fully implemented ... exiting!\n\n"; exit(1); + /* mlog << Debug(3) << "Calling " << user_ppath << " to run Python diagnostics script (" << script_name << " " << tmp_file_name << ").\n"; @@ -214,7 +215,7 @@ bool tmp_nc_tc_diag(const ConcatString &script_name, PyErr_Print(); mlog << Warning << "\n" << method_name << " -> " << "an error occurred initializing python\n\n"; - return(false); + return false; } // Prepare arguments to read input @@ -245,13 +246,13 @@ bool tmp_nc_tc_diag(const ConcatString &script_name, mlog << Warning << "\n" << method_name << " -> " << "an error occurred importing module " << '\"' << path << "\"\n\n"; - return(false); + return false; } if(!module_obj) { mlog << Warning << "\n" << method_name << " -> " << "error running Python script\n\n"; - return(false); + return false; } // Get the namespace for the module (as a dictionary) @@ -272,7 +273,8 @@ bool tmp_nc_tc_diag(const ConcatString &script_name, // Cleanup remove_temp_file(tmp_nc_path); - return(true); + return true; + */ } //////////////////////////////////////////////////////////////////////// @@ -280,8 +282,8 @@ bool tmp_nc_tc_diag(const ConcatString &script_name, void diag_map_from_python_dict(PyObject *diag_dict, map &diag_map) { const char *method_name = "diag_map_from_python_dict()"; - PyObject *key_obj = 0; - PyObject *val_obj = 0; + PyObject *key_obj = nullptr; + PyObject *val_obj = nullptr; int status; double val; long pos; diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index 917df5b7cf..179831466a 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,8 @@ using namespace std; #include "vx_math.h" #include "vx_stat_out.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// static const char *TCStatJobType_FilterStr = "filter"; @@ -53,7 +53,7 @@ static bool check_masks (const MaskPoly &, const Grid &, const Ma //////////////////////////////////////////////////////////////////////// TCStatJob *TCStatJobFactory::new_tc_stat_job_type(const char *type_str) { - TCStatJob *job = (TCStatJob *) 0; + TCStatJob *job = (TCStatJob *) nullptr; TCStatJobType type = NoTCStatJobType; // Determine the TCStatJobType @@ -86,13 +86,13 @@ TCStatJob *TCStatJobFactory::new_tc_stat_job_type(const char *type_str) { exit(1); } // end switch - return(job); + return job; } /////////////////////////////////////////////////////////////////////////////// TCStatJob *TCStatJobFactory::new_tc_stat_job(const char *jobstring) { - TCStatJob *job = (TCStatJob *) 0; + TCStatJob *job = (TCStatJob *) nullptr; StringArray a; ConcatString type_str = na_string; ConcatString err_str; @@ -124,7 +124,7 @@ TCStatJob *TCStatJobFactory::new_tc_stat_job(const char *jobstring) { exit(1); } - return(job); + return job; } //////////////////////////////////////////////////////////////////////// @@ -158,20 +158,20 @@ TCStatJob::TCStatJob(const TCStatJob &j) { TCStatJob & TCStatJob::operator=(const TCStatJob &j) { - if(this == &j) return(*this); + if(this == &j) return *this; assign(j); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// void TCStatJob::init_from_scratch() { - DumpOut = (ofstream *) 0; - JobOut = (ofstream *) 0; - StatOut = (ofstream *) 0; + DumpOut = (ofstream *) nullptr; + JobOut = (ofstream *) nullptr; + StatOut = (ofstream *) nullptr; // Ignore case when performing comparisons AModel.set_ignore_case(1); @@ -232,11 +232,11 @@ void TCStatJob::clear() { DumpFile.clear(); close_dump_file(); - JobOut = (ofstream *) 0; + JobOut = (ofstream *) nullptr; StatFile.clear(); close_stat_file(); - StatOut = (ofstream *) 0; + StatOut = (ofstream *) nullptr; stat_row = 0; // Set to default values @@ -703,7 +703,7 @@ bool TCStatJob::is_keeper_track(const TrackPairInfo &pair, // Update counts if(!keep) n.NKeep -= pair.n_points(); - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -712,7 +712,7 @@ bool TCStatJob::is_keeper_line(const TCStatLine &line, TCPointCounts &n) const { // Does not apply to TCDIAG lines - if(line.type() == TCStatLineType_TCDIAG) return(true); + if(line.type() == TCStatLineType_TCDIAG) return true; bool keep = true; double v_dbl, alat, alon, blat, blon; @@ -870,7 +870,7 @@ bool TCStatJob::is_keeper_line(const TCStatLine &line, // Update counts if(!keep) n.NKeep -= 1; - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -887,7 +887,7 @@ double TCStatJob::get_column_double(const TCStatLine &line, if(strcasecmp(column.c_str(), "PROBRIRW_PROB") == 0 && line.type() == TCStatLineType_ProbRIRW) { v = get_probrirw_value(line, ProbRIRWThresh); - return(v); + return v; } // Check for absolute value @@ -924,7 +924,7 @@ double TCStatJob::get_column_double(const TCStatLine &line, // Apply absolute value, if requested if(abs_flag && !is_bad_data(v)) v = fabs(v); - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -955,7 +955,7 @@ bool TCStatJob::is_keeper_tcdiag(const StringArray &diag_name, // Update counts if(!keep) n.NKeep -= 1; - return(keep); + return keep; } //////////////////////////////////////////////////////////////////////// @@ -980,7 +980,7 @@ double TCStatJob::get_diag_double(const StringArray &diag_name, PrintDiagWarning.add(diag_cs); } - return(v); + return v; } //////////////////////////////////////////////////////////////////////// @@ -1091,7 +1091,7 @@ StringArray TCStatJob::parse_job_command(const char *jobstring) { else { b.add(a[i]); } } - return(b); + return b; } //////////////////////////////////////////////////////////////////////// @@ -1158,7 +1158,7 @@ void TCStatJob::close_dump_file() { DumpOut->close(); delete DumpOut; - DumpOut = (ofstream *) 0; + DumpOut = (ofstream *) nullptr; } return; @@ -1198,7 +1198,7 @@ void TCStatJob::close_stat_file() { StatOut->close(); delete StatOut; - StatOut = (ofstream *) 0; + StatOut = (ofstream *) nullptr; } return; @@ -1436,7 +1436,7 @@ ConcatString TCStatJob::serialize() const { if(StatFile.length() > 0) s << "-out_stat " << StatFile << " "; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -1447,7 +1447,6 @@ void TCStatJob::do_job(const StringArray &file_list, TCPointCounts &n) { << "the do_job() base class function should never be called!\n\n"; exit(1); - return; } //////////////////////////////////////////////////////////////////////// @@ -1721,11 +1720,11 @@ TCStatJobFilter::TCStatJobFilter(const TCStatJobFilter &j) { TCStatJobFilter & TCStatJobFilter::operator=(const TCStatJobFilter &j) { - if(this == &j) return(*this); + if(this == &j) return *this; assign(j); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -1940,11 +1939,11 @@ TCStatJobSummary::TCStatJobSummary(const TCStatJobSummary &j) { TCStatJobSummary & TCStatJobSummary::operator=(const TCStatJobSummary &j) { - if(this == &j) return(*this); + if(this == &j) return *this; assign(j); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -2033,7 +2032,7 @@ StringArray TCStatJobSummary::parse_job_command(const char *jobstring) { else { b.add(a[i]); } } - return(b); + return b; } //////////////////////////////////////////////////////////////////////// @@ -2099,7 +2098,7 @@ ConcatString TCStatJobSummary::serialize() const { // Always list the output alpha value used s << "-out_alpha " << OutAlpha << " "; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -2698,7 +2697,7 @@ TCStatJobType string_to_tcstatjobtype(const ConcatString s) { else if(strcasecmp(s.c_str(), TCStatJobType_ProbRIRWStr) == 0) t = TCStatJobType_ProbRIRW; else t = NoTCStatJobType; - return(t); + return t; } //////////////////////////////////////////////////////////////////////// @@ -2714,7 +2713,7 @@ ConcatString tcstatjobtype_to_string(const TCStatJobType t) { default: s = na_str; break; } - return(ConcatString(s)); + return ConcatString(s); } //////////////////////////////////////////////////////////////////////// @@ -2738,7 +2737,7 @@ bool is_time_series(const TimeArray &init, const NumArray &lead, mlog << Debug(4) << "Skipping time-series computations since the array " << "lengths differ.\n"; - return(false); + return false; } // Initialize time spacing @@ -2755,21 +2754,21 @@ bool is_time_series(const TimeArray &init, const NumArray &lead, << "Skipping time-series computations since the " << "initialization time spacing changed: " << dinit << " != " << (init[i+1] - init[i]) << "\n"; - return(false); + return false; } else if(dlead != (lead[i+1] - lead[i])) { mlog << Debug(4) << "Skipping time-series computations since the " << "lead time spacing changed: " << dlead << " != " << (lead[i+1] - lead[i]) << "\n"; - return(false); + return false; } else if(dvalid != (valid[i+1] - valid[i])) { mlog << Debug(4) << "Skipping time-series computations since the " << "valid time spacing changed: " << dvalid << " != " << (valid[i+1] - valid[i]) << "\n"; - return(false); + return false; } } @@ -2796,7 +2795,7 @@ bool is_time_series(const TimeArray &init, const NumArray &lead, << sec_to_hhmmss(dsec) << "\".\n"; } - return(!is_bad_data(dsec)); + return !is_bad_data(dsec); } //////////////////////////////////////////////////////////////////////// @@ -2846,7 +2845,7 @@ int compute_time_to_indep(const NumArray &val, int ds) { eff_size = val.n()*(n_run_abv + n_run_bel)/exp_runs; tind = ds*val.n()/eff_size; - return(nint(tind)); + return nint(tind); } //////////////////////////////////////////////////////////////////////// @@ -2860,7 +2859,7 @@ StringArray intersection(const StringArray &s1, const StringArray &s2) { if(s2.has(s1[i])) s.add(s1[i]); } - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -2925,11 +2924,11 @@ TCStatJobRIRW::TCStatJobRIRW(const TCStatJobRIRW &j) { TCStatJobRIRW & TCStatJobRIRW::operator=(const TCStatJobRIRW &j) { - if(this == &j) return(*this); + if(this == &j) return *this; assign(j); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -3024,7 +3023,7 @@ StringArray TCStatJobRIRW::parse_job_command(const char *jobstring) { else { b.add(a[i]); } } - return(b); + return b; } //////////////////////////////////////////////////////////////////////// @@ -3121,7 +3120,7 @@ ConcatString TCStatJobRIRW::serialize() const { // Always list the output alpha value used s << "-out_alpha " << OutAlpha << " "; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -3967,11 +3966,11 @@ TCStatJobProbRIRW::TCStatJobProbRIRW(const TCStatJobProbRIRW &j) { TCStatJobProbRIRW & TCStatJobProbRIRW::operator=(const TCStatJobProbRIRW &j) { - if(this == &j) return(*this); + if(this == &j) return *this; assign(j); - return(*this); + return *this; } //////////////////////////////////////////////////////////////////////// @@ -4070,7 +4069,7 @@ StringArray TCStatJobProbRIRW::parse_job_command(const char *jobstring) { else { b.add(a[i]); } } - return(b); + return b; } //////////////////////////////////////////////////////////////////////// @@ -4167,7 +4166,7 @@ ConcatString TCStatJobProbRIRW::serialize() const { // Always list the output alpha value used s << "-out_alpha " << OutAlpha << " "; - return(s); + return s; } //////////////////////////////////////////////////////////////////////// @@ -4532,7 +4531,7 @@ ConcatString build_map_key(const char *prefix, const TCStatLine &l, } // end for i - return(key); + return key; } //////////////////////////////////////////////////////////////////////// @@ -4581,7 +4580,7 @@ double get_probrirw_value(const TCStatLine &line, double ProbRIRWThresh) { ConcatString cs; // Only valid for the PROBRIRW line type - if(line.type() != TCStatLineType_ProbRIRW) return(bad_data_double); + if(line.type() != TCStatLineType_ProbRIRW) return bad_data_double; // Get the number of threhsolds n = atoi(line.get_item("N_THRESH")); @@ -4597,7 +4596,7 @@ double get_probrirw_value(const TCStatLine &line, double ProbRIRWThresh) { } } - return(p); + return p; } //////////////////////////////////////////////////////////////////////// From 2e1ab81a1fafcf6beeeceadf679fe23fc9f1bbe8 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 13 Jun 2023 16:22:11 -0600 Subject: [PATCH 35/39] #2521 Added namespace std to ofstream --- src/libcode/vx_stat_out/stat_columns.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcode/vx_stat_out/stat_columns.h b/src/libcode/vx_stat_out/stat_columns.h index ed11dbe2ab..b07045c1d7 100644 --- a/src/libcode/vx_stat_out/stat_columns.h +++ b/src/libcode/vx_stat_out/stat_columns.h @@ -26,8 +26,8 @@ extern void parse_row_col(const char *, int &, int &); //////////////////////////////////////////////////////////////////////// -extern void open_txt_file (ofstream *&, const char *); -extern void close_txt_file(ofstream *&, const char *); +extern void open_txt_file (std::ofstream *&, const char *); +extern void close_txt_file(std::ofstream *&, const char *); //////////////////////////////////////////////////////////////////////// From 2ccd2ecba6e823f9cf293c225212cc1ce30f82f7 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 13 Jun 2023 16:51:18 -0600 Subject: [PATCH 36/39] #2521 Added std namespace --- src/tools/tc_utils/tc_gen/tc_gen.h | 18 +++--- src/tools/tc_utils/tc_gen/tc_gen_conf_info.h | 64 ++++++++++---------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/tools/tc_utils/tc_gen/tc_gen.h b/src/tools/tc_utils/tc_gen/tc_gen.h index 5f1c4cc80c..fd49592bf7 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.h +++ b/src/tools/tc_utils/tc_gen/tc_gen.h @@ -109,7 +109,7 @@ static ConcatString out_base; // Output NetCDF file static ConcatString out_nc_file; -static netCDF::NcFile *nc_out = (netCDF::NcFile *) 0; +static netCDF::NcFile *nc_out = (netCDF::NcFile *) nullptr; static netCDF::NcDim lat_dim; static netCDF::NcDim lon_dim; @@ -117,16 +117,16 @@ static netCDF::NcDim lon_dim; static StringArray nc_var_sa; // Output STAT file -static ConcatString stat_file; -static ofstream *stat_out = (ofstream *) 0; -static AsciiTable stat_at; -static int i_stat_row; +static ConcatString stat_file; +static std::ofstream *stat_out = (std::ofstream *) nullptr; +static AsciiTable stat_at; +static int i_stat_row; // Optional ASCII output files -static ConcatString txt_file[n_txt]; -static ofstream *txt_out[n_txt]; -static AsciiTable txt_at[n_txt]; -static int i_txt_row[n_txt]; +static ConcatString txt_file[n_txt]; +static std::ofstream *txt_out[n_txt]; +static AsciiTable txt_at[n_txt]; +static int i_txt_row[n_txt]; // Strings to be output in the STAT and optional text files static StatHdrColumns shc; diff --git a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h index 4620e9315c..981b2e6842 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h +++ b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h @@ -51,30 +51,30 @@ static const STATLineType txt_file_type[n_txt] = { // Output data type names -static const string genesis_name ("GENESIS"); -static const string genesis_dev_name ("GENESIS_DEV"); -static const string genesis_ops_name ("GENESIS_OPS"); -static const string prob_genesis_name ("PROB_GENESIS"); -static const string genesis_shape_name("GENESIS_SHAPE"); +static const std::string genesis_name ("GENESIS"); +static const std::string genesis_dev_name ("GENESIS_DEV"); +static const std::string genesis_ops_name ("GENESIS_OPS"); +static const std::string prob_genesis_name ("PROB_GENESIS"); +static const std::string genesis_shape_name("GENESIS_SHAPE"); // Names for output data plane types -static const string fgen_str = "fcst_genesis"; -static const string ftrk_str = "fcst_track"; -static const string fdev_fyoy_str = "fcst_dev_fy_oy"; -static const string fdev_fyon_str = "fcst_dev_fy_on"; -static const string fops_fyoy_str = "fcst_ops_fy_oy"; -static const string fops_fyon_str = "fcst_ops_fy_on"; -static const string bgen_str = "best_genesis"; -static const string btrk_str = "best_track"; -static const string bdev_fyoy_str = "best_dev_fy_oy"; -static const string bdev_fnoy_str = "best_dev_fy_on"; -static const string bops_fyoy_str = "best_ops_fy_oy"; -static const string bops_fnoy_str = "best_ops_fy_on"; +static const std::string fgen_str = "fcst_genesis"; +static const std::string ftrk_str = "fcst_track"; +static const std::string fdev_fyoy_str = "fcst_dev_fy_oy"; +static const std::string fdev_fyon_str = "fcst_dev_fy_on"; +static const std::string fops_fyoy_str = "fcst_ops_fy_oy"; +static const std::string fops_fyon_str = "fcst_ops_fy_on"; +static const std::string bgen_str = "best_genesis"; +static const std::string btrk_str = "best_track"; +static const std::string bdev_fyoy_str = "best_dev_fy_oy"; +static const std::string bdev_fnoy_str = "best_dev_fy_on"; +static const std::string bops_fyoy_str = "best_ops_fy_oy"; +static const std::string bops_fnoy_str = "best_ops_fy_on"; static const int n_ncout = 12; -static const string ncout_str[n_ncout] = { +static const std::string ncout_str[n_ncout] = { fgen_str, ftrk_str, bgen_str, btrk_str, fdev_fyoy_str, fdev_fyon_str, bdev_fyoy_str, bdev_fnoy_str, fops_fyoy_str, fops_fyon_str, bops_fyoy_str, bops_fnoy_str @@ -163,7 +163,7 @@ class TCGenVxOpt { // Output file options ThreshArray ProbGenThresh; double CIAlpha; - map OutputMap; + std::map OutputMap; TCGenNcOutInfo NcInfo; SingleThresh ValidGenesisDHrThresh; bool BestUniqueFlag; @@ -237,7 +237,7 @@ class TCGenConfInfo { Grid NcOutGrid; // Summary of output file options across all filters - map OutputMap; + std::map OutputMap; TCGenNcOutInfo NcInfo; // Config file version @@ -250,7 +250,7 @@ class TCGenConfInfo { void read_config(const char *, const char *); void process_config(); - void process_flags(const map &, + void process_flags(const std::map &, const TCGenNcOutInfo &); double compute_dland(double lat, double lon); @@ -298,11 +298,11 @@ class GenCTCInfo { bool BestUniqueFlag; // Number of hits per BEST track genesis event - map BestDevHitMap; - map BestOpsHitMap; + std::map BestDevHitMap; + std::map BestOpsHitMap; // Output DataPlane variables - map DpMap; + std::map DpMap; ////////////////////////////////////////////////////////////////// @@ -319,8 +319,8 @@ class GenCTCInfo { void add_fcst_gen(const GenesisInfo &); void add_best_gen(const GenesisInfo &); - void inc_pnt(double, double, const string &); - void inc_trk(const GenesisInfo &, const string &); + void inc_pnt(double, double, const std::string &); + void inc_trk(const GenesisInfo &, const std::string &); }; //////////////////////////////////////////////////////////////////////// @@ -350,14 +350,14 @@ class ProbGenPCTInfo { IntArray LeadTimes; // Map of lead times to PCT tables - map PCTMap; + std::map PCTMap; // Map of lead times to vectors of pair info - map > ProbGenMap; - map > GenShapeMap; - map > ProbIdxMap; - map > BestGenMap; - map > BestEvtMap; + std::map > ProbGenMap; + std::map > GenShapeMap; + std::map > ProbIdxMap; + std::map > BestGenMap; + std::map > BestEvtMap; ////////////////////////////////////////////////////////////////// From 5440712d5b4625403a05f8ac10f2cf11c23b48c5 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Tue, 13 Jun 2023 16:51:51 -0600 Subject: [PATCH 37/39] #2521 Moved down using namespace below inculde statsments --- src/tools/tc_utils/tc_gen/tc_gen.cc | 22 +++++++++---------- src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index f666ebab7b..ee19f84ed2 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -29,8 +29,6 @@ // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -43,7 +41,6 @@ using namespace std; #include #include -using namespace netCDF; #include "main.h" #include "tc_gen.h" @@ -61,6 +58,9 @@ using namespace netCDF; #include "met_file.h" #include "nav.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// static void process_command_line (int, char **); @@ -211,10 +211,10 @@ int met_main(int argc, char *argv[]) { mlog << Debug(1) << "Output file: " << out_nc_file << "\n"; delete nc_out; - nc_out = (NcFile *) 0; + nc_out = (NcFile *) nullptr; } - return(0); + return 0; } //////////////////////////////////////////////////////////////////////// @@ -1051,7 +1051,7 @@ int find_genesis_match(const GenesisInfo &fcst_gi, << " has NO MATCH in the BEST or operational tracks.\n"; } - return(i_best); + return i_best; } //////////////////////////////////////////////////////////////////////// @@ -1138,7 +1138,7 @@ int find_probgen_match(const ProbGenInfo &prob_gi, << " has NO MATCH in the BEST or operational tracks.\n"; } - return(i_best); + return i_best; } //////////////////////////////////////////////////////////////////////// @@ -1181,7 +1181,7 @@ int find_genshape_match(const GenShapeInfo &gsi, } } // end for i - return(i_bga); + return i_bga; } //////////////////////////////////////////////////////////////////////// @@ -1807,7 +1807,7 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { if(init_from_scratch) { // Initialize file stream - txt_out[i] = (ofstream *) 0; + txt_out[i] = (ofstream *) nullptr; // Build the file name txt_file[i] << out_base << "_" << txt_file_abbr[i] @@ -2412,7 +2412,7 @@ void write_nc(GenCTCInfo &gci) { unixtime valid_end = (unixtime) 0; // Allocate memory - float *data = (float *) 0; + float *data = (float *) nullptr; int nx = gci.NcOutGrid->nx(); int ny = gci.NcOutGrid->ny(); data = new float [nx*ny]; @@ -2544,7 +2544,7 @@ void write_nc(GenCTCInfo &gci) { } // Deallocate and clean up - if(data) { delete [] data; data = (float *) 0; } + if(data) { delete [] data; data = (float *) nullptr; } return; } diff --git a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc index 86bc76dc9c..7a96505d11 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -25,6 +23,8 @@ using namespace std; #include "vx_regrid.h" #include "vx_log.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// // // Code for struct TCGenNcOutInfo From 982b12b19da8ca4748c3963a852e7aaf1a948800 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 14 Jun 2023 00:13:15 -0600 Subject: [PATCH 38/39] #2521 Put code back instead of calling adjuste_day_for_month_year_units --- src/basic/vx_cal/is_leap_year.cc | 41 +++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index ec57f2482d..58228f2a75 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -101,10 +101,10 @@ void increase_one_month(int &year, int &month) { void adjuste_day_for_month_year_units(int &day, int &month, int &year, double month_fraction) { // Compute remaining days from the month fraction bool day_adjusted = false; - const double day_offset = month_fraction * DAYS_PER_MONTH; + const int day_offset = (int)(month_fraction * DAYS_PER_MONTH + 0.5); const char *method_name = "adjuste_day() --> "; - day += (int)(day_offset + 0.5); + day += day_offset; if (day == 1 && abs(month_fraction-0.5) < DAY_EPSILON) { day = 15; // half month from the first day is 15, not 16 } @@ -189,8 +189,43 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, increase_one_month(year, month); } // Compute remaining days - adjuste_day_for_month_year_units(day, month, year, time_fraction); + //adjuste_day_for_month_year_units(day, month, year, time_fraction); + //ut = mdyhms_to_unix(month, day, year, hour, minute, second); + if (day == 1) { + if (abs(time_fraction-0.5) < DAY_EPSILON) day = 15; + else { + day_offset = time_fraction * DAYS_PER_MONTH; + day += (int)day_offset; + if (day_offset - (int)day_offset > 0.5) day++; + } + } + else { + day_offset = time_fraction * DAYS_PER_MONTH; + time_value_ut = (int)day_offset; + day += time_value_ut; + if (day_offset - time_value_ut > 0.5) day++; + if (day > DAYS_PER_MONTH) { + day -= DAYS_PER_MONTH; + increase_one_month(year, month); + } + } + + int day_org = day; + bool day_adjusted = false; + int max_day = monthly_days[month-1]; + if (day > max_day) { + day = max_day; + day_adjusted = true; + if (month == 2 && is_leap_year(year)) { + if (day_org == 29) day_adjusted = false; + day = 29; + } + } ut = mdyhms_to_unix(month, day, year, hour, minute, second); + if (day_adjusted) { + mlog << Debug(2) << method_name << "adjusted day " << day_org + << " to " << day << " for " << year << "-" << month << "\n"; + } } else if (!no_leap || sec_per_unit != 86400) { // seconds, minute, hours, and day unit with leap year From 3fa03eda3a9ba7064b7ed3ed437702f82b6c8f52 Mon Sep 17 00:00:00 2001 From: Howard Soh Date: Wed, 14 Jun 2023 09:21:05 -0600 Subject: [PATCH 39/39] #2521 Put old code back at add_to_unixtime --- src/basic/vx_cal/is_leap_year.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic/vx_cal/is_leap_year.cc b/src/basic/vx_cal/is_leap_year.cc index 58228f2a75..78d06eb0d5 100644 --- a/src/basic/vx_cal/is_leap_year.cc +++ b/src/basic/vx_cal/is_leap_year.cc @@ -191,6 +191,7 @@ unixtime add_to_unixtime(unixtime base_unixtime, int sec_per_unit, // Compute remaining days //adjuste_day_for_month_year_units(day, month, year, time_fraction); //ut = mdyhms_to_unix(month, day, year, hour, minute, second); + double day_offset; if (day == 1) { if (abs(time_fraction-0.5) < DAY_EPSILON) day = 15; else {