更新
This commit is contained in:
parent
ffdb036ba6
commit
1613ff0bf3
@ -28,7 +28,7 @@ WORKDIR /src/Fortran
|
|||||||
RUN for file in *.f90; do gfortran -fPIC -c "$file" -o "${file%.f90}.o"; done
|
RUN for file in *.f90; do gfortran -fPIC -c "$file" -o "${file%.f90}.o"; done
|
||||||
|
|
||||||
# 链接所有 .o 文件为共享库
|
# 链接所有 .o 文件为共享库
|
||||||
RUN gfortran -shared *.o -o libfortran_function.so
|
RUN gfortran -shared *.o -o libMSJGMX.so
|
||||||
|
|
||||||
# 回到主工作目录
|
# 回到主工作目录
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
@ -45,7 +45,7 @@ RUN dotnet publish -c Release -o /app/publish
|
|||||||
|
|
||||||
# 复制编译好的 .so 文件到发布目录
|
# 复制编译好的 .so 文件到发布目录
|
||||||
RUN mkdir -p /app/publish && \
|
RUN mkdir -p /app/publish && \
|
||||||
cp /src/Fortran/libfortran_function.so /app/publish/
|
cp /src/Fortran/libMSJGMX.so /app/publish/
|
||||||
|
|
||||||
# ===== 第二阶段:运行阶段 =====
|
# ===== 第二阶段:运行阶段 =====
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||||
@ -72,7 +72,7 @@ WORKDIR /app
|
|||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
# 确保 .so 文件的权限正确
|
# 确保 .so 文件的权限正确
|
||||||
RUN chmod 755 /app/libfortran_function.so
|
RUN chmod 755 /app/libMSJGMX.so
|
||||||
|
|
||||||
# 设置 LD_LIBRARY_PATH
|
# 设置 LD_LIBRARY_PATH
|
||||||
ENV LD_LIBRARY_PATH=/app
|
ENV LD_LIBRARY_PATH=/app
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"fortranSourceFile": "D:\\\u5DE5\u4F5C2025\\\u7B97\u6CD5\u5E73\u53F0\\dll\\\u9A6C\u65AF\u4EAC\u8DDF\u6A21\u578B\\MSJGMX\\MSJGMX\\MSJGMX - \u526F\u672C.f90",
|
"fortranSourceFile": "D:\\\u5DE5\u4F5C2025\\\u7B97\u6CD5\u5E73\u53F0\\dll\\\u9A6C\u65AF\u4EAC\u8DDF\u6A21\u578B\\MSJGMX\\MSJGMX\\MSJGMX - \u526F\u672C.f90",
|
||||||
"fortranFunctionName": "fortran_function",
|
"fortranFunctionName": "MSJGMX",
|
||||||
"projectName": "FortranWebApi",
|
"projectName": "FortranWebApi",
|
||||||
"outputDirectory": "D:\\\u5DE5\u4F5C2025\\\u7B97\u6CD5\u5E73\u53F0\\\u8F93\u51FA\u5E93\\\u9A6C\u65AF\u4EAC\u8DDF\u6A21\u578B",
|
"outputDirectory": "D:\\\u5DE5\u4F5C2025\\\u7B97\u6CD5\u5E73\u53F0\\\u8F93\u51FA\u5E93\\\u9A6C\u65AF\u4EAC\u8DDF\u6A21\u578B",
|
||||||
"cmbLanguage": "",
|
"cmbLanguage": "",
|
||||||
|
@ -14,11 +14,11 @@ namespace FortranWebApi.Services
|
|||||||
// 添加当前目录到库搜索路径
|
// 添加当前目录到库搜索路径
|
||||||
NativeLibrary.SetDllImportResolver(typeof(FortranInteropService).Assembly, (name, assembly, path) =>
|
NativeLibrary.SetDllImportResolver(typeof(FortranInteropService).Assembly, (name, assembly, path) =>
|
||||||
{
|
{
|
||||||
if (name == "libfortran_function.so")
|
if (name == "libMSJGMX.so")
|
||||||
{
|
{
|
||||||
// 尝试从当前目录加载
|
// 尝试从当前目录加载
|
||||||
string currentDir = Directory.GetCurrentDirectory();
|
string currentDir = Directory.GetCurrentDirectory();
|
||||||
string libraryPath = Path.Combine(currentDir, "libfortran_function.so");
|
string libraryPath = Path.Combine(currentDir, "libMSJGMX.so");
|
||||||
|
|
||||||
if (File.Exists(libraryPath))
|
if (File.Exists(libraryPath))
|
||||||
{
|
{
|
||||||
@ -32,8 +32,8 @@ namespace FortranWebApi.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DllImport声明
|
// DllImport声明
|
||||||
[DllImport("libfortran_function.so", CallingConvention = CallingConvention.Cdecl, EntryPoint = "MSJGMX")]
|
[DllImport("libMSJGMX.so", CallingConvention = CallingConvention.Cdecl, EntryPoint = "MSJGMX")]
|
||||||
private static extern void fortran_function(
|
private static extern void MSJGMX(
|
||||||
ref int FILELEN,
|
ref int FILELEN,
|
||||||
ref int NODE,
|
ref int NODE,
|
||||||
ref int M,
|
ref int M,
|
||||||
@ -111,7 +111,7 @@ namespace FortranWebApi.Services
|
|||||||
|
|
||||||
|
|
||||||
// 调用Fortran函数
|
// 调用Fortran函数
|
||||||
fortran_function(
|
MSJGMX(
|
||||||
ref FILELEN,
|
ref FILELEN,
|
||||||
ref NODE,
|
ref NODE,
|
||||||
ref M,
|
ref M,
|
||||||
|
Loading…
Reference in New Issue
Block a user