1 #include "RBGen_Params.h"
2 #include "RBGen_ConfigDefs.h"
7 #include "Teuchos_Assert.hpp"
8 #include "Teuchos_Ptr.hpp"
172 TEUCHOS_TEST_FOR_EXCEPTION(!fileio_params.isSublist(
"Data Filename Format" ), std::invalid_argument,
"Data Filename Format sublist does not exist!");
178 std::string prepend =
"";
179 if ( fileformat_params.isParameter(
"Prepend" ) ) {
180 prepend = Teuchos::getParameter<std::string>( fileformat_params,
"Prepend" );
184 std::string postpend =
"";
185 if ( fileformat_params.isParameter(
"Postpend" ) ) {
186 postpend = Teuchos::getParameter<std::string>( fileformat_params,
"Postpend" );
190 std::string extension =
"";
191 if ( fileformat_params.isParameter(
"Extension" ) ) {
192 extension = Teuchos::getParameter<std::string>( fileformat_params,
"Extension" );
197 if ( fileformat_params.isParameter(
"File Number Base" ) ) {
198 base_num = Teuchos::getParameter<int>( fileformat_params,
"File Number Base" );
201 std::string format_type = Teuchos::getParameter<std::string>( fileformat_params,
"Type" );
203 if ( format_type ==
"Single file" ) {
206 filenames->push_back( Teuchos::getParameter<std::string>( fileformat_params,
"Data File" ) );
210 if ( format_type ==
"Fixed length numeric" ) {
213 int num_files = Teuchos::getParameter<int>( fileformat_params,
"Number of Files" );
214 int max_num = base_num + num_files;
215 int num_places = (int)::ceil( ::log10( (
double)(max_num) ) );
217 for (
int i=base_num; i<max_num; i++) {
220 std::string curr_filename = prepend;
223 int curr_places = (int)::ceil( ::log10( (
double)(i+1) ) );
226 for (
int j=curr_places; j<num_places; j++) {
227 curr_filename +=
"0";
236 if ( format_type ==
"Variable length numeric" ) {
239 int num_files = Teuchos::getParameter<int>( fileformat_params,
"Number of Files" );
240 int max_num = base_num + num_files;
242 for (
int i=base_num; i<max_num; i++) {
248 std::string err_str =
"File format type, 'Type = " + format_type +
"', is not recognized!";
Teuchos::RCP< Teuchos::ParameterList > createParams(const std::string &filename)
Create a Teuchos::ParameterList from an XML file.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static std::string toString(const double &x)
Teuchos::RCP< std::vector< std::string > > genFileList(const Teuchos::ParameterList ¶ms)
Extract the filename list from a Teuchos::ParameterList.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool isSublist(const std::string &name) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")