!-------------------------------------------------
!  INDXlib Module
!-------------------------------------------------
module indxlib
  use dcl_common
  interface DclLocFirst
    module procedure DclLocFirstChar, DclLocFirstInt, DclLocFirstReal
  end interface

  interface DclLocLast
    module procedure DclLocLastChar, DclLocLastInt, DclLocLastReal
  end interface

  private :: DclLocFirstChar, DclLocFirstInt, DclLocFirstReal
  private :: DclLocLastChar,  DclLocLastInt,  DclLocLastReal
  
  contains
    
    function DclLocFirstChar(array,value)
      character(len=*), intent(in), dimension(:) :: array 
      character(len=*), intent(in)               :: value
      integer                                    :: DclLocFirstChar

      DclLocFirstChar = indxnf(array,size(array),1,value)
    end function
      
    function DclLocLastChar(array,value)
      character(len=*), intent(in), dimension(:) :: array
      character(len=*), intent(in)               :: value
      integer                                    :: DclLocLastChar

      DclLocLastChar = indxnl(array,size(array),1,value) 
    end function
      
    function DclLocFirstCharEx(array,value)
      character(len=*), intent(in), dimension(:) :: array
      character(len=*), intent(in)               :: value 
      integer                                    :: DclLocFirstCharEx

      DclLocFirstCharEx = indxmf(array,size(array),1,value)
    end function
      
    function DclLocLastCharEx(array,value)
      character(len=*), intent(in), dimension(:) :: array
      character(len=*), intent(in)               :: value
      integer                                    :: DclLocLastCharEx

      DclLocLastCharEx = indxml(array,size(array),1,value)
    end function
      
    function DclLocFirstInt(array,value)
      integer, intent(in), dimension(:) :: array
      integer, intent(in)               :: value
      integer                           :: DclLocFirstInt

      DclLocFirstInt = indxif(array,size(array),1,value)
    end function
      
    function DclLocLastInt(array,value)
      integer, intent(in), dimension(:) :: array
      integer, intent(in)               :: value
      integer                           :: DclLocLastInt

      DclLocLastInt = indxil(array,size(array),1,value)
    end function
      
    function DclLocFirstReal(array,value) 
      real, intent(in), dimension(:) :: array
      real, intent(in)               :: value
      integer                        :: DclLocFirstReal

      DclLocFirstReal = indxrf(array,size(array),1,value)
    end function
      
    function DclLocLastReal(array,value)
      real, intent(in), dimension(:) :: array
      real, intent(in)               :: value
      integer                        :: DclLocLastReal

      DclLocLastReal = indxrl(array,size(array),1,value)
    end function

end module

