Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Problem with shape of arrays using reallocation feature with TRANSPOSE(RESHAPE(..))

bpichon
Beginner
884 Views

Dear Fortran !

Here a possible bug with intel compilers (both Windows and Linux OS)
I don't see previous post for this problem but sorry in the converse case.

It involves :
   1)   TRANSPOSE(RESHAPE(...))             (yes, why not !)
   2)   Fortran 2003/2008 (re)allocatation feature

What do you think about this ?

Bernard
=================================================================
With ifort 14.0.0074.11 on windows 8 (via visual studio 2012)

 V(6)=[1,2,3,4,5,6]
 1 2 3 4 5 6

  D = RESHAPE(V,[3,2])
 1 2 3 4 5 6

  E = TRANSPOSE( RESHAPE(V,[3,2]) ) in one step :
            WRONG (E has not the right shape ...)
 3 2   |   2 3
 1 4 -858993460 2 5 -858993460

  F = TRANSPOSE(D)  with  D = RESHAPE(V,[3,2])  in two steps : Ok
 2 3
 1 4 2 5 3 6

  G = RESHAPE( V, Shape=[2,3] , Order=[2,1] ) in one step
                       with keyword order of RESHAPE : Ok
 2 3
 1 4 2 5 3 6

==================================================================
With ifort 14.0.0 (20130728)  on Linux (ifort with -assume realloc !!)

  V(6)=[1,2,3,4,5,6]
           1           2           3           4           5           6

  D = RESHAPE(V,[3,2])
           1           2           3           4           5           6

  E = TRANSPOSE( RESHAPE(V,[3,2]) ) in one step :
            WRONG (E has not the right shape ...)
           3           2   |             2           3
           1           4          18           2           5           0

  F = TRANSPOSE(D)  with  D = RESHAPE(V,[3,2])  in two steps : Ok
           2           3
           1           4           2           5           3           6

  G = RESHAPE( V, Shape=[2,3] , Order=[2,1] ) in one step
                       with keyworf order of RESHAPE : Ok
           2           3
           1           4           2           5           3           6

 

0 Kudos
6 Replies
Steven_L_Intel1
Employee
884 Views

Please reattach your test case - something went wrong.

0 Kudos
bpichon
Beginner
884 Views

I try again as an attached file

0 Kudos
bpichon
Beginner
884 Views

I don't know if i succeed

Here the text of the test :

program test

!ifort test.f90 -assume realloc_lhs

integer, Dimension(:,:), Allocatable :: C, D, E, F, G

integer, Dimension(6) :: V = [1,2,3,4,5,6]

Write(*,*) 'V(6)=[1,2,3,4,5,6]'

Write(*,*) V

Write(*,*)

!

D = RESHAPE(V,[3,2])

Write(*,*) " D = RESHAPE(V,[3,2]) "

Write(*,*) D

Write(*,*)

!

E = TRANSPOSE( RESHAPE(V,[3,2]) )

Write(*,*) " E = TRANSPOSE( RESHAPE(V,[3,2]) ) in one step : "

Write(*,*) " WRONG (E has not the right shape ...) "

Write(*,*) SHAPE(E), ' | ', SHAPE( TRANSPOSE( RESHAPE(V,[3,2]) ) ) ! very curious

Write(*,*) E

Write(*,*)

!

F = TRANSPOSE(D)

Write(*,*) " F = TRANSPOSE(D) with D = RESHAPE(V,[3,2]) in two steps : Ok "

Write(*,*) SHAPE(F)

Write(*,*) F

Write(*,*)

!

G = RESHAPE( V, Shape=[2,3] , Order=[2,1] )

Write(*,*) " G = RESHAPE( V, Shape=[2,3] , Order=[2,1] ) in one step "

Write(*,*) " with keyword order of RESHAPE : Ok "

Write(*,*) SHAPE(G)

Write(*,*) G

Write(*,*)

end program test

0 Kudos
m_sulc
Beginner
884 Views

Ah, yes, with ifort version 14.0.0.080 Build 20130728, the statement
[fortran]
E = TRANSPOSE( RESHAPE(V,[3,2]) )
[/fortran]
produces incorrect results (moreover dependent on the level of optimization)...

0 Kudos
Steven_L_Intel1
Employee
884 Views

I can reproduce this in 14.0, but not in our next-release development stream. I have asked the developers to see if an explicit fix for this was made and if it could be added to 14.0. Issue ID is DPD200250177.

0 Kudos
Steven_L_Intel1
Employee
884 Views

The developers identified the fix and said it will go into Update 2, planned for January.

0 Kudos
Reply