      SUBROUTINE FILM(NRALEN,NBTOUR,IBOUNCE,IFILM,NUMPT,NUMANI
     &               ,XX,LXX,NDX,YY,LYY,NDY,XX0,YY0)
C
      INCLUDE 'param.f'
      REAL*8    XX(*),YY(*)
      LOGICAL*4 LXX(*),LYY(*)
C
      CHARACTER*10 COMPT
      CALL GSLT(0)
      CALL GSLW(1)
      CALL GSLSS(1)
      CALL GSPATF(0)
      CALL GSPAT(16)
      CALL ASFCOL(4)
C
      IF (IFILM.GE.2) THEN
        XCOM = XMIN+.01*(XMAX-XMIN)
        YCOM = YMIN+.01*(YMAX-YMIN)
      ELSE
        XCOM = XX0+.01*(XMAX-XMIN)
        YCOM = YY0+.01*(YMAX-YMIN)
      ENDIF
      IF (NRALEN.GT.0) TEMPSAPERDRE = REAL(NRALEN)*0.001
      CALL GSCOL(7)
      CALL METS_CURSEUR(.5*(XMIN+XMAX),.5*(YMIN+YMAX))
      IF (IFILM.EQ.1) THEN
        CALL VRAIECOORD(XMIN,YMAX,IX0,IY0)
        CALL VRAIECOORD(XMAX,YMIN,IX1,IY1)
        ILARG = IX1-IX0
        IHAUT = IY1-IY0
        IX0 = IX0+1
        IX1 = IX1-1
        IY0 = IY0+1
        IY1 = IY1-1
        ILARG = ILARG-2
        IHAUT = IHAUT-2
        DO ITOUR=1,NBTOUR
          CALL ASFCOL(4)
          WRITE(COMPT(1:3),'(I2,":")') ITOUR
          DO IC=1,NCOURB
            WRITE(COMPT(4:7),'(I4)') IC
            CALL GSBND(XX0,XMAX,YY0,YMAX)
            CALL GSCHAR2(XCOM,YCOM,7,COMPT)
            CALL TRACE2(IC,IX0,IX1,IY0,IY1,ILARG,IHAUT
     &                 ,XX,LXX,NDX,YY,LYY,NDY)
            IF (NRALEN.GT.0) CALL PERDDUTEMPS(TEMPSAPERDRE)
          ENDDO
          IF (IBOUNCE.EQ.1) THEN
            CALL ASFCOL(1)
            DO IC=NCOURB,1,-1
              WRITE(COMPT(4:7),'(I4)') IC
              CALL GSBND(XX0,XMAX,YY0,YMAX)
              CALL GSCHAR2(XCOM,YCOM,7,COMPT)
              CALL TRACE2(IC,IX0,IX1,IY0,IY1,ILARG,IHAUT
     &                   ,XX,LXX,NDX,YY,LYY,NDY)
              IF (NRALEN.GT.0) CALL PERDDUTEMPS(TEMPSAPERDRE)
            ENDDO
          ENDIF
        ENDDO
      ELSE
        DO ITOUR=1,NBTOUR
          WRITE(COMPT(1:3),'(I2,":")') ITOUR
          ICOMP = 0
          IF (NUMPT.GT.0) THEN
            CALL GSMIX(1)
            DO IC=1,NCOURB
              IF (IMONO.EQ.1) THEN
                ICOLOR = ICOL(IC)
                CALL GSCOL(ICOLOR)
              ENDIF
              CALL GSLW(IGROS+IEPL(IC))
              IREACH(IC) = MAX(2,MIN(NUMPT,NPOINT(IC)))
              ICOMP = MAX(ICOMP,IREACH(IC))
              CALL GSPLNE_SPEED(IREACH(IC),XPOINT(NDEB(IC)+1)
     &                                    ,YPOINT(NDEB(IC)+1))
            ENDDO
          ELSE
            DO IC=1,NCOURB
              IREACH(IC) = 1
            ENDDO
          ENDIF
          IFINI = 1
 1000     CALL GSCOL(7)
          WRITE(COMPT(4:9),'(I6)') ICOMP
          CALL GSCHAR2(XCOM,YCOM,9,COMPT)
          CALL GSLW(IGROS-1)
          IF (NRALEN.GT.0) CALL PERDDUTEMPS(TEMPSAPERDRE)
          IF (IFINI.NE.0) THEN
            IFINI = 0
            ICOMP = 0
            DO IC=1,NCOURB
              IF (IMONO.EQ.1) THEN
                ICOLOR = ICOL(IC)
                CALL GSCOL(ICOLOR)
              ENDIF
              CALL GSLW(IGROS+IEPL(IC))
              NP = MIN(NUMANI,NPOINT(IC)-IREACH(IC))+1
              IF (NP.GT.1) THEN
                CALL GSPLNE_SPEED(NP,XPOINT(IREACH(IC)+NDEB(IC))
     &                              ,YPOINT(IREACH(IC)+NDEB(IC)))
                IF (NUMPT.GT.0) THEN
                  ID = IREACH(IC)-NUMPT+1
                  CALL GSMIX(1)
                  CALL GSPLNE_SPEED(NP,XPOINT(ID+NDEB(IC))
     &                                ,YPOINT(ID+NDEB(IC)))
                  CALL GSMOVE(XPOINT(ID+NDEB(IC)),YPOINT(ID+NDEB(IC)))
                  CALL GSLINE(XPOINT(ID+NDEB(IC)),YPOINT(ID+NDEB(IC)))
                  CALL GSMIX(0)
                ENDIF
                IREACH(IC) = IREACH(IC)+NP-1
                ICOMP = MAX(ICOMP,IREACH(IC))
                IF (IREACH(IC).LT.NPOINT(IC)) IFINI = 1
              ENDIF
            ENDDO
            GOTO 1000
          ENDIF
          CALL GSMIX(1)
          IF (IBOUNCE.EQ.0) THEN
            DO IC=1,NCOURB
              IF (IMONO.EQ.1) THEN
                ICOLOR = ICOL(IC)
                CALL GSCOL(ICOLOR)
              ENDIF
              CALL GSLW(IGROS+IEPL(IC))
              IF (NUMPT.EQ.0) THEN
                CALL GSPLNE_SPEED(NPOINT(IC),XPOINT(1+NDEB(IC))
     &                                      ,YPOINT(1+NDEB(IC)))
              ELSE
                NP = MAX(2,MIN(NUMPT,NPOINT(IC)))
                II = NPOINT(IC)-NP+1
                CALL GSPLNE_SPEED(NP,XPOINT(II+NDEB(IC))
     &                              ,YPOINT(II+NDEB(IC)))
              ENDIF
            ENDDO
          ELSE
            IFINI = 1
 2000       CALL GSMIX(0)
            CALL GSCOL(7)
            WRITE(COMPT(4:9),'(I6)') ICOMP
            CALL GSCHAR2(XCOM,YCOM,9,COMPT)
            CALL GSLW(IGROS-1)
            IF (NRALEN.GT.0) CALL PERDDUTEMPS(TEMPSAPERDRE)
            CALL GSMIX(1)
            IF (IFINI.NE.0) THEN
              IFINI = 0
              ICOMP = 0
              DO IC=1,NCOURB
                IF (IMONO.EQ.1) THEN
                  ICOLOR = ICOL(IC)
                  CALL GSCOL(ICOLOR)
                ENDIF
                CALL GSLW(IGROS+IEPL(IC))
                NP = MIN(NUMANI,IREACH(IC))+1
                IF (NP.GT.1) THEN
                  ID = IREACH(IC)-NP+1
                  CALL GSPLNE_SPEED(NP,XPOINT(ID+NDEB(IC))
     &                                ,YPOINT(ID+NDEB(IC)))
                  CALL GSMOVE(XPOINT(IREACH(IC)+NDEB(IC))
     &                       ,YPOINT(IREACH(IC)+NDEB(IC)))
                  CALL GSLINE(XPOINT(IREACH(IC)+NDEB(IC))
     &                       ,YPOINT(IREACH(IC)+NDEB(IC)))
                  IF (NUMPT.GT.0) THEN
                    ID = IREACH(IC)-NUMPT+1
                    CALL GSMIX(0)
                    CALL GSPLNE_SPEED(NP,XPOINT(ID+NDEB(IC))
     &                                  ,YPOINT(ID+NDEB(IC)))
                    CALL GSMOVE(XPOINT(ID+NDEB(IC))
     &                         ,YPOINT(ID+NDEB(IC)))
                    CALL GSLINE(XPOINT(ID+NDEB(IC))
     &                         ,YPOINT(ID+NDEB(IC)))
                    CALL GSMIX(1)
                  ENDIF
                  IREACH(IC) = IREACH(IC)-NP+1
                  ICOMP = MAX(ICOMP,IREACH(IC))
                  IF (IREACH(IC).GT.0) IFINI = 1
                ENDIF
              ENDDO
              GOTO 2000
            ENDIF
          ENDIF
          CALL GSMIX(0)
        ENDDO
      ENDIF
