anchor.diff:  ! return : number of member in specified group
   
   function get_grp_member( hecMESH, grp_type_name, name, member1, member2 )
  -        implicit none
  -        integer(kind=kint) :: get_grp_member
  -        type (hecmwST_local_mesh),target :: hecMESH
  -        character(len=*) :: grp_type_name
  -        character(len=*) :: name
  -        integer(kind=kint),pointer :: member1(:)
  -        integer(kind=kint),pointer, optional :: member2(:)
  -        integer(kind=kint) :: i, j, k, sn, en
  -
  -        get_grp_member = -1
  -        if( grp_type_name == 'surf_grp' .and. (.not. present( member2 ))) then
  -                        STOP 'assert in get_grp_member: not present member2 '
  -        end if
  -
  -        call set_group_pointers( hecMESH, grp_type_name )
  -
  -        do i = 1, n_grp
  -                if( fstr_streqr(grp_name%s(i), name)) then
  -                        sn = grp_index(i-1) + 1
  -                        en = grp_index(i)
  -                        k = 1
  -                        if( grp_type == 3 ) then ! == surf_grp
  -                                do j = sn, en
  -                                        member1(k) = grp_item(2*j-1)
  -                                        member2(k) = grp_item(2*j)
  -                                        k = k + 1
  -                                end do
  -                        else
  -                                do j = sn, en
  -                                        member1(k) = grp_item(j)
  -                                        k = k + 1
  -                                end do
  -                        end if
  -                        get_grp_member = en - sn + 1
  -                        return
  -                end if
  +  implicit none
  +  integer(kind=kint) :: get_grp_member
  +  type (hecmwST_local_mesh),target :: hecMESH
  +  character(len=*) :: grp_type_name
  +  character(len=*) :: name
  +  integer(kind=kint),pointer :: member1(:)
  +  integer(kind=kint),pointer, optional :: member2(:)
  +  integer(kind=kint) :: i, j, k, sn, en
  +
  +  get_grp_member = -1
  +  if( grp_type_name == 'surf_grp' .and. (.not. present( member2 ))) then
  +    STOP 'assert in get_grp_member: not present member2 '
  +  end if
  +
  +  call set_group_pointers( hecMESH, grp_type_name )
  +
  +  do i = 1, n_grp
  +    if( fstr_streqr(grp_name%s(i), name)) then
  +      sn = grp_index(i-1) + 1
  +      en = grp_index(i)
  +      k = 1
  +      if( grp_type == 3 ) then ! == surf_grp
  +        do j = sn, en
  +          member1(k) = grp_item(2*j-1)
  +          member2(k) = grp_item(2*j)
  +          k = k + 1
           end do
  -        get_grp_member = 0
  -        return
  +      else
  +        do j = sn, en
  +          member1(k) = grp_item(j)
  +          k = k + 1
  +        end do
  +      end if
  +      get_grp_member = en - sn + 1
  +      return
  +    end if
  +  end do
  +  get_grp_member = 0
  +  return
   end function get_grp_member
   
   !------------------------------------------------------------------------------
  
positive.code: !          >0 if name is a number and a node with ID=name is in myrank
  
  function get_local_member_index( hecMESH, type_name, name, local_id )
          implicit none
          integer(kind=kint) :: get_local_member_index
          type (hecmwST_local_mesh),target :: hecMESH
          character(len=*) :: type_name
          character(len=*) :: name
          integer(kind=kint) :: local_id
  
          integer(kind=kint) :: i, n, stat, no, fg
          integer(kind=kint),pointer :: global_item(:)
  
          if( .not. fstr_str2index(name, no) ) then
                  get_local_member_index = -1
                  return
          end if
  
          if( type_name == 'node' ) then
                  fg = 1
                  n  =  hecMESH%n_node
                  global_item => hecMESH%global_node_ID
          else if( type_name == 'element' ) then
                  fg = 2
                  n  =  hecMESH%n_elem
                  global_item => hecMESH%global_elem_ID
          else
                  STOP 'assert in get_local_member_index: unknown type_name'
          end if
  
          do i = 1, n
                  if( no == global_item(i)) then
                          local_id = i
                          get_local_member_index = local_id
                          return
                  end if
          end do
          local_id = 0
          get_local_member_index = 0
          return
  end function get_local_member_index
  
  !-----------------------------------------------------------------------------!
  !
  
  function get_sorted_local_member_index( hecMESH, hecPARAM, type_name, name, local_id )
          implicit none
          integer(kind=kint) :: get_sorted_local_member_index
          type (hecmwST_local_mesh),target :: hecMESH
          type(fstr_param), target         :: hecPARAM
          character(len=*) :: type_name
          character(len=*) :: name
          integer(kind=kint) :: local_id, idx
  
          integer(kind=kint) :: i, n, stat, no, fg
          integer(kind=kint),pointer :: item(:)
  
          if( .not. fstr_str2index(name, no) ) then
                  get_sorted_local_member_index = -1
                  return
          end if
  
          if( type_name == 'node' ) then
                  fg = 1
                  n  =  hecMESH%nn_internal
  !                item => hecMESH%global_node_ID
  !        else if( type_name == 'element' ) then
  !                fg = 2
  !                n  =  hecMESH%n_elem
  !                item => hecMESH%global_elem_ID
          else
                  STOP 'assert in get_sorted_local_member_index: unknown type_name'
          end if
  
          call bsearch_int_array(hecPARAM%global_local_ID(1,:), 1, n, no, idx)
          if(idx > 0)then
            get_sorted_local_member_index = hecPARAM%global_local_ID(2,idx)
            local_id = get_sorted_local_member_index
            return
          endif
  
          get_sorted_local_member_index = 0
          return
  end function get_sorted_local_member_index
  !-----------------------------------------------------------------------------!
  
  !-----------------------------------------------------------------------------!
  !~/FrontISTR/hecmw1/src/solver/matrix/hecmw_matrix_reorder.f90
  subroutine bsearch_int_array(array, istart, iend, val, idx)
    implicit none
    integer(kind=kint), intent(in) :: array(:)
  
negative.code: ! return : number of member in specified group
  
  function get_grp_member_n( hecMESH, grp_type_name, name )
    implicit none
    integer(kind=kint) :: get_grp_member_n
    type (hecmwST_local_mesh),target :: hecMESH
    character(len=*) :: grp_type_name
    character(len=*) :: name
    integer(kind=kint) :: i
  
    call set_group_pointers( hecMESH, grp_type_name )
  
    do i = 1, n_grp
      if( fstr_streqr(grp_name%s(i),name)) then
        get_grp_member_n = grp_index(i) - grp_index(i-1)
        return
      end if
    end do
    get_grp_member_n = 0
    return
  end function get_grp_member_n
  
  !------------------------------------------------------------------------------
  