5 #include "latlib/progress.h"
7 o815::o815(int argc, char **argv, const string& _programid) {
10 programid = _programid;
17 comargs.obscache = make_pair("",0);
18 comargs.confcache = make_pair("",0);
20 comargs.idonly = false;
21 comargs.showjobnum = false;
23 MPI_Init(&argc, &argv);
24 MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
25 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
27 paraQ = new paraq(numprocs, rank);
29 parseArgs(argc, argv);
32 cout << programid << headMaster() << endl << flush;
37 timestamp = time(NULL);
38 for(int idest=1; idest<numprocs; idest++)
39 MPI_Send(×tamp, 1, MPI_LONG, idest, 123, MPI_COMM_WORLD);
42 MPI_Recv(×tamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, &mpiStatus);
44 out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp);
47 void o815::mainLoop() {
48 if( comargs.showjobnum ) {
49 for( int i=1; i<=paraQ->getTotalJobs(); i++ ) {
50 if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " ";
56 *out->log << "OBS: Starting main loop." << endl;
58 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
61 while( nextParas() ) {
62 *out->log << endl << "O815: < ";
63 for (vector<string>::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait)
64 *out->log << *parait << "=" << (*paraQ)[*parait] << " ";
65 *out->log << ">" << endl << flush;
67 progress measProg(comargs.nmeas);
69 *out->log << "OBS: Starting measurement of observables:";
70 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
71 *out->log << " " << (*obsit)->obsid;
72 *out->log << endl << flush;
74 for( int imeas=0; imeas<comargs.nmeas; imeas++ ) {
75 bool nextAlready = false;
76 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) {
77 if( hypercache::readO( (*obsit)->ocid ) != -1 ) {
82 (*obsit)->meas(false);
83 hypercache::writeO( (*obsit)->ocid );
88 while( measProg.madeStep(imeas) )
89 *out->log << "O815: " << measProg.done()*100 << "% of measurements done." << endl << flush;
91 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
96 void o815::parseArgs(int argc, char **argv) {
99 while( (opt = getopt(argc, argv, "L:N:S:E:o:O:c:C:w:i:j:")) != -1 )
102 listArg(comargs.lsize, 2, optarg);
105 comargs.nmeas = atoi(optarg);
108 comargs.nskip = atoi(optarg);
111 comargs.nequi = atoi(optarg);
114 comargs.obscache.first = optarg;
115 comargs.obscache.second = 1;
118 comargs.obscache.first = optarg;
119 comargs.obscache.second = 2;
122 comargs.confcache.first = optarg;
123 comargs.confcache.second = 1;
126 comargs.confcache.first = optarg;
127 comargs.confcache.second = 2;
130 comargs.outdir = optarg;
133 comargs.idonly = atoi(optarg);
136 comargs.showjobnum = atoi(optarg);
141 void o815::listArg(int *target, int tlen, char *listarg) {
144 for( int pos=0; pos<strlen(listarg); pos++ )
145 if( listarg[pos] == ':' ) nargs++;
148 for(int i=0; i<tlen; i++) target[i] = atoi(listarg);
151 target[0] = atoi(strtok(listarg, ":"));
152 for(int i=0; i<nargs; i++)
153 target[i+1] = atoi(strtok(NULL, ":"));
157 string o815::headMaster()
161 hm << "-L" << comargs.lsize[0] << "_" << comargs.lsize[1] << "-E" << comargs.nequi << "-S" << comargs.nskip << "-N" << comargs.nmeas
162 << paraQ->rangeString();
168 if(comargs.outdir=="") {
169 MPI_Barrier(MPI_COMM_WORLD);
171 cout << "#end" << endl << flush;
173 hypercache::finalize();
178 int o815::nextParas()
180 if( paraQ->nextParas() ) {
181 for (vector<string>::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait)
182 hypercache::setPara(*parait, (*paraQ)[*parait]);
189 void o815::addPara(const string& paraid, const double& paraDefault) {
190 hypercache::addPara(paraid);
191 paraQ->setDefault(paraid, paraDefault);