5 o815::o815(int argc, char **argv, const string& _programid) {
8 programid = _programid;
15 comargs.obscache = make_pair("",0);
16 comargs.confcache = make_pair("",0);
18 comargs.idonly = false;
19 comargs.showjobnum = false;
21 MPI_Init(&argc, &argv);
22 MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
23 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
25 paraQ = new paraq(numprocs, rank);
27 parseArgs(argc, argv);
30 cout << programid << headMaster() << endl << flush;
34 if( comargs.showjobnum ) {
35 for( int i=1; i<=paraQ->getTotalJobs(); i++ ) {
36 if( paraQ->getTotalJobs()%i == 0 ) cout << paraQ->getTotalJobs()/i << "@" << i << " ";
43 timestamp = time(NULL);
44 for(int idest=1; idest<numprocs; idest++)
45 MPI_Send(×tamp, 1, MPI_LONG, idest, 123, MPI_COMM_WORLD);
48 MPI_Recv(×tamp, 1, MPI_LONG, 0, 123, MPI_COMM_WORLD, &mpiStatus);
50 out = new writeout(comargs.outdir, programid+headMaster(), rank, numprocs, timestamp);
53 void o815::mainLoop() {
54 *out->log << "OBS: Starting main loop." << endl;
56 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
59 while( nextParas() ) {
63 for (int i=0; i<100; i++) {
64 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit) {
70 for (vector<obs*>::iterator obsit = observables.begin(); obsit != observables.end(); ++obsit)
74 void o815::parseArgs(int argc, char **argv) {
77 while( (opt = getopt(argc, argv, "L:N:S:E:o:O:c:C:w:i:j:")) != -1 )
80 listArg(comargs.lsize, 2, optarg);
83 comargs.nmeas = atoi(optarg);
86 comargs.nskip = atoi(optarg);
89 comargs.nequi = atoi(optarg);
92 comargs.obscache.first = optarg;
93 comargs.obscache.second = 1;
96 comargs.obscache.first = optarg;
97 comargs.obscache.second = 2;
100 comargs.confcache.first = optarg;
101 comargs.confcache.second = 1;
104 comargs.confcache.first = optarg;
105 comargs.confcache.second = 2;
108 comargs.outdir = optarg;
111 comargs.idonly = atoi(optarg);
114 comargs.showjobnum = atoi(optarg);
119 void o815::listArg(int *target, int tlen, char *listarg) {
122 for( int pos=0; pos<strlen(listarg); pos++ )
123 if( listarg[pos] == ':' ) nargs++;
126 for(int i=0; i<tlen; i++) target[i] = atoi(listarg);
129 target[0] = atoi(strtok(listarg, ":"));
130 for(int i=0; i<nargs; i++)
131 target[i+1] = atoi(strtok(NULL, ":"));
135 string o815::headMaster()
139 hm << "-L" << comargs.lsize[0] << "_" << comargs.lsize[1] << "-E" << comargs.nequi << "-S" << comargs.nskip << "-N" << comargs.nmeas
140 << paraQ->rangeString();
146 if(comargs.outdir=="") {
147 MPI_Barrier(MPI_COMM_WORLD);
149 cout << "#end" << endl << flush;
155 int o815::nextParas()
157 if( paraQ->nextParas() ) {
158 for (vector<string>::iterator parait = paraQ->allParaIds.begin(); parait != paraQ->allParaIds.end(); ++parait)
159 hypercache::setPara(*parait, (*paraQ)[*parait]);