This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
2013:groups:sm:blha:api [2013/06/13 12:03] johann_felix.graf_von_sodenfraunhofen created (C/C++) |
2013:groups:sm:blha:api [2013/08/14 11:37] (current) johann_felix.graf_von_sodenfraunhofen OLP_Polvec added, C++ reference version adapted. |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Suggestion for implementation details of the BLHA2 accord ====== | ||
| - | C-compatible interface (pointer version) (olp.h) | ||
| - | <code c++> | + | ==== C/C++ interface (pointer version) (olp.h) ==== |
| + | |||
| + | <code c++ olp.h> | ||
| #ifndef __OLP_H__ | #ifndef __OLP_H__ | ||
| #define __OLP_H__ | #define __OLP_H__ | ||
| Line 11: | Line 13: | ||
| void OLP_Start(char* fname, int* ierr); | void OLP_Start(char* fname, int* ierr); | ||
| - | void OLP_SetParameter(char* line, double* real_part, double *cmplx_part, int* status); | + | void OLP_SetParameter(char* line, double* real_part, double* cmplx_part, int* status); |
| - | void OLP_EvalSubProcess2(int l, double* mom, double mu, double* r, int* status); | + | void OLP_EvalSubProcess2(int* l, double* mom, double* mu, double* r, double* acc); |
| + | void OLP_Info(char olp_name[15], char olp_version[15], char cite_message[255]); | ||
| + | void OLP_Polvec(double* p, double* q, double* eps); // optional | ||
| #ifdef __cplusplus | #ifdef __cplusplus | ||
| Line 20: | Line 24: | ||
| </code> | </code> | ||
| - | C++-only interface (reference version) | + | ==== C++ interface (reference version) ==== |
| - | <code c++> | + | <code c++ olp.h> |
| #ifndef __OLP_H__ | #ifndef __OLP_H__ | ||
| #define __OLP_H__ | #define __OLP_H__ | ||
| Line 30: | Line 34: | ||
| void OLP_Start(char* fname, int &ierr); | void OLP_Start(char* fname, int &ierr); | ||
| void OLP_SetParameter(char* line, double& real_part, double& cmplx_part, int& status); | void OLP_SetParameter(char* line, double& real_part, double& cmplx_part, int& status); | ||
| - | void OLP_EvalSubProcess2(int l, double& mom, double& mu, double& r, int& status); | + | void OLP_EvalSubProcess2(int* l, double mom[], double* mu, double r[], double &acc); |
| + | void OLP_Info(char olp_name[15], char olp_version[15], char cite_message[255]); | ||
| + | void OLP_Polvec(double p[], double q[], double eps[]); // optional | ||
| } | } | ||
| Line 37: | Line 43: | ||
| </code> | </code> | ||
| + | |||
| + | ==== Fortran 2003 (or later) module for binding with C/C++: ==== | ||
| + | |||
| + | <code fortran olp.f90> | ||
| + | module olp | ||
| + | implicit none | ||
| + | public :: OLP_Start, OLP_EvalSubProcess2, OLP_SetParameter | ||
| + | public :: OLP_Info, OLP_Polvec | ||
| + | |||
| + | contains | ||
| + | |||
| + | subroutine OLP_Start(contract_file_name,ierr) & | ||
| + | & bind(C,name="OLP_Start") | ||
| + | use, intrinsic :: iso_c_binding | ||
| + | implicit none | ||
| + | character(kind=c_char,len=1), intent(in) :: contract_file_name | ||
| + | integer(kind=c_int), intent(out) :: ierr | ||
| + | |||
| + | interface | ||
| + | function strlen(s) bind(C,name='strlen') | ||
| + | use, intrinsic :: iso_c_binding | ||
| + | implicit none | ||
| + | character(kind=c_char,len=1), intent(in) :: s | ||
| + | integer(kind=c_int) :: strlen | ||
| + | end function strlen | ||
| + | end interface | ||
| + | | ||
| + | | ||
| + | ! ... | ||
| + | ! open( ... , file=contract_file_name(1:strlen(l)), ...) | ||
| + | ! ... | ||
| + | |||
| + | end subroutine | ||
| + | |||
| + | |||
| + | subroutine OLP_SetParameter(variable_name, real_part, complex_part, success) & | ||
| + | & bind(C,name="OLP_SetParameter") | ||
| + | use, intrinsic :: iso_c_binding | ||
| + | implicit none | ||
| + | character(kind=c_char,len=1), intent(in) :: variable_name | ||
| + | real(kind=c_double), intent(in) :: real_part, complex_part | ||
| + | integer(kind=c_int), intent(out) :: success | ||
| + | |||
| + | !.... | ||
| + | end subroutine | ||
| + | |||
| + | subroutine OLP_EvalSubProcess2(label, momenta, mu, res, acc) & | ||
| + | & bind(C,name="OLP_EvalSubProcess2") | ||
| + | use, intrinsic :: iso_c_binding | ||
| + | implicit none | ||
| + | integer(kind=c_int), intent(in) :: label | ||
| + | real(kind=c_double), intent(in) :: mu | ||
| + | real(kind=c_double), dimension(50), intent(in) :: momenta | ||
| + | real(kind=c_double), dimension(60), intent(out) :: res | ||
| + | real(kind=c_double), dimension(1), intent(out) :: acc | ||
| + | |||
| + | !.... | ||
| + | end subroutine OLP_EvalSubProcess2 | ||
| + | |||
| + | subroutine OLP_Info(olp_name, olp_version, cite_message) & | ||
| + | & bind(C,name="OLP_Info") | ||
| + | use, intrinsic :: iso_c_binding | ||
| + | implicit none | ||
| + | character(kind=c_char,len=1), intent(out) :: olp_name | ||
| + | character(kind=c_char,len=1), intent(out) :: olp_version | ||
| + | character(kind=c_char,len=1), intent(out) :: cite_message | ||
| + | |||
| + | ! ... | ||
| + | |||
| + | end subroutine OLP_Info | ||
| + | |||
| + | subroutine OLP_Polvec(p, q, eps) & | ||
| + | & bind(C,name="OLP_PolVec") | ||
| + | use, intrinsic :: iso_c_binding | ||
| + | implicit none | ||
| + | real(ki), dimension(4), intent(in) :: p,q | ||
| + | real(ki), dimension(8), intent(out) :: eps | ||
| + | |||
| + | !.... optional | ||
| + | | ||
| + | end subroutine OLP_Polvec | ||
| + | |||
| + | end module olp | ||
| + | </code> | ||
| + | |||