NameError: name 'mpi_comm_self' is not defined

3 months ago by
Hi, I am using FEniCS for the subdomain assembly and solve.
I have a python script which works fine in MacBook, but when I try to use it in a cluster, it produces the following error.

from dolfin import *
from mpi4py import MPI

print("Running FEniCS...")
mpi_comm = MPI.COMM_WORLD
ip = mpi_comm.Get_rank()
mesh = UnitSquareMesh(mpi_comm_self(), 2, 2)

Produce : NameError: name 'mpi_comm_self' is not defined
Appreciate any suggestions.


Community: FEniCS Project

1 Answer

3 months ago by
Depends on version of FEniCS you are using.
Versions <= 2017.2.0 had dolfin.mpi_comm_world() and dolfin.mpi_comm_self()
Versions >= 2018.1.0 have dolfin.MPI.comm_world and dolfin.MPI.comm_self

Note: Please, do not import dolfin via wildcards (*). And you do not need to import mpi4py. Since 2018.1.0 dolfin.MPI.comm_world is mpi4py.MPI.Intracomm

import dolfin as d

comm = d.MPI.comm_world​
print("Rank %d" % comm.Get_rank())
Please login to add an answer/comment or follow this question.

Similar posts:
Search »