[mcstas-users] switchable components (WHEN) problem

Emmanuel FARHI farhi at ill.fr
Wed Jun 22 22:25:12 CEST 2011


Hello Jean-Francois,

Thanks for the special Barbapapa instrument file, which I should think
about including in the McStas package ;-) .

The declaration of variables can only be initialized to constants in
DECLARE. For other assignements, use the INITIALIZE:

DECLARE

  int NOK9_type=0;

INITIALIZE

  NOK9_type = NOK9_Type;


Cheers, Emmanuel.


On Wed, June 22, 2011 20:43, Jean-Francois.Moulin at hzg.de wrote:
> Hi dear McStas Team!
>
> first of all I wanted to send you a big thanks for the NIDS school in Lund
> !
> You got me started!
>
> Now... I of course come with some questions...
> First one is related to the use of facultative components built using a
> WHEN.
>
> I 'd like to be able to activate them via an INSTRUMENT parameter (which I
> understand is out of scope in the WHEN).
>
> This is what I did:
>
> DEFINE INSTRUMENT REFSANS(... foo, bar.....
>                                                   int NOK9_Type = 0 )
>         /* My switch*/
>
> DECLARE
> %{
>
>         int NOK9_type = NOK9_Type; */ copied here to put it in WHEN scope
> */
> ...
> %}
>
> .... long list of components...
>
> /*  In order to keep a reference to a switchable device I use an arm */
> COMPONENT NOK9 = Arm()
>     AT (0, 0, l_NOK8 + space_NOK89) RELATIVE NOK8
>
> /* first switchable */
> COMPONENT NOK9_guide = Guide_gravity(w1 = .112, ...., ) WHEN (NOK9_type ==
> 0)
>
>     AT (0, 0, 0) RELATIVE NOK9
> ....
>
> This code fails miserably with:
> /home/jfmoulin/McStas/refsans_chopper_all_noks_switchable.instr:50: error:
> initializer element is not constant
> (line 50 is the declare where I copy the instrument par...)
> I understand that the compiler expects the declare to be constants but I
> thought this followed the tip given in the manual ....
>
> As an additional remark, the manual references Neutron
> site/ILL/ILL_TOF_Env as an example... but this file does not exist on my
> install.
>
> Thanks a lot for any input
> Cheers Jean-Francois
> -
> Helmoltz Zentrum Geesthacht
> Institut für Werkstoffforschung
> Abteilung WPN, Instrument REFSANS
> Lichtenbergstr. 1
> 85747 Garching FRM II
> Tel.: +49 (0)89 289 10762
> Internet: http://www.frm2.tum.de
>
>
>
> Helmholtz-Zentrum Geesthacht
> Zentrum für Material- und Küstenforschung GmbH
> Max-Planck-Straße 1
> 21502 Geesthacht
> Deutschland/Germany
>
> Geschäftsführer/Board of Management: Prof. Dr. Wolfgang Kaysser,
> Dipl.-Ing. Michael Ganß
> Vorsitzender des Aufsichtsrates/Chairman of the Supervisory Board:
> Ministerialrat Wilfried Kraus
>
> Amtsgericht Lübeck  HRB 285 GE (Register Court)
> Internet: http://www.hzg.de
>
>
> ACHTUNG - ATTENTION
>
> Die Helmholtz-Zentrum Geesthacht Zentrum für Material- und Küstenforschung
> GmbH
> hieß bis zum 1. November 2010 GKSS-Forschungszentrum Geesthacht GmbH.
>
> Until 1st November 2010 the Helmholtz-Zentrum Geesthacht Zentrum für
> Material- und Küstenforschung GmbH was officially called
> GKSS-Forschungszentrum Geesthacht
> GmbH._______________________________________________
> mcstas-users mailing list
> mcstas-users at mcstas.org
> http://mailman.mcstas.org/cgi-bin/mailman/listinfo/mcstas-users
>


-- 
FARHI Emmanuel <farhi at ill.fr>
Groupe DS/CS, ILL4/156, Tel 04 76 20 71 35
ILL, Grenoble




More information about the mcstas-users mailing list