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 clearances(inpc,textpart,tieset,istat,n,iline,
20     &           ipol,inl,ipoinp,inp,ntie,ipoinpc,istep,tietol,irstrt,
21     &           ier)
22!
23!     reading the input deck: *CLEARANCE
24!
25      implicit none
26!
27      logical contactpair
28!
29      character*1 inpc(*)
30      character*81 tieset(3,*)
31      character*132 textpart(16),master,slave
32!
33      integer istat,n,i,j,key,ipos,iline,ipol,inl,ipoinp(2,*),irstrt(*),
34     &  inp(3,*),ntie,ipoinpc(0:*),iposslave,iposmaster,itie,istep,
35     &  ier
36!
37      real*8 tietol(3,*),value
38!
39      if((istep.gt.0).and.(irstrt(1).ge.0)) then
40         write(*,*) '*ERROR reading *CLEARANCE: *CLEARANCE should be'
41         write(*,*) '       placed before all step definitions'
42         ier=1
43         return
44      endif
45!
46      contactpair=.false.
47!
48      do i=2,n
49         if(textpart(i)(1:7).eq.'MASTER=') then
50            iposmaster=index(textpart(i),' ')
51            master(1:iposmaster-8)=textpart(i)(8:iposmaster-1)
52            do j=iposmaster-7,132
53               master(j:j)=' '
54            enddo
55         elseif(textpart(i)(1:6).eq.'SLAVE=') then
56            iposslave=index(textpart(i),' ')
57            slave(1:iposslave-7)=textpart(i)(7:iposslave-1)
58            do j=iposslave-6,132
59               slave(j:j)=' '
60            enddo
61         elseif(textpart(i)(1:6).eq.'VALUE=') then
62            read(textpart(i)(7:26),'(f20.0)',iostat=istat) value
63         else
64            write(*,*)
65     &       '*WARNING reading *CLEARANCE: parameter not recognized:'
66            write(*,*) '         ',
67     &                 textpart(i)(1:index(textpart(i),' ')-1)
68            call inputwarning(inpc,ipoinpc,iline,
69     &"*CLEARANCE%")
70         endif
71      enddo
72!
73!     selecting the appropriate action
74!
75      iposslave=index(slave(1:80),' ')
76      iposmaster=index(master(1:80),' ')
77      do i=1,ntie
78         if((tieset(1,i)(81:81).ne.'C').and.
79     &      (tieset(1,i)(81:81).ne.'-')) cycle
80         ipos=index(tieset(2,i),' ')-1
81         if(ipos.ne.iposslave) cycle
82         if(tieset(2,i)(1:ipos-1).ne.slave(1:ipos-1)) cycle
83         ipos=index(tieset(3,i),' ')-1
84         if(ipos.ne.iposmaster) cycle
85         if(tieset(3,i)(1:ipos-1).ne.master(1:ipos-1)) cycle
86         itie=i
87         exit
88      enddo
89!
90      if(i.gt.ntie) then
91         write(*,*) '*ERROR reading *CLEARANCE: no such contact pair'
92         call inputerror(inpc,ipoinpc,iline,
93     &        "*CLEARANCE%",ier)
94         return
95      endif
96      tietol(3,i)=value
97!
98      call getnewline(inpc,textpart,istat,n,key,iline,ipol,inl,
99     &     ipoinp,inp,ipoinpc)
100!
101      return
102      end
103
104
105
106