Tag: fortran90

C可变函数与Fortran的互操作性

有没有办法声明一个C variadic函数并从Fortran调用它? 我需要调用此函数来计算用字符串标记的向量之间的一些点积。 我的想法是声明类似下面的内容,其中变量参数列表包含字符串文字。 如果变量参数列表为空,那么我将在标准标签之间进行查找并执行计算。 如果用户指定了两个标签,我会检索这两个向量并得到它们的点积: extern “C” void compute_dot_product(double * dot_product, …) { va_list args; va_start(args, NULL); char * label1 = va_arg(args, char *); if (!label1) { // Do standard label lookup and compute dot product } else { // Compute dot product between the vectors with the specified labels char * label2 = […]

从Fortran / C调用Python函数

我正在编写Fortran代码,我想使用Python库中的一些特殊函数和方法。 这是一个Python代码: from mpmath import * from scipy.optimize import * def g(A,B,t): return newton(lambda x: (x – A*polylog(1.5, B*exp(-t*x))), 0.0) 在fortran代码中,我想传递实数值A,B,t并获得g(A,B,t)的值(可能是复数)。 这也可以在C中完成。 我想提一下,将Python与其他语言混合对我来说是新鲜事。