      SUBROUTINE ECR_ELM3D(IFIL,NEL,NUMSD,NODE,NDS)
C
      INTEGER NODE(28,*),NBSD(1000)
C
      IF (NUMSD.GT.1) THEN
        NUMSD_EFF = 0
        NEL_EFF   = 0
        DO 10 I=1,NUMSD
          NBSD(I) = 0
   10   CONTINUE
        NSD0 = 0
        IBADSD = 0
        DO 20 I=1,NEL
          NSD = NODE(NDS+1,I)
          NBSD(NSD) = NBSD(NSD) + 1
          IF (NSD.LT.NSD0) THEN
            PRINT*,'*** Warning. sd',NSD0,' before sd',NSD
            IBADSD = 1
          ENDIF
          NSD0 = NSD
   20   CONTINUE
Cfj        IF (IBADSD.NE.0)
Cfj     &PRINT*,'*** Les  numeros de sous-domaines seront faux dans xd3d'
        DO 30 N=1,NUMSD 
          PRINT*,'Subdomain',N,':',NBSD(N),' elements'
          IF (NBSD(N).NE.0) THEN
            NUMSD_EFF = NUMSD_EFF + 1
            NEL_EFF   = NEL_EFF + NBSD(N)
            WRITE(IFIL) NUMSD_EFF,1,NBSD(N),NDS
            NN = 0
            DO 40 I=1,NEL
              IF (NODE(NDS+1,I).EQ.N) THEN
                NN = NN+1
                WRITE(IFIL) NN,(NODE(K,I),K=1,NDS)
              ENDIF
   40       CONTINUE
          ENDIF
   30   CONTINUE 
        IF (NEL_EFF.NE.NEL) PRINT*,'*** Warning: NEL_EFF =',NEL_EFF,
     &                             ' and NEL =',NEL
      ELSE
        WRITE(IFIL) 1,1,NEL,NDS
        DO 100 I=1,NEL
          WRITE(IFIL) I,(NODE(K,I),K=1,NDS)
  100   CONTINUE
      ENDIF
      END
