Skip to content

Commit

Permalink
Add mpihome to install script
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjward committed Dec 13, 2024
1 parent 54ca480 commit 6580570
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions scripts/firedrake-install
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class FiredrakeConfiguration(dict):
self["options"][o] = args.__dict__[o]

_persistent_options = ["package_manager",
"minimal_petsc", "mpicc", "mpicxx", "mpif90", "mpiexec", "disable_ssh",
"minimal_petsc", "mpicc", "mpicxx", "mpif90", "mpiexec", "mpihome", "disable_ssh",
"honour_petsc_dir", "with_parmetis",
"slepc", "packages", "honour_pythonpath",
"opencascade", "torch", "jax",
Expand Down Expand Up @@ -306,6 +306,9 @@ honoured.""",
parser.add_argument("--mpiexec", type=str,
action="store", default=None,
help="MPI launcher. If not set, MPICH will be downloaded and used.")
parser.add_argument("--mpihome", type=str,
action="store", default=None,
help="Location of MPI files. If not set, MPICH will be downloaded and used.")
parser.add_argument("--mpi4py-version", help="Specify an exact version of mpi4py to install")
parser.add_argument("--show-petsc-configure-options", action="store_true",
help="Print out the configure options passed to PETSc and exit")
Expand Down Expand Up @@ -339,9 +342,9 @@ honoured.""",
args = parser.parse_args()

# If the user has set any MPI info, they must set them all
if args.mpicc or args.mpicxx or args.mpif90 or args.mpiexec:
if not (args.mpicc and args.mpicxx and args.mpif90 and args.mpiexec):
log.error("If you set any MPI information, you must set all of {mpicc, mpicxx, mpif90, mpiexec}.")
if args.mpicc or args.mpicxx or args.mpif90 or args.mpiexec or args.mpihome:
if not (args.mpicc and args.mpicxx and args.mpif90 and args.mpiexec and args.mpihome):
log.error("If you set any MPI information, you must set all of {mpicc, mpicxx, mpif90, mpiexec, mpihome}.")
sys.exit(1)

if args.package_branch:
Expand Down Expand Up @@ -1390,7 +1393,7 @@ if args.rebuild_script:
sys.exit(0)


def create_compiler_env(cc, cxx, f90):
def create_compiler_env(cc, cxx, f90, mpihome):
env = dict()
if cc:
env["MPICC"] = cc
Expand All @@ -1411,6 +1414,8 @@ def create_compiler_env(cc, cxx, f90):
env["MPIF90"] = f90
env["MPI_Fortran_COMPILER"] = f90
env["F90"] = f90
if mpihome:
env["MPI_HOME"] = mpihome

return env

Expand Down Expand Up @@ -1705,7 +1710,18 @@ cc = options["mpicc"]
cxx = options["mpicxx"]
f90 = options["mpif90"]
mpiexec = options["mpiexec"]
compiler_env = create_compiler_env(cc, cxx, f90)
try:
mpihome = options["mpihome"]
except KeyError:
if cc:
try:
mpihome = os.environ["MPI_HOME"]
except KeyError:
raise InstallError("MPI compilers specified but mpihome is missing from "
"configuration. Please set MPI_HOME to continue.")
else:
mpihome = None
compiler_env = create_compiler_env(cc, cxx, f90, mpihome)
os.chdir(firedrake_env)

# Dict to store BLAS and OPENBLAS environment variables
Expand Down Expand Up @@ -1802,7 +1818,8 @@ if mode == "install":
cxx = os.path.join(compilerbin, "mpicxx")
f90 = os.path.join(compilerbin, "mpif90")
mpiexec = os.path.join(compilerbin, "mpiexec")
compiler_env = create_compiler_env(cc, cxx, f90)
mpihome = os.path.join(compilerbin, "..")
compiler_env = create_compiler_env(cc, cxx, f90, mpihome)

# Make sure that we link against the right MPI and PETSc shared libraries
link_env = {
Expand Down Expand Up @@ -1955,7 +1972,8 @@ else:
cxx = os.path.join(compilerbin, "mpicxx")
f90 = os.path.join(compilerbin, "mpif90")
mpiexec = os.path.join(compilerbin, "mpiexec")
compiler_env = create_compiler_env(cc, cxx, f90)
mpihome = os.path.join(compilerbin, "..")
compiler_env = create_compiler_env(cc, cxx, f90, mpihome)

# Make sure that we link against the right MPI and PETSc shared libraries
link_env = {
Expand Down

0 comments on commit 6580570

Please sign in to comment.