queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::BaseEnvironment Class Referenceabstract

This (virtual) class sets up the environment underlying the use of the QUESO library by an executable. More...

#include <Environment.h>

Inheritance diagram for QUESO::BaseEnvironment:
QUESO::EmptyEnvironment QUESO::FullEnvironment

Public Member Functions

Constructor/Destructor methods
 BaseEnvironment (const char *passedOptionsInputFileName, EnvOptionsValues *alternativeOptionsValues)
 Default constructor. More...
 
 BaseEnvironment (const std::string &passedOptionsInputFileName, EnvOptionsValues *alternativeOptionsValues)
 
virtual ~BaseEnvironment ()
 Destructor. More...
 
Environment, Communicator and Options Input File methods
bool fullEnvIsReady () const
 Returns whether the full environment class is ready (constructor has successfully been called). More...
 
int worldRank () const
 Returns the same thing as fullRank() More...
 
int fullRank () const
 Returns the rank of the MPI process in QUESO's full communicator. More...
 
const MpiCommfullComm () const
 Access function for the communicator that was passed to QUESO's environment. More...
 
RawType_MPI_Group subGroup () const
 Access function for sub-group. More...
 
int subRank () const
 Returns the rank of the MPI process in the sub-communicator subComm() More...
 
const MpiCommsubComm () const
 Access function for each sub-environment's communicator. More...
 
const MpiCommselfComm () const
 Access function for MpiComm self-communicator. More...
 
int inter0Rank () const
 Returns the process inter0 rank. More...
 
const MpiComminter0Comm () const
 Access function for MpiComm communicator for processes with subRank() 0. More...
 
std::ofstream * subDisplayFile () const
 Access function for m_subDisplayFile (displays file on stream). More...
 
std::string subDisplayFileName () const
 Access function for m_subDisplayFileName (displays filename on stream). More...
 
unsigned int numSubEnvironments () const
 Access function to the number of sub-environments. More...
 
unsigned int subId () const
 Access function to the number of each sub-environment Id: m_subId. More...
 
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. More...
 
void checkTheParallelEnvironment () const
 
std::string optionsInputFileName () const
 Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the user to QUESO. More...
 
void setOptionsInputFileAccessState (bool newState) const
 
const
boost::program_options::options_description & 
allOptionsDesc () const
 
boost::program_options::variables_map & allOptionsMap () const
 
void scanInputFileForMyOptions (const boost::program_options::options_description &optionsDesc) const
 This method scans the input file provided by the user to QUESO. More...
 
unsigned int displayVerbosity () const
 
unsigned int syncVerbosity () const
 Access function to private attribute m_syncVerbosity. More...
 
unsigned int checkingLevel () const
 Access function to private attribute m_checkingLevel. More...
 
const RngBaserngObject () const
 Access to the RNG object. More...
 
void resetSeed (int newSeedOption)
 Reset RNG seed. More...
 
int seed () const
 Access to the RNG seed. More...
 
const BasicPdfsBasebasicPdfs () const
 Access to Basic PDFs. More...
 
std::string platformName () const
 Access to the platform name. More...
 
std::string identifyingString () const
 Access function to private attribute m_identifyingString: identifying string. More...
 
void resetIdentifyingString (const std::string &newString)
 Reset private attribute m_identifyingString with the value newString. More...
 
bool isThereInputFile () const
 //TODO Not implemented? it is called in examples/validationCycle/tests_old/results_5_25/uqTgaEx4.h. More...
 
