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 assigndomtonodes(ne,lakon,ipkon,kon,ielmat,inomat,
20     &  elcon,ncmat_,ntmat_,mi,ne2)
21!
22!     assigns the domain a node belongs to, to this node
23!     (for electromagnetic calculations, only for nodes not
24!      belonging to shells)
25!
26      implicit none
27!
28      character*8 lakon(*)
29!
30      integer i,j,nope,ne,imat,mi(*),ielmat(mi(3),*),ipkon(*),inomat(*),
31     &  ncmat_,ntmat_,node,kon(*),indexe,ne2
32!
33      real*8 elcon(0:ncmat_,ntmat_,*)
34!
35      do i=1,ne
36         if(ipkon(i).lt.0) cycle
37         if(lakon(i)(7:7).eq.'L') cycle
38         indexe=ipkon(i)
39!
40         if(lakon(i)(4:5).eq.'20') then
41            nope=20
42         elseif(lakon(i)(4:4).eq.'8') then
43            nope=8
44         elseif(lakon(i)(4:5).eq.'10') then
45            nope=10
46         elseif(lakon(i)(4:4).eq.'4') then
47            nope=4
48         elseif(lakon(i)(4:5).eq.'15') then
49            nope=15
50         elseif(lakon(i)(4:4).eq.'6') then
51            nope=6
52         else
53            cycle
54         endif
55!
56         imat=ielmat(1,i)
57!
58!        ne2 is the number of elements in domain 2 = A,V-domain
59!
60         if(int(elcon(2,1,imat)).eq.2) ne2=ne2+1
61!
62         do j=1,nope
63            node=kon(indexe+j)
64            if(inomat(node).ne.0) then
65               if(inomat(node).ne.int(elcon(2,1,imat))) then
66                  write(*,*) '*ERROR in assigndomtonodes: a node'
67                  write(*,*) '       cannot belong to more than'
68                  write(*,*) '       one domain'
69                  call exit(201)
70               else
71                  cycle
72               endif
73            endif
74            inomat(node)=int(elcon(2,1,imat))
75         enddo
76      enddo
77!
78      return
79      end
80