C+
C NAME:
C	ArrI4SetMinMax
C PURPOSE:
C	Limit range of integer*4 array to min and max
C CALLING SEQUENCE:
	subroutine ArrI4SetMinMax(N,A,AMin,AMax)
C CALLS:
C	BadI4
C SEE ALSO:
C	Array_Info
C-
	    integer	N
	    integer	A(*)
	    integer	AMin
	    integer	AMax

	integer		BadI4

	if (N .gt. 0) then		! Constrain all elements
	    do I=1,N
		A(I) = max(AMin,min(AMax,A(I)))
	    end do

	else if (N .lt. 0) then		! Constrain only non-ibad values

	    ibad = BadI4()

	    do I=1,-N
		if (A(I) .ne. ibad) A(I) = max(AMin,min(AMax,A(I)))
	    end do

	end if

	return
	end
