本文整理汇总了C++中AnyOption类的典型用法代码示例。如果您正苦于以下问题:C++ AnyOption类的具体用法?C++ AnyOption怎么用?C++ AnyOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AnyOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateOptions
static int ValidateOptions(AnyOption& options, String& file)
{
for( int i = 0; i < options.getArgc(); ++i )
{
file = options.getArgv(i);
break;
}
// If no file was passed then we have nothing to do.
if( file.empty() )
{
options.printAutoUsage();
return EXIT_FAILURE;
}
// Check that the file is a DLL.
String extension = PathGetFileExtension(file);
if( StringCompareInsensitive(extension, "dll") != 0 )
{
LogError("The file is not a DLL");
return EXIT_FAILURE;
}
// Check if the file exists.
if( !FileExists(file) )
{
LogError("The file could not be found");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例2: main
int main(int argc, char** argv)
{
int ret = EXIT_SUCCESS;
// Setup default error handling strategy.
// ...
// Setup the default log stream.
Log logger;
LogSetDefault(&logger);
// Setup the command line handling.
AnyOption options;
// Use this to active debug mode.
options.setFlag("debug", 'd');
options.setVerbose();
options.autoUsagePrint(true);
// Process the command line arguments.
options.processCommandArgs(argc, argv);
String file;
ret = ValidateOptions(options, file);
if( ret != EXIT_SUCCESS )
{
options.printUsage();
return ret;
}
Runtime runtime;
runtime.init();
runtime.shutdown();
return ret;
}
示例3: parse
void UpdaterOptions::parse(int argc, char** argv)
{
AnyOption parser;
parser.setOption("install-dir");
parser.setOption("package-dir");
parser.setOption("script");
parser.setOption("wait");
parser.setOption("mode");
parser.setFlag("version");
parser.setFlag("force-elevated");
parser.setFlag("auto-close");
parser.processCommandArgs(argc,argv);
if (parser.getValue("mode"))
{
mode = stringToMode(parser.getValue("mode"));
}
if (parser.getValue("install-dir"))
{
installDir = parser.getValue("install-dir");
}
if (parser.getValue("package-dir"))
{
packageDir = parser.getValue("package-dir");
}
if (parser.getValue("script"))
{
scriptPath = parser.getValue("script");
}
if (parser.getValue("wait"))
{
waitPid = static_cast<PLATFORM_PID>(atoll(parser.getValue("wait")));
}
showVersion = parser.getFlag("version");
forceElevated = parser.getFlag("force-elevated");
autoClose = parser.getFlag("auto-close");
if (installDir.empty())
{
// if no --install-dir argument is present, try parsing
// the command-line arguments in the old format (which uses
// a list of 'Key=Value' args)
parseOldFormatArgs(argc,argv);
}
}
示例4: main
int main( int argc, char **argv ) {
AnyOption *opt = parseInputOptions( argc, argv );
// Declare and populate variables
// First, file type
enum AtmosphericFileType { ATMOSFILE, JETFILE, SLICEFILE }; // Expand this enum as we put in more file types
AtmosphericFileType filetype;
int numTypesDeclared = 0;
string atmosfile = "";
if ( opt->getValue( "jetfile" ) != NULL ) {
atmosfile = opt->getValue( "jetfile" );
filetype = JETFILE;
numTypesDeclared++;
}
if ( opt->getValue( "atmosfile" ) != NULL ) {
atmosfile = opt->getValue( "atmosfile" );
filetype = ATMOSFILE;
numTypesDeclared++;
}
if (opt->getValue( "slicefile" ) != NULL ) {
atmosfile = opt->getValue( "slicefile" );
filetype = SLICEFILE;
numTypesDeclared++;
}
// Make sure only one file type was requested
if (numTypesDeclared != 1) {
delete opt;
throw invalid_argument( "Atmospheric file must be specified!");
}
// Parse arguments based on file type selected and set defaults
double elev0 = 0, maxelev = 0, delev = 1, azimuth0 = -1, maxazimuth = -1, dazimuth = 1,
maxraylength = 0, stepsize = 0.01, maxrange = 1e12, sourceheight = -1, maxheight = 150;
//double lat = 0, lon = 0;
unsigned int maxskips = 0;
bool inMPS = true;
// Elevation angle parameters
if (opt->getValue( "elev" ) != NULL) {
elev0 = atof( opt->getValue("elev") );
} else {
delete opt;
throw invalid_argument( "Option --elev is required!" );
}
if (fabs(elev0) >= 90.0) {
delete opt;
throw invalid_argument( "Option --elev must be in the range (-90,90)!" );
}
maxelev = elev0;
if (opt->getValue( "maxelev" ) != NULL) {
maxelev = atof( opt->getValue( "maxelev" ) );
}
if (opt->getValue( "delev" ) != NULL) {
delev = atof( opt->getValue( "delev" ) );
}
// Convert elevation angles to radians
elev0 = deg2rad( elev0 );
delev = deg2rad( delev );
maxelev = deg2rad( maxelev );
// Azimuth angle parameters. We'll keep azimuths in degrees cause that's what they are,
// and convert when necessary
if (filetype != SLICEFILE) {
if (opt->getValue( "azimuth" ) != NULL) {
azimuth0 = atof( opt->getValue("azimuth") );
} else {
delete opt;
throw invalid_argument( "Option --azimuth is required!" );
}
while (azimuth0 >= 360.0) {
azimuth0 -= 360.0;
}
while (azimuth0 < 0.0) {
azimuth0 += 360.0;
}
maxazimuth = azimuth0;
if (opt->getValue( "maxazimuth" ) != NULL) {
maxazimuth = atof( opt->getValue( "maxazimuth" ) );
}
if (opt->getValue( "dazimuth" ) != NULL) {
dazimuth = atof( opt->getValue( "dazimuth" ) );
}
while (maxazimuth >= 360.0) {
maxazimuth -= 360.0;
}
while (maxazimuth < 0.0) {
maxazimuth += 360.0;
}
}
// Calculation parameters
maxraylength = -1.0;
if (opt->getValue( "maxraylength" ) != NULL) {
maxraylength = atof( opt->getValue( "maxraylength" ) );
} else {
delete opt;
//.........这里部分代码省略.........
示例5: simple
void
simple( int argc, char* argv[] )
{
AnyOption *opt = new AnyOption();
opt->noPOSIX(); /* use simpler option type */
opt->setOption( "width" );
opt->setOption( "height" );
opt->setFlag( "convert");
opt->setCommandOption( "name" );
opt->setFileOption( "title" );
if ( ! opt->processFile( "sample.txt" ) )
cout << "Failed processing the resource file" << endl ;
opt->processCommandArgs( argc, argv );
cout << "THE OPTIONS : " << endl << endl ;
if( opt->getValue( "width" ) != NULL )
cout << "width : " << opt->getValue( "width" ) << endl ;
if( opt->getValue( "height" ) != NULL )
cout << "height : " << opt->getValue( "height" ) << endl ;
if( opt->getValue( "name" ) != NULL )
cout << "name : " << opt->getValue( "name" ) << endl ;
if( opt->getValue( "title" ) != NULL )
cout << "title : " << opt->getValue( "title" ) << endl ;
if( opt->getFlag( "convert" ) )
cout << "convert : set " << endl ;
cout << endl ;
cout << "THE ARGUMENTS : " << endl << endl ;
for( int i = 0 ; i < opt->getArgc() ; i++ ){
cout << opt->getArgv( i ) << endl ;
}
cout << endl;
delete opt;
}
示例6: main
int main(int argc, char** argv)
{
QApplication app(argc, argv);
AnyOption options;
options.addUsage(QString("Usage: %1 --help | --console | [--output path --prefix prefixName --suffix suffixName --type typeName").arg(argv[0]).toAscii());
options.addUsage("");
options.addUsage("--help Displays this message.");
options.addUsage("--console Run the gui version.");
options.addUsage("--output [path] Output directory for the plugin skeleton.");
options.addUsage("--prefix [prefixName] Prefix to use for the plugin.");
options.addUsage("--suffix [suffixName] Suffix to use for the plugin.");
options.addUsage("--type [typeName] Type to use for the plugin.");
options.addUsage("--quiet Process quietly (non gui generation only).");
options.setFlag("help");
options.setFlag("console");
options.setOption("output");
options.setOption("prefix");
options.setOption("suffix");
options.setOption("type");
options.setOption("quiet");
options.processCommandArgs(argc, argv);
if(options.getFlag("help")) {
options.printUsage();
return 0;
}
if(options.getFlag("console")) {
bool paramsOk = options.getValue("output") && options.getValue("prefix") && options.getValue("type") && options.getValue("suffix");
if( !paramsOk ) {
options.printUsage();
return 1;
}
if(!options.getFlag("quiet")) {
qDebug() << "output = " << options.getValue("output");
qDebug() << "prefix = " << options.getValue("prefix");
qDebug() << "suffix = " << options.getValue("suffix");
qDebug() << "type = " << options.getValue("type");
}
dtkPluginGenerator generator;
generator.setOutputDirectory(options.getValue("output"));
generator.setPrefix(options.getValue("prefix"));
generator.setSuffix(options.getValue("suffix"));
generator.setType(options.getValue("type"));
bool resultGenerator = generator.run();
if(!options.getFlag("quiet")) {
if(resultGenerator)
qDebug() << "Generation succeeded.";
else
qDebug() << "Plugin generation: Generation failed.";
}
} else {
dtkPluginGeneratorMainWindow generator;
generator.show();
generator.raise();
return app.exec();
}
}
示例7: main
int main(int argc, char **argv)
{
AnyOption *opt = new AnyOption();
opt->addUsage("");
opt->addUsage("Usage: ");
opt->addUsage("");
opt->addUsage(" -h --help Print usage ");
opt->addUsage(" -L --subsecLet Letter of Subsector (A-P) to generate, if omitted will generate entire sector ");
opt->addUsage(" -d --detail %|zero|rift|sparse|scattered|dense ");
opt->addUsage(" -m --maturity Tech level, backwater|frontier|mature|cluster ");
opt->addUsage(" -a --ac Two-letter system alignment code ");
opt->addUsage(" -s --secName Name of sector. For default output file name and sectorName_names.txt file");
opt->addUsage(" -p --path Path to sectorName_names.txt file ");
opt->addUsage(" -o --outFormat 1|2|3|4|5|6 : v1.0, v2.0, v2.1 v2.1b, v2.2, v2.5 ");
opt->addUsage(" -u --outPath Path and name of output file ");
opt->addUsage("");
opt->setCommandFlag("main", 'm');
opt->setCommandFlag("system", 'S');
opt->setCommandFlag("sector", 's');
opt->setCommandFlag("subsector", 'u');
opt->setCommandFlag("help", 'h');
opt->setCommandOption("", 'x');
opt->setCommandOption("", 'y');
opt->setCommandOption("", 'z');
opt->setCommandOption("detail", 'd');
opt->setCommandOption("seed");
//opt->setVerbose(); /* print warnings about unknown options */
//opt->autoUsagePrint(true); /* print usage for bad options */
opt->processCommandArgs(argc, argv);
#if 0
if(! opt->hasOptions()) { /* print usage if no options */
opt->printUsage();
delete opt;
return 0;
}
#endif
if(opt->getFlag("help") || opt->getFlag('h')) {
opt->printUsage();
delete opt;
return 0;
}
//long seed = 12345;
long x = 0;
long y = 10;
long z = 0;
int detail = 3;
if(opt->getValue('x') != NULL) {
x = atol(opt->getValue('x'));
}
if(opt->getValue('y') != NULL) {
y = atol(opt->getValue('y'));
}
if(opt->getValue('z') != NULL) {
z = atol(opt->getValue('z'));
}
if(opt->getValue("seed") != NULL) {
//seed = atol(opt->getValue("seed"));
}
if(opt->getValue("detail") != NULL) {
detail = atol(opt->getValue("detail"));
}
long startX, startY, startZ;
long endX, endY, endZ;
long sectorX = 8 * 4;
long sectorY = 10 * 4;
long sectorZ = 1;
if(opt->getFlag("sector")) {
startX = x / sectorX;
endX = startX + sectorX - 1;
startY = y / sectorY;
endY = startY + sectorY - 1;
startZ = z / sectorZ;
endZ = startZ + sectorZ - 1;
} else {
startX = x;
endX = x;
startY = y;
endY = y;
startZ = z;
endZ = z;
}
for(int i = startX; i <= endX; i++) {
for(int j = startY; j <= endY; j++) {
for(int k = startZ; k <= endZ; k++) {
printSystem(x, y, z, detail);
}
}
}
}
示例8: main
//+----------------------------------------------------------------------------+
//| main() |
//-----------------------------------------------------------------------------+
int
main(int argc, char** argv)
{
common::PathFileString pfs(argv[0]);
//////////////////////////////////////////////////////////////////////////////
// User command line parser
AnyOption *opt = new AnyOption();
opt->autoUsagePrint(true);
opt->addUsage( "" );
opt->addUsage( "Usage: " );
char buff[256];
sprintf(buff, " Example: %s -r example1_noisy.cfg", pfs.getFileName().c_str());
opt->addUsage( buff );
opt->addUsage( " -h --help Prints this help" );
opt->addUsage( " -r --readfile <filename> Reads the polyhedra description file" );
opt->addUsage( " -t --gltopic <topic name> (opt) ROS Topic to send OpenGL commands " );
opt->addUsage( "" );
opt->setFlag( "help", 'h' );
opt->setOption( "readfile", 'r' );
opt->processCommandArgs( argc, argv );
if( opt->getFlag( "help" ) || opt->getFlag( 'h' ) ) {opt->printUsage(); delete opt; return(1);}
std::string gltopic("OpenGLRosComTopic");
if( opt->getValue( 't' ) != NULL || opt->getValue( "gltopic" ) != NULL ) gltopic = opt->getValue( 't' );
std::cerr << "[OpenGL communication topic is set to : \"" << gltopic << "\"]\n";
std::string readfile;
if( opt->getValue( 'r' ) != NULL || opt->getValue( "readfile" ) != NULL )
{
readfile = opt->getValue( 'r' );
std::cerr << "[ World description is read from \"" << readfile << "\"]\n";
}
else{opt->printUsage(); delete opt; return(-1);}
delete opt;
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Initialize ROS and OpenGLRosCom node (visualization)
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]"<< std::endl;
ros::init(argc, argv, pfs.getFileName().c_str());
if(ros::isInitialized())
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[OK]\n"<< std::endl;
else{
std::cerr << "["<<pfs.getFileName()<<"]:" << "[Initializing ROS]:[FAILED]\n"<< std::endl;
return(1);
}
COpenGLRosCom glNode;
glNode.CreateNode(gltopic);
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Reading the input file
std::cerr << "Reading the input file..." << std::endl;
ShapeVector shapes;
PoseVector poses;
IDVector ID;
if(ReadPolyhedraConfigFile(readfile, shapes, poses, ID)==false)
{
std::cerr << "["<<pfs.getFileName()<<"]:" << "Error reading file \"" << readfile << "\"\n";
return(-1);
}
std::cerr << "Read " << poses.size() << " poses of " << shapes.size() << " shapes with " << ID.size() << " IDs.\n";
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Visualizing the configuration of objects
std::cerr << "Visualizing the configuration of objects..." << std::endl;
for(unsigned int i=0; i<shapes.size(); i++)
{
for(size_t j=0; j<shapes[i].F.size(); j++)
{
glNode.LineWidth(1.0f);
glNode.AddColor3(0.3f, 0.6f, 0.5f);
glNode.AddBegin("LINE_LOOP");
for(size_t k=0; k<shapes[i].F[j].Idx.size(); k++)
{
int idx = shapes[i].F[j].Idx[k];
Eigen::Matrix<Real,3,1> Vt = poses[i]*shapes[i].V[ idx ];
glNode.AddVertex(Vt.x(), Vt.y(), Vt.z());
}
glNode.AddEnd();
}
}
glNode.SendCMDbuffer();
ros::spinOnce();
common::PressEnterToContinue();
//
//////////////////////////////////////////////////////////////////////////////
//.........这里部分代码省略.........
示例9: main
int main(int argc, char * argv[], MPI_Comm commWorld)
{
#else
int main(int argc, char * argv[])
{
MPI_Comm commWorld;
#endif
std::string fileName;
int reduceDM = 10;
int reduceS= 1;
#ifndef PARTICLESRENDERER
std::string fullScreenMode = "";
bool stereo = false;
#endif
int nmaxsample = 200000;
std::string display;
bool inSitu = false;
bool quickSync = true;
int sleeptime = 1;
{
AnyOption opt;
#define ADDUSAGE(line) {{std::stringstream oss; oss << line; opt.addUsage(oss.str());}}
ADDUSAGE(" ");
ADDUSAGE("Usage:");
ADDUSAGE(" ");
ADDUSAGE(" -h --help Prints this help ");
ADDUSAGE(" -i --infile # Input snapshot filename ");
ADDUSAGE(" -I --insitu Enable in-situ rendering ");
ADDUSAGE(" --sleep # start up sleep in sec [1] ");
ADDUSAGE(" --noquicksync disable syncing with simulation [enabled] ");
ADDUSAGE(" --reduceDM # cut down DM dataset by # factor [10]. 0-disable DM");
ADDUSAGE(" --reduceS # cut down stars dataset by # factor [1]. 0-disable S");
#ifndef PARTICLESRENDERER
ADDUSAGE(" --fullscreen # set fullscreen mode string");
ADDUSAGE(" --stereo enable stereo rendering");
#endif
ADDUSAGE(" -s --nmaxsample # set max number of samples for DD [" << nmaxsample << "]");
ADDUSAGE(" -D --display # set DISPLAY=display, otherwise inherited from environment");
opt.setFlag ( "help" , 'h');
opt.setOption( "infile", 'i');
opt.setFlag ( "insitu", 'I');
opt.setOption( "reduceDM");
opt.setOption( "sleep");
opt.setOption( "reduceS");
opt.setOption( "fullscreen");
opt.setFlag("stereo");
opt.setOption("nmaxsample", 's');
opt.setOption("display", 'D');
opt.setFlag ( "noquicksync");
opt.processCommandArgs( argc, argv );
if( ! opt.hasOptions() || opt.getFlag( "help" ) || opt.getFlag( 'h' ) )
{
/* print usage if no options or requested help */
opt.printUsage();
::exit(0);
}
char *optarg = NULL;
if (opt.getFlag("insitu")) inSitu = true;
if ((optarg = opt.getValue("infile"))) fileName = std::string(optarg);
if ((optarg = opt.getValue("reduceDM"))) reduceDM = atoi(optarg);
if ((optarg = opt.getValue("reduceS"))) reduceS = atoi(optarg);
#ifndef PARTICLESRENDERER
if ((optarg = opt.getValue("fullscreen"))) fullScreenMode = std::string(optarg);
if (opt.getFlag("stereo")) stereo = true;
#endif
if ((optarg = opt.getValue("nmaxsample"))) nmaxsample = atoi(optarg);
if ((optarg = opt.getValue("display"))) display = std::string(optarg);
if ((optarg = opt.getValue("sleep"))) sleeptime = atoi(optarg);
if (opt.getValue("noquicksync")) quickSync = false;
if ((fileName.empty() && !inSitu) ||
reduceDM < 0 || reduceS < 0)
{
opt.printUsage();
::exit(0);
}
#undef ADDUSAGE
}
MPI_Comm comm = MPI_COMM_WORLD;
int mpiInitialized = 0;
MPI_Initialized(&mpiInitialized);
if (!mpiInitialized)
MPI_Init(&argc, &argv);
else
comm = commWorld;
int nranks, rank;
//.........这里部分代码省略.........
示例10: AnyOption
//
// Function to parse the input options (both command lines and in the options file ModessRD.options)
//
AnyOption *parseInputOptions( int argc, char **argv ) {
// parse input options
AnyOption *opt = new AnyOption();
opt->addUsage( "----------------------------------------------------------------------------" );
opt->addUsage( "| NCPA Infrasound |" );
opt->addUsage( "| Normal Modes for Range-Dependent Environments |" );
opt->addUsage( "| Two-Way Coupled Mode Solution |" );
opt->addUsage( "| Single Frequency: Effective Sound Speed Approximation |" );
opt->addUsage( "----------------------------------------------------------------------------" );
opt->addUsage( "Usage: " );
opt->addUsage( "By default the program computes the 1D transmission loss (TL)" );
opt->addUsage( "at the ground or the specified receiver height and saves the data to 2 files:" );
opt->addUsage( " file tloss_rd2wcm_1d.nm - considering attenuation in the atmosphere" );
opt->addUsage( " file tloss_rd2wcm_1d.lossless.nm - no attenuation" );
opt->addUsage( "Additionally, if the flag --write_2D_TLoss is present on the command line the 2D TL is saved to file tloss_rd_2d.nm" );
opt->addUsage( "The options below can be specified in a colon-separated file \"Modess.options\" or at the command line. Command-line options override file options." );
opt->addUsage( " --help -h Print this message and exit" );
opt->addUsage( "" );
opt->addUsage( " The atmosphere can be specified from one of 2 different sources:");
opt->addUsage( " 1. An .env file containing the atmospheric specifications at certain ranges:" );
opt->addUsage( " use option --g2senvfile <filename>" );
opt->addUsage( " 2. Several ASCII files stored in a given directory:" );
opt->addUsage( " use option --use_1D_profiles_from_dir <mydirname>" );
//opt->addUsage( "The program requires an .env file containing the atmospheric specifications at certain ranges" );
opt->addUsage( "The following options apply:" );
opt->addUsage( "" );
opt->addUsage( "REQUIRED (no default values):" );
//opt->addUsage( " --atmosfile <filename> Uses an ASCII atmosphere file" );
opt->addUsage( " --g2senvfile <filename> Uses an .env binary file containing multiple 1D profiles" );
opt->addUsage( " --atmosfileorder The order of the (z,t,u,v,w,p,d) fields in the ASCII file (Ex: 'ztuvpd')" );
opt->addUsage( " --skiplines Lines at the beginning of the ASCII file to skip" );
opt->addUsage( " --azimuth Degrees in range [0,360), clockwise from North" );
opt->addUsage( " --freq Frequency [Hz]" );
opt->addUsage( "" );
opt->addUsage( "OPTIONAL [defaults]:" );
opt->addUsage( " --maxheight_km Calculation grid height in km above MSL [150 km]" );
opt->addUsage( " --zground_km Height of the ground level above MSL [0 km]" );
opt->addUsage( " --Nz_grid Number of points on the z-grid from ground to maxheight [20000]" );
opt->addUsage( " --sourceheight_km Source height in km Above Ground Level (AGL) [0]" );
opt->addUsage( " --receiverheight_km Receiver height in km AGL [0]" );
opt->addUsage( " --maxrange_km Maximum horizontal distance from origin to propagate [1000 km]" );
opt->addUsage( " --Nrng_steps Number of range steps to propagate [1000]" );
opt->addUsage( " --ground_impedance_model Name of the ground impedance models to be employed:" );
opt->addUsage( " [rigid], others TBD" );
opt->addUsage( " --Lamb_wave_BC If ==1 it sets admittance = -1/2*dln(rho)/dz; [ 0 ]" );
opt->addUsage( " --wind_units Use it to specify 'kmpersec' if the winds are given in km/s [mpersec]" );
opt->addUsage( " --use_attn_file Use it to specify a file name containing user-provided" );
opt->addUsage( " attenuation coefficients to be loaded instead of " );
opt->addUsage( " the default Sutherland-Bass attenuation. " );
opt->addUsage( " The text file should contain two columns: " );
opt->addUsage( " height (km AGL) and " );
opt->addUsage( " attenuation coefficients in np/m." );
opt->addUsage( "" );
opt->addUsage( " --use_profile_ranges_km" );
opt->addUsage( " e.g. --use_profile_ranges_km 0_20_50_80.5_300 " );
opt->addUsage( " The profiles at certain ranges specified by numbers" );
opt->addUsage( " (in km) in a string such as 0_20_50_80.5_300 are");
opt->addUsage( " requested in the propagation. Note that underscores" );
opt->addUsage( " are necessary to separate the numbers." );
opt->addUsage( " Note also that these are requested ranges;" );
opt->addUsage( " however the left-closest profile available" );
opt->addUsage( " in the .env file will actually be used; " );
opt->addUsage( " for instance we request the profile at 300 km " );
opt->addUsage( " but in the .env file the left-closest profile" );
opt->addUsage( " may be available at 290 km and it is the one used." );
opt->addUsage( " Example: >> ../bin/ModessRD2WCM --atmosfile g2sgcp2011012606L.jordan.env ");
opt->addUsage( " --atmosfileorder zuvwtdp --azimuth 90 --freq 0.01 ");
opt->addUsage( " --use_profiles_ranges_km 100_200_250 --maxrange_km 500 ");
opt->addUsage( "" );
opt->addUsage( " --use_profiles_at_steps_km" );
opt->addUsage( " e.g. --use_profiles_at_steps_km 100" );
opt->addUsage( " The profiles are requested at equidistant intervals " );
opt->addUsage( " specified by this option [1000]" );
opt->addUsage( "" );
opt->addUsage( " --use_1D_profiles_from_dir" );
opt->addUsage( " e.g. --use_1D_profiles_from_dir myprofiles" );
opt->addUsage( " This option allows to use the ascii profiles stored in" );
opt->addUsage( " the specified directory. The profiles must have names" );
opt->addUsage( " 'profiles0001', 'profiles0002', etc. and will be" );
opt->addUsage( " used in alphabetical order at the provided ranges" );
opt->addUsage( " e.g. in conjunction with either" );
opt->addUsage( " option '--use_profile_ranges_km' " );
opt->addUsage( " or option '--use_profiles_at_steps_km'" );
opt->addUsage( " If there are more requested ranges than existing" );
opt->addUsage( " profiles then the last profile is used repeatedly" );
opt->addUsage( " as necessary." );
opt->addUsage( " Example: >> ../bin/ModessRD2WCM --atmosfileorder zuvwtdp --skiplines 1" );
opt->addUsage( " --azimuth 90 --freq 0.1 --use_1D_profiles_from_dir myprofiles" );
opt->addUsage( " --use_profile_ranges_km 0_100_300_500 " );
opt->addUsage( "" );
opt->addUsage( "FLAGS (no value required):" );
opt->addUsage( " --write_2D_TLoss Outputs the 2D transmission loss to" );
opt->addUsage( " default file: tloss_rd2wcm_2d.nm" );
opt->addUsage( "" );
opt->addUsage( "" );
//.........这里部分代码省略.........
示例11: main
/**
* @brief Read in files with arrays and join them into a single file
* @param argc
* @param argv[]
* @return
*/
int main (int argc, char *argv[]) {
AnyOption opt;
/* parse command line options */
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("output", 'o');
opt.setOption ("format", 'f');
opt.setOption ("verbose", 'v');
opt.addUsage ("Orthonal Array Convert: convert array file into a different format");
opt.addUsage ("Usage: oaconvert [OPTIONS] [INPUTFILE] [OUTPUTFILE]");
opt.addUsage ("");
opt.addUsage (" -h --help Prints this help ");
opt.addUsage (" -f [FORMAT] Output format (default: TEXT, or BINARY) ");
opt.processCommandArgs (argc, argv);
int verbose = opt.getIntValue ("verbose", 2);
if (verbose > 0)
print_copyright ();
/* parse options */
if (opt.getFlag ("help") || opt.getFlag ('h') || opt.getArgc () == 0) {
opt.printUsage ();
exit (0);
}
const std::string outputprefix = opt.getStringValue ('o', "");
std::string format = opt.getStringValue ('f', "BINARY");
arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (format);
if (opt.getArgc () != 2) {
opt.printUsage ();
exit (0);
}
std::string infile = opt.getArgv (0);
std::string outfile = opt.getArgv (1);
convert_array_file(infile, outfile, mode, verbose);
return 0;
}
示例12: main
/**
* @brief Filter arrays in a file and write filtered arrays to output file
* @param argc Number of command line arguments
* @param argv Command line arguments
* @return
*/
int main (int argc, char *argv[]) {
AnyOption opt;
/* parse command line options */
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("output", 'o');
opt.setOption ("verbose", 'v');
opt.setOption ("na", 'a');
opt.setOption ("index", 'i');
opt.setOption ("format", 'f');
opt.addUsage ("Orthonal Array Filter: filter arrays");
opt.addUsage ("Usage: oaanalyse [OPTIONS] [INPUTFILE] [VALUESFILE] [THRESHOLD] [OUTPUTFILE]");
opt.addUsage (" The VALUESFILE is a binary file with k*N double values. Here N is the number of arrays");
opt.addUsage (" and k the number of analysis values.");
opt.addUsage ("");
opt.addUsage (" -h --help Prints this help ");
opt.addUsage (" -v --verbose Verbose level (default: 1) ");
opt.addUsage (" -a Number of values in analysis file (default: 1) ");
opt.addUsage (" --index Index of value to compare (default: 0) ");
opt.addUsage (" -f [FORMAT] Output format (default: TEXT, or BINARY; B) ");
opt.processCommandArgs (argc, argv);
print_copyright ();
/* parse options */
if (opt.getFlag ("help") || opt.getFlag ('h') || opt.getArgc () < 4) {
opt.printUsage ();
exit (0);
}
int verbose = opt.getIntValue ('v', 1);
int na = opt.getIntValue ('a', 1);
int index = opt.getIntValue ("index", 0);
std::string format = opt.getStringValue ('f', "BINARY");
arrayfile::arrayfilemode_t mode = arrayfile_t::parseModeString (format);
/* read in the arrays */
std::string infile = opt.getArgv (0);
std::string anafile = opt.getArgv (1);
double threshold = atof (opt.getArgv (2));
std::string outfile = opt.getArgv (3);
if (verbose)
printf ("oafilter: input %s, threshold %f (analysisfile %d values, index %d)\n", infile.c_str (),
threshold, na, index);
arraylist_t *arraylist = new arraylist_t;
int n = readarrayfile (opt.getArgv (0), arraylist);
if (verbose)
printf ("oafilter: filtering %d arrays\n", n);
// read analysis file
FILE *afid = fopen (anafile.c_str (), "rb");
if (afid == 0) {
printf (" could not read analysisfile %s\n", anafile.c_str ());
exit (0);
}
double *a = new double[n * na];
fread (a, sizeof (double), n * na, afid);
fclose (afid);
std::vector< int > gidx;
;
for (int jj = 0; jj < n; jj++) {
double val = a[jj * na + index];
if (val >= threshold)
gidx.push_back (jj);
if (verbose >= 2)
printf ("jj %d: val %f, threshold %f\n", val >= threshold, val, threshold);
}
// filter
arraylist_t *filtered = new arraylist_t;
selectArrays (*arraylist, gidx, *filtered);
/* write arrays to file */
if (verbose)
cout << "Writing " << filtered->size () << " arrays (input " << arraylist->size () << ") to file "
<< outfile << endl;
writearrayfile (outfile.c_str (), *filtered, mode);
/* free allocated structures */
delete[] a;
delete arraylist;
delete filtered;
return 0;
}
示例13: AnyOption
AnyOption *parseInputOptions( int argc, char **argv ) {
// parse input options
AnyOption *opt = new AnyOption();
opt->addUsage( "----------------------------------------------------------------------------" );
opt->addUsage( "| NCPA Infrasound |" );
opt->addUsage( "| Normal Modes Broadband |" );
opt->addUsage( "| Based on either: Effective Sound Speed Approximation - see ModESS |" );
opt->addUsage( "| Wide_Angle High-Mach code - see WMod |" );
opt->addUsage( "----------------------------------------------------------------------------" );
opt->addUsage( "Usage: " );
opt->addUsage( "" );
opt->addUsage( "The options below can be specified in a colon-separated file \"ModBB.options\"");
opt->addUsage( "or at the command line. Command-line options override file options." );
opt->addUsage( "Be sure to precede all options with two minuses (--)." );
opt->addUsage( " --help -h Print this message and exit" );
opt->addUsage( "" );
opt->addUsage( "One of two algorithms can be used to perform pulse propagation." );
opt->addUsage( "The first is based on the Effective Sound Speed Approximation (as in ModESS);" );
opt->addUsage( "the second is based on the the Wide_Angle High-Mach solution ");
opt->addUsage( "of the wave equation (see implementation in WMod)." );
opt->addUsage( "ModESS is faster but it is accurate for (launch) angles less than 30 deg and" );
opt->addUsage( "low wind speeds. WMod extends the validity to higher angles" );
opt->addUsage( "and high Mach numbers but it runs slower." );
opt->addUsage( "Options --use_modess and --use_wmod allow the user to choose");
opt->addUsage( "the desired algorithm when computing the dispersion data (see step 1 below)." );
opt->addUsage( "" );
opt->addUsage( "To propagate a pulse, 2 steps must be completed:");
opt->addUsage( " 1. A dispersion file must be available or computed" );
opt->addUsage( " using the option --out_disp_src2rcv_file ." );
// opt->addUsage( " use either option --out_dispersion_files or --out_disp_src2rcv_file" );
opt->addUsage( " 2. Perform pulse propagation for one of several scenarios:");
opt->addUsage( " a. source-to-receiver at one range (option --pulse_prop_src2rcv)");
opt->addUsage( " b. source-to-receiver at several equally spaced ranges " );
opt->addUsage( " (option --pulse_prop_src2rcv_grid)");
// opt->addUsage( " c. computing the whole 2D pressure field " );
// opt->addUsage( " (most expensive - option --pulse_prop_grid)" );
opt->addUsage( " The source type can be one of the following:" );
opt->addUsage( " delta function -> see option --get_impulse_resp" );
opt->addUsage( " built-in pulse choice 1 -> see option --use_builtin_pulse1" );
opt->addUsage( " built-in pulse choice 2 -> see option --use_builtin_pulse2" );
opt->addUsage( " user-provided spectrum file -> see option --src_spectrum_file" );
opt->addUsage( " user-provided waveform file -> see option --src_waveform_file" );
opt->addUsage( "" );
// opt->addUsage( "To compute a dispersion file: one of the following 2 options is REQUIRED:" );
opt->addUsage( "To compute a dispersion file: the following option is REQUIRED:" );
opt->addUsage( " --out_disp_src2rcv_file <dispersion filename>");
opt->addUsage( " Output dispersion curves and modal values for" );
opt->addUsage( " source-to-receiver propagation to the specified file." );
// opt->addUsage( " --out_dispersion_files <dispersion filename stub>");
// opt->addUsage( " Output dispersion curves and modal values on a 2D grid" );
// opt->addUsage( " to binary files at each frequency. The resulting filenames" );
// opt->addUsage( " have the stub and frequency appended: " );
// opt->addUsage( " e.g. <stub><freq>_nm.bin." );
// opt->addUsage( " This option is computationally expensive." );
opt->addUsage( "" );
// opt->addUsage( " Examples (run in the 'samples' directory):" );
// opt->addUsage( "" );
// opt->addUsage( " a. Compute dispersion file that will be used to compute the pressure pulse at 1 receiver. Assume that we want to end up with a pulse having a spectrum with a maximum frequency of f_max=0.5 Hz. Also assume that we want the pulse represented on a time record of T=512 seconds. The number of positive frequencies necessary for the calculation is T*f_max = 256 i.e.256 frequencies between 0 and 0.5 Hz. Thus we know f_max=0.5 Hz and f_step=f_max/256=0.001953125 Hz. The corresponding run command is:" );
opt->addUsage( " Example (run in the 'samples' directory):" );
opt->addUsage( "" );
opt->addUsage( " Example to obtain a dispersion file that will be used to compute" );
opt->addUsage( " the propagated pressure pulse at a distant receiver. " );
opt->addUsage( " Assume that we want to end up with a pulse having a spectrum" );
opt->addUsage( " with a maximum frequency of f_max=0.5 Hz. " );
opt->addUsage( " Also assume that we want the pulse represented on a time record " );
opt->addUsage( " of T=512 seconds. The number of positive frequencies necessary " );
opt->addUsage( " for the calculation is T*f_max = 256 i.e.256 frequencies " );
opt->addUsage( " between f_min=f_step and 0.5 Hz. The step in frequency is " );
opt->addUsage( " f_step=f_max/256=0.001953125 Hz." );
opt->addUsage( " The corresponding run command is:" );
opt->addUsage( "" );
opt->addUsage( " >> ../bin/ModBB --out_disp_src2rcv_file myDispersionFile.dat " );
opt->addUsage( " --atmosfile NCPA_canonical_profile_zuvwtdp.dat --atmosfileorder zuvwtdp " );
opt->addUsage( " --skiplines 0 --azimuth 90 --f_step 0.001953125 --f_max 0.5 --use_modess" );
opt->addUsage( "" );
opt->addUsage( " Each line in this dispersion file has (4 + 4*n_modes) entries" );
opt->addUsage( " in the following format:" );
opt->addUsage( " freq n_modes rho_src rho_rcv Re(k_pert_m) Im(k_pert_m) V_m(z_src) V_m(z_rcv)" );
opt->addUsage( " where m varies from 1 to n_modes. k_pert_m, and V_m are" );
opt->addUsage( " the m_th wavenumber and mode amplitude respectively." );
opt->addUsage( " z_src and z_rcv stand for source and receiver height respectively." );
opt->addUsage( "" );
// opt->addUsage( " b. Compute dispersion files for propagation to all receivers on a 2D grid: for 256 frequencies from 0 to 0.5 Hz in steps of 0.5/256 Hz:" );
// opt->addUsage( "" );
// opt->addUsage( " >> ../bin/ModBB --out_dispersion_files disprs --atmosfile NCPA_canonical_profile_zuvwtdp.dat --atmosfileorder zuvwtdp --skiplines 0 --azimuth 90 --f_step 0.001953125 --f_max 0.5 --use_modess" );
opt->addUsage( "" );
opt->addUsage( "In addition the following options are REQUIRED:" );
opt->addUsage( " --use_modess Prompts the use of ModESS algorithm." );
opt->addUsage( " --use_wmod Prompts the use of WMod algorithm." );
opt->addUsage( " Note that --use_modess and --use_wmod are mutually exclusive." );
opt->addUsage( " --atmosfile <filename> Uses an ASCII atmosphere file" );
opt->addUsage( " referenced to Mean Sea Level (MSL)." );
opt->addUsage( " --atmosfileorder The order of the (z,t,u,v,w,p,d) fields in " );
opt->addUsage( " the ASCII file (Ex: 'ztuvpd')" );
opt->addUsage( " --skiplines Lines at the beginning of the ASCII file to skip" );
opt->addUsage( " --azimuth Value in range [0,360), clockwise from North" );
opt->addUsage( " --f_step The frequency step" );
opt->addUsage( " --f_max Maximum frequency to propagate" );
//.........这里部分代码省略.........
示例14: main
int main(int argc, char **argv){
// nekonstantni nastaveni generatoru nahodnych cisel
srand((unsigned int)time(0));
// server cast
clock_t t1, t2;
t1 = clock();
int NP = 50;
double F = 0.7;
double CR = 0.6;
int Generations = 10;
int pocet_neuronu = 5;
char *nejlepsi_jedinec = "nejlepsi_jedinec.txt";
char *data = "data.txt";
int tichy = 0;
// parsovani parametru
AnyOption *opt = new AnyOption();
opt->setVerbose(); /* print warnings about unknown options */
opt->autoUsagePrint(true); /* print usage for bad options */
opt->addUsage( "" );
opt->addUsage( "NNSA (Neural Network Space Arcade) - Testovani rekuretni neuronove site na jednoduche arkade" );
opt->addUsage( "" );
opt->addUsage( "Pouziti: " );
opt->addUsage( "" );
opt->addUsage( " -h --help Zobrazi tuto napovedu " );
opt->addUsage( " -n jedinec.txt Nejlepsi jedinec " );
opt->addUsage( " -d data.txt Udaje o jednotlivych generacich " );
opt->addUsage( " " );
opt->addUsage( " --NP 60 Velikost populace " );
opt->addUsage( " --F 0.7 Mutacni konstanta " );
opt->addUsage( " --CR 0.8 Prah krizeni " );
opt->addUsage( " --generations 100 Pocet kol slechteni populace " );
opt->addUsage( " --neurons 4 Pocet neuronu v neuronove siti " );
opt->addUsage( " --quiet 1 Neukecany rezim " );
opt->addUsage( "" );
opt->setFlag( "help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt->setOption('n');
opt->setOption('d');
opt->setOption("NP");
opt->setOption("F");
opt->setOption("CR");
opt->setOption("generations");
opt->setOption("neurons");
opt->setOption("quiet");
opt->processCommandArgs(argc, argv);
NP = atoi(opt->getValue("NP"));
F = atof(opt->getValue("F"));
CR = atof(opt->getValue("CR"));
Generations = atoi(opt->getValue("generations"));
pocet_neuronu = atoi(opt->getValue("neurons"));
nejlepsi_jedinec = opt->getValue('n');
data = opt->getValue('d');
tichy = atoi(opt->getValue("quiet"));
cout << "Parametry diferencialni evoluce:" << endl;
cout << " -> Velikost populace NP = " << NP << endl;
cout << " -> Mutacni konstanta F = " << F << endl;
cout << " -> Prah krizeni CR = " << CR << endl;
cout << " -> Pocet generaci = " << Generations << endl;
cout << " -> Pocet neuronu = " << pocet_neuronu << endl;
DiferencialniEvoluce *d1 = new DiferencialniEvoluce(NP, F, CR, Generations, pocet_neuronu, &ohodnoceni, tichy, data);
d1->UlozNejlepsiJedinec(nejlepsi_jedinec);
// 32bit - pretece cca po 36 minutach
t2 = clock();
cout << "Doba behu programu: " << ((double) (t2 - t1))/CLOCKS_PER_SEC << endl;
return 0;
}
示例15: main
int main (int argc, char *argv[]) {
AnyOption opt;
/* parse command line options */
opt.setFlag ("help", 'h'); /* a flag (takes no argument), supporting long and short form */
opt.setOption ("output", 'o');
opt.setOption ("input", 'I');
opt.setOption ("rand", 'r');
opt.setOption ("verbose", 'v');
opt.setOption ("ii", 'i');
opt.setOption ("jj");
opt.setOption ("xx", 'x');
opt.setOption ("dverbose", 'd');
opt.setOption ("rows");
opt.setOption ("cols");
opt.setOption ("nrestarts");
opt.setOption ("niter");
opt.setOption ("mdebug", 'm');
opt.setOption ("oaconfig", 'c'); /* file that specifies the design */
opt.addUsage ("Orthonal Array: oatest: testing platform");
opt.addUsage ("Usage: oatest [OPTIONS] [FILE]");
opt.addUsage ("");
opt.addUsage (" -h --help Prints this help ");
opt.processCommandArgs (argc, argv);
double t0 = get_time_ms (), dt = 0;
int randvalseed = opt.getIntValue ('r', 1);
int ix = opt.getIntValue ('i', 1);
int r = opt.getIntValue ('r', 1);
int jj = opt.getIntValue ("jj", 5);
int xx = opt.getIntValue ('x', 0);
int niter = opt.getIntValue ("niter", 10);
int verbose = opt.getIntValue ("verbose", 1);
const char *input = opt.getValue ('I');
if (input == 0)
input = "test.oa";
srand (randvalseed);
if (randvalseed == -1) {
randvalseed = time (NULL);
printf ("random seed %d\n", randvalseed);
srand (randvalseed);
}
array_link array = exampleArray(0);
lmc_t lmc_type = LMCcheck(array);
array = array.randomperm();
array.showarray();
array_link reduced_array = reduceLMCform(array);
reduced_array.showarray();
exit(0);
try {
array_link al = exampleArray(r);
al.show();
al.showarray();
std::vector<int> sizes = array2modelmatrix_sizes(al);
display_vector(sizes); myprintf("\n");
MatrixFloat modelmatrix = array2modelmatrix(al, "i", 1);
array_link modelmatrixx = modelmatrix;
modelmatrixx.show();
modelmatrixx.showarray();
modelmatrix = array2modelmatrix(al, "main", 1);
modelmatrixx = modelmatrix;
modelmatrixx.show();
modelmatrixx.showarray();
exit(0);
}
catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
throw;
}
{
array_link al = exampleArray (r);
array_transformation_t tt = reduceOAnauty (al);
array_link alx = tt.apply (al);
exit (0);
}
return 0;
}