Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow an external install of the mpi-serial library #4533

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions CIME/Tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,13 @@ ifeq ($(strip $(MPILIB)), mpi-serial)
MPIFC := $(SFC)
MPICC := $(SCC)
MPICXX := $(SCXX)
CONFIG_ARGS += MCT_PATH=$(SHAREDLIBROOT)/$(SHAREDPATH)/mct/mpi-serial
ifndef MPI_SERIAL_PATH
CONFIG_ARGS += MCT_PATH=$(SHAREDLIBROOT)/$(SHAREDPATH)/mct/mpi-serial
else
CONFIG_ARGS += MCT_PATH=$(MPI_SERIAL_PATH)
INC_MPI := $(MPI_SERIAL_PATH)/include
LIB_MPI := $(MPI_SERIAL_PATH)/lib
endif
else
CC := $(MPICC)
FC := $(MPIFC)
Expand Down Expand Up @@ -567,9 +573,9 @@ ifdef MPAS_LIBDIR
# used to build the MPAS dycore if needed.
libmpas: cam_abortutils.o physconst.o
$(MAKE) -C $(MPAS_LIBDIR) CC="$(CC)" FC="$(FC)" PIODEF="$(PIODEF)" \
FFLAGS='$(FREEFLAGS) $(FFLAGS)' GPUFLAGS='$(GPUFLAGS)' \
CASEROOT='$(CASEROOT)' COMPILER='$(COMPILER)' MACH='$(MACH)' \
FCINCLUDES='$(INCLDIR) $(INCS) -I$(ABS_INSTALL_SHAREDPATH)/include -I$(ABS_ESMF_PATH)/include'
FFLAGS='$(FREEFLAGS) $(FFLAGS)' GPUFLAGS='$(GPUFLAGS)' \
CASEROOT='$(CASEROOT)' COMPILER='$(COMPILER)' MACH='$(MACH)' \
FCINCLUDES='$(INCLDIR) $(INCS) -I$(ABS_INSTALL_SHAREDPATH)/include -I$(ABS_ESMF_PATH)/include'

dyn_comp.o: libmpas
dyn_grid.o: libmpas
Expand All @@ -595,10 +601,12 @@ ifdef LAPACK_LIBDIR
SLIBS += -L$(LAPACK_LIBDIR) -llapack -lblas
endif
ifdef LIB_MPI
ifndef MPI_LIB_NAME
SLIBS += -L$(LIB_MPI) -lmpi
else
SLIBS += -L$(LIB_MPI) -l$(MPI_LIB_NAME)
ifndef MPI_SERIAL_PATH
ifndef MPI_LIB_NAME
SLIBS += -L$(LIB_MPI) -lmpi
else
SLIBS += -L$(LIB_MPI) -l$(MPI_LIB_NAME)
endif
endif
endif

Expand Down Expand Up @@ -919,12 +927,21 @@ GENF90 ?= $(CIMEROOT)/CIME/non_py/externals/genf90/genf90.pl
.SUFFIXES: .F90 .F .f90 .f .c .cpp .o .in

ifeq ($(MPILIB),mpi-serial)
MPISERIAL = $(INSTALL_SHAREDPATH)/lib/libmpi-serial.a
MLIBS += -L$(INSTALL_SHAREDPATH)/lib -lmpi-serial
CMAKE_OPTS += -DMPI_C_INCLUDE_PATH=$(INSTALL_SHAREDPATH)/include \
ifdef MPI_SERIAL_PATH
MPISERIAL = $(MPI_SERIAL_PATH)/lib/libmpi-serial.a
MLIBS += -L$(MPI_SERIAL_PATH)/lib -lmpi-serial
CMAKE_OPTS += -DMPI_C_INCLUDE_PATH=$(MPI_SERIAL_PATH)/include \
-DMPI_Fortran_INCLUDE_PATH=$(MPI_SERIAL_PATH)/include \
-DMPI_C_LIBRARIES=$(MPI_SERIAL_PATH)/lib/libmpi-serial.a \
-DMPI_Fortran_LIBRARIES=$(MPI_SERIAL_PATH)/lib/libmpi-serial.a
else
MPISERIAL = $(INSTALL_SHAREDPATH)/lib/libmpi-serial.a
MLIBS += -L$(INSTALL_SHAREDPATH)/lib -lmpi-serial
CMAKE_OPTS += -DMPI_C_INCLUDE_PATH=$(INSTALL_SHAREDPATH)/include \
-DMPI_Fortran_INCLUDE_PATH=$(INSTALL_SHAREDPATH)/include \
-DMPI_C_LIBRARIES=$(INSTALL_SHAREDPATH)/lib/libmpi-serial.a \
-DMPI_Fortran_LIBRARIES=$(INSTALL_SHAREDPATH)/lib/libmpi-serial.a
endif
endif

$(MCTLIBS) : $(MPISERIAL)
Expand Down
11 changes: 9 additions & 2 deletions CIME/XML/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@


class Machines(GenericXML):
def __init__(self, infile=None, files=None, machine=None, extra_machines_dir=None):
def __init__(
self,
infile=None,
files=None,
machine=None,
extra_machines_dir=None,
read_only=True,
):
"""
initialize an object
if a filename is provided it will be used,
Expand Down Expand Up @@ -46,7 +53,7 @@ def __init__(self, infile=None, files=None, machine=None, extra_machines_dir=Non
else:
expect(False, f"file not found {infile}")

GenericXML.__init__(self, infile, schema)
GenericXML.__init__(self, infile, schema, read_only=read_only)

# Append the contents of $HOME/.cime/config_machines.xml if it exists.
#
Expand Down
5 changes: 5 additions & 0 deletions CIME/build_scripts/buildlib.mpi-serial
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def buildlib(bldroot, installpath, case):
###############################################################################
caseroot = case.get_value("CASEROOT")
srcroot = case.get_value("SRCROOT")
# check to see if MPI_SERIAL is installed
with open(os.path.join(caseroot, "Macros.make"), "r") as f:
for line in f:
if "MPI_SERIAL_PATH" in line:
return

customize_path = os.path.join(srcroot, "cime_config", "customize")

Expand Down
6 changes: 5 additions & 1 deletion CIME/non_py/src/timing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ ifeq ($(strip $(MPILIB)), mpi-serial)
FC := $(SFC)
MPIFC := $(SFC)
MPICC := $(SCC)
INCLDIR += -I$(GPTL_LIBDIR)/../mct/mpi-serial
ifdef MPI_SERIAL_PATH
INCLDIR += -I$(MPI_SERIAL_PATH)/include
else
INCLDIR += -I$(GPTL_LIBDIR)/../mct/mpi-serial
endif
else
CC := $(MPICC)
FC := $(MPIFC)
Expand Down
Loading