Skip to content

Commit

Permalink
Merge pull request #6 from ESCOMP/mpiserial_support
Browse files Browse the repository at this point in the history
add support for mpi-serial
  • Loading branch information
mvertens authored Jul 22, 2020
2 parents 05569c9 + 33da91b commit 8a3b7ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
19 changes: 4 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 3.10)
project(NUOPC_DATA_MODELS LANGUAGES Fortran VERSION 0.1)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(ExternalProject)

find_package(MPI REQUIRED)
find_package(ESMF REQUIRED)

if (DEFINED CIMEROOT)
Expand All @@ -16,20 +14,11 @@ if (DEFINED CIMEROOT)
set(FOX ${LIBROOT})
set(CMAKE_Fortran_FLAGS "${FFLAGS} -I${LIBROOT}/include -I${LIBROOT}/finclude -I${LIBROOT}/nuopc/esmf/${NINST_VALUE}/include")
else ()
message("CIMEROOT not found, downloading cime")
ExternalProject_Add (cime
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/cime
GIT_REPOSITORY https://github.com/ESMCI/cime
GIT_TAG cd1238247e71f0336fd790bc9716ac6f0bf91c21
GIT_PROGRESS TRUE
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
ExternalProject_Get_Property (cime SOURCE_DIR)
set (CIMEROOT ${SOURCE_DIR})
unset (SOURCE_DIR)
set(BLD_STANDALONE TRUE)
endif ()
if (NOT DEFINED MPILIB OR NOT ${MPILIB} STREQUAL "mpi-serial")
find_package(MPI REQUIRED)
endif()

if(BLD_STANDALONE)
add_subdirectory(share)
Expand Down
21 changes: 14 additions & 7 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def buildlib(bldroot, libroot, case, compname=None):
strthread = "threads"
else:
strthread = "nothreads"
mpilib = case.get_value("MPILIB")

sharedpath = os.path.join(case.get_value("COMPILER"),
case.get_value("MPILIB"), strdebug, strthread, "nuopc")
sharedpath = os.path.join(case.get_value("COMPILER"),mpilib,
strdebug, strthread, "nuopc")


if compname:
Expand All @@ -52,10 +53,11 @@ def buildlib(bldroot, libroot, case, compname=None):

cmake_flags = get_standard_cmake_args(case, os.path.join(sharedpath,"cdeps"), shared_lib=True)
ccomp, cxxcomp, fcomp = get_compiler_names(case)

cmake_flags += " -DCMAKE_C_COMPILER={} -DCMAKE_CXX_COMPILER={} -DCMAKE_Fortran_COMPILER={}".format(ccomp, cxxcomp, fcomp)
cmake_flags += " -DCMAKE_INSTALL_PREFIX={} ".format(libroot)
cmake_flags += " -DLIBROOT={} ".format(libroot) + srcpath

cmake_flags += " -DMPILIB={} ".format(mpilib)

logger.info("cmake_flags {}".format(cmake_flags))
s,o,e = run_cmd("cmake {} ".format(cmake_flags), from_dir=bldroot, verbose=True)
Expand All @@ -74,13 +76,18 @@ def buildlib(bldroot, libroot, case, compname=None):
os.rmdir(comppath)
symlink_force(os.path.join(bldroot,compname), comppath)


def get_compiler_names(case):
machobj = Machines(machine=case.get_value("MACH"))
compobj = Compilers(machobj)
ccomp = compobj.get_value("MPICC").strip()
cxxcomp = compobj.get_value("MPICXX").strip()
fcomp = compobj.get_value("MPIFC").strip()
if case.get_value("MPILIB") == 'mpi-serial':
ccomp = compobj.get_value("SCC").strip()
cxxcomp = compobj.get_value("SCXX").strip()
fcomp = compobj.get_value("SFC").strip()
else:
ccomp = compobj.get_value("MPICC").strip()
cxxcomp = compobj.get_value("MPICXX").strip()
fcomp = compobj.get_value("MPIFC").strip()

return ccomp, cxxcomp, fcomp

Expand Down

0 comments on commit 8a3b7ac

Please sign in to comment.