You are here
mix Fortran and C++ code in Abaqus user subroutines
Tue, 2023-01-10 13:15 - carlygao
Hi,
I need to make an Abaqus user subrouine mixing Fortran and C++ in Abaqus user subroutines. To call C++ functions from Fortran, I will use the appropriate Fortran intrinsic functions or ISO_C_BINDING module to interface with the C++ code. However, I have no clue about how to compile it. I usually work on the Fortran subrouines only. Now I have two languages. Is there anyone how to link both C++ and Fortran compiler to Abaqus and how to compile them?
Is there any a simple example, or instruction video? Thanks.
Carly
»
- carlygao's blog
- Log in or register to post comments
- 891 reads

Comments
There might be easier ways
There might be easier ways than what I suggest, I am no expert.
The issue in doing what you suggested is that Abaqus only takes in one user subroutine file. Even when people have multiple files, they will include them in one file which is then specified to Abaqus for compiling. This usually works fine in Fortran. Now, if you have C++ and Fortran files, you can't include one in another because of different programming languages.
I can then only think of manually compiling the files (with different compilers obviously) and combining the object files into one. The final object file can then be specified to Abaqus for linking. Check this simple example where I do this.
https://github.com/apedgaon/abaqus_utils/tree/main/mixed_fort_cpp
This method is already very messy not to mention that you will need an appropriate interface for calling C++ functions.