c
c----------------------------------------------------------------------------
c
      subroutine rotate(decay_rot, time)
c
c     routine to rotate the e+-momentum vector in case of an applied
c     bfield; BFIELD is a 4-component array with bfield(4) = polarization.
c     If Polarization = 0 return.
c
c       T. Prokscha,    15-Sep-2000,    PSI
c
c       Unix version,   part of the geant_lemsr program
c
c-----------------------------------------------------------------------------
c
      implicit none
c
#include "common.inc"
c
      real*4  decay_rot(3), time
      real*4  omega, prec_angle, costh, sinth, cosph, sinph
c
c------------------------------------------------
c
        if ( bfield(4) .eq. 0. ) return
c
        if ( bfield(2) .ne. 0. ) then
            omega      = bfield(2) * TWO_PI * MU_GYRO  ! cycle/nsec
            prec_angle = omega * time
            costh = cos(prec_angle)
            sinth = -sin(prec_angle)    ! clockwise rotation
            cosph = 1.
            sinph = 0.
c
            call gdrot(decay_rot, costh, sinth, cosph, sinph)
c
        endif
c
        if ( bfield(3) .ne. 0. ) then
            omega      = bfield(3) * TWO_PI * MU_GYRO  ! cycle/nsec
            prec_angle = omega * time
            cosph = cos(prec_angle)
            sinph = -sin(prec_angle)    ! clockwise rotation
            costh = 1.
            sinth = 0.
c
            call gdrot(decay_rot, costh, sinth, cosph, sinph)
c
        endif
c
        return
        end
