Complex Magnetic field custom routine error

Hello, I have a hard time to run my input file which has dipole, solenoid and quadrupole magnets. When I run quadrupole and solenoid magnets routines separately it works fine but when I try to merge them into one routine it says “STOP NO MAGNETIC FIELD IN THIS REGION”

I am attaching input file and merged magnetic field routine which triggers an error. Can you please advise why it throws an error?

thanks

magfld_merged.f (5.8 KB)
ex1001.out (267.9 KB)
ex1001.log (162 Bytes)
ex1001.err (614 Bytes)
fluka-input.inp (17.8 KB)

Hello everyone, can anyone please check my magfld_merged.f file and let me know what may be wrong with it?

Thanks in advance

Dear Zohrab,
you get an error massage handled by the routine code itself:
line 161: CALL FLABRT(‘MAGFLD’,‘NO MAGNETIC FIELD IN THIS REGION !’)

This is due to the region name handling strategy implemented in the code. You have ELSEIF loops for NUMSOL, NUMDIP1,2,3 variables, but not for NQADRAQ1, so the next ELSE loop send you to the programmed exception.
You can check it adding loop after the one for NUMDIP3
ELSEIF ( NREG .EQ. NQADRAQ1 ) THEN
BTX = ZERZER
BTY = DIPFLD
BTZ = ZERZER

However, to make routing not just work, but give meaningful results, I need to know physics of the process you want to simulate.

Sincerely,
Illia

Dear Illia,
Fixed the problem! Everything’s working smoothly now. Thanks for your support.

best regards
Zohrab