X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/7d17aa8c6bde2e49502401aa190a900bd4688362..238fccf7dd50a69b5825f4544b3e247bfbf4e417:/o815/o815.cpp diff --git a/o815/o815.cpp b/o815/o815.cpp index 29f5fd3..ff0b1ae 100644 --- a/o815/o815.cpp +++ b/o815/o815.cpp @@ -1,10 +1,15 @@ #include "o815.h" #include +#include #include "latlib/progress.h" -o815::o815(int argc, char **argv, const string& _programid) { +using namespace std; + +extern int opterr; + +o815::o815(int argc, char **argv, const string& _programid, comoption specOps[], void (*helpHeader)()) { long timestamp; programid = _programid; @@ -26,18 +31,67 @@ o815::o815(int argc, char **argv, const string& _programid) { paraQ = new paraq(numprocs, rank); - parseArgs(argc, argv); + addComOption("lsize", required_argument, NULL, 'L', "define lattice size", "xsize:tsize"); + addComOption("nmeas", required_argument, NULL, 'N', "set number of measurements", "nmeas"); + addComOption("skip", required_argument, NULL, 'S', "set number of skips between configs", "nskip"); + addComOption("nequi", required_argument, NULL, 'E', "set number of equilibrations", "nequi"); + addComOption("oro", required_argument, NULL, 'o', "read-only observable-store directory", "dir"); + addComOption("orw", required_argument, NULL, 'O', "read-write observable-store directory", "dir"); + addComOption("cro", required_argument, NULL, 'c', "read-only config-store directory", "dir"); + addComOption("crw", required_argument, NULL, 'C', "read-write config-store directory", "dir"); + addComOption("write", required_argument, NULL, 'w', "data writeout directory", "dir"); + addComOption("idonly", no_argument, &comargs.idonly, 'i', "show output-id only", ""); + addComOption("jobnum", no_argument, &comargs.showjobnum, 'j', "show jobnumber only", ""); - if(comargs.idonly) { - cout << programid << headMaster() << endl << flush; + if (specOps != NULL) + for (int ispecop = 0; specOps[ispecop].name != ""; ispecop++) + comOptions.push_back(specOps[ispecop]); + + if (argc > 1) + parseArgs(argc, argv, specOps); + else { + int longestCombinedLong=0; + + if (helpHeader != NULL) + helpHeader(); + + cout << "Options:" << endl; + + for (vector::iterator opit = comOptions.begin(); opit != comOptions.end(); ++opit) { + stringstream combinedLong; + + combinedLong << opit->name; + if (opit->has_arg == required_argument) + combinedLong << "=" << opit->argdesc; + else if (opit->has_arg == optional_argument) + combinedLong << "[=" << opit->argdesc << "]"; + + if (longestCombinedLong < combinedLong.str().size()) + longestCombinedLong = combinedLong.str().size(); + } + + for (vector::iterator opit = comOptions.begin(); opit != comOptions.end(); ++opit) { + stringstream combinedLong; + + cout << " -" << char(opit->val) << ", --"; + + combinedLong << opit->name; + if (opit->has_arg == required_argument) + combinedLong << "=" << opit->argdesc; + else if (opit->has_arg == optional_argument) + combinedLong << "[=" << opit->argdesc << "]"; + + cout << setw(longestCombinedLong) << setiosflags(ios::left) << combinedLong.str(); + + cout << "\t" << opit->optdesc; + + cout << endl; + } exit(0); } - if( comargs.showjobnum ) { - for( int i=1; i<=paraQ->getTotalJobs(); i++ ) { - if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " "; - } - cout << endl; + if(comargs.idonly) { + cout << programid << headMaster() << endl << flush; exit(0); } @@ -53,6 +107,14 @@ o815::o815(int argc, char **argv, const string& _programid) { } void o815::mainLoop() { + if( comargs.showjobnum ) { + for( int i=1; i<=paraQ->getTotalJobs(); i++ ) { + if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " "; + } + cout << endl; + exit(0); + } + *out->log << "OBS: Starting main loop." << endl; for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) @@ -63,10 +125,17 @@ void o815::mainLoop() { for (vector::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait) *out->log << *parait << "=" << (*paraQ)[*parait] << " "; *out->log << ">" << endl << flush; + + Sim->_newParas(); progress measProg(comargs.nmeas); - *out->log << "OBS: Starting measurements." << endl << flush; + *out->log << "OBS: Starting measurement of observables:"; + for (vector::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) + *out->log << " " << (*obsit)->obsid; + *out->log << endl << flush; + + Sim->toEquilibrate = true; for( int imeas=0; imeasflag != 0) + *thisop->flag = thisop->val; + else + parsedSpecOps.push_back( pair(thisop->val, optarg) ); + } break; } + + for (int ilon=0; optind+ilon < argc; ilon++) + lonelyArgs.push_back(argv[optind+ilon]); +} + +o815::comoption* o815::getOptionByVal(int val) { + for (vector::iterator opit = comOptions.begin(); opit != comOptions.end(); ++opit) + if ( opit->val == val ) + return &(*opit); + exit(1); } void o815::listArg(int *target, int tlen, char *listarg) {