文章标题

CADEC
Ask for help, report errors and share your experience with www.cadec-online.com

Skip to content

Search…
Search
Advanced search
Board index ‹ Abaqus
Select your language:
Change font size
Print view
FAQRegisterLogin
How to use intel mkl inside Abaqus user subroutine
Post a reply

Search this topic…
Search
5 posts • Page 1 of 1
How to use intel mkl inside Abaqus user subroutine
Postby Fer » Wed Sep 26, 2012 12:51 pm

I wanted to take advantage of the intel implementation of BLAS and LAPACK that is called Intel® Math Kernel Library (Intel® MKL) in a user subroutine.

This is how I managed to do it:

Just called the subroutine that you need in your code, for example:

CODE: SELECT ALL
subroutine InvertMatrix(A, n, invA)
implicit none

real(8), intent(in) :: A(n,n)
integer, intent(in) :: n
real(8), intent(out):: invA(n,n)

integer ipiv(n), info

real(8) s_work(1)
integer lwork
real(8), pointer:: work(:)

character(1000) ErrorMessage

invA = A

call dgetrf(n, n, invA, n, ipiv, info)

if (info /= 0) then
    write(ErrorMessage,*) 'InvertMatrix, dgetrf failed, info=', info
    call Error(ErrorMessage)
endif

!If lwork = -1, then a workspace query is assumed; the routine only
!calculates the optimal size of the work array, returns this value as the
!first entry of the work array, and no error message related to lwork is
!issued by xerbla.   
lwork = -1
call dgetri(n, invA, n, ipiv, s_work, lwork, info)

lwork = s_work(1)

allocate(work(lwork))

call dgetri(n, invA, n, ipiv, work, lwork, info)

deallocate(work)

if (info /= 0) then
    write(ErrorMessage,*) 'InvertMatrix, dgetri failed, info=', info
    call Error(ErrorMessage)
endif

endsubroutine
subroutine Error(Message)
implicit none

character(*), intent(in):: Message

write(7,*) trim(Message)

call xit()

endsubroutine
subroutine UMAT(STRESS,STATEV,DDSDDE,SSE,SPD,SCD,&
RPL,DDSDDT,DRPLDE,DRPLDT,&
STRAN,DSTRAN,TIME,DTIME,TEMP,DTEMP,PREDEF,DPRED,CMNAME,&
NDI,NSHR,NTENS,NSTATV,PROPS,NPROPS,COORDS,DROT,PNEWDT,&
CELENT,DFGRD0,DFGRD1,NOEL,NPT,LAYER,KSPT,KSTEP,KINC)

include ‘ABA_PARAM.INC’

character*80 CMNAME

dimension STRESS(NTENS),STATEV(NSTATV),&
DDSDDE(NTENS,NTENS),DDSDDT(NTENS),DRPLDE(NTENS),&
STRAN(NTENS),DSTRAN(NTENS),TIME(2),PREDEF(1),DPRED(1),&
PROPS(NPROPS),COORDS(3),DROT(3,3),DFGRD0(3,3),DFGRD1(3,3), &
Compliance(3,3)

E1 = PROPS(1)
E2 = PROPS(2)
PR12 = PROPS(3)
G12 = PROPS(4)

Compliance(1,:) = (/ 1/E1, -PR12/E1, 0.d0 /)
Compliance(2,:) = (/ -PR12/E1, 1/E2, 0.d0 /)
Compliance(3,:) = (/ 0.d0, 0.d0, 1/G12 /)

    call InvertMatrix(Compliance, 3, DDSDDE)

STRESS = matmul(DDSDDE, STRAN+DSTRAN)

endsubroutine

Of course the code above does not make any sense, but it is just to illustrate how can we use dgetri and dgetrf inside an Abaqus user subroutine.

Once we have that we call abaqus job=Job user=umat

and we get the following error in the Job.log file:

CODE: SELECT ALL
Abaqus Error: Problem during compilation - ifort.exe not found in PATH.
Abaqus/Analysis exited with errors

That means we forgot to set up “the compilation environment”

So we do a
call “C:\Program Files (x86)\Intel\Compiler\11.1\048\bin\ifortvars.bat” intel64
and then again
call abaqus job=Job user=umat

New errors:

CODE: SELECT ALL
Abaqus JOB Job
Abaqus 6.10-2
Begin Compiling Abaqus/Standard User Subroutines
9/26/2012 1:41:11 PM
End Compiling Abaqus/Standard User Subroutines
9/26/2012 1:41:11 PM
Begin Linking Abaqus/Standard User Subroutines
9/26/2012 1:41:11 PM
Creating library standardU.lib and object standardU.exp
Ugens.obj : error LNK2019: unresolved external symbol DGETRF referenced in function INVERTMATRIX
Ugens.obj : error LNK2019: unresolved external symbol DGETRI referenced in function INVERTMATRIX
standardU.dll : fatal error LNK1120: 2 unresolved externals
Abaqus Error: Problem during linking - Abaqus/Standard User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Abaqus/Analysis exited with errors

How do we solve this? Easy, just modify the environment file (C:\SIMULIA\Abaqus\6.10-2\site\abaqus_v6.env), add this to the compile_fortran variable:

CODE: SELECT ALL
/Qmkl:sequential

or any of the options: http://software.intel.com/en-us/article … l-options/

Run again and…

