How to compile Umat.f to dll file

How to compile umat fortan code into a DLL file, using VS or Msy64 MinGw? I have been troubled by this problem for a long time. Where can I find a detailed tutorial.

1 Like

Need:

$pacman -S mingw-w64-x86_64-toolchain

Example (UMAT dedicated for CalculiX):
gfortran -c YOSHIDA.f

gfortran -shared -o libYOSHIDA.dll YOSHIDA.o

or:

gfortran -static-libgfortran -shared -o libxyz.dll xyz.o

*MATERIAL, NAME=@YOSHIDA
*USER MATERIAL, CONSTANTS=8
79308.361,0.3,843.902,-216.91355,213.92731,58791.656,147.73622,1803.7759
284
**Young, Pisson, Initial Yield, 
*DEPVAR 
25
*SOLID SECTION, ELSET=Eall, MATERIAL=@YOSHIDA

or:

*MATERIAL, NAME=@MARQUIS
*USER MATERIAL, CONSTANTS=11
180000,0.33,114.,92.,8.,100.,32.,60.632
572.,0.66,10.
**Young, Pisson, Initial Yield, 
*DEPVAR 
25
*SOLID SECTION, ELSET=Eall, MATERIAL=@MARQUIS

Source: https://www.researchgate.net/publication/371492360_Finite_element_implementation_of_a_certain_class_of_elasto-viscoplastic_constitutive_models

1 Like

Thanks,I will have a try.

I encountered an error while compiling the DLL file.
Error: Can’t open included file ‘ABA_PARAM.INC’
I deleted this line and successfully generated the DLL. However, there was an error when calling this DLL in prepomax. What is the reason for this error.

I delete this line

I have two ideas:

  1. A library file was copied to the wrong folder.
  2. The library has the wrong name, no lib prefix (libSDV.dll)

I will also add that some materials require additional dynamic libraries (like: lingfortran-4.dll) to check:
$ldd libEXAMPLE.dll

These two methods did not work. In fact, I have used portable mfront.dll files that you have posted in other posts, and they can run successfully in prepomax.
MFront_2.0_v2.8.rar (dropbox.com)
However, when I use my own compiled DLL files, I keep getting the error * ERROR: invalid material name ‘@ LIBSDVINI’ (unable to load library). So I suspect there was a problem compiling the DLL and would like to ask you how to correctly compile the DLL library.Attach my fortan file need to compile.https://we.tl/t-MfmG5G9EmI

May I ask for data for this material?

structure steel,E=200Gpa, μ=0.3

Try: WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free

1 Like

I used the dll you sent, and there was a different error than before, attach my prepomax file.
But your compilation method should be effective, can you give me a detailed compilation tutorial, thank you.

I know the reason.I used codeblocks mingw64 to compile fortran code before,when I use msys2mingw64 to compile fortran code, I got the same dll file that you send yesterday.

I think that you should run the executable file of the Calculix solver in the MSYS2 environment where you built the DLL file.

I was using Umat material simulation at PrepoMAX and had some confusing issues. My steps are as follows

  1. Compile the umat code sdv.f file to libsdv.dll
  2. Call the libsdv.dll in keywords. *Material, Name=@ABAQUS_sdv
    *USER MATERIAL, CONSTANTS=2
    200000,0.3
    **Young, Pisson
    *DEPVAR
    2
    **
    ** Sections ++++++++++++++++++++++++++++++++++++++++++++++++
    **
    *Solid section, Elset=Internal_Selection-1_Solid_Section-1, Material=@ABAQUS_sdv
    **
    An error is reported in the running result.

But when I changed sdv.f to umat.f, it worked successfully by following the steps above. So is it an issue with sdv.f, or is there something wrong with my setup.
Attach my whole files.

Maybe the “SDV” combination itself is prohibited (e.g. due to *EL FILE SDV), maybe try SDV1?

ccx 2.21 manual 484:
image

@liberty
In umat.f the arrays of floats are defined as real8
real
8 stress(ntens),statev(nstatv),

in sdv.f the arrays of floats are defined by defaults
DIMENSION STRESS(NTENS),STATEV(NSTATV),DDSDDE(NTENS,NTENS),
which means, that some compilers by defaults will consider these arrays as real*4

something you could try would be by replacing “DIMENSION” with “real*8”

All calls in fortran are call by reference, so the start address will always be correct, but since arrays is address by a start and then a number of offset the values will be wrong when you access an array of real8 as real4 without conversion.

1 Like

I try replacing “DIMENSION” with “real*8”,it work successfully.Thanks for your reply.

1 Like