diff --git a/Dockerfile b/Dockerfile index 0640db0..c87e12b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ WORKDIR /src/Fortran RUN for file in *.f90; do gfortran -fPIC -c "$file" -o "${file%.f90}.o"; done # 链接所有 .o 文件为共享库 -RUN gfortran -shared *.o -o libfortran_function.so +RUN gfortran -shared *.o -o libMSJGMX.so # 回到主工作目录 WORKDIR /src @@ -45,7 +45,7 @@ RUN dotnet publish -c Release -o /app/publish # 复制编译好的 .so 文件到发布目录 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 @@ -72,7 +72,7 @@ WORKDIR /app COPY --from=build /app/publish . # 确保 .so 文件的权限正确 -RUN chmod 755 /app/libfortran_function.so +RUN chmod 755 /app/libMSJGMX.so # 设置 LD_LIBRARY_PATH ENV LD_LIBRARY_PATH=/app diff --git a/Fortran/1.json b/Fortran/1.json index 148137d..764c1d3 100644 --- a/Fortran/1.json +++ b/Fortran/1.json @@ -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", - "fortranFunctionName": "fortran_function", + "fortranFunctionName": "MSJGMX", "projectName": "FortranWebApi", "outputDirectory": "D:\\\u5DE5\u4F5C2025\\\u7B97\u6CD5\u5E73\u53F0\\\u8F93\u51FA\u5E93\\\u9A6C\u65AF\u4EAC\u8DDF\u6A21\u578B", "cmbLanguage": "", diff --git a/Services/FortranInteropService.cs b/Services/FortranInteropService.cs index ec120fa..2b2856c 100644 --- a/Services/FortranInteropService.cs +++ b/Services/FortranInteropService.cs @@ -14,11 +14,11 @@ namespace FortranWebApi.Services // 添加当前目录到库搜索路径 NativeLibrary.SetDllImportResolver(typeof(FortranInteropService).Assembly, (name, assembly, path) => { - if (name == "libfortran_function.so") + if (name == "libMSJGMX.so") { // 尝试从当前目录加载 string currentDir = Directory.GetCurrentDirectory(); - string libraryPath = Path.Combine(currentDir, "libfortran_function.so"); + string libraryPath = Path.Combine(currentDir, "libMSJGMX.so"); if (File.Exists(libraryPath)) { @@ -32,8 +32,8 @@ namespace FortranWebApi.Services } // DllImport声明 - [DllImport("libfortran_function.so", CallingConvention = CallingConvention.Cdecl, EntryPoint = "MSJGMX")] - private static extern void fortran_function( + [DllImport("libMSJGMX.so", CallingConvention = CallingConvention.Cdecl, EntryPoint = "MSJGMX")] + private static extern void MSJGMX( ref int FILELEN, ref int NODE, ref int M, @@ -111,7 +111,7 @@ namespace FortranWebApi.Services // 调用Fortran函数 - fortran_function( + MSJGMX( ref FILELEN, ref NODE, ref M,