CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                    C
C     THIS FILE CONTAINS THE SOURCE CODE FOR FORTRAN 90D INTRINSIC   C
C     FUNCTIONS.                                                     C
C                                                                    C
C     VERSION 1.00, 10/11/92                                         C
C                                                                    C
C     COPYRIGHT (C) NORTHEAST PARALLEL ARCHITECTURES CENTER,         C
C     SYRACUSE UNIVERSITY, SYRACUSE, NY 13244, USA.                  C
C                                                                    C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC


      logical function ALL_1_L(A, a1, a2, A_INFO, proclist)
      integer a1, a2, A_INFO(8,7), proclist(*)
      logical A(a1:a2), local
      integer i, logicalsize, type, status, min_row, max_row
      data logicalsize, type /4, 23/
      logical findand
      external findand

      COMMON /XPRESS/ NOCARE, NORDER, NONODE, IHOST, IALNOD, IALPRC

      min_row = A_INFO(1,1)
      max_row = A_INFO(2,1)
      local = A(min_row)

      do i=min_row+1, max_row
         if (.NOT. A(i)) then
            local = .FALSE.
         end if
      end do

      if (proclist(1) .EQ. -1) then
         status = KXCOMB(local,findand,logicalsize,1,IALNOD,0,type)
      else
         status = KXCOMB(local,findand,logicalsize,1,proclist(1),
     &                proclist(2),type)
      end if

      ALL_1_L = local

      return
      end
      

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC


      logical function ALL_2_L_S(A, a1, a2, a3, a4, A_INFO, 
     &       proclist)
      integer a1, a2, a3, a4, A_INFO(8,7), proclist(*)
      logical A(a1:a2,a3:a4), local
      integer min_row, max_row, min_col, max_col
      integer i, logicalsize, type, status
      data logicalsize, type /4, 23/
      logical findand
      external findand

      COMMON /XPRESS/ NOCARE, NORDER, NONODE, IHOST, IALNOD, IALPRC

      min_row = A_INFO(1,1)
      max_row = A_INFO(2,1)
      min_col = A_INFO(1,2)
      max_col = A_INFO(2,2)

      local = A(min_row,min_col)
      do j=min_col, max_col
         do i=min_row, max_row
            if (.NOT. A(i,j)) then
               local = .FALSE.
            end if
         end do
      end do

      if (proclist(1) .EQ. -1) then
         status = KXCOMB(local,findand,logicalsize,1,IALNOD,0,type)
      else
         status = KXCOMB(local,findand,logicalsize,1,proclist(1),
     &                   proclist(2),type)
      end if

      ALL_2_L_S = local

      return
      end


CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC


      subroutine ALL_2_L_V(A, a1, a2, a3, a4, A_INFO, dim, local, 
     &   s1, s2, LOCAL_INFO, proclist)
      integer a1, a2, a3, a4, s1, s2, A_INFO(8,7), LOCAL_INFO(8,7)
      logical A(a1:a2,a3:a4), local(s1:s2)
      integer dim, proclist(*)
      integer i, j, status, min_row, max_row, min_col, max_col
      integer logicalsize, type
      data logicalsize, type /4, 23/
      integer env(4), coord(2), nproc(2), size
      logical findand
      external findand

      COMMON /XPRESS/ NOCARE, NORDER, NONODE, IHOST, IALNOD, IALPRC

      min_row = A_INFO(1,1)
      max_row = A_INFO(2,1)
      min_col = A_INFO(1,2)
      max_col = A_INFO(2,2)

      if (dim .EQ. 2) then 
         size = max_row - min_row + 1
      else 
         size = max_col - min_col + 1
      end if

      if (dim .EQ. 2) then
         do i=min_row, max_row
            local(i) = A(i,min_col)
            do j=min_col+1, max_col
               if (.NOT. A(i,j)) then
                  local(i) = .FALSE.
               end if
            end do
         end do
      else
         do i=min_col, max_col
            local(i) = A(min_row,i)
            do j=min_row+1, max_row
               if (.NOT. A(j,i)) then
                  local(i) = .FALSE.
               end if
            end do
         end do
      end if


C     (BLOCK,*), (CYCLIC,*) AND REDUCTION ALONG COLUMN;   OR 
C     (*,BLOCK), (*,CYCLIC) AND REDUCTION ALONG ROW.


      if (((A_INFO(6,2) .EQ. 0) .AND. (dim .EQ. 1)) .OR. 
     & ((A_INFO(6,1) .EQ. 0) .AND. (dim .EQ. 2))) then
         nproc(1) = A_INFO(8,dim)
         status = KXGDIN(1, nproc)
         status = KXCOMB(local,findand,logicalsize,size,IALNOD,0,
     &        type)
      end if


C     ARRAY DECOMPOSED ALONG BOTH DIMENSIONS


      if ((A_INFO(6,1) .NE. 0) .AND. (A_INFO(6,2) .NE. 0)) then
         nproc(2) = A_INFO(8,1)
         nproc(1) = A_INFO(8,2)

         status = KXPARA(env)
         status = KXGDIN(2, nproc)
         status = KXGDCO(env(1), coord)

         if (dim .EQ. 2) then
            do i=0, nproc(1)-1
               coord(1) = i
               proclist(i+1) = KXGDPR(coord)
            end do
         else
            do i=0, nproc(2)-1
               coord(2) = i
               proclist(i+1) = KXGDPR(coord)
            end do 
         endif
         
         status = KXCOMB(local,findand,logicalsize,size,nproc(3-dim),
     &   proclist, type)
      end if

      return
      end





