Quantcast
Channel:
Viewing all articles
Browse latest Browse all 8

Quote:Chaoran Chen wrote:

$
0
0

Quote:

Chaoran Chen wrote:

Here is a small problem: I called this function repeatly. If I change the last line "interp_value(i)=t" into "interp_value(i)=1.d0", the program would be much faster (with the other lines unchanged, including the line "t=(f_x...etc"). The time consumed by "interp_value(i)=1.d0" would be just one fourth of the one compared with "interp_value(i)=t". 

Since both lines are giving some particular real number to interp_value(i), why would the speed differ so much?

Thank you very much!

subroutine myinterp1(x,f_x,xp,N,interp_value)

implicit none
integer:: N,i,x_index
real(kind=8):: x(N), f_x(N), xp(N),interp_value(N),t
do i=1,N
x_index = minloc(abs(x-xp(i)),1)
t = (f_x(x_index+1)-f_x(x_index))/(x(x_index+1)-x(x_index))
interp_value(i)=t
end do
end subroutine myinterp1

Sorry to mention. For the time elapsed, I only record the time used in this function, not including others.


Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>