Re: Real and complex arrays
- From: Brooks Moses <bmoses-nospam@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 25 Apr 2006 17:16:08 -0700
morten.langer@xxxxxxxxx wrote:
i believe you are right. Since I posted I have gotten a little further.
REAL(cmplxNo) does indeed return a real number (i can see that by
printing it to the screen), but when I try to assign it to a place in a
real array, I only see a 0 in the array. So the assignment somehow
fails..? This is the code snippet:
real rTst
complex magSignalComplex(512)
dimension magSignalReal(512)
do i=1,512
magSignalComplex(i) = abs(signalPartFreq(i))
rTst = real(magSignalComplex(i))
magSignalReal(i) = rTst
enddo
So, the magSignalReal array only contains zeros. If I print rTst to the
screen before the assignment, it looks fine - like a real number.. What
could be the matter?
This is not a complete sample program; it doesn't include any initialization for signalPartFreq, and thus it cannot be compiled and run by itself. Thus, it doesn't accomplish the primary purposes of producing a sample program -- namely, ensuring that the problem is in fact in the part of the code that you think it's in, and allowing us to try it out on our computers to see if we can reproduce the problem.
The following is a complete example program:
program test
complex mSC(3), sPF(3)
real mSR(3), rTst
sPF = (/ (0,2), (1,-1), (3,4) /)
do i = 1, 3
mSC(i) = abs(sPF(i))
rTst = real(mSC(i))
mSR(i) = rTst
write(*,*) i, mSC(i), rTst, mSR(i)
end do
end program
On my computer, it produces the following output:
1 (2.000000,0.0000000E+00) 2.000000 2.000000
2 (1.414214,0.0000000E+00) 1.414214 1.414214
3 (5.000000,0.0000000E+00) 5.000000 5.000000
What does it produce on yours?
- Brooks
--
The "bmoses-nospam" address is valid; no unmunging needed.
.
- References:
- Real and complex arrays
- From: morten . langer
- Re: Real and complex arrays
- From: glen herrmannsfeldt
- Re: Real and complex arrays
- From: morten . langer
- Real and complex arrays
- Prev by Date: Re: Real and complex arrays
- Next by Date: Re: Real and complex arrays
- Previous by thread: Re: Real and complex arrays
- Next by thread: Re: Real and complex arrays
- Index(es):
Relevant Pages
|
|