struct timeval timevalBegin () const
 Used to save the time when the combo `QUESO+user's application' started to run. More...
 
I/O methods
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. More...
 
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. More...
 
bool openInputFile (const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, FilePtrSetStruct &filePtrSet) const
 Opens an input file. More...
 
bool openUnifiedInputFile (const std::string &fileName, const std::string &fileType, FilePtrSetStruct &filePtrSet) const
 Opens the unified input file. More...
 
void closeFile (FilePtrSetStruct &filePtrSet, const std::string &fileType) const
 Closes the file. More...
 
void setExceptionalCircumstance (bool value) const
 Set an exceptional circumstance. More...
 
bool exceptionalCircumstance () const
 Decides whether there is an exceptional circumstance. More...
 
const GetPot & input () const
 The GetPot input file parser. More...
 
virtual void print (std::ostream &os) const =0
 

Protected Attributes

bool m_fullEnvIsReady
 
int m_worldRank
 
ScopedPtr< MpiComm >::Type m_fullComm
 
int m_fullRank
 
int m_fullCommSize
 
RawType_MPI_Group m_fullGroup
 
std::string m_optionsInputFileName
 
bool m_optionsInputFileAccessState
 
ScopedPtr
< boost::program_options::options_description >
::Type 
m_allOptionsDesc
 
ScopedPtr
< boost::program_options::variables_map >
::Type 
m_allOptionsMap
 
ScopedPtr< GetPot >::Type m_input
 
unsigned int m_subId
 
std::string m_subIdString
 
RawType_MPI_Group m_subGroup
 
ScopedPtr< MpiComm >::Type m_subComm
 
int m_subRank
 
int m_subCommSize
 
ScopedPtr< MpiComm >::Type m_selfComm
 
RawType_MPI_Group m_inter0Group
 
ScopedPtr< MpiComm >::Type m_inter0Comm
 
int m_inter0Rank
 
int m_inter0CommSize
 
ScopedPtr< std::ofstream >::Type m_subDisplayFile
 
ScopedPtr< RngBase >::Type m_rngObject
 
ScopedPtr< BasicPdfsBase >::Type m_basicPdfs
 
struct timeval m_timevalBegin
 
bool m_exceptionalCircumstance
 
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
 

Detailed Description

This (virtual) class sets up the environment underlying the use of the QUESO library by an executable.

This class sets up the environment underlying the use of the QUESO library by an executable. It:
  1. assigns rank numbers, other than the world rank, to nodes participating in a parallel job,
  2. provides communicators for generating a sequence of vectors in a distributed way,
  3. provides functionality to read options from the 'options input file' (whose name is passed in the constructor of this environment class),
  4. opens output files for messages that would otherwise be written to the screen (one output file per allowed rank is opened and allowed ranks can be specified through the 'options input file').

    This class is virtual. It is inherited by 'EmptyEnvironment' and 'FullEnvironment'.
    The QUESO environment class is instantiated at the application level, right after 'MPI_Init(&argc,&argv)'.
    The QUESO environment is required by reference by many constructors in the QUESO library,
    and is available by reference from many classes as well.
    

    Throughout QUESO, there are five classes whose constructors check options in the 'options input file':
    
    1. BaseEnvironment
    2. StatisticalInverseProblem
    3. StatisticalForwardProblem
    4. MetropolisHastingsSG ('SG' stands for 'sequence generator')
    5. MonteCarloSG
    These classes rely on 'options classes' to read their options from the input file.
    The options classes are, respectively:
    
    1. EnvironmentOptions
    2. StatisticalInverseProblemOptions
    3. StatisticalForwardProblemOptions
    4. MetropolisHastingsSGOptions
    5. MonteCarloSGOptions

    The last two classes also rely on SequenceStatisticalOptions for reading the options specifying which statistics have to be computed on the sequences of vectors

    involved.

    The QUESO environment class manages five types of communicators. Let:
    
    1. 'W >= 1' be the size of whole world communicator involved in a parallel run;
    2. 'N >= 1' be the size of the communicator passed to the QUESO environment constructor;
    3. 'S >= 1' be the number of statistical problems a QUESO environment will be handling at the same time, in parallel.

    Usually 'W'='N', but such equality is not necessary. The number 'S' is equal to the QUESO environment option 'm_numSubEnvironments', and is equal to 1 by default. The number 'N' must be a multiple of 'S', otherwise the QUESO class prints a fatal error message and MPI aborts. The five types of communicators that QUESO manages are referred to as:

    1. world = MPI_WORLD_COMM, of size W;
    2. full = communicator passed to the constructor of BaseEnvironment, of size N and usually equal to the world communicator;
    3. sub = communicator of size N/S that contains the number of MPI nodes necessary to solve a statistical inverse problem or a statistical forward problem.
    4. self = MPI_SELF_COMM, of size 1;
    5. inter0 = communicator of size S formed by all MPI nodes that have 'sub' rank 0 in their respective 'sub' communicators.

    So, any given node has potentially five different ranks. Of course, if the user is solving just one statistical problem with just one MPI node, then all ranks are equal to zero.


    In the QUESO library terminology, one might refer to a QUESO "full" environment composed of
    

    'S' QUESO "sub" environments. Each sub environment is assigned a "sub" id varying from 0 (zero) to S-1. Each sub environment is able to generate a statistical inverse problem and/or a statistical forward problem. That is, each sub environment is able to handle a "sub" Markov chain (a sequence) of vectors and/or a "sub" Monte Carlo sequence of output vectors. The "sub" sequences can be seen as forming a "unified" sequence in a distributed way. Indeed, the virtual class 'VectorSequence' provides "sub" and "unified" statistical operations.

    A QUESO "sub" environment eventually prints messages to its own output file. In order for that to happen, the requirements are:

    1. option 'm_subDisplayFileName', a string, must be different than the default value ".";
    2. option 'm_subDisplayAllowedSet', a set of sub ids, must contain the id of the sub environment wanting to write a message to the output file;
    3. the previous requirement is automatically satisfied if the option 'm_subDisplayAllowAll', a boolean, is set to 1 (the default value is 0);
    4. the processor wanting to write a message to the output file must have sub rank 0 (zero).

    If all requirements are satisfied, then QUESO will generate a file with name '<m_subDisplayFileName>_sub<sub id>.txt'. For instance, if 'm_subDisplayFileName' is 'pROblem_775_' then a node of sub rank 0 in sub environment 17 will write a message to the file 'pROblem_775_sub17.txt'.

Definition at line 198 of file Environment.h.

Constructor & Destructor Documentation

QUESO::BaseEnvironment::BaseEnvironment ( const char *  passedOptionsInputFileName,
EnvOptionsValues alternativeOptionsValues 
)

Default constructor.

Definition at line 145 of file Environment.C.

References m_optionsInputFileName, and m_optionsObj.

148  :
149  m_fullEnvIsReady (false),
150  m_worldRank (-1),
151  m_fullComm (),
152  m_fullRank (-1),
153  m_fullCommSize (1),
156 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
157  m_allOptionsDesc (),
158  m_allOptionsMap (),
159 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
160  m_input (new GetPot),
161  m_subComm (),
162  m_subRank (-1),
163  m_subCommSize (1),
164  m_selfComm (),
165  m_inter0Comm (),
166  m_inter0Rank (-1),
167  m_inter0CommSize (1),
168  m_subDisplayFile (),
169  m_rngObject (),
170  m_basicPdfs (),
172  m_optionsObj ()
173 {
174  if (passedOptionsInputFileName) m_optionsInputFileName = passedOptionsInputFileName;
175 
176  // If the user passed in an options object pointer, we really shouldn't let
177  // ScopedPtr delete their object, so we make a copy. That way, the dtor
178  // will kill this local copy and leave the user's object in tact.
179  if (alternativeOptionsValues != NULL) {
180  m_optionsObj.reset(new EnvOptionsValues(*alternativeOptionsValues));
181  }
182 }
ScopedPtr< GetPot >::Type m_input
Definition: Environment.h:453
ScopedPtr< MpiComm >::Type m_fullComm
Definition: Environment.h:442
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
ScopedPtr< RngBase >::Type m_rngObject
Definition: Environment.h:470
ScopedPtr< boost::program_options::variables_map >::Type m_allOptionsMap
Definition: Environment.h:451
ScopedPtr< boost::program_options::options_description >::Type m_allOptionsDesc
Definition: Environment.h:450
std::string m_optionsInputFileName
Definition: Environment.h:447
ScopedPtr< MpiComm >::Type m_selfComm
Definition: Environment.h:462
ScopedPtr< MpiComm >::Type m_inter0Comm
Definition: Environment.h:465
ScopedPtr< MpiComm >::Type m_subComm
Definition: Environment.h:458
ScopedPtr< BasicPdfsBase >::Type m_basicPdfs
Definition: Environment.h:471
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
QUESO::BaseEnvironment::BaseEnvironment ( const std::string &  passedOptionsInputFileName,
EnvOptionsValues alternativeOptionsValues 
)

Definition at line 184 of file Environment.C.

References m_optionsObj.

187  :
188  m_fullEnvIsReady (false),
189  m_worldRank (-1),
190  m_fullComm (),
191  m_fullRank (-1),
192  m_fullCommSize (1),
193  m_optionsInputFileName (passedOptionsInputFileName),
195 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
196  m_allOptionsDesc (),
197  m_allOptionsMap (),
198 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
199  m_input (new GetPot),
200  m_subComm (),
201  m_subRank (-1),
202  m_subCommSize (1),
203  m_selfComm (),
204  m_inter0Comm (),
205  m_inter0Rank (-1),
206  m_inter0CommSize (1),
207  m_subDisplayFile (),
208  m_rngObject (),
209  m_basicPdfs (),
211  m_optionsObj ()
212 {
213  // If the user passed in an options object pointer, we really shouldn't let
214  // ScopedPtr delete their object, so we make a copy. That way, the dtor
215  // will kill this local copy and leave the user's object in tact.
216  if (alternativeOptionsValues != NULL) {
217  m_optionsObj.reset(new EnvOptionsValues(*alternativeOptionsValues));
218  }
219 }
ScopedPtr< GetPot >::Type m_input
Definition: Environment.h:453
ScopedPtr< MpiComm >::Type m_fullComm
Definition: Environment.h:442
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
ScopedPtr< RngBase >::Type m_rngObject
Definition: Environment.h:470
ScopedPtr< boost::program_options::variables_map >::Type m_allOptionsMap
Definition: Environment.h:451
ScopedPtr< boost::program_options::options_description >::Type m_allOptionsDesc
Definition: Environment.h:450
std::string m_optionsInputFileName
Definition: Environment.h:447
ScopedPtr< MpiComm >::Type m_selfComm
Definition: Environment.h:462
ScopedPtr< MpiComm >::Type m_inter0Comm
Definition: Environment.h:465
ScopedPtr< MpiComm >::Type m_subComm
Definition: Environment.h:458
ScopedPtr< BasicPdfsBase >::Type m_basicPdfs
Definition: Environment.h:471
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
QUESO::BaseEnvironment::~BaseEnvironment ( )
virtual

Destructor.

It deallocates memory and does other cleanup for the class object and its class members when the object is destroyed. It displays the total run time of the combo QUESO + application using the function gettimeofday() from a struct timeval (as specified in <sys/time.h>).

Definition at line 222 of file Environment.C.

References displayVerbosity(), m_fullRank, m_subDisplayFile, and m_timevalBegin.

223 {
224  //if (m_subDisplayFile) {
225  // *m_subDisplayFile << "Entering BaseEnvironment::destructor()"
226  // << std::endl;
227  //}
228 
229  struct timeval timevalNow;
230  /*int iRC = 0;*/
231  /*iRC = */gettimeofday(&timevalNow, NULL);
232 
233  if (this->displayVerbosity() > 0) {
234  if (m_subDisplayFile) {
235  *m_subDisplayFile << "Ending run at " << ctime(&timevalNow.tv_sec)
236  << "Total run time = " << timevalNow.tv_sec - m_timevalBegin.tv_sec
237  << " seconds"
238  << std::endl;
239  }
240 
241  if (m_fullRank == 0) {
242  std::cout << "Ending run at " << ctime(&timevalNow.tv_sec)
243  << "Total run time = " << timevalNow.tv_sec - m_timevalBegin.tv_sec
244  << " seconds"
245  << std::endl;
246  }
247  }
248 
249  //if (m_subDisplayFile) {
250  // *m_subDisplayFile << "Leaving BaseEnvironment::destructor()"
251  // << std::endl;
252  //}
253 }
unsigned int displayVerbosity() const
Definition: Environment.C:450
struct timeval m_timevalBegin
Definition: Environment.h:472
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469

Member Function Documentation

const boost::program_options::options_description & QUESO::BaseEnvironment::allOptionsDesc ( ) const

Definition at line 375 of file Environment.C.

References m_allOptionsDesc.

376 {
377  queso_deprecated();
378 
379  return *m_allOptionsDesc;
380 }
ScopedPtr< boost::program_options::options_description >::Type m_allOptionsDesc
Definition: Environment.h:450
boost::program_options::variables_map & QUESO::BaseEnvironment::allOptionsMap ( ) const

Access function to private attribute m_allOptionsMap. It is an instance of boost::program_options::variables_map(), which allows concrete variables to map which store variables in real map.

Definition at line 386 of file Environment.C.

References m_allOptionsMap.

Referenced by QUESO::StatisticalInverseProblemOptions::getMyOptionValues(), QUESO::EnvironmentOptions::getMyOptionValues(), and QUESO::MetropolisHastingsSGOptions::getMyOptionValues().

387 {
388  queso_deprecated();
389 
390  queso_require_msg(m_allOptionsMap, "m_allOptionsMap variable is NULL");
391  return *m_allOptionsMap;
392 }
ScopedPtr< boost::program_options::variables_map >::Type m_allOptionsMap
Definition: Environment.h:451
const BasicPdfsBase * QUESO::BaseEnvironment::basicPdfs ( ) const

Access to Basic PDFs.

Definition at line 490 of file Environment.C.

References m_basicPdfs.

491 {
492  return m_basicPdfs.get();
493 }
ScopedPtr< BasicPdfsBase >::Type m_basicPdfs
Definition: Environment.h:471
unsigned int QUESO::BaseEnvironment::checkingLevel ( ) const

Access function to private attribute m_checkingLevel.

Definition at line 464 of file Environment.C.

References m_optionsObj.

Referenced by QUESO::TeuchosMatrix::inverse(), and QUESO::GslMatrix::inverse().

465 {
466  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
467  return m_optionsObj->m_checkingLevel;
468 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
void QUESO::BaseEnvironment::checkTheParallelEnvironment ( ) const
void QUESO::BaseEnvironment::closeFile ( FilePtrSetStruct filePtrSet,
const std::string &  fileType 
) const

Closes the file.

Definition at line 1084 of file Environment.C.

References QUESO::FilePtrSetStruct::h5Var, QUESO::FilePtrSetStruct::ifsVar, m_subDisplayFile, QUESO::FilePtrSetStruct::ofsVar, subDisplayFile(), and subRank().

Referenced by QUESO::GslVector::subReadContents(), QUESO::TeuchosVector::subReadContents(), QUESO::TeuchosMatrix::subReadContents(), QUESO::GslMatrix::subReadContents(), QUESO::GslVector::subWriteContents(), QUESO::TeuchosVector::subWriteContents(), QUESO::TeuchosMatrix::subWriteContents(), and QUESO::GslMatrix::subWriteContents().

1087 {
1088  std::string fileType(inputFileType);
1089 #ifdef QUESO_HAS_HDF5
1090  // Do nothing
1091 #else
1092  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1093  if (m_subDisplayFile) {
1094  *this->subDisplayFile() << "WARNING in BaseEnvironment::closeFile()"
1095  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1096  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1097  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1098  << "' instead..."
1099  << std::endl;
1100  }
1101  if (this->subRank() == 0) {
1102  std::cerr << "WARNING in BaseEnvironment::closeFile()"
1103  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1104  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1105  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1106  << "' instead..."
1107  << std::endl;
1108  }
1109  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
1110  }
1111 #endif
1112 
1113  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1114  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1115  //filePtrSet.ofsVar->close(); // close() crashes on Mac; need to use delete(); why? prudenci 2010/June
1116  delete filePtrSet.ofsVar;
1117  filePtrSet.ofsVar = NULL;
1118 
1119  //filePtrSet.ifsVar->close();
1120  delete filePtrSet.ifsVar;
1121  filePtrSet.ifsVar = NULL;
1122  }
1123 #ifdef QUESO_HAS_HDF5
1124  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1125  H5Fclose(filePtrSet.h5Var);
1126  }
1127 #endif
1128  else {
1129  queso_error_msg("invalid file type");
1130  }
1131 
1132  return;
1133 }
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
unsigned int QUESO::BaseEnvironment::displayVerbosity ( ) const

Access function to private attribute m_displayVerbosity. It manages how much information will be release during the use of the QUESO library.

Definition at line 450 of file Environment.C.

References m_optionsObj.

Referenced by QUESO::AsciiTable< V, M >::AsciiTable(), QUESO::BaseJointPdf< V, M >::BaseJointPdf(), QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::BaseMatrixCovarianceFunction(), QUESO::BaseOneDGrid< T >::BaseOneDGrid(), QUESO::BaseScalarCdf< T >::BaseScalarCdf(), QUESO::BaseScalarCovarianceFunction< V, M >::BaseScalarCovarianceFunction(), QUESO::BaseVectorCdf< V, M >::BaseVectorCdf(), QUESO::BaseVectorMdf< V, M >::BaseVectorMdf(), QUESO::BaseVectorRealizer< V, M >::BaseVectorRealizer(), QUESO::BaseVectorRV< V, M >::BaseVectorRV(), QUESO::BetaJointPdf< V, M >::BetaJointPdf(), QUESO::BetaVectorRealizer< V, M >::BetaVectorRealizer(), QUESO::BetaVectorRV< V, M >::BetaVectorRV(), QUESO::BIP_routine(), QUESO::ConcatenatedVectorRealizer< V, M >::ConcatenatedVectorRealizer(), QUESO::ConcatenatedVectorRV< V, M >::ConcatenatedVectorRV(), QUESO::FullEnvironment::construct(), QUESO::GslVector::cwSetBeta(), QUESO::TeuchosVector::cwSetBeta(), QUESO::TeuchosMatrix::determinant(), QUESO::GslMatrix::determinant(), QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::ExponentialMatrixCovarianceFunction(), QUESO::ExponentialScalarCovarianceFunction< V, M >::ExponentialScalarCovarianceFunction(), QUESO::FiniteDistribution::FiniteDistribution(), QUESO::GammaJointPdf< V, M >::GammaJointPdf(), QUESO::GammaVectorRealizer< V, M >::GammaVectorRealizer(), QUESO::GammaVectorRV< V, M >::GammaVectorRV(), QUESO::GaussianJointPdf< V, M >::GaussianJointPdf(), QUESO::GaussianVectorCdf< V, M >::GaussianVectorCdf(), QUESO::GaussianVectorMdf< V, M >::GaussianVectorMdf(), QUESO::GaussianVectorRealizer< V, M >::GaussianVectorRealizer(), QUESO::GaussianVectorRV< V, M >::GaussianVectorRV(), QUESO::GenericMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::GenericMatrixCovarianceFunction(), QUESO::GenericScalarCovarianceFunction< V, M >::GenericScalarCovarianceFunction(), QUESO::GenericVectorRealizer< V, M >::GenericVectorRealizer(), QUESO::GenericVectorRV< V, M >::GenericVectorRV(), QUESO::HessianCovMatricesTKGroup< V, M >::HessianCovMatricesTKGroup(), QUESO::horizontalDistance(), QUESO::TeuchosMatrix::inverse(), QUESO::GslMatrix::inverse(), QUESO::InverseGammaJointPdf< V, M >::InverseGammaJointPdf(), QUESO::InverseGammaVectorRealizer< V, M >::InverseGammaVectorRealizer(), QUESO::InverseGammaVectorRV< V, M >::InverseGammaVectorRV(), QUESO::TeuchosMatrix::invertMultiply(), QUESO::GslMatrix::invertMultiply(), QUESO::InvLogitGaussianVectorRV< V, M >::InvLogitGaussianVectorRV(), QUESO::JeffreysJointPdf< V, M >::JeffreysJointPdf(), QUESO::JeffreysVectorRealizer< V, M >::JeffreysVectorRealizer(), QUESO::JeffreysVectorRV< V, M >::JeffreysVectorRV(), QUESO::TeuchosMatrix::lnDeterminant(), QUESO::GslMatrix::lnDeterminant(), QUESO::LogNormalJointPdf< V, M >::LogNormalJointPdf(), QUESO::LogNormalVectorRealizer< V, M >::LogNormalVectorRealizer(), QUESO::LogNormalVectorRV< V, M >::LogNormalVectorRV(), QUESO::MetropolisAdjustedLangevinTK< V, M >::MetropolisAdjustedLangevinTK(), openInputFile(), openOutputFile(), openUnifiedInputFile(), openUnifiedOutputFile(), QUESO::PoweredJointPdf< V, M >::PoweredJointPdf(), QUESO::TeuchosMatrix::rank(), QUESO::GslMatrix::rank(), QUESO::SampledScalarCdf< T >::SampledScalarCdf(), QUESO::SampledVectorCdf< V, M >::SampledVectorCdf(), QUESO::SampledVectorMdf< V, M >::SampledVectorMdf(), QUESO::ScaledCovMatrixTKGroup< V, M >::ScaledCovMatrixTKGroup(), QUESO::EnvironmentOptions::scanOptionsValues(), QUESO::SequentialVectorRealizer< V, M >::SequentialVectorRealizer(), QUESO::StdOneDGrid< T >::StdOneDGrid(), QUESO::StdScalarCdf< T >::StdScalarCdf(), QUESO::TeuchosMatrix::svdSolve(), QUESO::GslMatrix::svdSolve(), QUESO::TransformedScaledCovMatrixTKGroup< V, M >::TransformedScaledCovMatrixTKGroup(), QUESO::UniformJointPdf< V, M >::UniformJointPdf(), QUESO::UniformOneDGrid< T >::UniformOneDGrid(), QUESO::UniformVectorRealizer< V, M >::UniformVectorRealizer(), QUESO::UniformVectorRV< V, M >::UniformVectorRV(), QUESO::VectorSet< V, M >::VectorSet(), QUESO::VectorSpace< V, M >::VectorSpace(), QUESO::VectorSubset< V, M >::VectorSubset(), QUESO::WignerJointPdf< V, M >::WignerJointPdf(), QUESO::WignerVectorRealizer< V, M >::WignerVectorRealizer(), QUESO::WignerVectorRV< V, M >::WignerVectorRV(), and ~BaseEnvironment().

451 {
452  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
453  return m_optionsObj->m_displayVerbosity;
454 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
bool QUESO::BaseEnvironment::exceptionalCircumstance ( ) const

Decides whether there is an exceptional circumstance.

Definition at line 1143 of file Environment.C.

References m_exceptionalCircumstance.

1144 {
1146 }
const MpiComm & QUESO::BaseEnvironment::fullComm ( ) const

Access function for the communicator that was passed to QUESO's environment.

The 'full' communicator is the MPI communicator that the user passed when creating the QUESO FullEnvironment. This is usually MPI_COMM_WORLD, but the user is permitted to pass any MPI communicator smaller than MPI_COMM_WORLD.

Definition at line 274 of file Environment.C.

References m_fullComm.

Referenced by QUESO::FullEnvironment::construct(), QUESO::EnvironmentOptions::getMyOptionValues(), QUESO::MiscCheckTheParallelEnvironment(), and QUESO::InterpolationSurrogateIOASCII< V, M >::read().

275 {
276  queso_require_msg(m_fullComm, "m_fullComm variable is NULL");
277  return *m_fullComm;
278 }
ScopedPtr< MpiComm >::Type m_fullComm
Definition: Environment.h:442
bool QUESO::BaseEnvironment::fullEnvIsReady ( ) const

Returns whether the full environment class is ready (constructor has successfully been called).

Definition at line 256 of file Environment.C.

References m_fullEnvIsReady.

257 {
258  return m_fullEnvIsReady;
259 }
std::string QUESO::BaseEnvironment::identifyingString ( ) const

Access function to private attribute m_identifyingString: identifying string.

Definition at line 502 of file Environment.C.

References m_optionsObj.

503 {
504  return m_optionsObj->m_identifyingString;
505 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
const MpiComm & QUESO::BaseEnvironment::inter0Comm ( ) const

Access function for MpiComm communicator for processes with subRank() 0.

Definition at line 313 of file Environment.C.

References m_inter0Comm.

Referenced by QUESO::ComputeCovCorrBetweenScalarSequences(), and QUESO::ComputeCovCorrMatricesBetweenVectorSequences().

314 {
315  queso_require_msg(m_inter0Comm, "m_inter0Comm variable is NULL");
316  return *m_inter0Comm;
317 }
ScopedPtr< MpiComm >::Type m_inter0Comm
Definition: Environment.h:465
int QUESO::BaseEnvironment::inter0Rank ( ) const
bool QUESO::BaseEnvironment::isThereInputFile ( ) const

//TODO Not implemented? it is called in examples/validationCycle/tests_old/results_5_25/uqTgaEx4.h.

unsigned int QUESO::BaseEnvironment::numSubEnvironments ( ) const

Access function to the number of sub-environments.

Definition at line 335 of file Environment.C.

References m_optionsObj.

Referenced by QUESO::ComputeUnifiedGaussian2dKde(), and QUESO::MiscCheckTheParallelEnvironment().

336 {
337  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
338  return m_optionsObj->m_numSubEnvironments;
339 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
bool QUESO::BaseEnvironment::openInputFile ( const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds,
FilePtrSetStruct filePtrSet 
) const

Opens an input file.

Definition at line 896 of file Environment.C.

References QUESO::CheckFilePath(), displayVerbosity(), QUESO::FilePtrSetStruct::h5Var, QUESO::FilePtrSetStruct::ifsVar, m_subDisplayFile, subDisplayFile(), and subRank().

Referenced by QUESO::GslVector::subReadContents(), QUESO::TeuchosVector::subReadContents(), QUESO::TeuchosMatrix::subReadContents(), and QUESO::GslMatrix::subReadContents().

901 {
902  std::string fileType(inputFileType);
903 #ifdef QUESO_HAS_HDF5
904  // Do nothing
905 #else
906  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
907  if (m_subDisplayFile) {
908  *this->subDisplayFile() << "WARNING in BaseEnvironment::openInputFile()"
909  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
910  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
911  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
912  << "' instead..."
913  << std::endl;
914  }
915  if (this->subRank() == 0) {
916  std::cerr << "WARNING in BaseEnvironment::openInputFile()"
917  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
918  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
919  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
920  << "' instead..."
921  << std::endl;
922  }
923  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
924  }
925 #endif
926 
927  bool returnValue = true;
928  filePtrSet.ifsVar = NULL;
929  if ((baseFileName == UQ_ENV_FILENAME_FOR_NO_INPUT_FILE) ||
930  (allowedSubEnvIds.find(this->subId()) == allowedSubEnvIds.end() )) {
931  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
932  *this->subDisplayFile() << "In BaseEnvironment::openInputFile()"
933  << ": no input file opened with base name '" << baseFileName << "." << fileType
934  << "'"
935  << std::endl;
936  }
937  returnValue = false;
938  }
939  else {
941  // Open file
943  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
944  *this->subDisplayFile() << "In BaseEnvironment::openInputFile()"
945  << ": opening input file with base name '" << baseFileName << "." << fileType
946  << "'"
947  << std::endl;
948  }
949  if (this->subRank() == 0) {
951  // Verify parent directory exists (for cases when a user
952  // specifies a relative path for the desired output file). prudenci 2010/06/26
954  // std::cout << "checking " << baseFileName+"."+fileType << std::endl;
955  int irtrn = CheckFilePath((baseFileName+"."+fileType).c_str());
956  queso_require_greater_equal_msg(irtrn, 0, "unable to verify input path");
957 
958  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
959  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
960  filePtrSet.ifsVar = new std::ifstream((baseFileName+"."+fileType).c_str(),
961  std::ofstream::in);
962  if ((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)) {
963  std::cerr << "In BaseEnvironment::openInputFile()"
964  << ": failed to open input file with base name '" << baseFileName << "." << fileType
965  << "'"
966  << std::endl;
967  }
968  queso_require_msg(!((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)), "file with fileName could not be found");
969  }
970 #ifdef QUESO_HAS_HDF5
971  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
972  filePtrSet.h5Var = H5Fopen((baseFileName+"."+fileType).c_str(),
973  H5F_ACC_RDONLY,
974  H5P_DEFAULT);
975  }
976 #endif
977  else {
978  queso_error_msg("invalid file type");
979  }
980  }
981  else {
982  returnValue = false;
983  }
984  //this->subComm().Barrier(); // prudenci-2011-01-17
985  }
986 
987  return returnValue;
988 }
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
int CheckFilePath(const char *path)
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
bool QUESO::BaseEnvironment::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 at line 521 of file Environment.C.

References QUESO::CheckFilePath(), displayVerbosity(), QUESO::FilePtrSetStruct::h5Var, m_subDisplayFile, QUESO::FilePtrSetStruct::ofsVar, subDisplayFile(), subId(), subIdString(), and subRank().

Referenced by QUESO::GslVector::subWriteContents(), QUESO::TeuchosVector::subWriteContents(), QUESO::TeuchosMatrix::subWriteContents(), and QUESO::GslMatrix::subWriteContents().

527 {
528  std::string fileType(inputFileType);
529 #ifdef QUESO_HAS_HDF5
530  // Do nothing
531 #else
532  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
533  if (m_subDisplayFile) {
534  *this->subDisplayFile() << "WARNING in BaseEnvironment::openOutputFile()"
535  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
536  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
537  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
538  << "' instead..."
539  << std::endl;
540  }
541  if (this->subRank() == 0) {
542  std::cerr << "WARNING in BaseEnvironment::openOutputFile()"
543  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
544  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
545  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
546  << "' instead..."
547  << std::endl;
548  }
549  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
550  }
551 #endif
552 
553  bool returnValue = true;
554  filePtrSet.ofsVar = NULL;
555  if ((baseFileName == UQ_ENV_FILENAME_FOR_NO_OUTPUT_FILE) ||
556  (allowedSubEnvIds.find(this->subId()) == allowedSubEnvIds.end() )) {
557  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
558  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
559  << ", subId = " << this->subId()
560  << ": no output file opened with base name '" << baseFileName << "." << fileType
561  << "'"
562  << ", writeOver = " << writeOver
563  << std::endl;
564  }
565  returnValue = false;
566  }
567  else {
569  // Open file
571  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
572  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
573  << ", subId = " << this->subId()
574  << ": opening output file with base name '" << baseFileName << "." << fileType
575  << "'"
576  << ", writeOver = " << writeOver
577  << std::endl;
578  }
579 
580  if (this->subRank() == 0) {
581 #if 0
582  std::cout << "In BaseEnvironment::openOutputFile()"
583  << ": opening output file with base name '" << baseFileName << "." << fileType
584  << "'"
585  << ", writeOver = " << writeOver
586  << std::endl;
587 #endif
588 
590  // Verify parent directory exists (for cases when a user
591  // specifies a relative path for the desired output file).
593  // std::cout << "checking " << baseFileName+"_sub"+this->subIdString()+"."+fileType << std::endl;
594  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
595  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
596  << ", subId = " << this->subId()
597  << ", trying to open output file with base name '" << baseFileName << "." << fileType
598  << "'"
599  << ", writeOver = " << writeOver
600  << ": calling CheckFilePath()..."
601  << std::endl;
602  }
603  int irtrn = CheckFilePath((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str());
604  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
605  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
606  << ", subId = " << this->subId()
607  << ", trying to open output file with base name '" << baseFileName << "." << fileType
608  << "'"
609  << ", writeOver = " << writeOver
610  << ": returned from CheckFilePath() with irtrn = " << irtrn
611  << std::endl;
612  }
613  queso_require_greater_equal_msg(irtrn, 0, "unable to verify output path");
614 
615  if (writeOver) {
617  // Write over an eventual pre-existing file
619  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
620  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
621  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
622  std::ofstream::out | std::ofstream::trunc);
623  }
624  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
625  queso_error_msg("hdf file type not supported yet");
626  }
627  else {
628  queso_error_msg("invalid file type");
629  }
630  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
631  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
632  << ": just opened output file with base name '" << baseFileName << "." << fileType
633  << "'"
634  << ", writeOver = " << writeOver
635  << ", options 'out|trunc'"
636  << ", osfvar = " << filePtrSet.ofsVar
637  << std::endl;
638  }
639  }
640  else {
642  // Write at the end of an eventual pre-existing file
644  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
645  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
646 #if 0
647  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
648  std::ofstream::in);
649  std::cout << "filePtrSet.ofsVar(1) = " << filePtrSet.ofsVar << std::endl;
650  if (filePtrSet.ofsVar) std::cout << "filePtrSet.ofsVar(1)->is_open() = " << filePtrSet.ofsVar->is_open() << std::endl;
651  if (filePtrSet.ofsVar) delete filePtrSet.ofsVar;
652 #endif
653  // 'm' and Ranger nodes behave differently on ofstream constructor... prudenci 2010/03/05
654  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
655  std::ofstream::out /*| std::ofstream::in*/ | std::ofstream::app);
656  }
657 #ifdef QUESO_HAS_HDF5
658  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
659  std::string fullFileName =
660  baseFileName+"_sub"+this->subIdString()+"."+fileType;
661 
662  // Use H5F_ACC_EXCL because not overwriting, so fail on existing file
663  filePtrSet.h5Var = H5Fcreate(fullFileName.c_str(),
664  H5F_ACC_EXCL,
665  H5P_DEFAULT,
666  H5P_DEFAULT);
667 
668  queso_require_greater_equal_msg(
669  filePtrSet.h5Var, 0,
670  "error opening file `" << fullFileName << "`");
671  }
672 #endif
673  else {
674  queso_error_msg("invalid file type");
675  }
676  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
677  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
678  << ": just opened output file with base name '" << baseFileName << "." << fileType
679  << "'"
680  << ", writeOver = " << writeOver
681  << ", options 'out|in|app'"
682  << ", osfvar = " << filePtrSet.ofsVar
683  << std::endl;
684  }
685 
686  if (fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) {
687  //std::cout << "filePtrSet.ofsVar(2) = " << filePtrSet.ofsVar << std::endl;
688  //if (filePtrSet.ofsVar) std::cout << "filePtrSet.ofsVar(2)->is_open() = " << filePtrSet.ofsVar->is_open() << std::endl;
689  if ((filePtrSet.ofsVar == NULL ) ||
690  (filePtrSet.ofsVar->is_open() == false)) {
691  //std::cout << "Retrying 1..." << std::endl;
692  delete filePtrSet.ofsVar;
693  filePtrSet.ofsVar = new std::ofstream((baseFileName+"_sub"+this->subIdString()+"."+fileType).c_str(),
694  std::ofstream::out | std::ofstream::trunc);
695  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
696  *this->subDisplayFile() << "In BaseEnvironment::openOutputFile()"
697  << ": just opened output file with base name '" << baseFileName << "." << fileType
698  << "'"
699  << ", writeOver = " << writeOver
700  << ", options 'out|trunc'"
701  << ", osfvar = " << filePtrSet.ofsVar
702  << std::endl;
703  }
704  }
705  } // only for matlab formats
706  }
707 
708  // Check the file actually opened
709  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
710  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
711  queso_require_msg(
712  (filePtrSet.ofsVar && filePtrSet.ofsVar->is_open()),
713  "failed to open output file");
714  }
715  }
716  else {
717  returnValue = false;
718  }
719  //this->subComm().Barrier(); // prudenci-2011-01-17
720  }
721 
722  return returnValue;
723 }
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
Definition: Environment.C:342
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
int CheckFilePath(const char *path)
unsigned int displayVerbosity() const
Definition: Environment.C:450
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:348
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
bool QUESO::BaseEnvironment::openUnifiedInputFile ( const std::string &  fileName,
const std::string &  fileType,
FilePtrSetStruct filePtrSet 
) const

Opens the unified input file.

Definition at line 991 of file Environment.C.

References QUESO::CheckFilePath(), displayVerbosity(), QUESO::FilePtrSetStruct::h5Var, QUESO::FilePtrSetStruct::ifsVar, m_subDisplayFile, subDisplayFile(), and subRank().

995 {
996  std::string fileType(inputFileType);
997 #ifdef QUESO_HAS_HDF5
998  // Do nothing
999 #else
1000  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1001  if (m_subDisplayFile) {
1002  *this->subDisplayFile() << "WARNING in BaseEnvironment::openUnifiedInputFile()"
1003  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1004  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1005  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1006  << "' instead..."
1007  << std::endl;
1008  }
1009  if (this->subRank() == 0) {
1010  std::cerr << "WARNING in BaseEnvironment::openUnifiedInputFile()"
1011  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1012  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1013  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1014  << "' instead..."
1015  << std::endl;
1016  }
1017  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
1018  }
1019 #endif
1020 
1021  bool returnValue = true;
1022  filePtrSet.ifsVar = NULL;
1023  if (baseFileName == UQ_ENV_FILENAME_FOR_NO_INPUT_FILE) {
1024  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
1025  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedInputFile()"
1026  << ": no input file opened with base name '" << baseFileName << "." << fileType
1027  << "'"
1028  << std::endl;
1029  }
1030  returnValue = false;
1031  }
1032  else {
1034  // Open file
1036  if ((m_subDisplayFile) && (this->displayVerbosity() >= 10)) {
1037  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedInputFile()"
1038  << ": opening input file with base name '" << baseFileName << "." << fileType
1039  << "'"
1040  << std::endl;
1041  }
1042  if (this->subRank() == 0) { // Needed ???????? prudenci 2010-11-11
1044  // Verify parent directory exists (for cases when a user
1045  // specifies a relative path for the desired output file). prudenci 2010/06/26
1047  // std::cout << "checking " << baseFileName+"."+fileType << std::endl;
1048  int irtrn = CheckFilePath((baseFileName+"."+fileType).c_str());
1049  queso_require_greater_equal_msg(irtrn, 0, "unable to verify input path");
1050 
1051  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1052  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1053  filePtrSet.ifsVar = new std::ifstream((baseFileName+"."+fileType).c_str(),
1054  std::ofstream::in);
1055  if ((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)) {
1056  std::cerr << "In BaseEnvironment::openUnifiedInputFile()"
1057  << ": failed to open input file with base name '" << baseFileName << "." << fileType
1058  << "'"
1059  << std::endl;
1060  }
1061  queso_require_msg(!((filePtrSet.ifsVar == NULL) || (filePtrSet.ifsVar->is_open() == false)), "file with fileName could not be found");
1062  }
1063 #ifdef QUESO_HAS_HDF5
1064  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1065  filePtrSet.h5Var = H5Fopen((baseFileName+"."+fileType).c_str(),
1066  H5F_ACC_RDONLY,
1067  H5P_DEFAULT);
1068  }
1069 #endif
1070  else {
1071  queso_error_msg("invalid file type");
1072  }
1073  }
1074  //else {
1075  // returnValue = false;
1076  //}
1077  //this->subComm().Barrier();
1078  }
1079 
1080  return returnValue;
1081 }
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
int CheckFilePath(const char *path)
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
bool QUESO::BaseEnvironment::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 at line 726 of file Environment.C.

References QUESO::CheckFilePath(), displayVerbosity(), QUESO::FilePtrSetStruct::h5Var, m_subDisplayFile, QUESO::FilePtrSetStruct::ofsVar, subDisplayFile(), and subRank().

731 {
732  std::string fileType(inputFileType);
733 #ifdef QUESO_HAS_HDF5
734  // Do nothing
735 #else
736  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
737  if (m_subDisplayFile) {
738  *this->subDisplayFile() << "WARNING in BaseEnvironment::openUnifiedOutputFile()"
739  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
740  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
741  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
742  << "' instead..."
743  << std::endl;
744  }
745  if (this->subRank() == 0) {
746  std::cerr << "WARNING in BaseEnvironment::openUnifiedOutputFile()"
747  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
748  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
749  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
750  << "' instead..."
751  << std::endl;
752  }
753  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
754  }
755 #endif
756 
757  bool returnValue = true;
758  filePtrSet.ofsVar = NULL;
759  if (baseFileName == ".") {
760  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
761  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
762  << ": no unified output file opened with base name '" << baseFileName << "." << fileType
763  << "'"
764  << ", writeOver = " << writeOver
765  << std::endl;
766  }
767  returnValue = false;
768  }
769  else {
771  // Open file
773  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
774  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
775  << ": opening unified output file with base name '" << baseFileName << "." << fileType
776  << "'"
777  << ", writeOver = " << writeOver
778  << std::endl;
779  }
780 
781 
782  //if ((this->subRank () == 0) &&
783  // (this->inter0Rank() == 0)) {
784 #if 0
785  std::cout << "In BaseEnvironment::openUnifiedOutputFile()"
786  << ": opening output file with base name '" << baseFileName << "." << fileType
787  << "'"
788  << ", writeOver = " << writeOver
789  << std::endl;
790 #endif
791  // Verify parent directory exists (for cases when a user
793  // specifies a relative path for the desired output file). prudenci 2010/06/26
795  // std::cout << "checking " << baseFileName+"."+fileType << std::endl;
796  int irtrn = CheckFilePath((baseFileName+"."+fileType).c_str());
797  queso_require_greater_equal_msg(irtrn, 0, "unable to verify output path");
798 
799  if (writeOver) {
801  // Write over an eventual pre-existing file
803  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
804  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
805  filePtrSet.ofsVar = new std::ofstream((baseFileName+"."+fileType).c_str(),
806  std::ofstream::out | std::ofstream::trunc);
807  }
808 #ifdef QUESO_HAS_HDF5
809  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
810  filePtrSet.h5Var = H5Fcreate((baseFileName+"."+fileType).c_str(),
811  H5F_ACC_TRUNC,
812  H5P_DEFAULT,
813  H5P_DEFAULT);
814  }
815 #endif
816  else {
817  queso_error_msg("invalid file type");
818  }
819  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
820  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
821  << ": just opened output file with base name '" << baseFileName << "." << fileType
822  << "'"
823  << ", writeOver = " << writeOver
824  << ", options 'out|trunc'"
825  << ", osfvar = " << filePtrSet.ofsVar
826  << std::endl;
827  }
828  }
829  else {
831  // Write at the end of an eventual pre-existing file
832  // 'm' and Ranger nodes behave differently on ofstream constructor... prudenci 2010/03/05
834  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
835  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
836  filePtrSet.ofsVar = new std::ofstream((baseFileName+"."+fileType).c_str(),
837  std::ofstream::out /*| std::ofstream::in*/ | std::ofstream::app);
838  }
839 #ifdef QUESO_HAS_HDF5
840  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
841  filePtrSet.h5Var = H5Fcreate((baseFileName+"."+fileType).c_str(), // TEMPORARY - FIX ME
842  H5F_ACC_TRUNC,
843  H5P_DEFAULT,
844  H5P_DEFAULT);
845 
846  // m_worldRank,
847  // "BaseEnvironment::openUnifiedOutputFile(), writeOver=false",
848  // "hdf file type not supported yet");
849  }
850 #endif
851  else {
852  queso_error_msg("invalid file type");
853  }
854  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
855  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
856  << ": just opened output file with base name '" << baseFileName << "." << fileType
857  << "'"
858  << ", writeOver = " << writeOver
859  << ", options 'out|in|app'"
860  << ", osfvar = " << filePtrSet.ofsVar
861  << std::endl;
862  }
863  if ((filePtrSet.ofsVar == NULL ) ||
864  (filePtrSet.ofsVar->is_open() == false)) {
865 #if 0
866  std::cout << "Retrying 2..." << std::endl;
867 #endif
868  delete filePtrSet.ofsVar;
869  filePtrSet.ofsVar = new std::ofstream((baseFileName+"."+fileType).c_str(),
870  std::ofstream::out | std::ofstream::trunc);
871  if ((m_subDisplayFile) && (this->displayVerbosity() > 10)) { // output debug
872  *this->subDisplayFile() << "In BaseEnvironment::openUnifiedOutputFile()"
873  << ": just opened output file with base name '" << baseFileName << "." << fileType
874  << "'"
875  << ", writeOver = " << writeOver
876  << ", options 'out|trunc'"
877  << ", osfvar = " << filePtrSet.ofsVar
878  << std::endl;
879  }
880  }
881  }
882  if (filePtrSet.ofsVar == NULL) {
883  std::cerr << "In BaseEnvironment::openUnifiedOutputFile()"
884  << ": failed to open unified output file with base name '" << baseFileName << "." << fileType
885  << "'"
886  << std::endl;
887  }
888  queso_require_msg((filePtrSet.ofsVar && filePtrSet.ofsVar->is_open()), "failed to open output file");
889  //}
890  }
891 
892  return returnValue;
893 }
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
int CheckFilePath(const char *path)
unsigned int displayVerbosity() const
Definition: Environment.C:450
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
std::string QUESO::BaseEnvironment::platformName ( ) const

Access to the platform name.

Definition at line 496 of file Environment.C.

References m_optionsObj.

497 {
498  return m_optionsObj->m_platformName;
499 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
virtual void QUESO::BaseEnvironment::print ( std::ostream &  os) const
pure virtual
void QUESO::BaseEnvironment::resetIdentifyingString ( const std::string &  newString)

Reset private attribute m_identifyingString with the value newString.

Definition at line 508 of file Environment.C.

References m_optionsObj.

509 {
510  m_optionsObj->m_identifyingString = newString;
511  return;
512 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
void QUESO::BaseEnvironment::resetSeed ( int  newSeedOption)

Reset RNG seed.

Definition at line 483 of file Environment.C.

References m_rngObject.

484 {
485  m_rngObject->resetSeed(newSeedOption);
486  return;
487 }
ScopedPtr< RngBase >::Type m_rngObject
Definition: Environment.h:470
void QUESO::BaseEnvironment::scanInputFileForMyOptions ( const boost::program_options::options_description &  optionsDesc) const

This method scans the input file provided by the user to QUESO.

It checks if no input file is passed and updates the private attribute m_allOptionsDesc, which keeps all the options.

Definition at line 397 of file Environment.C.

References m_allOptionsDesc, m_allOptionsMap, m_optionsInputFileName, and QUESO::queso_require_not_equal_to_msg.

Referenced by QUESO::StatisticalInverseProblemOptions::scanOptionsValues(), QUESO::EnvironmentOptions::scanOptionsValues(), and QUESO::MetropolisHastingsSGOptions::scanOptionsValues().

398 {
399  queso_deprecated();
400 
401 #ifdef UQ_USES_COMMAND_LINE_OPTIONS
402  // If you want to use command line options, the following line does *not* work outside 'main.C',
403  // e.g., in the constructor of FullEnvironment:
404  // Line: boost::program_options::store(boost::program_options::parse_command_line(argc, argv, *m_allOptionsDesc), *m_allOptionsMap);
405  //
406  // Instead, put the following three lines *immediately after* instantianting the UQ environment
407  // variable "FullEnvironment* env":
408  // Line 1: boost::program_options::store(boost::program_options::parse_command_line(argc, argv, env->allOptionsDesc()), env->allOptionsMap());
409  // Line 2: boost::program_options::notify(env->allOptionsMap());
410  // Line 3: env->getMyOptionValues();
411 #endif
412 
413 #ifdef QUESO_MEMORY_DEBUGGING
414  std::cout << "Entering BaseEnv::scanInputFileForMyOptions()" << std::endl;
415 #endif
416 
417  queso_require_msg(m_allOptionsDesc, "m_allOptionsDesc variable is NULL");
418  m_allOptionsDesc->add(optionsDesc);
419  //if (m_subDisplayFile) {
420  // *m_subDisplayFile << *m_allOptionsDesc
421  // << std::endl;
422  //}
423 
425  std::string("m_optionsInputFileName is 'nothing'"));
426  //std::ifstream ifs(m_optionsInputFileName.c_str());
427  std::ifstream* ifs = new std::ifstream(m_optionsInputFileName.c_str());
428 #ifdef QUESO_MEMORY_DEBUGGING
429  std::cout << "in BaseEnv::scanInputFileForMyOptions(), before store(a)" << std::endl;
430 #endif
431 
432  queso_require_msg(m_allOptionsMap, "m_allOptionsMap variable is NULL");
433  boost::program_options::store(boost::program_options::parse_config_file(*ifs, *m_allOptionsDesc, true), *m_allOptionsMap);
434 #ifdef QUESO_MEMORY_DEBUGGING
435  std::cout << "in BaseEnv::scanInputFileForMyOptions(), after store(a)" << std::endl;
436 #endif
437  boost::program_options::notify(*m_allOptionsMap);
438 
439  //ifs.close();
440  delete ifs;
441 #ifdef QUESO_MEMORY_DEBUGGING
442  std::cout << "Leaving BaseEnv::scanInputFileForMyOptions()" << std::endl;
443 #endif
444 
445  return;
446 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
ScopedPtr< boost::program_options::variables_map >::Type m_allOptionsMap
Definition: Environment.h:451
ScopedPtr< boost::program_options::options_description >::Type m_allOptionsDesc
Definition: Environment.h:450
std::string m_optionsInputFileName
Definition: Environment.h:447
int QUESO::BaseEnvironment::seed ( ) const

Access to the RNG seed.

Definition at line 477 of file Environment.C.

References m_rngObject.

478 {
479  return m_rngObject->seed();
480 }
ScopedPtr< RngBase >::Type m_rngObject
Definition: Environment.h:470
const MpiComm & QUESO::BaseEnvironment::selfComm ( ) const

Access function for MpiComm self-communicator.

This communicator is exactly MPI_COMM_SELF.

Definition at line 300 of file Environment.C.

References m_selfComm.

301 {
302  queso_require_msg(m_selfComm, "m_selfComm variable is NULL");
303  return *m_selfComm;
304 }
ScopedPtr< MpiComm >::Type m_selfComm
Definition: Environment.h:462
void QUESO::BaseEnvironment::setExceptionalCircumstance ( bool  value) const

Set an exceptional circumstance.

Definition at line 1136 of file Environment.C.

References m_exceptionalCircumstance.

1137 {
1138  m_exceptionalCircumstance = value;
1139  return;
1140 }
void QUESO::BaseEnvironment::setOptionsInputFileAccessState ( bool  newState) const

Definition at line 365 of file Environment.C.

References m_optionsInputFileAccessState.

366 {
368 
369  return;
370 }
const MpiComm & QUESO::BaseEnvironment::subComm ( ) const

Access function for each sub-environment's communicator.

Let's say QUESO was passed a fullComm() communicator of size N. The ranks of each process in this communicator are:

0 1 2 ... N-2 N-1

If the user asks for M sub-environments (chains) then, assuming M divides N, QUESO partitions the processes in the fullComm() communicator into M sub-communicators like so:

Sub-environment 0 contains processes with fullRank() 0 1 ... M-1

Sub-environment 1 contains processes with fullRank() M M+1 ... 2M-1

et cetera

Sub-environment M-1 contains processes with fullRank() N-M N-M+1 ... N-1

subComm() returns the sub-communicator corresponding to the sub-environment the calling MPI process belongs to. For example, if I am an MPI process calling this function and I live in sub-environment k, then this method returns the sub-communicator for sub-environment k.

Definition at line 293 of file Environment.C.

References m_subComm.

Referenced by QUESO::VectorFunctionSynchronizer< P_V, P_M, Q_V, Q_M >::callFunction(), and QUESO::MiscCheckTheParallelEnvironment().

294 {
295  queso_require_msg(m_subComm, "m_subComm variable is NULL");
296  return *m_subComm;
297 }
ScopedPtr< MpiComm >::Type m_subComm
Definition: Environment.h:458
std::ofstream * QUESO::BaseEnvironment::subDisplayFile ( ) const

Access function for m_subDisplayFile (displays file on stream).

Definition at line 320 of file Environment.C.

References m_subDisplayFile.

Referenced by QUESO::AsciiTable< V, M >::AsciiTable(), QUESO::BaseJointPdf< V, M >::BaseJointPdf(), QUESO::BaseMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::BaseMatrixCovarianceFunction(), QUESO::BaseOneDGrid< T >::BaseOneDGrid(), QUESO::BaseScalarCdf< T >::BaseScalarCdf(), QUESO::BaseScalarCovarianceFunction< V, M >::BaseScalarCovarianceFunction(), QUESO::BaseVectorCdf< V, M >::BaseVectorCdf(), QUESO::BaseVectorMdf< V, M >::BaseVectorMdf(), QUESO::BaseVectorRealizer< V, M >::BaseVectorRealizer(), QUESO::BaseVectorRV< V, M >::BaseVectorRV(), QUESO::BetaJointPdf< V, M >::BetaJointPdf(), QUESO::BetaVectorRealizer< V, M >::BetaVectorRealizer(), QUESO::BetaVectorRV< V, M >::BetaVectorRV(), QUESO::BIP_routine(), QUESO::MLSamplingOptions::checkOptions(), QUESO::GPMSAOptions::checkOptions(), QUESO::MLSamplingLevelOptions::checkOptions(), closeFile(), QUESO::ComputeConditionalGaussianVectorRV(), QUESO::ConcatenatedVectorRealizer< V, M >::ConcatenatedVectorRealizer(), QUESO::ConcatenatedVectorRV< V, M >::ConcatenatedVectorRV(), QUESO::GslVector::cwSetBeta(), QUESO::TeuchosVector::cwSetBeta(), QUESO::TeuchosMatrix::determinant(), QUESO::GslMatrix::determinant(), QUESO::EnvironmentOptions::EnvironmentOptions(), QUESO::ExponentialMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::ExponentialMatrixCovarianceFunction(), QUESO::ExponentialScalarCovarianceFunction< V, M >::ExponentialScalarCovarianceFunction(), QUESO::FiniteDistribution::FiniteDistribution(), QUESO::GammaJointPdf< V, M >::GammaJointPdf(), QUESO::GammaVectorRealizer< V, M >::GammaVectorRealizer(), QUESO::GammaVectorRV< V, M >::GammaVectorRV(), QUESO::GaussianJointPdf< V, M >::GaussianJointPdf(), QUESO::GaussianVectorCdf< V, M >::GaussianVectorCdf(), QUESO::GaussianVectorMdf< V, M >::GaussianVectorMdf(), QUESO::GaussianVectorRealizer< V, M >::GaussianVectorRealizer(), QUESO::GaussianVectorRV< V, M >::GaussianVectorRV(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step09_all(), QUESO::GenericMatrixCovarianceFunction< P_V, P_M, Q_V, Q_M >::GenericMatrixCovarianceFunction(), QUESO::GenericScalarCovarianceFunction< V, M >::GenericScalarCovarianceFunction(), QUESO::GenericVectorRealizer< V, M >::GenericVectorRealizer(), QUESO::GenericVectorRV< V, M >::GenericVectorRV(), QUESO::StatisticalInverseProblemOptions::getMyOptionValues(), QUESO::MetropolisHastingsSGOptions::getMyOptionValues(), QUESO::HessianCovMatricesTKGroup< V, M >::HessianCovMatricesTKGroup(), QUESO::horizontalDistance(), QUESO::if(), QUESO::InfiniteDimensionalMCMCSampler::InfiniteDimensionalMCMCSampler(), QUESO::MonteCarloSG< P_V, P_M, Q_V, Q_M >::internGenerateSequence(), QUESO::TeuchosMatrix::inverse(), QUESO::GslMatrix::inverse(), QUESO::InverseGammaJointPdf< V, M >::InverseGammaJointPdf(), QUESO::InverseGammaVectorRealizer< V, M >::InverseGammaVectorRealizer(), QUESO::InverseGammaVectorRV< V, M >::InverseGammaVectorRV(), QUESO::TeuchosMatrix::invertMultiply(), QUESO::GslMatrix::invertMultiply(), QUESO::InvLogitGaussianVectorRV< V, M >::InvLogitGaussianVectorRV(), QUESO::JeffreysJointPdf< V, M >::JeffreysJointPdf(), QUESO::JeffreysVectorRealizer< V, M >::JeffreysVectorRealizer(), QUESO::JeffreysVectorRV< V, M >::JeffreysVectorRV(), QUESO::TeuchosMatrix::lnDeterminant(), QUESO::GslMatrix::lnDeterminant(), QUESO::LogNormalJointPdf< V, M >::LogNormalJointPdf(), QUESO::LogNormalVectorRealizer< V, M >::LogNormalVectorRealizer(), QUESO::LogNormalVectorRV< V, M >::LogNormalVectorRV(), QUESO::MetropolisAdjustedLangevinTK< V, M >::MetropolisAdjustedLangevinTK(), QUESO::MetropolisHastingsSG< P_V, P_M >::MetropolisHastingsSG(), QUESO::MetropolisHastingsSGOptions::MetropolisHastingsSGOptions(), QUESO::MLSampling< P_V, P_M >::MLSampling(), QUESO::ModelValidation< P_V, P_M, Q_V, Q_M >::ModelValidation(), QUESO::MonteCarloSG< P_V, P_M, Q_V, Q_M >::MonteCarloSG(), openInputFile(), openOutputFile(), openUnifiedInputFile(), openUnifiedOutputFile(), QUESO::PoweredJointPdf< V, M >::PoweredJointPdf(), QUESO::TeuchosMatrix::rank(), QUESO::GslMatrix::rank(), QUESO::SampledScalarCdf< T >::SampledScalarCdf(), QUESO::SampledVectorCdf< V, M >::SampledVectorCdf(), QUESO::SampledVectorMdf< V, M >::SampledVectorMdf(), QUESO::ScaledCovMatrixTKGroup< V, M >::ScaledCovMatrixTKGroup(), QUESO::StatisticalInverseProblemOptions::scanOptionsValues(), QUESO::MetropolisHastingsSGOptions::scanOptionsValues(), QUESO::SequentialVectorRealizer< V, M >::SequentialVectorRealizer(), QUESO::StatisticalForwardProblem< P_V, P_M, Q_V, Q_M >::StatisticalForwardProblem(), QUESO::StatisticalInverseProblem< P_V, P_M >::StatisticalInverseProblem(), QUESO::StatisticalInverseProblemOptions::StatisticalInverseProblemOptions(), QUESO::StdOneDGrid< T >::StdOneDGrid(), QUESO::StdScalarCdf< T >::StdScalarCdf(), QUESO::GslVector::subReadContents(), QUESO::TeuchosVector::subReadContents(), QUESO::TeuchosMatrix::subReadContents(), QUESO::GslMatrix::subReadContents(), QUESO::TeuchosMatrix::svdSolve(), QUESO::GslMatrix::svdSolve(), QUESO::TransformedScaledCovMatrixTKGroup< V, M >::TransformedScaledCovMatrixTKGroup(), QUESO::UniformJointPdf< V, M >::UniformJointPdf(), QUESO::UniformOneDGrid< T >::UniformOneDGrid(), QUESO::UniformVectorRealizer< V, M >::UniformVectorRealizer(), QUESO::UniformVectorRV< V, M >::UniformVectorRV(), QUESO::ValidationCycle< P_V, P_M, Q_V, Q_M >::ValidationCycle(), QUESO::VectorSet< V, M >::VectorSet(), QUESO::VectorSpace< V, M >::VectorSpace(), QUESO::VectorSubset< V, M >::VectorSubset(), QUESO::WignerJointPdf< V, M >::WignerJointPdf(), QUESO::WignerVectorRealizer< V, M >::WignerVectorRealizer(), and QUESO::WignerVectorRV< V, M >::WignerVectorRV().

321 {
322  // Potentially dangerous? The user might delete it...
323  return m_subDisplayFile.get();
324 }
ScopedPtr< std::ofstream >::Type m_subDisplayFile
Definition: Environment.h:469
std::string QUESO::BaseEnvironment::subDisplayFileName ( ) const

Access function for m_subDisplayFileName (displays filename on stream).

Definition at line 327 of file Environment.C.

References m_optionsObj.

328 {
329  if (m_optionsObj == NULL) return ".";
330 
331  return m_optionsObj->m_subDisplayFileName;
332 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
RawType_MPI_Group QUESO::BaseEnvironment::subGroup ( ) const

Access function for sub-group.

Definition at line 281 of file Environment.C.

References m_subGroup.

282 {
283  return m_subGroup;
284 }
RawType_MPI_Group m_subGroup
Definition: Environment.h:457
unsigned int QUESO::BaseEnvironment::subId ( ) const

Access function to the number of each sub-environment Id: m_subId.

Definition at line 342 of file Environment.C.

References m_subId.

Referenced by QUESO::MLSamplingLevelOptions::checkOptions(), QUESO::MhOptionsValues::checkOptions(), QUESO::MetropolisHastingsSGOptions::getMyOptionValues(), openOutputFile(), and QUESO::MpiComm::syncPrintDebugMsg().

343 {
344  return m_subId;
345 }
unsigned int m_subId
Definition: Environment.h:455
const std::string & QUESO::BaseEnvironment::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 at line 348 of file Environment.C.

References m_subIdString.

Referenced by openOutputFile(), QUESO::Sampled1D1DFunction::printForMatlab(), QUESO::GslVector::subWriteContents(), QUESO::TeuchosVector::subWriteContents(), QUESO::TeuchosMatrix::subWriteContents(), and QUESO::GslMatrix::subWriteContents().

349 {
350  return m_subIdString;
351 }
std::string m_subIdString
Definition: Environment.h:456
int QUESO::BaseEnvironment::subRank ( ) const

Returns the rank of the MPI process in the sub-communicator subComm()

Example, if the calling MPI process has fullRank() equal to 3, the size of fullComm() is 6, and the user asked for two sub-environments, then this method will return 0. Here's why.

fullComm() has MPI processes with these ranks: 0 1 2 3 4 5

QUESO divides the first three (ranks 0, 1, 2) of these into a sub-communicator for sub-environment 0. Inside the sub-communicator their ranks are 0, 1, 2, respectively.

QUESO divides the second three (ranks 3, 4, 5) of these into a sub-communicator for sub-environment 1. Inside the sub-communicator their ranks are 0, 1, 2, respectively.

It should be clear, now, that if fullRank() is 3 then subRank() is 0.

Definition at line 287 of file Environment.C.

References m_subRank.

Referenced by closeFile(), QUESO::MetropolisHastingsSGOptions::getMyOptionValues(), QUESO::MiscCheckTheParallelEnvironment(), openInputFile(), openOutputFile(), openUnifiedInputFile(), openUnifiedOutputFile(), QUESO::GslVector::subReadContents(), QUESO::TeuchosVector::subReadContents(), QUESO::TeuchosMatrix::subReadContents(), QUESO::GslMatrix::subReadContents(), QUESO::GslVector::subWriteContents(), QUESO::TeuchosVector::subWriteContents(), QUESO::TeuchosMatrix::subWriteContents(), QUESO::GslMatrix::subWriteContents(), and QUESO::MpiComm::syncPrintDebugMsg().

288 {
289  return m_subRank;
290 }
unsigned int QUESO::BaseEnvironment::syncVerbosity ( ) const

Access function to private attribute m_syncVerbosity.

Definition at line 457 of file Environment.C.

References m_optionsObj.

Referenced by QUESO::MpiComm::syncPrintDebugMsg().

458 {
459  queso_require_msg(m_optionsObj, "m_optionsObj variable is NULL");
460  return m_optionsObj->m_syncVerbosity;
461 }
ScopedPtr< EnvOptionsValues >::Type m_optionsObj
Definition: Environment.h:475
struct timeval QUESO::BaseEnvironment::timevalBegin ( ) const

Used to save the time when the combo `QUESO+user's application' started to run.

