Type | Intent | Optional | Attributes | Name | |||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
subroutine func(x, ff)Arguments
|
|||||||||||||||||||||||||||
real(kind=8), | dimension(:) | :: | x | ||||||||||||||||||||||||
real(kind=8), | optional | :: | tol | ||||||||||||||||||||||||
integer, | optional | :: | info | ||||||||||||||||||||||||
logical, | optional | :: | check | ||||||||||||||||||||||||
integer, | optional | :: | maxfev |
subroutine fsolve_hybrd_sub(func,x,tol,info,check,maxfev) interface subroutine func(x,ff) real(8),dimension(:),intent(in) :: x real(8),dimension(size(x)) :: ff end subroutine func end interface real(8),dimension(:) :: x real(8),optional :: tol integer,optional :: info real(8) :: tol_ integer :: info_ integer,optional :: maxfev integer :: maxfev_ logical,optional :: check logical :: check_ integer :: n real(8),dimension(size(x)) :: fvec tol_ = 1.d-15;if(present(tol))tol_=tol check_=.true.;if(present(check))check_=check maxfev_=200;if(present(maxfev))maxfev_=maxfev n=size(x) call hybrd1(fsolve_hybrd1_sub2sub,n,x,fvec,tol_,info_,maxfev_) if(present(info))info=info_ if(check_)then include "fsolve_error.h90" endif contains subroutine fsolve_hybrd1_sub2sub(n,x,fvec,iflag) integer :: n real(8) :: x(n) real(8) :: fvec(n) integer :: iflag call func(x,fvec) if(iflag<0)stop "FSOLVE_HYBRD1_sub2sub ERROR: iflag < 0 " end subroutine fsolve_hybrd1_sub2sub end subroutine fsolve_hybrd_sub