! abelem10

! read ABAQUS 10-node tet *ELEMENTs and translate to ANSYS commands
!     Input:
!       _buffer    - buffer containing the ABAQUS file
!     Output:
!       *vwrite of the ANSYS commands
!     Input/Output:
!       _curline   - current line of the file
!       _readnext  - if 1, read a new line    0, process the current one

! read the elements
*dowhile,_readnext
   _curline = _curline + 1
   *if,_curline,gt,_nlines,then
      _readnext = 0
      *cycle
   *endif
   _lineIn(1) = _buffer(1,_curline)
   _c1=_buffer(1,_curline)
   ! check for a "*"
   _tt = STRSUB(_c1,1,1)
   *if,_tt,eq,'*',then
      ! check if comment - just add to input file as an ANSYS comment
      _tt = STRSUB(_c1,1,2)
      *if,_tt,eq,'**',then
         *vwrite,_lineIn(1)
! %C
         *cycle
      *endif
      ! it is a keyword - indicates that we've read these nodes in
      *if,_cmname,ne,' ',and,_nnodes,gt,0,then
         ! create the component if there was an ELSET=
         *vwrite,_cmname
         CM,e_%C,ELEMENT
      *endif
      *vwrite
      ('ESEL,ALL')
      _readnext = 0            ! we've already processed this line
      *cycle
   *endif
   ! get the element number and nodes off this input line
   makefields
   _enum = _field1
   _nnod = _nfield - 1
   *do,_i,1,_nnod
      _j = _i + 1
      _n%_i% = _field%_j%
   *enddo
   _curline = _curline + 1         ! get next line of nodes
   _lineIn(1) = _buffer(1,_curline)
   makefields
   _j = _nnod
   *do,_i,1,_nfield
      _j = _j + 1
      _n%_j% = _field%_i%
   *enddo
   *vwrite,_enum,_n1,_n2,_n3,_n4,_n5,_n6,_n7,_n8
   ('EN',9(',',a8))
   *vwrite,_n9,_n10
   ('EMORE',2(',',a8))
*enddo

_cmname=
_enum=
_tt=
_nnod=
_n1= $_n2= $_n3= $_n4= $_n5= $_n6= $_n7= $_n8= $_n9= $_n10=
