43 #include "Teuchos_YamlParameterListHelpers.hpp" 45 #include "Teuchos_CommHelpers.hpp" 47 void Teuchos::updateParametersFromYamlFileAndBroadcast(
48 const std::string &yamlFileName,
55 SafeFile(
const char* fname,
const char* options)
57 handle = fopen(fname, options);
78 SafeFile yamlFile(yamlFileName.c_str(),
"rb");
81 throw std::runtime_error(std::string(
"Failed to open YAML file \"") + yamlFileName +
"\"for reading.");
83 fseek(yamlFile.handle, 0, SEEK_END);
84 int strsize = ftell(yamlFile.handle) + 1;
85 rewind(yamlFile.handle);
88 fread((
void*) contents.get(), strsize - 1, 1, yamlFile.handle);
89 contents.get()[strsize - 1] = 0;
90 Teuchos::broadcast<int, int>(comm, 0, &strsize);
91 Teuchos::broadcast<int, char>(comm, 0, strsize, contents.get());
92 updateParametersFromYamlCString(contents.get(), paramList, overwrite);
97 Teuchos::broadcast<int, int>(comm, 0, &strsize);
99 Teuchos::broadcast<int, char>(comm, 0, strsize, contents.get());
100 updateParametersFromYamlCString(contents.get(), paramList, overwrite);
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void updateParametersFromYamlFile(const std::string &yamlFileName, const Ptr< ParameterList > ¶mList)
Reads Yaml parameters from a file and updates those already in the given parameter list...
virtual int getRank() const =0
Returns the rank of this process.
Abstract interface for distributed-memory communication.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
virtual int getSize() const =0
Returns the number of processes that make up this communicator.
Reference-counted smart pointer for managing arrays.