How to rotate the beam in the direction of incidence by 45 degrees with source.f?

I want the beam to be at a 45 degree angle to the y-axis, as shown in the image below. (This is what I did with the BEAMPOS card).


and dose distribution is correctly obtained to the Bragg Peak as below

When I using source.f, I modified the following values in the source file.
and get result:

How do I set it up correctly to get a beam at a 45-degree angle?

water.flair (3.0 KB)
water.inp (1.6 KB)
proton.f (11.6 KB)

The above are the relevant files.

Hello @zcao23 ,

First comment: to use a source routine you need to active the SOURCE card which was not the case in your input file.

Second comment: If I were you, to avoid complexity, I you have rotate my target and the ursbin attached to it of 45d instead using the card ROTPRBIN.

If you really want to use a source routine, I invite you to use the source_newgen.f routine, which is easier to use. You can find it in the data base but I uploaded here:
source_newgen.f (20.8 KB)
FLUKA course, new source routine

Using this routine, you just have to modify direction_cosx, direction_cosy, direction_cosz

Please let me know if this solved your problem or if you need more.