@@ -35,7 +35,6 @@ along with PhyloBayes. If not, see <http://www.gnu.org/licenses/>.
35
35
#include " Parallel.h"
36
36
#include < iostream>
37
37
#include < fstream>
38
- #include < limits>
39
38
40
39
using namespace std ;
41
40
@@ -182,16 +181,9 @@ class Model {
182
181
}
183
182
184
183
process->SetTopoBurnin (topoburnin);
185
- process->SetErrorHandling (true );
186
-
187
- if (myid == 0 && nprocs > process->GetNsite ())
188
- {
189
- cerr << " error: More processors than sites" ;
190
- exit (1 );
191
- }
192
184
}
193
185
194
- Model (string inname, int myid, int nprocs, bool catch_errors ) {
186
+ Model (string inname, int myid, int nprocs) {
195
187
196
188
name = inname;
197
189
@@ -259,13 +251,6 @@ class Model {
259
251
// cerr << "RESTORE SETSIZE\n";
260
252
process->SetSize (size);
261
253
// cerr << "reset size to " << process->GetSize() << '\n';
262
- process->SetErrorHandling (catch_errors);
263
-
264
- if (myid == 0 && nprocs > process->GetNsite ())
265
- {
266
- cerr << " error: More processors than sites" ;
267
- exit (1 );
268
- }
269
254
}
270
255
271
256
void ToStream (ostream& os, bool header) {
@@ -286,22 +271,12 @@ class Model {
286
271
process->WaitLoop ();
287
272
}
288
273
289
- void Move (double tuning, int nrep) {
274
+ double Move (double tuning, int nrep) {
275
+ double total = 0 ;
290
276
for (int rep=0 ; rep<nrep; rep++) {
291
- stringstream backup;
292
- process->ToStream (backup);
293
- while (process->Move (tuning))
294
- {
295
- // cerr << "warning: numerical error in move, retrying...\n";
296
- backup.clear ();
297
- backup.seekg (0 );
298
- process->FromStream (backup);
299
- MESSAGE signal = BCAST_TREE;
300
- MPI_Bcast (&signal ,1 ,MPI_INT,0 ,MPI_COMM_WORLD);
301
- process->GlobalBroadcastTree ();
302
- process->GlobalUnfold ();
303
- }
277
+ total += process->Move (tuning);
304
278
}
279
+ return total / nrep;
305
280
}
306
281
307
282
int RunningStatus () {
@@ -317,16 +292,14 @@ class Model {
317
292
}
318
293
319
294
void Run (int burnin) {
320
- stringstream ss;
321
295
322
296
if (burnin != 0 ) {
323
297
if (GetSize () < burnin) {
324
298
process->SetBurnin (true );
325
299
}
326
300
}
327
301
ofstream ros ((name + " .run" ).c_str ());
328
- ss << 1 << ' \n ' ;
329
- ros << ss.str ();
302
+ ros << 1 << ' \n ' ;
330
303
ros.close ();
331
304
332
305
while (RunningStatus () && ((until == -1 ) || (GetSize () < until))) {
@@ -341,37 +314,27 @@ class Model {
341
314
ofstream os ((name + " .treelist" ).c_str (), ios_base::app);
342
315
process->SetNamesFromLengths ();
343
316
process->RenormalizeBranchLengths ();
344
- ss.str (" " );
345
- GetTree ()->ToStream (ss);
317
+ GetTree ()->ToStream (os);
346
318
process->DenormalizeBranchLengths ();
347
- os << ss.str ();
348
319
os.close ();
349
320
350
321
ofstream tos ((name + " .trace" ).c_str (), ios_base::app);
351
- ss.str (" " );
352
- Trace (ss);
353
- tos << ss.str ();
322
+ Trace (tos);
354
323
tos.close ();
355
324
356
325
ofstream mos ((name + " .monitor" ).c_str ());
357
- ss.str (" " );
358
- process->Monitor (ss);
359
- mos << ss.str ();
326
+ process->Monitor (mos);
360
327
mos.close ();
361
328
362
329
ofstream pos ((name + " .param" ).c_str ());
363
- pos.precision (numeric_limits<double >::digits10);
364
- ss.str (" " );
365
- ToStream (ss,true );
366
- pos << ss.str ();
330
+ pos.precision (12 );
331
+ ToStream (pos,true );
367
332
pos.close ();
368
333
369
334
if (saveall) {
370
335
ofstream cos ((name + " .chain" ).c_str (),ios_base::app);
371
- cos .precision (numeric_limits<double >::digits10);
372
- ss.str (" " );
373
- ToStream (ss,false );
374
- cos << ss.str ();
336
+ cos .precision (12 );
337
+ ToStream (cos ,false );
375
338
cos .close ();
376
339
}
377
340
0 commit comments