Compute step size for center and forward difference calculations.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | itype |
The finite difference method being used, where: |
||
integer, | intent(in) | :: | k |
Index into |
||
real(kind=wp), | intent(in) | :: | betak |
The |
||
real(kind=wp), | intent(in) | :: | ssf(k) |
The scale used for the |
||
real(kind=wp), | intent(in) | :: | stpb(k) |
The relative step used for computing finite difference derivatives with respect
to |
||
integer, | intent(in) | :: | neta |
Number of good digits in the function results. |
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=wp), | public | :: | typj |
real(wp) pure function derstep(itype, k, betak, ssf, stpb, neta) result(derstepr) !! Compute step size for center and forward difference calculations. ! Routines Called DHSTEP ! Date Written 20040616 (YYYYMMDD) ! Revision Date 20040616 (YYYYMMDD) use odrpack_kinds, only: zero, one integer, intent(in) :: itype !! The finite difference method being used, where: `itype = 0` indicates forward !! finite differences, and `itype = 1` indicates central finite differences. integer, intent(in) :: k !! Index into `beta` where `betak` resides. real(wp), intent(in) :: betak !! The `k`-th function parameter. real(wp), intent(in) :: ssf(k) !! The scale used for the `beta`s. real(wp), intent(in) :: stpb(k) !! The relative step used for computing finite difference derivatives with respect !! to `beta`. integer, intent(in) :: neta !! Number of good digits in the function results. ! Local scalars real(wp) :: typj ! Variable definitions (alphabetically) ! BETAK: The K-th function parameter. ! ITYPE: 0 - calc foward difference step, 1 - calc center difference step. ! K: Index into beta where BETAK resides. ! NETA: Number of good digits in the function results. ! SSF: The scale used for the BETA'S. ! STPB: The relative step used for computing finite difference derivatives with ! respect to BETA. ! TYPJ: The typical size of the J-th unkonwn BETA. if (betak == zero) then if (ssf(1) < zero) then typj = one/abs(ssf(1)) else typj = one/ssf(k) end if else typj = abs(betak) end if derstepr = sign(one, betak)*typj*dhstep(itype, neta, 1, k, stpb, 1) end function derstep