1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998-2021 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19!
20!     identifies the position id of px in an ordered array
21!     x of integers; array x has two indices. The ordered array
22!     is the first index
23!
24!     id is such that x(1,id).le.px and x(1,id+1).gt.px
25!
26      subroutine nident2(x,px,n,id)
27!
28      implicit none
29!
30      integer x,px,n,id,n2,m
31!
32      dimension x(2,n)
33!
34      id=0
35      if(n.eq.0) return
36      n2=n+1
37      do
38         m=(n2+id)/2
39         if(px.ge.x(1,m)) then
40            id=m
41         else
42            n2=m
43         endif
44         if((n2-id).eq.1) return
45      enddo
46      end
47