0

I have several Fortran codes to run and sometimes I get an exception (segmentation fault for example):

  Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

This is not a big deal because a correction is possible. However, it stops the flow of the other execution with:

Backtrace for this error:

waiting at this time. With automatic testing, I do not care at this point about the backtrace and just want to display an error and I will come back to it later.

How can I prevent the program printing the backtrace for the error so that it just returns a value like 42?

I use gfortran 4.9.2.

Romain Picot
  • 255
  • 1
  • 13
  • What do you mean by *"just return a value"*? Print on the screen? Return the value to the operating system? How do you compile your code? Show all your compiler flags please. – Vladimir F Героям слава Oct 23 '17 at 14:29
  • @VladimirF By just "return a value" I mean have something like "STOP 1". My compile line is `gfortran code.f90 -O3 -m64 -o code` where code will have several value – Romain Picot Oct 23 '17 at 14:38
  • You would have to trap the exceptions. That is not possible in Fortran, it is a low-level OS-specific thing done in C. https://stackoverflow.com/questions/2663456/how-to-write-a-signal-handler-to-catch-sigsegv – Vladimir F Героям слава Oct 23 '17 at 14:45
  • Oh! unfortunate. I think I will try to work around and correct every mistake then – Romain Picot Oct 23 '17 at 14:48
  • 1
    If you run the automated with an external tool that just starts Fortran executables, it is at that level that you can ask for "retries". Your sentence "it stops the flow of the other execution with:" makes me wonder what "the other execution is". – Pierre de Buyl Oct 23 '17 at 15:19
  • I'd not let errors sit around to "deal with them later". It's going to bite you. – Fl.pf. Oct 27 '17 at 04:48

0 Answers0