1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998 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 writetetmesh(kontet,netet,cotet,nktet,field,nfield)
20!
21      implicit none
22!
23      character*1 c
24      character*3 m1,m2,m3,m4,m5
25      character*5 p0,p1,p2,p3,p4,p9999
26      character*132 text
27!
28      integer kontet(4,*),netet,one,i,j,nsom,
29     &  nktet,index,node,kode,nfield
30!
31      real*8 cotet(3,*),field(*),time
32!
33      c='C'
34!
35      m1=' -1'
36      m2=' -2'
37      m3=' -3'
38      m4=' -4'
39      m5=' -5'
40!
41      p0='    0'
42      p1='    1'
43      p2='    2'
44      p3='    3'
45      p4='    4'
46      p9999=' 9999'
47!
48      one=1
49      kode=1
50      time=0.d0
51!
52      open(9,file='TetMasterSubmodel.frd',status='unknown')
53!
54      write(9,'(a5,a1)') p1,c
55!
56!       storing the coordinates of the nodes
57!
58      write(9,'(a5,a1,67x,i1)') p2,c,one
59!
60      do i=1,nktet
61         write(9,100) m1,i,(cotet(j,i),j=1,3)
62      enddo
63!
64      write(9,'(a3)') m3
65!
66!       storing the element topology
67!
68      write(9,'(a5,a1,67x,i1)') p3,c,one
69!
70      do i=1,netet
71         if(kontet(1,i).eq.0) cycle
72         write(9,'(a3,i10,3a5)') m1,i,p3,p0,p0
73         write(9,'(a3,10i10)') m2,(kontet(j,i),j=1,4)
74      enddo
75      write(*,*) 'number of tetrahedra = ',netet
76!
77      write(9,'(a3)') m3
78      write(9,'(a5)') p9999
79!
80      close(9)
81!
82 100  format(a3,i10,1p,3e12.5)
83!
84      return
85      end
86