This is a typical problem in scientific computing programs. The code is huge and hairy. The program opens, reads or writes hundreds of files. You want to figure out what files the program is opening, reading or writing.
Thanks to Rohan for suggesting to use
strace for this. It captures the system calls called by your program during execution. The system calls related to files is
close. This information can be captured by this command:
$ strace -e trace=open,close -o trace.log ./foobar
The output can be found in the file
trace.log after the program exits.
If you just need the files opened:
$ strace -e trace=open -o trace.log ./foobar
Tried with: Ubuntu 14.04