Skip to Content.
Sympa Menu

opal - Re: [Opal] MACRO execution fails [nosign]

opal AT lists.psi.ch

Subject: The OPAL Discussion Forum

List archive

Re: [Opal] MACRO execution fails [nosign]


Chronological Thread  
  • From: "Snuverink Jochem (PSI)" <jochem.snuverink AT psi.ch>
  • To: "opal AT lists.psi.ch" <opal AT lists.psi.ch>, "Dr. Simon Friederich" <s.friederich AT uni-mainz.de>
  • Subject: Re: [Opal] MACRO execution fails [nosign]
  • Date: Fri, 19 Feb 2021 16:31:16 +0000
  • Accept-language: en-US, de-CH
  • Authentication-results: localhost; iprev=pass (psi-seppmail1.ethz.ch) smtp.remote-ip=129.132.93.141; spf=pass smtp.mailfrom=psi.ch; dmarc=skipped

Dear Simon,


In version 2.4 the SHOW command was removed. I see that the documentation on the MACRO command still shows an example using it. Sorry, for that, we'll update it. Secondly, there is a semicolon missing after your SHOWIT(PI).


The following should do what you want:


REAL X = 2;

// print value
VALUE,VALUE={X,X*2};
// print macro
SHOWIT(X): MACRO {
   VALUE,VALUE={X};
}
SHOWIT(X);
SHOWIT(PI);
// calculate
KS(X): MACRO {
   X = 3e-3*X+0.5e-3;
}
// assign X
KS(X);
// print X
SHOWIT(X);

Output:


OPAL> value: {X,X*2} = {2, 4}
OPAL> 
OPAL> 
OPAL> value: {X} = {2}
OPAL> 
OPAL> 
OPAL> value: {PI} = {3.14159}
OPAL> 
OPAL> 
OPAL> value: {X} = {0.0065}

Hope that helps,

Jochem



From: opal-request AT lists.psi.ch <opal-request AT lists.psi.ch> on behalf of Dr. Simon Friederich <s.friederich AT uni-mainz.de>
Sent: Friday, February 19, 2021 3:35 PM
To: opal AT lists.psi.ch
Subject: [Opal] MACRO execution fails
 

Dear OPAL-Team,

I wanted to play with the MACRO command, but unfortunately it leads to a "Segmentation fault":

Example from: http://amas.web.psi.ch/opal/Documentation/master/OPAL_Manual.html#sec.control.macro

test.in:

SHOWIT(X): MACRO {
   SHOW, NAME = X;
}
SHOWIT(PI)

Terminal output:

OPAL> This is OPAL (Object Oriented Parallel Accelerator Library) Version 2.4.0
OPAL>             git rev. ffded40c6dd317d29776f58f33080e2919319d89
...
OPAL> Finished reading startup file.
OPAL> * Reading input stream "test.in".
[desktop-04:394206] *** Process received signal ***
[desktop-04:394206] Signal: Segmentation fault (11)
[desktop-04:394206] Signal code: Address not mapped (1)
[desktop-04:394206] Failing at address: 0x34
[desktop-04:394206] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f06780253c0]
[desktop-04:394206] [ 1] opal(_ZlsRSoRK5Token+0x19)[0x55612ef3aed9]
[desktop-04:394206] [ 2] opal(_ZNK9Statement10printWhereER6Informb+0xbe)[0x55612ef38a6e]
[desktop-04:394206] [ 3] opal(_ZNK10OpalParser13readStatementEP11TokenStream+0x513)[0x55612ef60c13]
[desktop-04:394206] [ 4] opal(_ZNK10OpalParser3runEv+0x79)[0x55612ef5b519]
[desktop-04:394206] [ 5] opal(_ZNK10OpalParser3runEP11TokenStream+0x7d)[0x55612ef6064d]
[desktop-04:394206] [ 6] opal(main+0x20b9)[0x55612eea1f69]
[desktop-04:394206] [ 7] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f06770fc0b3]
[desktop-04:394206] [ 8] opal(_start+0x2a)[0x55612eeac03a]
[desktop-04:394206] *** End of error message ***
Segmentation fault (core dumped)

I guess this is the result of a compilation error for my OPAL version, right?

If I want to use functions in OPAL, is there another possibility than using MACROS? (E.g. def KS(x): return KS = 3e-3*x+0.5e-3?)

Best regards
Simon

-- 
Dr. Simon Friederich
Helmholtz-Institut Mainz | Insitut für Kernphysik
Kollaboration ACID       | B
Johannes Gutenberg-Universität Mainz
Staudingerweg 18         | Johann-Joachim-Becherweg 45
55128 Mainz, Deutschland

Tel.: +49 (0)6131 39-23160
E-Mail: s.friederich AT uni-mainz.de


  • [Opal] MACRO execution fails, Dr. Simon Friederich, 02/19/2021
    • Re: [Opal] MACRO execution fails [nosign], Snuverink Jochem (PSI), 02/19/2021

Archive powered by MHonArc 2.6.19.

Top of Page