opal AT lists.psi.ch
Subject: The OPAL Discussion Forum
List archive
- From: "Adelmann Andreas (PSI)" <andreas.adelmann AT psi.ch>
- To: Simon Friederich <sifriede AT uni-mainz.de>
- Cc: "Snuverink Jochem (PSI)" <jochem.snuverink AT psi.ch>, "opal AT lists.psi.ch" <opal AT lists.psi.ch>
- Subject: Re: [Opal] Arrays and tables
- Date: Sat, 8 Aug 2020 13:29:57 +0000
- Accept-language: en-US, de-CH
Hi Simon
REAL VECTOR rf_settings = {10.1,11.1};
REAL
a = rf_settings[1];
REAL
b = rf_settings[2];
VALUE,
a;
VALUE,
b;
VALUE, {rf_settings[1]};
this works fine. OPAL uses the FORTRAN indexing, i.e. we start with 1 not 0.
You also need { } around the vector variable.
Cheers A
------
Dr. sc. math. Andreas (Andy) Adelmann
Head a.i. Labor for Scientific Computing and Modelling
Paul Scherrer Institut OHSA/ CH-5232 Villigen PSI
Phone Office: xx41 56 310 42 33 Fax: xx41 56 310 31 91
Zoom ID: 470-582-4086 Password: AdA
-------------------------------------------------------
Friday: ETH HPK G 28 +41 44 633 3076
============================================
The more exotic, the more abstract the knowledge,
the more profound will be its consequences.
Leon Lederman
============================================
Dr. sc. math. Andreas (Andy) Adelmann
Head a.i. Labor for Scientific Computing and Modelling
Paul Scherrer Institut OHSA/ CH-5232 Villigen PSI
Phone Office: xx41 56 310 42 33 Fax: xx41 56 310 31 91
Zoom ID: 470-582-4086 Password: AdA
-------------------------------------------------------
Friday: ETH HPK G 28 +41 44 633 3076
============================================
The more exotic, the more abstract the knowledge,
the more profound will be its consequences.
Leon Lederman
============================================
On 8 Aug 2020, at 12:37, Simon Friederich <sifriede AT uni-mainz.de> wrote:
Hello Joachem and Andreas,
Thank you for your replies. Yes, I've figured out, that I missed "vector" in the array declaration.
But I still can't access single elements:
...
OPAL>
OPAL> This is OPAL (Object Oriented Parallel Accelerator Library) Version 2.3.0
OPAL> git rev. 788bd1b6cec32045efe14a8754ff1b169aab3565
...
==>REAL vector myvector = {1,2,3};
1 REAL vector myvector = {1,2,3};
==>VALUE, myvector[0];
2 VALUE, myvector[0];
Error>
Error> *** Parse error detected by function "OpalParser::parseEnd()"
Error> *** in line 2 of file "standard input" before token "[":
Error> VALUE,MYVECTOR[0];
Error> ^
Error> Syntax error (maybe missing comma or semicolon ? )I'm I missing something here?
Best regards,
Simon
Am 07.08.2020 um 15:40 schrieb Snuverink Jochem (PSI):
Dear Simon,As Christof wrote in the bug report, the correct syntax is “REAL VECTOR= {};I am not aware of the option of 2D-arrays.So perhaps then:REAL VECTOR volts = {7.5, 8.0, 8.5, 9.0, 9.5};REAL VECTOR lags = {239.32815,... };pb1: RFCAVITY, ...., VOLT = volts[0] * 1e-3, LAG = lags[0] * PI / 180, ...;Note that you can also do:REAL VECTOR volts = {7.5, 8.0, 8.5, 9.0, 9.5} * 1e-3; // in MVREAL VECTOR lags = {239.32815,... } * PI / 180; // in radspb1: RFCAVITY, ...., VOLT = volts[0], LAG = lags[0], ...;Best wishes,JochemFrom: opal-request AT lists.psi.ch <opal-request AT lists.psi.ch> On Behalf Of Adelmann Andreas (PSI)
Sent: Freitag, 7. August 2020 08:33
To: Simon Friederich <sifriede AT uni-mainz.de>
Cc: opal AT lists.psi.ch
Subject: Re: [Opal] Arrays and tablesDear Simon, indeed it seams that he array feature is broken.Even a one dimensional real array does not work. I will file a bug report.Thanks for reporting!Cheers A------
Dr. sc. math. Andreas (Andy) Adelmann
Head a.i. Labor for Scientific Computing and Modelling
Paul Scherrer Institut OHSA/ CH-5232 Villigen PSI
Phone Office: xx41 56 310 42 33 Fax: xx41 56 310 31 91
Zoom ID: 470-582-4086 Password: AdA
-------------------------------------------------------
Friday: ETH HPK G 28 +41 44 633 3076
============================================
The more exotic, the more abstract the knowledge,
the more profound will be its consequences.
Leon Lederman
============================================
On 5 Aug 2020, at 11:44, Simon Friederich <sifriede AT uni-mainz.de> wrote:Dear OPAL-Team,I have a set of configuration parameters for an RFCAVITY element:volt lag
7.5 239.328125
8.0 239.2578125
8.5 239.18359375
9.0 239.08984375
9.5 239.01953125I tried but failed to get the correctly needed syntax:
Can I use an array or table somehow like this?REAL rf_settings = {
{7.5, 239.328125},
{8.0, 239.2578125},
{8.5, 239.18359375},
{9.0, 239.08984375},
{9.5, 239.01953125},
};And then use (e.g. setting 0):pb1: RFCAVITY,...,VOLT=rf_settings[0][0]*1e-3, LAG=rf_settings[0][1]*PI/180,...;Thank you very much in advance!Best regards
Simon-------------------------------------Dr. Simon FriederichHelmholtz-Institut MainzKollaboration B/ACIDJohannes Gutenberg-Universität MainzStaudingerweg 1855128 Mainz, DeutschlandTel.: +49 (0)6131 39-23160E-Mail: sifriede AT uni-mainz.de------------------------------------------ ----------------------------------- Dr. Simon Friederich Helmholtz-Institut Mainz Kollaboration B/ACID Johannes Gutenberg-Universität Mainz Staudingerweg 18 55128 Mainz, Deutschland Tel.: +49 (0)6131 39-23160 E-Mail: sifriede AT uni-mainz.de ----------------------------------------
- [Opal] Arrays and tables, Simon Friederich, 08/05/2020
- Re: [Opal] Arrays and tables, Adelmann Andreas (PSI), 08/07/2020
- RE: [Opal] Arrays and tables, Snuverink Jochem (PSI), 08/07/2020
- Re: [Opal] Arrays and tables, Simon Friederich, 08/08/2020
- Re: [Opal] Arrays and tables, Adelmann Andreas (PSI), 08/08/2020
- Re: [Opal] Arrays and tables, Simon Friederich, 08/08/2020
- RE: [Opal] Arrays and tables, Snuverink Jochem (PSI), 08/07/2020
- Re: [Opal] Arrays and tables, Adelmann Andreas (PSI), 08/07/2020
Archive powered by MHonArc 2.6.19.