1 subroutine hybrd1
(fcn
,n
,x
,fvec
,tol
,info
,wa
,lwa
)
4 double precision x
(n
),fvec
(n
),wa
(lwa
)
10 c the purpose of hybrd1 is to find a zero of a system of
11 c n nonlinear functions in n variables by a modification
12 c of the powell hybrid method. this is done by using the
13 c more general nonlinear equation solver hybrd. the user
14 c must provide a subroutine which calculates the functions.
15 c the jacobian is then calculated by a forward-difference
18 c the subroutine statement is
20 c subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
24 c fcn is the name of the user-supplied subroutine which
25 c calculates the functions. fcn must be declared
26 c in an external statement in the user calling
27 c program, and should be written as follows.
29 c subroutine fcn(n,x,fvec,iflag)
31 c double precision x(n),fvec(n)
33 c calculate the functions at x and
34 c return this vector in fvec.
39 c the value of iflag should not be changed by fcn unless
40 c the user wants to terminate execution of hybrd1.
41 c in this case set iflag to a negative integer.
43 c n is a positive integer input variable set to the number
44 c of functions and variables.
46 c x is an array of length n. on input x must contain
47 c an initial estimate of the solution vector. on output x
48 c contains the final estimate of the solution vector.
50 c fvec is an output array of length n which contains
51 c the functions evaluated at the output x.
53 c tol is a nonnegative input variable. termination occurs
54 c when the algorithm estimates that the relative error
55 c between x and the solution is at most tol.
57 c info is an integer output variable. if the user has
58 c terminated execution, info is set to the (negative)
59 c value of iflag. see description of fcn. otherwise,
60 c info is set as follows.
62 c info = 0 improper input parameters.
64 c info = 1 algorithm estimates that the relative error
65 c between x and the solution is at most tol.
67 c info = 2 number of calls to fcn has reached or exceeded
70 c info = 3 tol is too small. no further improvement in
71 c the approximate solution x is possible.
73 c info = 4 iteration is not making good progress.
75 c wa is a work array of length lwa.
77 c lwa is a positive integer input variable not less than
82 c user-supplied ...... fcn
84 c minpack-supplied ... hybrd
86 c argonne national laboratory. minpack project. march 1980.
87 c burton s. garbow, kenneth e. hillstrom, jorge j. more
90 integer index
,j
,lr
,maxfev
,ml
,mode
,mu
,nfev
,nprint
91 double precision epsfcn
,factor
,one
,xtol
,zero
92 data factor
,one
,zero
/1.0d2
,1.0d0
,0.0d0
/
95 c check the input parameters for errors.
97 if (n
.le
. 0 .or
. tol
.lt
. zero
.or
. lwa
.lt
. (n*
(3*n
+ 13))/2)
114 call hybrd
(fcn
,n
,x
,fvec
,xtol
,maxfev
,ml
,mu
,epsfcn
,wa
(1),mode
,
115 * factor
,nprint
,info
,nfev
,wa
(index
+1),n
,wa
(6*n
+1),lr
,
116 * wa
(n
+1),wa
(2*n
+1),wa
(3*n
+1),wa
(4*n
+1),wa
(5*n
+1))
117 if (info
.eq
. 5) info
= 4
121 c last card of subroutine hybrd1.