A question on GFortran

Angelo Graziosi Angelo.Graziosi@roma1.infn.it
Wed Dec 27 20:35:00 GMT 2006


On Wed, 27 Dec 2006, Tim Prince wrote:

> Angelo Graziosi wrote:
> > 
> > Let us consider the following program
> > ----------------------------------------------------
> > $ cat h.F
> >       program hello
> >       implicit none
> >       integer i
> >       i = 0
> >       if (i.eq.0) stop 99901
> >       write(*,*) 'Hello!'
> >       end
> > ----------------------------------------------------
> > 
> > 
> > and the following script
> > ------------------------------------
> > $ cat run_h.sh
> > #!/bin/bash
> > 
> > build()
> > {
> > 
> > ./h || return 1
> > 
> > echo "Hello"
> > }
> > 
> > build
> > 
> > ------------------------------------
> > 
> > 
> > When one builds 'h.F' with G77, running the script, the result is:  
> > -----------------------------------------
> > g77 h.F -o h
> > 
> > $ ./run_h.sh
> > STOP 99901 statement executed
> > Hello
> > -----------------------------------------
> > 
> > 
> > If, instead, one build 'h.F' with GFortran:
> > ---------------------------------------
> > $ gfc h.F -o h
> >   
> > $ ./run_h.sh
> > STOP 99901
> > ---------------------------------------
> > 
> > 
> > i.e. in the first case the script line
> > 
> >    echo "Hello"
> > 
> > is executed, in the second NO.
> > 
> > This is because G77 does not intercept the execution of
> > 
> >   STOP 99901
> > 
> > like an abnormal termination.
> > 
> > 
> > I would ask if there is a GFC option or environment variable to set so
> > that the GFC behaviour is similar to that of G77.
> > 
> 

It is not clear what you mean

> I tried your example with g77 3.4.4, and it does not exhibit the bug 
> which you would like gfortran to support.
> 

On Cygwin with g77-3.4.4-3 and on GNU/Linux with g77-3.4.6 I observe the
following:
-----------------------------------------------
g77 h.F -o h

$ ./run_h.sh
STOP 99901 statement executed
Hello
-----------------------------------------------


while on Cygwin with gfc-20061210 and on GNU/Linux with gfc-20061205
---------------------------------------------------
$ gfc h.F -o h
  
$ ./run_h.sh
STOP 99901
---------------------------------------------------

The bug is on G77 side or GFC ? 



Tobias Schlüter wrote:

>
> I think gfortran does The Right Thing
>

If I have understood, the correct behaviour is that the compiler should
consider

    STOP 99901

as an abnormal termination. In this case it looks as a G77 bug.

Is this right?


For the sake of completeness if one changes 


  STOP 99901      with    STOP '99901'


on both systems the result is
----------------
using G77

$ ./run_h.sh
STOP 99901 statement executed
Hello
----------------


----------------
using GFC

$ ./run_h.sh
STOP 99901
Hello
----------------


Cheers,

  Angelo.



More information about the Fortran mailing list