      PROGRAM OBSCUR
      INCLUDE 'com_avoir.f'
      CHARACTER*1 D
      LOGICAL NOPR,LA
      INTEGER IBC6,IBC7
      REAL*4  XBC6,XBC7
      EQUIVALENCE(IBC6,XBC6)
      EQUIVALENCE(IBC7,XBC7)
      DATA PIS180 / 0.0174532925199433 /
C
 1    CALL LIFICH('Prefix of the .clairND to translate ?',0,FICH,LONG)
      NOK = 0
      INQUIRE(FILE=FICH(1:LONG)//'.clair2D',EXIST=LA)
      IF (LA) NOK = NOK+2
      INQUIRE(FILE=FICH(1:LONG)//'.clair3D',EXIST=LA)
      IF (LA) NOK = NOK+3
      IF (NOK.EQ.0) THEN
        PRINT*,'*** No file .clair2D or .clair3D with this prefix'
        STOP
      ELSEIF(NOK.EQ.2) THEN
        D = '2'
      ELSEIF(NOK.EQ.3) THEN
        D = '3'
      ELSEIF(NOK.EQ.5) THEN
        CALL LIENTIER('2d or 3d ? (2/3)',0,IDIM)
        IF (IDIM.EQ.2) THEN
          D = '2'
        ELSE
          D = '3'
        ENDIF
      ENDIF
      FICH = FICH(1:LONG)//'.clair'//D//'D'
      LONG = LONG+8
      IF (NOK.LT.5) PRINT*,'--> File '//FICH(1:LONG)//' found'
      OPEN(1,FILE=FICH(1:LONG),STATUS='OLD',ERR=1)
C
      READ(1,50) HED
      READ(1,100) NUMNP,MNDOF
C
      DO N=1,NUMNP
        READ(1,208) NN,(XYZ(L,N),L=1,3),(IBC(L,N),L=1,5),XBC6,XBC7
     &                ,(IBC(L,N),L=8,9)
        XBC6 = XBC6*PIS180
        XBC7 = XBC7*PIS180
        IBC(6,N) = IBC6
        IBC(7,N) = IBC7
      ENDDO
C
      NUMSD = 0
      N = 0
 30   READ(1,FMT=300,END=40) NN,NNTYP,NNEL,NNDS
      NUMSD = NUMSD+1
      IF (NNDS.GT.NDSMAX) THEN
        PRINT*,'*** Subdomain',NUMSD
     &        ,', too many nodes/element :',NNDS,' (max=',NDSMAX,')'
        STOP
      ENDIF
      NGROUP(NUMSD) = NN
      NTYP(NUMSD) = NNTYP
      NEL(NUMSD) = NNEL
      NDS(NUMSD) = NNDS
      NOPR = NNDS.NE.3.AND.NNDS.NE.4.AND.NNDS.NE.8
      DO I=1,NNEL
        N = N+1
        IF (NOPR) THEN
          IF (NNDS.EQ.9) THEN
            READ(1,409) (NODE(J,N),J=0,NNDS)
          ELSE
            READ(1,427) (NODE(J,N),J=0,NNDS)
          ENDIF
        ELSEIF(NNDS.EQ.8) THEN
          READ(1,408) (NODE(J,N),J=0,NNDS),NPR(N)
     &               ,(NFPR(J,N),PR(J,N),J=1,NPR(N))
        ELSEIF(NNDS.EQ.4) THEN
          READ(1,404) (NODE(J,N),J=0,NNDS),NPR(N)
     &               ,(NFPR(J,N),PR(J,N),J=1,NPR(N))
        ELSE  
          READ(1,403) (NODE(J,N),J=0,NNDS),NPR(N)
     &               ,(NFPR(J,N),PR(J,N),J=1,NPR(N))
        ENDIF
      ENDDO
      GOTO 30
 40   CLOSE(1)
C
      FICH = FICH(1:LONG-8)//'.avoir'//D//'D'
      CALL ECRITAVOIR(FICH,LONG,HED,NUMNP,NDSMAX,XYZ,IBC,NODE,NPR
     &               ,NFPR,PR,NGROUP,NTYP,NEL,NDS,NUMSD,2,0,IERR)

C
 50   FORMAT(A80)
 100  FORMAT(2I10)
ccc 208  FORMAT(I7,3F13.0,3I4,4I2,2I5)
 208  FORMAT(I7,3F13.0,3I4,2I2,2F10.0,2I5)
 300  FORMAT(4I7)
 403  FORMAT(4I7,I2,3(I2,F15.0))
 404  FORMAT(5I7,I2,4(I2,F15.0))
 409  FORMAT(10I7)
 408  FORMAT(9I7,I2,6(I2,F15.0))
 427  FORMAT(10I7,5(/7X,9I7))
      END
