C....*...1.........2.........3.........4.........5.........6.........7.*.......8
C     DGMZAP   11/29/73
C
C     PURPOSE
C     SET COMPUTED ZEROS RESULTING FROM MATRIX ALGEBRA TO MACHINE ZERO.
C
C     USAGE
C     CALL DGMZAP(A,N,M,TOL)
C
C     ARGUMENTS
C     A   - INPUT N BY M MATRIX.  STORED COLMNWISE (STORAGE MODE 0)
C           REAL*8
C     N   - NUMBER OF ROWS IN A.
C           INTEGER*4
C     M   - NUMBER OF COLUMNS IN A.
C           INTEGER*4
C     TOL - INPUT TOLERANCE.  A REASONABLE VALUE IS 1.D-13.
C           REAL*8
C
C     REMARK
C     A(I,J) IS SET TO 0.D0 IF DABS(A(I,J)).LT.TOL*AMAX WHERE AMAX IS
C     THE LARGEST ELEMENT OF A IN ABSOLUTE VALUE.
C
C
C
      SUBROUTINE DGMZAP(A,N,M,TOL)
      implicit real*8 (a-h,o-z)
      save
      REAL*8 A(1),TOL,TEST,AMAX
      NM=N*M
      AMAX=0.D0
      DO 10 I=1,NM
      TEST=DABS(A(I))
10    IF(TEST.GT.AMAX) AMAX=TEST
      TEST=TOL*AMAX
      DO 20 I=1,NM
20    IF(DABS(A(I)).LT.TEST) A(I)=0.D0
      RETURN
      END
