SUBROUTINE SUSDKL( IErr ) C -------------------------------------------------------------------------- C Purpose: Determine how far a particle of given decay length C travels before decaying. C C The equation governing the decay is: C N = N_o * exp( -x/decay_length) C Thus probabilty of decay in interval x -> x + dx is: C abs(dN/N_o) = exp( -x/decay_length) * dx/decay_length C C IErr = 1 -----> too many loops. gave up. In this case a random length C within the decay length is generated. C C Author: JMB C -------------------------------------------------------------------------- C IMPLICIT NONE C INCLUDE 'SUSANA.INC' C REAL randum, rn32, gone REAL prob INTEGER nloop, IErr C C -- Initialise C ierr = 0 nloop = 0 distance = 0.0 C gone = rn32(randum) C 1 CONTINUE C IF (nloop .GT. 100) THEN IErr = 1 GOTO 7900 ENDIF C nloop = nloop + 1 distance = distance + dx*decay_length C prob = dx * exp(-1.0*distance/decay_length) C IF ( gone .GT. prob) GOTO 1 C 7900 CONTINUE distance = distance + rn32(randum)*dx*decay_length C 8900 CONTINUE RETURN END