! SUBROUTINE findextreme(i, nmax, rvals, vp, jval, rext, v0, v1, v2, root, mu, ichanl) USE Numeric_Kinds_Module !------------------------------------------------------------------------- !this subroutine finds maximum/minimum of the potential function !------------------------------------------------------------------------- IMPLICIT none LOGICAL :: root INTEGER :: i, nmax, jval, ichanl REAL(dp) :: rext, r1, r2, vl, vr, v0, v1, v2,mu REAL(dp) :: rvals(nmax), vp(nmax) root=.false. !============================================================================== ! Checks if the first derivative of the potential has changed signs and begins ! to home in on exact value of maximum/minimum IF(vp(i-1)*vp(i).lt.0.d0)THEN r1=rvals(i-1) !sets initial inner bound to previous r value vl=vp(i-1) r2=rvals(i) !sets initial outer bound to current r value vr=vp(i) ! findext will further narrow down bounds CALL findext(rext, v0, v1, v2, r1, vl, r2, vr, jval, mu, ichanl) root=.true. !signals that a critical point has been found ENDIF RETURN END SUBROUTINE FindExtreme