************************************************************************
* File: matdiaco.for
************************************************************************
* Scopo: soluzione esercizio 4 del compito di esame del 12/01/2000
************************************************************************

      LOGICAL FUNCTION MatDiaCo (mat,n)
      IMPLICIT NONE
      INTEGER n, mat(n,n)
      INTEGER diagp/0/, diags/0/, i

      DO 10 i = 1, n
        diagp = diagp + mat(i,i)
        diags = diags + mat(i,n-i+1)
 10   CONTINUE
      MatDiaCo = (diagp .LT. diags)
      RETURN
      END

* TEST (PARTE NON RICHIESTA DAL TESTO)
      PROGRAM Main
      IMPLICIT NONE
      INTEGER DIM
      PARAMETER (DIM = 3)
      INTEGER matrice(DIM,DIM)
      LOGICAL MatDiaCo

      matrice(1,1) = 1
      matrice(2,2) = 1
      matrice(3,3) = 1
      matrice(1,3) = 1

      matrice(3,1) = 2
*     matrice(3,1) = 0

      matrice(1,2) = 0
      matrice(2,1) = 0
      matrice(2,3) = 0
      matrice(3,2) = 0

      IF (MatDiaCo(matrice,DIM)) THEN
        WRITE(*,*) 'VERIFICA LA PROPRIETA'''
      ELSE
        WRITE(*,*) 'NON VERIFICA LA PROPRIETA'''
      ENDIF

      STOP
      END
