Call SUBROUTINE GET_ME(P, ALPHAS, NHEL ,ANS) in C++

Asked by Thomas Müller on 2017-11-03

Dear experts,

I generate fortran code to calculate matrix elements via "output standalone ..." and I know how to create a python library and to call the get_me function in python (https://cp3.irmp.ucl.ac.be/projects/madgraph/wiki/FAQ-General-4). However, I need to call this function in C++. The detour calling the python code, which is created from fortran, in C++ is very slow and I am pretty sure, that it should be possible to call the fortran code directly in C++. Is there a small/minimal example how to do that?

I found out, that I can compile the fortran code into a library matrix.o with "make check". If I compile a test (hello world) script using "g++ -L../../lib/ -ldhelas -lmodel -lgfortran matrix.o test.cc", I get some undefined reference errors.

matrix.o: In function `matrix_':
matrix.f:(.text+0x1e6): undefined reference to `vxxxxx_'
matrix.f:(.text+0x220): undefined reference to `vxxxxx_'
matrix.f:(.text+0x24c): undefined reference to `sxxxxx_'
matrix.f:(.text+0x272): undefined reference to `vvs2_10_0_'
matrix.o: In function `get_me_':
matrix.f:(.text+0x6d5): undefined reference to `update_as_param_'
matrix.o: In function `initialise_':
matrix.f:(.text+0x73d): undefined reference to `setpara_'
collect2: error: ld returned 1 exit status

Any help is welcome. Thanks in advance.

The second question would be then how to distinguish multiple subprocess directories, that all contain the same function with the same name (GET_ME), but maybe I will figure out a way to do it...

Best regards,
Thomas

Question information

Language:
English Edit question
Status:
Answered
For:
MadGraph5_aMC@NLO Edit question
Assignee:
No assignee Edit question
Last query:
2017-11-03
Last reply:
2017-11-03

Hi Thomas,

For C++, the simple to my point of view is to ask Madgraph to write the code in C++ and not use any wrapping.
you have the output “standalone_cpp” (describe in the link that you follow) which does just that.

For having a single library, this is also possible with fortran/python as described in the link that you provide:
https://cp3.irmp.ucl.ac.be/projects/madgraph/wiki/FAQ-General-4#Fulllibraryofprocessinpython
(you need to use 2.6.0 for that)

Otherwise, Valentin Hirschi has written a dedicated plugin to have a more flexible cpp standalone output. This is not public but you can contact him, and he will provide it to you (if you kindly ask)

Cheers,

Olivier

> On Nov 3, 2017, at 11:53, Thomas Müller <email address hidden> wrote:
>
> New question #660295 on MadGraph5_aMC@NLO:
> https://answers.launchpad.net/mg5amcnlo/+question/660295
>
> Dear experts,
>
> I generate fortran code to calculate matrix elements via "output standalone ..." and I know how to create a python library and to call the get_me function in python (https://cp3.irmp.ucl.ac.be/projects/madgraph/wiki/FAQ-General-4). However, I need to call this function in C++. The detour calling the python code, which is created from fortran, in C++ is very slow and I am pretty sure, that it should be possible to call the fortran code directly in C++. Is there a small/minimal example how to do that?
>
> I found out, that I can compile the fortran code into a library matrix.o with "make check". If I compile a test (hello world) script using "g++ -L../../lib/ -ldhelas -lmodel -lgfortran matrix.o test.cc", I get some undefined reference errors.
>
> matrix.o: In function `matrix_':
> matrix.f:(.text+0x1e6): undefined reference to `vxxxxx_'
> matrix.f:(.text+0x220): undefined reference to `vxxxxx_'
> matrix.f:(.text+0x24c): undefined reference to `sxxxxx_'
> matrix.f:(.text+0x272): undefined reference to `vvs2_10_0_'
> matrix.o: In function `get_me_':
> matrix.f:(.text+0x6d5): undefined reference to `update_as_param_'
> matrix.o: In function `initialise_':
> matrix.f:(.text+0x73d): undefined reference to `setpara_'
> collect2: error: ld returned 1 exit status
>
> Any help is welcome. Thanks in advance.
>
> The second question would be then how to distinguish multiple subprocess directories, that all contain the same function with the same name (GET_ME), but maybe I will figure out a way to do it...
>
> Best regards,
> Thomas
>
> --
> You received this question notification because you are an answer
> contact for MadGraph5_aMC@NLO.

Can you help with this problem?

Provide an answer of your own, or ask Thomas Müller for more information if necessary.

To post a message you must log in.