LCOV - code coverage report
Current view: | top level - utils - intp_util.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 4 | 8 | 50.0 %
Date: | 2025-01-13 21:54:50 |  | Functions: | 1 | 1 | 100.0 %

              Line data    Source code
           1             : module intp_util
           2             :
           3             : implicit none
           4             :
           5             : private
           6             :
           7             : public :: findplb
           8             :
           9             : contains
          10             :
          11             : !#######################################################################
          12             :
          13        1536 : subroutine findplb( x, nx, xval, index )
          14             :
          15             :    !-----------------------------------------------------------------------
          16             :    ! Purpose:
          17             :    ! "find periodic lower bound"
          18             :    ! Search the input array for the lower bound of the interval that
          19             :    ! contains the input value.  The returned index satifies:
          20             :    ! x(index) .le. xval .lt. x(index+1)
          21             :    ! Assume the array represents values in one cycle of a periodic coordinate.
          22             :    ! So, if xval .lt. x(1), or xval .ge. x(nx), then the index returned is nx.
          23             :    !
          24             :    ! Author: B. Eaton
          25             :    !-----------------------------------------------------------------------
          26             :
          27             :    use shr_kind_mod, only: r8 => shr_kind_r8
          28             :
          29             :    integer, intent(in) ::   nx         ! size of x
          30             :    real(r8), intent(in) ::  x(nx)      ! strictly increasing array
          31             :    real(r8), intent(in) ::  xval       ! value to be searched for in x
          32             :
          33             :    integer, intent(out) ::  index
          34             :
          35             :    ! Local variables:
          36             :    integer i
          37             :    !-----------------------------------------------------------------------
          38             :
          39        1536 :    if ( xval .lt. x(1) .or. xval .ge. x(nx) ) then
          40        1536 :       index = nx
          41        1536 :       return
          42             :    end if
          43             :
          44           0 :    do i = 2, nx
          45           0 :       if ( xval .lt. x(i) ) then
          46           0 :          index = i-1
          47           0 :          return
          48             :       end if
          49             :    end do
          50             :
          51             : end subroutine findplb
          52             :
          53             : end module intp_util

Generated by: LCOV version 1.14