bug in to_f90 regarding INTENT

beliavsky_at_aol.com
Date: 01/27/04


Date: 27 Jan 2004 14:42:40 -0800

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.



Relevant Pages

  • Re: bug in to_f90 regarding INTENT
    ... > I think I have found a small bug in Alan Miller's useful to_f90.f90 ... > fixed format F77 form to free format and makes other stylistic ... The F77 program ...
    (comp.lang.fortran)
  • Re: Bit Concatenation
    ... (vis-a-vis F77). ... we went through our F77 code and produced F90 ... codes for an F77 compiler can be significant ...
    (comp.lang.fortran)
  • Re: Refactorings for Fortran and HighPerformance
    ... For old f77 code, ... compiler to produce as fast code as a f77 compiler would (note that, ... f77 code is perfectly valid f90). ...
    (comp.lang.fortran)
  • Re: Bugs at my web site
    ... but so are F95 compilers. ... > can get a free F77 compiler. ... > goes along with a bunch of other F77 code, ...
    (comp.lang.fortran)
  • Re: f77 GONE! HELP
    ... show up with f77. ... how can I install f77 on mandriva 2006? ... gfortran should compile your f77 code. ...
    (comp.lang.fortran)