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