I want to run a Python script in several parallel processes under MPI, and I need to pass command-line arguments. I'm using the argparse module in Python, but it's a little messy sometimes. If I don't specify the right arguments, all the processes complain, so I get many copies of the same error message.
I tried making only process 0 parse the arguments and then broadcast the results to the other processes, but then the other processes hang when the parsing fails and nothing gets broadcast.
How can I parse the command-line arguments, and print a readable message when the parsing fails?