mehdi.yasaee
Subscriber

I think this must be a bug in Ansys 2021 since in Ansys 2019 using the command works correctly and the usermat is compiled directly within Workbench Mechanical. 

What you need to do is to use the precompile method. Basically chose a folder on your machine as your usermat folder. Then put the compiled usermat files in there. 

In windows Environmental Variables create a system Environement Variable ANS_USER_PATH to point to the usermatfolder.

Finally to compile the usermat.f files, make sure all the correct softwares(intel compiler, visual studio) and paths have been installed correctly. Then go to this folder: 

C:\Program Files\ANSYS Inc\v212\ansys\custom\user\winx64

and look for the file: ANSUSERSHARED.bat

You need to put this and usermat.f in the same folder then run the batch file. Which should compile the usermat creating a bunch .dll, .lib, .map etc. files, . 

In Ansys Mechanical, you activate the usermat by adding APDL Command in the analysis tree, /UPF, usermat

Hope this helps