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 gapconductances(inpc,textpart,nelcon,nmat,ntmat_,
20     &        npmat_,plkcon,nplkcon,iperturb,irstrt,istep,istat,n,iline,
21     &        ipol,inl,ipoinp,inp,ipoinpc,ier)
22!
23!     reading the input deck: *GAP CONDUCTANCE
24!
25      implicit none
26!
27      character*1 inpc(*)
28      character*132 textpart(16)
29!
30      integer nelcon(2,*),nmat,ntmat_,ntmat,npmat_,npmat,istep,
31     &  n,key,i,nplkcon(0:ntmat_,*),iperturb(*),istat,ier,
32     &  irstrt(*),iline,ipol,inl,ipoinp(2,*),inp(3,*),ipoinpc(0:*)
33!
34      real*8 plkcon(0:2*npmat_,ntmat_,*),
35     & temperature
36!
37      ntmat=0
38      npmat=0
39!
40      if((istep.gt.0).and.(irstrt(1).ge.0)) then
41         write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
42         write(*,*) '       *GAP CONDUCTANCE should'
43         write(*,*) '       be placed before all step definitions'
44         ier=1
45         return
46      endif
47!
48      if(nmat.eq.0) then
49         write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
50         write(*,*) '       *GAP CONDUCTANCE should'
51         write(*,*) '       be preceded by a *SURFACE INTERACTION card'
52         ier=1
53         return
54      endif
55!
56      if(nelcon(1,nmat).eq.0) then
57         write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
58         write(*,*) '       *GAP CONDUCTANCE should'
59         write(*,*) '       be preceeded by a *SURFACE BEHAVIOR card'
60         ier=1
61         return
62      endif
63!
64      iperturb(1)=2
65c      iperturb(2)=1
66      write(*,*) '*INFO reading *GAP CONDUCTANCE: nonlinear geometric'
67      write(*,*) '      effects are turned on'
68      write(*,*)
69!
70      nelcon(1,nmat)=-51
71!
72      do i=2,n
73         if(textpart(i)(1:4).eq.'USER') then
74            call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
75     &           ipoinp,inp,ipoinpc)
76            return
77         else
78            write(*,*)
79     &        '*WARNING reading *GAP CONDUCTANCE:'
80            write(*,*) '         parameter not recognized:'
81            write(*,*) '         ',
82     &                 textpart(i)(1:index(textpart(i),' ')-1)
83            call inputwarning(inpc,ipoinpc,iline,
84     &"*GAP CONDUCTANCE%")
85         endif
86      enddo
87!
88         do
89            call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
90     &           ipoinp,inp,ipoinpc)
91            if((istat.lt.0).or.(key.eq.1)) exit
92            read(textpart(3)(1:20),'(f20.0)',iostat=istat) temperature
93            if(istat.gt.0) then
94               call inputerror(inpc,ipoinpc,iline,
95     &              "*GAP CONDUCTANCE%",ier)
96               return
97            endif
98!
99!           first temperature
100!
101            if(ntmat.eq.0) then
102               npmat=0
103               ntmat=ntmat+1
104               if(ntmat.gt.ntmat_) then
105                  write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
106                  write(*,*) '       increase ntmat_'
107                  ier=1
108                  return
109               endif
110               nplkcon(0,nmat)=ntmat
111               plkcon(0,ntmat,nmat)=temperature
112!
113!           new temperature
114!
115            elseif(plkcon(0,ntmat,nmat).ne.temperature) then
116               npmat=0
117               ntmat=ntmat+1
118               if(ntmat.gt.ntmat_) then
119                  write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
120                  write(*,*) '       increase ntmat_'
121                  ier=1
122                  return
123               endif
124               nplkcon(0,nmat)=ntmat
125               plkcon(0,ntmat,nmat)=temperature
126            endif
127            do i=1,2
128               read(textpart(i)(1:20),'(f20.0)',iostat=istat)
129     &              plkcon(2*npmat+i,ntmat,nmat)
130               if(istat.gt.0) then
131                  call inputerror(inpc,ipoinpc,iline,
132     &                 "*GAP CONDUCTANCE%",ier)
133                  return
134               endif
135            enddo
136            npmat=npmat+1
137            if(npmat.gt.npmat_) then
138               write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
139               write(*,*) '       increase npmat_'
140               ier=1
141               return
142            endif
143            nplkcon(ntmat,nmat)=npmat
144         enddo
145!
146      if(ntmat.eq.0) then
147         write(*,*) '*ERROR reading *GAP CONDUCTANCE:'
148         write(*,*) '       *GAP CONDUCTANCE card'
149         write(*,*) '       without data'
150         ier=1
151         return
152      endif
153!
154      return
155      end
156
157