Skip to content

Commit

Permalink
rom-fpmd driver and librom dependency in cmake. librom must be compil…
Browse files Browse the repository at this point in the history
…ed before mgmol cmake.
  • Loading branch information
dreamer2368 committed Apr 8, 2024
1 parent abedba9 commit 6149020
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 16 deletions.
20 changes: 4 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,12 @@ endif(${MGMOL_WITH_SCALAPACK} OR DEFINED SCALAPACK_ROOT)
set(USE_LIBROM False CACHE BOOL "Build with libROM")
set(LIBROM_PATH "" CACHE STRING "Path of libROM")
if(USE_LIBROM)
message(STATUS "LIBROM_PATH: ${LIBROM_PATH}")
if(NOT LIBROM_PATH)
message(FATAL_ERROR "libROM PATH not specified.")
else(NOT LIBROM_PATH)
set(LIBROM_SCRIPTS_PATH ${LIBROM_PATH}/scripts)
message(STATUS "LIBROM_PATH: ${LIBROM_PATH}")
message(STATUS "LIBROM_SCRIPTS_PATH: ${LIBROM_SCRIPTS_PATH}")
include(ExternalProject)
ExternalProject_Add(
libROM
SOURCE_DIR ${LIBROM_SCRIPTS_PATH}
CONFIGURE_COMMAND ""
BINARY_DIR ${LIBROM_PATH}
BUILD_COMMAND ${LIBROM_SCRIPTS_PATH}/compile.sh -t ${LIBROM_PATH}/cmake/toolchains/simple.cmake
INSTALL_COMMAND ""
)
include_directories(${LIBROM_PATH}/lib)
link_directories(${LIBROM_PATH}/build/lib)
message(FATAL_ERROR "Cmake is asked to use libROM, but LIBROM_PATH not specified.")
endif(NOT LIBROM_PATH)

find_package(libROM REQUIRED)
endif(USE_LIBROM)

# ARPACK (optional)
Expand Down
11 changes: 11 additions & 0 deletions cmake_modules/FindlibROM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if(NOT LIBROM_PATH)
message(FATAL_ERROR "LIBROM_PATH not specified.")
endif(NOT LIBROM_PATH)

find_library(LIBROM_LIB libROM.so HINTS "${LIBROM_PATH}/build/lib")
find_path(LIBROM_INCLUDES librom.h HINTS "${LIBROM_PATH}/lib")

mark_as_advanced(LIBROM_LIB LIBROM_INCLUDES)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libROM REQUIRED_VARS LIBROM_LIB LIBROM_INCLUDES)
3 changes: 3 additions & 0 deletions scripts/build_quartz_libROM.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ cd ${BUILD_DIR}
set USE_LIBROM="On"
set LIBROM_PATH = ${BUILD_DIR}/libROM
git clone https://github.com/LLNL/libROM
cd libROM
./scripts/compile.sh -t ./cmake/toolchains/default-toss_4_x86_64_ib-librom-dev.cmake
cd ${BUILD_DIR}

# call cmake
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
Expand Down
21 changes: 21 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,24 @@ endif (${MGMOL_WITH_LIBXC})

install(TARGETS mgmol-opt DESTINATION bin)

# build ROM executable
if(USE_LIBROM)
add_executable(mgmol-rom rom_main.cc)
target_include_directories (mgmol-rom PRIVATE ${Boost_INCLUDE_DIRS} ${LIBROM_INCLUDES})

target_link_libraries(mgmol-rom mgmol_src ${link_libs})
target_link_libraries(mgmol-rom ${SCALAPACK_LIBRARIES})
target_link_libraries(mgmol-rom ${HDF5_LIBRARIES})
target_link_libraries(mgmol-rom ${HDF5_HL_LIBRARIES})
target_link_libraries(mgmol-rom ${BLAS_LIBRARIES})
target_link_libraries(mgmol-rom ${LAPACK_LIBRARIES})
target_link_libraries(mgmol-rom ${Boost_LIBRARIES})
target_link_libraries(mgmol-rom ${LIBROM_LIB})
if (${OPENMP_CXX_FOUND})
target_link_libraries(mgmol-rom OpenMP::OpenMP_CXX)
endif()
if(${MGMOL_WITH_LIBXC})
target_link_libraries(mgmol-rom ${LIBXC_DIR}/lib/libxc.a)
endif (${MGMOL_WITH_LIBXC})
install(TARGETS mgmol-rom DESTINATION bin)
endif(USE_LIBROM)
102 changes: 102 additions & 0 deletions src/rom_main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2017, Lawrence Livermore National Security, LLC and
// UT-Battelle, LLC.
// Produced at the Lawrence Livermore National Laboratory and the Oak Ridge
// National Laboratory.
// LLNL-CODE-743438
// All rights reserved.
// This file is part of MGmol. For details, see https://github.com/llnl/mgmol.
// Please also read this link https://github.com/llnl/mgmol/LICENSE

//
// main.cc
//
// Description:
// Real grid, finite difference, molecular dynamics program
// for with nonorthogonal localized orbitals.
//
// Uses Mehrstellen operators, multigrid accelerations, and
// non-local pseudopotentials.
//
// Includes LDA and PBE exchange and correlation functionals.
//
// Units:
// Potentials, eigenvalues and operators in Rydberg
// Energies in Hartree
//
#include <cassert>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;

#ifdef _OPENMP
#include <omp.h>
#endif

#ifdef USE_CNR
#include <mkl.h>
#endif

#include <mpi.h>

#include "Control.h"
#include "DistMatrix.h"
#include "ExtendedGridOrbitals.h"
#include "LocGridOrbitals.h"
#include "MGmol.h"
#include "MGmol_MPI.h"
#include "MPIdata.h"
#include "MatricesBlacsContext.h"
#include "Mesh.h"
#include "PackedCommunicationBuffer.h"
#include "ReplicatedWorkSpace.h"
#include "SparseDistMatrix.h"
#include "magma_singleton.h"
#include "tools.h"

#include <fenv.h>
#include <sys/cdefs.h>
#include <time.h>

#include <boost/program_options.hpp>
namespace po = boost::program_options;

#include "librom.h"

//#include "MemTrack.h"

int main(int argc, char** argv)
{
// change handling of memory allocation errors
set_new_handler(noMoreMemory);

cout.sync_with_stdio();

int mpirc = MPI_Init(&argc, &argv);
if (mpirc != MPI_SUCCESS)
{
cerr << "MPI Initialization failed!!!" << endl;
MPI_Abort(MPI_COMM_WORLD, 0);
}
MPI_Comm_rank(MPI_COMM_WORLD, &mype);
assert(mype > -1);
onpe0 = (mype == 0);

CAROM::Vector librom_vector(10, false);

mpirc = MPI_Finalize();
if (mpirc != MPI_SUCCESS)
{
cerr << "MPI Finalize failed!!!" << endl;
}

time_t tt;
time(&tt);
if (onpe0) cout << " Run ended at " << ctime(&tt) << endl;

// MemTrack::TrackDumpBlocks();

// MemTrack::TrackListMemoryUsage();

return 0;
}

0 comments on commit 6149020

Please sign in to comment.