Commit 1baf29abb2a54f9373731d78e4b2f940433d593d

Authored by Jürgen Knödlseder
1 parent b1d2c005

Added critical statement in GCTAObservation (#2192)

Added OpenMP critical wrapper to GCTAObservation::load() to prevent loading multiple files simultaneously
Updated GCTAEventList to wrap testing of the fits file (#2192)
ChangeLog
... ... @@ -4,7 +4,8 @@
4 4 ================================
5 5  
6 6 Correct background interpolation in GCTACubeBackground::operator() (#2268)
7   - Correct GModelSpatialComposite::copy_members() bug.
  7 + Fix OpenMP segfault issue when fetching CTA events (#2192)
  8 + Correct GModelSpatialComposite::copy_members() bug
8 9  
9 10  
10 11 2017-08-24
... ...
doc/source/admin/release_history/1.4.3.rst
... ... @@ -12,4 +12,6 @@ The following bugs have been fixed:
12 12  
13 13 * [`2268 <https://cta-redmine.irap.omp.eu/issues/2268>`_] -
14 14 Correct background interpolation in ``GCTACubeBackground::operator()``
  15 +* [`2192 <https://cta-redmine.irap.omp.eu/issues/2192>`_] -
  16 + Fix OpenMP segfault issue when fetching CTA events
15 17 * Correct bug in ``GModelSpatialComposite::copy_members()``
... ...
inst/cta/src/GCTAEventList.cpp
... ... @@ -705,14 +705,6 @@ void GCTAEventList::fetch(void) const
705 705 // Continue only if the file name is not empty
706 706 if (!m_filename.is_empty()) {
707 707  
708   - // Throw an exception if the file does not exist
709   - if (!m_filename.exists()) {
710   - std::string msg = "File \""+m_filename+"\" not found. "
711   - "Cannot fetch events. Maybe the file has "
712   - "been deleted in the meantime.";
713   - GException::file_error(G_FETCH, msg);
714   - }
715   -
716 708 // Initialise exception flag
717 709 bool has_exception = false;
718 710  
... ... @@ -721,19 +713,18 @@ void GCTAEventList::fetch(void) const
721 713 #pragma omp critical(GCTAEventList_fetch)
722 714 {
723 715 try {
724   -
725 716 // Open FITS file
726 717 GFits fits(m_filename);
727   -
  718 +
728 719 // Initialise events extension name
729 720 std::string extname = fits.filename().extname(gammalib::extname_cta_events);
730   -
  721 +
731 722 // Get event list HDU
732 723 const GFitsTable& events = *fits.table(extname);
733   -
  724 +
734 725 // Load event data
735 726 read_events(events);
736   -
  727 +
737 728 // Close FITS file
738 729 fits.close();
739 730  
... ...
inst/cta/src/GCTAObservation.cpp
... ... @@ -1132,18 +1132,20 @@ void GCTAObservation::write(GFits&amp; fits, const std::string&amp; evtname,
1132 1132 ***************************************************************************/
1133 1133 void GCTAObservation::load(const GFilename& filename)
1134 1134 {
1135   - // Store event filename
1136   - m_eventfile = filename;
1137   -
1138   - // Open FITS file
1139   - GFits fits(filename);
1140   -
1141   - // Read data
1142   - read(fits);
1143   -
1144   - // Close FITS file
1145   - fits.close();
1146   -
  1135 + #pragma omp critical(GCTAObservation_load)
  1136 + {
  1137 + // Store event filename
  1138 + m_eventfile = filename;
  1139 +
  1140 + // Open FITS file
  1141 + GFits fits(filename);
  1142 +
  1143 + // Read data
  1144 + read(fits);
  1145 +
  1146 + // Close FITS file
  1147 + fits.close();
  1148 + }
1147 1149 // Return
1148 1150 return;
1149 1151 }
... ...