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!     this routine is identical to ident except that x and px are
20!     integer*8
21!
22!     identifies the position id of px in an ordered array
23!     x of integers;
24!
25!     id is such that x(id).le.px and x(id+1).gt.px
26!
27      subroutine nidentll(x,px,n,id)
28      implicit none
29      integer n,id,n2,m
30      integer*8 x,px
31      dimension x(n)
32      id=0
33      if(n.eq.0) return
34      n2=n+1
35      do
36         m=(n2+id)/2
37         if(px.ge.x(m)) then
38            id=m
39         else
40            n2=m
41         endif
42         if((n2-id).eq.1) return
43      enddo
44      end
45