No announcement yet.

Debugging subroutines with Visual Studio

  • Filter
  • Time
  • Show
Clear All
new posts

  • Debugging subroutines with Visual Studio

    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.

         3 PROPS(NPROPS),COORDS(3),DROT(3,3),DFGRD0(3,3),DFGRD1(3,3)
          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)
          DIMENSION DSTRESS(4)      
          READ(*,*), VARIABLE
    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)

  • #2
    Cool. Thanks for the info!

    Jorgen Bergstrom, Ph.D. PolymerFEM Administrator


    • #3
      Error message recieved while debugging.....

      Hi IceBreaker, I am a new user of ABAQUS. I am trying to use UMAT fortran subroutine. I have followed all the steps given in your thread, but due to some reason I am getting an error message.

      Error Message: "Problem during compilation - ifort.exe not found in PATH. Abaqus/Analysis exited with errors".

      I am also attaching an image of the error message shown by the cmd. I unable to sort out this error. Can you kindly help me on this? Thanks in advance.

      Click image for larger version

Name:	error message 2.jpg
Views:	1
Size:	22.5 KB
ID:	12211

      Thanks and Best Regards


      • #4
        Have you already installed intel fortran compiler?


        • #5
          An alternate way of doing this, instead of putting a READ command into your code, is to call Abaqus using the debug option i.e.

          abaqus debug user=fortranFile(.for) job=inputfile(.inp) -explicit

          This will open up an instance of the default debugging program (Visual Studio) attached to the Abaqus explicit process. You can use the command line option 'abaqus debug help' for more information. Open up the fortran file you are using in the instance that just opened, place break points, and start debugging. Modifiying the environment file (Step 1.) is still necessary. Note: this will open up a new instance of Visual Studio every time it is used.

          If you are having PATH issues: the local environment must know the location of the debugging program and the Fortran compiler. If the environmental variables are not already set to this effect you must run the necessary batch files. For example, you need to call ifortvars.bat and vcvarsall.bat, with the appropriate options, to let the system know where the Intel Fortran Compiler and Microsoft Visual Studio are located respectively; if these system variables have not already been established during installation or otherwise.


          • #6
            Hello JonnyUCSB,

            Thank for sharing this method of debugging! I have been trying to find a method such as this. However, I am running into some issues that I hope you can help me with. I do not believe this falls within the PATH issues you described as my Visual Studio is linked to a Fortran compiler. When I try to debug the subroutine I ran with the instance that opened I get many of the following errors:

            'explicit.exe' (Win32): Loaded 'C:\SIMULIA\Abaqus\6.14-1\code\bin\ABQSMACsmModule.dll'. Cannot find or open the PDB file.

            Additionally, error such as this are present as well:

            'explicit.exe' (Win32): Loaded 'C:\Windows\System32\mfc100enu.dll'. Module was built without symbols.

            If you are aware of what may be the cause of this I would greatly appreciate some help. If it is indeed a path issue I will try to resolve it with your precious advice.

            Thank you very much for your post and help!

            Kind Regards
            Adam Carreon


            • #7
              subscribe to and seek assistance from the
              ABAQUS mailing list
              Search the archive of the list before posting in it.