[cig-commits] r4772 - short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d

willic3 at geodynamics.org willic3 at geodynamics.org
Tue Oct 10 08:35:24 PDT 2006


Author: willic3
Date: 2006-10-10 08:35:24 -0700 (Tue, 10 Oct 2006)
New Revision: 4772

Added:
   short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/zbrac.f
Log:
Initial version of a root bracketing routine modified from Numerical
Recipes.  This will be needed for power-law rheology.


Added: short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/zbrac.f
===================================================================
--- short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/zbrac.f	2006-10-10 15:29:47 UTC (rev 4771)
+++ short/3D/PyLith/branches/pylith-0.8/pylith3d/libpylith3d/zbrac.f	2006-10-10 15:35:24 UTC (rev 4772)
@@ -0,0 +1,87 @@
+c -*- Fortran -*-
+c
+c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+c
+c  PyLith by Charles A. Williams, Brad Aagaard, and Matt Knepley
+c
+c  Copyright (c) 2004-2006 Rensselaer Polytechnic Institute
+c
+c  Permission is hereby granted, free of charge, to any person obtaining
+c  a copy of this software and associated documentation files (the
+c  "Software"), to deal in the Software without restriction, including
+c  without limitation the rights to use, copy, modify, merge, publish,
+c  distribute, sublicense, and/or sell copies of the Software, and to
+c  permit persons to whom the Software is furnished to do so, subject to
+c  the following conditions:
+c
+c  The above copyright notice and this permission notice shall be
+c  included in all copies or substantial portions of the Software.
+c
+c  THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+c  EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+c  MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
+c  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+c  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+c  OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
+c  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+c
+c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+c
+      SUBROUTINE zbrac(func,x1,x2,rpar,nrpar,ipar,nipar,ierr,errstrng)
+c
+c...  subroutine to bracket the root of a real function.  Modified
+c     from Numerical Recipes.
+c
+c     Error codes:
+c         0:  No error
+c       114:  Initial bracketing values are identical
+c       410:  Bracketing values not found
+c
+      include "implicit.inc"
+c
+c...  parameter definitions
+c
+      INTEGER NTRY
+      double precision FACTOR
+      PARAMETER (FACTOR=1.6d0,NTRY=50)
+c
+c...  subroutine arguments
+c
+      integer nrpar,nipar,ierr
+      integer ipar(nipar)
+      double precision x1,x2,rpar(nrpar)
+      character errstrng*(*)
+c
+c...  external routines
+c
+      EXTERNAL func
+c
+c...  local variables
+c
+      INTEGER j
+      double precision f1,df1,f2,df2
+c
+      ierr=0
+c
+      if(x1.eq.x2) then
+        ierr=114
+        errstrng="zbrac"
+        return
+      end if
+      call func(x1,f1,df1,rpar,nrpar,ipar,nipar)
+      call func(x2,f2,df2,rpar,nrpar,ipar,nipar)
+      do j=1,NTRY
+        if(f1*f2.lt.0.0d0)return
+        if(abs(f1).lt.abs(f2))then
+          x1=x1+FACTOR*(x1-x2)
+          call func(x1,f1,df1,rpar,nrpar,ipar,nipar)
+        else
+          x2=x2+FACTOR*(x2-x1)
+          call func(x2,f2,df2,rpar,nrpar,ipar,nipar)
+        endif
+      end do
+      ierr=410
+      errstrng="zbrac"
+      return
+      END
+C  (C) Copr. 1986-92 Numerical Recipes Software .zW.



More information about the cig-commits mailing list