- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
REAL*8n2mid(1,NZ-1)
REAL*8n0mid(3,NZ-1)
n2mid=n0mid([1],:)!No Problem
n2mid=n0mid(1,:)!The compiler issues the following error message:
error#6366:Theshapesofthearrayexpressionsdonotconform.[N2MID]
n2mid=n0mid(1,:)
--------^
My question: What's the difference of this two kind of array indexing? When and How to use the square bracket [] correctlly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
REAL*8n2mid(1,NZ-1)
REAL*8n0mid(3,NZ-1)
n2mid=n0mid([1],:)!No Problem
n2mid=n0mid(1,:)!The compiler issues the following error message:
error#6366:Theshapesofthearrayexpressionsdonotconform.[N2MID]
n2mid=n0mid(1,:)
--------^
My question: What's the difference of this two kind of array indexing? When and How to use the square bracket [] correctlly?
[1], traditionally spelled (/1/), is an array constructor. The resulting array has rank 1 and has 1 element.
Thus, n0mid([1], :) is a rank-2 array, whose shape is [1, NZ-1].
1 is a scalar, thus n0mid(1, :) is a rank-1 array, whose shape is [NZ-1].
You may assign a rank-2 array to another rank-2 array (provided that the shapes are identical, which is the case). However, you may not assign a rank-1 array to a rank-2 array -- that doesn't have mathematical sense.
Rule of thumb: every scalar in an array-indexing expression reduces the rank of the resulting array for 1. For example, if A is an array, A(1) has rank 1-1=0=scalar, while A(1:2) or A([1,2]) is still a rank-1 array.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
REAL*8n2mid(1,NZ-1)
REAL*8n0mid(3,NZ-1)
n2mid=n0mid([1],:)!No Problem
n2mid=n0mid(1,:)!The compiler issues the following error message:
error#6366:Theshapesofthearrayexpressionsdonotconform.[N2MID]
n2mid=n0mid(1,:)
--------^
My question: What's the difference of this two kind of array indexing? When and How to use the square bracket [] correctlly?
[1], traditionally spelled (/1/), is an array constructor. The resulting array has rank 1 and has 1 element.
Thus, n0mid([1], :) is a rank-2 array, whose shape is [1, NZ-1].
1 is a scalar, thus n0mid(1, :) is a rank-1 array, whose shape is [NZ-1].
You may assign a rank-2 array to another rank-2 array (provided that the shapes are identical, which is the case). However, you may not assign a rank-1 array to a rank-2 array -- that doesn't have mathematical sense.
Rule of thumb: every scalar in an array-indexing expression reduces the rank of the resulting array for 1. For example, if A is an array, A(1) has rank 1-1=0=scalar, while A(1:2) or A([1,2]) is still a rank-1 array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[1], traditionally spelled (/1/), is an array constructor. The resulting array has rank 1 and has 1 element.
Thus, n0mid([1], :) is a rank-2 array, whose shape is [1, NZ-1].
1 is a scalar, thus n0mid(1, :) is a rank-1 array, whose shape is [NZ-1].
You may assign a rank-2 array to another rank-2 array (provided that the shapes are identical, which is the case). However, you may not assign a rank-1 array to a rank-2 array -- that doesn't have mathematical sense.
Rule of thumb: every scalar in an array-indexing expression reduces the rank of the resulting array for 1. For example, if A is an array, A(1) has rank 1-1=0=scalar, while A(1:2) or A([1,2]) is still a rank-1 array.
Thank you very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
REAL*8n2mid(1,NZ-1)
REAL*8n0mid(3,NZ-1)
n2mid=n0mid([1],:)!No Problem
n2mid=n0mid(1,:)!The compiler issues the following error message:
error#6366:Theshapesofthearrayexpressionsdonotconform.[N2MID]
n2mid=n0mid(1,:)
--------^
My question: What's the difference of this two kind of array indexing? When and How to use the square bracket [] correctlly?
Why dont you declare
real*8 n2mid(nz-1)
Then, n2mid = n0mid(1,:) would be possible. An array of size 1 doesnt make sense to me... Why do you use it?
Markus

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