5 #include "latlib/progress.h"
9 o815::o815(int argc, char **argv, const string& _programid) {
12 programid = _programid;
19 comargs.obscache = make_pair("",0);
20 comargs.confcache = make_pair("",0);
22 comargs.idonly = false;
23 comargs.showjobnum = false;
25 MPI_Init(&argc, &argv);
26 MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
27 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
29 paraQ = new paraq(numprocs, rank);
31 parseArgs(argc, argv);
34 cout << programid << headMaster() << endl << flush;
39 timestamp = time(NULL);
40 for(int idest=1; idest<numprocs; idest++)
41 MPI_Send(×tamp, 1, MPI_LONG, idest, 123, MPI_COMM_WORLD);
44 MPI_Recv(×tamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, &mpiStatus);
46 out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp);
49 void o815::mainLoop() {
50 if( comargs.showjobnum ) {
51 for( int i=1; i<=paraQ->getTotalJobs(); i++ ) {
52 if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " ";
58 *out->log << "OBS: Starting main loop." << endl;
60 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
63 while( nextParas() ) {
64 *out->log << endl << "O815: < ";
65 for (vector<string>::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait)
66 *out->log << *parait << "=" << (*paraQ)[*parait] << " ";
67 *out->log << ">" << endl << flush;
69 progress measProg(comargs.nmeas);
71 *out->log << "OBS: Starting measurement of observables:";
72 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
73 *out->log << " " << (*obsit)->obsid;
74 *out->log << endl << flush;
76 Sim->toEquilibrate = true;
78 for( int imeas=0; imeas<comargs.nmeas; imeas++ ) {
79 bool nextAlready = false;
80 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) {
81 if( hypercache::readO( (*obsit)->ocid ) != -1 ) {
86 (*obsit)->meas(false);
87 hypercache::writeO( (*obsit)->ocid );
92 while( measProg.madeStep(imeas) )
93 *out->log << "O815: " << measProg.done()*100 << "% of measurements done." << endl << flush;
95 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
100 void o815::parseArgs(int argc, char **argv) {
105 while( (opt = getopt(argc, argv, "L:N:S:E:o:O:c:C:w:i:j:")) != -1 )
108 listArg(comargs.lsize, 2, optarg);
111 comargs.nmeas = atoi(optarg);
114 comargs.nskip = atoi(optarg);
117 comargs.nequi = atoi(optarg);
120 comargs.obscache.first = optarg;
121 comargs.obscache.second = 1;
124 comargs.obscache.first = optarg;
125 comargs.obscache.second = 2;
128 comargs.confcache.first = optarg;
129 comargs.confcache.second = 1;
132 comargs.confcache.first = optarg;
133 comargs.confcache.second = 2;
136 comargs.outdir = optarg;
139 comargs.idonly = atoi(optarg);
142 comargs.showjobnum = atoi(optarg);
147 void o815::listArg(int *target, int tlen, char *listarg) {
150 for( int pos=0; pos<strlen(listarg); pos++ )
151 if( listarg[pos] == ':' ) nargs++;
154 for(int i=0; i<tlen; i++) target[i] = atoi(listarg);
157 target[0] = atoi(strtok(listarg, ":"));
158 for(int i=0; i<nargs; i++)
159 target[i+1] = atoi(strtok(NULL, ":"));
163 string o815::headMaster()
167 hm << "-L" << comargs.lsize[0] << "_" << comargs.lsize[1] << "-E" << comargs.nequi << "-S" << comargs.nskip << "-N" << comargs.nmeas
168 << paraQ->rangeString();
174 if(comargs.outdir=="") {
175 MPI_Barrier(MPI_COMM_WORLD);
177 cout << "#end" << endl << flush;
179 hypercache::finalize();
184 int o815::nextParas()
186 if( paraQ->nextParas() ) {
187 for (vector<string>::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait)
188 hypercache::setPara(*parait, (*paraQ)[*parait]);
195 void o815::addPara(const string& paraid, const double& paraDefault) {
196 hypercache::addPara(paraid);
197 paraQ->setDefault(paraid, paraDefault);