Definition at line 515 of file Environment.C.

516 {
517  return m_timevalBegin;
518 }
struct timeval m_timevalBegin
Definition: Environment.h:472
int QUESO::BaseEnvironment::worldRank ( ) const

Returns the same thing as fullRank()

This is the same thing as fullRank(), since QUESO's 'world' communicator is not MPI_COMM_WORLD, but the communicator that user passed to it when creating the environment.

Definition at line 262 of file Environment.C.

References m_worldRank.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::alpha(), QUESO::TeuchosMatrix::chol(), QUESO::GslMatrix::chol(), QUESO::ComputeCovCorrMatricesBetweenVectorSequences(), QUESO::MetropolisHastingsSGOptions::getMyOptionValues(), QUESO::GslMatrix::internalSvd(), and QUESO::ScalarSequence< T >::subInterQuantileRange().

263 {
264  return m_worldRank;
265 }

Member Data Documentation

ScopedPtr<boost::program_options::options_description>::Type QUESO::BaseEnvironment::m_allOptionsDesc
protected
ScopedPtr<boost::program_options::variables_map>::Type QUESO::BaseEnvironment::m_allOptionsMap
protected
ScopedPtr<BasicPdfsBase>::Type QUESO::BaseEnvironment::m_basicPdfs
protected

