I am currently working on writing a UMAT subroutine. In one part of the code, I need to solve a system of linear equations. Initially, I used Fortran libraries such as LAPACK and PARDISO for solving the system, but they were unable to provide accurate solutions for the equation’s roots when the matrixes are very large and sparse. In contrast, MATLAB can calculate these roots with high accuracy. To address this, I established a connection between Fortran and MATLAB to compute the roots directly within the Fortran code.
At present, the Fortran code executes without errors in Visual Studio 2019 and produces results that align with my previous MATLAB implementation. However, when I incorporate this Fortran code into the UMAT subroutine, Abaqus fails to access MATLAB libraries during the analysis phase.
To resolve this issue, I conducted extensive research and modified the abq2024.bat, win86_64.env, and custom_v6.env files to define the paths for MATLAB libraries in Abaqus (based on suggestions from online forums). The MATLAB libraries required for execution are located in the following path:
C:Program FilesMATLABMatlabVersionexternlibwin64microsoft.
I attempted to add this path both through Windows environment variables and by explicitly defining it in Abaqus’ .env files. However, the error persists.
To simplify my debugging process, I wrote a basic code in the UMAT subroutine to calculate DDSDDE for a material and call a MATLAB function at the end, passing it a value. This code successfully links with MATLAB and returns the correct output when executed in Visual Studio. However, when running the same code through Abaqus, it fails with a linking error.
Any insights or suggestions would be greatly appreciated!
A portion of the UMAT code for connecting to MATLAB and calling its function is as follows:
x=27
ep = engOpen('matlab ')
if (ep .eq. 0) then
write(6,*) 'Can''t start MATLAB engine' stop
endif
Xp =mxCreateDoubleMatrix(1,1,0)
#if MX_HAS_INTERLEAVED_COMPLEX
call mxCopyReal8ToPtr(x,mxGetDoubles(Xp),1)
#else
call mxCopyReal8ToPtr(x,mxGetPr(X),1)
#endif
status1 = engPutVariable(ep, 'Xp', Xp)
if (status1 .ne. 0) then
write(6,*) 'engPutVariable failed for x'
stop
endif
if (engEvalString(ep, 'cd /path/functionName.m;') .ne. 0) then
write(6,*) 'faield in finding path!!!'
stop
endif
if (engEvalString(ep, 'Yp=FuncForFortran(Xp);') .ne. 0) then
write(6,*) 'faield in calling function!!!'
stop
endif
Yp = engGetVariable(ep,'Yp')
#if MX_HAS_INTERLEAVED_COMPLEX call mxCopyPtrToReal8(mxGetDoubles(Yp), y,1)
#else
call mxCopyPtrToReal8(mxGetPr(Yp), y, 1)
#endif
call mxDestroyArray(Xp) call mxDestroyArray(Yp)
print *, 'y = ', y
status1 = engClose(ep)
if (status1 .ne. 0) then
write(6,*) 'engClose failed'
stop
endif
The error message encountered during Abaqus execution is as follows:
error LNK2019: unresolved external symbol engopen referenced in function umat.R
error LNK2019: unresolved external symbol mxcreatedoublematrix800 referenced in function umat.R
error LNK2019: unresolved external symbol mxgetdoubles800 referenced in function umat.R
error LNK2019: unresolved external symbol mxcopyreal8toptr800 referenced in function umat.R
error LNK2019: unresolved external symbol engputvariable referenced in function umat.R
error LNK2019: unresolved external symbol engevalstring referenced in function umat.R
error LNK2019: unresolved external symbol enggetvariable referenced in function umat.R
error LNK2019: unresolved external symbol mxcopyptrtoreal8800 referenced in function umat.R
error LNK2019: unresolved external symbol mxdestroyarray800 referenced in function umat.R
error LNK2019: unresolved external symbol engclose referenced in function umat.R
Albert2013 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.