Commit ffc25c9d authored by Daniel Wortmann's avatar Daniel Wortmann

Made juDFT its own cmake project

parent 5026885e
if (FLEUR_HDF5_SUBMODULE)
#get source code
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/hdf5-git/src" )
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule init external/hdf5-git WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _res_init OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _res_update OUTPUT_QUIET ERROR_QUIET)
if( ${_res_init} GREATER 0 OR ${_res_update} GREATER 0 )
message(FATAL_ERROR "HDF5 source could not be downloaded.\n"
"We tried: 'git submodule init external/hdf5-git && git submodule update' and resulted in error" )
endif()
endif()
#configure HDF5
set(HDF5_EXTERNALLY_CONFIGURED 1)
set(HDF5_EXPORTED_TARGETS "hdf5_fortran-static")
set(HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support")
set(HDF5_BUILD_CPP_LIB OFF CACHE BOOL "Build HDF5 C++ Library")
set(HDF5_BUILD_HL_LIB OFF CACHE BOOL "Build HIGH Level HDF5 Library")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared Libraries")
set(HDF5_BUILD_TOOLS OFF CACHE BOOL "Build HDF5 Tools")
set(HDF5_BUILD_EXAMPLES OFF CACHE BOOL "Build HDF5 Library Examples")
set(BUILD_TESTING OFF CACHE BOOL "Build HDF5 Unit Testing")
if (FLEUR_USE_MPI)
set(HDF5_ENABLE_PARALLEL ON CACHE BOOL "Enable parallel build (requires MPI)")
else()
set(HDF5_ENABLE_PARALLEL OFF CACHE BOOL "Enable parallel build (requires MPI)")
endif()
#set(HDF5_F90_BINARY_DIR "${CMAKE_SOURCE_DIR}/external/hdf5-git/fortran/")
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5")
#set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/external/hdf5/CMake-hdf5-1.10.3/HDF_Group/HDF5/1.10.3/include/")
add_subdirectory (external/hdf5-git)
#Now set all the FLEUR specific stuff
if(${FLEUR_USE_MPI})
target_link_libraries(fleur_MPI hdf5_fortran-static)
target_compile_definitions(fleur_MPI PUBLIC "CPP_HDF5MPI")
target_compile_definitions(fleur_MPI PUBLIC "CPP_HDF")
target_compile_definitions(juDFT PUBLIC "CPP_HDF5MPI")
target_compile_options(fleur_MPI PUBLIC "-I${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5/static")
endif()
if (${FLEUR_USE_SERIAL})
target_link_libraries(fleur hdf5_fortran-static)
target_link_libraries(inpgen hdf5_fortran-static)
target_compile_definitions(fleur PUBLIC "CPP_HDF")
target_compile_options(fleur PUBLIC "-I${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5/static")
endif()
target_link_libraries(juDFT hdf5_fortran-static)
target_link_libraries(juDFT hdf5-static)
target_compile_definitions(juDFT PUBLIC "CPP_HDF")
target_compile_options(juDFT PUBLIC "-I${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5/static")
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/juDFT/CMakeLists.txt" )
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule init juDFT WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _res_init OUTPUT_QUIET ERROR_QUIET)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _res_update OUTPUT_QUIET ERROR_QUIET)
if( ${_res_init} GREATER 0 OR ${_res_update} GREATER 0 )
message(FATAL_ERROR "HDF5 source could not be downloaded.\n"
"We tried: 'git submodule init external/libxc-git && git submodule update' and resulted in error" )
endif()
endif()
set(JUDFT_USE_MPI ${FLEUR_USE_MPI} CACHE BOOL "Compile with MPI, will also work in serial")
set(JUDFT_USE_HDF5 ${FLEUR_USE_HDF5} CACHE BOOL "Compile with HDF5")
if (DEFINED FLEUR_USE_HDF5MPI)
set(JUDFT_USE_HDF5MPI FLEUR_USE_HDF5MPI CACHE BOOL"Is the HDF5 version able to do parallel IO" )
endif()
#In addition you might want to set
set(JUDFT_COMPILEOPTS ${FLEUR_PRECISION_OPTION})
add_subdirectory(juDFT)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/juDFT/modules/juDFT")
cmake_minimum_required(VERSION 3.0)
project(FLEUR LANGUAGES Fortran)
#These options should be adjusted
option(JUDFT_USE_MPI "Compile with MPI, will also work in serial" OFF)
option(JUDFT_USE_HDF5 "Compile HDF5 tools" OFF)
option(JUDFT_USE_HDF5MPI "Is the HDF5 version able to do parallel IO" OFF)
option(JUDFT_USE_COLLECT "Collect usage data" ON)
option(JUDFT_USE_DEBUG "Set CPP_DEBUG when compiling code" OFF)
#In addition you might want to set
#set(JUDFT_LIBRARIES "-lsomething")
#set(JUFDT_COMPILEOPTS "-r8")
if (${FLEUR_USE_HDF5}) if (${JUDFT_USE_HDF5})
set(judft_HDF set(judft_HDF
juDFT/hdf_accessprp.F90 hdf_accessprp.F90
juDFT/hdf_tools.F90 hdf_tools.F90
juDFT/hdf_tools_attr.F90 hdf_tools_attr.F90
juDFT/hdf_tools_exists.F90 hdf_tools_exists.F90
juDFT/hdf_tools_misc.F90 hdf_tools_misc.F90
juDFT/hdf_tools_rw.F90 hdf_tools_rw.F90
juDFT/hdf_tools_rw_var.F90 hdf_tools_rw_var.F90
juDFT/hdf_tools_stride.F90) hdf_tools_stride.F90)
else() else()
set(judft_HDF "") set(judft_HDF "")
endif() endif()
add_library(juDFT STATIC add_library(juDFT STATIC
${judft_HDF} ${judft_HDF}
juDFT/usage_data.F90 usage_data.F90
juDFT/info.F90 info.F90
juDFT/init.F90 init.F90
juDFT/juDFT.F90 juDFT.F90
juDFT/stop.F90 stop.F90
juDFT/string.f90 string.f90
juDFT/time.F90 time.F90
juDFT/args.F90 args.F90
juDFT/sysinfo.F90 sysinfo.F90
juDFT/check_arguments.F90 check_arguments.F90
juDFT/xmlOutput.F90 xmlOutput.F90
) )
target_compile_definitions(juDFT PUBLIC ${FLEUR_DEFINITIONS}) if (JUDFT_USE_MPI)
target_link_libraries(juDFT ${FLEUR_LIBRARIES}) target_compile_definitions(juDFT PUBLIC CPP_MPI)
target_compile_options(juDFT PUBLIC ${FLEUR_PRECISION_OPTION}) endif()
include_directories("${CMAKE_CURRENT_BINARY_DIR}/modules/juDFT") if (JUDFT_USE_HDF5)
if (${FLEUR_USE_HDF5}) target_compile_definitions(juDFT PUBLIC CPP_HDF)
target_link_libraries(juDFT "hdf5;hdf5_fortran") target_link_libraries(juDFT "hdf5;hdf5_fortran")
endif()
if (JUDFT_USE_HDF5MPI)
target_compile_definitions(juDFT PUBLIC CPP_HDFMPI)
endif() endif()
if (JUDFT_USE_COLLECT)
target_compile_definitions(juDFT PUBLIC CPP_ALLOW_USAGE_DATA)
endif()
if (JUDFT_USE_DEBUG)
target_compile_definitions(juDFT PUBLIC CPP_DEBUG)
endif()
if (DEFINED JUDFT_LIBRARIES )
target_link_libraries(juDFT ${JUDFT_LIBRARIES})
endif()
if (DEFINED JUDFT_COMPILEOPTS )
target_compile_options(juDFT PUBLIC ${JUDFT_COMPILEOPTS})
endif()
#Set module directories
include_directories("${CMAKE_CURRENT_BINARY_DIR}/modules/juDFT")
set_target_properties(juDFT PROPERTIES Fortran_MODULE_DIRECTORY modules/juDFT) set_target_properties(juDFT PROPERTIES Fortran_MODULE_DIRECTORY modules/juDFT)
...@@ -66,7 +66,7 @@ CONTAINS ...@@ -66,7 +66,7 @@ CONTAINS
#ifdef CPP_MPI #ifdef CPP_MPI
include 'mpif.h' include 'mpif.h'
LOGICAL :: first_parallel LOGICAL :: first_parallel
CALL MPI_INITALIZED(l_mpi,e) CALL MPI_INITIALIZED(l_mpi,e)
IF (l_mpi) THEN IF (l_mpi) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,e) CALL MPI_COMM_RANK(MPI_COMM_WORLD,irank,e)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD,isize,e) CALL MPI_COMM_SIZE(MPI_COMM_WORLD,isize,e)
...@@ -196,7 +196,7 @@ CONTAINS ...@@ -196,7 +196,7 @@ CONTAINS
#ifdef CPP_MPI #ifdef CPP_MPI
INCLUDE 'mpif.h' INCLUDE 'mpif.h'
INTEGER :: ierr INTEGER :: ierr
CALL MPI_INITALIZED(l_mpi,ierr) CALL MPI_INITIALIZED(l_mpi,ierr)
#endif #endif
l_endXML_local = .TRUE. l_endXML_local = .TRUE.
......
...@@ -160,7 +160,7 @@ CONTAINS ...@@ -160,7 +160,7 @@ CONTAINS
IF (.NOT. l_debug) RETURN IF (.NOT. l_debug) RETURN
if (debugtimestart < 0) debugtimestart = cputime() if (debugtimestart < 0) debugtimestart = cputime()
#ifdef CPP_MPI #ifdef CPP_MPI
CALL MPI_INITALIZED(l_mpi,ierr) CALL MPI_INITIALIZED(l_mpi,ierr)
IF (l_mpi) THEN IF (l_mpi) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, ierr) CALL MPI_COMM_RANK(MPI_COMM_WORLD, irank, ierr)
WRITE (*, "(i3,3a,f20.2,5x,a)") irank, startstop, name, " at:", cputime() - debugtimestart, memory_usage_string() WRITE (*, "(i3,3a,f20.2,5x,a)") irank, startstop, name, " at:", cputime() - debugtimestart, memory_usage_string()
...@@ -376,7 +376,7 @@ CONTAINS ...@@ -376,7 +376,7 @@ CONTAINS
#ifdef CPP_MPI #ifdef CPP_MPI
IF (l_mpi) THEN IF (l_mpi) THEN
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, isize, err) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, isize, err)
WRITE (fn, *) "Program used ", isize, " PE" WRITE (6, *) "Program used ", isize, " PE"
ENDIF ENDIF
#endif #endif
json_str = "" json_str = ""
...@@ -392,7 +392,7 @@ CONTAINS ...@@ -392,7 +392,7 @@ CONTAINS
IMPLICIT NONE IMPLICIT NONE
INTEGER :: fn, irank = 0 INTEGER :: irank = 0
LOGICAL :: l_out LOGICAL :: l_out
TYPE(t_timer), POINTER :: timer TYPE(t_timer), POINTER :: timer
#ifdef CPP_MPI #ifdef CPP_MPI
...@@ -504,7 +504,7 @@ CONTAINS ...@@ -504,7 +504,7 @@ CONTAINS
IMPLICIT NONE IMPLICIT NONE
INTEGER :: fn, irank = 0 INTEGER :: irank = 0
LOGICAL :: l_out LOGICAL :: l_out
TYPE(t_timer), POINTER :: timer, parenttimer TYPE(t_timer), POINTER :: timer, parenttimer
#ifdef CPP_MPI #ifdef CPP_MPI
......
...@@ -89,7 +89,7 @@ CONTAINS ...@@ -89,7 +89,7 @@ CONTAINS
#ifdef CPP_MPI #ifdef CPP_MPI
INCLUDE 'mpif.h' INCLUDE 'mpif.h'
LOGICAL MPI_init LOGICAL MPI_init
CALL MPI_INITALIZED(mpi_init,ierr) CALL MPI_INITIALIZED(mpi_init,ierr)
IF (mpi_init) THEN IF (mpi_init) THEN
CALL MPI_COMM_RANK(MPI_COMM_WORLD,i,ierr) CALL MPI_COMM_RANK(MPI_COMM_WORLD,i,ierr)
IF (i.NE.0) RETURN IF (i.NE.0) RETURN
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment