program trapezio implicit double precision (a-h,o-z) parameter (nd=1000) dimension x(nd),y(nd) open(1,file='points.dat') do i=1,nd read(1,*,end=10)x(i),y(i) enddo stop 'Increase dimension (x.y)' 10 n=i-1 close(1) call trap(n,x,y,sum,nd) write(*,*)' Sum = ', sum end c ********************************************************************* subroutine trap(n,x,y,sum,nd) c ********************************************************************* implicit double precision (a-h,o-z) dimension x(nd),y(nd) sum=0.d0 do i=2,n if(x(i).le.x(i-1)) stop ' x NOT in INCREASING order ' sum=sum+.5d0*(x(i)-x(i-1))*(y(i)+y(i-1)) enddo return end