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 have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

Assignment between arrays of size 1

tplaakso
Beginner
681 Views
Hi,

Maybe the following should compile:
[fortran]program test integer, dimension(1) :: x, y x = 1 y(1) = x end program test [/fortran] Instead, I get (OSX):
[plain][octopus] misc > ifort --version ifort (IFORT) 12.1.3 20120130 Copyright (C) 1985-2012 Intel Corporation. All rights reserved. [octopus] misc > ifort -free test.f test.f(6): error #6366: The shapes of the array expressions do not conform. y(1) = x --^ compilation aborted for test.f (code 1) [/plain]
Teemu Laakso
0 Kudos
3 Replies
tplaakso
Beginner
681 Views
Sorry, my mistake. y(1)=x should be written y(1:1)=x, of course. No problem here, whatsoever.

Teemu
0 Kudos
Steven_L_Intel1
Employee
681 Views
Or better:

y=x
0 Kudos
tplaakso
Beginner
681 Views
True. For me, this silly example reminded that the correct way to extrapolate to smaller subarray size is x(1:3), x(1:2), and x(1:1) - NOT x(1).

x(1:1) is rank 1 and x(1) is rank 0.

Teemu
0 Kudos
Reply