diff --git a/src/basic/vx_log/Makefile.am b/src/basic/vx_log/Makefile.am index 9e4ba32cf2..6679fec4a2 100644 --- a/src/basic/vx_log/Makefile.am +++ b/src/basic/vx_log/Makefile.am @@ -15,6 +15,7 @@ libvx_log_a_SOURCES = concat_string.cc concat_string.h \ file_fxns.cc file_fxns.h \ indent.cc indent.h \ logger.cc logger.h \ + main.cc main.h \ string_array.cc string_array.h \ str_wrappers.cc str_wrappers.h \ vx_log.h diff --git a/src/basic/vx_log/Makefile.in b/src/basic/vx_log/Makefile.in index 64b1b5ccc7..9c229711b2 100644 --- a/src/basic/vx_log/Makefile.in +++ b/src/basic/vx_log/Makefile.in @@ -108,8 +108,8 @@ am__v_AR_1 = libvx_log_a_AR = $(AR) $(ARFLAGS) libvx_log_a_LIBADD = am_libvx_log_a_OBJECTS = concat_string.$(OBJEXT) file_fxns.$(OBJEXT) \ - indent.$(OBJEXT) logger.$(OBJEXT) string_array.$(OBJEXT) \ - str_wrappers.$(OBJEXT) + indent.$(OBJEXT) logger.$(OBJEXT) main.$(OBJEXT) \ + string_array.$(OBJEXT) str_wrappers.$(OBJEXT) libvx_log_a_OBJECTS = $(am_libvx_log_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -128,8 +128,8 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/concat_string.Po \ ./$(DEPDIR)/file_fxns.Po ./$(DEPDIR)/indent.Po \ - ./$(DEPDIR)/logger.Po ./$(DEPDIR)/str_wrappers.Po \ - ./$(DEPDIR)/string_array.Po + ./$(DEPDIR)/logger.Po ./$(DEPDIR)/main.Po \ + ./$(DEPDIR)/str_wrappers.Po ./$(DEPDIR)/string_array.Po am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) @@ -336,6 +336,7 @@ libvx_log_a_SOURCES = concat_string.cc concat_string.h \ file_fxns.cc file_fxns.h \ indent.cc indent.h \ logger.cc logger.h \ + main.cc main.h \ string_array.cc string_array.h \ str_wrappers.cc str_wrappers.h \ vx_log.h @@ -392,6 +393,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_fxns.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indent.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_wrappers.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string_array.Po@am__quote@ # am--include-marker @@ -547,6 +549,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/file_fxns.Po -rm -f ./$(DEPDIR)/indent.Po -rm -f ./$(DEPDIR)/logger.Po + -rm -f ./$(DEPDIR)/main.Po -rm -f ./$(DEPDIR)/str_wrappers.Po -rm -f ./$(DEPDIR)/string_array.Po -rm -f Makefile @@ -598,6 +601,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/file_fxns.Po -rm -f ./$(DEPDIR)/indent.Po -rm -f ./$(DEPDIR)/logger.Po + -rm -f ./$(DEPDIR)/main.Po -rm -f ./$(DEPDIR)/str_wrappers.Po -rm -f ./$(DEPDIR)/string_array.Po -rm -f Makefile diff --git a/src/basic/vx_log/main.cc b/src/basic/vx_log/main.cc new file mode 100644 index 0000000000..400e599c9d --- /dev/null +++ b/src/basic/vx_log/main.cc @@ -0,0 +1,185 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 2022 - 2022 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +//////////////////////////////////////////////////////////////////////// +// +// Filename: main.cc +// +// Description: +// MET has only one main(). The common features like logging with user ID +// for STIG and the signal handling are implemented one place whcih +// prevents from copying or calling the same APIs at the multiple palces. +// The existing "main" at MET tools should be renamed to "met_main" and +// three APIs (get_tool_name, initialize, and process_command_line) must +// be added. Most MET tools have initialize and process_command_line. +// +// int main(int argc, char *argv[]) +// ==> +// int met_main(int argc, char *argv[]) +// +// string get_tool_name() { return "mode"; } +// void initialize(); +// void process_command_line(int argc, char **argv); +// +// Mod# Date Name Description +// ---- ---- ---- ----------- +// 000 07/06/22 Howard Soh New + +#include +#include + +#include "main.h" +#include "concat_string.h" +#include "memory.h" +#include "logger.h" + + +//////////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////////// + +static std::string met_cmdline = ""; + +static int met_start_time; +static int met_end_time; +static uid_t met_user_id; +static string met_user_name; +static string met_tool_name; + +//////////////////////////////////////////////////////////////////////// + +extern string get_tool_name(); + +extern int met_main(int argc, char *argv[]); + +//extern void initialize(); +//extern void process_command_line(int argc, char **argv); + +void do_post_process(); +void do_pre_process(int argc, char *argv[]); +void set_handlers(); +void set_user_id(); +void store_arguments(int argc, char **argv); + +//////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) { + + do_pre_process(argc, argv); + + //initialize(); + //process_command_line(argc, argv); + + int return_code = met_main(argc, argv); + + do_post_process(); + + return return_code; + +} + +//////////////////////////////////////////////////////////////////////// + +void do_pre_process(int argc, char *argv[]) { + ConcatString msg, msg2; + + store_arguments(argc, argv); + + set_user_id(); + met_tool_name = get_tool_name(); + + msg << "Start " << met_tool_name << " by " << met_user_name + << "(" << met_user_id << ") at " << get_current_time(); + msg2 << " cmd: " << met_cmdline; + mlog << Debug(1) << msg << msg2 << "\n"; + + set_handlers(); +} + +//////////////////////////////////////////////////////////////////////// + +void do_post_process() { + ConcatString msg; + msg << "Finish " << met_tool_name << " by " << met_user_name + << "(" << met_user_id << ") at " << get_current_time(); + mlog << Debug(1) << msg << "\n"; +} + +//////////////////////////////////////////////////////////////////////// + +string get_current_time() { + time_t curr_time; + tm * curr_tm; + char date_string[MET_BUF_SIZE]; + + time(&curr_time); + curr_tm = gmtime (&curr_time); + + strftime(date_string, MET_BUF_SIZE, "%Y-%m-%d %TZ", curr_tm); + //string time_str(date_string); + + return string(date_string); +} + +//////////////////////////////////////////////////////////////////////// + +/* not working at Docker +// based on blog at http://www.alexonlinux.com/how-to-handle-sigsegv-but-also-generate-core-dump +// NOTE: that comments on the blog indicate the core file generated on red hat or on multi-threaded programs +// might contain unhelpful information. +void segv_handler(int signum) { + char cwdbuffer[MET_BUF_SIZE+1]; + string timebuffer = get_current_time(); + + getcwd(cwdbuffer,MET_BUF_SIZE+1); + + fprintf(stderr, "FATAL ERROR (SEGFAULT): Process %d got signal %d @ local time = %s\n", getpid(), signum, timebuffer); + fprintf(stderr, "FATAL ERROR (SEGFAULT): Look for a core file in %s\n",cwdbuffer); + fprintf(stderr, "FATAL ERROR (SEGFAULT): Process command line: %s\n",met_cmdline.c_str()); + signal(signum, SIG_DFL); + kill(getpid(), signum); +} +*/ + +//////////////////////////////////////////////////////////////////////// +// Need signal handlers for SIGINT, SIGHUP, SIGTERM, SIGPIPE, and SIGSEGV +// PORTsignal(SIGPIPE, (PORTsigfunc)SIG_IGN); +// PORTsignal(SIGSEGV, segv_handler); + +void set_handlers() { + + set_new_handler(oom); +} + +//////////////////////////////////////////////////////////////////////// + +void set_user_id() { + met_user_id = geteuid (); + register struct passwd *pw; + pw = getpwuid (met_user_id); + if (pw) met_user_name = string(pw->pw_name); +} + +//////////////////////////////////////////////////////////////////////// + +void store_arguments(int argc, char **argv) { + for (int ix = 0; ix < argc; ix++){ + met_cmdline += argv[ix]; + met_cmdline += " "; + } +} + +//////////////////////////////////////////////////////////////////////// + +void tidy_and_exit(int signal) { + printf("Exiting %d\n", signal); + exit(signal); +} + +//////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_log/main.h b/src/basic/vx_log/main.h new file mode 100644 index 0000000000..a008a26c7c --- /dev/null +++ b/src/basic/vx_log/main.h @@ -0,0 +1,40 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2022 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + + +//////////////////////////////////////////////////////////////////////// + + +#ifndef __MAIN_H__ +#define __MAIN_H__ + + +//////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +using namespace std; + +//////////////////////////////////////////////////////////////////////// + +#define MET_BUF_SIZE 4096 + +//////////////////////////////////////////////////////////////////////// + +//extern void log_event(int event_id, string event_msg); +extern string get_current_time(); + +//////////////////////////////////////////////////////////////////////// + +#endif // __MAIN_H__ + + +//////////////////////////////////////////////////////////////////////// + diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 11dd67670d..f710378cef 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -66,6 +66,7 @@ // 034 01/14/21 McCabe MET #1695 All members in one file. // 035 02/15/22 Halley Gotway MET #1583 Add HiRA option. // 036 02/20/22 Halley Gotway MET #1259 Write probabilistic statistics. +// 037 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -73,18 +74,15 @@ using namespace std; #include #include -#include #include #include -#include #include #include #include -#include #include #include -#include +#include "main.h" #include "ensemble_stat.h" #include "vx_nc_util.h" @@ -186,14 +184,11 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { // Set up OpenMP (if enabled) init_openmp(); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -214,6 +209,13 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() +{ + return "ensemble_stat"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { int i; CommandLine cline; diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index b840dd1991..a02f4ada15 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -109,6 +109,7 @@ // filtering options. // 052 05/28/21 Halley Gotway Add MCTS HSS_EC output. // 053 12/11/21 Halley Gotway MET #1991 Fix VCNT output. +// 054 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -116,17 +117,15 @@ using namespace std; #include #include -#include #include #include -#include #include #include #include #include #include -#include +#include "main.h" #include "handle_openmp.h" #include "grid_stat.h" @@ -185,14 +184,11 @@ static bool read_data_plane(VarInfo* info, DataPlane& dp, Met2dDataFile* mtddf, //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { // Set up OpenMP (if enabled) init_openmp(); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -207,6 +203,13 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() +{ + return "ensemble_stat"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; GrdFileType ftype, otype; diff --git a/src/tools/core/mode/mode.cc b/src/tools/core/mode/mode.cc index 3563cc3d82..1a034885d4 100644 --- a/src/tools/core/mode/mode.cc +++ b/src/tools/core/mode/mode.cc @@ -54,6 +54,7 @@ // 017 05/20/16 Prestopnik J Removed -version (now in command_line.cc) // 018 04/08/19 Halley Gotway Add percentile thresholds. // 019 04/01/19 Fillmore Add FCST and OBS units. +// 020 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -62,17 +63,15 @@ using namespace std; #include #include -#include #include #include -#include #include #include #include #include #include -#include +#include "main.h" #include "string_array.h" #include "mode_usage.h" #include "mode_conf_info.h" @@ -119,8 +118,7 @@ static const char default_config_filename [] = "MET_BASE/config/MODEConfig_defau /////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) - +int met_main(int argc, char * argv []) { int j, n; @@ -190,6 +188,13 @@ return ( status ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() +{ + return "mode"; +} + /////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/mode/mode_frontend.cc b/src/tools/core/mode/mode_frontend.cc index 3d140c8db6..0c999675ac 100644 --- a/src/tools/core/mode/mode_frontend.cc +++ b/src/tools/core/mode/mode_frontend.cc @@ -88,12 +88,6 @@ int mode_frontend(const StringArray & Argv) { - // - // Set handler to be called for memory allocation error - // - -set_new_handler(oom); - // // Process the command line arguments // diff --git a/src/tools/core/mode/mode_multivar.cc b/src/tools/core/mode/mode_multivar.cc index a80c8a5453..9ef2d9b81d 100644 --- a/src/tools/core/mode/mode_multivar.cc +++ b/src/tools/core/mode/mode_multivar.cc @@ -84,12 +84,6 @@ int main_multivar(int argc, char * argv []) { - // - // Set handler to be called for memory allocation error - // - -set_new_handler(oom); - // // Process the command line arguments // diff --git a/src/tools/core/mode/mode_singlevar.cc b/src/tools/core/mode/mode_singlevar.cc index e541b5ee3b..ed400fa2eb 100644 --- a/src/tools/core/mode/mode_singlevar.cc +++ b/src/tools/core/mode/mode_singlevar.cc @@ -84,12 +84,6 @@ int main_singlevar(int argc, char * argv []) { - // - // Set handler to be called for memory allocation error - // - -set_new_handler(oom); - // // Process the command line arguments // diff --git a/src/tools/core/mode_analysis/mode_analysis.cc b/src/tools/core/mode_analysis/mode_analysis.cc index 4159138653..29433266ee 100644 --- a/src/tools/core/mode_analysis/mode_analysis.cc +++ b/src/tools/core/mode_analysis/mode_analysis.cc @@ -29,12 +29,12 @@ // 004 05/14/12 Halley Gotway Switch to using vx_config library. // 005 05/20/16 Prestopnik J Removed -version (now in command_line.cc). // 006 05/15/17 Prestopnik P Add shape for regrid. +// 007 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// using namespace std; -#include #include #include #include @@ -42,9 +42,9 @@ using namespace std; #include #include #include -#include #include +#include "main.h" #include "vx_util.h" #include "vx_analysis_util.h" @@ -106,18 +106,12 @@ static void set_lookin(const char * path); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { ConcatString default_config_file; - // - // set handler to be called for memory allocation error - // - -set_new_handler(oom); - if ( argc == 1 ) { usage(); } @@ -195,6 +189,13 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() +{ + return "mode_analysis"; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/pcp_combine/pcp_combine.cc b/src/tools/core/pcp_combine/pcp_combine.cc index 5be8ea838e..87884b0ad5 100644 --- a/src/tools/core/pcp_combine/pcp_combine.cc +++ b/src/tools/core/pcp_combine/pcp_combine.cc @@ -75,6 +75,7 @@ // 022 03/08/19 Halley Gotway Support multiple -field options. // 023 08/29/19 Halley Gotway Support multiple arguments for the // the -pcpdir option. +// 024 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -82,21 +83,16 @@ using namespace std; #include #include -#include #include #include -#include #include #include #include -#include #include #include #include -#include - -using namespace netCDF; +#include "main.h" #include "vx_log.h" #include "vx_data2d_factory.h" #include "vx_data2d.h" @@ -198,16 +194,11 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { int i, j; program_name = get_short_name(argv[0]); - // - // Set handler to be called for memory allocation error - // - set_new_handler(oom); - // // Process the command line arguments // @@ -251,6 +242,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "pcp_combine"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 1aced4fad9..470992b99b 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -100,6 +100,7 @@ // Added code for obs_qty_exc. // 049 12/11/21 Halley Gotway MET #1991 Fix VCNT output. // 050 02/11/22 Halley Gotway MET #2045 Fix HiRA output. +// 051 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -107,17 +108,15 @@ using namespace std; #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "point_stat.h" #include "vx_statistics.h" @@ -171,12 +170,9 @@ static void set_outdir(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { int i; - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -205,6 +201,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "point_stat"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; int i; diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index da4a35cfd7..f3fb73609d 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -32,6 +32,7 @@ // 011 05/28/21 Halley Gotway Add MCTS HSS_EC output. // 012 01/20/22 Halley Gotway MET #2003 Add PSTD BRIERCL output. // 013 05/25/22 Halley Gotway MET #2147 Add CTS HSS_EC output. +// 014 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -39,18 +40,16 @@ using namespace std; #include #include -#include #include #include -#include #include #include #include -#include #include #include #include +#include "main.h" #include "series_analysis.h" #include "vx_statistics.h" @@ -120,10 +119,7 @@ static void parse_long_names(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler to be called for memory allocation error - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // Process the command line arguments process_command_line(argc, argv); @@ -139,6 +135,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "series_analysis"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { int i; CommandLine cline; diff --git a/src/tools/core/stat_analysis/stat_analysis.cc b/src/tools/core/stat_analysis/stat_analysis.cc index b90c2b7bae..01bb49973a 100644 --- a/src/tools/core/stat_analysis/stat_analysis.cc +++ b/src/tools/core/stat_analysis/stat_analysis.cc @@ -42,6 +42,7 @@ // 012 04/25/21 Halley Gotway Replace pickle files for temporary // ascii. // 013 07/16/21 Halley Gotway MET #1788 Add CBS Index. +// 014 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -112,16 +113,11 @@ static void open_temps(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) { +int met_main(int argc, char * argv []) { int i; StringArray jobs_sa; ConcatString default_config_file; - // - // Set handler to be called for memory allocation error - // - set_new_handler(oom); - // // Parse the command line // @@ -249,6 +245,12 @@ int main(int argc, char * argv []) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "stat_analysis"; +} + +//////////////////////////////////////////////////////////////////////// + void parse_command_line(int &argc, char **argv) { CommandLine cline; int i; diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index db93f4f3bd..fba1cc753d 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -37,6 +37,7 @@ // 012 04/08/19 Halley Gotway Add percentile thresholds. // 013 04/01/19 Fillmore Add FCST and OBS units. // 014 07/09/21 Linden MET #1746 Skip thresholding. +// 015 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -134,10 +135,7 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler to be called for memory allocation error - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // Process the command line arguments process_command_line(argc, argv); @@ -153,6 +151,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "wavelet_stat"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; GrdFileType ftype, otype; diff --git a/src/tools/dev_utils/Makefile.am b/src/tools/dev_utils/Makefile.am index 9240cb48bd..d161fe92b6 100644 --- a/src/tools/dev_utils/Makefile.am +++ b/src/tools/dev_utils/Makefile.am @@ -34,20 +34,20 @@ bin_PROGRAMS = chk4copyright \ chk4copyright_SOURCES = chk4copyright.cc chk4copyright_CPPFLAGS = ${MET_CPPFLAGS} chk4copyright_LDFLAGS = ${MET_LDFLAGS} -chk4copyright_LDADD = -lvx_util \ - -lvx_log +chk4copyright_LDADD = -lvx_log \ + -lvx_util reformat_map_data_SOURCES = reformat_map_data.cc reformat_map_data_CPPFLAGS = ${MET_CPPFLAGS} reformat_map_data_LDFLAGS = ${MET_LDFLAGS} -reformat_map_data_LDADD = -lvx_util \ - -lvx_log +reformat_map_data_LDADD = -lvx_log \ + -lvx_util reformat_county_data_SOURCES = reformat_county_data.cc reformat_county_data_CPPFLAGS = ${MET_CPPFLAGS} reformat_county_data_LDFLAGS = ${MET_LDFLAGS} -reformat_county_data_LDADD = -lvx_util \ - -lvx_log +reformat_county_data_LDADD = -lvx_log \ + -lvx_util pbtime_SOURCES = pbtime.cc \ ../other/pb2nc/openpb.f \ @@ -56,9 +56,9 @@ pbtime_CPPFLAGS = ${MET_CPPFLAGS} pbtime_LDFLAGS = ${MET_LDFLAGS} pbtime_LDADD = -lvx_pb_util \ -lvx_config \ - -lvx_util \ - -lvx_cal \ -lvx_log \ + -lvx_cal \ + -lvx_util \ $(BLIB_NAME) \ $(FLIBS) @@ -69,9 +69,9 @@ gribtab_dat_to_flat_CPPFLAGS = ${MET_CPPFLAGS} gribtab_dat_to_flat_LDFLAGS = ${MET_LDFLAGS} gribtab_dat_to_flat_LDADD = -lvx_pb_util \ -lvx_config \ - -lvx_util \ - -lvx_cal \ -lvx_log \ + -lvx_cal \ + -lvx_util \ $(BLIB_NAME) \ $(FLIBS) @@ -82,9 +82,9 @@ nceptab_to_flat_CPPFLAGS = ${MET_CPPFLAGS} nceptab_to_flat_LDFLAGS = ${MET_LDFLAGS} nceptab_to_flat_LDADD = -lvx_pb_util \ -lvx_config \ - -lvx_util \ - -lvx_cal \ -lvx_log \ + -lvx_cal \ + -lvx_util \ $(BLIB_NAME) \ $(FLIBS) @@ -94,10 +94,10 @@ insitu_nc_to_ascii_CPPFLAGS = ${MET_CPPFLAGS} insitu_nc_to_ascii_LDFLAGS = ${MET_LDFLAGS} insitu_nc_to_ascii_LDADD = -lvx_nc_util \ -lvx_config \ + -lvx_log \ -lvx_util \ -lvx_cal \ -lvx_math \ - -lvx_log \ -lm -lnetcdf_c++4 -lnetcdf swinging_door_SOURCES = swinging_door.cc \ @@ -111,6 +111,7 @@ swinging_door_LDADD = -lvx_time_series \ -lvx_cal \ -lvx_math \ -lvx_log \ + -lvx_util \ -lm -lnetcdf_c++4 -lnetcdf gen_climo_bin_SOURCES = gen_climo_bin.cc diff --git a/src/tools/dev_utils/Makefile.in b/src/tools/dev_utils/Makefile.in index 0cf1a6a71e..73fca6d9f6 100644 --- a/src/tools/dev_utils/Makefile.in +++ b/src/tools/dev_utils/Makefile.in @@ -469,20 +469,20 @@ SUBDIRS = shapefiles chk4copyright_SOURCES = chk4copyright.cc chk4copyright_CPPFLAGS = ${MET_CPPFLAGS} chk4copyright_LDFLAGS = ${MET_LDFLAGS} -chk4copyright_LDADD = -lvx_util \ - -lvx_log +chk4copyright_LDADD = -lvx_log \ + -lvx_util reformat_map_data_SOURCES = reformat_map_data.cc reformat_map_data_CPPFLAGS = ${MET_CPPFLAGS} reformat_map_data_LDFLAGS = ${MET_LDFLAGS} -reformat_map_data_LDADD = -lvx_util \ - -lvx_log +reformat_map_data_LDADD = -lvx_log \ + -lvx_util reformat_county_data_SOURCES = reformat_county_data.cc reformat_county_data_CPPFLAGS = ${MET_CPPFLAGS} reformat_county_data_LDFLAGS = ${MET_LDFLAGS} -reformat_county_data_LDADD = -lvx_util \ - -lvx_log +reformat_county_data_LDADD = -lvx_log \ + -lvx_util pbtime_SOURCES = pbtime.cc \ ../other/pb2nc/openpb.f \ @@ -492,9 +492,9 @@ pbtime_CPPFLAGS = ${MET_CPPFLAGS} pbtime_LDFLAGS = ${MET_LDFLAGS} pbtime_LDADD = -lvx_pb_util \ -lvx_config \ - -lvx_util \ - -lvx_cal \ -lvx_log \ + -lvx_cal \ + -lvx_util \ $(BLIB_NAME) \ $(FLIBS) @@ -506,9 +506,9 @@ gribtab_dat_to_flat_CPPFLAGS = ${MET_CPPFLAGS} gribtab_dat_to_flat_LDFLAGS = ${MET_LDFLAGS} gribtab_dat_to_flat_LDADD = -lvx_pb_util \ -lvx_config \ - -lvx_util \ - -lvx_cal \ -lvx_log \ + -lvx_cal \ + -lvx_util \ $(BLIB_NAME) \ $(FLIBS) @@ -520,9 +520,9 @@ nceptab_to_flat_CPPFLAGS = ${MET_CPPFLAGS} nceptab_to_flat_LDFLAGS = ${MET_LDFLAGS} nceptab_to_flat_LDADD = -lvx_pb_util \ -lvx_config \ - -lvx_util \ - -lvx_cal \ -lvx_log \ + -lvx_cal \ + -lvx_util \ $(BLIB_NAME) \ $(FLIBS) @@ -533,10 +533,10 @@ insitu_nc_to_ascii_CPPFLAGS = ${MET_CPPFLAGS} insitu_nc_to_ascii_LDFLAGS = ${MET_LDFLAGS} insitu_nc_to_ascii_LDADD = -lvx_nc_util \ -lvx_config \ + -lvx_log \ -lvx_util \ -lvx_cal \ -lvx_math \ - -lvx_log \ -lm -lnetcdf_c++4 -lnetcdf swinging_door_SOURCES = swinging_door.cc \ @@ -551,6 +551,7 @@ swinging_door_LDADD = -lvx_time_series \ -lvx_cal \ -lvx_math \ -lvx_log \ + -lvx_util \ -lm -lnetcdf_c++4 -lnetcdf gen_climo_bin_SOURCES = gen_climo_bin.cc diff --git a/src/tools/dev_utils/chk4copyright.cc b/src/tools/dev_utils/chk4copyright.cc index 8d44d1b373..e3e5661a42 100644 --- a/src/tools/dev_utils/chk4copyright.cc +++ b/src/tools/dev_utils/chk4copyright.cc @@ -31,9 +31,7 @@ using namespace std; -#include #include -#include #include #include #include @@ -44,6 +42,7 @@ using namespace std; #include #include +#include "main.h" #include "command_line.h" #include "string_fxns.h" #include "vx_log.h" @@ -78,7 +77,7 @@ static int get_line(int &, ConcatString &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) +int met_main(int argc, char *argv[]) { CommandLine cline; @@ -157,6 +156,14 @@ int main(int argc, char *argv[]) //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "chk4copyright"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { mlog << Error << "\nUsage: " << program_name << "\n" diff --git a/src/tools/dev_utils/gen_climo_bin.cc b/src/tools/dev_utils/gen_climo_bin.cc index ccd19aa5bd..25a1a60cb0 100644 --- a/src/tools/dev_utils/gen_climo_bin.cc +++ b/src/tools/dev_utils/gen_climo_bin.cc @@ -14,6 +14,7 @@ // // Mod# Date Name Description // ---- ---- ---- ----------- +// 000 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -21,18 +22,16 @@ using namespace std; #include #include -#include #include #include -#include #include #include -#include #include #include #include #include +#include "main.h" #include "vx_util.h" #include "vx_nc_util.h" #include "vx_log.h" @@ -86,7 +85,7 @@ static void usage(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { program_name = get_short_name(argv[0]); @@ -131,6 +130,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "gen_climo_bin"; +} + +//////////////////////////////////////////////////////////////////////// + void process_binary() { DataPlane dp; DataPlaneArray dpa; diff --git a/src/tools/dev_utils/gribtab.dat_to_flat.cc b/src/tools/dev_utils/gribtab.dat_to_flat.cc index bbcb27546f..078c04a1ae 100644 --- a/src/tools/dev_utils/gribtab.dat_to_flat.cc +++ b/src/tools/dev_utils/gribtab.dat_to_flat.cc @@ -12,14 +12,13 @@ using namespace std; -#include #include #include #include -#include #include #include +#include "main.h" #include "vx_log.h" #include "vx_util.h" @@ -33,7 +32,7 @@ static void parse_line(const char * line); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -81,6 +80,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "gribtab_daT-to_flat"; +} + + +//////////////////////////////////////////////////////////////////////// + + void parse_line(const char * line) { diff --git a/src/tools/dev_utils/insitu_nc_to_ascii.cc b/src/tools/dev_utils/insitu_nc_to_ascii.cc index 1cbc3249b2..f03a2eabd3 100644 --- a/src/tools/dev_utils/insitu_nc_to_ascii.cc +++ b/src/tools/dev_utils/insitu_nc_to_ascii.cc @@ -12,14 +12,13 @@ using namespace std; -#include #include #include #include -#include #include #include +#include "main.h" #include "vx_log.h" #include "vx_util.h" @@ -39,9 +38,9 @@ const int MAX_EDR_GRIB_CODE = 200; const double FEET_TO_M = 0.3048; -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { - static const string method_name = "insitu_nc_to_ascii::main()"; + static const string method_name = "insitu_nc_to_ascii::met_main()"; // Check the command line and extract the arguments @@ -133,6 +132,14 @@ int main(int argc, char * argv []) //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "insitu_nc_to_ascii"; +} + + +//////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/nceptab_to_flat.cc b/src/tools/dev_utils/nceptab_to_flat.cc index fc82732879..5c9934e163 100644 --- a/src/tools/dev_utils/nceptab_to_flat.cc +++ b/src/tools/dev_utils/nceptab_to_flat.cc @@ -28,16 +28,13 @@ static const char target_start [] = "const struct"; //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include -#include #include #include +#include "main.h" #include "vx_log.h" #include "vx_util.h" @@ -69,7 +66,7 @@ static bool parse_line(const char * line); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -107,6 +104,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "nceptab_to_flat"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/dev_utils/pbtime.cc b/src/tools/dev_utils/pbtime.cc index e5e5a6c396..ec3bcc4517 100644 --- a/src/tools/dev_utils/pbtime.cc +++ b/src/tools/dev_utils/pbtime.cc @@ -14,20 +14,16 @@ // // Mod# Date Name Description // ---- ---- ---- ----------- +// 000 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include @@ -56,7 +52,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { int i_date; ConcatString pb_file, blk_file; unixtime ut; @@ -97,3 +93,9 @@ int main(int argc, char *argv[]) { } //////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return program_name; +} + +//////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/reformat_county_data.cc b/src/tools/dev_utils/reformat_county_data.cc index 74fdfe07c8..a81f84dfa6 100644 --- a/src/tools/dev_utils/reformat_county_data.cc +++ b/src/tools/dev_utils/reformat_county_data.cc @@ -10,16 +10,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include -#include #include #include +#include "main.h" #include "vx_util.h" @@ -40,7 +37,7 @@ static void reformat(const char * input_filename, const char * output_filename); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -66,6 +63,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "reformat_country_data"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/dev_utils/reformat_map_data.cc b/src/tools/dev_utils/reformat_map_data.cc index 7f6f066857..ce0eb1a631 100644 --- a/src/tools/dev_utils/reformat_map_data.cc +++ b/src/tools/dev_utils/reformat_map_data.cc @@ -10,16 +10,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include -#include #include #include +#include "main.h" #include "vx_util.h" @@ -40,7 +37,7 @@ static void reformat(const char * input_filename, const char * output_filename); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -66,6 +63,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "reformat_map_data"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/dev_utils/shapefiles/Makefile.am b/src/tools/dev_utils/shapefiles/Makefile.am index 35ca347b31..3062b2f05b 100644 --- a/src/tools/dev_utils/shapefiles/Makefile.am +++ b/src/tools/dev_utils/shapefiles/Makefile.am @@ -18,9 +18,10 @@ make_mapfiles_CPPFLAGS = ${MET_CPPFLAGS} make_mapfiles_LDFLAGS = ${MET_LDFLAGS} make_mapfiles_LDADD = -lvx_config \ -lvx_gis \ + -lvx_log \ -lvx_util \ - -lvx_math \ -lvx_cal \ + -lvx_math \ -lvx_log \ -lm diff --git a/src/tools/dev_utils/shapefiles/Makefile.in b/src/tools/dev_utils/shapefiles/Makefile.in index e475f39acc..41203ec2e4 100644 --- a/src/tools/dev_utils/shapefiles/Makefile.in +++ b/src/tools/dev_utils/shapefiles/Makefile.in @@ -318,9 +318,10 @@ make_mapfiles_CPPFLAGS = ${MET_CPPFLAGS} make_mapfiles_LDFLAGS = ${MET_LDFLAGS} make_mapfiles_LDADD = -lvx_config \ -lvx_gis \ + -lvx_log \ -lvx_util \ - -lvx_math \ -lvx_cal \ + -lvx_math \ -lvx_log \ -lm diff --git a/src/tools/dev_utils/shapefiles/make_mapfiles.cc b/src/tools/dev_utils/shapefiles/make_mapfiles.cc index 615b67d2e3..2f7c452b94 100644 --- a/src/tools/dev_utils/shapefiles/make_mapfiles.cc +++ b/src/tools/dev_utils/shapefiles/make_mapfiles.cc @@ -12,17 +12,16 @@ using namespace std; -#include #include #include #include -#include #include #include #include #include #include +#include "main.h" #include "vx_util.h" #include "shp_file.h" @@ -108,7 +107,7 @@ static void patch(ConcatString &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -189,6 +188,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "make_mapfilws"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/dev_utils/swinging_door.cc b/src/tools/dev_utils/swinging_door.cc index cd701da0ef..c38032dc30 100644 --- a/src/tools/dev_utils/swinging_door.cc +++ b/src/tools/dev_utils/swinging_door.cc @@ -18,27 +18,24 @@ // ---- ---- ---- ----------- // 000 08-19-14 Rehak New // 001 04-27-154 Halley Gotway List and format output files +// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include #include -#include #include #include #include #include +#include "main.h" #include "vx_nc_util.h" #include "vx_util.h" #include "vx_math.h" @@ -74,14 +71,10 @@ static bool write_ramps(const vector< SDObservation > &observations, //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) +int met_main(int argc, char *argv[]) { CommandLine cline; - // Set handler to be called for memory allocation error - - set_new_handler(oom); - // Check for zero arguments if (argc == 1) @@ -121,6 +114,12 @@ int main(int argc, char *argv[]) //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return program_name; +} + +//////////////////////////////////////////////////////////////////////// + bool process_file() { // Read in the input data diff --git a/src/tools/other/ascii2nc/ascii2nc.cc b/src/tools/other/ascii2nc/ascii2nc.cc index 09ee7489f7..45efcb7e73 100644 --- a/src/tools/other/ascii2nc/ascii2nc.cc +++ b/src/tools/other/ascii2nc/ascii2nc.cc @@ -45,28 +45,23 @@ // 017 01-25-21 Halley Gotway MET #1630 Handle zero obs. // 018 03-01-21 Fillmore Replace pickle files for temporary // ascii. +// 019 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include #include -#include -using namespace netCDF; +#include "main.h" #include "data2d_factory.h" #include "mask_poly.h" @@ -147,18 +142,13 @@ static void setup_wrapper_path(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { CommandLine cline; - // - // Set handler to be called for memory allocation error - // - set_new_handler(oom); - // // Check for zero arguments // - if(argc == 1) usage(); + if(argc == 1) { usage(); return 0; } // // Parse the command line into tokens @@ -189,7 +179,7 @@ int main(int argc, char *argv[]) { // Check for error. There should be at least two arguments left: // the ascii input filenames and the netCDF output filename // - if(cline.n() < 2) usage(); + if(cline.n() < 2) { usage(); return 0; } // // Store the input ASCII file name and the output NetCDF file name @@ -239,7 +229,7 @@ int main(int argc, char *argv[]) { if(!file_handler->readAsciiFiles(asfile_list)) { mlog << Error << "\n" << program_name << "-> " << "encountered an error while reading input files!\n\n"; - exit(1); + return 1; } // @@ -262,6 +252,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return program_name; +} + +//////////////////////////////////////////////////////////////////////// + FileHandler *create_file_handler(const ASCIIFormat format, const ConcatString &ascii_filename) { #ifdef ENABLE_PYTHON @@ -497,7 +493,6 @@ void usage() { << flush; - exit (1); } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index ab489047f8..5df9c68656 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -18,25 +18,22 @@ // 001 11/15/21 Halley Gotway MET #1968 Ensemble -ctrl error check. // 002 01/14/21 McCabe MET #1695 All members in one file. // 003 02/17/22 Halley Gotway MET #1918 Add normalize config option. +// 004 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include +#include "main.h" #include "gen_ens_prod.h" #include "vx_nc_util.h" @@ -87,14 +84,11 @@ static void set_ctrl_file (const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { // Set up OpenMP (if enabled) init_openmp(); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -107,6 +101,14 @@ int main(int argc, char *argv[]) { return(0); } +//////////////////////////////////////////////////////////////////////// + + +const string get_tool_name() { + return "gen_ens_prod"; +} + + //////////////////////////////////////////////////////////////////////// void process_command_line(int argc, char **argv) { diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 0295d9247c..dfcb1eef07 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -28,25 +28,22 @@ // 010 08/30/21 Halley Gotway MET #1891 Fix input and mask fields. // 011 12/13/21 Halley Gotway MET #1993 Fix -type grid. // 012 05/05/22 Halley Gotway MET #2152 Add -type poly_xy. +// 013 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include #include +#include "main.h" #include "gen_vx_mask.h" #include "grib_classes.h" @@ -62,12 +59,9 @@ using namespace std; //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { static DataPlane dp_data, dp_mask, dp_out; - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -99,6 +93,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "gen_vx_mask"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; diff --git a/src/tools/other/gis_utils/Makefile.am b/src/tools/other/gis_utils/Makefile.am index 8afa92eaf4..72b76ddead 100644 --- a/src/tools/other/gis_utils/Makefile.am +++ b/src/tools/other/gis_utils/Makefile.am @@ -20,9 +20,9 @@ gis_dump_shp_CPPFLAGS = ${MET_CPPFLAGS} gis_dump_shp_LDFLAGS = ${MET_LDFLAGS} gis_dump_shp_LDADD = -lvx_config \ -lvx_gis \ - -lvx_util \ -lvx_cal \ -lvx_log \ + -lvx_util \ -lm gis_dump_shx_SOURCES = gis_dump_shx.cc @@ -31,9 +31,9 @@ gis_dump_shx_CPPFLAGS = ${MET_CPPFLAGS} gis_dump_shx_LDFLAGS = ${MET_LDFLAGS} gis_dump_shx_LDADD = -lvx_config \ -lvx_gis \ - -lvx_util \ -lvx_cal \ -lvx_log \ + -lvx_util \ -lm gis_dump_dbf_SOURCES = gis_dump_dbf.cc @@ -42,8 +42,8 @@ gis_dump_dbf_CPPFLAGS = ${MET_CPPFLAGS} gis_dump_dbf_LDFLAGS = ${MET_LDFLAGS} gis_dump_dbf_LDADD = -lvx_config \ -lvx_gis \ - -lvx_util \ -lvx_cal \ -lvx_log \ + -lvx_util \ -lm diff --git a/src/tools/other/gis_utils/Makefile.in b/src/tools/other/gis_utils/Makefile.in index ca9c58dcbb..2612a7c3cc 100644 --- a/src/tools/other/gis_utils/Makefile.in +++ b/src/tools/other/gis_utils/Makefile.in @@ -333,9 +333,9 @@ gis_dump_shp_CPPFLAGS = ${MET_CPPFLAGS} gis_dump_shp_LDFLAGS = ${MET_LDFLAGS} gis_dump_shp_LDADD = -lvx_config \ -lvx_gis \ - -lvx_util \ -lvx_cal \ -lvx_log \ + -lvx_util \ -lm gis_dump_shx_SOURCES = gis_dump_shx.cc @@ -343,9 +343,9 @@ gis_dump_shx_CPPFLAGS = ${MET_CPPFLAGS} gis_dump_shx_LDFLAGS = ${MET_LDFLAGS} gis_dump_shx_LDADD = -lvx_config \ -lvx_gis \ - -lvx_util \ -lvx_cal \ -lvx_log \ + -lvx_util \ -lm gis_dump_dbf_SOURCES = gis_dump_dbf.cc @@ -353,9 +353,9 @@ gis_dump_dbf_CPPFLAGS = ${MET_CPPFLAGS} gis_dump_dbf_LDFLAGS = ${MET_LDFLAGS} gis_dump_dbf_LDADD = -lvx_config \ -lvx_gis \ - -lvx_util \ -lvx_cal \ -lvx_log \ + -lvx_util \ -lm all: all-am diff --git a/src/tools/other/gis_utils/gis_dump_dbf.cc b/src/tools/other/gis_utils/gis_dump_dbf.cc index f5fddd2a21..1afd53e07f 100644 --- a/src/tools/other/gis_utils/gis_dump_dbf.cc +++ b/src/tools/other/gis_utils/gis_dump_dbf.cc @@ -1,5 +1,3 @@ - - //////////////////////////////////////////////////////////////////////// @@ -15,18 +13,15 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include #include #include -#include #include +#include "main.h" #include "vx_util.h" #include "vx_log.h" @@ -52,7 +47,7 @@ static void usage(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -163,6 +158,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "gis_dump_dbf"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/other/gis_utils/gis_dump_shp.cc b/src/tools/other/gis_utils/gis_dump_shp.cc index 0f29a53486..6db3275963 100644 --- a/src/tools/other/gis_utils/gis_dump_shp.cc +++ b/src/tools/other/gis_utils/gis_dump_shp.cc @@ -1,5 +1,3 @@ - - //////////////////////////////////////////////////////////////////////// @@ -15,18 +13,15 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include #include #include -#include #include +#include "main.h" #include "vx_util.h" #include "vx_log.h" @@ -77,7 +72,7 @@ static void do_point_dump (ShpFile &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -159,6 +154,12 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return "gis_dump_shp"; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gis_utils/gis_dump_shx.cc b/src/tools/other/gis_utils/gis_dump_shx.cc index c799d50015..d8b37d049f 100644 --- a/src/tools/other/gis_utils/gis_dump_shx.cc +++ b/src/tools/other/gis_utils/gis_dump_shx.cc @@ -1,5 +1,3 @@ - - //////////////////////////////////////////////////////////////////////// @@ -15,18 +13,15 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include #include #include -#include #include +#include "main.h" #include "vx_util.h" #include "vx_log.h" @@ -52,7 +47,7 @@ static void usage(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -135,6 +130,13 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return "gis_dump_shx"; +} + + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/grid_diag/grid_diag.cc b/src/tools/other/grid_diag/grid_diag.cc index 60f2446209..a8e2212371 100644 --- a/src/tools/other/grid_diag/grid_diag.cc +++ b/src/tools/other/grid_diag/grid_diag.cc @@ -18,25 +18,22 @@ // 001 07/28/20 Halley Gotway Updates for #1391. // 002 03/04/21 Halley Gotway Bugfix #1694. // 003 08/20/21 Halley Gotway Bugfix #1886 for integer overflow. +// 004 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include +#include "main.h" #include "grid_diag.h" #include "series_data.h" #include "series_pdf.h" @@ -70,10 +67,7 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler to be called for memory allocation error - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // Process the command line arguments process_command_line(argc, argv); @@ -234,6 +228,12 @@ void process_command_line(int argc, char **argv) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "grid_diag"; +} + +//////////////////////////////////////////////////////////////////////// + void process_series(void) { DataPlane data_dp[conf_info.get_n_data()]; double min, max; diff --git a/src/tools/other/gsi_tools/gsid2mpr.cc b/src/tools/other/gsi_tools/gsid2mpr.cc index e392986bf5..33b841d370 100644 --- a/src/tools/other/gsi_tools/gsid2mpr.cc +++ b/src/tools/other/gsi_tools/gsid2mpr.cc @@ -16,22 +16,20 @@ // ---- ---- ---- ----------- // 000 06/09/15 Bullock New // 001 01/26/16 Halley Gotway Add -no_check_dup option. +// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include #include #include -#include #include #include +#include "main.h" #include "vx_util.h" #include "vx_math.h" #include "config_constants.h" @@ -65,7 +63,7 @@ static void set_outdir(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) { +int met_main(int argc, char * argv []) { CommandLine cline; ConcatString output_filename; @@ -122,6 +120,12 @@ int main(int argc, char * argv []) { // //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "gsid2mpr"; +} + +//////////////////////////////////////////////////////////////////////// + void process_conv(const char *conv_filename, const char *output_filename) { int i; int n_in, n_out; diff --git a/src/tools/other/gsi_tools/gsidens2orank.cc b/src/tools/other/gsi_tools/gsidens2orank.cc index f6fc8ff898..fc1347794b 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.cc +++ b/src/tools/other/gsi_tools/gsidens2orank.cc @@ -15,22 +15,20 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 07/09/15 Halley Gotway New +// 001 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include #include #include -#include #include #include +#include "main.h" #include "vx_data2d_factory.h" #include "vx_util.h" #include "vx_math.h" @@ -75,7 +73,7 @@ static void set_hdr(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) { +int met_main(int argc, char * argv []) { CommandLine cline; StringArray ens_file_list; int i; @@ -184,6 +182,12 @@ int main(int argc, char * argv []) { // //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "gisdens2orank"; +} + +//////////////////////////////////////////////////////////////////////// + void process_conv(const char *conv_filename, int i_mem) { int i, n_in; diff --git a/src/tools/other/ioda2nc/ioda2nc.cc b/src/tools/other/ioda2nc/ioda2nc.cc index 6fa1201a6e..ab00a45ef5 100644 --- a/src/tools/other/ioda2nc/ioda2nc.cc +++ b/src/tools/other/ioda2nc/ioda2nc.cc @@ -20,21 +20,18 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 07-21-20 Howard Soh New +// 001 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include -#include #include #include -#include #include +#include "main.h" #include "apply_mask.h" #include "ioda2nc_conf_info.h" #include "vx_log.h" @@ -164,12 +161,9 @@ static bool has_postfix(std::string const &, std::string const &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { int i; - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Initialize static variables initialize(); @@ -202,6 +196,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "ioda2nc"; +} + +//////////////////////////////////////////////////////////////////////// + void initialize() { n_total_obs = 0; diff --git a/src/tools/other/lidar2nc/Makefile.am b/src/tools/other/lidar2nc/Makefile.am index 9563167eee..d4ebc99268 100644 --- a/src/tools/other/lidar2nc/Makefile.am +++ b/src/tools/other/lidar2nc/Makefile.am @@ -41,7 +41,6 @@ lidar2nc_LDADD = -lvx_shapedata \ -lvx_gnomon \ -lvx_stat_out \ -lvx_statistics \ - -lvx_gsl_prob \ -lvx_grid \ -lvx_util \ -lvx_config \ @@ -49,6 +48,7 @@ lidar2nc_LDADD = -lvx_shapedata \ -lvx_math \ -lvx_cal \ -lvx_log \ + -lvx_util \ $(PYTHON_LIBS) \ -lvx_summary \ -lmfhdf -ldf -ljpeg \ diff --git a/src/tools/other/lidar2nc/Makefile.in b/src/tools/other/lidar2nc/Makefile.in index e7cd912834..c14f6d1138 100644 --- a/src/tools/other/lidar2nc/Makefile.in +++ b/src/tools/other/lidar2nc/Makefile.in @@ -361,7 +361,6 @@ lidar2nc_LDADD = -lvx_shapedata \ -lvx_gnomon \ -lvx_stat_out \ -lvx_statistics \ - -lvx_gsl_prob \ -lvx_grid \ -lvx_util \ -lvx_config \ @@ -369,6 +368,7 @@ lidar2nc_LDADD = -lvx_shapedata \ -lvx_math \ -lvx_cal \ -lvx_log \ + -lvx_util \ $(PYTHON_LIBS) \ -lvx_summary \ -lmfhdf -ldf -ljpeg \ diff --git a/src/tools/other/lidar2nc/lidar2nc.cc b/src/tools/other/lidar2nc/lidar2nc.cc index 87f153bae1..18adf15d73 100644 --- a/src/tools/other/lidar2nc/lidar2nc.cc +++ b/src/tools/other/lidar2nc/lidar2nc.cc @@ -17,6 +17,7 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 03-22-17 Bullock New +// 001 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -27,18 +28,13 @@ static const char hdr_typ_string[] = "calipso"; //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include @@ -49,6 +45,7 @@ using namespace std; #include "hdf.h" #include "mfhdf.h" +#include "main.h" #include "data2d_factory.h" #include "mask_poly.h" #include "vx_grid.h" @@ -103,18 +100,12 @@ static void write_nc_record(const float * f, int qc_value = -1); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { program_name = get_short_name(argv[0]); - // - // Set handler to be called for memory allocation error - // - -set_new_handler(oom); - // // parse command line // @@ -159,6 +150,12 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return "lidar2nc"; +} + //////////////////////////////////////////////////////////////////////// void usage() { diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index ecb537b8a4..fd5640210b 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -32,28 +32,22 @@ // observation type. // 006 07-23-18 Halley Gotway Support masks from gen_vx_mask. // 007 01-11-19 Howard Soh Added config file option. +// 008 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include -#include -using namespace netCDF; - +#include "main.h" #include "madis2nc.h" #include "data2d_factory.h" @@ -127,12 +121,7 @@ static void set_config(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // - // Set handler to be called for memory allocation error - // - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // // Initialize static variables @@ -183,6 +172,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "madis2nc"; +} + +//////////////////////////////////////////////////////////////////////// + void initialize() { mdfile.clear(); diff --git a/src/tools/other/mode_graphics/Makefile.am b/src/tools/other/mode_graphics/Makefile.am index fc5e1f530b..e1861a8de3 100644 --- a/src/tools/other/mode_graphics/Makefile.am +++ b/src/tools/other/mode_graphics/Makefile.am @@ -35,10 +35,10 @@ plot_mode_field_LDADD = -lvx_config \ -lvx_pxm \ -lvx_render \ -lvx_color \ + -lvx_log \ -lvx_util \ -lvx_config \ -lvx_cal \ - -lvx_log \ -lvx_math \ -lcairo -lfreetype -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lz diff --git a/src/tools/other/mode_graphics/Makefile.in b/src/tools/other/mode_graphics/Makefile.in index c747c4aa74..4effb87ed7 100644 --- a/src/tools/other/mode_graphics/Makefile.in +++ b/src/tools/other/mode_graphics/Makefile.in @@ -361,10 +361,10 @@ plot_mode_field_LDADD = -lvx_config \ -lvx_pxm \ -lvx_render \ -lvx_color \ + -lvx_log \ -lvx_util \ -lvx_config \ -lvx_cal \ - -lvx_log \ -lvx_math \ -lcairo -lfreetype -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lz diff --git a/src/tools/other/mode_graphics/plot_mode_field.cc b/src/tools/other/mode_graphics/plot_mode_field.cc index 6e4a3d5ce5..118fbe9b6d 100644 --- a/src/tools/other/mode_graphics/plot_mode_field.cc +++ b/src/tools/other/mode_graphics/plot_mode_field.cc @@ -16,6 +16,7 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 09-05-14 Bullock New +// 001 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// @@ -30,15 +31,6 @@ static const int ctable_text_width = 30; //////////////////////////////////////////////////////////////////////// -using namespace std; - - -//////////////////////////////////////////////////////////////////////// - - -using namespace std; - -#include #include #include #include @@ -47,6 +39,7 @@ using namespace std; #include "cgraph.h" +#include "main.h" #include "mode_nc_output_file.h" #include "vx_plot_util.h" @@ -209,7 +202,7 @@ static void draw_raw_colortable(Cgraph &, const Box & map_box); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -262,6 +255,12 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return "plot_mode_field"; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/mtd.cc b/src/tools/other/mode_time_domain/mtd.cc index dc816c5400..1a1fcf2f1d 100644 --- a/src/tools/other/mode_time_domain/mtd.cc +++ b/src/tools/other/mode_time_domain/mtd.cc @@ -19,6 +19,7 @@ // 001 05-15-17 Prestopnik P. Added regrid shape // 002 04-18-19 Halley Gotway Add FCST and OBS units. // 003 04-25-19 Halley Gotway Add percentiles to 2D output. +// 004 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_ain // //////////////////////////////////////////////////////////////////////// @@ -41,13 +42,11 @@ static const char default_prefix [] = "mtd"; //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include +#include "main.h" #include "vx_data2d_factory.h" #include "apply_mask.h" #include "mtd_config_info.h" @@ -96,7 +95,7 @@ static void do_single_field(MtdConfigInfo &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -886,6 +885,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "mtd"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/other/modis_regrid/modis_regrid.cc b/src/tools/other/modis_regrid/modis_regrid.cc index ccf0ad4e95..0157de39fd 100644 --- a/src/tools/other/modis_regrid/modis_regrid.cc +++ b/src/tools/other/modis_regrid/modis_regrid.cc @@ -16,14 +16,12 @@ static const char default_units [] = "none"; //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include +#include "main.h" #include "modis_file.h" #include "vx_util.h" @@ -84,7 +82,7 @@ int get_compress(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -158,6 +156,12 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return "modis_regrid"; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index 7dc9629403..985b027b10 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -53,26 +53,23 @@ // 09/15/17 Howard Soh Removed options: -all, and -use_var_id. // 015 02/10/18 Halley Gotway Add message_type_group_map. // 016 07/23/18 Halley Gotway Support masks defined by gen_vx_mask. +// 017 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include #include +#include "main.h" #include "pb2nc_conf_info.h" #include "data_class.h" #include "data2d_factory.h" @@ -413,12 +410,9 @@ derive_var_cfg::derive_var_cfg(ConcatString _var_name) { //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { int i; - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Initialize static variables initialize(); @@ -462,6 +456,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return program_name; +} + +//////////////////////////////////////////////////////////////////////// + void initialize() { n_total_obs = 0; 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 d5eb23e571..b373c520f4 100644 --- a/src/tools/other/plot_data_plane/plot_data_plane.cc +++ b/src/tools/other/plot_data_plane/plot_data_plane.cc @@ -25,24 +25,21 @@ // Mod# Date Name Description // ---- ---- ---- ----------- // 000 12/19/11 Holmes New +// 001 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "vx_log.h" #include "data_plane.h" #include "vx_data2d.h" @@ -85,7 +82,7 @@ static void set_title_string(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv[]) { +int met_main(int argc, char * argv[]) { program_name = get_short_name(argv[0]); @@ -217,6 +214,12 @@ int main(int argc, char * argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "plot_data_plane"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; diff --git a/src/tools/other/plot_point_obs/plot_point_obs.cc b/src/tools/other/plot_point_obs/plot_point_obs.cc index 5990a33769..47ccd59e44 100644 --- a/src/tools/other/plot_point_obs/plot_point_obs.cc +++ b/src/tools/other/plot_point_obs/plot_point_obs.cc @@ -25,24 +25,21 @@ // plot. // 003 01/24/13 Halley Gotway Add -dotsize. // 004 11/10/20 Halley Gotway Add -config and -plot_grid. +// 005 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_mai // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "plot_point_obs.h" #include "data_plane_plot.h" @@ -69,7 +66,7 @@ static void set_dotsize(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { CommandLine cline; // Check for zero arguments @@ -132,6 +129,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "plot_point_obs"; +} + +//////////////////////////////////////////////////////////////////////// + void process_point_obs(const char *point_obs_filename) { int h, v, i_obs; const char *method_name = "process_point_obs() -> "; diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index 7b4285e0b4..fd125500cf 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -19,17 +19,15 @@ // ---- ---- ---- ----------- // 000 12-11-19 Howard Soh Support GOES-16 // 001 01-25-21 Halley Gotway MET #1630 Handle zero obs. +// 002 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include -#include +#include "main.h" #include "vx_log.h" #include "vx_data2d_factory.h" #include "vx_data2d.h" @@ -204,14 +202,11 @@ static void set_qc_flags(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { // Store the program name program_name = get_short_name(argv[0]); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -223,6 +218,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "point2grid"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; static const char *method_name = "process_command_line() -> "; diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index b3e77bf356..3c9188b000 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -23,14 +23,12 @@ // 003 09-24-17 Howard Soh Support Gaussian filtering // 004 01-28-20 Howard Soh Moved GOES-16/17 to point2grib // 005 04-09-20 Halley Gotway Add convert and censor options. +// 006 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include #include @@ -42,6 +40,7 @@ using namespace std; #include #include +#include "main.h" #include "vx_log.h" #include "vx_data2d_factory.h" #include "vx_data2d.h" @@ -100,14 +99,11 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { // Store the program name program_name = get_short_name(argv[0]); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -119,6 +115,17 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "regrid_data_plane"; +} + +//////////////////////////////////////////////////////////////////////// + +void initialize() { +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; diff --git a/src/tools/other/shift_data_plane/shift_data_plane.cc b/src/tools/other/shift_data_plane/shift_data_plane.cc index bf05003341..1affa85a9b 100644 --- a/src/tools/other/shift_data_plane/shift_data_plane.cc +++ b/src/tools/other/shift_data_plane/shift_data_plane.cc @@ -21,21 +21,17 @@ // ---- ---- ---- ----------- // 000 11-12-14 Halley Gotway New // 001 06-07-22 Halley Gotway MET #2173 Fix python embedding +// 002 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include @@ -91,14 +87,11 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { // Store the program name program_name = get_short_name(argv[0]); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -110,6 +103,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "shift_data_plane"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; diff --git a/src/tools/other/wwmca_tool/wwmca_plot.cc b/src/tools/other/wwmca_tool/wwmca_plot.cc index 839fbc2359..1e742cf99a 100644 --- a/src/tools/other/wwmca_tool/wwmca_plot.cc +++ b/src/tools/other/wwmca_tool/wwmca_plot.cc @@ -22,17 +22,14 @@ static const char map_filename [] = "MET_BASE/map/country_major_lakes_data"; //////////////////////////////////////////////////////////////////////// -using namespace std; - -#include #include #include #include #include -#include #include #include +#include "main.h" #include "vx_log.h" #include "vx_util.h" #include "vx_math.h" @@ -124,7 +121,7 @@ static void draw_meridian(PSfile & plot, const char hemisphere, double lon); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -172,6 +169,14 @@ return ( 0 ); //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "wwmca_plot"; +} + + +//////////////////////////////////////////////////////////////////////// + + void usage() { diff --git a/src/tools/other/wwmca_tool/wwmca_regrid.cc b/src/tools/other/wwmca_tool/wwmca_regrid.cc index 31261c00aa..5aa45f6737 100644 --- a/src/tools/other/wwmca_tool/wwmca_regrid.cc +++ b/src/tools/other/wwmca_tool/wwmca_regrid.cc @@ -80,7 +80,7 @@ static void sanity_check(); //////////////////////////////////////////////////////////////////////// -int main(int argc, char * argv []) +int met_main(int argc, char * argv []) { @@ -172,6 +172,12 @@ return ( 0 ); } +//////////////////////////////////////////////////////////////////////// + +const string get_tool_name() { + return "wwmca_regrid"; +} + //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc b/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc index b885f3bf27..0ae2a6584f 100644 --- a/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc +++ b/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc @@ -6,21 +6,17 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "rmw_analysis.h" #include "vx_nc_util.h" @@ -48,10 +44,7 @@ static void read_nc_tracks(NcFile*); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler for memory allocation error - set_new_handler(oom); // out of memory +int met_main(int argc, char *argv[]) { // Process command line arguments process_command_line(argc, argv); @@ -73,6 +66,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "rmw_analysis"; +} + +//////////////////////////////////////////////////////////////////////// + void usage() { cout << "\n*** Model Evaluation Tools (MET" << met_version diff --git a/src/tools/tc_utils/tc_dland/Makefile.am b/src/tools/tc_utils/tc_dland/Makefile.am index 4dd626c77d..d304029ddf 100644 --- a/src/tools/tc_utils/tc_dland/Makefile.am +++ b/src/tools/tc_utils/tc_dland/Makefile.am @@ -20,11 +20,11 @@ tc_dland_LDADD = -lvx_tc_util \ -lvx_grid \ -lvx_gnomon \ -lvx_nav \ + -lvx_log \ -lvx_util \ -lvx_config \ -lvx_gsl_prob \ -lvx_cal \ -lvx_math \ - -lvx_log \ -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas \ $(FLIBS) diff --git a/src/tools/tc_utils/tc_dland/Makefile.in b/src/tools/tc_utils/tc_dland/Makefile.in index 6e33b7ae30..8efdd55cc8 100644 --- a/src/tools/tc_utils/tc_dland/Makefile.in +++ b/src/tools/tc_utils/tc_dland/Makefile.in @@ -338,12 +338,12 @@ tc_dland_LDADD = -lvx_tc_util \ -lvx_grid \ -lvx_gnomon \ -lvx_nav \ + -lvx_log \ -lvx_util \ -lvx_config \ -lvx_gsl_prob \ -lvx_cal \ -lvx_math \ - -lvx_log \ -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas \ $(FLIBS) diff --git a/src/tools/tc_utils/tc_dland/tc_dland.cc b/src/tools/tc_utils/tc_dland/tc_dland.cc index 34e8f262c8..5fad6ae650 100644 --- a/src/tools/tc_utils/tc_dland/tc_dland.cc +++ b/src/tools/tc_utils/tc_dland/tc_dland.cc @@ -17,24 +17,21 @@ // 000 03/19/12 Halley Gotway New // 001 07/25/14 Halley Gotway Add -land option and update how // distances are computed. +// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "grib_classes.h" #include "vx_log.h" @@ -96,13 +93,10 @@ static void set_compress(const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { +int met_main(int argc, char *argv[]) { program_name = get_short_name(argv[0]); - // Set handler to be called for memory allocation error - set_new_handler(oom); - // Process the command line arguments process_command_line(argc, argv); @@ -117,6 +111,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "tc_dland"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index 1e339dbec5..ecb53f577c 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -23,25 +23,22 @@ // 006 11/04/21 Halley Gotway MET #1809 Add -edeck option // 007 11/22/21 Halley Gotway MET #1810 Add -shape option // 008 05/02/22 Halley Gotway MET #2148 Fix init_hour and lead misses +// 009 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include +#include "main.h" #include "tc_gen.h" #include "pair_data_genesis.h" @@ -155,10 +152,7 @@ static void set_out (const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler to be called for memory allocation error - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // Process the command line arguments process_command_line(argc, argv); @@ -217,6 +211,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "tc_gen"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; ConcatString default_config_file; diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/src/tools/tc_utils/tc_pairs/tc_pairs.cc index f997c43524..fd5f6d20ba 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -33,25 +33,22 @@ // that contain all required lead times. // 011 07/27/18 Halley Gotway Support masks defined by // the gen_vx_mask tool. +// 020 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include #include -#include #include #include #include +#include "main.h" #include "tc_pairs.h" #include "vx_nc_util.h" @@ -154,10 +151,7 @@ static void set_out (const StringArray &); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler to be called for memory allocation error - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // Process the command line arguments process_command_line(argc, argv); @@ -176,6 +170,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "tc_gen"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; ConcatString default_config_file; diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index 5bac0a311e..0ddfcdd710 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -16,22 +16,21 @@ // ---- ---- ---- ----------- // 000 04/18/19 Fillmore New // 001 05/15/20 Halley Gotway Fix data file list option logic. +// 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "tc_rmw.h" #include "tcrmw_grid.h" @@ -80,10 +79,7 @@ static void process_fields(const TrackInfoArray&); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler for memory allocation error - set_new_handler(oom); // out of memory +int met_main(int argc, char *argv[]) { // Process command line arguments process_command_line(argc, argv); @@ -102,6 +98,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "tc_rmw"; +} + +//////////////////////////////////////////////////////////////////////// + void usage() { cout << "\n*** Model Evaluation Tools (MET" << met_version diff --git a/src/tools/tc_utils/tc_stat/tc_stat.cc b/src/tools/tc_utils/tc_stat/tc_stat.cc index 73865d4d9f..ae2610eba4 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat.cc @@ -19,24 +19,21 @@ // 002 09/28/16 Halley Gotway Add DESC output column. // 003 07/27/18 Halley Gotway Support masks defined by // the gen_vx_mask tool. +// 020 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include -#include #include #include -#include #include #include -#include #include #include #include +#include "main.h" #include "tc_stat.h" #include "tc_stat_job.h" @@ -61,10 +58,7 @@ static void close_out_file (); //////////////////////////////////////////////////////////////////////// -int main(int argc, char *argv[]) { - - // Set handler to be called for memory allocation error - set_new_handler(oom); +int met_main(int argc, char *argv[]) { // Process the command line arguments process_command_line(argc, argv); @@ -80,6 +74,12 @@ int main(int argc, char *argv[]) { //////////////////////////////////////////////////////////////////////// +const string get_tool_name() { + return "tc_stat"; +} + +//////////////////////////////////////////////////////////////////////// + void process_command_line(int argc, char **argv) { CommandLine cline; ConcatString default_config_file;