|
Sierra Toolkit
Version of the Day
|
00001 /*--------------------------------------------------------------------*/ 00002 /* Copyright 2003 - 2010 Sandia Corporation. */ 00003 /* Under the terms of Contract DE-AC04-94AL85000, there is a */ 00004 /* non-exclusive license for use of this work by or on behalf */ 00005 /* of the U.S. Government. Export of this program may require */ 00006 /* a license from the United States Government. */ 00007 /*--------------------------------------------------------------------*/ 00008 00009 #ifndef STK_UTIL_DIAG_Env_h 00010 #define STK_UTIL_DIAG_Env_h 00011 00012 #include <ios> // #include <iosfwd> // ios_base is not defined in the forward file 00013 #include <string> 00014 00015 #include <stk_util/stk_config.h> 00016 #if defined( STK_HAS_MPI ) 00017 #include <mpi.h> 00018 #endif 00019 #include <stk_util/parallel/Parallel.hpp> 00020 00021 #include <stk_util/environment/ProgramOptions.hpp> 00022 #include <stk_util/util/Bootstrap.hpp> 00023 00024 #include <stk_util/util/FeatureTest.hpp> 00025 #include <stk_util/diag/Option.hpp> 00026 #include <stk_util/diag/Writer_fwd.hpp> 00027 00028 namespace sierra { 00029 00043 namespace Env { 00044 00045 static const std::string PARAM_ON = "on"; 00046 00051 00062 enum ExecType { 00063 EXEC_TYPE_WORLD = 0, 00064 EXEC_TYPE_FLUID = 1, 00065 EXEC_TYPE_LAG = 2, 00066 EXEC_TYPE_PEER = 3 00067 }; 00068 00069 struct ExecInfo 00070 { 00071 MPI_Comm m_groupComm; 00072 int m_master; 00073 }; 00074 00075 00076 00105 bool StartupSierra(int *argc, char ***argv, const char *product_name, const char *build_date_time, 00106 ExecType mpi_key = EXEC_TYPE_WORLD, const std::vector<int> *peer_sizes = NULL); 00107 00108 // 00109 // Cleanup any MPI stuff that was created from the startup sierra call, pass in the MPI initialization flag 00110 // that StartupSierra generated 00111 // 00112 void ShutDownSierra(bool mpiInitFlag); 00113 00114 00122 class Startup 00123 { 00124 public: 00125 00153 Startup(int *argc, char ***argv, const char *product_name, const char *build_date_time, 00154 ExecType mpi_key = EXEC_TYPE_WORLD, const std::vector<int> *peer_sizes = NULL); 00155 00161 ~Startup(); 00162 00163 private: 00185 void startup(int *argc, char ***argv, const char *product_name, const char *build_time, 00186 ExecType mpi_key, const std::vector<int> *peer_sizes); 00187 00188 private: 00189 bool m_mpiInitFlag; 00190 }; 00191 00192 00212 void reset(MPI_Comm mpi_comm); // , const char * const work_dir = NULL); 00213 void setMpiCommunicator(MPI_Comm communicator); 00214 bool is_comm_valid(); 00215 00216 00228 const std::string &get_param(const char * const option); 00229 00230 00241 void set_param(const char *option, const std::string &value); 00242 00250 const std::string &product_name(); 00251 00252 00261 bool developer_mode(); 00262 00268 void set_input_file_required(bool value); 00269 00270 void setInputFileName(std::string value); 00271 std::string getInputFileName(); 00272 00273 00278 void set_check_subcycle(bool value); 00279 00289 const std::string &architecture(); 00290 00291 00300 const std::string &executable_file(); 00301 00302 00311 const std::string &executable_date(); 00312 00321 const std::string &startup_date(); 00322 00323 00332 double start_time(); 00333 00334 00342 double wall_now(); 00343 00344 00352 double cpu_now(); 00353 00354 00363 double vm_now(); 00364 00365 00374 const std::string working_directory(); 00375 00376 00387 std::ostream &output(); 00388 00389 00399 std::ostream &outputP0(); 00400 00401 00410 std::ostream &outputNull(); 00411 00412 00429 //std::ostream &output_open(const char * const filename); 00430 00431 00439 const char *section_separator(); 00440 00441 00448 const char *subsection_separator(); 00449 00450 00461 std::string section_title(const std::string &title); 00462 00463 00473 void output_flush(); 00474 00475 00487 void output_flush(std::ostream &stream); 00488 00489 void request_shutdown(bool shutdown = true); 00490 00491 bool is_shutdown_requested(); 00492 00498 void abort(); 00499 00500 00508 MPI_Comm parallel_comm(); 00509 00517 MPI_Comm parallel_world_comm(); 00518 00519 00526 int peer_group(); 00527 00528 00535 int parallel_fluid_master(); 00536 00537 00544 int parallel_lag_master(); 00545 00546 00555 int parallel_size(); 00556 00557 00566 int parallel_rank(); 00567 00568 // /** 00569 // * @brief Function <b>set_current_diag_stream</b> set the diagnostic writer current out 00570 // * put stream. The special names - and cout attach the diag stream to the std::cout 00571 // * stream. The special name cerr attaches the stream to the std::cerr stream, output 00572 // * attaches to the stream Env::output() and outputp0 to the stream outputP0(). Otherwise, 00573 // * the file is opened with <b>mode</b> ios mode flags and attached to the diagnostic 00574 // * stream. 00575 // * 00576 // * @param path a <b>char</b> const pointer to the file path to 00577 // * open. 00578 // * 00579 // * @param mode a <b>std::ios::openmode</b> value of the ios mode to 00580 // * open the file. 00581 // * 00582 // */ 00583 // void set_current_diag_stream(const char *path, std::ios_base::openmode mode = std::ios_base::out); 00584 00585 // /** 00586 // * @brief Function <b>getCurrentStream</b> returns the current diagnostic stream. 00587 // * 00588 // * @return a <b>std::ostream</b> reference to the current diagnostic 00589 // * stream. 00590 // */ 00591 // // Diag::Stream &get_current_diag_stream(); 00592 // std::ostream &get_current_diag_stream(); 00593 00597 00598 } // namespace Env 00599 } // namespace sierra 00600 00601 #endif // STK_UTIL_DIAG_Env_h