adjust_x_for_bounds Subroutine

private subroutine adjust_x_for_bounds(me, x)

if necessary, adjust the x vector to be within the bounds. used for the initial guess.

Type Bound

nlesolver_type

Arguments

Type IntentOptional Attributes Name
class(nlesolver_type), intent(inout) :: me
real(kind=wp), intent(inout), dimension(me%n) :: x

the x vector to adjust


Calls

proc~~adjust_x_for_bounds~~CallsGraph proc~adjust_x_for_bounds nlesolver_type%adjust_x_for_bounds proc~int2str int2str proc~adjust_x_for_bounds->proc~int2str

Called by

proc~~adjust_x_for_bounds~~CalledByGraph proc~adjust_x_for_bounds nlesolver_type%adjust_x_for_bounds proc~nlesolver_solver nlesolver_type%nlesolver_solver proc~nlesolver_solver->proc~adjust_x_for_bounds

Source Code

    subroutine adjust_x_for_bounds(me,x)

    implicit none

    class(nlesolver_type),intent(inout) :: me
    real(wp),dimension(me%n),intent(inout) :: x  !! the `x` vector to adjust

    integer :: i !! counter

    if (me%bounds_mode/=NLESOLVER_IGNORE_BOUNDS) then
        ! for all bounds modes, adjust the initial guess to be within the bounds
        ! x = min(max(x,me%xlow),me%xupp)
        do i = 1, me%n
            if (x(i)<me%xlow(i)) then
                x(i) = me%xlow(i)
                if (me%verbose) write(me%iunit, '(A)') 'Initial x('//int2str(i)//') < xlow(i) : adjusting to lower bound'
            else if (x(i)>me%xupp(i)) then
                x(i) = me%xupp(i)
                if (me%verbose) write(me%iunit, '(A)') 'Initial x('//int2str(i)//') > xupp(i) : adjusting to upper bound'
            end if
        end do
    end if

    end subroutine adjust_x_for_bounds