vendredi 6 février 2015

comparing real*8 numbers in fortran

I have two arrays defined as "real*8". I want to compare the two arrays and perform some further actions. I am using an if statement to compare the two as given below



do i=1,np*(ncp_span1-3)
do k=1,nsec
if (bspline_datapoints(i,1)==section(k))then
print*,bspline_datapoints(i,1)
end if
end do
end do


Is there a way in which I can compare the numbers in the two arrays upto a specific decimal points. Below is an example of the numbers in two arrays


bspline_datapoints: 0.0000, 0.24946612,0.501308622 section:0.0000000,0.25000000000,0.50000000000


if I do the if statement as shown above the above numbers wont match, I was thinking of comparing them upto 2 decimal points. Is there a way I can do this??


Aucun commentaire:

Enregistrer un commentaire