fortran 错误提示:
lagrange.f90:7.21:

  real :: interpolate(NP1:NP2)
                     1
Error: Symbol 'interpolate' at (1) cannot have a type
lagrange.f90:33.67:

           coeff(j) = coeff(j-1) * (x-datas(j,1))/(datas(i,1)-datas(j,1)) 
                                                                   1
Error: Rank mismatch in array reference at (1) (2/1)
lagrange.f90:35.67:

           coeff(j) = coeff(j-1) * (x-datas(j,1))/(datas(i,1)-datas(j,1))
                                                                   1
Error: Rank mismatch in array reference at (1) (2/1)
lagrange.f90:40.44:

      lagrange = lagrange + coeff(j+1)*datas(i,2)!computing pi(x)=yi*li
                                            1
Error: Rank mismatch in array reference at (1) (2/1)
lagrange.f90:17.8:

   datas(l,1) = r
        1
Error: Rank mismatch in array reference at (1) (2/1)
lagrange.f90:18.8:

   datas(l,2) = func(datas(l,1))
        1
Error: Rank mismatch in array reference at (1) (2/1)
lagrange.f90:18.26:

   datas(l,2) = func(datas(l,1))
                          1
Error: Rank mismatch in array reference at (1) (2/1)
lagrange.f90:48.17:

  use INTERPOLATE
                 1
Fatal Error: Can't open module file 'interpolate.mod' for reading at (1): No such file or directory

程序:
module INTERPOLATE
  implicit none
  real, parameter :: PI=3.14159
  real, parameter :: xmin = -5.0, xmax = 5.0
  integer, parameter :: m = 6,n=2, NP1 = 100, NP2 =2
  real :: datas(m:n)
  real :: interpolate(NP1:NP2)

 contains
  subroutine GenerateData(func)
    real, external :: func
    real r, width
    integer l
    width = (xmax-xmin)/(m-1)
    r = xmin
    do l=1,m
      datas(l,1) = r
      datas(l,2) = func(datas(l,1))
      r = r+width !put m points(xi,yi) into the matrix of datas(m) 
    end do
  end subroutine

  real function lagrange(x)!to compute the goal function
    real x
    real :: coeff(m)!row control the number of points
    integer i,j
    lagrange = 0
    do i=1,m!using i to control the number of points,m
     do j=1,m!using j to control the number of lj(x)
       if ( i/=j )then
         if((j-1)<=0)then!if statement to compute lj(x),j=1,2,...m
           coeff(j-1)=1
           coeff(j) = coeff(j-1) * (x-datas(j,1))/(datas(i,1)-datas(j,1)) 
         else
           coeff(j) = coeff(j-1) * (x-datas(j,1))/(datas(i,1)-datas(j,1))
         end if
        end if
      end do

      lagrange = lagrange + coeff(j+1)*datas(i,2)!computing pi(x)=yi*li

    end do
    lagrange=lagrange*sin(x)!compute pi(x)*f(x),that is the goal function
  end function
end module

program main
  use INTERPOLATE
  implicit none
  real, intrinsic :: sin
  real xinc,x
  integer k

  call GenerateData(sin)!put m points(xi,yi) into the matrix of datas(m)  
  x=-5.0
  xinc = (xmax-xmin)/(NP-1)
  do k=1,NP
    interpolate(k:1) = x!segmenting the domain of (-5,5) into np fragments
    interpolate(k:2)= lagrange(x)!put the function value of each fragment into the matrix of interpolate

    x = x+xinc
  end do
OPEN(10,file='test0.dat')
  WRITE(10,*)interpolate !exporting the value of matrix interpolate
CLOSE(10)
end program