Abaqusdebug
Abaqusdebug
Abaqusdebug
Abaqus subroutines
Introduction Attaching to an Abaqus subroutine abaqus_v6.env User subroutine
1 1 2 2
In the following sequence of steps, the procedure for attaching the Intel debugger to an Abaqus user-subroutine is described. 1. A customised Abaqus environment file (abaqus_v6.env) needs to be located in the same directory in which the problem is run. This file sets the Abaqus compilation environment so that the user subroutine can be compiled properly for debugging. The file should contain the following, paying particular attention to the indentation of the lines in the file:
import os def prepDebug(var,dbgOption): import types varOptions = globals().get(var) if varOptions: # Add debug option if type(varOptions) == types.StringType: varOptions = varOptions.split() varOptions.insert(6,dbgOption) # Remove compiler performance options if var[:5] == 'comp': optOption = ['/O','O','xO','fast','depend','vpara'] for option in varOptions [:] for opt in optOption: if len(option) >= len(opt) and option[:len(opt)] == opt: varOptions.remove(option) return varOptions if os.name == 'nt': compile_fortran = prepDebug('compile fortran', '/debug') compile_cpp = prepDebug('compile cpp','/Z7') link_sl = prepDebug('link sl','/DEBUG') link_exe = prepDebug('link exe','/DEBUG') else: compile_fortran = prepDebug('compile fortran','g') compile_cpp = prepDebug ('compile cpp','g') del prepDebug
2. Login to Stokes or Stoney on two separate terminals. One of these terminals will be used to start the Abaqus job, the other will be used to run the debugger - this second terminal should have X-forwarding enabled (e.g. login with ssh -X stokes.ichec.ie). 3. The procedure described here requires that the user subroutine be modified temporarily in order topause the program so that the debugger can be attached to the running process. One way to achieve this is to cause the code to enter an infinite loop, e.g.
Subroutine umat (stressu,statev,ddsddeu,sse,spd, + scd,rpl,ddsddt,drplde,drpldt,stranu,dstranu, + time,dtime,temp,dtemp,predef,dpred,cmname,ndiu, + nshru,ntensu,nstatv,props,nprops,coords,drot, + pnewdt,celent,dfgrd0,dfgrd1,noel,npt,layer,kspt, + kstep,kinc) Include 'aba_param.inc' ... Integer myTmpVar ! ! ! The following will create an infinite loop, giving sufficient time to attach the debugger to the running process once the program is running
Figure 1. Screenshots of the Intel debugger being used to debug an Abaqus subroutine
4. In the terminal with X-forwarding enabled, start the debugger. In this example the Intel debugger is used:
6. At this point go to the debugger, select File->Attach to Process and select the entry containing standard.exe, as shown in Figure 1(a). At this point the source of the user subroutine should appear, with the current execution position (denoted by the yellow arrow) within the loop code inserted previously. In order to break out of this loop its firstly necessary to step forward though the code until the execution position is at the line containing the Do While statement. Then the value of myTmpVar needs to be changed to 999. As shown in Figure 1(b), to set this value, go to View->Locals, scroll down to myTmpVar and right- click on it and select set value. Stepping forward should cause the code to break out of the loop. 7. As shown in Figure 2(a), at this point the user subroutine should be under the control of the debugger. The code can then be stepped line-by-line, values of variables can be inspected etc. 8. To finish the debugging session, simply close the debugger. Note that you must also ensure that you terminate the Abaqus run in the terminal in which it was started using e.g. Ctrl+C or the kill command
(a) Stepping the source line to exit the temporary infinite loop
(b) The debugger can now be used to debug the code as usual
Figure 2. Screenshots of the Intel debugger being used to debug an Abaqus subroutine