Again: maximum number of events...

Ulrich C. Wildgruber MPI fuer Metallforschung Stuttgart wildgrub at
Mon Mar 5 14:06:27 CET 2001

Mark Hagen wrote:
> Dear Ulrich,
> Apologies if I am saying the obvious here, or if what I am saying is already
> known, but 2e9 is close to 2**31-1, the limit for a "signed int" (i.e. default
> integer) on a 32 bit machine. Presumably a signed int on a 64 bit ALpha is much
> larger. If you try an integer larger than 2e9 then presumably you get a memory
> overspill and uncontrolled results (the program goes on and on forever). Many
> compilers don't trap integer overflow by default, I'm not sure what settings the
> gcc in McStas has for this but it may ignore the overflow (it may even use an
> integer overflow in the random number generator).
> You could test this if you could find in the code the definition of the integer
> holding the number of neutrons and change it from "int" to "long int" or even
> "unsigned int" (the later would get you to 2**32, i.e. 4e9, while the former
> would get you to the same integer precision as the Alpha presumably).
> If you want someone to try your job next weekend (I calculate from your figures
> that it will take 25 hours to run if it works ?) then I will give it a go on my
> Mandrake 7.0 (450MHz Pentium III). Although it has to be next weekend since I
> need the PC for other things during the week.
> Don't know if that is any help,
> cheers,
> Mark

Dear Mark,

thanks for the quick response and the offer to run a 25 hours job on a
machine of yours. I am really interested in seeing what would happen on
your PC because of the following:
A while ago I ran a 3e+09 job on my office PC (SuSe 6.4) which I stopped after
- what I thought was - plenty of time to complete. I sent an email to 
Per-Olof assuming that counting of neutrons was done with a "plain" integer
variable where you should run into the 2**31-1 problem. I was asking Per-Olof
to add an additional (outer) loop to be able to run more neutrons through
mcstas. Per-olof kindly forwarded my message to Kristian who told me (us)
that he is using a floating point variable to count the neutrons. This should
allow to run much longer jobs than I wanted to...
I used an ALPHA workstation to try it again and it worked just fine (at least
up to n=4e+09) i.e the program comes to a regular end. I was using the ALPHA
to run those bigger jobs for a couple of weeks but finally decided to
reinstall mcstas on the Linux machine and try it there too.
I hoped it would work and I waited and waited and waited until this morning...

Maybe I misunderstood Kristian's email (I'll look for it and forward it to
you) or there is something wrong with the way McStas is set up on my
machine. The behaviour of McStas seems to be compatible with an "long int" 
counting variable being 32bits on a PC and 64 bits on the ALPHA...
I guess I'll try to look into the code...

Nevertheless I'd appreciate if you give it a go next weekend unless I (we)
have found an answer to this "mystery" by then...

Thanks again!



wildgrub at
Max-Planck-Institut für Metallforschung	| Technische Universität München
Heisenbergstr. 1		        | ZBE Neue Forschungs-Neutronenquelle
					| Instrumentierung
D-70569 Stuttgart			| D-85747 Garching/München
Tel.: (+49)-711-689-1900		| Tel.: (+49)-89-289-14681
Fax.: (+49)-711-689-1902		| Fax.: (+49)-89-289-14666

More information about the mcstas-users mailing list