Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Parameterized derived type: unexpected run-time error with arrays of non-default bounds

$
0
0

The following simple code encounters an unexpected run-time error:

module m

   type, public :: t( m, n )
      private
      integer, len :: m
      integer, len :: n
      real         :: m_a( m:n )
   contains
      private
      procedure, pass(this), public :: init => init_a_t
   end type t

contains

   subroutine init_a_t( this )

      class(t(*,*)), intent(inout) :: this

      print *, " lbound of this%m_a = ", lbound(this%m_a, dim=1)
      print *, " ubound of this%m_a = ", ubound(this%m_a, dim=1)

      this%m_a = 0.0

      return

   end subroutine init_a_t

end module m

program p

   use m, only : t

   implicit none

   type(t(-1,1)) :: foo

   call foo%init()

   stop

end program p

Upon execution with Intel Fortran compiler version 2015, update 4:

  lbound of this%m_a =  -1
  ubound of this%m_a =  1
forrtl: severe (408): fort: (11): Subscript #1 of the array M_A has value -1 whi
ch is less than the lower bound of 0

Image              PC                Routine            Line        Source

p64.exe            000000013FF3BAD0  Unknown               Unknown  Unknown
p64.exe            000000013FF316EE  M_mp_INIT_A_T              22  m.f90
p64.exe            000000013FF31931  MAIN__                      9  p.f90
p64.exe            000000013FFBDE6E  Unknown               Unknown  Unknown
p64.exe            000000013FFBE93C  Unknown               Unknown  Unknown
p64.exe            000000013FFBEA7E  Unknown               Unknown  Unknown
kernel32.dll       00000000776159DD  Unknown               Unknown  Unknown
ntdll.dll          00000000779AA551  Unknown               Unknown  Unknown
Press any key to continue . . .

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



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