Make gmx_node_num/rank safer
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 9 Jul 2014 19:43:09 +0000 (22:43 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sat, 12 Jul 2014 08:35:59 +0000 (10:35 +0200)
commit06ff230c2cb585eb8c5a94b347e4162ec0adabf6
treeba738af61b3e5ddc0dd91c7dfcc4cfbd25ea66d1
parent9944846c408587cede17ff2a54c2369c6b9e3e0e
Make gmx_node_num/rank safer

With real MPI, MPI_Init() is called as the first thing, but with
thread-MPI, MPI is "initialized" only much later, when the actual
threads are started.  But code between these two points may expect to be
able to check whether the current rank is the master and/or whether
there are other ranks, and try to use these functions for that.

Previously, for thread-MPI builds, they accessed invalid memory and
returned essentially random values if called between these two init
points.  Now they behave as if the single thread that is executing at
that time is the single master rank.

Also document the behavior in more detail.

Change-Id: Ia3bef9c5899c528e315fe1310bde970dfec68769
src/gromacs/commandline/cmdlinemodulemanager.cpp
src/gromacs/commandline/pargs.cpp
src/gromacs/utility/basenetwork.cpp
src/gromacs/utility/basenetwork.h