checking array bounds for actual arguments

Janus Weil jaydub66@googlemail.com
Tue Sep 25 15:08:00 GMT 2007


Hi all,
I have a question regarding the following code sample:


program main
implicit none
real x(2),y(3),z(4)

call a(x)
call a(y)
call a(z)

contains

  subroutine a(x)
    implicit none
    real x(3)
    write(*,*) 'x=',x
  end subroutine a

end program main


For the first call of the subroutine I get this warning:

call a(x)
      1
Warning: Actual argument contains too few elements for dummy argument
'x' (2/3) at (1)

But for "call a(z)" I don't get any warning, although the shape of the
array does not match either. Is there any way to make gfortran issue a
warning for such a case? And if not, do think it would make sense to
implement such a check?
Cheers,
Janus



More information about the Fortran mailing list