
C	subroutine to check how the corners of a search 
C	rectangle are in relation to the branch cuts, 
C	the search rectangle may be 'skipped'

C	Sven Ivansson 1990



	SUBROUTINE CORNTESTSUB (X1,X2,Y1,Y2, SKIPRECT)

	IMPLICIT NONE

	COMMON /CORNTEST/ ICORNTEST, XYHYPA,XYHYPB
	INTEGER ICORNTEST
	REAL*16 XYHYPA,XYHYPB
	SAVE   /CORNTEST/

	REAL*16 X1,X2,Y1,Y2

	LOGICAL SKIPRECT

	REAL*16 SLASK, SLASKMIN,SLASKMAX

	IF (ICORNTEST.EQ.0) THEN

	  SKIPRECT = .FALSE.
	  RETURN

	ELSE

	  GOTO (1,2,3,4,5,6,7) ICORNTEST
	  STOP 4516

 1	  IF (X1.GE.0.0Q0) THEN
	    IF ( X1*Y1 .GT. XYHYPA ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    IF ( X2*Y2 .GT. XYHYPA ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  END IF
	  RETURN

 2	  IF (X1.GE.0.0Q0) THEN
	    IF ( X2*Y2 .LT. XYHYPA ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    IF ( X1*Y1 .LT. XYHYPA ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  END IF
	  RETURN

 3	  IF (X1.GE.0.0Q0) THEN
	    IF ( X1*Y1 .GT. XYHYPB ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    IF ( X2*Y2 .GT. XYHYPB ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  END IF
	  RETURN

 4	  IF (X1.GE.0.0Q0) THEN
	    IF ( X2*Y2 .LT. XYHYPB ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    IF ( X1*Y1 .LT. XYHYPB ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  END IF
	  RETURN

 5	  SLASK = MIN(XYHYPA,XYHYPB)
	  IF (X1.GE.0.0Q0) THEN
	    IF ( X1*Y1 .GT. SLASK ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    IF ( X2*Y2 .GT. SLASK ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  END IF
	  RETURN

 6	  SLASK = MAX(XYHYPA,XYHYPB)
	  IF (X1.GE.0.0Q0) THEN
	    IF ( X2*Y2 .LT. SLASK ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    IF ( X1*Y1 .LT. SLASK ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SKIPRECT = .FALSE.
	    END IF
	  END IF
	  RETURN

 7	  SLASKMIN = MIN(XYHYPA,XYHYPB)
	  SLASKMAX = MAX(XYHYPA,XYHYPB)
	  IF (X1.GE.0.0Q0) THEN
	    SLASK = X2*Y2
	    IF ( SLASK .LT. SLASKMIN ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SLASK = X1*Y1
	      IF ( SLASK .GT. SLASKMAX ) THEN
	        SKIPRECT = .TRUE.
	      ELSE
	        SKIPRECT = .FALSE.
	      END IF
	    END IF
	  ELSE
	    IF (X2.GT.0.0Q0) STOP 341
	    SLASK = X1*Y1
	    IF ( SLASK .LT. SLASKMIN ) THEN
	      SKIPRECT = .TRUE.
	    ELSE
	      SLASK = X2*Y2
	      IF ( SLASK .GT. SLASKMAX ) THEN
	        SKIPRECT = .TRUE.
	      ELSE
	        SKIPRECT = .FALSE.
	      END IF
	    END IF
	  END IF
	  RETURN

	END IF

	END