Definition at line 471 of file Environment.h.

Referenced by basicPdfs(), and QUESO::FullEnvironment::construct().

bool QUESO::BaseEnvironment::m_exceptionalCircumstance
mutableprotected

Definition at line 473 of file Environment.h.

Referenced by exceptionalCircumstance(), and setExceptionalCircumstance().

ScopedPtr<MpiComm>::Type QUESO::BaseEnvironment::m_fullComm
protected

Definition at line 442 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and fullComm().

int QUESO::BaseEnvironment::m_fullCommSize
protected

Definition at line 444 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct().

bool QUESO::BaseEnvironment::m_fullEnvIsReady
protected

Definition at line 439 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and fullEnvIsReady().

RawType_MPI_Group QUESO::BaseEnvironment::m_fullGroup
protected

Definition at line 445 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct().

int QUESO::BaseEnvironment::m_fullRank
protected
ScopedPtr<GetPot>::Type QUESO::BaseEnvironment::m_input
protected

Definition at line 453 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and input().

ScopedPtr<MpiComm>::Type QUESO::BaseEnvironment::m_inter0Comm
protected

Definition at line 465 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and inter0Comm().

int QUESO::BaseEnvironment::m_inter0CommSize
protected

Definition at line 467 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct().

RawType_MPI_Group QUESO::BaseEnvironment::m_inter0Group
protected

