()
| 401 | |
| 402 | |
| 403 | def get_rank_without_mpi_import(): |
| 404 | # check environment variables here instead of importing mpi4py |
| 405 | # to avoid calling MPI_Init() when this module is imported |
| 406 | for varname in ["PMI_RANK", "OMPI_COMM_WORLD_RANK"]: |
| 407 | if varname in os.environ: |
| 408 | return int(os.environ[varname]) |
| 409 | return 0 |
| 410 | |
| 411 | |
| 412 | def mpi_weighted_mean(comm, local_name2valcount): |