Protecting against division by 0
authorfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 May 2001 16:42:10 +0000 (16:42 +0000)
committerfca <fca@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 May 2001 16:42:10 +0000 (16:42 +0000)
HIJING/hijing1_36/attrad.F

index 8654762..4a188b1 100644 (file)
@@ -62,7 +62,12 @@ C.....BOOST TO REST SYSTEM FOR PARTICLES JL AND JL+1.....
        CALL ATROBO(0.,0.,BEX,BEY,BEZ,IMIN,IMAX,IERROR)
        IF(IERROR.NE.0) RETURN
 C.....ROTATE TO Z-AXIS....
-       CTH=P(JL,3)/SQRT(MAX(0,P(JL,4)**2-P(JL,5)**2))
+        PABS=(P(JL,4)-P(JL,5))*(P(JL,4)+P(JL,5))
+        IF (PABS .GT. 0) THEN
+          CTH=P(JL,3)/SQRT(PABS)
+        ELSE
+          CTH=SIGN(1.,P(JL,3))
+        ENDIF
        IF(ABS(CTH).GT.1.0)  CTH=MAX(-1.,MIN(1.,CTH))
        THETA=ACOS(CTH)
        PHI=ULANGL_HIJING(P(JL,1),P(JL,2))