Commit 60aa959e99bc33ca3d176a0eccf5fa089b1fd94c

Authored by Jürgen Knödlseder
1 parent 830ce1be

Test catching of exception within critical OpenMP block

Showing 1 changed file with 14 additions and 5 deletions
src/support/ctool.cpp
@@ -594,7 +594,8 @@ GEbounds ctool::create_ebounds(void) @@ -594,7 +594,8 @@ GEbounds ctool::create_ebounds(void)
594 594
595 // Make loading of energy boundaries OpenMP thread save 595 // Make loading of energy boundaries OpenMP thread save
596 #pragma omp critical(ctool_create_ebounds1) 596 #pragma omp critical(ctool_create_ebounds1)
597 - { 597 + //{
  598 + try {
598 599
599 // Open energy boundary file using the EBOUNDS or ENERGYBINS 600 // Open energy boundary file using the EBOUNDS or ENERGYBINS
600 // extension or energy values using the ENERGIES extension. 601 // extension or energy values using the ENERGIES extension.
@@ -624,8 +625,11 @@ GEbounds ctool::create_ebounds(void) @@ -624,8 +625,11 @@ GEbounds ctool::create_ebounds(void)
624 "file \""+ebinfile+"\". Please specify a " 625 "file \""+ebinfile+"\". Please specify a "
625 "valid energy binning file."; 626 "valid energy binning file.";
626 } 627 }
627 -  
628 - } // end: omp critical section 628 + }
  629 + catch (const std::exception& e) {
  630 + msg = e.what();
  631 + }
  632 + //} // end: omp critical section
629 633
630 } // endif: no extension name specified 634 } // endif: no extension name specified
631 635
@@ -635,7 +639,8 @@ GEbounds ctool::create_ebounds(void) @@ -635,7 +639,8 @@ GEbounds ctool::create_ebounds(void)
635 639
636 // Make loading of energy boundaries OpenMP thread save 640 // Make loading of energy boundaries OpenMP thread save
637 #pragma omp critical(ctool_create_ebounds2) 641 #pragma omp critical(ctool_create_ebounds2)
638 - { 642 + //{
  643 + try {
639 644
640 // Open energy boundary file 645 // Open energy boundary file
641 GFits file(ebinfile.url()); 646 GFits file(ebinfile.url());
@@ -669,7 +674,11 @@ GEbounds ctool::create_ebounds(void) @@ -669,7 +674,11 @@ GEbounds ctool::create_ebounds(void)
669 674
670 } // endelse: extension name was present in FITS file 675 } // endelse: extension name was present in FITS file
671 676
672 - } // end: omp critical section 677 + }
  678 + catch (const std::exception& e) {
  679 + msg = e.what();
  680 + }
  681 + //} // end: omp critical section
673 682
674 } // endelse: loaded energy boundaries from table extension 683 } // endelse: loaded energy boundaries from table extension
675 684