C
      END
C-----------------------------------------------------------------------
      SUBROUTINE TRACE2(ICOURB,IX0,IX1,IY0,IY1,ILARG,IHAUT
     &                 ,XX,LXX,NDX,YY,LYY,NDY)
      INCLUDE 'param.f'
      REAL*8    XX(*),YY(*)
      LOGICAL*4 LXX(*),LYY(*)
C
      CALL GSPROGRE(1)
      CALL x11effacepix
      CALL GSBND(XMIN,XMAX,YMIN,YMAX)
      IF (IQUADR.LT.0) CALL AXES(XX,LXX,NDX,YY,LYY,NDY,0,0)
      IF (ILT(1).GE.0) THEN
        CALL GSCOL(ICOL(1))
        CALL GSLW(IGROS+IEPL(1))
        CALL GSLT(ILT(1))
        CALL GSPLNE_SPEED(NPOINT(ICOURB),XPOINT(1+NDEB(ICOURB))
     &                                  ,YPOINT(1+NDEB(ICOURB)))
      ENDIF
      IF (NMARK(1).GT.0) THEN
        CALL GSCOL(ICOLM(1))
        CALL GSMS(NMARK(1))
        CALL GSMB(TM(1)*XMB,TM(1)*YMB)
        CALL GSMRKS(NPOINT(ICOURB),XPOINT(1+NDEB(ICOURB))
     &                            ,YPOINT(1+NDEB(ICOURB)))
      ENDIF
      CALL AXES(XX,LXX,NDX,YY,LYY,NDY,1,1)
      CALL GSPROGRE(0)
      CALL x11metrect2(IX0,IY0,ILARG,IHAUT,IX0,IY0)
      CALL viderbuff2()
      IF (ILT(1).NE.0) CALL GSLT(0)
      END
