Possible bug in gfortran: array sections in actual arguments

Clive Page clivegpage@googlemail.com
Wed Jan 28 17:13:00 GMT 2009


I think I may have found a bug in the way that gfortran handles array sections. 
  I had an image that I wanted to invert in the y-axis, so handed it over to a 
subroutine as an array section, e.g.
  array(:, ny:-:-1)
This didn't work, as shown below.

Here's a simple test program, which I think is valid Fortran.  By the way, using 
the triplet notation correctly inverts the array if used in an assignment 
statement, it is just the use in a procedure call which seems not to work properly.

module testy_mod
implicit none
contains
subroutine mysub(text, array)
character(len=*), intent(in) :: text
integer, intent(in) :: array(:,:)
integer :: j
print *, text
do j = 1, ubound(array,2)
    print '(10000i4)', array(:,j)
end do
end subroutine mysub
end module testy_mod

program testy
use testy_mod
implicit none
integer, parameter :: nx = 4, ny = 3
integer :: array(nx,ny)
data array / 1,2,3,4, 10,20,30,40, 100,200,300,400 /
call mysub('normal', array)
call mysub('y-inverted', array(:,ny:1:-1))
end program

Here are the results from using g95 (on Windows) which seems to work:
  normal
    1   2   3   4
   10  20  30  40
  100 200 300 400
  y-inverted
  100 200 300 400
   10  20  30  40
    1   2   3   4

And here's the same code run on gfortran on Windows:
  normal
    1   2   3   4
   10  20  30  40
  100 200 300 400
  y-inverted


[note, no output after the text "y-inverted"]

The version I'm using is:
GNU Fortran (GCC) 4.4.0 20090123 (experimental) [trunk revision 143587]

I tried to work out how to submit a bug using the gcc bugzilla, but it defeated 
me, sorry.

-- 
Clive Page



More information about the Fortran mailing list