Abaqus has many built-in options but sometimes these do not suffice. You may want to include a material model that is not implemented, have a complex type of loading that is not available by default or even define your own element. Abaqus' user subroutine capabilities allow you to do this. User subroutines are written in Fortran and in order to use them, you need a Fortran compiler. In this blog I'll show how to install a freely available fortran compiler and link it to Abaqus. Thanks to Oliver Lundqvist working for Sweco in Finland for making me aware of this option, and to oaeres on https://community.intel.com/t5/Registration-Download-Licensing/How-to-link-ABAQUS-with-Intel-One-API-toolkits-to-run-FORTRAN/td-p/1244548/page/2 who provided this solution (especially the last workaround).
I'll assume Abaqus is already running on your system. This was tested with Abaqus 2020hf1 and Abaqus 2019.
Visual Studio including desktop development with C++
First install Visual Studio, if this is not available yet. I used Visual Studio Community 2019. Download and run the installer. Apart from the default also select the 'desktop development with C++' workload.
In case Visual Studio is installed but the mentioned workload isn't, you can use the Visual Studio Installer to add this specific component.
Intel oneAPI Base Toolkit
After Visual Studio is installed, download Intel oneAPI Base Toolkit. Make sure you are not logged in to this website when trying to access the download, and click 'maybe next time. Please take me to my download' rather than 'Sign in or sign up'. (For more info on where this remark comes from, click here). Install the software; I used the recommended installation. If you do not have the 'desktop development with C++ workload' the installer will tell you so. Select the version of Visual Studio that is installed (2019 in this case) and start the installation.This takes some time. I ended with this screen:
I closed this and confirmed that I was sure I wanted to quit the installer.
Intel oneAPI HPC Toolkit
The next step is to download and install oneAPI HPC Toolkit. This process is similar to the previous step, but should be faster since it only installs an add-on.
Now that the software is installed, Abaqus still needs to be able to find the compiler. To do this, first locate the file 'vars.bat'. In my case it was located here:
C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat
Now you need to ensure that the following command is run before starting up Abaqus:
"C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat" intel64 vs2019
Here the first part of the command is the location of the vars.bat file, and the last part (vs2019) refers to the Visual Studio version (in my case Visual Studio 2019).
You can run this command manually in the command line before you run Abaqus, but it is easier to do it automatically. If you often use a (desktop) shortcut you can change the shortcut to include this:
I often type the Abaqus command in the command window. In that case abaqus.bat is called (located here: C:\SIMULIA\Commands by default). To be able to use the fortran compiler, I added a line of code to this file:
(The command as mentioned previously, but including @call )
Modification of usersubroutines
Now we are almost there. Due to a bug, this will not work. The workaround (as pointed out by oares) is to include an additional line as first line of your fortran file:
!DEC$ ATTRIBUTES ALIAS:"user"::USER
So for instance, if running a VUMAT, you would add this line: !DEC$ ATTRIBUTES ALIAS:"vumat"::VUMAT
That should do the trick.
Checking whether this works properly
Usually the best way to check whether everything is set up correctly, is to run the Abaqus verify command from the command line, e.g.:
abaqus verify -user_exp
to verify Abaqus/Explicit with user subroutines.
When you do this, Abaqus will fetch the relevant files including the fortran file. This does not include the above statement and will therefore give an error. You do have the input (xpl_user.inp) and fortran (xpl_user.for) file in a 'verify' folder then. Manually add !DEC$ ATTRIBUTES ALIAS:"vumat"::VUMAT as first line in the fetched fortran file and save it. In the command window, go inside the verify folder (cd verify). You can now run the job from the command line using:
abaqus job=xpl_user user=xpl_user.for
Of course you can also test with your own example problem.