C--------------------------------------------------------------------
      SUBROUTINE GENERIQUE(NRALEN,XCOM,YCOM)
C
      INCLUDE 'param.f'
C
      CHARACTER*6 COMPT
C
      NRALEN2 = NRALEN*NCOURB
      CALL GSCOL(4)
      COMPT = '     1'
      CALL GSCHAR2(XCOM,YCOM,6,COMPT)
      DO K=1,NRALEN2
        CALL GSPLNE_SPEED(NPOINT(1),XPOINT(1),YPOINT(1))
      ENDDO
      WRITE(COMPT,'("1/",I4)') NCOURB
      CALL GSCHAR2(XCOM,YCOM,6,COMPT)
      DO K=1,NRALEN2
        CALL GSPLNE_SPEED(NPOINT(NCOURB),XPOINT(1+NDEB(NCOURB))
     &                                  ,YPOINT(1+NDEB(NCOURB)))
      ENDDO
      CALL GSCOL(0)
      WRITE(COMPT,'(I6)') NCOURB
      CALL GSCHAR2(XCOM,YCOM,6,COMPT)
      DO K=1,NRALEN2
        CALL GSPLNE_SPEED(NPOINT(1),XPOINT(1),YPOINT(1))
      ENDDO
      DO K=1,NRALEN2
        CALL GSPLNE_SPEED(NPOINT(NCOURB),XPOINT(1+NDEB(NCOURB))
     &                                  ,YPOINT(1+NDEB(NCOURB)))
      ENDDO
      CALL GSCOL(4)
      COMPT = '     1'
      CALL GSCHAR2(XCOM,YCOM,6,COMPT)
      DO K=1,NRALEN2
        CALL GSPLNE_SPEED(NPOINT(1),XPOINT(1),YPOINT(1))
      ENDDO
      END
