If you are like me, you'd prefer to debug subroutines the way Matlab allows you to debug scripts. It took me a while to figure out how to get Visual Studio to allow me to debug my subroutine. So, here's how it worked for me (Vista/XP, 64-bit, VS 2008, Fortran 10/11, ..):
1. Prepare the Abaqus environment
a. Go to C:\Abaqus\6.9-1\site and open abaqus_v6.env with a text editor
b. Scroll down
c. In "compile_fortran", add ‘/Od’ and ‘/Zi’ parameters to enable Intel Fortran compiler to add debug symbolic information into .obj file
• compile_fortran=['ifort', '/c', '/Gm', '/recursive', '/nologo', '/heap-arrays:1', '/include:%I', '/Od', '/Zi']
d. In "link_sl", add /DEBUG to let Visual C++ .NET linker to link the files with the symbolic information in .obj file
• link_sl='cmd /c "LINK /DEBUG /nologo /INCREMENTAL:NO /subsystem:console /machine:X86
e. In "link_exe", add /DEBUG to let Visual C++ .NET linker to debug the files
• link_exe='cmd /c "LINK /DEBUG /nologo /INCREMENTAL:NO /subsystem:console
2. Prepare your job file (*.inp) and the subroutine file (*.for)
3. Open your FORTRAN code in Microsoft Visual Studio.
4. Insert a READ(*,*) VARIABLE in your subroutine source code file right after the "DIMENSION" definition where "VARIABLE" is the arbitrary name of the variable. Also, insert a breakpoint at a function/variable of interest like at READ(*,*), VARIABLE or watch a variable of interest (using Debug -> QuickWatch). You can add/remove breakpoints by pressing F9.
5. Launch ABAQUS with the command "ABAQUS job=JOB_NAME user=SUBROUTINE_NAME interactive
a. ABAQUS command prompt will wait when it reaches "READ(*,*) defined in step 4.
6. Watch the command prompt window. As soon as the command prompt says <N tokens out of M licenses remain available> a couple of times, switch to Visual Studio
7. Go to Tools -> Attach to Process. Select standard.exe and click Attach.
8. In the command prompt window, type in some arbitrary value for "READ(*,*) in step 4.
9. Visual Studio should show you the source code in another tab after it successfully breaks in the subroutine you are trying to debug.
10. Debug as you wish. For example, start pressing F11. (Visual Studio may switch back to the command prompt window if you also define a breakpoint at Read(*,*), VARIABLE)
1. Prepare the Abaqus environment
a. Go to C:\Abaqus\6.9-1\site and open abaqus_v6.env with a text editor
b. Scroll down
c. In "compile_fortran", add ‘/Od’ and ‘/Zi’ parameters to enable Intel Fortran compiler to add debug symbolic information into .obj file
• compile_fortran=['ifort', '/c', '/Gm', '/recursive', '/nologo', '/heap-arrays:1', '/include:%I', '/Od', '/Zi']
d. In "link_sl", add /DEBUG to let Visual C++ .NET linker to link the files with the symbolic information in .obj file
• link_sl='cmd /c "LINK /DEBUG /nologo /INCREMENTAL:NO /subsystem:console /machine:X86
e. In "link_exe", add /DEBUG to let Visual C++ .NET linker to debug the files
• link_exe='cmd /c "LINK /DEBUG /nologo /INCREMENTAL:NO /subsystem:console
2. Prepare your job file (*.inp) and the subroutine file (*.for)
3. Open your FORTRAN code in Microsoft Visual Studio.
4. Insert a READ(*,*) VARIABLE in your subroutine source code file right after the "DIMENSION" definition where "VARIABLE" is the arbitrary name of the variable. Also, insert a breakpoint at a function/variable of interest like at READ(*,*), VARIABLE or watch a variable of interest (using Debug -> QuickWatch). You can add/remove breakpoints by pressing F9.
Code:
INCLUDE 'ABA_PARAM.INC'
C
CHARACTER*80 CMNAME
C
C
DIMENSION STRESS(NTENS),STATEV(NSTATV),
1 DDSDDE(NTENS,NTENS),DDSDDT(NTENS),DRPLDE(NTENS),
2 STRAN(NTENS),DSTRAN(NTENS),TIME(2),PREDEF(1),DPRED(1),
3 PROPS(NPROPS),COORDS(3),DROT(3,3),DFGRD0(3,3),DFGRD1(3,3)
C
C
C
PARAMETER (M=3,N=3,ID=3,ZERO=0.D0,ONE=1.D0,TWO=2.D0,THREE=3.D0,
+ SIX=6.D0, NINE=9.D0, TOLER=0.D-6)
C
DIMENSION DSTRESS(4)
C
DIMENSION VARIABLE(1)
READ(*,*), VARIABLE
a. ABAQUS command prompt will wait when it reaches "READ(*,*) defined in step 4.
6. Watch the command prompt window. As soon as the command prompt says <N tokens out of M licenses remain available> a couple of times, switch to Visual Studio
7. Go to Tools -> Attach to Process. Select standard.exe and click Attach.
8. In the command prompt window, type in some arbitrary value for "READ(*,*) in step 4.
9. Visual Studio should show you the source code in another tab after it successfully breaks in the subroutine you are trying to debug.
10. Debug as you wish. For example, start pressing F11. (Visual Studio may switch back to the command prompt window if you also define a breakpoint at Read(*,*), VARIABLE)
Comment