      SUBROUTINE ECR_PTS
     &(IFIL,HED,NUMNP,NDIM,XYZ,IREF,ISD,IOPT,EPS,NCOPNP,M,NEL)
C
      CHARACTER*80 HED
      REAL*4  XYZ(NDIM,*)
      INTEGER IREF(*),ISD(*),M(*)
C
      COMMON / MIMMAX / XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX
C
      REWIND(IFIL)
C
      DO I=1,NUMNP
        IREF(I) = 0
        ISD(I)  = 0
      ENDDO
      WRITE(IFIL) HED
      WRITE(IFIL) NUMNP,8
      IF (NDIM.EQ.2.OR.IOPT.EQ.0) THEN
        IA = 1
        DO I=1,NEL
          NMAE = M(IA+1)
          NNO  = M(IA+3)
          IF (NCOPNP.EQ.0) THEN
            NPO = M(IA+4+NNO)
            IA2 = IA + 5 + NNO + NMAE + NPO
c
c Les 2 lignes suivantes ont ete interverties !!
c Aldjia Mazari 18/03/2002
c
            KK = 1+NNO
            NNO = NPO
          ELSE
            IA2 = IA + 4 + NNO + NMAE
            KK = 0
          ENDIF
          DO K=1,NNO
            IF (NMAE.NE.0) IREF(M(IA+3+K+KK)) = M(IA2-NNO-1+K)
            ISD(M(IA+3+K)) = M(IA+2)
          ENDDO
          IA = IA2
        ENDDO
        IF (NDIM.EQ.2) THEN
          DO I=1,NUMNP
            WRITE(IFIL) (XYZ(K,I),K=1,2),0.,0,0,0,IREF(I),ISD(I),0,0,0,0
          ENDDO
        ELSE
          DO I=1,NUMNP
cc          if (iref(i).eq.7) then
cc            ipr = -1
cc          elseif (iref(i).eq.8) then
cc            ipr = 1
cc          else
cc            ipr = 0
cc          endif
            IPR = IREF(I)-2
            WRITE(IFIL) (XYZ(K,I),K=1,3),0,0,0,IREF(I),ISD(I),0,0,ipr,0
          ENDDO
        ENDIF
      ELSE
        IA = 1
        DO I=1,NUMNP
          IJK = 0
          IF (ABS(XYZ(1,I)-XMIN).LT.EPS.OR.ABS(XYZ(1,I)-XMAX).LT.EPS)
     &        IJK = IJK+100
          IF (ABS(XYZ(2,I)-YMIN).LT.EPS.OR.ABS(XYZ(2,I)-YMAX).LT.EPS)
     &        IJK = IJK+20
          IF (ABS(XYZ(3,I)-ZMIN).LT.EPS.OR.ABS(XYZ(3,I)-ZMAX).LT.EPS)
     &        IJK = IJK+3
          IJK = -IJK
          NMAE = M(IA+1)
          NNO  = M(IA+3)
          IF (NCOPNP.EQ.0) THEN
            NPO = M(IA+4+NNO)
            IA2 = IA + 5 + NNO + NMAE + NPO
            NNO = NPO
            KK = 1+NPO
          ELSE
            IA2 = IA + 4 + NNO + NMAE
            KK = 0
          ENDIF
          DO K=1,NNO
            IF (NMAE.NE.0) IREF(M(IA+3+K+KK)) = M(IA2-NNO-1+K)
            ISD(M(IA+3+K)) = M(IA+2)
          ENDDO
          IA = IA2
cc          IF (IREF(I).LT.0) THEN
cc            IPRES = -IREF(I)
cc          ELSE
cc            IPRES = 0
cc          ENDIF
          IPRES = IREF(I)-2
          WRITE(IFIL)(XYZ(K,I),K=1,3),0,0,0,IREF(I),ISD(I),0,0,IPRES,IJK
        ENDDO
      ENDIF
      END
