Intel® Fortran Compiler 17.0 Developer Guide and Reference

Debugging a Coarray Application (Linux*)

Steps to perform to debug a coarray application.

For the following, you need an application with shared variables or coarrays whose storage spans across all the images in a program.

Follow these steps to debug your coarray application:

  1. Add a stall loop to your application before the area of code you wish to debug.
    LOGICAL VOLATILE :: WAIT_FOR_DEBUGGER
    LOGICAL, VOLATILE :: TICK
    :
    DO WHILE(WAIT_FOR_DEBUGGER)
    TICK = .NOT. TICK
    END DO
    ! Code you want to debug is here

    The use of VOLATILE is required to ensure that the loop will not be removed by the compiler. If the problem is only found on one image, you can wrap the loop in IF (THIS_IMAGE() .EQ. 4) THEN or the like.

  2. Compile and link with debug enabled (-g).
  3. Create at least N+1 terminal windows on the machine where the application will be running, where N is the number of images your application will have.
  4. In a terminal window, start the application.
    linuxprompt> ./my_app
  5. In each of the other terminal windows, set your default directory to be the same as the location of the application executable. Use the ps command in one of the windows to find out which processes are running your application:
    linuxprompt> ps –ef | grep 'whoami' | grep my_app
    There will be several processes. The oldest is the one you started in step 4 – it has run the MPI launcher and is now waiting for the others to terminate. Do not debug it.
    The others will look like this:
    <your-user-name> 25653 25650 98 15:06 ? 00:00:49 my_app 
    <your-user-name> 25654 25651 97 15:06 ? 00:00:48 my_app 
    <your-user-name> 25655 25649 98 15:06 ? 00:00:49 my_app

    The first number is the PID of the process (for example, 25653 in the first line). In the steps below, the PIDs of these N processes are referred to as P1, P2, and so on. When you type the commands, replace the text <P1> with the actual value of the PID for process 1, and so on.

  6. In each window other than the first, start your debugger and set it to stop processes when attached:
    linuxprompt> gdb
  7. Attach to one of the processes. For example, attach to P1 in window 1, attach to P2 in window 2, and so on.
    (gdb) attach <P1>
  8. Get execution out of the stall loop:
    (gdb) set WAIT_FOR_DEBUGGER = .false.
    You are now ready to debug your coarray application.

You are now ready to debug your coarray application by examining the data and code paths in the various images.