I get an error in line 7 that fun is not a function. I have no idea how to fix this, to me it seems that it is a functions. I saw a lot of examples of using external functions as arguments for procedures(functions and subroutines). I am trying to do this in Fortran 77 or Fortran 90.
program integral
implicit none
external fun
double precision a,b,results,help
integer n
results = 0
call integrate(fun,a,b,n,results)
read(5,*) a,b,n
write(6,*) results
end program integral
function fun(x)
implicit none
double precision fun
double precision x
fun = 4*x*x
return
end function fun
subroutine integrate (f,a,b,n,results)
implicit none
integer i,n
double precision a,b,h,results,f
results= 0
h = (b-a)/n
do i=0,n-1
results = results + f(a+i*h)
end do
return
end subroutine integrate