Skip to main content

How to compile an UMAT wrote in C/C++?

Submitted by Weijie Liu on

Hi,

Does anyone know how to compiler an umat in c/c++ for abaqus under windows system?

The Umat wrote in fortran works well, but I do prefer using c/c++ to make program.

I have installed visual studio 2010 c++, intel fortran.

 

Or is it possible to use c/c++ for umat?

 

Thanks in advance.

Hi,

Few years ago I also decided to write my Abaqus user subroutines in C++. Basically, in the C++ code the function must be called for instance:

extern "C" void umat_(double *stress, double *statev, double *ddsdde, double *sse, double *spd, double *scd, double *rpl, double *ddsddt, double *drplde, double *drpldt, double *stran, double *dstran, double *time, double *dtime, double *temp, double *dtemp, double *predef, double *dpred, char *cmname, int *ndi, int *nshr, int *ntens, int *nstatv, double *props, int *nprops, double *coords, double *drot, double *pnewdt, double *celent, double *dfgrd0, double *dfgrd1, int *noel, int *npt, int *layer, int *kspt, int *kstep, int *kinc, short cmname_len)

Then, under linux, I use gcc and the following options to compile the C++ code:

gcc -c -O3 -fPIC -o usub.o usub.cpp

Before 6.13, Abaqus was configured to compile/link with icc, so one also had to modify the compiling/linking instructions in abaqus_v6.env in order to use gcc, but now it seems that gcc is the default compiler/linker. Note however that if you use shared libraries you will still have to modify the linking instructions in abaqus_v6.en. Anyway, finally you provide the compiled object to abaqus:

abaqus user=usub.o job=job

At the end, for new developments I now use fortran—that's what most people use, so it makes collaborations and code sharing much more straightforward. Anyway, I hope that helps.

Martin

Tue, 06/02/2015 - 01:05 Permalink

Thanks for sharing the solution of compiling umat under gcc. In the future, maybe I would also transfer to program in fortran, for now I prefer c/c++, just to be more familiar for me.

For win_64 os, I use the following options under ms visual studio:

cl /c /nologo /W0 /MD /TP /EHsc /DNDEBUG /DWIN32 /DTP_IP /D_CONSOLE /DNTI /DFLT_LIC /DOL_DOC /D__LIB__ /DHKS_NT /DABQ_NTI_NET /DFAR= /D_WINDOWS /DABQ_WIN86_64 /O1 /I%I

Wed, 06/03/2015 - 13:56 Permalink