Definition at line 464 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct().

int QUESO::BaseEnvironment::m_inter0Rank
protected

Definition at line 466 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and inter0Rank().

bool QUESO::BaseEnvironment::m_optionsInputFileAccessState
mutableprotected

Definition at line 448 of file Environment.h.

Referenced by optionsInputFileName(), and setOptionsInputFileAccessState().

std::string QUESO::BaseEnvironment::m_optionsInputFileName
protected
ScopedPtr<RngBase>::Type QUESO::BaseEnvironment::m_rngObject
protected

Definition at line 470 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), resetSeed(), rngObject(), and seed().

ScopedPtr<MpiComm>::Type QUESO::BaseEnvironment::m_selfComm
protected

Definition at line 462 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and selfComm().

ScopedPtr<MpiComm>::Type QUESO::BaseEnvironment::m_subComm
protected

Definition at line 458 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and subComm().

int QUESO::BaseEnvironment::m_subCommSize
protected

Definition at line 460 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct().

ScopedPtr<std::ofstream>::Type QUESO::BaseEnvironment::m_subDisplayFile
mutableprotected
RawType_MPI_Group QUESO::BaseEnvironment::m_subGroup
protected

Definition at line 457 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and subGroup().

unsigned int QUESO::BaseEnvironment::m_subId
protected

Definition at line 455 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and subId().

std::string QUESO::BaseEnvironment::m_subIdString
protected

Definition at line 456 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and subIdString().

int QUESO::BaseEnvironment::m_subRank
protected

Definition at line 459 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and subRank().

struct timeval QUESO::BaseEnvironment::m_timevalBegin
protected

Definition at line 472 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and ~BaseEnvironment().

int QUESO::BaseEnvironment::m_worldRank
protected

Definition at line 440 of file Environment.h.

Referenced by QUESO::FullEnvironment::construct(), and worldRank().


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:05 for queso-0.57.1 by  doxygen 1.8.5