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 keystart(ifreeinp,ipoinp,inp,name,iline,ikey)
20!
21      implicit none
22!
23!     stores the order in which the input is to be read in fields
24!     ipoinp and inp; before adding keywords to the list below
25!     look at the CalculiX documentation, section "Program structure"
26!     subsection "Allocation of the fields" subsubsection "readinput".
27!
28!     order:
29!     1)  *RESTART,READ
30!     2)  *NODE
31!     3)  *USER ELEMENT
32!     4)  *ELEMENT
33!     5)  *NSET
34!     6)  *ELSET
35!     7)  *SURFACE
36!     8)  *TRANSFORM
37!     9)  *MATERIAL
38!     10) *DISTRIBUTION
39!     11) *ORIENTATION
40!     12) *TIE
41!     13) *SURFACE INTERACTION
42!     14) *INITIAL CONDITIONS
43!     15) *AMPLITUDE
44!     16) *CONTACT PAIR
45!     17) *COUPLING
46!     18) everything else
47!
48      integer nentries
49      parameter(nentries=18)
50!
51      character*20 name,nameref(nentries)
52!
53      integer ifreeinp,ipoinp(2,*),inp(3,*),namelen(nentries),i,ikey,
54     &  iline
55!
56!     order in which the cards have to be read
57!
58      data nameref /'RESTART,READ','NODE','USERELEMENT','ELEMENT',
59     &              'NSET',
60     &              'ELSET','SURFACE','TRANSFORM','MATERIAL',
61     &              'DISTRIBUTION',
62     &              'ORIENTATION','TIE','INTERACTION',
63     &              'INITIALCONDITIONS','AMPLITUDE',
64     &              'CONTACTPAIR','COUPLING','REST'/
65!
66!     length of the names in field nameref
67!
68      data namelen /12,4,11,7,4,5,7,9,8,12,11,3,11,17,9,11,8,4/
69!
70      do i=1,nentries
71         if(name(1:namelen(i)).eq.nameref(i)(1:namelen(i))) then
72            if(ikey.eq.i) return
73            if(ikey.gt.0) inp(2,ipoinp(2,ikey))=iline-1
74            ikey=i
75            if(ipoinp(1,i).eq.0) then
76               ipoinp(1,i)=ifreeinp
77            else
78               inp(3,ipoinp(2,i))=ifreeinp
79            endif
80            ipoinp(2,i)=ifreeinp
81            exit
82         endif
83      enddo
84      inp(1,ifreeinp)=iline
85      ifreeinp=ifreeinp+1
86!
87      return
88      end
89