... or so it seems. This doesn't work:
$ cat reshape-2.f90 program resh real, dimension (0:1,0:2) :: a,c real, dimension (12) :: b b = (/(i,i=1,12)/) a = reshape(b(1:12:2),shape(a),order=(/2,1/)) print '(6F8.3)',a c = reshape(b(1:12:2),shape(a),order=(/2,1/)) print '(6F8.3)',c end $ gfortran reshape-2.f90 $ ./a.out 0.000 0.000 0.000 2.029 2.027 2.025 -2.000 2.022 0.000 2.166 0.000 0.000 This works: $ cat reshape-2.f90 program resh real, dimension (0:1,0:2) :: a,c real, dimension (12) :: b b = (/(i,i=1,12)/) a = reshape(b(1:12:2),shape(a),order=(/2,1/)) print '(6F8.3)',a c = reshape(b(1:12:2),shape(a),order=(/2,1/)) print '(6F8.3)',c end $ gfortran reshape-2.f90 $ ./a.out 0.000 0.000 0.000 2.029 2.027 2.025 -2.000 2.022 0.000 2.166 0.000 0.000 $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.1/configure --enable-languages=c,f95 --prefix=/home/ig25 Thread model: posix gcc version 4.1.0 20050419 (experimental) Reshape is trickier than I thought, apparently. -- Summary: reshape with order causes memory corruption Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libfortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21108