function overlap(n,h,f1,f2) c function to calculate the overlap between two vectors f1 and f2 c using simpsons rule, assuming f1(0)*f2(0)=f1(n+1)*f2(n+1)=0 c assumes f1, f2 tabulated at points r=i*h implicit real*8 (a-h,o-z) dimension f1(n),f2(n) if (n.lt.4) then overlap=0 do i=1,n overlap=overlap+h*f1(i)*f2(i) enddo return endif fac=h/3 overlap=4*f1(1)*f2(1)+f1(2)*f2(2) do i=4,n,2 overlap=overlap+f1(i-2)*f2(i-2)+4*f1(i-1)*f2(i-1)+f1(i)*f2(i) enddo overlap=fac*overlap return end