bug in to_f90 regarding INTENT 
Author Message
 bug in to_f90 regarding INTENT

I think I have found a small bug in Alan Miller's useful to_f90.f90
program,  (downloadable at
http://www.*-*-*.com/ ) , which converts
fixed format F77 form to free format and makes other stylistic
changes.

The to_f90 program transforms some F77 subroutine argument
declarations so that they have INTENT(OUT), when I think they should
have INTENT(IN OUT).

Here is an example. The F77 program

        subroutine twice(xx)
        real xx
        xx = 2.0*xx
        end

        program xtwice
        xx = 3.0
        call twice(xx)
        print*,xx
        end

is transformed to

SUBROUTINE twice(xx)

! Code converted using TO_F90 by Alan Miller
! Date: 2004-01-27  Time: 17:16:02

REAL, INTENT(OUT)                        :: xx

xx = 2.0*xx
END SUBROUTINE twice

PROGRAM xtwice
xx = 3.0
CALL twice(xx)
PRINT*,xx
END PROGRAM xtwice

Because xx is declared INTENT(OUT), Compaq Visual fortran 6.6C
correctly gives the warning

inout.f90(9) : Warning: Variable XX is used before its value has been
defined
xx = 2.0*xx

There is nothing unusual about the F77 code above, except for its
brevity, so it appears to me that to_f90 subtly mistranslates a wide
range of F77 code.
Most compilers on most settings will print 6.0 as the output of the
program, but this is not guaranteed -- I asked about this in an
"intent(out) arguments" thread about a month ago.



Sun, 16 Jul 2006 06:42:40 GMT  
 bug in to_f90 regarding INTENT

Quote:
> I think I have found a small bug in Alan Miller's useful to_f90.f90
> program,  (downloadable at
> http://users.bigpond.net.au/amiller/to_f90.f90 ) , which converts
> fixed format F77 form to free format and makes other stylistic
> changes.

> The to_f90 program transforms some F77 subroutine argument
> declarations so that they have INTENT(OUT), when I think they should
> have INTENT(IN OUT).

> Here is an example. The F77 program

>         subroutine twice(xx)
>         real xx
>         xx = 2.0*xx
>         end

>         program xtwice
>         xx = 3.0
>         call twice(xx)
>         print*,xx
>         end

> is transformed to

> SUBROUTINE twice(xx)

> ! Code converted using TO_F90 by Alan Miller
> ! Date: 2004-01-27  Time: 17:16:02

> REAL, INTENT(OUT)                        :: xx

> xx = 2.0*xx
> END SUBROUTINE twice

> PROGRAM xtwice
> xx = 3.0
> CALL twice(xx)
> PRINT*,xx
> END PROGRAM xtwice

> Because xx is declared INTENT(OUT), Compaq Visual Fortran 6.6C
> correctly gives the warning

> inout.f90(9) : Warning: Variable XX is used before its value has been
> defined
> xx = 2.0*xx

> There is nothing unusual about the F77 code above, except for its
> brevity, so it appears to me that to_f90 subtly mistranslates a wide
> range of F77 code.
> Most compilers on most settings will print 6.0 as the output of the
> program, but this is not guaranteed -- I asked about this in an
> "intent(out) arguments" thread about a month ago.

Thanks for the message.
There are certainly bugs in to_f90.
I have used it a great deal, and always need to make corrections to the
translated code.
It is often extremely difficult to deduce the INTENT's of subroutine
arguments, when it is not my own code.

Feel free to make corrections to the code.
Cheers

--
Alan Miller
http://users.bigpond.net.au/amiller
Retired Statistician



Sun, 16 Jul 2006 19:30:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. overlap of INTENT(IN) and INTENT(OUT) arguments

2. Newbie question regarding SmallEiffel (potential compiler bug?)

3. Bug in latest snapshot, regarding Float#to_s

4. Regarding MAJOR FPU bug in Pentium II

5. beginner question regarding a bug.

6. Possible bug in tkMain regarding argv0

7. BUG: unknown (and therefore all autoloading routines) broken regarding namespace

8. Tcl8.0 bug regarding booleans

9. BUG: Tk4.0b3 Text Search regarding indices

10. New version of to_f90

11. to_f90

12. to_f90

 

 
Powered by phpBB® Forum Software