26 #include <stk_util/util/Null_Streambuf.hpp> 27 #include <stk_util/parallel/mpi_filebuf.hpp> 29 #include <stk_util/diag/Timer.hpp> 30 #include <stk_util/diag/Writer.hpp> 31 #include <stk_util/diag/WriterRegistry.hpp> 32 #include <stk_util/diag/Env.hpp> 33 #include <stk_util/diag/Platform.hpp> 36 #include <stk_util/parallel/ExceptionReport.hpp> 37 #include <stk_util/parallel/MPI.hpp> 39 #include <stk_util/environment/ProductRegistry.hpp> 40 #include <stk_util/diag/StringUtil.hpp> 43 #include <stk_util/diag/PreParse.hpp> 46 #include <stk_util/environment/ProgramOptions.hpp> 48 #include <stk_util/parallel/BroadcastArg.hpp> 49 #include <stk_util/parallel/ParallelReduce.hpp> 50 #include <stk_util/util/Bootstrap.hpp> 51 #include <stk_util/util/IndentStreambuf.hpp> 61 boost::program_options::options_description desc(
"Runtime environment", 120);
63 (
"help,h",
"Display command line options")
64 (
"directory,d", boost::program_options::value<std::string>()->default_value(
"./"),
"Set working directory")
65 (
"output-log,o", boost::program_options::value<std::string>()->default_value(
""),
"Output log file path, one of : 'cout', 'cerr', or a file path")
66 (
"logfile,l", boost::program_options::value<std::string>()->default_value(
""),
"Output log file path, one of : 'cout', 'cerr', or a file path")
67 (
"pout", boost::program_options::value<std::string>()->implicit_value(
"-"),
"Per-processor log file path")
68 (
"dout", boost::program_options::value<std::string>()->implicit_value(
"out"),
"Diagnostic output stream one of: 'cout', 'cerr', 'out' or a file path")
70 (
"version",
"Display version information")
71 (
"jamsub", boost::program_options::value<std::string>(),
"Display user subroutine build command")
72 (
"runtest", boost::program_options::value<std::string>()->implicit_value(
"pid"),
"Record process host and pid to this file")
73 (
"developer-mode",
"Activate developer specific features")
74 (
"architecture", boost::program_options::value<std::string>(),
"Specifies the architecture running the sierra application");
83 typedef std::map<ExecType, ExecInfo> ExecMap;
85 static EnvData &instance() {
92 : m_productName(
"not specified"),
95 m_outputNull(&m_nullBuf),
96 m_outputP0(&std::cout),
98 m_startTime((
double) ::time(NULL)),
100 m_shutdownRequested(
false),
101 m_inputFileRequired(
true),
102 m_checkSubCycle(
false),
103 m_worldComm(MPI_COMM_NULL),
104 m_parallelComm(MPI_COMM_NULL),
139 std::string m_productName;
141 boost::program_options::variables_map & m_vm;
143 null_streambuf m_nullBuf;
144 std::ostream m_outputNull;
145 std::ostream * m_outputP0;
146 std::ostringstream m_output;
149 std::string m_executablePath;
151 bool m_shutdownRequested;
152 bool m_inputFileRequired;
153 bool m_checkSubCycle;
155 MPI_Comm m_worldComm;
157 MPI_Comm m_parallelComm;
163 const std::string m_emptyString;
164 const std::string m_onString;
166 std::string m_inputFile;
174 return EnvData::instance().m_productName;
181 return EnvData::instance().m_executablePath;
190 if (executable_date.empty())
191 executable_date = ProductRegistry::instance().getProductAttribute(EnvData::instance().m_productName, ProductRegistry::BUILD_TIME);
202 if (startup_date.empty())
203 startup_date =
format_time(EnvData::instance().m_startTime).c_str();
212 return EnvData::instance().m_startTime;
219 return !
get_param(
"developer-mode").empty();
223 void setInputFileName(std::string name) {
224 EnvData::instance().m_inputFile = name;
227 std::string getInputFileName() {
228 return EnvData::instance().m_inputFile;
233 EnvData::instance().m_inputFileRequired = value;
238 EnvData::instance().m_checkSubCycle = value;
252 std::string directory =
get_param(
"directory");
253 if (directory[0] !=
'/' && getcwd(cwd, PATH_MAX) != NULL) {
264 return EnvData::instance().m_output;
271 return *EnvData::instance().m_outputP0;
277 return EnvData::instance().m_outputNull;
284 static const char *s_sectionSeparator =
"+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----";
286 return s_sectionSeparator;
293 static const char *s_subsectionSeparator =
"---------------------------------------------------";
295 return s_subsectionSeparator;
301 const std::string &
title)
305 std::ostringstream strout;
313 return EnvData::instance().m_parallelSize;
317 return EnvData::instance().m_parallelRank;
323 return EnvData::instance().m_parallelComm;
329 return EnvData::instance().m_worldComm;
333 return EnvData::instance().m_execMap[
EXEC_TYPE_LAG].m_master;
345 get_program_path(
const char *program)
348 if (program[0] ==
'/')
351 char full_path[PATH_MAX];
352 if (strchr(program,
'/') != NULL) {
353 realpath(program, full_path);
357 char *PATH = getenv(
"PATH");
358 while (PATH && *PATH) {
361 char *end = strchr(PATH,
':');
363 end = PATH+strlen(PATH);
367 strncpy(full_path, PATH, end-PATH);
368 full_path[end-PATH] =
'/';
369 strcpy(&full_path[end-PATH+1], program);
372 if (access(full_path, X_OK) == 0)
376 PATH = *end ? end+1 : end;
387 void parse_options(MPI_Comm comm,
int *argc,
char ***argv);
388 void startup_multi_exec(MPI_Comm world_comm,
ExecType my_executable_type,
const std::vector<int> *peer_sizes);
395 const char * build_time,
397 const std::vector<int> *peer_sizes) {
398 bool returnValue =
false;
402 EnvData &env_data = EnvData::instance();
404 env_data.m_executablePath = get_program_path(*argv[0]);
407 ProductRegistry::instance().setProductName(product_name);
409 ProductRegistry::AttributeMap &product_attributes = ProductRegistry::instance().getProductAttributeMap(product_name);
410 product_attributes[ProductRegistry::BUILD_TIME] = build_time;
411 product_attributes[ProductRegistry::EXECUTABLE] = env_data.m_executablePath;
414 sierra::register_product();
417 sierra::mpih::register_product();
420 ProductRegistry::AttributeMap &attr_map = ProductRegistry::instance().addProduct(
osname().c_str());
421 attr_map[ProductRegistry::VERSION] =
osversion().c_str();
424 namespace opt = boost::program_options;
429 boost::program_options::options_description desc(
"Diagnostic writers", 120);
432 std::ostringstream str;
433 str <<
"Diagnostic writer " << (*it).first << std::endl;
434 (*it).second.second->describe(str);
435 desc.add_options()((*it).first.c_str(), boost::program_options::value<std::string>(), str.str().c_str());
438 std::ostringstream str;
439 str <<
"Wall and CPU time options" << std::endl;
440 Diag::theTimerParser().describe(str);
441 desc.add_options()(
"timer", boost::program_options::value<std::string>(), str.str().c_str());
446 for (
int i = 0; i < *argc; ++i) {
447 const std::string s((*argv)[i]);
448 if (s ==
"-h" || s ==
"-help" || s ==
"--help") {
449 std::cout << std::endl
450 <<
"Sierra Usage: sierra " <<
lower(product_name) <<
" [sierra-options...] -O \"[" <<
lower(product_name) <<
"-options...]\"" << std::endl << std::endl
452 <<
"For example:" << std::endl
454 <<
" sierra " <<
lower(product_name) <<
" -i input_deck.i -o sierra.log" << std::endl
455 <<
" This creates the normal output file sierra.log" << std::endl
457 <<
" sierra " <<
lower(product_name) <<
" -i input_deck.i -o sierra.log -O \"--pout=pp.log\"" << std::endl
458 <<
" The per-processor output is written to pp.log.n.r for each rank, r, of n processors." << std::endl
460 <<
" sierra " <<
lower(product_name) <<
" -i input_deck.i -o sierra.log -O \"--fmwkout=field,parameters\"" << std::endl
461 <<
" Enable the framework field and parameter diagnostics" << std::endl
463 <<
" sierra " <<
lower(product_name) <<
" -i input_deck.i -o sierra.log -O \"--timer=all\"" << std::endl
464 <<
" Enable the all timers" << std::endl
466 <<
" For additional information see:" << std::endl
467 <<
" http://sierra-dev.sandia.gov/stk/group__stk__util__output__log__detail.html#stk_util_output_log_howto_use_in_sierra_app" << std::endl << std::endl
468 << product_name <<
" options are:" << std::endl
474 for (
int i = 0; i < *argc; ++i) {
475 const std::string s((*argv)[i]);
476 if (s ==
"-jamsub" || s ==
"--jamsub") {
477 const char *t = (*argv)[i + 1];
478 const char **symbol = sierra::Plugin::Registry::getsym<const char **>(t);
480 std::cout << *symbol << std::endl;
492 int mpi_init_val = 0 ;
493 if ( MPI_SUCCESS != MPI_Initialized( &mpi_init_val ) ) {
498 MPI_Comm startup_mpi_comm = MPI_COMM_WORLD;
503 if ( mpi_init_val == 0 ) {
504 if ( MPI_SUCCESS != MPI_Init( argc , argv ) ) {
510 if (mpi_key !=
EXEC_TYPE_WORLD) startup_multi_exec(startup_mpi_comm, mpi_key, peer_sizes);
514 MPI_Comm new_comm = mpi_key !=
EXEC_TYPE_WORLD ? env_data.m_execMap[mpi_key].m_groupComm : MPI_COMM_WORLD;
517 catch (
const std::exception &x) {
518 std::cerr <<
"SIERRA execution failed during mpi initialization with the following exception:" << std::endl
519 << x.what() << std::endl;
520 MPI_Abort(env_data.m_parallelComm , MPI_ERR_OTHER);
523 std::cerr <<
"SIERRA execution failed during mpi initialization with unknown exception:" << std::endl;
525 MPI_Abort(env_data.m_parallelComm, MPI_ERR_OTHER);
528 parse_options(env_data.m_parallelComm, argc, argv);
531 std::ostringstream output_description;
539 std::string out_path1 = vm[
"output-log"].as<std::string>();
540 std::string out_path2 = vm[
"logfile"].as<std::string>();
545 std::string modifiedFileName = originalFileName;
547 if(originalFileName ==
"") {
552 if (env_data.m_inputFileRequired) {
553 throw RuntimeError() <<
"No input file specified. An input file must be specified with the '-i' option";
555 std::cerr <<
"WARNING: No input file specified. An input file should be specified with the '-i' option!" << std::endl;
558 }
else if ( env_data.m_checkSubCycle ) {
560 bool debugSubCycleSplit =
false;
561 std::string subCycleRegexp(
"^\\s*subcycle\\s+blocks\\s*=");
562 bool subCycleSet = CaseInSensitiveRegexInFile(subCycleRegexp, originalFileName, debugSubCycleSplit);
563 std::string coarseRegionRegexp(
"^\\s*begin\\s+presto\\s+region\\s+\\w+_AutoCoarseRegion\\>");
564 bool coarseRegionMade = CaseInSensitiveRegexInFile( coarseRegionRegexp, originalFileName, debugSubCycleSplit);
565 std::string fineRegionRegexp(
"^\\s*begin\\s+presto\\s+region\\s+\\w+_AutoFineRegion\\>");
566 bool fineRegionMade = CaseInSensitiveRegexInFile( fineRegionRegexp, originalFileName, debugSubCycleSplit);
568 if ( !coarseRegionMade && !fineRegionMade ) {
569 modifiedFileName = CreateSubCycleInputFile( originalFileName );
572 std::cout<<
"Input File: " << originalFileName <<
" Appears to have already been converted for subcycling. ";
573 std::cout<<
"Skipping input conversion " << std::endl;
579 setInputFileName(modifiedFileName);
583 if(out_path2 !=
"") {
585 }
else if(out_path1 !=
"") {
600 int dotPos = originalFileName.rfind(
".");
603 trueOut = originalFileName +
".log";
605 trueOut = originalFileName.substr(0, dotPos) +
".log";
610 int apreproPos = trueOut.rfind(
".aprepro");
611 if(apreproPos != -1) {
612 trueOut.erase(apreproPos, 8);
617 int lastSlashPos = trueOut.rfind(
"/");
619 if(lastSlashPos != -1) {
620 trueOut.erase(0,lastSlashPos+1);
626 std::string out_path = trueOut;
631 std::string out_ostream;
634 if (out_path.size() && out_path[0] !=
'/')
639 output_description <<
"outfile=\"" << out_path <<
"\"";
640 out_ostream =
"outfile";
643 out_ostream = out_path;
647 out_ostream =
"null";
649 std::string pout_ostream =
"null";
650 if (vm.count(
"pout")) {
651 std::string pout_path = vm[
"pout"].as<std::string>();
652 if (pout_path ==
"-") {
653 std::ostringstream s;
662 std::ostringstream s;
669 output_description <<
" poutfile=\"" << pout_path <<
"\"";
670 pout_ostream =
"poutfile";
673 pout_ostream = pout_path;
677 std::string dout_ostream;
678 if (vm.count(
"dout")) {
679 std::string dout_path = vm[
"dout"].as<std::string>();
681 dout_ostream = dout_path;
683 std::ostringstream s;
684 if (dout_path.size() && dout_path[0] !=
'/')
689 output_description <<
" doutfile=\"" << dout_path <<
"\"";
690 dout_ostream =
"doutfile";
694 dout_ostream =
"out";
697 output_description <<
" out>" << out_ostream <<
"+pout";
699 output_description <<
" out>pout";
701 output_description <<
" pout>" << pout_ostream <<
" dout>" << dout_ostream;
709 #ifdef SIERRA_EXPORT_CONTROL_EAR99 716 std::cerr <<
"ERROR: You are running an EAR99 export controlled version of\n";
717 std::cerr <<
" Sierra. For this export control level, a maximum of\n";
718 std::cerr <<
" "<<SIERRA_EXPORT_CONTROL_EAR99<<
" processors is permitted\n";
720 MPI_Abort(env_data.m_parallelComm, MPI_ERR_OTHER);
730 mpi_buf.open(env_data.m_parallelComm, 0, std::ios::out,
get_param(
"runtest").c_str());
732 if ( ! mpi_buf.is_open() )
735 std::ostream s( &mpi_buf );
743 Diag::sierraTimerSet().setEnabledTimerMask(parser.
parse(
get_param(
"timer").c_str()));
749 catch (
const std::exception &x) {
750 std::cerr <<
"SIERRA execution failed during diagnostic and timer initialization with the following exception:" << std::endl
751 << x.what() << std::endl;
755 std::cerr <<
"SIERRA execution failed during diagnostic and timer initialization with unknown exception:" << std::endl;
776 const char * build_time,
778 const std::vector<int> *peer_sizes) {
779 m_mpiInitFlag =
StartupSierra(argc, argv, product_name, build_time, mpi_key, peer_sizes);
786 const char * product_name,
787 const char * build_date_time,
789 const std::vector<int> *peer_sizes)
790 : m_mpiInitFlag(false)
792 startup(argc, argv, product_name, build_date_time, mpi_key, peer_sizes);
796 void ShutDownSierra(
bool mpiInitFlag) {
800 mpih::Delete_Handles();
802 EnvData &env_data = EnvData::instance();
803 mpih::Keyval_delete(env_data.m_parallelComm);
805 reset(MPI_COMM_NULL);
814 ShutDownSierra(m_mpiInitFlag);
818 void parse_options(MPI_Comm comm,
823 char ** argv2 =
new char *[*argc];
824 for (
int i = 0; i < *argc; ++i) {
825 if (std::strlen((*argv)[i]) > 2 && (*argv)[i][0] ==
'-' && (*argv)[i][1] !=
'-') {
826 argv2[i] =
new char[std::strlen((*argv)[i]) + 2];
828 std::strcpy(&argv2[i][1], (*argv)[i]);
831 argv2[i] =
new char[std::strlen((*argv)[i]) + 1];
832 std::strcpy(argv2[i], (*argv)[i]);
839 for (
int i = 0; i < *argc; ++i)
843 namespace opt = boost::program_options;
846 opt::store(opt::parse_command_line(b_arg.
m_argc, b_arg.
m_argv, od, opt::command_line_style::unix_style), vm);
850 if (vm.count((*it).first.c_str()))
851 (*it).second.second->parse(vm[(*it).first.c_str()].as<std::string>().c_str());
855 const std::string &working_dir =
get_param(
"directory");
856 if ( working_dir.empty() || working_dir ==
PARAM_ON )
857 throw RuntimeError() <<
"working directory must be specified";
858 if (working_dir[working_dir.length() - 1] !=
'/')
859 const_cast<std::string &>(working_dir) +=
'/';
862 catch (
const std::exception &x) {
863 std::cerr <<
"SIERRA execution failed during command line processing with the following exception:" << std::endl
864 << x.what() << std::endl;
865 MPI_Abort(comm, MPI_ERR_OTHER);
868 std::cerr <<
"SIERRA execution failed during command line processing with unknown exception:" << std::endl;
870 MPI_Abort(comm, MPI_ERR_OTHER);
875 startup_multi_exec(MPI_Comm world_comm,
877 const std::vector<int> *peer_sizes)
879 EnvData &env_data = EnvData::instance();
882 int world_size = -1 ;
883 int world_rank = -1 ;
885 if ( MPI_Comm_size(world_comm, &world_size) != MPI_SUCCESS)
888 if ( MPI_Comm_rank(world_comm, &world_rank) != MPI_SUCCESS || -1 == world_rank )
897 int lag_rank_size = -1;
898 int fluid_master = 0;
900 if (world_rank == 0) {
901 typedef std::map<ExecType, std::vector<int> > ExecTypeRanks;
903 ExecTypeRanks exec_type_ranks;
905 exec_type_ranks[my_executable_type].push_back(0);
907 for (
int i = 1; i < world_size; ++i) {
910 if (MPI_Recv(proc_stat, 2, MPI_INTEGER, i, MPI_ANY_TAG, world_comm, &status) != MPI_SUCCESS)
913 exec_type_ranks[(
ExecType) proc_stat[1]].push_back(proc_stat[0]);
917 if (fluid_ranks.size())
918 fluid_master = fluid_ranks.front();
920 if (MPI_Bcast(&fluid_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
923 std::vector<int> &lag_ranks = exec_type_ranks[
EXEC_TYPE_LAG];
924 if (lag_ranks.size())
925 lag_master = lag_ranks.front();
927 if (MPI_Bcast(&lag_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
930 lag_rank_size = lag_ranks.size();
931 if (MPI_Bcast(&lag_rank_size, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
936 proc_stat[0] = world_rank;
937 proc_stat[1] = my_executable_type;
939 if (MPI_Send(proc_stat, 2, MPI_INTEGER, 0, 0, world_comm) != MPI_SUCCESS)
942 if (MPI_Bcast(&fluid_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
945 if (MPI_Bcast(&lag_master, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
948 if (MPI_Bcast(&lag_rank_size, 1, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
952 MPI_Comm lag_comm = world_comm;
953 MPI_Comm fluid_comm = MPI_COMM_NULL;
954 const int fluid_rank_size = world_size - lag_rank_size;
955 if (fluid_rank_size) {
957 MPI_Group world_group;
959 MPI_Group fluid_group;
961 if (MPI_Comm_group(world_comm, &world_group) != MPI_SUCCESS)
964 std::vector<int> lag_ranks;
965 for (
int i = 0; i < lag_rank_size; ++i)
966 lag_ranks.push_back(lag_master + i);
968 if (MPI_Group_incl(world_group, lag_ranks.size(), &lag_ranks[0], &lag_group) != MPI_SUCCESS)
970 if (MPI_Comm_create(world_comm, lag_group, &lag_comm) != MPI_SUCCESS)
973 std::vector<int> fluid_ranks;
974 for (
int i = 0; i < fluid_rank_size; ++i)
975 fluid_ranks.push_back(fluid_master + i);
977 if (MPI_Group_incl(world_group, fluid_ranks.size(), &fluid_ranks[0], &fluid_group) != MPI_SUCCESS)
979 if (MPI_Comm_create(world_comm, fluid_group, &fluid_comm) != MPI_SUCCESS)
983 env_data.m_worldComm = world_comm;
1004 if (peer_sizes != NULL && peer_sizes->size() > 2) {
1005 throw RuntimeError() <<
"The total number of peer application processor sizes specfied is " 1006 << peer_sizes->size()
1007 <<
", but the current limit is 2.";
1013 if (world_rank == 0) {
1014 if (peer_sizes != NULL) {
1015 peers[0] = (*peer_sizes)[0];
1016 peers[1] = (*peer_sizes)[1];
1018 peers[0] = world_size / 2;
1019 peers[1] = world_size - world_size/2;
1022 if (MPI_Bcast(peers, 2, MPI_INTEGER, 0, world_comm) != MPI_SUCCESS)
1023 throw RuntimeError() <<
"MPI_Broadcast -- peers failed";
1027 int peer_proc_count = peers[0] + peers[1];
1028 if (peer_proc_count != world_size) {
1029 throw RuntimeError() <<
"The total number of peer processors specfied is " << peer_proc_count
1030 <<
" which is not equal to the total number of processors (" << world_size <<
").";
1033 int my_peer_group = MPI_UNDEFINED;
1035 for (
size_t i=0; i < 2; i++) {
1037 if (world_rank < sum) {
1044 if (MPI_Comm_split(world_comm, my_peer_group, world_rank, &peer_comm) != MPI_SUCCESS) {
1047 env_data.m_worldComm = world_comm;
1056 EnvData &env_data = EnvData::instance();
1057 if (env_data.m_parallelComm == MPI_COMM_NULL) {
1068 EnvData &env_data = EnvData::instance();
1071 if (env_data.m_parallelComm != MPI_COMM_NULL) {
1073 if (new_comm != MPI_COMM_NULL) {
1074 mpih::Sub_Communicator(env_data.m_parallelComm, new_comm);
1077 env_data.m_parallelComm = MPI_COMM_NULL ;
1078 env_data.m_parallelSize = -1;
1079 env_data.m_parallelRank = -1 ;
1082 setMpiCommunicator(new_comm);
1085 void setMpiCommunicator(MPI_Comm communicator)
1087 EnvData &env_data = EnvData::instance();
1088 if(communicator != MPI_COMM_NULL)
1090 env_data.m_parallelComm = communicator;
1092 if(MPI_Comm_size(env_data.m_parallelComm, &env_data.m_parallelSize) != MPI_SUCCESS
1093 || MPI_Comm_rank(env_data.m_parallelComm, &env_data.m_parallelRank) != MPI_SUCCESS
1094 || env_data.m_parallelSize == -1
1095 || env_data.m_parallelRank == -1)
1097 throw RuntimeError() <<
"reset given bad MPI communicator";
1105 EnvData &env_data = EnvData::instance();
1110 env_data.m_output.str(
"");
1115 request_shutdown(
bool shutdown)
1117 EnvData::instance().m_shutdownRequested = shutdown;
1122 is_shutdown_requested()
1124 int shutdown_requested_in = EnvData::instance().m_shutdownRequested ||
Env::HUP_received();
1127 MPI_Allreduce(&shutdown_requested_in, &shutdown_requested, 1, MPI_INT, MPI_SUM,
Env::parallel_comm());
1129 return shutdown_requested != 0;
1134 EnvData &env_data = EnvData::instance();
1138 std::cerr << std::endl
1139 <<
"*** SIERRA ABORT on P" << EnvData::instance().m_parallelRank <<
" ***" 1141 <<
"*** check " <<
get_param(
"output-log")
1142 <<
" file for more information ***" 1145 if (!env_data.m_output.str().empty()) {
1146 std::cerr <<
"Buffer contents of deferred output stream on processor " <<
parallel_rank()
1148 std::cerr << env_data.m_output.str();
1156 MPI_Abort(env_data.m_parallelComm, MPI_ERR_OTHER);
1157 std::exit( EXIT_FAILURE );
1163 const char *
const option)
1165 if (EnvData::instance().m_vm.count(option)) {
1166 if (EnvData::instance().m_vm[option].as<std::string>().empty())
1167 return EnvData::instance().m_onString;
1169 return EnvData::instance().m_vm[option].as<std::string>();
1172 return EnvData::instance().m_emptyString;
1178 const char * option,
1179 const std::string & value) {
1182 namespace opt = boost::program_options;
1188 char *s = std::strcpy(
new char[std::strlen(option) + 1], option);
1190 opt::store(opt::parse_command_line(argc, &s, od), vm);
std::ostream & dout()
Diagnostic output stream.
std::ostream & output()
Function output returns the processor output log stream. This stream is connected via an mpi_filebuf ...
std::string title(const std::string &s)
Function title returns a first letter of each word capitalized of the string.
std::ostream & dwout()
Diagnostic writer stream.
const std::string & startup_date()
Function startup_date returns the startup date of this application execution.
std::string osversion()
Function osversion returns the hardware type of the host running the application. ...
void set_param(const char *option, const std::string &value)
Member function set_param assigns the value to the parameter option.
void set_check_subcycle(bool value)
Function set_check_subcycle sets whether to check input file for subcycling. The default behavior cor...
Class TimerParser implements the bit mask parser for the timer's bit masks.
Generic application using entire communicator (MPI_COMM_WORLD)
~Startup()
Destroys a Startup instance. IT closes all logging output streams and will finalize MPI only if the S...
double wall_now()
Member function wall_now returns the epoch as a double precision value in seconds to "millisecond" ac...
std::ostream & outputP0()
Function outputP0 returns the processor output log stream on processor 0 and the null log stream on a...
Split communicator application; non-Gemini.
const std::string working_directory()
Function working_directory returns the current working directory of this application execution...
std::ostream & pout()
Per-processor output stream (See RuntimeDeferredx)
void unregister_log_ostream(std::ostream &os)
Function register_log_ostream takes an existing std::ostream and makes it available for output redire...
const std::string & executable_file()
Function executable_file returns the path of this executable file. information.
int pid()
Function pid returns the process id of the process running the application.
bool shutdown_requested()
Function shutdown_requested returns true if an application shutdown has requested via the request_shu...
boost::program_options::options_description & get_options_description()
Function get_options_description is a singleton used to store the command line option descriptions fo...
std::ostream & outputNull()
Function outputNull returns the null output stream. All data is simply discarded by the buffer associ...
const std::string & architecture()
Function architecture returns the platform executing this product. This is obtained during startup by...
std::ostream & out()
Normal output stream.
void abort()
Function abort aborts the execution of the sierra application.
String lower(const String &s)
Function lower returns a lower case version of the string.
void startup_preparallel_platform()
Function startup_preparallel_platform ...
static const std::string PARAM_ON
Option value when command line option specified without a parameter.
static void bootstrap()
Member function bootstrap runs through the stored bootstrap function pointers and executes each funct...
Class Bootstrap serves as a bootstrapping mechanism for products in the sierra toolkit and elsewhere...
void bind_output_streams(const std::string &output_description)
Function bind_output_streams parses the output_description and opens and registers the log streams an...
std::string section_title(const std::string &title)
Function section_title returns a section title. The title has date and time concatenated and right ju...
Class basic_indent_streambuf implements a output streambuf that performs indentation, blank line removal and outline bracing, sending the result character stream to another output stream buffer.
Mask parse(const char *mask_string) const
Member function parse parses the mask string and generates the corresponding bit mask.
int parallel_rank()
function parallel_rank returns the rank of this processor in the current mpi communicator.
ExecType
Enumeration ExecutableType defines the known types of coordinated executables that operate with a sie...
double start_time()
Function start_time returns the start time of this application execution.
bool is_registered_ostream(const std::string &name)
Function is_registered_ostream returns true if an output stream of the specified name is registered...
void all_write_string(ParallelMachine arg_comm, std::ostream &arg_root_os, const std::string &arg_msg)
Write string from any or all processors to the ostream on the root processor.
ExTemp1< std::runtime_error > RuntimeError
Defined in <stdexcept>
MPI_Comm parallel_world_comm()
Function parallel_world_comm returns the MPI_COMM_WORLD communicator used by the sierra environment i...
bool HUP_received()
Function request_shutdown sets the shutdown requested flag so that future calls to shutdown_requested...
void report_deferred_messages(ParallelMachine comm)
Function report_deferred_messages aggregates and reports the message on the root processor.
char ** m_argv
The broadcasted argv.
const char * subsection_separator()
Function subsection_separator returns a c-style string to be used as a output subsection separator...
Class BroadcastArg creates a copy of argc and argv after broadcasting them from processor 0...
int m_argc
The broadcasted argc.
bool StartupSierra(int *argc, char ***argv, const char *product_name, const char *build_time, ExecType mpi_key, const std::vector< int > *peer_sizes)
Initialize MPI related operations for sierra, outputs banner, etc. returns 1 if MPI was initialized...
std::string format_time(double t, const char *format)
Function format_time encodes the time using the format specified. The format is described in stdftime...
void deactivate_signals()
Function deactivate_signals disables the signal handlers.
int peer_group()
Function peer_group returns the peer group rank for an application of type EXEC_TYPE_PEER.
void register_stl_parallel_exceptions()
Member function register_stl_parallel_exceptions registers the stl exceptions with the parallel excep...
std::string domainname()
Function domainname returns the domainname of the domain running the application. ...
int parallel_lag_master()
Function parallel_lag_master returns the global rank of the Sierra lagrangian application.
WriterRegistry & getWriterRegistry()
Function getWriterRegistry returns a reference to the diagnostic writer registry. ...
Gemini Euler application.
std::ostream & tout()
Regression test textual output stream.
MPI_Comm parallel_comm()
Function parallel_comm returns the current MPI communicator used by the sierra environment.
boost::program_options::variables_map & get_variables_map()
Function get_variabel_map is a singleton used to store the variables parsed from the line option desc...
int parallel_fluid_master()
Function parallel_lag_master returns the global rank of the Gemini Euler application.
const std::string & executable_date()
Function executable_date returns the build date of the executable file as a string in the form Mmm dd...
bool developer_mode()
Function developer_mode returns true if the –developer option was specified on the application comma...
void register_log_ostream(std::ostream &os, const std::string &name)
Function register_log_ostream takes an existing std::ostream and makes it available for output redire...
void reset(MPI_Comm new_comm)
Function reset determines new parallel_size and parallel_rank. Flushes, closes, and reopens log files...
const std::string & get_param(const char *const option)
Function query_env_param searches the command line options for the specified option. If not found, a const reference to an empty string is returned.
int parallel_size()
function parallel_size returns the number of processors in the current mpi communicator.
void register_ostream(std::ostream &os, const std::string &name)
Function register_ostream registers an output stream with the output stream registry. The registration process creates an intermediate tee streambuf.
void activate_signals()
Function activate_signals enables the signal handlers.
Sierra Lagrangian application.
void set_input_file_required(bool value)
Function set_input_file_required sets whether lack of an input file specification will automatically ...
Startup(int *argc, char ***argv, const char *product_name, const char *build_date_time, ExecType mpi_key=EXEC_TYPE_WORLD, const std::vector< int > *peer_sizes=NULL)
Creates a new Startup instance.
int pgrp()
Function pgrp returns the process group id of the process running the application.
std::string osname()
Function osname returns the operating system nameof the host running the application.
std::string hostname()
Function hostname returns the hostname of the host running the application.
void output_flush()
Function output_flush flushes all output on all currently open synchronous outptu files which were op...
_setw setw(int width)
Function setw sets the width for the next field as a manipulator.
void unregister_ostream(std::ostream &os)
Function unregister_ostream unregisters an output stream.
std::ostream * get_log_ostream(const std::string &name)
Function get_log_file_ostream return the output stream of the log file with the specified name from t...
const char * section_separator()
Function output_open opens an output file on processor zero for synchronous data output from all proc...
const std::string & product_name()
Function product_name returns the product's name. This name is used to query the product registry for...