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

Problem with parameterized derived type declared with ALLOCATABLE attribute

$
0
0

The following simple code compiles with no errors or warnings with Intel(R) Visual Fortran Compiler XE 15.0.1.148 but it generates a run-time error with the parameterized derived type that has an ALLOCATABLE attribute.  Is this due to incorrect code or a bug in Intel Fortran?

Thanks,

PROGRAM p

   USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : I4 => INT32, SP => REAL32, DP => REAL64, QP => REAL128

   IMPLICIT NONE

   TYPE :: t(k,n)
      INTEGER(I4), KIND :: k = SP
      INTEGER(I4), LEN  :: n = 1
      REAL(k)           :: x(n)
   END TYPE t

   !.. Local variables
   TYPE(t) :: boo
   TYPE(t(QP,2)) :: foo
   TYPE(t(DP,:)), ALLOCATABLE :: goo
   INTEGER(I4) :: Istat
   CHARACTER(LEN=80) :: ErrAlloc

   PRINT *, " Test #72: PDT"
   PRINT *

   PRINT *, " boo%n = ", boo%n
   boo%x = REAL(-1.0, KIND=boo%k)
   PRINT *, " boo%x = ", boo%x
   PRINT *

   PRINT *, " foo%n = ", foo%n
   foo%x = REAL(0.0, KIND=foo%k)
   PRINT *, " foo%x = ", foo%x
   PRINT *

   ALLOCATE( t(DP,3) :: goo, STAT=Istat, ERRMSG=ErrAlloc)
   IF (Istat /= 0) THEN
      PRINT *, " Allocation of goo failed: STAT = ", Istat, "; error message = ", ErrAlloc
   END IF
   PRINT *, " goo%n = ", goo%n
   PRINT *, " Shape of goo%x is (", LBOUND(goo%x, DIM=1), ":", UBOUND(goo%x, DIM=1), ")"
   goo%x = REAL(1.0, KIND=goo%k)
   PRINT *, " goo%x = ", goo%x
   PRINT *

   !..
   STOP

END PROGRAM p
  Test #72: PDT

  boo%n =  1
  boo%x =  -1.000000

  foo%n =  2
  foo%x =  0.00000000000000000000000000000000
 0.00000000000000000000000000000000

  goo%n =  3
  Shape of goo%x is ( 1 : 3 )
forrtl: severe (408): fort: (2): Subscript #1 of the array X has value 1 which i
s greater than the upper bound of 0

Image              PC        Routine            Line        Source
TestFor32.exe      01135C94  Unknown               Unknown  Unknown
TestFor32.exe      01133537  _MAIN__                    39  TestFor.f90
TestFor32.exe      011A53E2  Unknown               Unknown  Unknown
TestFor32.exe      011A5DAA  Unknown               Unknown  Unknown
TestFor32.exe      011A5EFD  Unknown               Unknown  Unknown
kernel32.dll       7576338A  Unknown               Unknown  Unknown
ntdll.dll          7735BF32  Unknown               Unknown  Unknown
ntdll.dll          7735BF05  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>