C OOOSUQ    SOURCE    PV090527  26/04/24    08:23:22     12524          
      SUBROUTINE OOOSUQ(nth)
C--------------------------------------------------------------------
C
C    EFFECTUER LA SUPPRESSION DES SEGMENTS EN QUEUE DE SUPPRESSION
C
C--------------------------------------------------------------------
C
%INC IOOADR
%INC IOOADZ
%INC IOODES
%INC IOOSGM
%INC IOOWCOM
%INC IOOSAF

      POINTEUR      PSEG.PSEG
C
      IF (ISUPQ(nth).eq.0) return
      KOD=0
      do 100 i=1,isupq(nth)
         pseg=supq(nth,i)
         if (pseg.eq.0)goto 100
         if (pseg.lt.0)goto 902
         
         CALL OOOVPN (PSEG)
C         deja fait dans OOOVPN
C         call ooove2(lret,pseg)
C         if(lret .eq. 3)goto 903
C         if(lret .eq. 1)goto 902

         if (thread) then
C          en mode force on n'attends pas car cela empecherait le menage de marcher
           if (.not.ooofor.or.nth.ne.0) then
C            il faut attendre que le segment soit libre
  10  if ((ibits(mdrw(pseg),0,18).ne.0.and.ibits(mdrw(pseg),0,18)
     >  .ne.nth+1).or.
     >(nth.lt.64.and.mdro1(pseg).ne.0.and.mdro1(pseg).ne.(ibset(0,nth)))
     >.or.
     >(nth.ge.64.and.mdro2(pseg).ne.0.and.mdro2(pseg).ne.
     >     (ibset(0,nth-64))))
     >   then
C              on doit attendre.
C              si necessaire on cree une condition
               if (mdco(pseg).eq.0) then
                 call ooocon(mdco(pseg))
               endif
               call oooddl(pseg,harg)
               lnsf(nth)=0
               call ooowait(mdco(pseg))
               lnsf(nth)=1
               call oooudl
               goto 10
             endif
           endif
         endif

         CALL OOOSUP (LRET,PSEG,KOD)
         IF(LRET.EQ.1)                                  GO TO 901
100   continue
      isupq(nth)=0
      lsupq(nth)=0
                                                        RETURN

C-----------------------------------------------------------------------
C                MESSAGES D'ERREUR
C-----------------------------------------------------------------------
 901  CALL OOOERR (0,0,'PAS ASSEZ DE PLACE EN MEMOIRE')
                                                        STOP 16
 902  CALL OOOERR (PSEG,-1,'POINTEUR ARGUMENT INVALIDE')
                                                        STOP 16
      END
 
