Question: I'm in the process of adding an option to a Fortran program to run it using multiple processors using MPI. If the user is going to run it in parallel, the user needs to specify different input files---one file for each domain (processor) of the problem. The program will look for a specific filename by default (a file called "serial.inp"). So I need the program to know when it is being run in parallel so that it can instead look for the other filenames instead (e.g. "parallel\_1.inp", "parallel\_2.inp", "parallel\_3.inp", etc.). My first thought is to have the user pass an argument to the program when they execute it, e.g.:

mpiexec -n 4 myprogram.exe -parallel

This way, it will look for the parallel files when that argument is present. But it seems kind of redundant. If the program is being called with mpiexec, there is no question that the user is attempting to run it in parallel. Is there any way that my program will know it was started using mpiexec? Or is the command line argument my best bet?

Answer: 
Put

```
$DB::single = 1;

```

before any statement to set a permanent breakpoint in your code.
This works with compile-time code, too, and may be the only good way to set a breakpoint during the compile phase.

---

To have the debugger automatically start your code, you can manipulate the `@DB::typeahead` array in either a `.perldb` file or in a compile-time (`BEGIN`) block in your code. For example:

```
# .perldb file
push @DB::typeahead, "c";

```

or

```
BEGIN { push @DB::typeahead, "p 'Hello!'", "c" }
...
$DB::single = 1;
$x = want_to_stop_here();

```

There is also a `"NonStop"` option that you could set in `.perldb` or in the `PERLDB_OPTS` environment variable:

```
PERLDB_OPTS=NonStop perl -d myprogram.pl

```

All of this (and much more) is discussed deep in the bowels of [`perldebug`](http://search.cpan.org/perldoc?perldebug) and [`perl5db.pl`](http://search.cpan.org/perldoc?perl5db.pl)

Update:
-------

To address the issues raised in the most recent update. Use the following in `./perldb`:

```
print "Reading ~/.perldb options.\n";
push @DB::typeahead, "c";
parse_options("inhibit_exit=0");

```
Also check out [Enbugger](https://metacpan.org/module/Enbugger). And while on the topic of debuggers, see [Devel::Trepan](https://metacpan.org/module/Devel%3a%3aTrepan) which also works with Enbugger.