C "@(#)fffff.f	6.1	1/6/87"
	program regress
	common / sub2data / iarray(4)
	common /sub3common/ n1sub3,nsub3
	common /failure/ ifail
	integer iarray2(10,10)
c some random numbers:
	data iarray / 13,899,177,299907 /
	data nsub3 / 10 /
	data ifail / 0 /
	call sub1
	call sub2(iarray)
	call sub2e1
	call sub2e2
	call sub2e3
	iarray2(2,2) = 0
c sets iarray2(2,2) = 13
	call sub3(iarray2)
	if (iarray2(2,2) .ne. 13) then
		ifail = ifail + 1
		print*,'fail sub3'
	endif
	call sub4
	call sub5
	call sub6
	call sub7
	if (ifail .ne. 0) then
		print*,'regress.f: failed ',ifail
	else
		print*,'regress.f: pass'
	endif
	end

	subroutine sub1
	common /failure/ ifail
	integer ia(10)
	isf(ix,iy)=ia(ix) + iabs(iy)
	i = 3
	ia(i) = -16

	i0 = -37
	i1 = -37
	i2 = -37
	i3 = -37
	i4 = -37
	i5 = -37
	i6 = -37
	i7 = -37
	i8 = -37
	i0 = isf(i,i0)
	i1 = isf(i,i1)
	i2 = isf(i,i2)
	i3 = isf(i,i3)
	i4 = isf(i,i4)
	i5 = isf(i,i5)
	i6 = isf(i,i6)
	i7 = isf(i,i7)
	i8 = isf(i,i8)
	if (i0 .ne. 21) then
		print*,'fail 0'
		ifail = ifail + 1
	endif
	if (i1 .ne. 21) then
		print*,'fail 1'
		ifail = ifail + 1
	endif
	if (i2 .ne. 21) then
		print*,'fail 2'
		ifail = ifail + 1
	endif
	if (i3 .ne. 21) then
		print*,'fail 3'
		ifail = ifail + 1
	endif
	if (i4 .ne. 21) then
		print*,'fail 4'
		ifail = ifail + 1
	endif
	if (i5 .ne. 21) then
		print*,'fail 5'
		ifail = ifail + 1
	endif
	if (i6 .ne. 21) then
		print*,'fail 6'
		ifail = ifail + 1
	endif
	if (i7 .ne. 21) then
		print*,'fail 7'
		ifail = ifail + 1
	endif
	if (i8 .ne. 21) then
		print*,'fail 8'
		ifail = ifail + 1
	endif
	end

	subroutine sub2(ia)
	integer ia(4)
	call sub2sub1(ia(1),13)
	return

	entry sub2e1
	call sub2sub1(ia(2),899)
	return

	entry sub2e2
	call sub2sub1(ia(3),177)
	return

	entry sub2e3
	call sub2sub1(ia(4),299907)
	return
	end

	subroutine sub2sub1(i,correct)
	integer correct
	common /failure/ ifail
	if (i .ne. correct) then
		print*,'fail sub2, value=',i,' correct=',correct
		ifail = ifail+1
	endif
	end

	subroutine sub4
	integer i
	real a
	i = 1
	a = float(i - 5)
	if (abs(a + 4.0) .gt. .0001) then
c	if (a .ne. -4.0) then
		print*,'fail sub4, a=',a
		ifail = ifail+1
	endif
	end

	subroutine sub3(ia)
	dimension ia(n,n)
	common /sub3common/ n1,n
	ia(2,2) = 13
	end

	subroutine sub5
	character*10 c10
	character*18 c18
	common /failure/ ifail
	c10 = '1234567890'
	call sub5a(c10)
	if (c10 .ne. '1abcdefgh0') then
		print*,'fail sub5 (part 1), c10="',c10,'"'
		ifail = ifail + 1
	endif

	c18 = 'abcdefghijklmnopqr'
	call sub5c(c18)
	if (c18 .ne. 'ab12345678klmnopqr') then
		print*,'fail sub5 (part 2), c18="',c18,'"'
		ifail = ifail + 1
	endif
	end

	subroutine sub5a(s)
	character s(8)
	call sub5b(s(2))
	end

	subroutine sub5b(s)
	character*8 s
	s = 'abcdefgh'
	end

	subroutine sub5c(s)
	character s(*)
	call sub5d(s(3))
	end

	subroutine sub5d(s)
	character*8 s
	s = '12345678'
	end

	subroutine sub6
	common /failure/ ifail
	logical bad

	bad = .false.
	do 10 i = 1,0
10	bad = .true.

	do 20 i = 10,0
20	bad = .true.

	do 30 i = -1,-2
30	bad = .true.

	do 40 i = 0,-5
40	bad = .true.

	do 50 i = 0,1,-1
50	bad = .true.

	do 60 i = 0,10,-1
60	bad = .true.

	j = 0
	do 70 i = 1,1
70	j = j + 1
	if (j.ne.1) bad = .true.

	if (bad) then
		print*,'fail sub6'
		ifail = ifail + 1
	endif
	end

	subroutine sub7
	common /failure/ ifail
	double precision x,y,z
	x = 1.8
	y = 1.88
	z = max(x,y)
	if (z .ne. y) then
		print*,'fail sub7 (part 1)'
		ifail = ifail + 1
	endif

	z = max(x,y)
	if (z .ne. x) then
		print*,'fail sub7 (part 2)'
		ifail = ifail + 1
	endif
	end
