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: !------------------------------------------------------------------------------
  
  subroutine fstr_ctrl_err_stop
          implicit none
          character(len=256) :: msg
  
          call fstr_ctrl_get_err_msg( msg, 256 )
          write(*,*) msg
          write(imsg,*) msg
          call hecmw_abort( hecmw_comm_get_comm())
  end subroutine fstr_ctrl_err_stop
  
  !------------------------------------------------------------------------------
  
  subroutine fstr_setup_util_err_stop( msg )
          implicit none
          character(*) :: msg
  
          write(*,*) msg
          write(imsg,*) msg
          call hecmw_abort( hecmw_comm_get_comm())
  end subroutine fstr_setup_util_err_stop
  
  
  !------------------------------------------------------------------------------
  
  ! grp_type_name : 'node_grp', 'elem_grp' or 'surf_grp'
  
  subroutine set_group_pointers( hecMESH, grp_type_name )
          type (hecmwST_local_mesh),target :: hecMESH
          character(len=*) :: grp_type_name
  
          if( grp_type_name == 'node_grp' ) then
                  grp_type = 1
                  n_grp      => hecMESH%node_group%n_grp
                  grp_name%s => hecMESH%node_group%grp_name
                  grp_index  => hecMESH%node_group%grp_index
                  grp_item   => hecMESH%node_group%grp_item
          else if( grp_type_name == 'elem_grp' ) then
                  grp_type = 2
                  n_grp      => hecMESH%elem_group%n_grp
                  grp_name%s => hecMESH%elem_group%grp_name
                  grp_index  => hecMESH%elem_group%grp_index
                  grp_item   => hecMESH%elem_group%grp_item
          else if( grp_type_name == 'surf_grp' ) then
                  grp_type = 3
                  n_grp      => hecMESH%surf_group%n_grp
                  grp_name%s => hecMESH%surf_group%grp_name
                  grp_index  => hecMESH%surf_group%grp_index
                  grp_item   => hecMESH%surf_group%grp_item
          else
                  STOP 'assert in set_group_pointers'
          end if
  
  end subroutine set_group_pointers
  
  
  subroutine backset_group_pointers( hecMESH, grp_type_name )
          type (hecmwST_local_mesh),target :: hecMESH
          character(len=*) :: grp_type_name
  
          if( grp_type_name == 'node_grp' ) then
                  grp_type = 1
                  hecMESH%node_group%grp_name => grp_name%s
                  hecMESH%node_group%grp_index => grp_index
                  hecMESH%node_group%grp_item => grp_item
          else if( grp_type_name == 'elem_grp' ) then
                  grp_type = 2
                  hecMESH%elem_group%grp_name => grp_name%s
                  hecMESH%elem_group%grp_index => grp_index
                  hecMESH%elem_group%grp_item => grp_item
          else if( grp_type_name == 'surf_grp' ) then
                  grp_type = 3
                  hecMESH%surf_group%grp_name => grp_name%s
                  hecMESH%surf_group%grp_index => grp_index
                  hecMESH%surf_group%grp_item => grp_item
          else
                  STOP 'assert in set_group_pointers'
          end if
  
  end subroutine backset_group_pointers
  
  
  function node_global_to_local( hecMESH, list, n )
          implicit none
          type (hecmwST_local_mesh), target :: hecMESH
          integer(kind=kint) :: list(:)
          integer(kind=kint) :: n, i, j
          logical:: fg
          integer(kind=kint):: node_global_to_local
          node_global_to_local = 0
          do j=1, n
                  fg = .false.
                  do i=1, hecMESH%n_node
                          if( hecMESH%global_node_ID(i) == list(j)) then
                                  list(j) = i
                                  fg = .true.
                                  node_global_to_local = node_global_to_local +1
                                  exit
                          endif
                  end do
                  if( .not. fg ) then
                          list(j) = -list(j) ! not exist node
                  endif
          end do
  end function node_global_to_local
  
  function elem_global_to_local( hecMESH, list, n )
          implicit none
          type (hecmwST_local_mesh), target :: hecMESH
          integer(kind=kint), pointer :: list(:)
          integer(kind=kint) :: n, i, j
          logical :: fg
          integer(kind=kint) :: elem_global_to_local
  
          elem_global_to_local = 0
          do j=1, n
                  fg = .false.
                  do i=1, hecMESH%n_elem
                          if( hecMESH%global_elem_ID(i) == list(j)) then
                                  list(j) = i
                                  fg = .true.
                                  elem_global_to_local = elem_global_to_local+1
                                  exit
                          endif
                  end do
                  if( .not. fg ) then
                          list(j) = -list(j)
                  endif
          end do
  end function elem_global_to_local
  
  
  function append_single_group( hecMESH, grp_type_name, no_count, no_list )
          implicit none
          type (hecmwST_local_mesh), target :: hecMESH
          character(len=*) :: grp_type_name
          integer(kind=kint) :: no_count
          integer(kind=kint),pointer :: no_list(:)
          integer(kind=kint):: append_single_group
  
          integer(kind=kint) :: old_grp_number, new_grp_number
          integer(kind=kint) :: old_item_number, new_item_number
  
          integer(kind=kint) :: i,j,k, exist_n
          integer(kind=kint), save :: grp_count = 1
          character(50) :: grp_name_s
  
          call set_group_pointers( hecMESH, grp_type_name )
          if( grp_type_name == 'node_grp') then
                  exist_n = node_global_to_local( hecMESH, no_list, no_count )
          else if( grp_type_name == 'elem_grp') then
                  exist_n = elem_global_to_local( hecMESH, no_list, no_count )
          endif
  
          old_grp_number = n_grp
          new_grp_number = old_grp_number + no_count
  
          old_item_number = grp_index(n_grp)
          new_item_number = old_item_number + exist_n
  
          call fstr_expand_name_array( grp_name, old_grp_number, new_grp_number )
          call fstr_expand_index_array( grp_index, old_grp_number + 1, new_grp_number+1)
          call fstr_expand_integer_array( grp_item, old_item_number, new_item_number )
  
          n_grp = new_grp_number
  
          j = old_grp_number + 1
          k = old_item_number + 1
          do i = 1, no_count
                  write( grp_name_s, '(a,i0,a,i0)') 'FSTR_', grp_count, '_', i
                  grp_name%s(j) = grp_name_s
                  if( no_list(i) >= 0) then
                      grp_item(k) = no_list(i)
                      grp_index(j) = grp_index(j-1)+1
                      k = k + 1
                  else
                      grp_index(j) = grp_index(j-1)
                  endif
                  j = j + 1
          end do
          grp_count = grp_count + 1
          call backset_group_pointers( hecMESH, grp_type_name )
          append_single_group = exist_n
  end function append_single_group
  
  !------------------------------------------------------------------------------
  
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
  
  !------------------------------------------------------------------------------
  