- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer :: arr(2,2) = [1,2,3,4] ! accepted
arr = [5,6,7,8] ! array shape mismatch complaint
If its acceptable in declaration, why isnt it acceptable inline?
Compiler obviously has ALL the info it needs about arr's shape
to make a DEFAULT FORTRAN DATA (no reshapewanted) assignment.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm. From my reading of the standard, the first shouldn't be accepted either. The standard says:
"If initialization is =initialization-expr, the object name becomes defined with the value determined from initialization-expr in accordance with the rules of intrinsic assignment (7.5.1.4)."
My guess is that the compiler is applying the more generous DATA statement rules, which don't allow you to specify an array constructor but merely a sequence of values.
BTW, I'm ignoring for now your use of the non-standard (in F95, but not F2003) square brackets for the array constructor, as these are not needed to demonstrate the problem.

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