same function giving different results
From: Bart Vandewoestyne (MyFirstName.MyLastName_at_telenet.be)
Date: 01/06/05
- Next message: Bart Vandewoestyne: "Re: same function giving different results"
- Previous message: rwa_at_purdue.edu: "Re: Portability VMS to Linux"
- Next in thread: Bart Vandewoestyne: "Re: same function giving different results"
- Reply: Bart Vandewoestyne: "Re: same function giving different results"
- Reply: Rich Townsend: "Re: same function giving different results"
- Reply: Ron Shepard: "Re: same function giving different results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 6 Jan 2005 14:25:45 +0000 (UTC)
In my main program, i call the following function two or more times:
function radical_inverse(n, b) result (radinv)
integer, intent(in) :: n, b
double precision :: radinv
integer :: i
double precision :: b_factor
integer, allocatable :: mydigits(:)
radinv = 0.0
allocate(mydigits(get_nb_digits(n, b)))
call get_digits(n, b, mydigits)
b_factor = real(1.0/b)
do i=1,get_nb_digits(n, b)
radinv = radinv + mydigits(i)*b_factor
b_factor = b_factor/b
end do
deallocate(mydigits)
end function radical_inverse
The function comes from a submodule.
When i run my testprogram which contains the following lines:
print *, "radical_inverse(154754, 10) = ", radical_inverse(154754, 10)
print *, "radical_inverse(154754, 10) = ", radical_inverse(154754, 10)
I get two different results:
radical_inverse(154754, 10) = 0.4574510000000000
radical_inverse(154754, 10) = 5.7451000000000002E-02
the first result is ok, the rest of the results is wrong.
I have been looking over and over this again, and my guess would be that the problem is somewhere with the allocatable array I'm using inside my function, but
i cannot find the real problem and how to fix it.
Can anybody tell me what I'm doing wrong?
Regards,
Bart
-- "Share what you know. Learn what you don't."
- Next message: Bart Vandewoestyne: "Re: same function giving different results"
- Previous message: rwa_at_purdue.edu: "Re: Portability VMS to Linux"
- Next in thread: Bart Vandewoestyne: "Re: same function giving different results"
- Reply: Bart Vandewoestyne: "Re: same function giving different results"
- Reply: Rich Townsend: "Re: same function giving different results"
- Reply: Ron Shepard: "Re: same function giving different results"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]