Is it possible to use FTorch in ABAQUS Fortran subroutine? #471
-
|
I want to utilize the neural network (Pytorch) in ABAQUS Fortran subroutine, is it possible? Do I need any extra operation? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 7 replies
-
|
Hi @Fengyixin-research we are not ABAQUS users, so we'll need a bit more information to try and help you with this. How do you compile ABAQUS code? FTorch can be linked to as a Fortran library similarly to any other external library (see details below). A quick search suggests it is possible to link to shared libraries from ABAQUS, but you may also need to compile your code as a shared library: https://abaqus-docs.mit.edu/2017/English/SIMACAEEXCRefMap/simaexc-c-makeproc.htm I also found this article detailing how to use the external LAPACK library in ABAQUS Fortran subroutines through linking: https://www.bibekanandadatta.com/blog/2024/lapack-Intel-Fortran-Abaqus/ Do you have anyone who has expertise in ABAQUS or can you raise with them how to link to external libraries when building? Linking to FTorch as an external library: FTorch can be linked to as a Fortran library similarly to any other external library. DetailsTo build a project with make or similar you need to include the FTorch's header (.h) and module (.mod) files and link the executable to the Ftorch library (e.g., .so, .dll, .dylib depending on your system) when compiling. To compile with make use the following compiler flag for any files that use ftorch to include the module and header files: This is often done by appending to an FCFLAGS compiler flags variable or similar: When compiling the final executable add the following linker flag: This is often done by appending to an LDFLAGS linker flags variable or similar: If you have pkg-config installed, you can easily query the compiler and linker flags of FTorch rather than manually specifying them as was shown above. FTorch provides a standard pkg-config file in both the directory in which FTorch was built (e.g., </path/to/FTorch>/build) as well as the library directory in which it was installed (e.g., </path/to/FTorch/install/location>/lib/pkgconfig). For example, the following commands are equivalent to adding the manually specified flags: You can simplify these commands by adding FTorch to the PKG_CONFIG_PATH environment variable: You may also need to add the location of the dynamic library .so files to your LD_LIBRARY_PATH environment variable unless installing in a default location: |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your quick reply. |
Beta Was this translation helpful? Give feedback.
-
|
Great. I shared the second link not suggesting you use LAPACK, but because it discusses linking an external library into ABAQUS Fortran subroutines. Direct linking for complex architectures is definitely the sensible approach in our opinion. Good luck. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @Fengyixin-research I have converted this to a discussion as it pertains to use-cases and integration rather than an issue with FTorch itself. Please do feed back any progress you have as there may well be others that want to integrate FTorch to ABAQUS and can build off your experiences. Thanks. |
Beta Was this translation helpful? Give feedback.
-
|
Hey @Fengyixin-research the fact FTorch is working standalone is a good sign and starting point!! Regarding ABAQUS, it looks like there is a linking error. Shortened paths may/may not be causing issues. with Another thing is order. instead of though this may require some further iteration. |
Beta Was this translation helpful? Give feedback.
-
|
Updated. @jatkinson1000 @TomMelt . And the corresponding result is that: To sum up:
Then, you could enjoy using the FTorch with ABAQUS Fortran subroutine. |
Beta Was this translation helpful? Give feedback.



Updated. @jatkinson1000 @TomMelt .
Fortunately, I have successfully solved the above problem with the help of Deepseek and Gemini.
The main question is that ABAQUS could not recognize the upperclass word in the function name, therfore, we need to manually add the /names:lowercase to the build option for FTorch.
For example, we could use dumpbin to extract the function name in FTorch.lib:
dumpbin /exports "D:\FTorch_install\lib\ftorch.lib" > ftorch_exports.txtIf we use the default build option for FTorch, the corresponding function names are:
However, if we add the the /names:lowercase to the build option for FTorch:
Obviously, the latter names could be found by ABAQUS.
Then, the code w…