Dear Jordi,
the SAVE statement is used at variable declaration not when the value is assigned. (See variable LFCOPE)
However there are some algorithmic problems with your code:
-
Once
bdxcodeis set to19, it will remain19and the test in theUSDRAWentry becomes meaningless. -
The
USDRAWentry is called when an interaction is happening (in regionMREG, at the positionXSCO,YSCO,ZSCO), it is not related at all to boundary crossings. -
Also there is no guarantee that the interaction scored with
USDRAWand the muon which crossed the region are related at all.
If I understood you correctly you want to dump all secondaries created by muons, which previously crossed a region boundary. If this is true, you may use the LLOUSE, ISPUSR, or SPAUSR user variables in the trackr.inc common to mark the muons passing the boundary in BXDRAW, and use this information to filter the secondaries generated in USDRAW.
See: 13.2.21} stupre.f: SeT User PRoperties for EMF particles | FLUKA and Information about particle ancestors - #2 by a.lechner
Cheers,
David