C+ C NAME: C nrZbrak C PURPOSE: C Bracket one or more zero's in a given interval for a function of one C independent variable C CATEGORY: C Math: finding roots C CALLING SEQUENCE: subroutine nrZbrak(FUNC,X1,X2,N,XB1,XB2,NB) C INPUTS: C FUNC real function to be tested; should be declared external in C the calling program C X1,X2 real limits of interval to be tested C N integer # subintervals to be tested C NB integer maximum # sign changes looked for C OUTPUTS: C NB integer # sign changes detected C XB1(NB),XB2(NB) C real limits of subintervals over which sign change C is detected C SEE ALSO: C nrZbrac, nrZBrent C RESTRICTIONS: C XB1 and XB2 must be declared in the calling program with a dimension C equal or greater than the input value of NB. C PROCEDURE: C "Inward search" for roots. Subdivide a given interval [X1,X2] into C N subintervals and look for sign changes across the subintervals. C See Press et al., "Numerical Recipes", Cambridge UP (1989), par. 9.1, C p. 245 C- real FUNC real X1 real X2 integer N real XB1(*) real XB2(*) integer NB NBB = NB NB = 0 X = X1 DX = (X2-X1)/N FP = FUNC(X) do I=1,N X = X+DX FC = FUNC(X) if (FC*FP .lt. 0.) then NB = NB+1 XB1(NB) = X-DX XB2(NB) = X end if FP = FC if (NBB .eq. NB) return end do return end