*$ CREATE MAGFLD.FOR
*COPY MAGFLD
*
*===magfld=============================================================*
*
      SUBROUTINE MAGFLD ( X, Y, Z, BTX, BTY, BTZ, B, NREG, IDISC )

      INCLUDE '(DBLPRC)'
      INCLUDE '(DIMPAR)'
      INCLUDE '(IOUNIT)'
*
*----------------------------------------------------------------------*
*                                                                      *
*     Copyright (C) 1988-2010      by Alberto Fasso` & Alfredo Ferrari *
*     All Rights Reserved.                                             *
*                                                                      *
*                                                                      *
*     Created  in     1988         by    Alberto Fasso`                *
*                                                                      *
*                                                                      *
*     Last change on 06-Nov-10     by    Alfredo Ferrari               *
*                                                                      *
*     Input variables:                                                 *
*            x,y,z = current position                                  *
*            nreg  = current region                                    *
*     Output variables:                                                *
*            btx,bty,btz = cosines of the magn. field vector           *
*            B = magnetic field intensity (Tesla)                      *
*            idisc = set to 1 if the particle has to be discarded      *
*                                                                      *
*----------------------------------------------------------------------*
*
      INCLUDE '(CMEMFL)'
      INCLUDE '(CSMCRY)'
*  +-------------------------------------------------------------------*
*	Initialize Core Routine                                          *
*  +-------------------------------------------------------------------*
      IDISC = 0

* 0.205 T fields in 2 regions TurnVac1 BTY = 1.0, TurnVac2 BTY = -1.0  *
      IF ( NREG .EQ. TurnVac1 ) THEN
*        First linac turn, 0.205 T in positive y-axis
         BTX = ZERZER
         BTY = ONEONE
         BTZ = ZERZER
      ELSEIF ( NREG .EQ. TurnVac2 ) THEN
*        Second linac turn, 0.205 T in negative y-axis
         BTX = ZERZER
         BTY = -ONEONE
         BTZ = ZERZER
      ENDIF

*     get field intensity: 
      B   = 0.205



      RETURN
*=== End of subroutine Magfld =========================================*
      END


