int main (int argc, char **argv) { GOptionGroup *options; GOptionContext *context; GError *error = NULL; GMainLoop *loop; GstElement *play; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_set_application_name (_("Audio Preview")); g_setenv("PULSE_PROP_application.icon_name", "totem", TRUE); g_setenv("PULSE_PROP_media.role", "music", TRUE); context = g_option_context_new ("Plays audio passed on the standard input or the filename passed on the command-line"); options = gst_init_get_option_group (); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_add_group (context, options); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print ("couldn't parse command-line options: %s\n", error->message); g_error_free (error); return 1; } if (g_fatal_warnings) { GLogLevelFlags fatal_mask; fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; g_log_set_always_fatal (fatal_mask); } if (show_mimetype == TRUE) { print_mimetypes (); return 0; } if (filenames != NULL && g_strv_length (filenames) != 1) { char *help; help = g_option_context_get_help (context, FALSE, NULL); g_print ("%s", help); g_free (help); return 1; } play = gst_element_factory_make ("playbin", "play"); setup_play (play); setup_filename (play); setup_errors (play); totem_resources_monitor_start (NULL, -1); gst_element_set_state (play, GST_STATE_PLAYING); loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (loop); return 0; }
int main(int argc, char **argv) { // Set stack size (not necesart for jobs) set_stacksize(max(32, MHD::Nx*MHD::Nky/1000)); feenableexcept(FE_DIVBYZERO | FE_INVALID); signal(SIGFPE, signal_handler); signal(SIGINT , signal_handler); signal(SIGUSR1 , signal_handler); signal(SIGUSR2 , signal_handler); std::string setup_filename(""), setup_Xoptions(""); int c; while ((c = getopt(argc, argv, "c:o:")) != -1) { switch(c) { case 'c' : setup_filename = std::string(optarg); break; case 'o' : setup_Xoptions = std::string(optarg); break; default: std::cout << "Unknown option : " << optarg << " please check if compiled for this mode " << std::endl; exit(1); } } // Start as ./MHD -c File -o Options /*********************************************************** // Start Helios engine and main loop ***********************************************************/ sim = new MHD(setup_filename, setup_Xoptions); sim->startMainLoop(); delete sim; }
/** * @brief Program starting point * * The main program. Reads in program arguments and initializes * the Setup class and the gkc class and handles over the * control to mainLoop * **/ int main(int argc, char **argv) { // Set stack size (necesary to set for local jobs) System::set_min_stacksize(256); // Some internal variables time_t start_sim_time, start_all_time, end_sim_time, end_all_time; // Rank can be changed by MPI Process process_rank = 0; time(&start_all_time); ////////////////////////////////////////////////////////////////// // // Check command line parameters (note, the user can also // specify PETSc parameters // std::string setup_filename(""), setup_Xoptions(""), setup_ExArgv(""), stack_size(""); // set it to automatic ? std::string setup_decomposition("Auto Decomposition"); int gkcFlags=0; /////////////////// Read In Command Line Arguments ////////////////// int c; extern char *optarg; while ((c = getopt(argc, argv, "x:o:c:d:v;s:;f;i")) != -1) { switch(c) { case 'c' : setup_filename = std::string(optarg); break; case 'o' : setup_Xoptions = std::string(optarg); break; case 'x' : setup_ExArgv = std::string(optarg); break; case 'd' : setup_decomposition = std::string(optarg); break; case 'v' : gkcFlags |= Setup::GKC_VERBOSE; break; case 's' : stack_size = std::string(optarg); break; case 'f' : gkcFlags |= Setup::GKC_OVERWRITE; break; case 'i' : gkcFlags |= Setup::GKC_READ_STDIN; break; //case 'b' : gkcFlags |= GKC_SILENT; // break; default: std::cout << "Unknown option : " << optarg << " please check if compiled for this mode " << std::endl; exit(1); } } // Get simulation properties and setup Setup *setup = new Setup(argc, argv, setup_filename, setup_decomposition, setup_Xoptions, setup_ExArgv, gkcFlags); ////////////////// Start gkc engine and main loop ///////////////////// // define static, as destructor is called @ exit() (see, § 3.6.3 of C++03) static GKC *gkc = new GKC(setup); time(&start_sim_time); int GKC_status = gkc->mainLoop(); time(&end_sim_time); ////////////////////////////////////////////////////////////////////////// // Clean up and print basic informations. delete gkc; delete setup; time(&end_all_time); if(process_rank == MASTER_PROCESS) { std::cout << "Total Time : " << end_all_time - start_all_time << "s" << " Loop Time : " << end_sim_time - start_sim_time << "s" <<std::endl; } return 0; }