- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This appears to work in initalization expression but not in assignment. Why is that? For example:
integer,dimension(2,3) :: x=[[1,2,3],[4,5,6]],y
y = [[1,2,3],[4,5,6]]
print *,x
print *,y
end
ifort mat.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.10.0 Build 20230609_000000
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
mat.f90(2): error #6366: The shapes of the array expressions do not conform. [Y]
y = [[1,2,3],[4,5,6]]
^
compilation aborted for mat.f90 (code 1)
I do realize I can use a rank 1 literal and the reshape function to get around this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The initialization is also an error, one that the Intel compiler does not detect, even with standards warnings on, so that's a bug. The standard says:
If initialization appears for a nonpointer entity,
• its type and type parameters shall conform as specified for intrinsic assignment (10.2.1.2)
• if the entity has implied shape, the rank of initialization shall be the same as the rank of the entity;
• if the entity does not have implied shape, initialization shall either be scalar or have the same shape as the entity.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Array constructors are always rank 1, reshape is what you have to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The initialization is also an error, one that the Intel compiler does not detect, even with standards warnings on, so that's a bug. The standard says:
If initialization appears for a nonpointer entity,
• its type and type parameters shall conform as specified for intrinsic assignment (10.2.1.2)
• if the entity has implied shape, the rank of initialization shall be the same as the rank of the entity;
• if the entity does not have implied shape, initialization shall either be scalar or have the same shape as the entity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I filed a bug report on missing error message for the initialization based on what Steve cited from the Fortran Standard. Bug report is CMPLRLLVM-57399.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HA! This turned out to be a duplicate bug report and the fix is ready for release with 2024.2.0. Look for that version in mid-2024!

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