Replicating results



Hi,

I have the following piece of fortran code that seems to give me
different answers every time I run it. I need to get the same result
every time because, although these differences look small, they
unravel into substantial differences. This code snippet is part of a
gradient calculation used in a large optimization routine.

I have printed the code and results below. Has anybody else run into
this problem? I am using the absoft compiler on an intel64 machine.
Please let me know if more information is needed.

-Kalu

begin CoDE:
-----------------------

real*8 :: x(n),grad(n),dh(nmax),ee(nmax,nmax),xsav(nmax)

! ... some more code goes here ...

do i = 1,n

do j = 1,n
x(j) = xsav(j) - ee(i,j)
end do

call evalf(x,tempf1)

do j = 1,n
x(j) = xsav(j) + ee(i,j)
end do

call evalf(x,tempf2)

! point of interest

grad(i) = (tempf2-tempf1)/(2.0D+00*dh(i))

! output below shows that the arguments to the right of the equal
sign are the
! same every time while the results of this calculation differ

print *,'tempf2 = ',tempf2,' tempf1 = ',tempf1,' dh(',i,') =
',dh(i),'grad(',i,') = ',grad(i)

end do
------------
End CoDE

Begin Output
-------------

tempf2 = -11.2891215185643 tempf1 = -11.2891217937382 dh( 4 )
= 8.680700000000000E-007 grad( 4 ) = 0.158497573828246

tempf2 = -11.2891215185643 tempf1 = -11.2891217937382 dh( 4 )
= 8.680700000000000E-007 grad( 4 ) = 0.158497571781917

------------
End Output

.



Relevant Pages

  • Re: Replicating results
    ... I have the following piece of fortran code that seems to give me ... gradient calculation used in a large optimization routine. ... I am using the absoft compiler on an intel64 machine. ... the optimum dh to use is C \epsilon_m^, where C is a problem-dependent constant that may depend on x but not on h. ...
    (comp.lang.fortran)
  • Re: Replicating results
    ... I have the following piece of fortran code that seems to give me ... gradient calculation used in a large optimization routine. ... I am using the absoft compiler on an intel64 machine. ... That sounds like an uninitialized variable problem. ...
    (comp.lang.fortran)