当前位置: 首页>>代码示例>>C++>>正文


C++ ProgramOptions::parse_command_line方法代码示例

本文整理汇总了C++中ProgramOptions::parse_command_line方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramOptions::parse_command_line方法的具体用法?C++ ProgramOptions::parse_command_line怎么用?C++ ProgramOptions::parse_command_line使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgramOptions的用法示例。


在下文中一共展示了ProgramOptions::parse_command_line方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CaledoniaDriver

void CaledoniaDriver(ProgramOptions& options, int& argc, char* argv[])
{
   //  Get basic MPI information
   MPI_Struct world;
   world = MPI_Struct::world();
#  ifdef USE_MPI
   MPI_Comm_rank(world.comm,&world.iproc);
   MPI_Comm_size(world.comm,&world.nproc);
#  endif
 
   bool verbose = options.get_value<bool>("verbose") && (world.iproc==0);
   if(verbose) std::cout << __FILE__ << ":" << __LINE__ << " Construction objects" << std::endl;

   // Construct a hamiltonian object 
   HAMILTON hamilton;
   hamilton.add_options(options);

   // Construct the sampling object
   SIMULATION simulation;
   simulation.add_options(options);

   typedef WALKER<typename HAMILTON::Config,typename HAMILTON::Observables> Walker;
   std::vector<Walker> walkerpool(1);

   // The measurement object
   // EMX_Measure measure_obj;
   MEASURE measure_obj;

   // Get parameters
   if(verbose) std::cout << __FILE__ << ":" << __LINE__ << " Parsing parameters" << std::endl;
   options.parse_command_line(argc,argv);
   if( options.get_value<bool>("help") ) return;

   // seed the random number geneator
   if(verbose) std::cout << __FILE__ << ":" << __LINE__ << " Creating random number generator" << std::endl;
   simulation.urng.seed( ParallelSeed(SeedFromClock()) );
   bool rng_output = false;
   bool rng_failed = RNGTestMoments(simulation.urng,rng_output,std::cout);
   if( false && rng_failed )
      std::cout << __FILE__ << ":" << __LINE__ << "Problem detected with random number generator (returns 1?)" << std::endl;

   // Initialize objects based on ProgramOptions
   if(verbose) std::cout << __FILE__ << ":" << __LINE__ << " Call Init routines" << std::endl;
   hamilton.init(verbose);
   hamilton.initial(walkerpool[0].sigma);
   simulation.init(hamilton,walkerpool,verbose);
   measure_obj.init(simulation);

   // Construct a representation of the model
   // This includes the "microscopic" configuration sigma_i
   // and the macroscopic quantities like magnetization and energy
   if(verbose) std::cout << __FILE__ << ":" << __LINE__ << " Beginning simulation" << std::endl;
   simulation.DoCalculate(hamilton,walkerpool,measure_obj);

   if(verbose) std::cout << __FILE__ << ":" << __LINE__ << " Saving options" << std::endl;
   options.write();
}
开发者ID:browngrg,项目名称:caledonia,代码行数:57,代码来源:caledonia.cpp


注:本文中的ProgramOptions::parse_command_line方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。