Initializing user routine magfld.f

Dear FLUKA users,

I am trying to initialize the user routine magfld.f with a constant magnetic field By = - 1.2 T in a region called “selmag”. But after compiling and creating executable and running the simulation I don’t have the magnetic field initialized , the protons travel undeflected.
I just installed a new FLUKA and FLAIR distribution on Mac OS Catalina.
Before compiling I launched the following commands following the instructions:

  1. ./fff …/…/…/Case/magfld.f
    2)/lfluka -m fluka -o myfluka …/…/…/Case/magfld.o
  2. Then I created the exe file in the flair Compile section
  3. My WHATSOU in MGFLD card are 0.0 ,0.0, 0.0 for Bx,By, Bz.

Am I doing something wrong?
During the compiling and building I did not receive any errors.
Thanks
Here is my routine:

*
*===magfld=============================================================*
*
      SUBROUTINE MAGFLD ( X, Y, Z, BTX, BTY, BTZ, B, NREG, IDISC )

      INCLUDE 'dblprc.inc'
      INCLUDE 'dimpar.inc'
      INCLUDE 'iounit.inc'
*
*----------------------------------------------------------------------*
*                                                                      *
*     Copyright (C) 2003-2019:  CERN & INFN                            *
*     All Rights Reserved.                                             *
*                                                                      *
*     Created  in     1988         by    Alberto Fasso`                *
*                                                                      *
*     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.inc'
      INCLUDE 'csmcry.inc'
*
*  +-------------------------------------------------------------------*
      DIMENSION IROTIN(10)
      LOGICAL LFIRST
      SAVE LFIRST 
      SAVE SEL1, MAG1
      DATA LFIRST / .TRUE. /, IROTIN / 10*0 /
      IDISC = 0
      IF (LFIRST) THEN
         SEL1  = -1.2D+00
         CALL GEON2R("selmag", MAG1, IERR)
         LFIRST  = .FALSE.
      END IF

      IF (NREG.EQ.MAG1) THEN 
         BTX   = ZERZER
         BTY   = ONEONE
         BTZ   = ZERZER
         B     = SEL1
      END IF
      RETURN
*=== End of subroutine Magfld =========================================*
      END

Dear Sophia,

without the .flair file I can’t test is, but if I’m correct you should use the "selmag " (two spaces at the end) string in the GEON2R function.

FLUKA pads the names of bodies and regions with spaces to be 8 character long.

Cheers,
David

2 posts were split to a new topic: Definition of “negative” magnetic field