Van Snyder,
I disagree with you on P1 but not on P2.
(But I'm still a beginner on some(or many) parts of F90/95.)
Declaration of T2 gives following order between the elements:
T2 = 11 21 31 41 12 22 32 42 13 23 33 43 14 24 34 44
The actual argument to RES1 is thus
reshape(t2,(/16/)) = 11 21 31 41 12 22 32 42 13 23 33 43 14 24 34 44
which differ from T2 in shape but not in element order.
Thus I think P1 also should have the same element order:
P1 = 11 21 31 41 12 22 32 42 13 23 33 43 14 24 34 44
With CVF6.1a I got the above values for P1 and your values for P2.
Greetings,
Kurt
----- Original Message -----
From: Van Snyder <[log in to unmask]>
To: <[log in to unmask]>
Sent: den 7 juni 2000 03:57
Subject: Bug or feature
>
> I've tried the following program with two compilers. I think they both
> get the "wrong" answers for P1 and P2. Neither one reports an error at
> compile- or run-time. I've reported to the vendors.
>
> Maybe it's my mistake.
>
> I think P1 should be
> 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44
> and P2 should be
> 1 5 9 13
> 2 6 10 14
> 3 7 11 15
> 4 8 12 16
>
> 1. What do you think the "right" answers are for P1 and P2?
> 2. Do you have a compiler that does what you (or I) expect?
>
> Best regards,
> Van Snyder
> ==========================================================================
> module RESHAPERS
> interface RES
> module procedure RES1, RES2
> end interface
> contains
> function RES1 ( R1 )
> integer, pointer :: RES1(:)
> integer, target :: R1(:)
> res1 => r1
> end function RES1
> function RES2 ( R2 )
> integer, pointer :: RES2(:,:)
> integer, target :: R2(:,:)
> res2 => r2
> end function RES2
> end module RESHAPERS
>
> program TEST
> use RESHAPERS
> integer, pointer :: P1(:)
> integer, pointer :: P2(:,:)
>
> integer, target :: T1(16) = (/ (i,i=1,16) /)
> integer, target :: T2(4,4) = reshape( (/ ((10*i+j,i=1,4),j=1,4) /),
(/4,4/) )
>
> p1 => res(reshape(t2,(/16/)))
> p2 => res(reshape(t1,(/4,4/)))
>
> print *, 'T1 ='
> print '(16i3)', t1
> print *, 'T2 ='
> print '(4i3)', (t2(i,:),i=1,4)
> print *, 'P1 => res(reshape(t2,(/16/))) ='
> print '(16i3)', p1
> print *, 'P2 => res(reshape(t1,(/4,4/))) ='
> print '(4i3)', (p2(i,:),i=1,4)
> print *, 'SHAPE(P1) =', shape(p1)
> print *, 'SHAPE(P2) =', shape(p2)
> end program TEST
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|