Quantcast
Viewing all articles
Browse latest Browse all 3270

Run-time diagnostics for shape mismatches in array assignments possible?

This is based on discussions in this thread at comp.lang.fortran: https://groups.google.com/forum/#!topic/comp.lang.fortran/OCWxsF-Tm0U.

The following simple code compiles with no errors or warnings with Intel Fortran and raises no run-time exceptions during the i=j array assignment at line 17 even though the array extents are different (as noted on the comp,lang.fortran forum, NAgFor does give a run-time error).  Run-time diagnostics is set to /check:all.  Is it possible to give some run-time diagnostics here?

module m

   implicit none

contains

   subroutine s ( i )

      !.. Argument list
      integer, intent(inout) :: i(:)

      !.. Local variables
      integer :: j(2)

      !..
      j = 42
      i = j

   end subroutine s

end module m

program p

   use m, only : s

   implicit none

   integer :: ia(1)

   ia = 0
   call s(ia)
   write (*,*) " ia = ", ia

   stop

end program p

Upon execution,

  ia =  42
Press any key to continue . . .

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>