      CHARACTER*80  HED
      CHARACTER*128 FICH1,FICH2
      INTEGER NODE(27)
C
      CALL LIFICH('Text file ?',0,FICH1,LF1)
      OPEN(1,FILE=FICH1(1:LF1),STATUS='OLD')
      CALL LIFICH('Prefix of the "avoir" file ?',0,FICH2,LF2)
      CALL LIENTIER('Dimension ?',0,IDIM)
      IF (IDIM.EQ.2) THEN
        OPEN(2,FILE=FICH2(1:LF2)//'.avoir2D',FORM='UNFORMATTED')
        Z = 0.
      ELSE
        IDIM = 3
        OPEN(2,FILE=FICH2(1:LF2)//'.avoir3D',FORM='UNFORMATTED')
      ENDIF
C
      READ(1,*) NUMNP,NEL,NDS
      HED = 'File translated through "txt2avoir"'
      WRITE(2) HED
      WRITE(2) NUMNP,8
      DO I=1,NUMNP
        IF (IDIM.EQ.2) THEN
          READ(1,*) K,X,Y
        ELSE
          READ(1,*) K,X,Y,Z
        ENDIF
        WRITE(2) X,Y,Z,(0,K=1,9)
      ENDDO
      WRITE(2) 1,1,NEL,NDS
      DO I=1,NEL
        READ(1,*) K,(NODE(J),J=1,NDS)
        IF (NDS.EQ.9.OR.NDS.EQ.27) THEN
          WRITE(2) K,(NODE(J),J=1,NDS)
        ELSE
          WRITE(2) K,(NODE(J),J=1,NDS),0
        ENDIF
      ENDDO
      CLOSE(1)
      CLOSE(2)
      END
