|
|
|
|
@ -2,11 +2,11 @@ cmake_minimum_required(VERSION 3.15)
|
|
|
|
|
project(AMGExamples Fortran)
|
|
|
|
|
|
|
|
|
|
# Installation directories (passed as CMake variables)
|
|
|
|
|
set(AMG_INSTALL_DIR "" CACHE PATH "Path to AMG installation")
|
|
|
|
|
set(AMG4PSBLAS_INSTALL_DIR "" CACHE PATH "Path to AMG installation")
|
|
|
|
|
set(PSBLAS_INSTALL_DIR "" CACHE PATH "Path to PSBLAS installation")
|
|
|
|
|
|
|
|
|
|
# Check if installation directories are set
|
|
|
|
|
if(NOT AMG_INSTALL_DIR)
|
|
|
|
|
if(NOT AMG4PSBLAS_INSTALL_DIR)
|
|
|
|
|
message(FATAL_ERROR "AMG_INSTALL_DIR must be set. Use -DAMG_INSTALL_DIR=/path/to/amg when running CMake.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
@ -14,32 +14,46 @@ if(NOT PSBLAS_INSTALL_DIR)
|
|
|
|
|
message(FATAL_ERROR "PSBLAS_INSTALL_DIR must be set. Use -DPSBLAS_INSTALL_DIR=/path/to/psblas when running CMake.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
find_package(psblas REQUIRED PATHS ${PSBLAS_INSTALL_DIR})
|
|
|
|
|
find_package(amg4psblas REQUIRED PATHS ${AMG4PSBLAS_INSTALL_DIR})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Include directories
|
|
|
|
|
include_directories(
|
|
|
|
|
"."
|
|
|
|
|
"${AMG_INSTALL_DIR}/include"
|
|
|
|
|
"${AMG_INSTALL_DIR}/modules"
|
|
|
|
|
"${AMG4PSBLAS_INSTALL_DIR}/include"
|
|
|
|
|
"${AMG4PSBLAS_INSTALL_DIR}/modules"
|
|
|
|
|
"${PSBLAS_INSTALL_DIR}/include"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Fortran module directory
|
|
|
|
|
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/modules")
|
|
|
|
|
set(FMFLAG "-I")
|
|
|
|
|
set(FMFLAG "-I")
|
|
|
|
|
|
|
|
|
|
# Library directories
|
|
|
|
|
link_directories(
|
|
|
|
|
"${AMG_INSTALL_DIR}/lib"
|
|
|
|
|
"${AMG4PSBLAS_INSTALL_DIR}/lib"
|
|
|
|
|
"${PSBLAS_INSTALL_DIR}/lib"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Libraries
|
|
|
|
|
set(AMG_LIBS psb_linsolve amg_prec psb_prec)
|
|
|
|
|
set(PSBLAS_LIBS psb_util psb_linsolve psb_prec psb_base)
|
|
|
|
|
set(AMG_LIBS amg4psblas::amgprec)
|
|
|
|
|
set(PSBLAS_LIBS psblas::util psblas::linsolve psblas::prec psblas::base)
|
|
|
|
|
|
|
|
|
|
# Executable directory
|
|
|
|
|
set(EXEDIR "${CMAKE_CURRENT_BINARY_DIR}/runs")
|
|
|
|
|
file(MAKE_DIRECTORY "${EXEDIR}")
|
|
|
|
|
|
|
|
|
|
set(COMMON_SOURCE data_input.f90)
|
|
|
|
|
|
|
|
|
|
# Source files
|
|
|
|
|
set(DFSOBJS ${COMMON_SOURCE} amg_df_sample.f90)
|
|
|
|
|
set(SFSOBJS ${COMMON_SOURCE} amg_sf_sample.f90)
|
|
|
|
|
set(CFSOBJS ${COMMON_SOURCE} amg_cf_sample.f90)
|
|
|
|
|
set(ZFSOBJS ${COMMON_SOURCE} amg_zf_sample.f90)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Source files
|
|
|
|
|
set(DGEN2D
|
|
|
|
|
amg_d_pde2d_poisson_mod.f90
|
|
|
|
|
@ -68,30 +82,33 @@ set(SGEN3D
|
|
|
|
|
|
|
|
|
|
# Define executables and their sources
|
|
|
|
|
set(amg_d_pde3d_SOURCES
|
|
|
|
|
${COMMON_SOURCE}
|
|
|
|
|
amg_d_pde3d.f90
|
|
|
|
|
amg_d_genpde_mod.f90
|
|
|
|
|
${DGEN3D}
|
|
|
|
|
data_input.f90
|
|
|
|
|
)
|
|
|
|
|
set(amg_s_pde3d_SOURCES
|
|
|
|
|
${COMMON_SOURCE}
|
|
|
|
|
amg_s_pde3d.f90
|
|
|
|
|
amg_s_genpde_mod.f90
|
|
|
|
|
${SGEN3D}
|
|
|
|
|
data_input.f90
|
|
|
|
|
)
|
|
|
|
|
set(amg_d_pde2d_SOURCES
|
|
|
|
|
${COMMON_SOURCE}
|
|
|
|
|
amg_d_pde2d.f90
|
|
|
|
|
amg_d_genpde_mod.f90
|
|
|
|
|
${DGEN2D}
|
|
|
|
|
data_input.f90
|
|
|
|
|
)
|
|
|
|
|
set(amg_s_pde2d_SOURCES
|
|
|
|
|
${COMMON_SOURCE}
|
|
|
|
|
amg_s_pde2d.f90
|
|
|
|
|
amg_s_genpde_mod.f90
|
|
|
|
|
${SGEN2D}
|
|
|
|
|
data_input.f90
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Function to create executable
|
|
|
|
|
macro(create_amg_executable target sources)
|
|
|
|
|
add_executable(${target} ${sources})
|
|
|
|
|
@ -102,11 +119,15 @@ macro(create_amg_executable target sources)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Move executable to EXEDIR (post-build)
|
|
|
|
|
add_custom_command(TARGET ${target} POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E move $<TARGET_FILE:${target}> ${EXEDIR}
|
|
|
|
|
)
|
|
|
|
|
#add_custom_command(TARGET ${target} POST_BUILD
|
|
|
|
|
# COMMAND ${CMAKE_COMMAND} -E move $<TARGET_FILE:${target}> ${EXEDIR}
|
|
|
|
|
#)
|
|
|
|
|
set_target_properties(${target} PROPERTIES
|
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${EXEDIR}
|
|
|
|
|
)
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Create executables
|
|
|
|
|
create_amg_executable(amg_d_pde3d ${amg_d_pde3d_SOURCES})
|
|
|
|
|
create_amg_executable(amg_s_pde3d ${amg_s_pde3d_SOURCES})
|
|
|
|
|
|