- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
!*****************************************************************
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page