Introduction

Debugging a parallel version of XBeach using multiple processes is possible, but not as convenient as debugging in, for example, Visual Studio. This section describes a way to truly debug a parallel program like XBeach.

Compile the program without optimization

In order to prevent the debugger to randomly skip through the code, optimizations should be prevented. This can be done to alter the above mentions call to the configuration script as follows:

 FC=gfortran44 FCFLAGS="-g -O0" ./configure --with-mpi 

The -g option makes sure debugging symbols are included in the result. The -O0 sets the optimizations to a minimum. By default these are set to -O2. Now create a binary file:

make distclean
make install

Installing XBeach is necessary to get a proper executable that can be debugged. To change the directory the XBeach binary is installed to, add the following to the configure command:

 --prefix=<installation_path> 

Have an X Window system available

On Microsoft Windows, make sure an X Window emulator is running. For example, start Exceed: START -> Program -> Exceed -> Exceed

It may be necessary to set the DISPLAY variable in the environment by using:

 export DISPLAY=<computer_name>:0.0 

Run the model

Start the just compiled XBeach binary in your model directory in a bit peculiar way:

 mpirun -n <nr_of_processes> xterm -e gdb <path_to_binary>/xbeach 

This will start a number of command windows (xterm) equal to the number of processes you defined after the -n option. In each command window, a instance of the debugger (gdb) will be started. Each instance of the debugger will debug a specific subprocess of the XBeach program stored in the <path_to_binary> path.

Start debugging

The debugger provides at least the following commands, which can be used in each command window separately:

Command

Description

Example

r

Starts the XBeach program in the current debugger

r

b

Adds or queries a breakpoint

b <filename>.F90:<linenr>

 

 

b 1

c

Continue running after breakpoint

c

n

Continue to next line

n

p

Print variable contents

p <varname>

q

Quit running

q

Especially the commands n or p might complain about a lack of line numbers or variables. This can be due to you are still using optimizations or you use an inferior type of debugging symbols. You might want to consider using another type, like DWARF-2. How? I don't know! If you do, please provide the info here...

  • No labels