Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Vector updating with implied DO does not work

Anders_S_1
New Contributor III
548 Views

Hi,

Tentatively I tried to update the second and third component in a integer vector with dimensions a(100,1,1):

a(5,1:1,1:1)=[2,3]

but the compiler discover that the two vectors had different shapes. How should this vector update be written?

Best regards

Anders S

0 Kudos
3 Replies
Arjen_Markus
Honored Contributor II
548 Views

The left-hand side is a single element of the array a, whereas the right-hand side is an array with two elements. The compiler is quite right here. I do not quite understand which elements of the array a you mean, but this should work:

a(2:3,1:1,1:1) = [2,3]

 

 

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
548 Views

Use: a(2:3,1,1) = [2,3] ! Where array a has dimension (100,1,1)

Jim Dempsey

0 Kudos
Anders_S_1
New Contributor III
548 Views

Hi everybody,

Thanks for your answers that made me think twice. It is embarassing to confess that I should define a as a vector a(100,2). Then 

a(5,1:2)=[2,3] works fine!

Sorry to have taken your time!  Vector usage apparently is not basic to everybody.

Best regards

Anders S

0 Kudos
Reply