Reputation: 175
For an academic paper, the authors have provided their code of their results and so I am trying to run their code. When I compile, there is an error which says that a function cannot be used as an argument. Here below I provide the relevant parts of the code that the error seem to point out (In particular the message is: "error 997 - An internal FUNCTION, such as FOC, cannot be used as an actual argument"
).
.........
function foc(ain)
implicit none
real*8:: ain, foc
foc = plterm+meru(ain,i)-upap(n,ain,i)
end function foc
...........
yy1 = zbrent(foc,a(np-1),yexp,errrel)
where zbrent is a subroutine called by the main program. If necessary I can attach the whole code.
FUNCTION zbrent (func,x1,x2,tol)
implicit none
real(8), external:: func
real(8), intent(in):: x1,x2,tol
END FUNCTION zbrent
I am not familiar with Fortran or any programming and wondering whether someone can advice something.
Upvotes: 0
Views: 1131
Reputation: 59998
The key is in the error message:
An internal FUNCTION, such as FOC, cannot be used as an actual argument
Your function foc
is apparently an internal function. It is placed after the word contains
in the main program or in another procedure.
Internal procedures are prohibited to be a passed as argument in Fortran 2003 and earlier. Fortran 2008 relaxed this.
Place the function in a module and it will be OK. Also external one will work in this case, but I do not recommend it that much (that means just move foc
outside of everything).
Or use a compiler that implements the Fortran 2008 rules for this (recent versions of gfortran should suffice).
Upvotes: 2