Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Shape conformance

forall
Beginner
378 Views

I observed the following suspect behaviour in array arithmetic in Compaq and Intel compilers. From my understanding it violates the shape conformance standard and is inconsistent: why should the array attribute (allocatable or fixed size) matter?

!*****************************************************************
program test_arrayShapeArithmetic
! Purpose: test array shape arithmetic.
! From my understanding lines labelled version A and version B
! are illegal in Fortran (array shapes do not conform).
! However, if the arrays are declared as "allocatable" the
! error is not flagged.Also,combinations of lines 1A,1B,2A,2B
! behave inconsistently.
!---
! Suspect behaviour observed on
! * CVF 6.6.B
! * IVF 7.1
implicit none
! Variable definitions
integer,parameter::n=10
!real,allocatable :: a(:),b(:) ! Version 1
real :: a(n),b(n) ! Version 2
! start procedure here
!allocate(a(n),b(n)) ! Version 1
a(:)=4; b(:)=5
write(*,*) "Shape of A:",shape(a(::2))
write(*,*) "Shape of B:",shape(b(::3))
!a=b ! Version A
a(1:n:4)=b ! Version B
write(*,*) "Addition of 'a+b' successful"
pause
! end procedure here
endprogram test_arrayShapeArithmetic
!*****************************************************************

0 Kudos
1 Reply
Steven_L_Intel1
Employee
378 Views
Neither of these compilers do run-time shape checking. (The Intel 7.1 compiler may have done it in some situations.) If the program violates the standard's rules on shape conformance, the results are unpredictable.
We'd like to add shape checking to a future version.
0 Kudos
Reply