- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm having trouble with the ORDER parameter in the RESHAPE() intrinsic. If I don't use it, reshape() works just fine. However, if I use order, the array gets gibberish. With this program:
program test
implicit none
real, dimension(1:3, 1:3) :: matr
integer :: i
matr = reshape((/ (i, i=0,8) /), (/ 3, 3 /))
do i = lbound(matr, 1), ubound(matr, 1)
print *, matr(i,:)
end do
print *
matr = reshape((/ (i, i=1,9) /), (/ 3, 3 /), order=(/ 2, 1 /))
do i = lbound(matr, 1), ubound(matr, 1)
print *, matr(i,:)
end do
end program test
I get the following output:
0.0000000E+00 3.000000 6.000000
1.000000 4.000000 7.000000
2.000000 5.000000 8.000000
0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 -1.1987086E+09 -1.1987087E+09
1.0953484E+09 1.0934118E+09 -1.1987085E+09
In the case where order wasn't used, the output was correct. But when I try to correct for Fortran's column-major format with the order parameter, the array is filled with garbage. Anyone know what I'm doing wrong, or is this a bug in the intrinsic's implementation?
program test
implicit none
real, dimension(1:3, 1:3) :: matr
integer :: i
matr = reshape((/ (i, i=0,8) /), (/ 3, 3 /))
do i = lbound(matr, 1), ubound(matr, 1)
print *, matr(i,:)
end do
print *
matr = reshape((/ (i, i=1,9) /), (/ 3, 3 /), order=(/ 2, 1 /))
do i = lbound(matr, 1), ubound(matr, 1)
print *, matr(i,:)
end do
end program test
I get the following output:
0.0000000E+00 3.000000 6.000000
1.000000 4.000000 7.000000
2.000000 5.000000 8.000000
0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 -1.1987086E+09 -1.1987087E+09
1.0953484E+09 1.0934118E+09 -1.1987085E+09
In the case where order wasn't used, the output was correct. But when I try to correct for Fortran's column-major format with the order parameter, the array is filled with garbage. Anyone know what I'm doing wrong, or is this a bug in the intrinsic's implementation?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What compiler version are you using? It works ok for me in the current 8.0.047.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to register with Premier Support using the serial number included with the compiler (sent by e-mail if you got it online). You can then log in to Premier Support and download the latest compiler your license will allow. If you got a non-commercial (free) license, it will be as of the date the license was issued. If an eval, you have 30 days of free support, and if you have a full support license, you geta year of support and updates.
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