CODE: SELECT ALL
Abaqus JOB Job
Abaqus 6.10-2
Begin Compiling Abaqus/Standard User Subroutines
9/26/2012 1:49:20 PM
End Compiling Abaqus/Standard User Subroutines
9/26/2012 1:49:20 PM
Begin Linking Abaqus/Standard User Subroutines
9/26/2012 1:49:20 PM
LINK : fatal error LNK1181: cannot open input file ‘oldnames.lib’
Abaqus Error: Problem during linking - Abaqus/Standard User Subroutines.
This error may be due to a mismatch in the Abaqus user subroutine arguments.
These arguments sometimes change from release to release, so user subroutines
used with a previous release of Abaqus may need to be adjusted.
Abaqus/Analysis exited with errors

or something like mkl fatal error cannot load xxx, and other variations.

To solve that, the only thing you have to do is modify the LIB environment variable to include the mkl directory:

C:\Program Files (x86)\Intel\Compiler\11.1\048\mkl\em64t

and then the umat will work
Fer
Site Admin

Posts: 76
Joined: Mon Apr 30, 2012 1:58 pm
Top
Re: How to use intel mkl inside Abaqus user subroutine
Postby ebarbero » Wed Mar 27, 2013 4:32 am

I want to use /Qmkl:parallel.

I tested my UMAT (actually UGENS) outside Abaqus, in VS 2008, using Fortran Intel 11.1.048, which is what Abaqus uses, with /Qmkl=parallel. No problem. Runs great with numCpus=cpu_count(), which is 4 in my computer.

Then I changed the abaqus_v6.env to /Qmkl:parallel. I compile with abaqus make library=ugens, producing ugens-std.obj, then run with abaqus job=Job-1 user=ugens-std.obj
No luck. I get “***ERROR: Analysis is being terminated from a user subroutine” in the Job-1.msg file

So, I try to run with abaqus job=Job-1 user=ugens.for
No luck. I get “The executable C:\SIMULIA\Abaqus\6.10-1\exec\standard.exe aborted with system error code 29539.”

What can I do? I need “parallel”
User avatar
ebarbero

Posts: 98
Joined: Mon May 21, 2012 11:24 am
Top
Re: How to use intel mkl inside Abaqus user subroutine
Postby Fer » Wed Mar 27, 2013 6:43 am

ebarbero wrote:
I want to use /Qmkl:parallel.

I tested my UMAT (actually UGENS) outside Abaqus, in VS 2008, using Fortran Intel 11.1.048, which is what Abaqus uses, with /Qmkl=parallel. No problem. Runs great with numCpus=cpu_count(), which is 4 in my computer.

Then I changed the abaqus_v6.env to /Qmkl:parallel. I compile with abaqus make library=ugens, producing ugens-std.obj, then run with abaqus job=Job-1 user=ugens-std.obj
No luck. I get “***ERROR: Analysis is being terminated from a user subroutine” in the Job-1.msg file

So, I try to run with abaqus job=Job-1 user=ugens.for
No luck. I get “The executable C:\SIMULIA\Abaqus\6.10-1\exec\standard.exe aborted with system error code 29539.”

What can I do? I need “parallel”

numCpus=cpu_count() is a Python command for running jobs using the Abaqus CAE API, so I dont think you are using that when testing the ugens using Visual Studio.

Did you tried running the job from the source code instead of the obj? did it work?

Abaqus 6.12 links to mkl automatically so you dont need this tutorial anymore, try upgrading to 6.12 and see if you can run it.

Failing all that, you can post your question in the Abaqus support: https://iam.3ds.com/

Unfortunately, that site is hidden for google so the only way to search is using their custom engine, that needless to say, is not that good as google.

I opened a question some time ago regarding mkl, you can read it here:
https://swym.3ds.com/#community:73/iquestions:12312

The community where you want to post is called SIMULIA Learning: https://swym.3ds.com/#community:73

If you find the solution, ask for permission and copy it here for the world :D
Fer
Site Admin

Posts: 76
Joined: Mon Apr 30, 2012 1:58 pm
Top
Re: How to use intel mkl inside Abaqus user subroutine
Postby ebarbero » Wed Mar 27, 2013 3:04 pm

Q: Did you tried running the job from the source code instead of the obj? did it work?
A => yes, I run the job with the source, and it does not work either. It gives “The executable C:\SIMULIA\Abaqus\6.10-1\exec\standard.exe aborted with system error code 29539.”
User avatar
ebarbero

Posts: 98
Joined: Mon May 21, 2012 11:24 am
Top
Re: How to use intel mkl inside Abaqus user subroutine
Postby Fer » Wed Mar 27, 2013 6:13 pm

ebarbero wrote:
Q: Did you tried running the job from the source code instead of the obj? did it work?
A => yes, I run the job with the source, and it does not work either. It gives “The executable C:\SIMULIA\Abaqus\6.10-1\exec\standard.exe aborted with system error code 29539.”

This is a tough one, what I did at the time was to use only one processor.
Try contacting the Simulia support guys. Oh wait!!! I dont have that excuse anymore!
Ok, the way I see it, you have several options:
Use only one processor. This is not that terrible, or is it? Why?
Upgrade to 6.12 (this will fix the problem)
Post the problem in swym
Contact Abaqus support, they know the answer (I work for SLM, different thing :D )
Dont use mkl, use a stand alone library
Use Excel, Excel is always an alternative
Fer
Site Admin

Posts: 76
Joined: Mon Apr 30, 2012 1:58 pm
Top
Display posts from previous: Sort by Go
Post a reply
5 posts • Page 1 of 1
Return to Abaqus

Jump to: Go
WHO IS ONLINE
Users browsing this forum: No registered users and 3 guests

Board indexThe team • Delete all board cookies • All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group

你可能感兴趣的:(intel-MKL)