<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hello McStas users,
<p>I sent an e-mail yesterday to Per-Olof, proposing a new version of mcstas-r.c
and .h so that the counter is a double, and global variable:
<p>----------
<br>You will find in this mail two new versions of mcstas-r.c and mcstas-r.h
files in 'lib/mcstas/' in order to make two things:
<br>1- It is now possible to know (in the code) the simulation precentage
ellapsed with the
<br><tt>mcget_run_num()/mcget_ncount()</tt> .
<br>I thus added the function <tt>mcget_run_num</tt> in <tt>mctas-r.c</tt>,
and passed the '<tt>run_num</tt>' variable from '<tt>mcstas_main</tt>'
to global '<tt>mcrun_num</tt>' as a double (not int as before !! I think
int are 32 bits on DEC machines). This should solve the never ending
simulations...
<br>2- A signal handler is added in <tt>mcstas-r.c </tt>and <tt>h</tt>
<br>It is included for non-MAC and non-WIN32 systems. It can handle USR1
signal, that tells simulation degree (%), and other signals (such as Ctrl-C=SIGINT)
will cause simulation to end, saving results...
<br>examples:
<br>To get information
<br><tt>kill -USR1 <McStas simulation Pid></tt>
<br><tt># McStas: Signal 30 detected in simulation H8 (h8.instr):
SIGUSR1</tt>
<br><tt># Date Mon Mar 5 15:05:15 2001</tt>
<br><tt># McStas: simulation now at 2.17 % ( 2171334.0/100000000.0)</tt>
<p>To end simulation
<br><tt>kill <McStas simulation Pid></tt>
<br><tt># McStas: Signal 15 detected in simulation H8 (h8.instr):
SIGTERM</tt>
<br><tt># Date Mon Mar 5 15:06:01 2001</tt>
<br><tt># McStas: finishing simulation at at 8.34 % ( 8341648.0/100000000.0)</tt>
<br><tt>Detector: D0_Source_I=5.84579e+08 D0_Source_ERR=507190 D0_Source_N=1....</tt>
<br>(saving results with <tt>mcfinally</tt>)
<br>Big system error (core dumps...) will not save results
<br>Ctrl-Z works as usual, enabling to put process in background (does
not stop the simulation).
<p>Cheers. Emmanuel.
<p>Kim Lefmann wrote:
<blockquote TYPE=CITE>------------------------------
<br>From: Kristian Nielsen <kristian@edlund.dk>
<br>Subject: Re: Again: maximum number of events...
<br>In-reply-to: "Ulrich C. Wildgruber MPI fuer Metallforschung Stuttgart"'s
<br> message of "Mon, 05 Mar 2001 14:06:27 +0100"
<br>To: neutron-mc@risoe.dk
<br>Message-id: <uofvfmj8k.fsf@edlund.dk>
<br>MIME-version: 1.0
<br>Content-type: text/plain; charset=us-ascii
<br>User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
<br>Lines: 42
<br>References: <3AA34FFE.E3B2B252@dxray.mpi-stuttgart.mpg.de>
<br> <3AA36A49.282C40B@phys.keele.ac.uk>
<br> <3AA38F53.22411C9@dxray.mpi-stuttgart.mpg.de>
<p>"Ulrich C. Wildgruber MPI fuer Metallforschung Stuttgart" <wildgrub@dxray.mpi-stuttgart.mpg.de>
writes:
<p>> Maybe I misunderstood Kristian's email (I'll look for it and forward
it to
<br>> you) or there is something wrong with the way McStas is set up on
my
<br>> machine. The behaviour of McStas seems to be compatible with an "long
int"
<br>> counting variable being 32bits on a PC and 64 bits on the ALPHA...
<br>> I guess I'll try to look into the code...
<p>I decided to re-check the source code. The relevant code is in the file
<br>"lib/mcstas-r.c" (some parts deleted for clarity):
<p> /* Number of neutron histories to simulate. */
<br> static double mcncount = 1e6;
<p> /* McStas main() function. */
<br> int
<br> mcstas_main(int argc, char *argv[])
<br> {
<br> int run_num = 0;
<br> ^^^
<p> while(run_num < mcncount)
<br> {
<br> mcsetstate(0, 0, 0, 0, 0,
1, 0, 0, 1, 0, 1);
<br> mcraytrace();
<br> run_num++;
<br> }
<p> return 0;
<br> }
<p>So "mcncount" is a double, as I said before, but the loop counter
<br>"run_num" is an int. This is a bug, the declaration should be changed
to
<p> double run_num = 0;
<p>Without this change, McStas is clearly limited to about 2*10**9
<br>neutrons/run on 32 bit machines. I am mystified as to why this is not
<br>the case on the Alpha (I thought that on Alpha, int was 32 bit and
long
<br>was 64, but maybe my memory deceives me).
<p> - Kristian.</blockquote>
<pre>--
What's up Doc ?
--------------------------------------------
Emmanuel FARHI, <A HREF="http://www.ill.fr/tas/people/Farhi.html">http://www.ill.fr/tas/people/Farhi.html</A> \|/ ____ \|/
CS-Group ILL4/156, Institut Laue-Langevin (ILL) Grenoble ~@-/ oO \-@~
6 rue J. Horowitz, BP 156, 38042 Grenoble Cedex 9,France /_( \__/ )_\
Work :Tel (33/0) 4 76 20 71 35. Fax (33/0) 4 76 48 39 06 \__U_/</pre>
</html>