Problem when trying to run own magfld.f routine

Hi All,

I’m new to using FLUKA and FLAIR and I’ve been trying to just model a constant magnetic field using a modified magfld.f routine to compare with the result I get when I just change the MGNFIELD card to By=1.0 T, Bx=Bz=1.0 T (with the aim to model more complicated fields later). I’ve attached my input file and modified magfld.f routine (called magfld_dipole.f), the executable builds fine. I’m scoring dose in a water phantom after going through the constant magnet, and the result is exactly the same as when there is no magnetic field (despite the fact that it works when I just use MGNFIELD). Can anyone let me know what I’ve done wrong? I’ve downloaded the latest FLAIR and FLUKA from the website and I’m running it on Fedora on virtual box.
Dipole.flair (2.1 KB)
magfld_dipole.f (2.3 KB)


Dear Lucy,

I find it strange that you didn’t get any compilation error since your user routine is a mix from different FLUKA versions.

I suggest you start over with the one coming with the CERN distribution.


1 Like

Hi David,

Thank you for your reply! I have now written a new user routine and made sure to use the one from the CERN distribution, and gotten this to work. I have also written a new user routine for a simple quadrupole magnet, butI am going to post a new question because I am a bit confused over what the units of the quadrupole strengths are (I think they should be in T/cm but my results don’t match up with the same thing in TOPAS so need to check)!

Thanks again,