C Copyright (c) 1992 Carnegie Mellon University 
C                     SCAL project: Guy Blelloch, Siddhartha Chatterjee,
C                                   Jonathan Hardwick, Jay Sipelstein,
C                                   Marco Zagha
C  All Rights Reserved.
C 
C  Permission to use, copy, modify and distribute this software and its
C  documentation is hereby granted, provided that both the copyright
C  notice and this permission notice appear in all copies of the
C  software, derivative works or modified versions, and any portions
C  thereof, and that both notices appear in supporting documentation.
C 
C  CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
C  CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
C  ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
C 
C  The SCAL project requests users of this software to return to 
C 
C   Marco Zagha and Guy Blelloch		marco.zagha@cs.cmu.edu	
C   School of Computer Science		guy.blelloch@cs.cmu.edu	
C   Carnegie Mellon University
C   5000 Forbes Ave.
C   Pittsburgh PA 15213-3890
C 
C  any improvements or extensions that they make and grant Carnegie Mellon
C  the rights to redistribute these changes.

      subroutine LOOP5(n,X,Y,Z)
      integer i,n
      real X(100001),Y(100001),Z(100001)
      do 5 i = 2,n
 5       X(i) = Z(i) * (Y(i) - X(i-1))
      return
      end

      subroutine LOOP19(n,STB5,B5,SA,SB)
      integer i,k,n
      real STB5,B5(100001),SA(100001),SB(100001)
      do 191 k = 1,n
         B5(k) = SA(k) + STB5 * SB(k)
 191     STB5 = B5(k) - STB5
      do 193 i = 1,n
         k = n - i + 1
         B5(k) = SA(k) + STB5 * SB(k)
 193     STB5 = B5(k) - STB5
      return
      end
      
      subroutine FPACK(n,val,flag,res,m)
      integer i,n,flag(100001),m
      real val(100001),res(100001)
      m = 1
      do 200 i = 1,n
        if (flag(i).eq.1) then
          res(m) = val(i)
	  m = m+1
	endif
 200  continue
      return
      end

      subroutine FSPLIT(n,val,flag,res)
      integer i,n,flag(100001),m
      real val(100001),res(100001)
      m = 1
      do 301 i = 1,n
        if (flag(i).eq.1) then
          res(m) = val(i)
	  m = m+1
	endif
 301  continue
      do 302 i = 1,n
        if (flag(i).eq.0) then
          res(m) = val(i)
	  m = m+1
	endif
 302  continue
      return
      end

