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      subroutine extfacepernode(iponoelfa,inoelfa,lakonfa,ipkonfa,
20     &       konfa,nsurfs,inoelsize)
21!
22      implicit none
23!
24      character*8 lakonfa(*)
25!
26      integer iponoelfa(*),inoelfa(3,*),ipkonfa(*),konfa(*),i,j,nsurfs,
27     &  inoelfree,nope,indexe,node,inoelsize
28!
29!
30!
31!     lists which external faces correspond to a given node i
32!     iponoelfa(i) points to an entry j in field inoelfa where:
33!     inoelfa(1,j): face number as catalogued in fields konfa, lakonfa
34!     inoelfa(2,j): local node number in the topology description
35!     inoelfa(3,j): pointer to the next face to which i belongs, or, if
36!                   none is left: zero
37!
38      inoelfree=1
39      do i=1,nsurfs
40         if(ipkonfa(i).lt.0) cycle
41         if(lakonfa(i)(2:2).eq.'8') then
42            nope=8
43         elseif(lakonfa(i)(2:2).eq.'4') then
44            nope=4
45         elseif(lakonfa(i)(2:2).eq.'6') then
46            nope=6
47         elseif(lakonfa(i)(2:2).eq.'3') then
48            nope=3
49         endif
50         indexe=ipkonfa(i)
51         do j=1,nope
52            node=konfa(indexe+j)
53            inoelfa(1,inoelfree)=i
54            inoelfa(2,inoelfree)=j
55            inoelfa(3,inoelfree)=iponoelfa(node)
56            iponoelfa(node)=inoelfree
57            inoelfree=inoelfree+1
58         enddo
59      enddo
60!
61!     size of field inoelfa
62!
63      inoelsize=inoelfree-1
64!
65      return
66      end
67