      SUBROUTINE LECTURE(XINIT_FACT)
C
      INCLUDE 'com_coor.f'
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
      CHARACTER*256 MOELLE
      COMMON / SOUTERRAIN / MOELLE,LMOELLE,INOMBRE_VAR
C
      CHARACTER*80 HED
      INTEGER IBC(9)
C
      PARAMETER (LWORK=NPMAX)
      DIMENSION WORK(LWORK)
      INTEGER   IWORK(LWORK)
      CHARACTER*1 CWORK(4*NPMAX)
      EQUIVALENCE (IWORK(1),WORK(1))
      EQUIVALENCE (IWORK(1),CWORK(1))
      EQUIVALENCE (IBC(1),IWORK(4))
      CHARACTER*256 LIGNE
      CHARACTER*20 CEXP
      REAL*8 T1,T2
      LOGICAL EGAL
      DATA PI / 3.14159265358979  /
C
    1 DO I=1,80
        HED(I:I) = ' '
      ENDDO
      INOMBRE_VAR = 2
      XMIN =  BIG
      XMAX = -BIG
      YMIN =  BIG
      YMAX = -BIG
      ZMIN =  BIG
      ZMAX = -BIG
      MATMIN = 9999
      MATMAX = -9999
      IDEFOR = 0
      IGROUP = 1
      LONTIT = 0
      ICOURXYZ = 0
      IFIX = 0
      IF (ICOURB.GT.-2.AND.IARCH.EQ.0) REWIND(IFAC)
C
C Maillage
C
      IF (ICOURB.GT.0) THEN
        IF (IARCH.EQ.0) THEN
          READ(IFAC) HED
        ELSE
          CALL litrecbin(IFAC,IWORK,LLL,1)
          DO I=1,80
            HED(I:I) = CWORK(I)
          ENDDO
        ENDIF
        CALL ENLEVE_TOUS_BLANCS(HED,LONTIT,80)
        IF (LONTIT.NE.0.AND.ISTDOUT.EQ.0) WRITE(*,1000) HED(1:LONTIT)
        IF (IARCH.EQ.0) THEN
          READ(IFAC) NUMNP,MNDOF
        ELSE
          CALL litrecbin(IFAC,IWORK,LLL,0)
          NUMNP = IWORK(1)
cc          MNDOF = IWORK(2)
        ENDIF
        IF (NUMNP.GT.NPMAX) CALL TROPDEPOINTS(NUMNP,0,0)
        NBCORN = 0
        IPS2D  = 1
        DO 9 N=1,NUMNP
          IF (IARCH.EQ.0) THEN
            READ(IFAC) X(N),Y(N),Z(N),IBC
          ELSE
            CALL litrecbin(IFAC,IWORK,LLL,0)
            X(N) = WORK(1)
            Y(N) = WORK(2)
            Z(N) = WORK(3)
          ENDIF
          IREF(N)  = IBC(4)
          IREF3(N) = IBC(5)
          MATMIN = MIN(MATMIN,IREF3(N))
          MATMAX = MAX(MATMAX,IREF3(N))
Cfj          IF (ABS(IBC(8)).LT.1000) THEN
Cfj            IREF2(N) = IBC(8)+2
Cfj          ELSEIF(IBC(8).GT.0) THEN
Cfj            IREF2(N) = 13
Cfj          ELSE
Cfj            IREF2(N) = 14
Cfj          ENDIF
          IBC9 = MOD(IABS(IBC(9)),1000)
          IF (IBC9.EQ.111.AND.IFIX.LE.0) THEN
            IFIX = N
          ELSEIF(IBC9.EQ.110.AND.IFIX.EQ.0) THEN
            IFIX = -N
          ENDIF
          IBC9B = IABS(IBC(9))/1000
          IPS2D = MIN(IPS2D,MOD(IBC9,2))
          IBLOQ(N) = 8*IBC9B + 4*MOD(IBC9,2) + 2*MOD(IBC9/10,2)
     &             + MOD(IBC9/100,2)
C
C Deplacement unilatéral
C
          IF (IBC(8).GE.9901.AND.IBC(8).LE.9906) THEN
            IBLOQ(N) = IBLOQ(N) + 100*(IBC(8)-9900)
C
C Contact unilatéral
C
          ELSEIF(IBC(8).GE.8801.AND.IBC(8).LE.8899) THEN
            IBCC = IBC(8)-8800
            IBLOQ(N) = IBLOQ(N) + 10000*IBCC
