Commit 81a45bf9994e727f9820c7900f477575ef83c699

Authored by Jean-Baptiste CAYROU
1 parent 5059c9af

Fix bug with GLog

Showing 1 changed file with 20 additions and 8 deletions
src/ctobssim/ctobssim.cpp
... ... @@ -267,17 +267,23 @@ void ctobssim::run(void)
267 267 #pragma omp parallel
268 268 {
269 269 //each thread has his own variable;
270   - GLog wrklog(log);
  270 + GLog wrklog;
  271 +
  272 + //Copy configuration
  273 + wrklog.date(log.date());
  274 + wrklog.name(log.name());
  275 +
  276 + // Set a big value to block the flush
  277 + wrklog.max_size(10000000);
271 278  
272 279 #pragma omp for
273 280 // Loop over all observation in the container
274 281 for (int i = 0; i < m_obs.size(); ++i) {
275   -
276 282 // Get CTA observation
277 283 GCTAObservation* obs = dynamic_cast<GCTAObservation*>(&m_obs[i]);
278 284  
279 285 // Continue only if observation is a CTA observation
280   - if (obs != NULL) {
  286 + if (obs != NULL) {
281 287 // Write header for observation
282 288 if (logTerse()) {
283 289 if (obs->name().length() > 1) {
... ... @@ -286,20 +292,26 @@ void ctobssim::run(void)
286 292 else {
287 293 wrklog.header3("Observation");
288 294 }
289   - }
  295 + }
290 296 // Increment counter
291 297 n_observations++;
292   -
  298 +
293 299 // Simulate source events
294 300 simulate_source(obs, m_obs.models(),m_rans[i],&wrklog);
295   -
  301 +
296 302 // Simulate source events
297 303 simulate_background(obs, m_obs.models(),m_rans[i],&wrklog);
298   -
  304 +
299 305 } // endif: CTA observation found
300   -
  306 +
301 307 } // endfor: looped over observations
302 308  
  309 + // Add wrklog to log
  310 + #pragma omp critical (log)
  311 + {
  312 + log<<wrklog;
  313 + }
  314 +
303 315 } // end pragma omp parallel
304 316  
305 317 // If more than a single observation has been handled then make sure that
... ...