I am having problems with using the real function with complex arrays, when combined inline with sum function. The following produces strange output for the second print statement, but the last print statement which is exactly the same except not done inline ( the sum is first copied to another variable and then the real part taken works fine.
The code works in g95, all print statements are correct. I'm not sure if it's a program fault or a problem from my coding and that g95 is being tolerant.
Any help will be gratefully appreciated
Albert
program test
Implicit none
complex,dimension(1,3) :: csum complex,dimension(10,3) :: c real, dimension (10,6) :: r
call RANDOM_NUMBER(r)
! Build a complex array c= cmplx(r(: , 1:5:2) , r(: , 2:6:2))
! sum of each column csum(1, : ) = sum(c, dim=1)
print*, sum(c , dim=1 ) print*, real( sum(c , dim=1 )) print*, aimag( sum(c , dim=1 )) print*, real(csum)
end program