Skip to content
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ if(${MGMOL_WITH_CLANG_FORMAT})
find_package(CLANG_FORMAT)
if(${CLANG_FORMAT_FOUND})
message(STATUS "Indent with clang-format")
file(GLOB_RECURSE FORMAT_SOURCES src/*.cc src/*.h tests/*.cc tests/*.h)
file(GLOB_RECURSE FORMAT_SOURCES src/*.cc src/*.h tests/*.cc tests/*.h drivers/*.cc)
add_custom_target(format
COMMAND ${CLANG_FORMAT_EXECUTABLE} -i -style=file ${FORMAT_SOURCES}
DEPENDS ${FORMAT_SOURCES})
Expand Down Expand Up @@ -252,5 +252,7 @@ include_directories("${PROJECT_SOURCE_DIR}/src")
# add subdirectories for source files, tests
add_subdirectory(src)

add_subdirectory(drivers)

add_subdirectory(tests)

9 changes: 9 additions & 0 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include_directories( ${CMAKE_SOURCE_DIR}/src )

add_executable(check_input
check_input.cc
)

target_include_directories(check_input PRIVATE ${Boost_INCLUDE_DIRS})

target_link_libraries(check_input mgmol_src)
93 changes: 93 additions & 0 deletions drivers/check_input.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// 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

#include "Control.h"
#include "ExtendedGridOrbitals.h"
#include "LocGridOrbitals.h"
#include "MGmol.h"
#include "MGmol_MPI.h"
#include "MPIdata.h"
#include "mgmol_run.h"

#include <cassert>
#include <iostream>

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

int main(int argc, char** argv)
{
int mpirc = MPI_Init(&argc, &argv);
if (mpirc != MPI_SUCCESS)
{
std::cerr << "MPI Initialization failed!!!" << std::endl;
MPI_Abort(MPI_COMM_WORLD, 0);
}

MPI_Comm comm = MPI_COMM_WORLD;

mgmol_init(comm);

// read runtime parameters
std::string input_filename("");
std::string lrs_filename;
std::string constraints_filename("");

float total_spin = 0.;
bool with_spin = false;

po::variables_map vm;

// read options from PE0 only
if (MPIdata::onpe0)
{
read_config(argc, argv, vm, input_filename, lrs_filename,
constraints_filename, total_spin, with_spin);
}

MGmol_MPI::setup(comm, std::cout, with_spin);
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
MPI_Comm global_comm = mmpi.commGlobal();

Control::setup(global_comm, with_spin, total_spin);
Control& ct = *(Control::instance());

ct.setOptions(vm);

int ret = ct.checkOptions();
if (ret < 0) return ret;

mmpi.bcastGlobal(input_filename);
mmpi.bcastGlobal(lrs_filename);

// Enter main scope
{
MGmolInterface* mgmol;
if (ct.isLocMode())
mgmol = new MGmol<LocGridOrbitals>(global_comm, *MPIdata::sout,
input_filename, lrs_filename, constraints_filename);
else
mgmol = new MGmol<ExtendedGridOrbitals>(global_comm, *MPIdata::sout,
input_filename, lrs_filename, constraints_filename);

*MPIdata::sout << " Input parameters OK\n";

delete mgmol;
} // close main scope

mgmol_finalize();

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

return 0;
}
17 changes: 9 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ install(TARGETS mgmol_src DESTINATION lib)
add_executable(mgmol-opt main.cc)
target_include_directories (mgmol-opt PRIVATE ${Boost_INCLUDE_DIRS})

target_link_libraries(mgmol-opt mgmol_src ${link_libs})
target_link_libraries(mgmol-opt ${SCALAPACK_LIBRARIES})
target_link_libraries(mgmol-opt ${HDF5_LIBRARIES})
target_link_libraries(mgmol-opt ${HDF5_HL_LIBRARIES})
target_link_libraries(mgmol-opt ${BLAS_LIBRARIES})
target_link_libraries(mgmol-opt ${LAPACK_LIBRARIES})
target_link_libraries(mgmol-opt ${Boost_LIBRARIES})
target_link_libraries(mgmol_src ${link_libs})
target_link_libraries(mgmol_src ${SCALAPACK_LIBRARIES})
target_link_libraries(mgmol_src ${LAPACK_LIBRARIES})
target_link_libraries(mgmol_src ${BLAS_LIBRARIES})
target_link_libraries(mgmol_src ${HDF5_LIBRARIES})
target_link_libraries(mgmol_src ${HDF5_HL_LIBRARIES})
target_link_libraries(mgmol_src ${Boost_LIBRARIES})

target_link_libraries(mgmol-opt mgmol_src)
if (${OPENMP_CXX_FOUND})
target_link_libraries(mgmol-opt OpenMP::OpenMP_CXX)
endif()
Expand All @@ -192,4 +194,3 @@ if(${MGMOL_WITH_LIBXC})
endif (${MGMOL_WITH_LIBXC})

install(TARGETS mgmol-opt DESTINATION bin)

4 changes: 3 additions & 1 deletion src/Electrostatic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Timer Electrostatic::solve_tm_("Electrostatic::solve");

Electrostatic::Electrostatic(PoissonFDtype lap_type, const short bcPoisson[3],
const double screening_const)
: laptype_(lap_type)
: laptype_(lap_type), poisson_solver_(nullptr)
{
assert(bcPoisson[0] >= 0);
assert(bcPoisson[1] >= 0);
Expand Down Expand Up @@ -166,6 +166,8 @@ Electrostatic::Electrostatic(PoissonFDtype lap_type, const short bcPoisson[3],

Electrostatic::~Electrostatic()
{
assert(poisson_solver_ != nullptr);

delete poisson_solver_;
if (grhod_ != nullptr) delete grhod_;
if (grhoc_ != nullptr) delete grhoc_;
Expand Down
Loading