Check the validity of the inputs to the initialize routines.
Prints warning message if there is an error,
and also sets ierr
(/=0 if there were any errors).
Supports up to 6D: x,y,z,q,r,s
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(linear_interp_class), | intent(in) | :: | me | |||
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | x |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | y |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | z |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | q |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | r |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | s |
|
integer, | intent(out) | :: | ierr |
|
pure subroutine check_inputs(me,x,y,z,q,r,s,ierr) implicit none class(linear_interp_class),intent(in) :: me real(wp),dimension(:),intent(in),optional :: x !! `x` abscissa vector real(wp),dimension(:),intent(in),optional :: y !! `y` abscissa vector real(wp),dimension(:),intent(in),optional :: z !! `z` abscissa vector real(wp),dimension(:),intent(in),optional :: q !! `q` abscissa vector real(wp),dimension(:),intent(in),optional :: r !! `r` abscissa vector real(wp),dimension(:),intent(in),optional :: s !! `s` abscissa vector integer,intent(out) :: ierr !! `0` : no problems, !! `1` : `x` is not strictly increasing, !! `2` : `y` is not strictly increasing, !! `3` : `z` is not strictly increasing, !! `4` : `q` is not strictly increasing, !! `5` : `r` is not strictly increasing, !! `6` : `s` is not strictly increasing, !! `100` : cannot use linear interpolation for only one point. ierr = 0 ! initialize if (present(x)) call check(x,1,ierr); if (ierr/=0) return if (present(y)) call check(y,2,ierr); if (ierr/=0) return if (present(z)) call check(z,3,ierr); if (ierr/=0) return if (present(q)) call check(q,4,ierr); if (ierr/=0) return if (present(r)) call check(r,5,ierr); if (ierr/=0) return if (present(s)) call check(s,6,ierr); if (ierr/=0) return if (ierr == 0) then select type (me) class is (nearest_interp_1d) class is (nearest_interp_2d) class is (nearest_interp_3d) class is (nearest_interp_4d) class is (nearest_interp_5d) class is (nearest_interp_6d) class default ! need at least two points for linear interpolation: if (size(x)==1) ierr = 100 end select end if contains !***************************************************************************************** pure subroutine check(v,error_code,ierr) implicit none real(wp),dimension(:),intent(in) :: v !! abcissae vector integer,intent(in) :: error_code !! error code for check integer,intent(inout) :: ierr !! will be set to `error_code` if there is a problem integer :: i !! counter integer :: n !! size of the input `v` array n = size(v) do i=2,n if (v(i) <= v(i-1)) then ierr = error_code exit end if end do end subroutine check end subroutine check_inputs