Commit dc4622a12812d1ad6e0f17e1afd1305cf300f230

Authored by Josh Cardenzana
1 parent 0b1c5b6e

Openmp support works for cabin (#1970)

Finalized a workaround to the python wrapper issue that caused the 'ctbin::run()' method to crash.
Showing 1 changed file with 13 additions and 20 deletions
src/ctbin/ctbin.cpp
... ... @@ -235,26 +235,21 @@ void ctbin::run(void)
235 235 // Write header into logger
236 236 log_header1(TERSE, gammalib::number("Bin observation", m_obs.size()));
237 237  
  238 + // Extract out all of the non-NULL observations
  239 + log_header2(TERSE, "Executing pre-loop");
  240 + std::vector<GCTAObservation*> obs_list(0);
  241 + for (GCTAObservation* obs = first_unbinned_observation(); obs != NULL;
  242 + obs = next_unbinned_observation()) {
  243 + obs_list.push_back(obs);
  244 + }
  245 +
  246 + // Write sub-header into logger
  247 + log_header2(TERSE, "Filling observations");
  248 +
238 249 // Loop over all unbinned CTA observations in the container
239 250 #pragma omp parallel for
240   - for (int o=0; o<m_obs.size(); o++) {
241   - GCTAObservation* obs = dynamic_cast<GCTAObservation*>(m_obs[o]);
242   -
243   - // Skip if the observation is NULL. This can happen if the observation
244   - // isn't a CTA observation
245   - if (obs == NULL) {
246   - std::string msg = " Skipping "+obs->instrument()+" observation";
247   - log_string(NORMAL, msg);
248   - continue;
249   - }
250   -
251   - // Skip observation if we have a binned observation
252   - if (obs->eventtype() == "CountsCube") {
253   - obs = NULL;
254   - std::string msg = " Skipping binned "+obs->instrument()+" observation";
255   - log_string(NORMAL, msg);
256   - continue;
257   - }
  251 + for (int oindx=0; oindx<obs_list.size(); ++oindx) {
  252 + GCTAObservation* obs = obs_list[oindx];
258 253  
259 254 // Fill the cube
260 255 fill_cube(obs);
... ... @@ -282,8 +277,6 @@ void ctbin::run(void)
282 277 publish();
283 278 }
284 279  
285   -log_string(NORMAL, "RUNNING HAS FINISHED");
286   -
287 280 // Return
288 281 return;
289 282 }
... ...