! Prototype source code for the multinewt subroutine. !--------------------------------------------------------------------------- module general_newton use precision implicit none contains !--------------------------------------------------------------------------- subroutine multnewt(f,df,x,n,tol,ierr) integer,intent(in):: n real(R),intent(inout):: x(n) real(R),intent(in):: tol integer,intent(out):: ierr ! ! The interface block below completes the declarations. Although F is ! a vector-valued function in principle, it is implemented as a subroutine ! here. The function value is returned through the N-vector FCN. ! Similarly, DF is an NxN matrix, which is returned as a subroutine argument. ! interface subroutine f(y,n,fcn) use precision integer,intent(in):: n ! the number of equations real(R),intent(in):: y(n) real(R),intent(out):: fcn(n) ! holds F(y) on return end subroutine f !------------------ subroutine df(y,n,dfcn) use precision integer,intent(in):: n ! the number of equations real(R),intent(in):: y(n) real(R),intent(out):: dfcn(n,n) ! holds the Jacobian matrix on return end subroutine df end interface !------------------ ! ! Local variables and the rest of your code go here. ! Note: if you change precision from single to double, ! you need to call DGESV instead of SGESV. The calling ! interface is the same, except that the floating-point ! arguments are double precision instead of single precision. ! return end subroutine multinewt !--------------------------------------------------------------------------- end module general_newton