queso-0.56.0
Environment.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
26 #include <boost/program_options.hpp>
27 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
28 
29 #define GETPOT_NAMESPACE QUESO
30 #include <queso/getpot.h>
31 
32 #include <queso/queso.h>
33 #include <queso/Environment.h>
34 #include <queso/EnvironmentOptions.h>
35 #include <queso/RngGsl.h>
36 #include <queso/RngBoost.h>
37 #include <queso/BasicPdfsGsl.h>
38 #include <queso/BasicPdfsBoost.h>
39 #include <queso/Miscellaneous.h>
40 #include <sys/time.h>
41 #ifdef HAVE_GRVY
42 #include <grvy.h>
43 #endif
44 
45 // queso error handling
46 #include <queso/asserts.h>
47 
48 //-----------------------------
49 // Library versioning routines
50 //-----------------------------
51 
52 namespace QUESO {
53 
54  void QUESO_version_print(std::ostream &os)
55  {
56  {
57  os << "------------------------------------------------------------------------------------------" ;
58  os << "--------------------" << std::endl;
59  os << "QUESO Library: Version = " << QUESO_LIB_VERSION;
60  os << " (" << QUESO_get_numeric_version() << ")" << std::endl << std::endl;
61 
62  os << QUESO_LIB_RELEASE << std::endl << std::endl;
63 
64  os << "Build Date = " << QUESO_BUILD_DATE << std::endl;
65  os << "Build Host = " << QUESO_BUILD_HOST << std::endl;
66  os << "Build User = " << QUESO_BUILD_USER << std::endl;
67  os << "Build Arch = " << QUESO_BUILD_ARCH << std::endl;
68  os << "Build Rev = " << QUESO_BUILD_VERSION << std::endl << std::endl;
69 
70  os << "C++ Config = " << QUESO_CXX << " " << QUESO_CXXFLAGS << std::endl;
71  os << std::endl;
72  os << "Trilinos DIR = " << QUESO_TRILINOS_DIR << std::endl;
73  os << "GSL Libs = " << QUESO_GSL_DIR << std::endl;
74  os << "GRVY DIR = " << QUESO_GRVY_DIR << std::endl;
75  os << "GLPK DIR = " << QUESO_GLPK_DIR << std::endl;
76  os << "HDF5 DIR = " << QUESO_HDF5_DIR << std::endl;
77  os << "------------------------------------------------------------------------------------------" ;
78  os << "--------------------" << std::endl;
79  }
80 
81  return;
82  }
83 
85  {
86  // Note: return format follows the versioning convention xx.yy.z where
87  //
88  // xx = major version number
89  // yy = minor version number
90  // zz = micro version number
91  //
92  // For example:
93  // v. 0.23 -> 002300 = 2300
94  // v. 0.23.1 -> 002301 = 2301
95  // v. 10.23.2 -> 102302
96 
97  int major_version = 0;
98  int minor_version = 0;
99  int micro_version = 0;
100 
101 #ifdef QUESO_MAJOR_VERSION
102  major_version = QUESO_MAJOR_VERSION;
103 #endif
104 
105 #ifdef QUESO_MINOR_VERSION
106  minor_version = QUESO_MINOR_VERSION;
107 #endif
108 
109 #ifdef QUESO_MICRO_VERSION
110  micro_version = QUESO_MICRO_VERSION;
111 #endif
112 
113  return(major_version*10000 + minor_version*100 + micro_version);
114  }
115 
117  :
118  ofsVar(NULL),
119  ifsVar(NULL)
120 #ifdef QUESO_HAS_HDF5
121  , // lol
122  h5Var(-1)
123 #endif
124 {
125 }
126 
128 {
129 }
130 
131  //
132  // queso terminate handler will be invoked for unhandled exceptions
133  // needs to be invoked in FullEnvironment constructor
134  //
135  std::terminate_handler old_terminate_handler;
136 
137 //*****************************************************
138 // Base class
139 //*****************************************************
140 // Default constructor --------------------------------
142  const char* passedOptionsInputFileName,
143  EnvOptionsValues* alternativeOptionsValues)
144  :
145  m_fullEnvIsReady (false),
146  m_worldRank (-1),
147  m_fullComm (NULL),
148  m_fullRank (-1),
149  m_fullCommSize (1),
150  m_optionsInputFileName (""),
151  m_optionsInputFileAccessState(true),
152 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
153  m_allOptionsDesc (NULL),
154  m_allOptionsMap (NULL),
155 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
156  m_input (new GetPot),
157  m_subComm (NULL),
158  m_subRank (-1),
159  m_subCommSize (1),
160  m_selfComm (NULL),
161  m_inter0Comm (NULL),
162  m_inter0Rank (-1),
163  m_inter0CommSize (1),
164  m_subDisplayFile (NULL),
165  m_rngObject (NULL),
166  m_basicPdfs (NULL),
167  m_exceptionalCircumstance (false),
168  m_optionsObj (alternativeOptionsValues)
169 {
170  if (passedOptionsInputFileName) m_optionsInputFileName = passedOptionsInputFileName;
171 }
172 
174  const std::string& passedOptionsInputFileName,
175  EnvOptionsValues* alternativeOptionsValues)
176  :
177  m_fullEnvIsReady (false),
178  m_worldRank (-1),
179  m_fullComm (NULL),
180  m_fullRank (-1),
181  m_fullCommSize (1),
182  m_optionsInputFileName (passedOptionsInputFileName),
183  m_optionsInputFileAccessState(true),
184 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
185  m_allOptionsDesc (NULL),
186  m_allOptionsMap (NULL),
187 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
188  m_input (new GetPot),
189  m_subComm (NULL),
190  m_subRank (-1),
191  m_subCommSize (1),
192  m_selfComm (NULL),
193  m_inter0Comm (NULL),
194  m_inter0Rank (-1),
195  m_inter0CommSize (1),
196  m_subDisplayFile (NULL),
197  m_rngObject (NULL),
198  m_basicPdfs (NULL),
199  m_exceptionalCircumstance (false),
200  m_optionsObj (alternativeOptionsValues)
201 {
202 }
203 
204 // Destructor -------------------------------------------
206 {
207  //if (m_subDisplayFile) {
208  // *m_subDisplayFile << "Entering BaseEnvironment::destructor()"
209  // << std::endl;
210  //}
211 
212  struct timeval timevalNow;
213  /*int iRC = 0;*/
214  /*iRC = */gettimeofday(&timevalNow, NULL);
215 
216  if( this->displayVerbosity() > 0 )
217  {
218  if (m_subDisplayFile) {
219  *m_subDisplayFile << "Ending run at " << ctime(&timevalNow.tv_sec)
220  << "Total run time = " << timevalNow.tv_sec - m_timevalBegin.tv_sec
221  << " seconds"
222  << std::endl;
223  }
224 
225  if (m_fullRank == 0) {
226  std::cout << "Ending run at " << ctime(&timevalNow.tv_sec)
227  << "Total run time = " << timevalNow.tv_sec - m_timevalBegin.tv_sec
228  << " seconds"
229  << std::endl;
230  }
231  }
232 
233 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
234  if (m_allOptionsMap) {
235  delete m_allOptionsMap;
236  delete m_allOptionsDesc;
237  }
238 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
239 
240  if (m_basicPdfs) delete m_basicPdfs;
241  if (m_rngObject) delete m_rngObject;
242 
243  //if (m_subDisplayFile) {
244  // *m_subDisplayFile << "Leaving BaseEnvironment::destructor()"
245  // << std::endl;
246  //}
247 
249  if (m_inter0Comm ) delete m_inter0Comm;
250  if (m_selfComm ) delete m_selfComm;
251  if (m_subComm ) delete m_subComm;
252  if (m_fullComm ) delete m_fullComm;
253 }
254 // Environment, Communicator and Options Input File methods
255 bool
257 {
258  return m_fullEnvIsReady;
259 }
260 //-------------------------------------------------------
261 int
263 {
264  return m_worldRank;
265 }
266 //-------------------------------------------------------
267 int
269 {
270  return m_fullRank;
271 }
272 //-------------------------------------------------------
273 const MpiComm&
275 {
276  queso_require_msg(m_fullComm, "m_fullComm variable is NULL");
277  return *m_fullComm;
278 }
279 //-------------------------------------------------------
282 {
283  return m_subGroup;
284 }
285 //-------------------------------------------------------
286 int
288 {
289  return m_subRank;
290 }
291 //-------------------------------------------------------
292 const MpiComm&
294 {
295  queso_require_msg(m_subComm, "m_subComm variable is NULL");
296  return *m_subComm;
297 }
298 //-------------------------------------------------------
299 const MpiComm&
301 {
302  queso_require_msg(m_selfComm, "m_selfComm variable is NULL");
303  return *m_selfComm;
304 }
305 //-------------------------------------------------------
306 int
308 {
309  return m_inter0Rank;
310 }
311 //-------------------------------------------------------
312 const MpiComm&
314 {
315  queso_require_msg(m_inter0Comm, "m_inter0Comm variable is NULL");
316  return *m_inter0Comm;
317 }
318 //-------------------------------------------------------
319 std::ofstream*
321 {
322  return m_subDisplayFile;
323 }
324 //-------------------------------------------------------
325 std::string
327 {
328  if (m_optionsObj == NULL) return ".";
329 
331 }
332 //-------------------------------------------------------
333 unsigned int
335 {
336  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
338 }
339 //-------------------------------------------------------
340 unsigned int
342 {
343  return m_subId;
344 }
345 //-------------------------------------------------------
346 const std::string&
348 {
349  return m_subIdString;
350 }
351 //-------------------------------------------------------
352 std::string
354 {
356  return m_optionsInputFileName;
357  }
358  else {
359  return "";
360  }
361 }
362 //-------------------------------------------------------
363 void
365 {
367 
368  return;
369 }
370 //-------------------------------------------------------
371 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
372 #ifdef UQ_USES_COMMAND_LINE_OPTIONS
373 const boost::program_options::options_description&
374 BaseEnvironment::allOptionsDesc() const
375 {
377 
378  return *m_allOptionsDesc;
379 }
380 #endif
381 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
382 //-------------------------------------------------------
383 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
384 boost::program_options::variables_map&
386 {
388 
389  queso_require_msg(m_allOptionsMap, "m_allOptionsMap variable is NULL");
390  return *m_allOptionsMap;
391 }
392 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
393 //-------------------------------------------------------
394 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
395 void
396 BaseEnvironment::scanInputFileForMyOptions(const boost::program_options::options_description& optionsDesc) const
397 {
399 
400 #ifdef UQ_USES_COMMAND_LINE_OPTIONS
401  // If you want to use command line options, the following line does *not* work outside 'main.C',
402  // e.g., in the constructor of FullEnvironment:
403  // Line: boost::program_options::store(boost::program_options::parse_command_line(argc, argv, *m_allOptionsDesc), *m_allOptionsMap);
404  //
405  // Instead, put the following three lines *immediately after* instantianting the UQ environment
406  // variable "FullEnvironment* env":
407  // Line 1: boost::program_options::store(boost::program_options::parse_command_line(argc, argv, env->allOptionsDesc()), env->allOptionsMap());
408  // Line 2: boost::program_options::notify(env->allOptionsMap());
409  // Line 3: env->getMyOptionValues();
410 #endif
411 
412 #ifdef QUESO_MEMORY_DEBUGGING
413  std::cout << "Entering BaseEnv::scanInputFileForMyOptions()" << std::endl;
414 #endif
415 
416  queso_require_msg(m_allOptionsDesc, "m_allOptionsDesc variable is NULL");
417  m_allOptionsDesc->add(optionsDesc);
418  //if (m_subDisplayFile) {
419  // *m_subDisplayFile << *m_allOptionsDesc
420  // << std::endl;
421  //}
422 
424  std::string("m_optionsInputFileName is 'nothing'"));
425  //std::ifstream ifs(m_optionsInputFileName.c_str());
426  std::ifstream* ifs = new std::ifstream(m_optionsInputFileName.c_str());
427 #ifdef QUESO_MEMORY_DEBUGGING
428  std::cout << "in BaseEnv::scanInputFileForMyOptions(), before store(a)" << std::endl;
429 #endif
430 
431  queso_require_msg(m_allOptionsMap, "m_allOptionsMap variable is NULL");
432  boost::program_options::store(boost::program_options::parse_config_file(*ifs, *m_allOptionsDesc, true), *m_allOptionsMap);
433 #ifdef QUESO_MEMORY_DEBUGGING
434  std::cout << "in BaseEnv::scanInputFileForMyOptions(), after store(a)" << std::endl;
435 #endif
436  boost::program_options::notify(*m_allOptionsMap);
437 
438  //ifs.close();
439  delete ifs;
440 #ifdef QUESO_MEMORY_DEBUGGING
441  std::cout << "Leaving BaseEnv::scanInputFileForMyOptions()" << std::endl;
442 #endif
443 
444  return;
445 }
446 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
447 //-----------------------------------------------------
448 unsigned int
450 {
451  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
453 }
454 //-------------------------------------------------------
455 unsigned int
457 {
458  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
460 }
461 //-------------------------------------------------------
462 unsigned int
464 {
465  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
467 }
468 //-------------------------------------------------------
469 const RngBase*
471 {
472  return m_rngObject;
473 }
474 //-------------------------------------------------------
475 int
477 {
478  return m_rngObject->seed();
479 }
480 //-------------------------------------------------------
481 void
482 BaseEnvironment::resetSeed(int newSeedOption)
483 {
484  m_rngObject->resetSeed(newSeedOption);
485  return;
486 }
487 //-------------------------------------------------------
488 const BasicPdfsBase*
490 {
491  return m_basicPdfs;
492 }
493 //-------------------------------------------------------
494 std::string
496 {
498 }
499 //-------------------------------------------------------
500 std::string
502 {
504 }
505 //-------------------------------------------------------
506 void
507 BaseEnvironment::resetIdentifyingString(const std::string& newString)
508 {
509  m_optionsObj->m_identifyingString = newString;
510  return;
511 }
512 //-------------------------------------------------------
513 struct timeval
514 BaseEnvironment::timevalBegin() const
515 {
516  return m_timevalBegin;
517 }
518 //-------------------------------------------------------
519 bool
521  const std::string& baseFileName,
522  const std::string& inputFileType,
523  const std::set<unsigned int>& allowedSubEnvIds,
524  bool writeOver,
525  FilePtrSetStruct& filePtrSet) const
526 {
527  std::string fileType(inputFileType);
528 #ifdef QUESO_HAS_HDF5
529  // Do nothing
530 #else
531  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
532  if (m_subDisplayFile) {
533  *this->subDisplayFile() << "WARNING in BaseEnvironment::openOutputFile()"
534  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
535  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
536  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
537  << "' instead..."
538  << std::endl;
539  }
540  if (this->subRank() == 0) {
541  std::cerr << "WARNING in BaseEnvironment::openOutputFile()"
542  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
543  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
544  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
545  << "' instead..."
546  << std::endl;
547  }
549  }
550 #endif
551 
552  bool returnValue = true;
553  filePtrSet.ofsVar = NULL;
554  if ((baseFileName == UQ_ENV_FILENAME_FOR_NO_OUTPUT_FILE) ||
555  (allowedSubEnvIds.find(this->subId()) == allowedSubEnvIds.end() )) {
556  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
557  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
558  << ", subId = " << this->subId()
559  << ": no output file opened with base name '" << baseFileName << "." << fileType
560  << "'"
561  << ", writeOver = " << writeOver
562  << std::endl;
563  }
564  returnValue = false;
565  }
566  else {
568  // Open file
570  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
571  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
572  << ", subId = " << this->subId()
573  << ": opening output file with base name '" << baseFileName << "." << fileType
574  << "'"
575  << ", writeOver = " << writeOver
576  << std::endl;
577  }
578 
579  if (this->subRank() == 0) {
580 #if 0
581  std::cout << "In BaseEnvironment::openOutputFile()"
582  << ": opening output file with base name '" << baseFileName << "." << fileType
583  << "'"
584  << ", writeOver = " << writeOver
585  << std::endl;
586 #endif
587 
589  // Verify parent directory exists (for cases when a user
590  // specifies a relative path for the desired output file).
592  // std::cout << "checking " << baseFileName+"_sub"+this->subIdString()+"."+fileType << std::endl;
593  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
594  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
595  << ", subId = " << this->subId()
596  << ", trying to open output file with base name '" << baseFileName << "." << fileType
597  << "'"
598  << ", writeOver = " << writeOver
599  << ": calling CheckFilePath()..."
600  << std::endl;
601  }
602  int irtrn = CheckFilePath((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str());
603  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
604  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
605  << ", subId = " << this->subId()
606  << ", trying to open output file with base name '" << baseFileName << "." << fileType
607  << "'"
608  << ", writeOver = " << writeOver
609  << ": returned from CheckFilePath() with irtrn = " << irtrn
610  << std::endl;
611  }
612  queso_require_greater_equal_msg(irtrn, 0, "unable to verify output path");
613 
614  if (writeOver) {
616  // Write over an eventual pre-existing file
618  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
619  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
620  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
621  std::ofstream::out | std::ofstream::trunc);
622  }
623  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
624  queso_error_msg("hdf file type not supported yet");
625  }
626  else {
627  queso_error_msg("invalid file type");
628  }
629  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
630  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
631  << ": just opened output file with base name '" << baseFileName << "." << fileType
632  << "'"
633  << ", writeOver = " << writeOver
634  << ", options 'out|trunc'"
635  << ", osfvar = " << filePtrSet.ofsVar
636  << std::endl;
637  }
638  }
639  else {
641  // Write at the end of an eventual pre-existing file
643  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
644  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
645 #if 0
646  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
647  std::ofstream::in);
648  std::cout << "filePtrSet.ofsVar(1) = " << filePtrSet.ofsVar << std::endl;
649  if (filePtrSet.ofsVar) std::cout << "filePtrSet.ofsVar(1)->is_open() = " << filePtrSet.ofsVar->is_open() << std::endl;
650  if (filePtrSet.ofsVar) delete filePtrSet.ofsVar;
651 #endif
652  // 'm' and Ranger nodes behave differently on ofstream constructor... prudenci 2010/03/05
653  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
654  std::ofstream::out /*| std::ofstream::in*/ | std::ofstream::app);
655  }
656 #ifdef QUESO_HAS_HDF5
657  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
658  std::string fullFileName =
659  baseFileName+"_sub"+this->subIdString()+"."+fileType;
660 
661  // Use H5F_ACC_EXCL because not overwriting, so fail on existing file
662  filePtrSet.h5Var = H5Fcreate(fullFileName.c_str(),
663  H5F_ACC_EXCL,
664  H5P_DEFAULT,
665  H5P_DEFAULT);
666 
668  filePtrSet.h5Var, 0,
669  "error opening file `" << fullFileName << "`");
670  }
671 #endif
672  else {
673  queso_error_msg("invalid file type");
674  }
675  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
676  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
677  << ": just opened output file with base name '" << baseFileName << "." << fileType
678  << "'"
679  << ", writeOver = " << writeOver
680  << ", options 'out|in|app'"
681  << ", osfvar = " << filePtrSet.ofsVar
682  << std::endl;
683  }
684 
685  if (fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) {
686  //std::cout << "filePtrSet.ofsVar(2) = " << filePtrSet.ofsVar << std::endl;
687  //if (filePtrSet.ofsVar) std::cout << "filePtrSet.ofsVar(2)->is_open() = " << filePtrSet.ofsVar->is_open() << std::endl;
688  if ((filePtrSet.ofsVar == NULL ) ||
689  (filePtrSet.ofsVar->is_open() == false)) {
690  //std::cout << "Retrying 1..." << std::endl;
691  delete filePtrSet.ofsVar;
692  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
693  std::ofstream::out | std::ofstream::trunc);
694  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
695  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
696  << ": just opened output file with base name '" << baseFileName << "." << fileType
697  << "'"
698  << ", writeOver = " << writeOver
699  << ", options 'out|trunc'"
700  << ", osfvar = " << filePtrSet.ofsVar
701  << std::endl;
702  }
703  }
704  } // only for matlab formats
705  }
706 
707  // Check the file actually opened
708  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
709  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
711  (filePtrSet.ofsVar && filePtrSet.ofsVar->is_open()),
712  "failed to open output file");
713  }
714  }
715  else {
716  returnValue = false;
717  }
718  //this->subComm().Barrier(); // prudenci-2011-01-17
719  }
720 
721  return returnValue;
722 }
723 //-------------------------------------------------------
724 bool
726  const std::string& baseFileName,
727  const std::string& inputFileType,
728  bool writeOver,
729  FilePtrSetStruct& filePtrSet) const
730 {
731  std::string fileType(inputFileType);
732 #ifdef QUESO_HAS_HDF5
733  // Do nothing
734 #else
735  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
736  if (m_subDisplayFile) {
737  *this->subDisplayFile() << "WARNING in BaseEnvironment::openUnifiedOutputFile()"
738  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
739  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
740  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
741  << "' instead..."
742  << std::endl;
743  }
744  if (this->subRank() == 0) {
745  std::cerr << "WARNING in BaseEnvironment::openUnifiedOutputFile()"
746  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
747  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
748  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
749  << "' instead..."
750  << std::endl;
751  }
753  }
754 #endif
755 
756  bool returnValue = true;
757  filePtrSet.ofsVar = NULL;
758  if (baseFileName == ".") {
759  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
760  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
761  << ": no unified output file opened with base name '" << baseFileName << "." << fileType
762  << "'"
763  << ", writeOver = " << writeOver
764  << std::endl;
765  }
766  returnValue = false;
767  }
768  else {
770  // Open file
772  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
773  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
774  << ": opening unified output file with base name '" << baseFileName << "." << fileType
775  << "'"
776  << ", writeOver = " << writeOver
777  << std::endl;
778  }
779 
780 
781  //if ((this->subRank () == 0) &&
782  // (this->inter0Rank() == 0)) {
783 #if 0
784  std::cout << "In BaseEnvironment::openUnifiedOutputFile()"
785  << ": opening output file with base name '" << baseFileName << "." << fileType
786  << "'"
787  << ", writeOver = " << writeOver
788  << std::endl;
789 #endif
790  // Verify parent directory exists (for cases when a user
792  // specifies a relative path for the desired output file). prudenci 2010/06/26
794  // std::cout << "checking " << baseFileName+"."+fileType << std::endl;
795  int irtrn = CheckFilePath((baseFileName+"."+fileType).c_str());
796  queso_require_greater_equal_msg(irtrn, 0, "unable to verify output path");
797 
798  if (writeOver) {
800  // Write over an eventual pre-existing file
802  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
803  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
804  filePtrSet.ofsVar = new std::ofstream((baseFileName+"."+fileType).c_str(),
805  std::ofstream::out | std::ofstream::trunc);
806  }
807 #ifdef QUESO_HAS_HDF5
808  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
809  filePtrSet.h5Var = H5Fcreate((baseFileName+"."+fileType).c_str(),
810  H5F_ACC_TRUNC,
811  H5P_DEFAULT,
812  H5P_DEFAULT);
813  }
814 #endif
815  else {
816  queso_error_msg("invalid file type");
817  }
818  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
819  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
820  << ": just opened output file with base name '" << baseFileName << "." << fileType
821  << "'"
822  << ", writeOver = " << writeOver
823  << ", options 'out|trunc'"
824  << ", osfvar = " << filePtrSet.ofsVar
825  << std::endl;
826  }
827  }
828  else {
830  // Write at the end of an eventual pre-existing file
831  // 'm' and Ranger nodes behave differently on ofstream constructor... prudenci 2010/03/05
833  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
834  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
835  filePtrSet.ofsVar = new std::ofstream((baseFileName+"."+fileType).c_str(),
836  std::ofstream::out /*| std::ofstream::in*/ | std::ofstream::app);
837  }
838 #ifdef QUESO_HAS_HDF5
839  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
840  filePtrSet.h5Var = H5Fcreate((baseFileName+"."+fileType).c_str(), // TEMPORARY - FIX ME
841  H5F_ACC_TRUNC,
842  H5P_DEFAULT,
843  H5P_DEFAULT);
844 
845  // m_worldRank,
846  // "BaseEnvironment::openUnifiedOutputFile(), writeOver=false",
847  // "hdf file type not supported yet");
848  }
849 #endif
850  else {
851  queso_error_msg("invalid file type");
852  }
853  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
854  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
855  << ": just opened output file with base name '" << baseFileName << "." << fileType
856  << "'"
857  << ", writeOver = " << writeOver
858  << ", options 'out|in|app'"
859  << ", osfvar = " << filePtrSet.ofsVar
860  << std::endl;
861  }
862  if ((filePtrSet.ofsVar == NULL ) ||
863  (filePtrSet.ofsVar->is_open() == false)) {
864 #if 0
865  std::cout << "Retrying 2..." << std::endl;
866 #endif
867  delete filePtrSet.ofsVar;
868  filePtrSet.ofsVar = new std::ofstream((baseFileName+"."+fileType).c_str(),
869  std::ofstream::out | std::ofstream::trunc);
870  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
871  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
872  << ": just opened output file with base name '" << baseFileName << "." << fileType
873  << "'"
874  << ", writeOver = " << writeOver
875  << ", options 'out|trunc'"
876  << ", osfvar = " << filePtrSet.ofsVar
877  << std::endl;
878  }
879  }
880  }
881  if (filePtrSet.ofsVar == NULL) {
882  std::cerr << "In BaseEnvironment::openUnifiedOutputFile()"
883  << ": failed to open unified output file with base name '" << baseFileName << "." << fileType
884  << "'"
885  << std::endl;
886  }
887  queso_require_msg((filePtrSet.ofsVar && filePtrSet.ofsVar->is_open()), "failed to open output file");
888  //}
889  }
890 
891  return returnValue;
892 }
893 //-------------------------------------------------------
894 bool
896  const std::string& baseFileName,
897  const std::string& inputFileType,
898  const std::set<unsigned int>& allowedSubEnvIds,
899  FilePtrSetStruct& filePtrSet) const
900 {
901  std::string fileType(inputFileType);
902 #ifdef QUESO_HAS_HDF5
903  // Do nothing
904 #else
905  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
906  if (m_subDisplayFile) {
907  *this->subDisplayFile() << "WARNING in BaseEnvironment::openInputFile()"
908  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
909  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
910  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
911  << "' instead..."
912  << std::endl;
913  }
914  if (this->subRank() == 0) {
915  std::cerr << "WARNING in BaseEnvironment::openInputFile()"
916  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
917  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
918  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
919  << "' instead..."
920  << std::endl;
921  }
923  }
924 #endif
925 
926  bool returnValue = true;
927  filePtrSet.ifsVar = NULL;
928  if ((baseFileName == UQ_ENV_FILENAME_FOR_NO_INPUT_FILE) ||
929  (allowedSubEnvIds.find(this->subId()) == allowedSubEnvIds.end() )) {
930  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
931  *this->subDisplayFile() << "In BaseEnvironment::openInputFile()"
932  << ": no input file opened with base name '" << baseFileName << "." << fileType
933  << "'"
934  << std::endl;
935  }
936  returnValue = false;
937  }
938  else {
940  // Open file
942  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
943  *this->subDisplayFile() << "In BaseEnvironment::openInputFile()"
944  << ": opening input file with base name '" << baseFileName << "." << fileType
945  << "'"
946  << std::endl;
947  }
948  if (this->subRank() == 0) {
950  // Verify parent directory exists (for cases when a user
951  // specifies a relative path for the desired output file). prudenci 2010/06/26
953  // std::cout << "checking " << baseFileName+"."+fileType << std::endl;
954  int irtrn = CheckFilePath((baseFileName+"."+fileType).c_str());
955  queso_require_greater_equal_msg(irtrn, 0, "unable to verify input path");
956 
957  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
958  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
959  filePtrSet.ifsVar = new std::ifstream((baseFileName+"."+fileType).c_str(),
960  std::ofstream::in);
961  if ((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)) {
962  std::cerr << "In BaseEnvironment::openInputFile()"
963  << ": failed to open input file with base name '" << baseFileName << "." << fileType
964  << "'"
965  << std::endl;
966  }
967  queso_require_msg(!((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)), "file with fileName could not be found");
968  }
969 #ifdef QUESO_HAS_HDF5
970  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
971  filePtrSet.h5Var = H5Fopen((baseFileName+"."+fileType).c_str(),
972  H5F_ACC_RDONLY,
973  H5P_DEFAULT);
974  }
975 #endif
976  else {
977  queso_error_msg("invalid file type");
978  }
979  }
980  else {
981  returnValue = false;
982  }
983  //this->subComm().Barrier(); // prudenci-2011-01-17
984  }
985 
986  return returnValue;
987 }
988 //-------------------------------------------------------
989 bool
991  const std::string& baseFileName,
992  const std::string& inputFileType,
993  FilePtrSetStruct& filePtrSet) const
994 {
995  std::string fileType(inputFileType);
996 #ifdef QUESO_HAS_HDF5
997  // Do nothing
998 #else
999  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1000  if (m_subDisplayFile) {
1001  *this->subDisplayFile() << "WARNING in BaseEnvironment::openUnifiedInputFile()"
1002  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1003  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1004  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1005  << "' instead..."
1006  << std::endl;
1007  }
1008  if (this->subRank() == 0) {
1009  std::cerr << "WARNING in BaseEnvironment::openUnifiedInputFile()"
1010  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1011  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1012  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1013  << "' instead..."
1014  << std::endl;
1015  }
1017  }
1018 #endif
1019 
1020  bool returnValue = true;
1021  filePtrSet.ifsVar = NULL;
1022  if (baseFileName == UQ_ENV_FILENAME_FOR_NO_INPUT_FILE) {
1023  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
1024  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedInputFile()"
1025  << ": no input file opened with base name '" << baseFileName << "." << fileType
1026  << "'"
1027  << std::endl;
1028  }
1029  returnValue = false;
1030  }
1031  else {
1033  // Open file
1035  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
1036  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedInputFile()"
1037  << ": opening input file with base name '" << baseFileName << "." << fileType
1038  << "'"
1039  << std::endl;
1040  }
1041  if (this->subRank() == 0) { // Needed ???????? prudenci 2010-11-11
1043  // Verify parent directory exists (for cases when a user
1044  // specifies a relative path for the desired output file). prudenci 2010/06/26
1046  // std::cout << "checking " << baseFileName+"."+fileType << std::endl;
1047  int irtrn = CheckFilePath((baseFileName+"."+fileType).c_str());
1048  queso_require_greater_equal_msg(irtrn, 0, "unable to verify input path");
1049 
1050  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1051  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1052  filePtrSet.ifsVar = new std::ifstream((baseFileName+"."+fileType).c_str(),
1053  std::ofstream::in);
1054  if ((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)) {
1055  std::cerr << "In BaseEnvironment::openUnifiedInputFile()"
1056  << ": failed to open input file with base name '" << baseFileName << "." << fileType
1057  << "'"
1058  << std::endl;
1059  }
1060  queso_require_msg(!((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)), "file with fileName could not be found");
1061  }
1062 #ifdef QUESO_HAS_HDF5
1063  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1064  filePtrSet.h5Var = H5Fopen((baseFileName+"."+fileType).c_str(),
1065  H5F_ACC_RDONLY,
1066  H5P_DEFAULT);
1067  }
1068 #endif
1069  else {
1070  queso_error_msg("invalid file type");
1071  }
1072  }
1073  //else {
1074  // returnValue = false;
1075  //}
1076  //this->subComm().Barrier();
1077  }
1078 
1079  return returnValue;
1080 }
1081 //-------------------------------------------------------
1082 void
1084  FilePtrSetStruct& filePtrSet,
1085  const std::string& inputFileType) const
1086 {
1087  std::string fileType(inputFileType);
1088 #ifdef QUESO_HAS_HDF5
1089  // Do nothing
1090 #else
1091  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1092  if (m_subDisplayFile) {
1093  *this->subDisplayFile() << "WARNING in BaseEnvironment::closeFile()"
1094  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1095  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1096  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1097  << "' instead..."
1098  << std::endl;
1099  }
1100  if (this->subRank() == 0) {
1101  std::cerr << "WARNING in BaseEnvironment::closeFile()"
1102  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1103  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1104  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1105  << "' instead..."
1106  << std::endl;
1107  }
1109  }
1110 #endif
1111 
1112  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1113  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1114  //filePtrSet.ofsVar->close(); // close() crashes on Mac; need to use delete(); why? prudenci 2010/June
1115  delete filePtrSet.ofsVar;
1116  filePtrSet.ofsVar = NULL;
1117 
1118  //filePtrSet.ifsVar->close();
1119  delete filePtrSet.ifsVar;
1120  filePtrSet.ifsVar = NULL;
1121  }
1122 #ifdef QUESO_HAS_HDF5
1123  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1124  H5Fclose(filePtrSet.h5Var);
1125  }
1126 #endif
1127  else {
1128  queso_error_msg("invalid file type");
1129  }
1130 
1131  return;
1132 }
1133 //-------------------------------------------------------
1134 void
1136 {
1137  m_exceptionalCircumstance = value;
1138  return;
1139 }
1140 //-------------------------------------------------------
1141 bool
1143 {
1145 }
1146 
1147 const GetPot &
1149 {
1150  return *m_input;
1151 }
1152 
1153 
1154 //*****************************************************
1155 // Empty Environment
1156 //*****************************************************
1158  :
1159  BaseEnvironment("",NULL)
1160 {
1161 }
1162 //-------------------------------------------------------
1164 {
1165 }
1166 //-------------------------------------------------------
1167 void
1168 EmptyEnvironment::print(std::ostream& os) const
1169 {
1170  os.flush(); // just to avoid icpc warnings
1171  return;
1172 }
1173 
1174 //*****************************************************
1175 // Full Environment
1176 //*****************************************************
1177 #ifdef QUESO_HAS_MPI
1179  RawType_MPI_Comm inputComm,
1180  const char* passedOptionsInputFileName,
1181  const char* prefix,
1182  EnvOptionsValues* alternativeOptionsValues)
1183  :
1184  BaseEnvironment(passedOptionsInputFileName,alternativeOptionsValues)
1185 {
1186  this->construct(inputComm, prefix);
1187 }
1188 
1190  RawType_MPI_Comm inputComm,
1191  const std::string& passedOptionsInputFileName,
1192  const std::string& prefix,
1193  EnvOptionsValues* alternativeOptionsValues)
1194  :
1195  BaseEnvironment(passedOptionsInputFileName,alternativeOptionsValues)
1196 {
1197  this->construct(inputComm, prefix.c_str());
1198 }
1199 
1200 void
1202  const char *prefix)
1203 {
1204 #ifdef QUESO_MEMORY_DEBUGGING
1205  std::cout << "Entering FullEnv" << std::endl;
1206 #endif
1207 
1209  // Initialize "full" communicator -- Not necessarily MPI_COMM_WORLD
1211  int mpiRC = MPI_Comm_rank(inputComm,&m_worldRank);
1212  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed to get world fullRank()");
1213 
1214  m_fullComm = new MpiComm(*this,inputComm);
1215 
1218 
1219  mpiRC = MPI_Comm_group(m_fullComm->Comm(), &m_fullGroup);
1220  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Comm_group()");
1221 
1222  // saving old uncaught exception handler, invoking queso_terminate
1223  old_terminate_handler = std::set_terminate(queso_terminate_handler);
1224 
1225 #ifdef QUESO_MEMORY_DEBUGGING
1226  std::cout << "In FullEnv, finished dealing with MPI initially" << std::endl;
1227 #endif
1228 
1230  // Read options
1232  // If NULL, we create one
1233  if (m_optionsObj == NULL) {
1234  // If there's an input file, we grab the options from there. Otherwise the
1235  // defaults are used
1236  if (m_optionsInputFileName != "") {
1237 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
1238  m_allOptionsMap = new boost::program_options::variables_map();
1239  m_allOptionsDesc = new boost::program_options::options_description("Allowed options");
1240 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
1241 
1243 
1244  m_input->parse_input_file(m_optionsInputFileName);
1245  }
1246 
1247  EnvOptionsValues * tempOptions = new EnvOptionsValues(this, prefix);
1248 
1249  // We did this dance because scanOptionsValues is not a const method, but
1250  // m_optionsObj is a pointer to const
1251  m_optionsObj = tempOptions;
1252  }
1253 
1254  // If help option was supplied, print info
1255  if (m_optionsObj->m_help != "") {
1256  // We write to std::cout because subDisplayFile() isn't ready yet?
1257  std::cout << (*m_optionsObj) << std::endl;
1258  }
1259 
1261  fullComm().NumProc() % m_optionsObj->m_numSubEnvironments, 0,
1262  "total number of processors in environment must be multiple of the specified number of subEnvironments");
1263 
1264 #ifdef QUESO_MEMORY_DEBUGGING
1265  std::cout << "In FullEnv, finished scanning options" << std::endl;
1266 #endif
1267 
1268  // Only display these messages if the user wants them
1269  // NOTE: This got moved below the Read Options section
1270  // because we need the options to be read to know what
1271  // the verbosity level is.
1272  if (this->displayVerbosity() > 0) {
1274  // Display main initial messages
1275  // 'std::cout' is for: main trace messages + synchronized trace messages + error messages prior to 'exit()' or 'abort()'
1277  /*int iRC = 0;*/
1278  /*iRC = */gettimeofday(&m_timevalBegin, NULL);
1279 
1280  if (m_fullRank == 0) {
1281  QUESO_version_print(std::cout);
1282  }
1283 
1284  if (m_fullRank == 0) {
1285  std::cout << "Beginning run at " << ctime(&m_timevalBegin.tv_sec)
1286  << std::endl;
1287  }
1288  }
1289 
1291  // Deal with multiple subEnvironments: create the sub communicators, one for each subEnvironment
1293  unsigned int numRanksPerSubEnvironment = m_fullCommSize/m_optionsObj->m_numSubEnvironments;
1294 
1295  m_subId = m_fullRank/numRanksPerSubEnvironment;
1296  char tmpSubId[16];
1297  sprintf(tmpSubId,"%u",m_subId);
1298  m_subIdString = tmpSubId;
1299 
1301  m_optionsObj->m_subDisplayAllowedSet.insert((unsigned int) m_subId);
1302  }
1303 
1304  std::vector<int> fullRanksOfMySubEnvironment(numRanksPerSubEnvironment,0);
1305  for (unsigned int i = 0; i < numRanksPerSubEnvironment; ++i) {
1306  fullRanksOfMySubEnvironment[i] = m_subId * numRanksPerSubEnvironment + i;
1307  }
1308 
1309  mpiRC = MPI_Group_incl(m_fullGroup, (int) numRanksPerSubEnvironment, &fullRanksOfMySubEnvironment[0], &m_subGroup);
1310  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Group_incl() for a subEnvironment");
1311 
1312  RawType_MPI_Comm subRawComm;
1313  mpiRC = MPI_Comm_create(m_fullComm->Comm(), m_subGroup, &subRawComm);
1314  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Comm_group() for a subEnvironment");
1315  m_subComm = new MpiComm(*this,subRawComm);
1316  m_subRank = m_subComm->MyPID();
1318 
1320  // Deal with multiple subEnvironments: create the self communicator
1322  m_selfComm = new MpiComm(*this,RawValue_MPI_COMM_SELF);
1323 
1325  // Deal with multiple subEnvironments: create the inter0 communicator
1327  std::vector<int> fullRanksOfInter0(m_optionsObj->m_numSubEnvironments,0);
1328  for (unsigned int i = 0; i < m_optionsObj->m_numSubEnvironments; ++i) {
1329  fullRanksOfInter0[i] = i * numRanksPerSubEnvironment;
1330  }
1331  mpiRC = MPI_Group_incl(m_fullGroup, (int) m_optionsObj->m_numSubEnvironments, &fullRanksOfInter0[0], &m_inter0Group);
1332  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Group_incl() for inter0");
1333  RawType_MPI_Comm inter0RawComm;
1334  mpiRC = MPI_Comm_create(m_fullComm->Comm(), m_inter0Group, &inter0RawComm);
1335  queso_require_equal_to_msg(mpiRC, MPI_SUCCESS, "failed MPI_Comm_group() for inter0");
1336  if (m_fullRank%numRanksPerSubEnvironment == 0) {
1337  m_inter0Comm = new MpiComm(*this,inter0RawComm);
1340  }
1341 
1343  // This situation has been already taken care of above
1344  }
1346  if (m_inter0Rank >= 0) {
1347  m_optionsObj->m_subDisplayAllowedSet.insert((unsigned int) m_subId);
1348  }
1349  }
1350 
1351 
1353  // Open "screen" file
1355  bool openFile = false;
1356  if ((m_subRank == 0 ) &&
1359  openFile = true;
1360  }
1361 
1362  if (openFile && m_worldRank == 0) {
1364  // Verify parent directory exists (for cases when a user
1365  // specifies a relative path for the desired output file).
1367  int irtrn = CheckFilePath((m_optionsObj->m_subDisplayFileName+"_sub"+m_subIdString+".txt").c_str());
1368  queso_require_greater_equal_msg(irtrn, 0, "unable to verify output path");
1369  }
1370 
1372  // Ensure that rank 0 has created path, if necessary, before other tasks use it
1374  m_fullComm->Barrier();
1375 
1376  if (openFile) {
1378  // Always write over an eventual pre-existing file
1380  m_subDisplayFile = new std::ofstream((m_optionsObj->m_subDisplayFileName+"_sub"+m_subIdString+".txt").c_str(),
1381  std::ofstream::out | std::ofstream::trunc);
1382  queso_require_msg((m_subDisplayFile && m_subDisplayFile->is_open()), "failed to open sub screen file");
1383 
1385 
1386  *m_subDisplayFile << "Beginning run at " << ctime(&m_timevalBegin.tv_sec)
1387  << std::endl;
1388  }
1389 
1391  // Debug message related to subEnvironments
1393  if (this->displayVerbosity() >= 2) {
1394  for (int i = 0; i < m_fullCommSize; ++i) {
1395  if (i == m_fullRank) {
1396  //std::cout << "In FullEnvironment::commonConstructor()"
1397  std::cout << "MPI node of worldRank " << m_worldRank
1398  << " has fullRank " << m_fullRank
1399  << ", belongs to subEnvironment of id " << m_subId
1400  << ", and has subRank " << m_subRank
1401  << std::endl;
1402 
1403  std::cout << "MPI node of worldRank " << m_worldRank
1404  << " belongs to sub communicator with full ranks";
1405  for (unsigned int j = 0; j < fullRanksOfMySubEnvironment.size(); ++j) {
1406  std::cout << " " << fullRanksOfMySubEnvironment[j];
1407  }
1408  std::cout << "\n";
1409 
1410  if (m_inter0Comm) {
1411  std::cout << "MPI node of worldRank " << m_worldRank
1412  << " also belongs to inter0 communicator with full ranks";
1413  for (unsigned int j = 0; j < fullRanksOfInter0.size(); ++j) {
1414  std::cout << " " << fullRanksOfInter0[j];
1415  }
1416  std::cout << ", and has inter0Rank " << m_inter0Rank;
1417  }
1418  std::cout << "\n";
1419 
1420  std::cout << std::endl;
1421  }
1422  m_fullComm->Barrier();
1423  }
1424  //if (this->fullRank() == 0) std::cout << "Sleeping 3 seconds..."
1425  // << std::endl;
1426  //sleep(3);
1427  }
1428 
1430  // Deal with seed
1432  if (m_optionsObj->m_rngType == "gsl") {
1433  m_rngObject = new RngGsl(m_optionsObj->m_seed,m_worldRank);
1434  m_basicPdfs = new BasicPdfsGsl(m_worldRank);
1435  }
1436  else if (m_optionsObj->m_rngType == "boost") {
1437  m_rngObject = new RngBoost(m_optionsObj->m_seed,m_worldRank);
1438  m_basicPdfs = new BasicPdfsBoost(m_worldRank);
1439  }
1440  else {
1441  std::cerr << "In Environment::constructor()"
1442  << ": rngType = " << m_optionsObj->m_rngType
1443  << std::endl;
1444  queso_error_msg("the requested 'rngType' is not supported yet");
1445  }
1446 
1448  // Leave commonConstructor()
1450  m_fullComm->Barrier();
1451  m_fullEnvIsReady = true;
1452 
1453  if ((m_subDisplayFile) && (this->displayVerbosity() >= 5)) {
1454  *m_subDisplayFile << "Done with initializations at FullEnvironment::commonConstructor()"
1455  << std::endl;
1456  }
1457 
1458  return;
1459 }
1460 #endif // QUESO_HAS_MPI
1461 
1463  const char* passedOptionsInputFileName,
1464  const char* prefix,
1465  EnvOptionsValues* alternativeOptionsValues)
1466  :
1467  BaseEnvironment(passedOptionsInputFileName,alternativeOptionsValues)
1468 {
1469  this->construct(prefix);
1470 }
1471 
1473  const std::string& passedOptionsInputFileName,
1474  const std::string& prefix,
1475  EnvOptionsValues* alternativeOptionsValues)
1476  :
1477  BaseEnvironment(passedOptionsInputFileName,alternativeOptionsValues)
1478 {
1479  this->construct(prefix.c_str());
1480 }
1481 
1482 void
1483 FullEnvironment::construct (const char *prefix)
1484 {
1485 #ifdef QUESO_MEMORY_DEBUGGING
1486  std::cout << "Entering FullEnv" << std::endl;
1487 #endif
1488 
1489  m_worldRank = 0;
1490 
1491  m_fullComm = new MpiComm(*this);
1492  m_fullRank = 0;
1493  m_fullCommSize = 1;
1494 
1495 #ifndef QUESO_HAS_MPI
1496  m_fullGroup = 0;
1497 #endif
1498 
1499  // saving old uncaught exception handler, invoking queso_terminate
1500  old_terminate_handler = std::set_terminate(queso_terminate_handler);
1501 
1502 #ifdef QUESO_MEMORY_DEBUGGING
1503  std::cout << "In FullEnv, finished dealing with MPI initially" << std::endl;
1504 #endif
1505 
1507  // Read options
1509  // If NULL, we create one
1510  if (m_optionsObj == NULL) {
1511  // If there's an input file, we grab the options from there. Otherwise the
1512  // defaults are used
1513  if (m_optionsInputFileName != "") {
1514 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
1515  m_allOptionsMap = new boost::program_options::variables_map();
1516  m_allOptionsDesc = new boost::program_options::options_description("Allowed options");
1517 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
1518 
1520 
1521  m_input->parse_input_file(m_optionsInputFileName);
1522  }
1523 
1524  EnvOptionsValues * tempOptions = new EnvOptionsValues(this, prefix);
1525 
1526  // We did this dance because scanOptionsValues is not a const method, but
1527  // m_optionsObj is a pointer to const
1528  m_optionsObj = tempOptions;
1529  }
1530 
1531  // If help option was supplied, print info
1532  if (m_optionsObj->m_help != "") {
1533  // We write to std::cout because subDisplayFile() isn't ready yet?
1534  std::cout << (*m_optionsObj) << std::endl;
1535  }
1536 
1538  fullComm().NumProc() % m_optionsObj->m_numSubEnvironments, 0,
1539  "total number of processors in environment must be multiple of the specified number of subEnvironments");
1540 
1541 #ifdef QUESO_MEMORY_DEBUGGING
1542  std::cout << "In FullEnv, finished scanning options" << std::endl;
1543 #endif
1544 
1545  // Only display these messages if the user wants them
1546  // NOTE: This got moved below the Read Options section
1547  // because we need the options to be read to know what
1548  // the verbosity level is.
1549  if (this->displayVerbosity() > 0) {
1551  // Display main initial messages
1552  // 'std::cout' is for: main trace messages + synchronized trace messages + error messages prior to 'exit()' or 'abort()'
1554  /*int iRC = 0;*/
1555  /*iRC = */gettimeofday(&m_timevalBegin, NULL);
1556 
1557  QUESO_version_print(std::cout);
1558 
1559  std::cout << "Beginning run at " << ctime(&m_timevalBegin.tv_sec)
1560  << std::endl;
1561  }
1562 
1563  m_subId = 0;
1564  char tmpSubId[16];
1565  sprintf(tmpSubId,"%u",m_subId);
1566  m_subIdString = tmpSubId;
1567 
1569  m_optionsObj->m_subDisplayAllowedSet.insert((unsigned int) m_subId);
1570  }
1571 
1572  int fullRanksOfMySubEnvironment = 1;
1573 
1574 #ifndef QUESO_HAS_MPI
1575  m_subGroup = 0;
1576 #endif
1577 
1578  m_subComm = new MpiComm(*this);
1579  m_subRank = 0;
1580  m_subCommSize = 1;
1581 
1583  // Deal with multiple subEnvironments: create the self communicator
1585  m_selfComm = new MpiComm(*this);
1586 
1588  // Deal with multiple subEnvironments: create the inter0 communicator
1590  int fullRanksOfInter0 = 0;
1591 #ifndef QUESO_HAS_MPI
1592  m_inter0Group = 0;
1593 #endif
1594  m_inter0Comm = new MpiComm(*this);
1595  m_inter0Rank = 0;
1596  m_inter0CommSize = 1;
1597 
1599  // This situation has been already taken care of above
1600  }
1602  if (m_inter0Rank >= 0) {
1603  m_optionsObj->m_subDisplayAllowedSet.insert((unsigned int) m_subId);
1604  }
1605  }
1606 
1607 
1609  // Open "screen" file
1611  bool openFile = false;
1612  if ((m_subRank == 0 ) &&
1615  openFile = true;
1616  }
1617 
1618  if (openFile && m_worldRank == 0) {
1620  // Verify parent directory exists (for cases when a user
1621  // specifies a relative path for the desired output file).
1623  int irtrn = CheckFilePath((m_optionsObj->m_subDisplayFileName+"_sub"+m_subIdString+".txt").c_str());
1624  queso_require_greater_equal_msg(irtrn, 0, "unable to verify output path");
1625  }
1626 
1628  // Ensure that rank 0 has created path, if necessary, before other tasks use it
1630  m_fullComm->Barrier();
1631 
1632  if (openFile) {
1634  // Always write over an eventual pre-existing file
1636  m_subDisplayFile = new std::ofstream((m_optionsObj->m_subDisplayFileName+"_sub"+m_subIdString+".txt").c_str(),
1637  std::ofstream::out | std::ofstream::trunc);
1638  queso_require_msg((m_subDisplayFile && m_subDisplayFile->is_open()), "failed to open sub screen file");
1639 
1641 
1642  *m_subDisplayFile << "Beginning run at " << ctime(&m_timevalBegin.tv_sec)
1643  << std::endl;
1644  }
1645 
1647  // Debug message related to subEnvironments
1649  if (this->displayVerbosity() >= 2) {
1650  for (int i = 0; i < m_fullCommSize; ++i) {
1651  if (i == m_fullRank) {
1652  //std::cout << "In FullEnvironment::commonConstructor()"
1653  std::cout << "MPI node of worldRank " << m_worldRank
1654  << " has fullRank " << m_fullRank
1655  << ", belongs to subEnvironment of id " << m_subId
1656  << ", and has subRank " << m_subRank
1657  << std::endl;
1658 
1659  std::cout << "MPI node of worldRank " << m_worldRank
1660  << " belongs to sub communicator with full ranks";
1661  std::cout << " " << fullRanksOfMySubEnvironment;
1662  std::cout << "\n";
1663 
1664  if (m_inter0Comm) {
1665  std::cout << "MPI node of worldRank " << m_worldRank
1666  << " also belongs to inter0 communicator with full ranks";
1667  std::cout << " " << fullRanksOfInter0;
1668  std::cout << ", and has inter0Rank " << m_inter0Rank;
1669  }
1670  std::cout << "\n";
1671 
1672  std::cout << std::endl;
1673  }
1674  m_fullComm->Barrier();
1675  }
1676  }
1677 
1679  // Deal with seed
1681  if (m_optionsObj->m_rngType == "gsl") {
1682  m_rngObject = new RngGsl(m_optionsObj->m_seed,m_worldRank);
1683  m_basicPdfs = new BasicPdfsGsl(m_worldRank);
1684  }
1685  else if (m_optionsObj->m_rngType == "boost") {
1686  m_rngObject = new RngBoost(m_optionsObj->m_seed,m_worldRank);
1687  m_basicPdfs = new BasicPdfsBoost(m_worldRank);
1688  }
1689  else {
1690  std::cerr << "In Environment::constructor()"
1691  << ": rngType = " << m_optionsObj->m_rngType
1692  << std::endl;
1693  queso_error_msg("the requested 'rngType' is not supported yet");
1694  }
1695 
1697  // Leave commonConstructor()
1699  m_fullComm->Barrier();
1700  m_fullEnvIsReady = true;
1701 
1702  if ((m_subDisplayFile) && (this->displayVerbosity() >= 5)) {
1703  *m_subDisplayFile << "Done with initializations at FullEnvironment::commonConstructor()"
1704  << std::endl;
1705  }
1706 
1707  return;
1708 }
1709 
1710 //-------------------------------------------------------
1712 {
1713 }
1714 //-------------------------------------------------------
1715 void
1716 FullEnvironment::print(std::ostream& os) const
1717 {
1718  os.flush(); // just to avoid icpc warnings
1719  return;
1720 }
1721 
1723 {
1724 #ifdef QUESO_HAS_MPI
1725  int mpi_initialized;
1726  MPI_Initialized (&mpi_initialized);
1727 
1728  if (mpi_initialized)
1729  {
1730  //MPI_Abort(m_fullComm->Comm(), 1);
1731  MPI_Abort(MPI_COMM_WORLD, 1);
1732  }
1733  else
1734  {
1735  // The system terminate_handler may do useful things like printing
1736  // uncaught exception information, or the user may have created
1737  // their own terminate handler that we want to call.
1739  }
1740 #else
1742 #endif
1743  exit(1);
1744 }
1745 
1746 
1747 //-------------------------------------------------------
1748 void
1750 {
1751  std::ifstream* ifs = new std::ifstream(m_optionsInputFileName.c_str());
1752  if (ifs->is_open()) {
1753  //ifs->close();
1754  delete ifs;
1755  }
1756  else {
1757  if (m_fullRank == 0) std::cout << "An invalid input file has been passed to the 'environment' class constructor!"
1758  << ": name of file is '" << m_optionsInputFileName.c_str() << "'"
1759  << std::endl;
1760 
1761  if (m_fullRank == 0) std::cout << "\nThis is a help message of the QUESO library."
1762  << "\nAn application using the QUESO library shall be executed by typing"
1763  << "\n '<eventual mpi commands and options> <Application> <InputFile>'"
1764  << "\nin the command line."
1765  << "\n"
1766  << std::endl;
1767  queso_error();
1768  }
1769 
1770  return;
1771 }
1772 
1773 } // End namespace QUESO
virtual ~BaseEnvironment()
Destructor.
Definition: Environment.C:205
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:123
std::terminate_handler old_terminate_handler
Definition: Environment.C:135
#define UQ_ENV_FILENAME_FOR_NO_INPUT_FILE
std::string m_optionsInputFileName
Definition: Environment.h:374
EnvOptionsValues * m_optionsObj
Definition: Environment.h:402
struct timeval m_timevalBegin
Definition: Environment.h:399
int worldRank() const
Returns the process world rank.
Definition: Environment.C:262
RawType_MPI_Comm Comm() const
Extract MPI Communicator from a MpiComm object.
Definition: MpiComm.C:105
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:164
const GetPot & input() const
The GetPot input file parser.
Definition: Environment.C:1148
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:78
bool m_subDisplayAllowAll
Allows (or not) all sub-environments to write to output file.
int subRank() const
Access function for sub-rank.
Definition: Environment.C:287
std::ifstream * ifsVar
Provides a stream interface to read data from files.
Definition: Environment.h:88
int CheckFilePath(const char *path)
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:353
boost::program_options::variables_map * m_allOptionsMap
Definition: Environment.h:378
This class provides a suite options one can pass to a QUESO environment.
#define queso_error()
Definition: asserts.h:53
int RawType_MPI_Comm
Definition: MpiComm.h:57
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:197
int MyPID() const
Return my process ID.
Definition: MpiComm.C:114
void resetIdentifyingString(const std::string &newString)
Reset private attribute m_identifyingString with the value newString.
Definition: Environment.C:507
int inter0Rank() const
Returns the process inter0 rank.
Definition: Environment.C:307
std::string subDisplayFileName() const
Access function for m_subDisplayFileName (displays filename on stream).
Definition: Environment.C:326
RawType_MPI_Group m_subGroup
Definition: Environment.h:384
std::ofstream * m_subDisplayFile
Definition: Environment.h:396
std::string platformName() const
Access to the platform name.
Definition: Environment.C:495
unsigned int m_syncVerbosity
Synchronized verbosity.
EmptyEnvironment()
Default constructor. Does nothing.
Definition: Environment.C:1157
bool fullEnvIsReady() const
Returns whether the full environment class is ready (constructor has successfully been called)...
Definition: Environment.C:256
std::string m_platformName
Platform name.
#define RawValue_MPI_COMM_SELF
Definition: MpiComm.h:63
Class for random number generation using Boost library.
void print(std::ostream &os) const
Sends the environment options to the stream.
Definition: Environment.C:1716
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
bool openInputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, FilePtrSetStruct &filePtrSet) const
Opens an input file.
Definition: Environment.C:895
#define UQ_FILE_EXTENSION_FOR_HDF_FORMAT
Definition: Defines.h:104
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:385
std::string m_subIdString
Definition: Environment.h:383
Class for random number generation using GSL library.
#define UQ_FILE_EXTENSION_FOR_TXT_FORMAT
Definition: Defines.h:103
Struct for handling data input and output from files.
Definition: Environment.h:76
boost::program_options::options_description * m_allOptionsDesc
Definition: Environment.h:377
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
Definition: Environment.C:341
unsigned int syncVerbosity() const
Access function to private attribute m_syncVerbosity.
Definition: Environment.C:456
#define queso_deprecated()
Definition: Defines.h:134
void print(std::ostream &os) const
Definition: Environment.C:1168
std::string identifyingString() const
Access function to private attribute m_identifyingString: identifying string.
Definition: Environment.C:501
unsigned int m_subId
Definition: Environment.h:382
virtual void resetSeed(int newSeed)
Resets the seed with value newSeed.
Definition: RngBase.C:48
unsigned int m_displayVerbosity
Verbosity.
std::string m_subDisplayFileName
Output filename for sub-screen writing.
void scanInputFileForMyOptions(const boost::program_options::options_description &optionsDesc) const
This method scans the input file provided by the user to QUESO.
Definition: Environment.C:396
Class for random number generation (base class for either GSL or Boost RNG).
Definition: RngBase.h:45
std::set< unsigned int > m_subDisplayAllowedSet
Sub-environments that will write to output.
const std::string & subIdString() const
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment.
Definition: Environment.C:347
Definition: getpot.h:152
void setExceptionalCircumstance(bool value) const
Set an exceptional circumstance.
Definition: Environment.C:1135
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1083
int fullRank() const
Returns the process full rank.
Definition: Environment.C:268
void readOptionsInputFile()
Checks the options input file and reads the options.
Definition: Environment.C:1749
int QUESO_get_numeric_version()
Definition: Environment.C:84
unsigned int numSubEnvironments() const
Access function to the number of sub-environments.
Definition: Environment.C:334
~FilePtrSetStruct()
Destructor.
Definition: Environment.C:127
std::ofstream * ofsVar
Provides a stream interface to write data to files.
Definition: Environment.h:85
BaseEnvironment(const char *passedOptionsInputFileName, EnvOptionsValues *alternativeOptionsValues)
Default constructor.
Definition: Environment.C:141
RawType_MPI_Group subGroup() const
Access function for sub-group.
Definition: Environment.C:281
bool exceptionalCircumstance() const
Decides whether there is an exceptional circumstance.
Definition: Environment.C:1142
TODO: Base class for basic PDFs using Gsl library.
Definition: BasicPdfsGsl.h:43
bool openOutputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, bool writeOver, FilePtrSetStruct &filePtrSet) const
Opens an output file for each sub-environment that was chosen to send data to the file...
Definition: Environment.C:520
void resetSeed(int newSeedOption)
Reset RNG seed.
Definition: Environment.C:482
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:74
TODO: Base class for basic PDFs (via either GSL or Boost).
Definition: BasicPdfsBase.h:44
unsigned int checkingLevel() const
Access function to private attribute m_checkingLevel.
Definition: Environment.C:463
int seed() const
Access to the RNG seed.
Definition: Environment.C:476
std::string m_rngType
Type of the random number generator.
ScopedPtr< GetPot >::Type m_input
Definition: Environment.h:380
unsigned int displayVerbosity() const
Definition: Environment.C:449
RawType_MPI_Group m_fullGroup
Definition: Environment.h:372
const MpiComm & subComm() const
Access function for MpiComm sub communicator.
Definition: Environment.C:293
unsigned int m_checkingLevel
Checking level.
const BasicPdfsBase * basicPdfs() const
Access to Basic PDFs.
Definition: Environment.C:489
#define UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT
Definition: Defines.h:102
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
The QUESO MPI Communicator Class.
Definition: MpiComm.h:203
~FullEnvironment()
Destructor.
Definition: Environment.C:1711
const MpiComm & fullComm() const
Access function for MpiComm full communicator.
Definition: Environment.C:274
std::string m_identifyingString
Identifying string.
~EmptyEnvironment()
Destructor.
Definition: Environment.C:1163
void queso_terminate_handler()
Function for unhandled exceptions in Queso.
Definition: Environment.C:1722
int m_seed
Seed of the random number generator.
int seed() const
Sets the seed.
Definition: RngBase.C:42
bool openUnifiedInputFile(const std::string &fileName, const std::string &fileType, FilePtrSetStruct &filePtrSet) const
Opens the unified input file.
Definition: Environment.C:990
void setOptionsInputFileAccessState(bool newState) const
Definition: Environment.C:364
RawType_MPI_Group m_inter0Group
Definition: Environment.h:391
FullEnvironment(const char *passedOptionsInputFileName, const char *prefix, EnvOptionsValues *alternativeOptionsValues)
Parallel constructor.
Definition: Environment.C:1462
#define queso_error_msg(msg)
Definition: asserts.h:47
FilePtrSetStruct()
Struct constructor.
Definition: Environment.C:116
#define UQ_ENV_FILENAME_FOR_NO_OUTPUT_FILE
TODO: Base class for basic PDFs using Boost library.
bool openUnifiedOutputFile(const std::string &fileName, const std::string &fileType, bool writeOver, FilePtrSetStruct &filePtrSet) const
Opens a unified output file, that will contain data from all sub-environments.
Definition: Environment.C:725
int RawType_MPI_Group
Definition: MpiComm.h:58
void QUESO_version_print(std::ostream &os)
Definition: Environment.C:54
BasicPdfsBase * m_basicPdfs
Definition: Environment.h:398
const MpiComm & inter0Comm() const
Access function for MpiComm inter0-communicator.
Definition: Environment.C:313
void construct(const char *prefix)
Named constructor backend for multiple constructor overloads.
Definition: Environment.C:1483
bool m_subDisplayAllowInter0
Allows (or not) all inter0 nodes to write to output file.
const MpiComm & selfComm() const
Access function for MpiComm self-communicator.
Definition: Environment.C:300

Generated on Tue Nov 29 2016 10:53:10 for queso-0.56.0 by  doxygen 1.8.5