94 subroutine dcsrch(f,g,stp,ftol,gtol,xtol,stpmin,stpmax,
98 double precision f,g,stp,ftol,gtol,xtol,stpmin,stpmax
99 double precision dsave(13)
110 double precision zero,p5,p66
111 parameter(zero=0.0d0,p5=0.5d0,p66=0.66d0)
112 double precision xtrapl,xtrapu
113 parameter(xtrapl=1.1d0,xtrapu=4.0d0)
117 double precision finit,ftest,fm,fx,fxm,fy,fym,ginit,gtest,
118 + gm,gx,gxm,gy,gym,stx,sty,stmin,stmax,width,width1
122 if (task(1:5) .eq.
'START')
then
126 if (stp .lt. stpmin) task = .LT.
'ERROR: STP STPMIN'
127 if (stp .gt. stpmax) task = .GT.
'ERROR: STP STPMAX'
128 if (g .ge. zero) task = .GE.
'ERROR: INITIAL G ZERO'
129 if (ftol .lt. zero) task = .LT.
'ERROR: FTOL ZERO'
130 if (gtol .lt. zero) task = .LT.
'ERROR: GTOL ZERO'
131 if (xtol .lt. zero) task = .LT.
'ERROR: XTOL ZERO'
132 if (stpmin .lt. zero) task = .LT.
'ERROR: STPMIN ZERO'
133 if (stpmax .lt. stpmin) task = .LT.
'ERROR: STPMAX STPMIN'
137 if (task(1:5) .eq.
'ERROR')
return
146 width = stpmax - stpmin
163 stmax = stp + xtrapu*stp
172 if (isave(1) .eq. 1)
then
197 ftest = finit + stp*gtest
198 if (stage .eq. 1 .and. f .le. ftest .and. g .ge. zero)
203 if (brackt .and. (stp .le. stmin .or. stp .ge. stmax))
204 + task =
'WARNING: ROUNDING ERRORS PREVENT PROGRESS'
205 if (brackt .and. stmax - stmin .le. xtol*stmax)
206 + task =
'WARNING: XTOL TEST SATISFIED'
207 if (stp .eq. stpmax .and. f .le. ftest .and. g .le. gtest)
208 + task =
'WARNING: STP = STPMAX'
209 if (stp .eq. stpmin .and. (f .gt. ftest .or. g .ge. gtest))
210 + task =
'WARNING: STP = STPMIN'
214 if (f .le. ftest .and. abs(g) .le. gtol*(-ginit))
215 + task =
'CONVERGENCE'
219 if (task(1:4) .eq.
'WARN' .or. task(1:4) .eq.
'CONV')
goto 1000
225 if (stage .eq. 1 .and. f .le. fx .and. f .gt. ftest)
then
238 call dcstep(stx,fxm,gxm,sty,fym,gym,stp,fm,gm,
239 + brackt,stmin,stmax)
252 call dcstep(stx,fx,gx,sty,fy,gy,stp,f,g,
253 + brackt,stmin,stmax)
260 if (abs(sty-stx) .ge. p66*width1) stp = stx + p5*(sty - stx)
271 stmin = stp + xtrapl*(stp - stx)
272 stmax = stp + xtrapu*(stp - stx)
277 stp = max(stp,stpmin)
278 stp = min(stp,stpmax)
283 if (brackt .and. (stp .le. stmin .or. stp .ge. stmax)
284 + .or. (brackt .and. stmax-stmin .le. xtol*stmax)) stp = stx
subroutine dcsrch(f, g, stp, ftol, gtol, xtol, stpmin, stpmax, task, isave, dsave)
This subroutine finds a step that satisfies a sufficient decrease condition and a curvature condition...
subroutine dcstep(stx, fx, dx, sty, fy, dy, stp, fp, dp, brackt, stpmin, stpmax)
This subroutine computes a safeguarded step for a search procedure and updates an interval that conta...