如何在OpenModelica(Linux)中使用外部功能来调用CoolProps共享库中的功能?使用Fortran-77包装器没有奏效
中尝试了fortran wapper。
我在
double precision T,Q,D,h,s,P
character(LEN=32) Ref,Output, Name1, Name2
double precision outVal,Prop1,Prop2
integer inte
T = 400
Q = 1;
Output = "D"//CHAR(0)
Name1 = "Q"//CHAR(0)
Prop1 = Q
Name2 = "T"//CHAR(0)
Prop2 = T
Ref = "IF97::Water"//CHAR(0)
outval = 9999999
call PropsSi(Output, Name1, Prop1, Name2, Prop2, Ref, outVal)
我遵循以下步骤在Modelica中调用上述函数:
- 构建了一个静态的coolprop库:在coolprop的根目录中(也在我自己的软件包库中尝试了),我用代码构建了一个静态库:
mkdir build && cd build
mkdir gccstatic && cd gccstatic
cmake ../.. -DCOOLPROP_STATIC_LIBRARY=ON -DCOOLPROP_EXTERNC_LIBRARY=ON -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build .
代码中生成的库然后被移至Modelica软件包储备链
- 链接fortran文件到coolprop shared libary libcoolprop.a。使用了多种方法,但逻辑是相同的:
f77 main.f -L. -lCoolProp
- 在Modelica中使用的外部关键字
function propssi
extends Modelica.Icons.Function;
input Real T;
input Real Q;
output Real D;
protected
String out = "D";
String n1 = "Q";
String n2 = "T";
String ref= "IF97::Water";
external "FORTRAN 77" D = PropsSI(out, n1, Q, n2, T, ref) annotation(Library = {"testfunction"});
end propssi;
在多种变化中进行此功能,我从Modelica那里获得了汇编错误,我无法确定。
/usr/bin/ld:/usr/local/lib/lib/libcoolprop.a(coolproplib.cpp.o):符号'_ZTVN10_CXXABIV121_VMI_CLASS_CLASS_TYPE_TYPE_INFOE@CXXABI@@cxxabi_1.1.1.1.3''_ZTVN10_CXABIV1_VMING'_ZTVN10_CXABIV1_ /usr/bin/ld:/lib/x86_64-linux-gnu/libstdc++so.6:错误添加符号:命令行中缺少DSO clang:错误:Linker命令因出口代码1失败(使用-V查看调用) 制作:*** [usefortran.makefile:37:omc_main_target]错误1 汇编过程失败。用代码2退出。
任何人都可以建议访问coolprop库功能或正确调用现有fortran示例代码的替代方法
I tried out the Fortran Wapper in CoolProp Sources
The example fortran code given in the wrapper uses the function PropsSI in CoolProp.
double precision T,Q,D,h,s,P
character(LEN=32) Ref,Output, Name1, Name2
double precision outVal,Prop1,Prop2
integer inte
T = 400
Q = 1;
Output = "D"//CHAR(0)
Name1 = "Q"//CHAR(0)
Prop1 = Q
Name2 = "T"//CHAR(0)
Prop2 = T
Ref = "IF97::Water"//CHAR(0)
outval = 9999999
call PropsSi(Output, Name1, Prop1, Name2, Prop2, Ref, outVal)
I followed these steps to call the above function in Modelica:
- Built a static Coolprop library: In the root directory of the CoolProp(also tried out in my own package repo) I built a static library with the code:
mkdir build && cd build
mkdir gccstatic && cd gccstatic
cmake ../.. -DCOOLPROP_STATIC_LIBRARY=ON -DCOOLPROP_EXTERNC_LIBRARY=ON -DCMAKE_VERBOSE_MAKEFILE=ON
cmake --build .
The library generated in the code was moved then to the modelica package repo
- Linked fortran file to Coolprop shared libary libCoolProp.a. Used multiple methods but the logic was the same:
f77 main.f -L. -lCoolProp
- Used external keyword in modelica to call the function
function propssi
extends Modelica.Icons.Function;
input Real T;
input Real Q;
output Real D;
protected
String out = "D";
String n1 = "Q";
String n2 = "T";
String ref= "IF97::Water";
external "FORTRAN 77" D = PropsSI(out, n1, Q, n2, T, ref) annotation(Library = {"testfunction"});
end propssi;
After doing this in multiple variations, i am getting a compilation error from modelica which i cant figure out.
/usr/bin/ld: /usr/local/lib/libCoolProp.a(CoolPropLib.cpp.o): undefined reference to symbol '_ZTVN10__cxxabiv121__vmi_class_type_infoE@@CXXABI_1.3'
/usr/bin/ld: /lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [UseFortran.makefile:37: omc_main_target] Error 1
Compilation process failed. Exited with code 2.
Can anyone suggest alternate methods to access the coolprop library functions or to properly call the existing fortran example code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论