C
C Contact bilatéral
C
          ELSEIF(IBC(8).GE.-8899.AND.IBC(8).LE.-8801) THEN
            IBCC = ABS(IBC(8))-8800
            IBLOQ(N) = IBLOQ(N) + 1000000*IBCC
          ENDIF
          IF (MOD(IBC(5),2).EQ.1.AND.(IBC(4).EQ.8.OR.IBC(4).EQ.11)) THEN
            NBCORN = NBCORN+1
            ICOR(N) = 1
            IF (IBC(1).EQ.1.AND.IBC(2).EQ.1) THEN
              XCCOR = X(N)
              YCCOR = Y(N)
              ZCCOR = Z(N)
            ENDIF
          ELSE
            ICOR(N) = 0
          ENDIF
          XMIN = AMIN1(XMIN,X(N))
          XMAX = AMAX1(XMAX,X(N))
          YMIN = AMIN1(YMIN,Y(N))
          YMAX = AMAX1(YMAX,Y(N))
          ZMIN = AMIN1(ZMIN,Z(N))
          ZMAX = AMAX1(ZMAX,Z(N))
    9   CONTINUE
        IF (IEXAG.EQ.0.AND.IPS2D.NE.0.AND.IWILD.NE.0
     & .AND.NOM_FICH(LONG-7:LONG).EQ.'.avoir3D') THEN
          CALL PREMIER_LIBRE(IBID)
          OPEN(IBID,FILE=NOM_FICH(1:LONG-2)//'2D',FORM='UNFORMATTED'
     &        ,STATUS='OLD',IOSTAT=IERR)
          CLOSE(IBID)
          IF (IERR.EQ.0) THEN
            NOM_FICH(LONG-1:LONG-1) = '2'
            IF (ISTDOUT.EQ.0) THEN
              IF (ILANG.EQ.0) THEN
                PRINT*,'En fait on préfère ouvrir '//NOM_FICH(1:LONG)
              ELSE
                PRINT*,'I preferred opening '//NOM_FICH(1:LONG)
              ENDIF
            ENDIF
            IF (IARCH.EQ.0) THEN
              OPEN(IFAC,FILE=NOM_FICH(1:LONG),FORM='UNFORMATTED'
     &            ,STATUS='OLD')
            ELSE
              CALL ouvrebin(IFAC,NOM_FICH(1:LONG)//CHAR(0),0,IRC)
            ENDIF
            GOTO 1
          ENDIF
        ENDIF
        IF (IEXAG.NE.0) THEN
          XMIN0 =  BIG
          XMAX0 = -BIG
          YMIN0 =  BIG
          YMAX0 = -BIG
          IDEFOR = 1
          IF (XINIT_FACT.NE.BIGS) THEN
            IF (XINIT_FACT.EQ.311263.) THEN
              FACEXA = 1.
            ELSE
              FACEXA = XINIT_FACT
            ENDIF
          ELSE
            FACEXA = 1.
          ENDIF
          IF (IEXAG.EQ.1) THEN
            IF (IARCH.EQ.0) THEN
              REWIND(IFAC2)
              READ(IFAC2) HED
            ELSE
              CALL litrecbin(IFAC2,IWORK,LLL,1)
              DO I=1,80
                HED(I:I) = CWORK(I)
              ENDDO
            ENDIF
            CALL ENLEVE_TOUS_BLANCS(HED,LONTIT,80)
            IF (LONTIT.NE.0) WRITE(*,1000) HED(1:LONTIT)
            IF (IARCH.EQ.0) THEN
              READ(IFAC2) NNN,MNDOF
            ELSE
              CALL litrecbin(IFAC2,IWORK,LLL,0)
              NNN   = IWORK(1)
cc              MNDOF = IWORK(2)
            ENDIF
            IF (NNN.NE.NUMNP) THEN
              IF (ILANG.EQ.0) THEN
                PRINT*,
     &               '*** Fichier .avoir incompatible avec le .deformee'
              ELSE
                PRINT*,
     &               '*** File .avoir not compatible with the .deformee'
              ENDIF
              IEXAG = 0
              GOTO 10
            ENDIF
            DO N=1,NUMNP
              IF (IARCH.EQ.0) THEN
                READ(IFAC2) XN,YN,ZN
              ELSE
                CALL litrecbin(IFAC2,IWORK,LLL,0)
                XN = WORK(1)
                YN = WORK(2)
                ZN = WORK(3)
              ENDIF
              DEPX(N) = X(N)-XN
              DEPY(N) = Y(N)-YN
              DEPZ(N) = Z(N)-ZN
              IF (FACEXA.NE.1.) THEN
                X(N) = XN + FACEXA*DEPX(N)
                Y(N) = YN + FACEXA*DEPY(N)
                Z(N) = ZN + FACEXA*DEPZ(N)
              ENDIF
              XMIN0 = AMIN1(XMIN0,XN)
              XMAX0 = AMAX1(XMAX0,XN)
              YMIN0 = AMIN1(YMIN0,YN)
              YMAX0 = AMAX1(YMAX0,YN)
            ENDDO
          ELSE
cc            READ(IFAC2,*) NNN
            CALL LITITRE(IFAC2,NNN,IERR)
            IF (NNN.NE.NUMNP) THEN
              IF (ISTDOUT.EQ.0) THEN
                IF (ISTDOUT.EQ.0) THEN
                  IF (ILANG.EQ.0) THEN
                    PRINT*,
     &                 '*** Fichier .depl incompatible avec le maillage'
                  ELSE
                    PRINT*,
     &             '*** File .depl not compatible with the mesh file'
                  ENDIF
                ENDIF
              ENDIF
              IEXAG = 0
              CALL TUELEGNEW
              GOTO 10
            ENDIF
            IF (IEXAG.EQ.2) THEN
              DO N=1,NUMNP
                READ(IFAC2,*) DEPX(N),DEPY(N)
                DEPZ(N) = 0.
              ENDDO
            ELSE
              DO N=1,NUMNP
                READ(IFAC2,*) DEPX(N),DEPY(N),DEPZ(N)
              ENDDO
            ENDIF
            XMIN0 = XMIN
            XMAX0 = XMAX
            YMIN0 = YMIN
            YMAX0 = YMAX
            XMIN =  BIG
            XMAX = -BIG
            YMIN =  BIG
            YMAX = -BIG
            ZMIN =  BIG
            ZMAX = -BIG
            DO N=1,NUMNP
              X(N) = X(N) + FACEXA*DEPX(N)
              Y(N) = Y(N) + FACEXA*DEPY(N)
              Z(N) = Z(N) + FACEXA*DEPZ(N)
              XMIN = AMIN1(XMIN,X(N))
              XMAX = AMAX1(XMAX,X(N))
              YMIN = AMIN1(YMIN,Y(N))
              YMAX = AMAX1(YMAX,Y(N))
              ZMIN = AMIN1(ZMIN,Z(N))
              ZMAX = AMAX1(ZMAX,Z(N))
            ENDDO
          ENDIF
 10       CLOSE(IFAC2)
          VITMIN = BIG
          VITMAX = -BIG
          DO N=1,NUMNP
            VITN(1,N) = DEPX(N)
            VITN(2,N) = DEPY(N)
            VITN(3,N) = DEPZ(N)
            TOTO = SQRT(DEPX(N)**2+DEPY(N)**2+DEPZ(N)**2)
            VALX(N) = TOTO
            VITMIN = MIN(VITMIN,TOTO)
            VITMAX = MAX(VITMAX,TOTO)
          ENDDO
          IFVIT = 2
          IFISO = 1
          IF (NOM_FICH(LONG-7:LONG-7).EQ.'.') THEN
            NOM_VIT = NOM_FICH(1:LONG-7)//'depl'
            LONVIT = LONG-3
          ELSE
            NOM_VIT = NOM_FICH(1:LONG)
            LONVIT = LONG
          ENDIF
          NOM_ISO = '$|'//NOM_VIT(1:LONVIT)//'|'
          LONISO  = LONVIT+3
          VMIN = VITMIN
          VMAX = VITMAX
          VMIN0 = VMIN
          VMAX0 = VMAX
          VMINISO = VMIN
          VMAXISO = VMAX
          ISOBID = 7
          CALL METLEGNEW
        ENDIF
        IF (ZMIN.NE.ZMAX.AND.NBCORN.NE.0)
     &    CALL RAYTMS(X,Y,Z,ICOR,RAYON0,BIG,NUMNP,NBCORN)
C
C Courbe(s) 3d dans un fichier
C
      ELSEIF(ICOURB.EQ.-1) THEN
        IF (IARCH.EQ.0) THEN
          READ(IFAC) NUMX,NUMY
        ELSE
          CALL litrecbin(IFAC,IWORK,LLL,0)
          NUMX = IWORK(1)
          NUMY = IWORK(2)
        ENDIF
        IF (NUMX.EQ.0) THEN
          IOPTCO = NUMY
          IF (IARCH.EQ.0) THEN
            READ(IFAC) NUMX,NUMY
          ELSE
            CALL litrecbin(IFAC,IWORK,LLL,0)
            NUMX = IWORK(1)
            NUMY = IWORK(2)
          ENDIF
        ELSE
          IOPTCO = 0
        ENDIF
C
        NUMNP0 = NUMX*NUMY
        IF (NUMX.GT.NXYMAX.OR.NUMY.GT.NXYMAX) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,
     &           '*** Votre fichier comprend',NUMX,' x',NUMY,' points'
            PRINT*,'*** Alors que le maximum permis est',NXYMAX
          ELSE
            PRINT*,'*** Your file contains',NUMX,' x',NUMY,' points'
            PRINT*,'*** Maximum allowed =',NXYMAX
          ENDIF
          STOP
        ENDIF
        IF (NUMNP0.GT.NPMAX) CALL TROPDEPOINTS(NUMNP0,0,0)
        IF (IARCH.EQ.0) THEN
          READ(IFAC) (XSU(I),I=1,NUMX),(YSU(I),I=1,NUMY)
        ELSE
          CALL litrecbin(IFAC,IWORK,LLL,0)
          DO I=1,NUMX
            XSU(I) = WORK(I)
          ENDDO
          DO I=1,NUMY
            YSU(I) = WORK(I+NUMX)
          ENDDO
        ENDIF
        IF (IOPTCO.NE.0) THEN
          IF (IARCH.EQ.0) THEN
            READ(IFAC) (Z(NPMAX+I),I=1,NUMNP0)
          ELSE
            CALL litrecbin(IFAC,IWORK,LLL,0)
            DO I=1,NUMNP0
              Z(NPMAX+I) = WORK(I)
            ENDDO
          ENDIF
          NUMSD = 1
          NUMNP = NUMNP0
          DO I=1,NUMNP
            IREF(I)  = 0
            IREF3(I) = 0
            IBLOQ(I) = 0
          ENDDO
C
C Coordonnees cylindriques r=f(theta,z)
C
          IF (IOPTCO.EQ.1) THEN
            IF (ISTDOUT.EQ.0) THEN
              IF (ILANG.EQ.0) THEN
                PRINT*,'Courbe en coordonnées cylindriques r=f(theta,z)'
              ELSE
                PRINT*,'Cylindrical coordinates r=f(theta,z)'
              ENDIF
            ENDIF
            RMOY = 0.
            DO I=1,NUMNP
              THETA = XSU(1+MOD(I-1,NUMX))
              X(I) = Z(NPMAX+I)*COS(THETA)
              Y(I) = Z(NPMAX+I)*SIN(THETA)
              Z(I) = YSU(1+(I-1)/NUMX)
              XMIN = MIN(XMIN,X(I))
              XMAX = MAX(XMAX,X(I))
              YMIN = MIN(YMIN,Y(I))
              YMAX = MAX(YMAX,Y(I))
              ZMIN = MIN(ZMIN,Z(I))
              ZMAX = MAX(ZMAX,Z(I))
              RMOY = RMOY+Z(NPMAX+I)
            ENDDO
            RMOY = RMOY/REAL(NUMNP)
            DO I=1,NUMNP
              THETA = XSU(1+MOD(I-1,NUMX))
              DEPX(I) = X(I)-RMOY*COS(THETA)
              DEPY(I) = Y(I)-RMOY*SIN(THETA)
              DEPZ(I) = 0.
              ISD(I) = 1
            ENDDO
            XMIREE = XMIN
            XMAREE = XMAX
            YMIREE = YMIN
            YMAREE = YMAX
C
C Coordonnees spheriques
C
          ELSEIF(IOPTCO.EQ.2) THEN
            IF (ILANG.EQ.0) THEN
              PRINT*,'Courbe en coordonéees sphériques r=f(theta,phi)'
            ELSE
              PRINT*,'Spherical coordinates r=f(theta,phi)'
            ENDIF
            RMOY = 0.
            DO I=1,NUMNP
              THETA = XSU(1+MOD(I-1,NUMX))
              PHI   = YSU(1+(I-1)/NUMX)
              X(I) = Z(NPMAX+I)*SIN(PHI)*COS(THETA)
              Y(I) = Z(NPMAX+I)*SIN(PHI)*SIN(THETA)
              Z(I) = Z(NPMAX+I)*COS(PHI)
              XMIN = MIN(XMIN,X(I))
              XMAX = MAX(XMAX,X(I))
              YMIN = MIN(YMIN,Y(I))
              YMAX = MAX(YMAX,Y(I))
              ZMIN = MIN(ZMIN,Z(I))
              ZMAX = MAX(ZMAX,Z(I))
              RMOY = RMOY+Z(NPMAX+I)
            ENDDO
            RMOY = RMOY/REAL(NUMNP)
            DO I=1,NUMNP
              THETA = XSU(1+MOD(I-1,NUMX))
              PHI   = YSU(1+(I-1)/NUMX)
              DEPX(I) = X(I)-RMOY*SIN(PHI)*COS(THETA)
              DEPY(I) = Y(I)-RMOY*SIN(PHI)*SIN(THETA)
              DEPZ(I) = Z(I)-RMOY*COS(PHI)
              ISD(I) = 1
            ENDDO
            XMIREE = XMIN
            XMAREE = XMAX
            YMIREE = YMIN
            YMAREE = YMAX
C
C Coordonnees cylindriques z=f(r,theta)
C
          ELSE
            IF (ISTDOUT.EQ.0) THEN
              IF (ILANG.EQ.0) THEN
                PRINT*,'Courbe en coordonnées cylindriques z=f(r,theta)'
              ELSE
                PRINT*,'Cylindric coordinates z=f(r,theta)'
              ENDIF
            ENDIF
            ZMOY = 0.
            DO I=1,NUMNP
              RRR   = XSU(1+MOD(I-1,NUMX))
              THETA = YSU(1+(I-1)/NUMX)
              X(I) = RRR*COS(THETA)
              Y(I) = RRR*SIN(THETA)
              Z(I) = Z(NPMAX+I)
              XMIN = MIN(XMIN,X(I))
              XMAX = MAX(XMAX,X(I))
              YMIN = MIN(YMIN,Y(I))
              YMAX = MAX(YMAX,Y(I))
              ZMIN = MIN(ZMIN,Z(I))
              ZMAX = MAX(ZMAX,Z(I))
              ZMOY = ZMOY+Z(I)
            ENDDO
            ZMOY = ZMOY/REAL(NUMNP)
            DO I=1,NUMNP
              THETA = YSU(1+(I-1)/NUMX)
              DEPX(I) = X(I)
              DEPY(I) = Y(I)
              DEPZ(I) = Z(I) - ZMOY
              ISD(I) = 1
            ENDDO
          ENDIF
          XMIREE = XMIN
          XMAREE = XMAX
          YMIREE = YMIN
          YMAREE = YMAX
C
C Coordonnees cartesiennes
C
        ELSE
          IF (ISTDOUT.EQ.0) THEN
            IF (ILANG.EQ.0) THEN
              PRINT*,'Courbe en coordonnées cartésiennes z=f(x,y)'
            ELSE
              PRINT*,'Cartesian coordinates z=f(x,y)'
            ENDIF
          ENDIF
          NUMNP = 0
          IF (IARCH.EQ.0) THEN
 100        READ(IFAC,END=101,ERR=101) (Z(NUMNP+I),I=1,NUMNP0)
            NUMNP = NUMNP+NUMNP0
            GOTO 100
          ELSE
 200        CALL litrecbin(IFAC,IWORK,LLL,0)
            IF (LLL.GT.0) THEN
              DO I=1,NUMNP0
                Z(I+NUMNP) = WORK(I)
              ENDDO
              NUMNP = NUMNP+NUMNP0
              GOTO 200
            ENDIF
          ENDIF
 101      NUMSD = NUMNP/NUMNP0
          IGROUP = NUMSD
          DO J=1,NUMY
            YMIN = MIN(YMIN,YSU(J))
            YMAX = MAX(YMAX,YSU(J))
          ENDDO
          DO I=1,NUMX
            XMIN = MIN(XMIN,XSU(I))
            XMAX = MAX(XMAX,XSU(I))
          ENDDO
          XMIREE = XMIN
          XMAREE = XMAX
          YMIREE = YMIN
          YMAREE = YMAX
          II = 0
          DO N=1,NUMSD
            DO I=1,NUMNP0
              II = II+1
              ISD(II) = N
            ENDDO
          ENDDO
          IF (NUMSD.EQ.1) THEN
            DO I=1,NUMNP
              ZMIN = MIN(ZMIN,Z(I))
              ZMAX = MAX(ZMAX,Z(I))
              X(I) = XSU(1+MOD(I-1,NUMX))
              Y(I) = YSU(1+(I-1)/NUMX)
              DEPX(I) = X(I)
              DEPY(I) = Y(I)
              DEPZ(I) = Z(I)
            ENDDO
            XMIN0 = 0.
            XMAX0 = 0.
            YMIN0 = 0.
            YMAX0 = 0.
          ELSE
            IFRONT = -1
            DO I=1,NUMNP0
              XI = XSU(1+MOD(I-1,NUMX))
              YI = YSU(1+(I-1)/NUMX)
              XMIMI = BIG
              XMAMA = -BIG
              YMIMI = BIG
              YMAMA = -BIG
              ZMIMI = BIG
              ZMAMA = -BIG
              DO K=1,NUMSD
                II = I+(K-1)*NUMNP0
                ZMIN = MIN(ZMIN,Z(II))
                ZMAX = MAX(ZMAX,Z(II))
                XMIMI = MIN(XMIMI,X(II))
                XMAMA = MAX(XMAMA,X(II))
                YMIMI = MIN(YMIMI,Y(II))
                YMAMA = MAX(YMAMA,Y(II))
                ZMIMI = MIN(ZMIMI,Z(II))
                ZMAMA = MAX(ZMAMA,Z(II))
                X(II) = XI
                Y(II) = YI
              ENDDO
              XMIDMID = .5*(XMIMI+XMAMA)
              YMIDMID = .5*(YMIMI+YMAMA)
              ZMIDMID = .5*(ZMIMI+ZMAMA)
              DO K=1,NUMSD
                II = I+(K-1)*NUMNP0
                DEPX(II) = X(II)-XMIDMID
                DEPY(II) = Y(II)-YMIDMID
                DEPZ(II) = Z(II)-ZMIDMID
              ENDDO
            ENDDO
            XMIN0 = XMIDMID
            XMAX0 = XMIDMID
            YMIN0 = YMIDMID
            YMAX0 = YMIDMID
          ENDIF
        ENDIF
        CLOSE(IFAC)
      ELSEIF(ICOURB.EQ.-2) THEN
C
C Fonction tapee au clavier z=f(x,y)
C
        NUMSD = 1
 27     IF (ILANG.EQ.0) THEN
          CALL LIENTIER('Nombre de points en X ?',0,NUMX)
          CALL LIENTIER('Nombre de points en Y ?',0,NUMY)
        ELSE
          CALL LIENTIER('Number of points in the X direction ?',0,NUMX)
          CALL LIENTIER('Number of points in the Y direction ?',0,NUMY)
        ENDIF
        NUMX = MAX(NUMX,3)
        NUMY = MAX(NUMY,3)
        IF (NUMX.GT.NXYMAX.OR.NUMY.GT.NXYMAX) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,'*** Trop de points dans une direction'
            PRINT*,'*** Maximum permis :',NXYMAX
          ELSE
            PRINT*,'*** Too many points in one direction'
            PRINT*,'*** Maximum allowed:',NXYMAX
          ENDIF
          GOTO 27
        ENDIF
        NUMNP = NUMX*NUMY
        IF (NUMNP.GT.NPMAX) THEN
          CALL TROPDEPOINTS(NUMNP,0,1)
          GOTO 27
        ENDIF
 28     IF (ILANG.EQ.0) THEN
          CALL LI2REEL1('Entrez Xmin et Xmax',0,XMIN,XMAX)
        ELSE
          CALL LI2REEL1('Enter Xmin and Xmax',0,XMIN,XMAX)
        ENDIF
        IF (XMIN.GT.XMAX) THEN
          CALL ECHR(XMIN,XMAX)
        ELSEIF(XMIN.EQ.XMAX) THEN
          GOTO 28
        ENDIF
        IF (ILANG.EQ.0) THEN
          CALL LI2REEL1('Entrez Ymin et Ymax',0,YMIN,YMAX)
        ELSE
          CALL LI2REEL1('Enter Ymin and Ymax',0,YMIN,YMAX)
        ENDIF
        IF (YMIN.GT.YMAX) THEN
          CALL ECHR(YMIN,YMAX)
        ELSEIF(YMIN.EQ.YMAX) THEN
          GOTO 28
        ENDIF
        XMIREE = XMIN
        XMAREE = XMAX
        YMIREE = YMIN
        YMAREE = YMAX
        CALL INITIS(WORK,LWORK,0,0)
 30     CONTINUE
        IF (ILANG.EQ.0) THEN
          PRINT*,'>>> Tapez l''expression ;',
     &' (une seule ligne, syntaxe Fortran, variables x,y)'
        ELSE
          PRINT*,'>>> Type the expression ;',
     &' (one line, Fortran syntax, variables x,y)'
        ENDIF
        LFON = 400
        CALL FONINI(WORK,LFON,ICODE)
        CALL FONDEF(WORK,CEXP,IFON,ICODE)
        IF (ICODE.NE.0) GOTO 30
        CALL FONDRL(LIGNE)
        XL = XMAX-XMIN
        YL = YMAX-YMIN
        PASX = XL/REAL(NUMX-1)
        PASY = YL/REAL(NUMY-1)
        DO I=1,NUMX
          XSU(I) = XMIN + REAL(I-1)*PASX
        ENDDO
        DO I=1,NUMY
          YSU(I) = YMIN + REAL(I-1)*PASY
        ENDDO
        DO I=1,NUMNP
          X(I) = XSU(1+MOD(I-1,NUMX))
          Y(I) = YSU(1+(I-1)/NUMX)
          IREF(I)  = 0
          IREF3(I) = 0
          IBLOQ(I) = 0
          CALL FON2RR(WORK,IFON,X(I),Y(I),Z(I),ICODE)
          ZMIN = MIN(ZMIN,Z(I))
          ZMAX = MAX(ZMAX,Z(I))
          DEPX(I) = X(I)
          DEPY(I) = Y(I)
          DEPZ(I) = Z(I)
        ENDDO
        XMIN0 = 0.
        XMAX0 = 0.
        YMIN0 = 0.
        YMAX0 = 0.
        ILEG = 1
        ICTLEG = 7
        LEG(1:LMOELLE) = MOELLE(1:LMOELLE)
        LONLEG = LMOELLE
        IF (LONLEG.GT.50) FACLEG = .45/.65
      ELSEIF(ICOURB.EQ.-3) THEN
C
C Fonction parametree tapee au clavier
C
        NUMSD = 1
 37     IF (ILANG.EQ.0) THEN
          CALL LIENTIER('Nombre de points en U ?',0,NUMX)
          CALL LIENTIER('Nombre de points en V ?',0,NUMY)
        ELSE
          CALL LIENTIER('Number of points along U ?',0,NUMX)
          CALL LIENTIER('Number of points along V ?',0,NUMY)
        ENDIF
        NUMX = MAX(NUMX,3)
        NUMY = MAX(NUMY,3)
        IF (NUMX.GT.NXYMAX.OR.NUMY.GT.NXYMAX) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,'*** Trop de points dans une direction'
            PRINT*,'*** Maximum permis :',NXYMAX
          ELSE
            PRINT*,'*** Too many points in one direction'
            PRINT*,'*** Maximum allowed :',NXYMAX
          ENDIF
          GOTO 37
        ENDIF
        NUMNP = NUMX*NUMY
        IF (NUMNP.GT.NPMAX) THEN
          CALL TROPDEPOINTS(NUMNP,0,1)
          GOTO 37
        ENDIF
 38     IF (ILANG.EQ.0) THEN
          CALL LI2REEL1('Entrez Umin et Umax',0,UMIN,UMAX)
        ELSE
          CALL LI2REEL1('Enter Umin and Umax',0,UMIN,UMAX)
        ENDIF
        IF (UMIN.GT.UMAX) THEN
          CALL ECHR(UMIN,UMAX)
        ELSEIF(UMIN.EQ.UMAX) THEN
          GOTO 38
        ENDIF
        IF (ILANG.EQ.0) THEN
          CALL LI2REEL1('Entrez Vmin et Vmax',0,VMIN,VMAX)
        ELSE
          CALL LI2REEL1('Enter Vmin and Vmax',0,VMIN,VMAX)
        ENDIF
        IF (VMIN.GT.VMAX) THEN
          CALL ECHR(VMIN,VMAX)
        ELSEIF(VMIN.EQ.VMAX) THEN
          GOTO 38
        ENDIF
        XMIREE = XMIN
        XMAREE = XMAX
        YMIREE = YMIN
        YMAREE = YMAX
        CALL INITIS(WORK,LWORK,0,0)
        LFON = 400
        UL = UMAX-UMIN
        VL = VMAX-VMIN
        PASU = UL/REAL(NUMX-1)
        PASV = VL/REAL(NUMY-1)
        DO I=1,NUMX
          UUU(I) = UMIN + REAL(I-1)*PASU
        ENDDO
        DO I=1,NUMY
          VVV(I) = VMIN + REAL(I-1)*PASV
        ENDDO
        IIII = 0
 40     IIII = IIII+1
        IF (ILANG.EQ.0) THEN
          IF (IIII.EQ.1) THEN
            PRINT*,'>>> Tapez l''expression de X ;',
     &           ' (une seule ligne, syntaxe Fortran)'
          ELSEIF(IIII.EQ.2) THEN
            PRINT*,'>>> Tapez l''expression de Y ;',
     &           ' (une seule ligne, syntaxe Fortran)'
          ELSE
            PRINT*,'>>> Tapez l''expression de Z ;',
     &           ' (une seule ligne, syntaxe Fortran)'
          ENDIF
        ELSE
          IF (IIII.EQ.1) THEN
            PRINT*,'>>> Type the expression for X ;',
     &           ' (one ligne, Fortran syntax)'
          ELSEIF(IIII.EQ.2) THEN
            PRINT*,'>>> Type the expression for Y ;',
     &           ' (one ligne, Fortran syntax)'
          ELSE
            PRINT*,'>>> Type the expression for Z ;',
     &           ' (one ligne, Fortran syntax)'
          ENDIF
        ENDIF
        CALL FONINI(WORK,LFON,ICODE)
        CALL FONDEF(WORK,CEXP,IFON,ICODE)
        IF (ICODE.NE.0) GOTO 40
        CALL FONDRL(LIGNE)
        IF (IIII.EQ.1) THEN
          DO I=1,NUMNP
            IREF(I)  = 0
            IREF3(I) = 0
            IBLOQ(I) = 0
            CALL FON2RR(WORK,IFON
     &     ,UUU(1+MOD(I-1,NUMX)),VVV(1+(I-1)/NUMX),X(I),ICODE)
            XMIN = MIN(XMIN,X(I))
            XMAX = MAX(XMAX,X(I))
            DEPX(I) = X(I)
          ENDDO
          GOTO 40
        ELSEIF(IIII.EQ.2) THEN
          DO I=1,NUMNP
            IREF(I)  = 0
            IREF3(I) = 0
            IBLOQ(I) = 0
            CALL FON2RR(WORK,IFON
     &     ,UUU(1+MOD(I-1,NUMX)),VVV(1+(I-1)/NUMX),Y(I),ICODE)
            YMIN = MIN(YMIN,Y(I))
            YMAX = MAX(YMAX,Y(I))
            DEPY(I) = Y(I)
          ENDDO
          GOTO 40
        ELSE
          DO I=1,NUMNP
            IREF(I)  = 0
            IREF3(I) = 0
            IBLOQ(I) = 0
            CALL FON2RR(WORK,IFON
     &     ,UUU(1+MOD(I-1,NUMX)),VVV(1+(I-1)/NUMX),Z(I),ICODE)
            ZMIN = MIN(ZMIN,Z(I))
            ZMAX = MAX(ZMAX,Z(I))
            DEPZ(I) = Z(I)
          ENDDO
        ENDIF
        XMIN0 = 0.
        XMAX0 = 0.
        YMIN0 = 0.
        YMAX0 = 0.
c        ILEG = 1
c        ICTLEG = 7
c        LEG(1:LMOELLE) = MOELLE(1:LMOELLE)
c        LONLEG = LMOELLE
C
C Bitmap (pbm - dithered, ou pgm - niveaux de gris)
C
      ELSEIF(ICOURB.EQ.-4) THEN
        NBCOM = 0
 3232   READ(IFAC,'(A1)') HED(3:3)
        IF (HED(3:3).EQ.'#') THEN
          NBCOM = NBCOM+1
          GOTO 3232
        ELSE
          BACKSPACE(IFAC)
        ENDIF
        IF (IPBM.NE.0) THEN
          READ(IFAC,*) NUMX,NUMY
          MAXVAL = 0
        ELSE
          READ(IFAC,*) NUMX,NUMY,MAXVAL
        ENDIF
        NUMNP = NUMX*NUMY
        IF (NUMX.GT.NXYMAX.OR.NUMY.GT.NXYMAX) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,
     &           '*** Votre fichier comprend',NUMX,' x',NUMY,' points'
            PRINT*,'*** Alors que le maximum permis est',NXYMAX
          ELSE
            PRINT*,
     &           '*** Your file contains',NUMX,' x',NUMY,' points'
            PRINT*,'*** Maximum allowed =',NXYMAX
          ENDIF
          STOP
        ENDIF
        IF (NUMNP.GT.NPMAX) CALL TROPDEPOINTS(NUMNP,0,0)
        IF (ISTDOUT.EQ.0) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,'Fichier Bitmap'
          ELSE
            PRINT*,'Bitmap file'
          ENDIF
        ENDIF
C
C Raw
C
        IF (IPBM.EQ.2.OR.IPGM.EQ.2) THEN
          CLOSE(IFAC)
          NBCOM = NBCOM+4
          IF (NBCOM.LT.10) THEN
            WRITE(CEXP(1:6),'(2H +,I1,3H   )') NBCOM
          ELSEIF(NBCOM.LT.100) THEN
            WRITE(CEXP(1:6),'(2H +,I2,2H  )') NBCOM
          ELSE
            WRITE(CEXP(1:6),'(2H +,I3,1H )') NBCOM
          ENDIF
          print*,
     &         'tail'//CEXP(1:6)//NOM_FICH(1:LONG)//'> /tmp/bidonbidon'
          CALL EXEC(
     &         'tail'//CEXP(1:6)//NOM_FICH(1:LONG)//'> /tmp/bidonbidon')
          CALL ouvrebin(IFAC,'/tmp/bidonbidon'//CHAR(0),0,IRC)
C Raw pbm
          IF (IPBM.EQ.2) THEN
            IF (MOD(NUMNP,8).EQ.0) THEN
              N = NUMNP/8
            ELSE
              N = 1+NUMNP/8
            ENDIF
            CALL litduncoup(IFAC,CWORK,N)
            NN = 0
            DO I=1,N
              K = ICHAR(CWORK(I))
              DO J=8,1,-1
                Z(NN+J) = MOD(K,2)
                K = K/2
              ENDDO
              NN = NN+8
            ENDDO
C Raw pgm
          ELSEIF(IPGM.EQ.2) THEN
            IF (MAXVAL.LT.256) THEN
              CALL litduncoup(IFAC,CWORK,NUMNP)
              DO I=1,NUMNP
                Z(I) = ICHAR(CWORK(I))
              ENDDO
            ELSE
              CALL litduncoup(IFAC,CWORK,2*NUMNP)
              DO I=1,NUMNP
                II = 2*I-1
                Z(I) = 256*ICHAR(CWORK(II)) + ICHAR(CWORK(II+2))
              ENDDO
            ENDIF
          ENDIF
          CALL fermebin(IFAC)
          CALL EXEC('/bin/rm -f /tmp/bidonbidon')
        ELSE
          READ(IFAC,*) (Z(I),I=1,NUMNP)
        ENDIF
        XMIN = 0.
        YMIN = 0.
        DX = 1.
        DY = 1.
        IF (IPBM.NE.2.AND.IPGM.NE.2) THEN
          READ(IFAC,*,ERR=3131,END=3131) XMIN,DX,YMIN,DY
 3131     CLOSE(IFAC)
        ENDIF
        XMAX = XMIN+DX*REAL(NUMX-1)
        YMAX = YMIN+DY*REAL(NUMY-1)
        XMIREE = XMIN
        XMAREE = XMAX
        YMIREE = YMIN
        YMAREE = YMAX
        DO I=1,NUMX
          XSU(I) = XMIN+DX*REAL(I-1)
        ENDDO
        DO I=1,NUMY
          YSU(I) = YMIN+DY*REAL(I-1)
        ENDDO
        ZMIN = BIG
        ZMAX = -BIG
        NN = (NUMY/2)*NUMX
        DO I=1,NUMNP
          IF (I.LE.NN) THEN
            P = 1 + MOD(I-1,NUMX)
            Q = 1 + (I-1)/NUMX
            II = (NUMY-Q)*NUMX + P
            CALL ECHR(Z(I),Z(II))
          ENDIF
          ZMIN = MIN(ZMIN,Z(I))
          ZMAX = MAX(ZMAX,Z(I))
          X(I) = XSU(1+MOD(I-1,NUMX))
          Y(I) = YSU(1+(I-1)/NUMX)
          IREF(I)  = 0
          IREF3(I) = 0
          IBLOQ(I) = 0
          DEPX(I) = X(I)
          DEPY(I) = Y(I)
          DEPZ(I) = Z(I)
        ENDDO
        XMIN0 = 0.
        XMAX0 = 0.
        YMIN0 = 0.
        YMAX0 = 0.
        I2D = 0
        NUMSD = 1
      ELSEIF(ICOURB.EQ.-5) THEN
C
C Fichier de points xyz (generation d'un maillage Delaunay -> nappe)
C ou bien courbe (1d) dans l'espace si fichier commence par #+
C
 3333   READ(IFAC,'(A2)') HED(1:2)
        IF (HED(1:1).EQ.'#') THEN
          IF (HED(2:2).EQ.'+') ICOURXYZ = 1
          GOTO 3333
        ELSE
          BACKSPACE(IFAC)
        ENDIF
        NUMNP = 0
        XMIN = BIG
        XMAX = -BIG
        YMIN = BIG
        YMAX = -BIG
        ZMIN = BIG
        ZMAX = -BIG
        NPMAX2 = MIN(1+NFMAX/2,NPMAX)
        DO I=1,NPMAX2
          READ(IFAC,*,END=3334,ERR=3334) X(I),Y(I),Z(I)
          NUMNP = NUMNP+1
          XMIN = MIN(XMIN,X(I))
          XMAX = MAX(XMAX,X(I))
          YMIN = MIN(YMIN,Y(I))
          YMAX = MAX(YMAX,Y(I))
          ZMIN = MIN(ZMIN,Z(I))
          ZMAX = MAX(ZMAX,Z(I))
          IREF(I)  = 0
          IREF3(I) = 0
          IBLOQ(I) = 0
          DEPX(I) = X(I)
          DEPY(I) = Y(I)
          DEPZ(I) = Z(I)
        ENDDO
 3334   XMIN0 = 0.
        XMAX0 = 0.
        YMIN0 = 0.
        YMAX0 = 0.
        CLOSE(IFAC)
        I2D = 0
        NUMSD = 1
        IF (ISTDOUT.EQ.0) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,NUMNP,' points lus'
          ELSE
            PRINT*,NUMNP,' points red'
          ENDIF
        ENDIF
        IF (NUMNP.EQ.NPMAX2) THEN
          IF (ISTDOUT.EQ.0) THEN
            IF (ILANG.EQ.0) THEN
              PRINT*,
     &     '*** ATTENTION on n''a peut-être pas lu tout le fichier :'
              PRINT*,'*** Nombre maximal de points NPMAX2 =',NPMAX2
            ELSE
              PRINT*,
     &     '*** WARNING the file may be truncated:'
              PRINT*,'*** Maximal number of points NPMAX2 =',NPMAX2
            ENDIF
          ENDIF
        ENDIF
C
        IF (ILOGX.NE.0) THEN
          IF (XMIN.GT.0.) THEN
            DO I=1,NUMNP
              X(I) = LOG10(X(I))
              DEPX(I) = X(I)
            ENDDO
            XMIN = LOG10(XMIN)
            XMAX = LOG10(XMAX)
          ELSE
            PRINT*,'*** Echelle Log en x impossible'
            ILOGX = 0
          ENDIF
        ENDIF
        IF (ILOGY.NE.0) THEN
          IF (YMIN.GT.0.) THEN
            DO I=1,NUMNP
              Y(I) = LOG10(Y(I))
              DEPY(I) = Y(I)
            ENDDO
            YMIN = LOG10(YMIN)
            YMAX = LOG10(YMAX)
          ELSE
            PRINT*,'*** Echelle Log en y impossible'
            ILOGY = 0
          ENDIF
        ENDIF
        IF (ILOGZ.NE.0) THEN
          IF (ZMIN.GT.0.) THEN
            DO I=1,NUMNP
              Z(I) = LOG10(Z(I))
              DEPZ(I) = Z(I)
            ENDDO
            ZMIN = LOG10(ZMIN)
            ZMAX = LOG10(ZMAX)
          ELSE
            PRINT*,'*** Echelle Log en z impossible'
            ILOGZ = 0
          ENDIF
        ENDIF
C
        IF (ICOURXYZ.EQ.0) THEN
          CALL TEMPS(T1,I)
          CALL DELAUN2(X,Y,NUMNP,NELDEL,XF,YF,ITAB,NTET,IORDRE,VITF
     &                ,ICLAS,ILANG)
          CALL TEMPS(T2,I)
          IF (ISTDOUT.EQ.0) THEN
            IF (ILANG.EQ.0) THEN
              PRINT*,NELDEL,' triangles générés en',REAL(T2-T1),' s'
            ELSE
              PRINT*,NELDEL,' triangles generated in',REAL(T2-T1),' s'
            ENDIF
          ENDIF
        ELSE
          NELDEL = NUMNP-1
          DO I=1,NELDEL
            ICLAS(1,I) = I
            ICLAS(2,I) = I+1
            ICLAS(3,I) = I+1
            ICLAS(4,I) = 0
            ICLAS(5,I) = 0
            ICLAS(6,I) = 0
            ICLAS(7,I) = 0
          ENDDO
        ENDIF
        IF (ISTDOUT.EQ.0) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,'Dimensions du domaine :'
     &           ,XMAX-XMIN,' x',YMAX-YMIN,' x',ZMAX-ZMIN
          ELSE
            PRINT*,'Domain dimensions:'
     &           ,XMAX-XMIN,' x',YMAX-YMIN,' x',ZMAX-ZMIN
          ENDIF
        ENDIF
      ENDIF
C
C Changement d'origine
C
      IF (IEXAG.NE.0) THEN
        DEPXM = -BIG
        DEPYM = -BIG
        DEPZM = -BIG
        XMINREF =  BIG
        XMAXREF = -BIG
        YMINREF =  BIG
        YMAXREF = -BIG
        ZMINREF =  BIG
        ZMAXREF = -BIG
        DO I=1,NUMNP
          DEPXM = MAX(DEPXM,ABS(DEPX(I)))
          DEPYM = MAX(DEPYM,ABS(DEPY(I)))
          DEPZM = MAX(DEPZM,ABS(DEPZ(I)))
          XMINREF = AMIN1(XMINREF,X(I)-FACEXA*DEPX(I))
          XMAXREF = AMAX1(XMAXREF,X(I)-FACEXA*DEPX(I))
          YMINREF = AMIN1(YMINREF,Y(I)-FACEXA*DEPY(I))
          YMAXREF = AMAX1(YMAXREF,Y(I)-FACEXA*DEPY(I))
          ZMINREF = AMIN1(ZMINREF,Z(I)-FACEXA*DEPZ(I))
          ZMAXREF = AMAX1(ZMAXREF,Z(I)-FACEXA*DEPZ(I))
        ENDDO
      ELSE
        DEPXM = 0.
        DEPYM = 0.
        DEPZM = 0.
        XMINREF = XMIN
        XMAXREF = XMAX
        YMINREF = YMIN
        YMAXREF = YMAX
        ZMINREF = ZMIN
        ZMAXREF = ZMAX
      ENDIF
      DEPMAX = MAX(DEPXM,DEPYM,DEPZM)
      DIMMAXXREF = XMAXREF-XMINREF
      DIMMAXYREF = YMAXREF-YMINREF
      DIMMAXZREF = ZMAXREF-ZMINREF
      DIMMAXREF  = MAX(DIMMAXXREF,DIMMAXYREF,DIMMAXZREF)
C
      IF (XINIT_FACT.EQ.311263..AND.DEPMAX.GT.0.) THEN
        CONSEIL = 0.3*DIMMAXREF/DEPMAX
        DFAC = CONSEIL-FACEXA
        FACEXA = CONSEIL
        XMIN =  BIG
        XMAX = -BIG
        YMIN =  BIG
        YMAX = -BIG
        ZMIN =  BIG
        ZMAX = -BIG
        DO N=1,NUMNP
          X(N) = X(N) + DFAC*DEPX(N)
          Y(N) = Y(N) + DFAC*DEPY(N)
          Z(N) = Z(N) + DFAC*DEPZ(N)
          XMIN = AMIN1(XMIN,X(N))
          XMAX = AMAX1(XMAX,X(N))
          YMIN = AMIN1(YMIN,Y(N))
          YMAX = AMAX1(YMAX,Y(N))
          ZMIN = AMIN1(ZMIN,Z(N))
          ZMAX = AMAX1(ZMAX,Z(N))
        ENDDO
      ELSE
        ITOUCHEX = 0
      ENDIF
C
      DIMMAXX = XMAX-XMIN
      DIMMAXY = YMAX-YMIN
      DIMMAXZ = ZMAX-ZMIN
      DIMMAX  = MAX(DIMMAXX,DIMMAXY,DIMMAXZ)
C
      IF (ZMIN.EQ.ZMAX.AND.ICOURB.NE.-5) THEN
        I2D = 1
        DIM1 = DIMMAXX
        DIM2 = DIMMAXY
        DIM1REF = DIMMAXXREF
        DIM2REF = DIMMAXYREF
      ELSEIF(YMIN.EQ.YMAX) THEN
        I2D = 3
        DIM1 = DIMMAXX
        DIM2 = DIMMAXZ
        DIM1REF = DIMMAXXREF
        DIM2REF = DIMMAXZREF
      ELSEIF(XMIN.EQ.XMAX) THEN
        I2D = 2
        DIM1 = DIMMAXY
        DIM2 = DIMMAXZ
        DIM1REF = DIMMAXYREF
        DIM2REF = DIMMAXZREF
      ELSEIF(ICOURB.NE.-5) THEN
        I2D = 0
        IF (ISTDOUT.EQ.0) THEN
          IF (DEPMAX.EQ.0.) THEN
            IF (ILANG.EQ.0) THEN
              PRINT*,'Dimensions du domaine :'
     &             ,DIMMAXX,' x',DIMMAXY,' x',DIMMAXZ
            ELSE
              PRINT*,'Domain dimensions:'
     &             ,DIMMAXX,' x',DIMMAXY,' x',DIMMAXZ
            ENDIF
          ELSE
            IF (ILANG.EQ.0) THEN
              PRINT*,'Dimensions du domaine de référence :'
     &             ,DIMMAXXREF,' x',DIMMAXYREF,' x',DIMMAXZREF
              PRINT*,'Dimensions du domaine déformé :     '
     &             ,DIMMAXX,' x',DIMMAXY,' x',DIMMAXZ
            ELSE
              PRINT*,'Reference domain dimensions:'
     &             ,DIMMAXXREF,' x',DIMMAXYREF,' x',DIMMAXZREF
              PRINT*,'Deformed domain dimensions: '
     &             ,DIMMAXX,' x',DIMMAXY,' x',DIMMAXZ
            ENDIF
          ENDIF
        ENDIF
      ENDIF
C
      IF (IFIX.LT.0) THEN
        IF (I2D.EQ.0) THEN
          IFIX = 0
        ELSE
          IFIX = -IFIX
        ENDIF
      ENDIF
C
      IF (I2D.NE.0) THEN
        IF (ISTDOUT.EQ.0) THEN
          IF (DEPMAX.EQ.0.) THEN
            IF (ILANG.EQ.0) THEN
              PRINT*,'Dimensions du domaine :',DIM1,' x',DIM2
            ELSE
              PRINT*,'Domain dimensions:',DIM1,' x',DIM2
            ENDIF
          ELSE
            IF (ILANG.EQ.0) THEN
              PRINT*,'Dimensions du domaine de référence :'
     &             ,DIM1REF,' x',DIM2REF
              PRINT*,'Dimensions du domaine déformé :     '
     &             ,DIM1,' x',DIM2
            ELSE
              PRINT*,'Reference domain dimensions:'
     &             ,DIM1REF,' x',DIM2REF
              PRINT*,'Deformed domain dimensions: '
     &             ,DIM1,' x',DIM2
            ENDIF
          ENDIF
        ENDIF
      ENDIF
C
      IF (IPS2D.NE.0.OR.I2D.NE.0) THEN
        DO I=1,NUMNP
          JJJ = IBLOQ(I)/100
          KKK = MOD(IBLOQ(I),100)
          III = KKK/8
          IF (III.NE.0) III = 1
          IBLOQ(I) = 100*JJJ + 8*III + MOD(KKK,4)
        ENDDO
      ENDIF
      IF (I2D.EQ.0) THEN
        IF (ICOURB.GT.0) THEN
          IBORD = 1
        ELSEIF(ICOURB.EQ.-4) THEN
          IBORD = -1
          ICOURB = -1
        ELSE  
          IBORD = 0
        ENDIF
      ELSE
        IFC   = -1
        IBORD =  0
      ENDIF
C
      IFBLO = 0
      DO I=1,NUMNP
        IFBLO = MAX(IFBLO,IBLOQ(I))
      ENDDO
C
      CALL ARONDI(XMIN,XMAX,XECH,PROPX,NECHX,NBECH)
      CALL ARONDI(YMIN,YMAX,YECH,PROPY,NECHY,NBECH)
      CALL ARONDI(ZMIN,ZMAX,ZECH,PROPZ,NECHZ,NBECH)
      IF (ICOURB.LT.0) THEN
        TOTO = MIN((XMAX-XMIN),(YMAX-YMIN),(ZMAX-ZMIN))
        EXAX0  = TOTO/(XMAX-XMIN)
        EXAY0  = TOTO/(YMAX-YMIN)
        EXAZ0  = TOTO/(ZMAX-ZMIN)
        EXAX00 = 1.
        EXAY00 = 1.
        EXAZ00 = 1.
      ENDIF
      XMED2= XMIN+XMAX
      YMED2= YMIN+YMAX
      XMED = .5*XMED2
      YMED = .5*YMED2
      ZMED = .5*(ZMIN+ZMAX)
      XMED0 = XMED
      YMED0 = YMED
      ZMED0 = ZMED
      BX = (XMAX-XMIN)*.5
      BY = (YMAX-YMIN)*.5
      BZ = (ZMAX-ZMIN)*.5
      IF (ICOURXYZ.NE.0) THEN
        BX = BX*1.2
        BY = BY*1.2
        BZ = BZ*1.2
      ENDIF
      BNOR = SQRT(BX**2+BY**2+BZ**2)
      BX0 = BX
      BY0 = BY
      BZ0 = BZ
      XCCOR = XCCOR-XMED
      YCCOR = YCCOR-YMED
      ZCCOR = ZCCOR-ZMED
C
      ISYM = 4
      TOL = 1.E-5
      EPSX = TOL*(XMAXREF-XMINREF)
      EPSY = TOL*(YMAXREF-YMINREF)
      IF (YMINREF.GT.-EPSY) THEN
        IF (XMINREF.GT.-EPSX) THEN
          IDEMI = 0
C
C symetries .ne. 4
C
          IF (HED(77:78).EQ.'#S') THEN
            READ(HED(79:80),FMT='(I2)',ERR=3737) II
            IF (II.GT.1.AND.MOD(II,2).EQ.0) ISYM = II
 3737       CONTINUE
          ENDIF
        ELSE
          IDEMI = 1
        ENDIF
      ELSE
        IF (XMINREF.GT.-EPSX) THEN
          IDEMI = 2
        ELSE
          IDEMI = 3
        ENDIF
      ENDIF
C
      IF (ISYM.EQ.4) THEN
        DIRX = 1.
        DIRY = 0.
      ELSE
        DIRX = SIN(PI/REAL(ISYM/2))
        DIRY = COS(PI/REAL(ISYM/2))
      ENDIF
      DO N=1,NUMNP
        IF (ABS(Y(N)).LT.EPSY) THEN
          IF (ABS(X(N)).LT.EPSX) THEN
            IPLAN(N) = 3
          ELSE
            IPLAN(N) = 1
          ENDIF
        ELSEIF(EGAL(DIRX*X(N),DIRY*Y(N))) THEN
          IPLAN(N) = 2
        ELSE
          IPLAN(N) = 0
        ENDIF
        X(N) = X(N)-XMED
        Y(N) = Y(N)-YMED
        Z(N) = Z(N)-ZMED
      ENDDO
C
      DIST0 = SQRT((XMAX-XMIN)**2+(YMAX-YMIN)**2+(ZMAX-ZMIN)**2)
      DIST = DIST0
      XPUP(1) = DIST
      XPUP(2) = DIST
      XPUP(3) = DIST
      IF (MATMIN.NE.MATMAX
     &.AND.MATMIN.NE.9999.AND.MATMAX.NE.-9999) THEN
        IF (ISTDOUT.EQ.0) THEN
          IF (ILANG.EQ.0) THEN
            PRINT*,'Matériaux entre',MATMIN,' et',MATMAX
          ELSE
            PRINT*,'Material numbers between',MATMIN,' and',MATMAX
          ENDIF
        ENDIF
        IFLAG3 = 1
      ELSE
        IFLAG3 = 0
      ENDIF
C
      IF (ICOURB.NE.-5) THEN
        ILOGX = 0
        ILOGY = 0
        ILOGZ = 0
      ENDIF
C
      IF (LONTIT.GT.0) THEN
        TITAV(1:LONTIT) = HED(1:LONTIT)
      ELSE
        TITAV = ' '
      ENDIF
C
      CALL datefichier(NOM_FICH(1:LONG)//CHAR(0),ID,IRC)
      IF (IRC.EQ.0) IDFICH = ID
      IF (IEXAG.GE.2) THEN
        CALL datefichier(NOM_FICH(1:LONG-7)//'depl'//CHAR(0),ID,IRC)
        IF (IRC.EQ.0) IDDEPL = ID
      ENDIF
      IF (IDVIT.NE.0) THEN
        IRC = 1
        CALL LIVAL(NOM_ISO,LONISO,IVAL,ICLAS,ICONTR,NDSEL,IRC)
        IF (IVAL.EQ.-1) THEN
          III = 2
        ELSE
          III = 0
        ENDIF
        CALL LIVIT(ICLAS,III,NOM_VIT,LONVIT,IRC,0,0)
      ENDIF
      IF (IDISO.NE.0) THEN
        IRC = 1
        CALL LIVAL(NOM_ISO,LONISO,IVAL,ICLAS,ICONTR,NDSEL,IRC)
        CALL LIISO(ICLAS,NOM_ISO,LONISO,IRC,ICONTR,1,IVAL)
        IF (ISO.EQ.0.AND.(IVAL.EQ.1.OR.IVAL.EQ.4).AND.NSURF.LE.0) THEN
cc??          IOPT = -1
        ELSE
          IF (NSURF.GT.0) CALL CALSUR(1)
        ENDIF
      ENDIF
C
 1000 FORMAT('"',A,'"')
      END
C-----------------------------------------------------------------------
      SUBROUTINE TROPDEPOINTS(N,INODE,IOPT)
      INCLUDE 'com_coor.f'
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
C
      IF (ILANG.EQ.0) THEN
        IF (INODE.EQ.0) THEN
          PRINT*,'*** Votre fichier comprend',N,' points'
          PRINT*,'*** Alors que le maximum permis est',NPMAX
        ELSEIF(INODE.GT.0) THEN
          PRINT*,'*** Trop d''éléments à',INODE,' noeuds :',N
          PRINT*,'*** Alors que le maximum permis est',NEMAX/INODE
        ELSEIF(INODE.EQ.-1) THEN
          PRINT*,'*** Trop de faces :',NFACE
          PRINT*,'*** Alors que le maximum permis est',NFMAX
        ELSEIF(INODE.EQ.-2) THEN
          PRINT*,'*** Trop de tetraèdres'
        ENDIF
        PRINT*,'*** Essayez de recompiler "'//PROGEFF(1:LPROGEFF)
     &       //'" avec plus de mémoire'
      ELSE
        IF (INODE.EQ.0) THEN
          PRINT*,'*** Your file contains',N,' nodes'
          PRINT*,'*** Maximum allowed =',NPMAX
        ELSEIF(INODE.GT.0) THEN
          PRINT*,'*** Too many',INODE,'-nodes elements',N
          PRINT*,'*** Maximum allowed =',NEMAX/INODE
        ELSEIF(INODE.EQ.-1) THEN
          PRINT*,'*** Too many facets:',NFACE
          PRINT*,'*** Maximum allowed =',NFMAX
        ELSEIF(INODE.EQ.-2) THEN
          PRINT*,'*** Too many tetraedrons'
        ENDIF
        PRINT*,'*** Try to recompile "'//PROGEFF(1:LPROGEFF)
     &       //'" with more memory'
      ENDIF
      IF (IOPT.EQ.0) STOP
      END
