Sets the variable bounds for sparsity in a numdiff_type.
These are only used for sparsity_mode=2
.
Note
This routine assumes that xlow
and xhigh
have already
been set in the class.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(numdiff_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | xlow |
lower bounds on |
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | xhigh |
upper bounds on |
subroutine set_numdiff_sparsity_bounds(me,xlow,xhigh) implicit none class(numdiff_type),intent(inout) :: me real(wp),dimension(:),intent(in),optional :: xlow !! lower bounds on `x` to be used for !! sparsity computation. If not present, !! then then `xlow` values in the class are used. real(wp),dimension(:),intent(in),optional :: xhigh !! upper bounds on `x` to be used for !! sparsity computation. If not present, !! then then `xhigh` values in the class are used. if (me%exception_raised) return ! check for exceptions if (allocated(me%xlow_for_sparsity)) deallocate(me%xlow_for_sparsity) if (allocated(me%xhigh_for_sparsity)) deallocate(me%xhigh_for_sparsity) if (.not. present(xlow)) then allocate(me%xlow_for_sparsity(size(me%xlow))) me%xlow_for_sparsity = me%xlow else allocate(me%xlow_for_sparsity(size(xlow))) me%xlow_for_sparsity = xlow end if if (.not. present(xhigh)) then allocate(me%xhigh_for_sparsity(size(me%xhigh))) me%xhigh_for_sparsity = me%xhigh else allocate(me%xhigh_for_sparsity(size(xhigh))) me%xhigh_for_sparsity = xhigh end if ! error checks: if (size(me%xlow_for_sparsity)/=me%n .or. size(me%xhigh_for_sparsity)/=me%n) then call me%raise_exception(6,'set_numdiff_sparsity_bounds',& 'invalid size of xlow or xhigh') else if (any(me%xlow_for_sparsity>=me%xhigh_for_sparsity)) then call me%raise_exception(7,'set_numdiff_sparsity_bounds',& 'all xlow must be < xhigh') end if end subroutine set_numdiff_sparsity_bounds