Attach with debugger to um-atmos.exe


I am making some modifications to a number of routines in the UM (specifically in the UKCA part). The modifications should not change the semantics in any way, but to help performance. Unfortunately, while compilation works, I now get a runtime error:

[1] exceptions: An exception was raised:11 (Segmentation fault)
[1] exceptions: the exception reports the extra information: Sent by the kernel.
[1] exceptions: whilst in a serial region
[1] exceptions: Task had pid=16410 on host ip-172-31-15-74
[1] exceptions: Program is “/home/ubuntu/cylc-run/u-cl636/share/fcm_make/build-atmos/bin/um-atmos.exe”

In a simple world, I’d re-run the program with GDB via something like:
gdb um-atmos.exe
<… seg fault occurs …>

Unfortunately, the UM kindly hides all the details from me behind a number of scripts, which makes it particulary joyful when thinking of debugging.

Can anyone suggest how I can run um-atmos.exe with a debugger so that I actually can make some progress?


Okay, I found a way, similar to what MPI developers do here: FAQ: Debugging applications in parallel

I make sure to add something like this at the start of execution to make master process sleep for 60 seconds:

USE ios_communicators, ONLY: model_rank

IF (model_rank == 0) THEN
CALL sleep(60)

Then I run my j́ob script, check the smallest PID of the um-atmos.exe processes via
ps aux | grep um-atmos.exe

and then I do
gdb program <PID>