User login

You are here

Debugging standard user subroutines of ABAQUS

Hi,

I managed to find a way to debug UMAT step by step. I tested it on ABAQUS 6.9 using intel fortran 11.0 which is integrated with Visual Studio 2005 or 2008 running on Win 7/x64. The process is the same for other versions and other user subroutines (The same process should also work in linux, but with different debugger).

The whole idea is to attach your "ABAQUS standard" process to a debugger. To do so, you must compile and link your UMAT code in debug mode.
So you should compile your user-subroutine file as if you want to create an exe console application and do not pay attention to the last linker error, saying that your file does not contain the main subroutine. Here, it is much easier to use the pre-compiled obj file instead of the original fortran file while running an abaqus job (because the debug-information file is created in a fixed location and not in the temp folder that abaqus creates each time at different folders). 

To create the object file in debug mode, I use a command like this (you might need to modify it a bit based on the paths of your VS):

ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"compiled\modules\\" /object:"compiled\\" /traceback /check:bounds /libs:static /threads /dbglibs /Qvc8 /Qlocation,link,"c:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin\amd64" "Umat-Test.f90"

In my foldering, I say the compiler to create module files in "compiled\modules" and the object files in this folder: "compiled". You might have your owns. By running this command, the linker also creates the file needed for debug, which is (in MS-VS) a file with pdb extension.

After compiling, you can find the file "Umat-Test.pdb" in the same folder as that of your fortran file.

I should say that Abaqus links each created obj file to the file "standardU.dll" which is re-created after submitting each job. This file is the main output of the linker command in abaqus_v6.env file, which is loaded by Abaqus. So you must modify the linker command to create it in debug mode as well. To do so, I just copied link_sl and link_exe from the main abaqus_v6.env file and put it in my user-level abaqus_v6.env file. Then I added the switch /debug:full to the origial command. Your commands should look like this:

link_sl='cmd /c "LINK /nologo /debug:full /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:MSVCRT.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /dll /def:%E /out:%U %F %A %B oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib && mt /manifest %U.manifest /outputresource:%U;2 && del %U.manifest"'

link_exe='cmd /c "LINK /nologo /debug:full /INCREMENTAL:NO /subsystem:console /machine:AMD64 /NODEFAULTLIB:LIBC.LIB /NODEFAULTLIB:LIBCMT.LIB /DEFAULTLIB:OLDNAMES.LIB /DEFAULTLIB:LIBIFCOREMD.LIB /DEFAULTLIB:LIBIFPORTMD.LIB /DEFAULTLIB:LIBMMD.LIB /DEFAULTLIB:MSVCRT.LIB /DEFAULTLIB:kernel32.lib /DEFAULTLIB:user32.lib /DEFAULTLIB:advapi32.lib /FIXED:NO /LARGEADDRESSAWARE /out:%J %F %M %L %B %O oldnames.lib user32.lib ws2_32.lib netapi32.lib advapi32.lib && mt /manifest %J.manifest /outputresource:%J;1 && del %J.manifest"'

Then the settings are ready. Go to VS, create a fortarn project and add you fortran source code file to the project. DO REMEMBER that your compiled file MUST match with your code while debugging.

Then go to Tools->Options->Debugging->Symbols, add the path of your pdb file to "Symbol file (.pdb) location" section.

These procedures are needed to be done just once.

Now submit your job, and wait for a while to see Standard.exe in the list of your processes (use the task manager of win for example) then switch to VS and go to Debug-> Attach to Process.
Select standard.exe from the list of the running processes. If you did all the steps flawlessly, VS would successfully load the debug symbols from the pdb file and you must be able to debug your code line by line, as I did.

Here are some useful hints: Put a one-time delaying command (like sleep) to buy some time to switch to VS environment and attaching the debugger to the process (standard.exe). You can put your break points after that line. If you have difficulties going through these steps, you may want to drop me an email.

 Here is a screenshot of what it looks like after attaching the process to the debugger:

Screenshot 

Explanation: In my code above, InitializationDone is a common variable which I use once to catch the process after 10 secs sleep. 

Here is a simple sample you can try (Umat-Test.f90):
 

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'
  integer::nTestNum

  nTestNum = 0

  ! wait for 10 seconds
  CALL sleep(10)
 
  ! put your break point here:
  nTestNum = nTestNum + 1

! you can use add watch to inspect the values. Enjoy!

  RETURN
END SUBROUTINE UMAT

-- 

Cheers,

Hamidreza,

Comments

Could you uploal a full edition,we are the newer to subrouting debug.

Hi, I am trying to follow the steps that you described but I am having some difficulties. First one: I am not seeing any .pdb extension file in my fortran file. second: I did not find any standard.exe in my debug>attach to process section. Can you please advice on this.

 Thanks, 

 Imran

Hi, this is for windows systems, but for linux how could we do?

 

Thanks.

Long

Mr Hamid.Mirkhani can u tell me how to get standard.exe compiler in visual studio as it is missing in the 'debug>>attach to process' ??

Subscribe to Comments for "Debugging standard user subroutines of ABAQUS"

More comments

Syndicate

Subscribe to Syndicate