title: Fortran Arithmetic Exception
body: <p>This is a short question but I have tried to give as much detail as possible.</p>
  
  <p>I am compiling an old, but still actively developed, fortran code (f77 standard) on Scientific Linux. The recommended compilers for this code are ifort and gfortran. Using gfortran I can compile and run this code. However, if I make with the DEBUG=1 flag the code compiles but terminates with a SEG FAULT. Stepping through with gdb leads to the following source of error:</p>
  
  <pre><code>REAL*4 TIME_CURRENT     
  CALL CPU_TIME(TIME_CURRENT) 
  ISECS = 100*INT(TIME_CURRENT)  
  </code></pre>
  
  <p>The program terminates with:</p>
  
  <pre><code>Program received signal SIGFPE, Arithmetic exception. 
  timer (init=1, isecs=0) at myprog.f:1818
  1818 ISECS = 100*INT(TIME_CURRENT)
  </code></pre>
  
  <p>If I stop execution on line 1818 and examine ISECS and TIME_CURRENT I get:</p>
  
  <pre><code>(gdb) ptype(TIME_CURRENT)
  type = real(kind=4)
  (gdb) ptype(ISECS)
  type = integer(kind=4)
  </code></pre>
  
  <p>I've tried being more specific and using:</p>
  
  <pre><code>ISECS = 100*INT(TIME_CURRENT,4)
  </code></pre>
  
  <p>But it doesn't help. I fail to see how this could equate to an Arithmetic error?</p>
  
  <p>My (makefile generated) debug compile flags are:</p>
  
  <pre><code>gfortran -fno-automatic -m32 -O0 -g \
           -ffpe-trap=invalid,zero,overflow,underflow,precision -static-libgfortran
  </code></pre>
  
  <p>When I compile out of debug I no longer receive a SEG FAULT but and my compile flags are</p>
  
  <pre><code>gfortran -fno-automatic -m32 -O2 -ffast-math -static-libgfortran
  </code></pre>
  
  <p>I am not a fortran programmer so any assistance would be greatly appreciated. Please note, I am compiling on a 64bit system but forcing a 32bit compilation, as this is required.</p>