diff --git a/CMake-for-ppm/Core/CMakeLists.txt b/CMake-for-ppm/Core/CMakeLists.txt index f5fc86bc22e8dfbc2a1f6410be4e84d3d354c077..cdb2524478ede913f9d523d567c396f67b653366 100644 --- a/CMake-for-ppm/Core/CMakeLists.txt +++ b/CMake-for-ppm/Core/CMakeLists.txt @@ -34,7 +34,7 @@ project(${PROJECT_NAME} Fortran) # ============= Search for libraries ============= # We search for libraries ppm depends on and -# and set the compile/link conf (-I and -L opt) +# set the compile/link conf (-I and -L opt) # ---- Metis ---- if(USE_Metis) @@ -111,7 +111,7 @@ else(Fortran_HAVE_ffree_form) endif(Fortran_HAVE_free) endif(Fortran_HAVE_ffree_form) append_Fortran_FLAGS(${Fortran_Free_Flag}) -append_Fortran_FLAGS("-cpp -w") +append_Fortran_FLAGS("-cpp -w -fPIC") # ============= Generates ppm_define.h ============= # The file ppm_define.h will be generated from config.h.cmake; @@ -122,6 +122,7 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) configure_file(config.h.cmake src/ppm_define.h) endif(NOT CONFIG_H_GLOBAL_CONFIGURED) include_directories(${CMAKE_BINARY_DIR}/src) + list(APPEND ${PROJECT_NAME}_HDRS ${CMAKE_BINARY_DIR}/src/ppm_define.h) endif(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) # ============= Source and header files list ============= @@ -145,6 +146,8 @@ foreach(_DIR ${${PROJECT_NAME}_SRCDIRS}) endforeach(_EXT ${EXTS_HDRS}) endforeach(_DIR ${${PROJECT_NAME}_SRCDIRS}) + + # -I include_directories(${${PROJECT_NAME}_SRCDIRS}) include_directories(${CMAKE_Fortran_MODULE_DIRECTORY}) @@ -165,6 +168,12 @@ endif(${PROJECT_NAME}_LINK_FLAGS) # The var LIBS must have been filled during 'find_package' process (for MPI, Metis ...) target_link_libraries(${PROJECT_LIBRARY_NAME} ${LIBS}) +# ============= Install ============= +# The library, the headers and mod files, the cmake generated files +# will be install in CMAKE_INSTALL_PREFIX/lib include and share +include(InstallPackage) +install_package(${PACKAGE_NAME} ${PROJECT_LIBRARY_NAME} ${PROJECT_NAME}_HDRS) + # ============= RPATH ============= # Concerning rpath see for example http://www.itk.org/Wiki/CMake_RPATH_handling @@ -179,13 +188,8 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -# ============= Install ============= -# The library, the headers and mod files, the cmake generated files -# will be install in CMAKE_INSTALL_PREFIX/lib include and share -include(InstallPackage) -install_package(${PACKAGE_NAME} ${PROJECT_LIBRARY_NAME} ${${PROJECT_NAME}_HDRS}) - # ============= Summary ============= +get_target_property(PROJECT_LIBRARY_FULL_NAME ${PROJECT_LIBRARY_NAME} LOCATION) if(VERBOSE_MODE) message(STATUS "====================== Summary ======================") message(STATUS " Compiler : ${CMAKE_Fortran_COMPILER}") @@ -193,5 +197,6 @@ if(VERBOSE_MODE) message(STATUS " Project uses MPI : ${USE_MPI}") message(STATUS " Project uses Metis : ${USE_Metis}") message(STATUS " Project will be installed in ${CMAKE_INSTALL_PREFIX}") + message(STATUS " Build library : ${PROJECT_LIBRARY_FULL_NAME}") message(STATUS "====================== ======= ======================") endif() diff --git a/CMake-for-ppm/Core/PPMCoreConfig.cmake.in b/CMake-for-ppm/Core/PPMCoreConfig.cmake.in index 75568772ef218209701e2d7146234769b701dbe1..b3997ef70e72915c589d94a27fb93df6bf7b7054 100644 --- a/CMake-for-ppm/Core/PPMCoreConfig.cmake.in +++ b/CMake-for-ppm/Core/PPMCoreConfig.cmake.in @@ -1,37 +1,44 @@ -# - config file for ppmcore package +# - config file for @PACKAGE_NAME@ package # Written by F. Pérignon, 2011 march # -# This file generates PPCore-config.cmake, that may be used by another cmake project -# to retrieve all the configuration variables from ppmcore. -# For example, PPMNumerics will include this file to set options (use_mpi, use_metis ...) or to find ppmcore lib, headers and modules. +# This file generates @PACKAGE_NAME@Config.cmake, that may be used by another cmake project +# to retrieve all the configuration variables from @PACKAGE_NAME@. +# For example, PPMNumerics will include this file to set options (use_mpi, use_metis ...) or to find @PACKAGE_NAME@ lib, headers and modules. # # It defines the following variables # -# @PACKAGE_NAME@_INCLUDE_DIRS - include directories for ppmcore +# @PACKAGE_NAME@_INCLUDE_DIR - include directory for @PACKAGE_NAME@ # @PACKAGE_NAME@_EXTRA_INCLUDE_DIRS - path to extra headers needed for @PACKAGE_NAME@ (metis.h ...) -# @PACKAGE_NAME@_LIBRARY_DIRS - path to @PACKAGE_NAME@ library(ies) -# @PACKAGE_NAME@_LIBRARIES - libraries to link against to use ppmcore +# @PACKAGE_NAME@_INCLUDE_DIRS - All include directories for @PACKAGE_NAME@ (concat of INCLUDE_DIR et EXTRA_INCLUDE_DIRS) +# @PACKAGE_NAME@_LIBRARY_DIRS - path to @PACKAGE_NAME@ library +# @PACKAGE_NAME@_LIBRARY - @LIBRARY_PROJECT_NAME@ library (full path) # @PACKAGE_NAME@_USE_XXX - value of option "USE_XXX" (for example USE_MPI, USE_Metis ... = ON or OFF) -# Tell the user where to find ppmcore headers +# Tell the user where to find @PACKAGE_NAME@ headers # Tell the user project where to find our headers and libraries -set(@PACKAGE_NAME@_INCLUDE_DIRS "${${PACKAGE_NAME}_INCLUDE_DIRS}") +set(@PACKAGE_NAME@_INCLUDE_DIR "${${PACKAGE_NAME}_INCLUDE_DIRS}" "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules" ) set(@PACKAGE_NAME@_EXTRA_INCLUDE_DIRS "${${PACKAGE_NAME}_EXTRA_INCLUDE_DIRS}") +set(@PACKAGE_NAME@_INCLUDE_DIRS "${${PACKAGE_NAME}_INCLUDE_DIRS}" "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules" "${${PACKAGE_NAME}_EXTRA_INCLUDE_DIRS}") set(@PACKAGE_NAME@_LIBRARY_DIRS "${${PACKAGE_NAME}_LIB_DIR}") -set(@PACKAGE_NAME@_MODULE_DIR "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules") + +#set(@PACKAGE_NAME@_MODULE_DIR "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules") # Our library dependencies (contains definitions for IMPORTED targets) include("${${PACKAGE_NAME}_CMAKE_DIR}/@PACKAGE_NAME@LibraryDepends.cmake") -# These are IMPORTED targets created by FooBarLibraryDepends.cmake -set(@PACKAGE_NAME@_LIBRARIES @PROJECT_LIBRARY_NAME@) +# These are IMPORTED targets created by @PACKAGE_NAME@LibraryDepends.cmake +set(@PACKAGE_NAME@_LIB_NAME "@PROJECT_LIBRARY_NAME@") +get_target_property(@PACKAGE_NAME@_LIBRARY @PROJECT_LIBRARY_NAME@ LOCATION) # Set all @PACKAGE_NAME@ options set(@PACKAGE_NAME@_USE_MPI @USE_MPI@) set(@PACKAGE_NAME@_USE_Metis @USE_Metis@) +set(@PACKAGE_NAME@_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) # Set var for compilers used by @PACKAGE_NAME@ set(@PACKAGE_NAME@_Fortran_COMPILER @CMAKE_Fortran_COMPILER@) # Fortran flags set(@PACKAGE_NAME@_Fortran_FLAGS @CMAKE_Fortran_FLAGS@) + + diff --git a/CMake-for-ppm/Core/PPMCoreConfigVersion.cmake.in b/CMake-for-ppm/Core/PPMCoreConfigVersion.cmake.in index 9118c9a37e23f591c67b9c7973f321973799a308..75641507e3fc025c2e940002e3838ac290bee349 100644 --- a/CMake-for-ppm/Core/PPMCoreConfigVersion.cmake.in +++ b/CMake-for-ppm/Core/PPMCoreConfigVersion.cmake.in @@ -1,6 +1,5 @@ set(PACKAGE_VERSION "@PPMCore_version@") - # Check whether the requested PACKAGE_FIND_VERSION is compatible if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") set(PACKAGE_VERSION_COMPATIBLE FALSE) diff --git a/CMake-for-ppm/Core/PPMCoreSettings.cmake b/CMake-for-ppm/Core/PPMCoreSettings.cmake index 024e9a1816fd5e0697b5f8117889edf3221ddfd1..a76c9306e53d4d235d2b731eaf260ea3b7cc105b 100644 --- a/CMake-for-ppm/Core/PPMCoreSettings.cmake +++ b/CMake-for-ppm/Core/PPMCoreSettings.cmake @@ -15,9 +15,8 @@ option(VERBOSE_MODE "enable verbose mode for cmake exec" ON) option(USE_MPI "enable mpi for ppm_core, default = on " ON) option(USE_Metis "enable metis for ppm_core, default = on" ON) +option(BUILD_SHARED_LIBS "Enable dynamic library build, default = OFF" OFF) -# --- default library type (shared or static) --- -set(BUILD_SHARED_LIBS ON) # --- Name of the current project --- set(PROJECT_NAME ppm_core) # --- Name for the package --- @@ -30,7 +29,7 @@ set(PROJECT_LIBRARY_NAME ${PROJECT_NAME}) # --- The list of all dirs containing sources to be compiled for the PPMCore library --- set(${PROJECT_NAME}_SRCDIRS src) # --- Matching expr for files to be compiled. --- -set(EXTS ppm_module*.f *.h *.f90) +set(EXTS ppm_module*.f) # --- Matching expr for headers to be installed --- set(EXTS_HDRS *.h) # Note FP : we can also use cmake vars ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} ${CMAKE_C_SOURCE_FILE_EXTENSIONS} ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} diff --git a/CMake-for-ppm/Numerics/CMakeLists.txt b/CMake-for-ppm/Numerics/CMakeLists.txt index 5b6dcdea04745753a4c9f22555e7b9ec857f7c7e..54d21ff8ccf53c7178fcbbe3bacba4d227656ba2 100644 --- a/CMake-for-ppm/Numerics/CMakeLists.txt +++ b/CMake-for-ppm/Numerics/CMakeLists.txt @@ -40,29 +40,18 @@ project(${PROJECT_NAME} Fortran) # We need the file "PPMCoreConfig.cmake generated during PPMCore install. # If not in a standard place, user may use "-DPPMCore_DIR=PAth_to/PPMCoreConfig.cmake during cmake call -find_package(PPMCore 1.2 REQUIRED) +find_package(PPMCore ${${PROJECT_NAME}_version} REQUIRED) # Search for and Read PPMCoreConfig.cmake and PPMCoreConfigVersion.cmake. # It results in a set of all the PPMCore related variables. +include_directories(${PPMCore_INCLUDE_DIRS}) +set(LIBS ${LIBS} ${PPMCore_LIBRARY}) if(VERBOSE_MODE) - if(PPMCore_FOUND) - message(STATUS "Found PPMCore config file: ${PPMCore_CONFIG}") - message(STATUS " PPMCore version: ${PACKAGE_VERSION}") - message(STATUS " PPMCore library: ${PPMCore_LIBRARIES}") - message(STATUS " PPMCore modules: ${PPMCore_MODULE_DIR}") - message(STATUS " PPMCore headers: ${PPMCore_INCLUDE_DIRS}") - message(STATUS " PPMCore extra headers: ${PPMCore_EXTRA_INCLUDE_DIRS}") - message(STATUS " Fortran compiler for PPMCore was ${PPMCore_Fortran_COMPILER}".) - endif(PPMCore_FOUND) + message(STATUS "Found PPM version ${PPMCore_VERSION}: ${PPMCore_LIBRARY}") + message(STATUS " Fortran compiler for PPMCore was ${PPMCore_Fortran_COMPILER}".) endif(VERBOSE_MODE) -# Set include directories according to PPMCore -# -I -include_directories(${PPMCore_INCLUDE_DIRS}) -include_directories(${PPMCore_EXTRA_INCLUDE_DIRS}) -include_directories(${PPMCore_MODULE_DIR}) -# Set libraries to be linked with -# -l -set(LIBS ${LIBS} ${PPMCore_LIBRARIES}) +# Choose static or dynamic lib for ppmnumerics, accordingly to ppmcore. +set(BUILD_SHARED_LIBS PPMCore_BUILD_SHARED_LIBS) # PPMCore options set(USE_MPI ${PPMCore_USE_MPI}) @@ -71,7 +60,7 @@ set(CMAKE_Fortran_COMPILER ${PPMCore_Fortran_COMPILER}) # Set options that will be used to generate ppm_define.h if(USE_Metis) - set(__Metis 1) + set(__METIS 1) endif() # set __Linux var in ppm_define.h depending on the OS @@ -105,6 +94,7 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) configure_file(config.h.cmake src/ppm_define.h) endif(NOT CONFIG_H_GLOBAL_CONFIGURED) include_directories(${CMAKE_BINARY_DIR}/src) + list(APPEND ${PROJECT_NAME}_HDRS ${CMAKE_BINARY_DIR}/src/ppm_define.h) endif(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) # ============= Prepare compilation ============= @@ -113,7 +103,6 @@ endif(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake) # CMAKE_BUILD_TYPE = empty, Debug, Release, RelWithDebInfo or MinSizeRel. if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None, Debug, Release, RelWithDebInfo or MinSizeRel." FORCE) - display(CMAKE_BUILD_TYPE) endif (NOT CMAKE_BUILD_TYPE) # If the project uses Fortran ... @@ -124,7 +113,6 @@ set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules) include(TestFortranAcceptsFlag) # Try -ffree-form option (GNU) CHECK_Fortran_ACCEPTS_FLAG(-ffree-form Fortran_HAVE_ffree_form) -display(Fortran_HAVE_ffree_form) if(Fortran_HAVE_ffree_form) set(Fortran_Free_Flag "-ffree-form") @@ -163,6 +151,7 @@ foreach(_DIR ${${PROJECT_NAME}_SRCDIRS}) endforeach(_EXT ${EXTS_HDRS}) endforeach(_DIR ${${PROJECT_NAME}_SRCDIRS}) + # -I include_directories(${${PROJECT_NAME}_SRCDIRS}) include_directories(${CMAKE_Fortran_MODULE_DIRECTORY}) @@ -201,9 +190,11 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # The library, the headers and mod files, the cmake generated files # will be install in CMAKE_INSTALL_PREFIX/lib include and share include(InstallPackage) -install_package(${PACKAGE_NAME} ${PROJECT_LIBRARY_NAME} ${${PROJECT_NAME}_HDRS}) + +install_package(${PACKAGE_NAME} ${PROJECT_LIBRARY_NAME} ${PROJECT_NAME}_HDRS) # ============= Summary ============= +get_target_property(PROJECT_LIBRARY_FULL_NAME ${PROJECT_LIBRARY_NAME} LOCATION) if(VERBOSE_MODE) message(STATUS "====================== Summary ======================") message(STATUS " Compiler : ${CMAKE_Fortran_COMPILER}") @@ -212,5 +203,6 @@ if(VERBOSE_MODE) message(STATUS " Project uses Metis : ${USE_Metis}") message(STATUS " Project uses FFTW : ${USE_FFTW}") message(STATUS " Project will be installed in ${CMAKE_INSTALL_PREFIX}") + message(STATUS " Build library : ${PROJECT_LIBRARY_FULL_NAME}") message(STATUS "====================== ======= ======================") endif() \ No newline at end of file diff --git a/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in b/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in index ec02fc620bffb4ef79df60eff1a66eda714f8edf..465382377c118955c754ae63421c8f0c9059d16b 100644 --- a/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in +++ b/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in @@ -1,9 +1,8 @@ # - config file for @PACKAGE_NAME@ package # Written by F. Pérignon, 2011 march # -# This file generates PPCore-config.cmake, that may be used by another cmake project -# to retrieve all the configuration variables from ppmcore. -# For example, PPMNumerics will include this file to set options (use_mpi, use_metis ...) or to find ppmcore lib, headers and modules. +# This file generates @PACKAGE_NAME@Config.cmake, that may be used by another cmake project +# to retrieve all the configuration variables from @PACKAGE_NAME@ # # It defines the following variables # @@ -15,16 +14,17 @@ # Tell the user where to find ppmcore headers # Tell the user project where to find our headers and libraries -set(@PACKAGE_NAME@_INCLUDE_DIRS "${${PACKAGE_NAME}_INCLUDE_DIRS}") +set(@PACKAGE_NAME@_INCLUDE_DIR "${${PACKAGE_NAME}_INCLUDE_DIRS}" "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules" ) set(@PACKAGE_NAME@_EXTRA_INCLUDE_DIRS "${${PACKAGE_NAME}_EXTRA_INCLUDE_DIRS}") +set(@PACKAGE_NAME@_INCLUDE_DIRS "${${PACKAGE_NAME}_INCLUDE_DIRS}" "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules" "${${PACKAGE_NAME}_EXTRA_INCLUDE_DIRS}") set(@PACKAGE_NAME@_LIBRARY_DIRS "${${PACKAGE_NAME}_LIB_DIR}") -set(@PACKAGE_NAME@_MODULE_DIR "${${PACKAGE_NAME}_INCLUDE_DIRS}/Modules") # Our library dependencies (contains definitions for IMPORTED targets) include("${${PACKAGE_NAME}_CMAKE_DIR}/@PACKAGE_NAME@LibraryDepends.cmake") -# These are IMPORTED targets created by FooBarLibraryDepends.cmake -set(@PACKAGE_NAME@_LIBRARIES @PROJECT_LIBRARY_NAME@) +# These are IMPORTED targets created by @PACKAGE_NAME@LibraryDepends.cmake +set(@PACKAGE_NAME@_LIB_NAME "@PROJECT_LIBRARY_NAME@") +get_target_property(@PACKAGE_NAME@_LIBRARY @PROJECT_LIBRARY_NAME@ LOCATION) # Set all @PACKAGE_NAME@ options set(@PACKAGE_NAME@_USE_MPI @USE_MPI@) @@ -38,3 +38,7 @@ set(@PACKAGE_NAME@_Fortran_COMPILER @CMAKE_Fortran_COMPILER@) # Fortran flags set(@PACKAGE_NAME@_Fortran_FLAGS @CMAKE_Fortran_FLAGS@) + +# PPMCore dir and others. Useless? +set(PPMCore_DIR @PPMCore_DIR@) +set(PPMCore_MODULE_DIR @PPMCore_MODULE_DIR@) \ No newline at end of file diff --git a/CMake-for-ppm/Numerics/PPMNumericsConfigVersion.cmake.in b/CMake-for-ppm/Numerics/PPMNumericsConfigVersion.cmake.in index f5b061e44c77f70b02abe643c855a482d7f74e26..31a4cdf1c248492d3fd7123ceed092a2d939afe4 100644 --- a/CMake-for-ppm/Numerics/PPMNumericsConfigVersion.cmake.in +++ b/CMake-for-ppm/Numerics/PPMNumericsConfigVersion.cmake.in @@ -1,5 +1,4 @@ set(PACKAGE_VERSION "@PPMNumerics_version@") - # Check whether the requested PACKAGE_FIND_VERSION is compatible if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") diff --git a/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake b/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake index 0d6ac19dce58237957d3b769c12de2787b09a72e..c90274b957e7e34a2787d729b3681805bc0c41e9 100644 --- a/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake +++ b/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake @@ -24,8 +24,6 @@ option(USE_NOMICROINSTRUCTION "microinstruction mode (?), default = OFF" OFF) # Note that some other options (such as USE_Metis, USE_MPI ...) will be read from PPMCore config. -# --- default library type (shared or static) --- -set(BUILD_SHARED_LIBS ON) # --- Name of the current project --- set(PROJECT_NAME ppm_numerics) # --- Name for the package --- @@ -38,7 +36,7 @@ set(PROJECT_LIBRARY_NAME ${PROJECT_NAME}) # --- The list of all dirs containing sources to be compiled for the PPMCore library --- set(${PROJECT_NAME}_SRCDIRS src) # --- Matching expr for files to be compiled. --- -set(EXTS ppm_module*.f *.h *.f90) +set(EXTS ppm_module*.f *.f90) # --- Matching expr for headers to be installed --- set(EXTS_HDRS *.h) # Note FP : we can also use cmake vars ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} ${CMAKE_C_SOURCE_FILE_EXTENSIONS} ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} diff --git a/CMake/CMakeListsForTests.cmake b/CMake/CMakeListsForTests.cmake index ac99db3f20790de0a97e9a4f93c947110fe14755..fe7c3531df90dacd73891a23cce2dfe2963e97bd 100644 --- a/CMake/CMakeListsForTests.cmake +++ b/CMake/CMakeListsForTests.cmake @@ -9,11 +9,11 @@ foreach(_EXE ${_EXE_LIST_${_CURRENT_TEST_DIRECTORY}}) # Create an executable for the current test add_executable(${_EXE} ${${_EXE}_FSOURCES}) - - # Add a dependency between current test and the main target (i.e. main project) - add_dependencies(${_EXE} ${PROJECT_NAME}) + + # Add a dependency between current test and the main library target + add_dependencies(${_EXE} ${PROJECT_LIBRARY_NAME}) # link current target test with the same lib as for main project lib - target_link_libraries(${_EXE} ${PROJECT_NAME}_shared) + target_link_libraries(${_EXE} ${PROJECT_LIBRARY_NAME}) target_link_libraries(${_EXE} ${LIBS}) # add test for ctest diff --git a/CMake/FindPPMNumerics.cmake b/CMake/FindPPMNumerics.cmake deleted file mode 100644 index 2c89f80b60215997e5860b34f08a11dd4d777b5e..0000000000000000000000000000000000000000 --- a/CMake/FindPPMNumerics.cmake +++ /dev/null @@ -1,45 +0,0 @@ -# - Try to find ppmnumerics library -# Once done, this will define -# -# PPMNumerics_FOUND - system has ppm_numerics -# PPMNumerics_INCLUDE_DIRS - the ppm_numerics include directories -# PPMNumerics_LIBRARIES - link these to use ppm_numerics -# -# LJK, Franck Perignon, jan. 2011 -# -# -include(LibFindMacros) - -# Dependencies -libfind_package(PPMNumerics PPMCore) - -# Use pkg-config to get hints about paths -libfind_pkg_check_modules(PPMNumerics_PKGCONF PPMNumerics) - -# Modules and headers location -find_path( - PPMNumerics_MODULES_DIR - NAMES ppm_module_alloc.mod - PATHS ENV INCLUDE ENV PATH ${PPMNumerics_PKGCONF_INCLUDE_DIRS} -) - -find_path( - PPMNumerics_INCLUDE_DIR - NAMES ppm_error.h - PATHS ENV INCLUDE ENV PATH ${PPMNumerics_PKGCONF_INCLUDE_DIRS} -) - -# Finally the library itself -find_library( - PPMNumerics_LIBRARY - NAMES ppmcore - PATHS ${PPMNumerics_PKGCONF_LIBRARY_DIRS} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH - ) - -if(PPMNumerics_INCLUDE_DIR AND PPMNumerics_MODULES_DIR) - set(PPMNumerics_INCLUDE_DIR ${PPMNumerics_INCLUDE_DIR} ${PPMNumerics_MODULES_DIR}) -endif(PPMNumerics_INCLUDE_DIR AND PPMNumerics_MODULES_DIR) - -set(PPMNumerics_PROCESS_INCLUDES PPMNumerics_INCLUDE_DIR) -set(PPMNumerics_PROCESS_LIBS PPMNumerics_LIBRARY) -libfind_process(PPMNumerics) diff --git a/CMake/InstallPackage.cmake b/CMake/InstallPackage.cmake index 39063be8dd0a7f59e33a80405a0ae2e5a31589fa..403e44eccc5b297caee2b1557d1fcbbd4cac131e 100644 --- a/CMake/InstallPackage.cmake +++ b/CMake/InstallPackage.cmake @@ -1,11 +1,13 @@ #=========================================================== -# Macro to install a package (ppmcore or ppmnumerics indeed) +# Macro to install a package # # F. Pérignon, LJK-CNRS, april 2011 # #=========================================================== -macro(install_package _PACK _LIB_NAME _HEADERS) +macro(install_package _PACK _LIB_NAME _HEADERSLIST) + + set(_HEADERS ${${_HEADERSLIST}}) # Offer the user the choice of overriding the installation directories set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") @@ -33,6 +35,7 @@ macro(install_package _PACK _LIB_NAME _HEADERS) # The headers and modules install(FILES ${_HEADERS} DESTINATION "${INSTALL_INCLUDE_DIR}") + install(DIRECTORY ${CMAKE_BINARY_DIR}/Modules DESTINATION "${INSTALL_INCLUDE_DIR}") export(TARGETS ${_LIB_NAME} FILE "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}LibraryDepends.cmake") diff --git a/HySoP/CMakeLists.txt b/HySoP/CMakeLists.txt index a7fc758b5245f0935303ee7e52539fa312cc5d61..71c2db0426cbbced648c67da0bb84d712f172a9c 100644 --- a/HySoP/CMakeLists.txt +++ b/HySoP/CMakeLists.txt @@ -17,15 +17,51 @@ include(OutOfSourceBuild) # Some usefull macros include(MyTools) +# ============= Specific settings for PPMCore ============= +# In this file (PPMCoreSettings.cmake) we set all variables +# required to compile and install PPMCore such as the name of +# the library to be created, the place where we can find the sources, +# the version number of the current package ... + # User defined options option(VERBOSE_MODE "enable verbose mode for cmake exec. Default = on" ON) -option(WITH_PPM "link parmes with ppm when this mode is enable. Default = on." ON) -option(WITH_MPI "compile and link parmes with mpi when this mode is enable. Default = on." ON) +option(USE_PPM "link parmes with ppm when this mode is enable. Default = on." ON) +option(USE_MPI "compile and link parmes with mpi when this mode is enable. Default = on." ON) +option(USE_PPM "link Parmes with PPM library (core component). Default = on." ON) +option(USE_PPMNumerics "link Parmes with PPM-numerics. Default = off" OFF) option(DOUBLEPREC "set precision for real numbers to double precision when this mode is enable. Default = on." ON) option(WITH_TESTS "Enable testing. Default = on" ON) +option(BUILD_SHARED_LIBS "Enable dynamic library build, default = ON" ON) + +# cmake project name +set(PROJECT_NAME parmes) +# --- Name for the package --- +# This name will be used to install Parmes (library, headers, ...) and when another lib or soft will need to search for Parmes. +set(PACKAGE_NAME "Parmes") +# --- Set a version number for the package --- +set(${PACKAGE_NAME}_version 1.0.0) +# --- The name (without extension) of the lib to be created --- +set(PROJECT_LIBRARY_NAME ${PROJECT_NAME}) +# --- The name of the exe to be created (test purpose) +# This exe will be linked with libPROJECT_LIBRARY_NAME +set(EXE_NAME ${PROJECT_NAME}Run) +# The list of all dirs containing sources to be compiled for the Parmes lib +# Any file in those dirs will be used to create libparmes +set(${PROJECT_LIBRARY_NAME}_SRCDIRS + src + src/interfaces/Fortran2Cpp + src/interfaces/ppm + ) +# A main file to create an executable (test purpose) +# Any files in these dirs will be used to create Parmes exec (linked with libparmes) +set(${EXE_NAME}_SRCDIRS src/main) +# Matching expr for files to be compiled. +set(EXTS *.cxx *.f90 *.f95) +# Matching expr for headers (install purpose) +set(EXTS_HDRS *.hpp *.h) +# Note FP : we can also use cmake vars ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} ${CMAKE_C_SOURCE_FILE_EXTENSIONS} ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} + -# default library type -set(BUILD_SHARED_LIBS 1) # ============= The project ============= # Set project name and project languages @@ -33,40 +69,24 @@ set(BUILD_SHARED_LIBS 1) # - ${PROJECT_NAME}_BINARY_DIR : where you have run cmake, i.e. the place for compilation # - ${PROJECT_NAME}_SOURCE_DIR : where sources (.f and .h and this CMakeLists.txt) are located # Note that because of OutOfSourceBuild, binary_dir and source_dir must be different. -set(PROJECT_NAME Parmes) + project(${PROJECT_NAME} CXX C Fortran) -# Set a version number for the project -set(${PROJECT_NAME}_version 1.0.0) # ============= Tests ============= if(WITH_TESTS) enable_testing() endif(WITH_TESTS) -# ============= Prepare compilation ============= - -# Force a default build type if not provided by user -# CMAKE_BUILD_TYPE = empty, Debug, Release, RelWithDebInfo or MinSizeRel. -if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None, Debug, Release, RelWithDebInfo or MinSizeRel." FORCE) - display(CMAKE_BUILD_TYPE) -endif (NOT CMAKE_BUILD_TYPE) +# ============= Search for libraries ============= +# We search for libraries Parmes depends on and +# set the compile/link conf (-I and -L opt) -# If the project uses Fortran ... -# Set module files directory (i.e. where .mod will be created) -set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules) -# Add compilation flags: -append_Fortran_FLAGS("-Wall") - -# -------------------------------------------- -# Find libraries on which parmes depends. -# -------------------------------------------- -# Find Boost +# --- Boost --- find_package(Boost REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) -# MPI -if(WITH_MPI) +# --- MPI --- +if(USE_MPI) # Find MPI for C++ and fortran. find_package(MPI REQUIRED) find_package(MPI_Fortran REQUIRED) @@ -91,93 +111,135 @@ if(WITH_MPI) endif(MPI_Fortran_COMPILER) set(LIBS ${LIBS} ${MPI_LIBRARIES} ${MPI_Fortran_LIBRARIES} ) -endif(WITH_MPI) -# Find PPM Core -if(WITH_PPM) - find_package(PPMCore REQUIRED) +endif(USE_MPI) + +# --- PPM Core --- +if(USE_PPM) + find_package(PPMCore 1.2 REQUIRED) include_directories(${PPMCore_INCLUDE_DIRS}) - set(LIBS ${LIBS} ${PPMCore_LIBRARIES}) - + set(LIBS ${LIBS} ${PPMCore_LIBRARY}) + if(VERBOSE_MODE) + message(STATUS "Found PPM version ${PPMCore_VERSION}: ${PPMCore_LIBRARY}") + message(STATUS "PPM headers location: ${PPMCore_INCLUDE_DIRS}") + endif(VERBOSE_MODE) +endif() + +# --- PPM Numerics --- +if(USE_PPMNumerics) + find_package(PPMNumerics 1.2 REQUIRED) + include_directories(${PPMNumerics_INCLUDE_DIRS}) +# include_directories(${PPMNumerics_MODULE_DIR}) + set(LIBS ${LIBS} ${PPMNumerics_LIBRARY}) if(VERBOSE_MODE) - display(Metis_INCLUDE_DIRS) - display(Metis_LIBRARIES) - display(PPMCore_INCLUDE_DIRS) - display(PPMCore_LIBRARIES) + message(STATUS "Found PPMNumerics version ${PPMNUmerics_VERSION}: ${PPMNumerics_LIBRARY}") + message(STATUS "PPMNumerics header location: ${PPMNumerics_INCLUDE_DIRS}") endif(VERBOSE_MODE) -endif(WITH_PPM) -# ---------------------- -# Generate ParmesConfig.hpp +endif() + +# ============= Prepare compilation ============= + +# Force a default build type if not provided by user +# CMAKE_BUILD_TYPE = empty, Debug, Release, RelWithDebInfo or MinSizeRel. +if (NOT CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None, Debug, Release, RelWithDebInfo or MinSizeRel." FORCE) +endif (NOT CMAKE_BUILD_TYPE) + +# If the project uses Fortran ... +# Set module files directory (i.e. where .mod will be created) +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules) +# Add compilation flags: +append_Fortran_FLAGS("-Wall") + +# ============= Generates ParmesConfig.hpp ============= +# The file PROJECT_NAME_defines.hpp will be generated from config.hpp.cmake; if(EXISTS ${CMAKE_SOURCE_DIR}/config.hpp.cmake) if(NOT CONFIG_H_GLOBAL_CONFIGURED) - set(CONFIG_H_GLOBAL_CONFIGURED 1 CACHE BOOL "ParmesConfig.hpp generation." ) - configure_file(config.hpp.cmake ${PROJECT_NAME}Config.hpp) - endif(NOT CONFIG_H_GLOBAL_CONFIGURED) + set(CONFIG_H_GLOBAL_CONFIGURED 1 CACHE BOOL "Parmes_defines.hpp generation." ) + configure_file(config.hpp.cmake ${PROJECT_NAME}_defines.hpp) + endif() include_directories(${CMAKE_BINARY_DIR}) -endif(EXISTS ${CMAKE_SOURCE_DIR}/config.hpp.cmake) - -# -------------------------------------------- -# Create executable or lib -# -------------------------------------------- -# The list of all dirs containing sources to be compiled for the Parmes lib -set(${PROJECT_NAME}_SRCDIRS - src - src/interfaces/Fortran2Cpp - src/interfaces/ppm - ) +endif() -# A main file to create an executable (test purpose) -set(${PROJECT_NAME}_MAINSRCDIRS - src/main - ) +# ============= Source and header files list ============= +# We scan all files with matching extension in directories +# containing sources. -# Matching expr for files to be compiled. -set(EXTS *.cxx *.hpp *.h *.f90 *.f95) -# Note FP : we can also use cmake vars ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} ${CMAKE_C_SOURCE_FILE_EXTENSIONS} ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} -# Source files list: -foreach(_DIR ${${PROJECT_NAME}_SRCDIRS}) +# Source and header files list: +foreach(_DIR ${${PROJECT_LIBRARY_NAME}_SRCDIRS}) set(_DIR_FILES) - foreach(_EXT ${EXTS}) + foreach(_EXT ${EXTS}) # Source files + file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) + if(_DIR_FILES_EXT) + list(APPEND ${PROJECT_LIBRARY_NAME}_SRC ${_DIR_FILES_EXT}) + endif() + endforeach() + foreach(_EXT ${EXTS_HDRS}) # Headers file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) if(_DIR_FILES_EXT) - list(APPEND ${PROJECT_NAME}_SRC ${_DIR_FILES_EXT}) - endif(_DIR_FILES_EXT) - endforeach(_EXT ${EXTS}) -endforeach(_DIR ${${PROJECT_NAME}_SRCDIRS}) + list(APPEND ${PROJECT_LIBRARY_NAME}_HDRS ${_DIR_FILES_EXT}) + endif() + endforeach() +endforeach() +# We add headers to source files +list(APPEND ${PROJECT_LIBRARY_NAME}_SRC ${${PROJECT_LIBRARY_NAME}_HDRS}) -foreach(_DIR ${${PROJECT_NAME}_MAINSRCDIRS}) +# The same for main dir ... +foreach(_DIR ${${EXE_NAME}_SRCDIRS}) set(_DIR_FILES) foreach(_EXT ${EXTS}) file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) if(_DIR_FILES_EXT) - list(APPEND ${PROJECT_NAME}_MAINSRC ${_DIR_FILES_EXT}) - endif(_DIR_FILES_EXT) - endforeach(_EXT ${EXTS}) -endforeach(_DIR ${${PROJECT_NAME}_MAINSRCDIRS}) + list(APPEND ${EXE_NAME}_SRC ${_DIR_FILES_EXT}) + endif() + endforeach() + foreach(_EXT ${EXTS_HDRS}) + file(GLOB _DIR_FILES_EXT ${_DIR}/${_EXT}) + if(_DIR_FILES_EXT) + list(APPEND ${EXE_NAME}_HDRS ${_DIR_FILES_EXT}) + endif() + endforeach() +endforeach() +list(APPEND ${EXE_NAME}_SRC ${${EXE_NAME}_HDRS}) +# Add directories to those searched by compiler ... # -I -include_directories(${${PROJECT_NAME}_SRCDIRS}) +include_directories(${${PROJECT_LIBRARY_NAME}_SRCDIRS}) +include_directories(${${EXE_NAME}_HDRS}) include_directories(${CMAKE_Fortran_MODULE_DIRECTORY}) +# Cmake tools to handle fortran-c interface. It will generate F2CMangle.hpp, a file +# that will contain some useful macros to deal with fortran-C name mangling. +# See cmake doc for this module. include(FortranCInterface) -FortranCInterface_HEADER(${CMAKE_Fortran_MODULE_DIRECTORY}/FCMangle.h - MACRO_NAMESPACE "PPM_" - SYMBOL_NAMESPACE "PPM_" - SYMBOLS init testPPM:init) - -# Create the Parmes Library -add_library(${PROJECT_NAME}_shared ${${PROJECT_NAME}_SRC}) - -# Creates the executable -add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_MAINSRC}) -add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_shared) -target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_shared) -target_link_libraries(${PROJECT_NAME} ${LIBS}) +FortranCInterface_HEADER(${CMAKE_Fortran_MODULE_DIRECTORY}/F2CMangle.hpp + MACRO_NAMESPACE "F2C_" + SYMBOL_NAMESPACE "F2C_") + +# ============= Creates the library ============= +if(BUILD_SHARED_LIBS) # shared library + add_library(${PROJECT_LIBRARY_NAME} SHARED ${${PROJECT_LIBRARY_NAME}_SRC}) +else() # static library + add_library(${PROJECT_LIBRARY_NAME} STATIC ${${PROJECT__LIBRARY_NAME}_SRC}) +endif() +# Libs to link with PROJECT__LIBRARY_NAME +target_link_libraries(${PROJECT_LIBRARY_NAME} ${LIBS}) + +# ============= Creates the executable ============= +add_executable(${EXE_NAME} ${${EXE_NAME}_SRC}) +add_dependencies(${EXE_NAME} ${PROJECT_LIBRARY_NAME}) + +# libs to link with EXE_NAME +display(LIBS) +target_link_libraries(${EXE_NAME} ${PROJECT_LIBRARY_NAME}) +target_link_libraries(${EXE_NAME} ${LIBS}) + # CXX is used as linker language -set_target_properties(${PROJECT_NAME} ${PROJECT_NAME}_shared PROPERTIES LINKER_LANGUAGE CXX) +#set_target_properties(${EXE_NAME} ${PROJECT_LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE CXX) +# ============== Add tests ============== if(WITH_TESTS) message(STATUS "Enable testing ...") begin_test(src/tests/F2003) @@ -186,8 +248,22 @@ if(WITH_TESTS) end_test() endif(WITH_TESTS) -# -------------------------------------------- -# RPATH +# ============= Prepare install ============= + +# The library +# The library, the headers and mod files, the cmake generated files +# will be install in CMAKE_INSTALL_PREFIX/lib include and share +include(InstallPackage) + +install_package(${PACKAGE_NAME} ${PROJECT_LIBRARY_NAME} ${${PROJECT_NAME}_HDRS}) + +#install(TARGETS ${EXE_NAME} +#RUNTIME DESTINATION bin # executables +# ) + +# ============= RPATH ============= +# Concerning rpath see for example http://www.itk.org/Wiki/CMake_RPATH_handling + # -------------------------------------------- # do not skip the full RPATH for the build tree set(CMAKE_SKIP_BUILD_RPATH FALSE) @@ -195,22 +271,18 @@ set(CMAKE_SKIP_BUILD_RPATH FALSE) # (but later on when installing) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # the RPATH to be used when installing -set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib") +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -# ============= Prepare install ============= - -# The library -install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_shared # targets list - RUNTIME DESTINATION bin # executables - ARCHIVE DESTINATION lib # static libs - LIBRARY DESTINATION lib # shared libs -) - - -# The headers and/or the modules -install(FILES ${${PROJECT_NAME}_HDRS} DESTINATION include) -install(DIRECTORY ${CMAKE_BINARY_DIR}/Modules DESTINATION include) - +# ============= Summary ============= +if(VERBOSE_MODE) + message(STATUS "====================== Summary ======================") + message(STATUS " Compiler : ${CMAKE_Fortran_COMPILER}") + message(STATUS " Sources are in : ${CMAKE_SOURCE_DIR}") + message(STATUS " Project uses MPI : ${USE_MPI}") + message(STATUS " Project uses PPM : ${USE_PPM}") + message(STATUS " Project will be installed in ${CMAKE_INSTALL_PREFIX}") + message(STATUS "====================== ======= ======================") +endif() diff --git a/HySoP/src/ParmesDef.hpp b/HySoP/src/ParmesDef.hpp index e517ca7f7e59c1a50e6163d335e3c9baf4c59790..a54f4aaa5ad81dd938d8a812eb290cda7e0de41e 100644 --- a/HySoP/src/ParmesDef.hpp +++ b/HySoP/src/ParmesDef.hpp @@ -9,7 +9,7 @@ namespace Parmes { /** Namespace for basic definitions in Parmes : typedef, enum ... */ namespace Def { -#include "ParmesConfig.hpp" +#include "parmes_defines.hpp" /** enumerated type used to describe in a more readible way the access to some components. For example, myGrid being a cartesian grid, you can call myGrid.length[X] rather than myGrid.length[0]. diff --git a/HySoP/src/callCharFunc.f90 b/HySoP/src/callCharFunc.f90 index 6b39dcdea0fce7afe40c73743e304399114e556b..9ba929739ea6b8cafb589d87b62c7f2393242ca5 100644 --- a/HySoP/src/callCharFunc.f90 +++ b/HySoP/src/callCharFunc.f90 @@ -5,7 +5,7 @@ module charFunctions use ppm_module_substart use ppm_module_substop - + implicit none contains diff --git a/HySoP/src/interfaces/ppm/ppm_wrapper.hpp b/HySoP/src/interfaces/ppm/ppm_wrapper.hpp index 822f0b0e2cb71fc4e0a938257423601c5ba8de28..85181449f73f2baea3acbceb8356d3beba5a1728 100644 --- a/HySoP/src/interfaces/ppm/ppm_wrapper.hpp +++ b/HySoP/src/interfaces/ppm/ppm_wrapper.hpp @@ -2,7 +2,7 @@ */ #ifndef PPMWRAPPER_HPP #define PPMWRAPPER_HPP -#include"FCMangle.h" +#include"F2CMangle.hpp" #include<mpi.h> #include <cstring> @@ -13,27 +13,27 @@ namespace PPM extern "C" { - //PPM_GLOBAL(pass,PASS); + //F2C_GLOBAL(pass,PASS); // Init and close ppm - void PPM_MODULE(ppm_module_init,ppm_init, PPM_MODULE_INIT,PPM_INIT)(int*, int*,int*,int*,int*,int*,int*,int*,int*); - void PPM_MODULE(ppm_module_finalize, ppm_finalize,PPM_MODULE_FINALIZE,PPM_FINALIZE)(int&); + void F2C_MODULE(ppm_module_init,ppm_init, PPM_MODULE_INIT,PPM_INIT)(int*, int*,int*,int*,int*,int*,int*,int*,int*); + void F2C_MODULE(ppm_module_finalize, ppm_finalize,PPM_MODULE_FINALIZE,PPM_FINALIZE)(int&); // Display functions - void PPM_MODULE(charfunctions, start, CHARFUNCTIONS, START)(double*,int*,char*,int ); - void PPM_MODULE(charfunctions, stop, CHARFUNCTIONS, stop)(double*,int*,char*,int ); + void F2C_MODULE(charfunctions, start, CHARFUNCTIONS, START)(double*,int*,char*,int ); + void F2C_MODULE(charfunctions, stop, CHARFUNCTIONS, stop)(double*,int*,char*,int ); - void PPM_MODULE(testppm,mult,TESTPPM,MULT)(double*,double*,int*); + void F2C_MODULE(testppm,mult,TESTPPM,MULT)(double*,double*,int*); // Topologies - // void PPM_MODULE(ppm_module_mktopo, ppm_mktopo, PPM_MODULE_MKTOPO,PPM_MKTOPO)(int*, double*, int*, + // void F2C_MODULE(ppm_module_mktopo, ppm_mktopo, PPM_MODULE_MKTOPO,PPM_MKTOPO)(int*, double*, int*, - void PPM_MODULE(modtest, cas1, MODTEST,CAS1)(double*); - void PPM_MODULE(modtest, cas2, MODTEST,CAS2)(double*); - void PPM_MODULE(modtest, cas3, MODTEST,CAS3)(double*); - void PPM_MODULE(modtest, cas4, MODTEST,CAS4)(double*); - void PPM_MODULE(modtest, cas5, MODTEST,CAS5)(double*); - void PPM_MODULE(modtest, cas6, MODTEST,CAS6)(double*); - void PPM_MODULE(modtest, application3, MODTEST,APPLICATION3)(); - // int PPM_MODULE(ppm_module_data,ppm_debug, PPM_MODULE_DATA,PPM_DEBUG); + void F2C_MODULE(modtest, cas1, MODTEST,CAS1)(double*); + void F2C_MODULE(modtest, cas2, MODTEST,CAS2)(double*); + void F2C_MODULE(modtest, cas3, MODTEST,CAS3)(double*); + void F2C_MODULE(modtest, cas4, MODTEST,CAS4)(double*); + void F2C_MODULE(modtest, cas5, MODTEST,CAS5)(double*); + void F2C_MODULE(modtest, cas6, MODTEST,CAS6)(double*); + void F2C_MODULE(modtest, application3, MODTEST,APPLICATION3)(); + // int F2C_MODULE(ppm_module_data,ppm_debug, PPM_MODULE_DATA,PPM_DEBUG); } @@ -59,7 +59,7 @@ namespace PPM static void init(int ndim, int MK,int tolexp, MPI::Intracomm& comm, int debug, int* info, int ppm_log_unit, int err, int out) { MPI_Fint Fcomm = MPI_Comm_c2f(comm); - PPM_MODULE(ppm_module_init,ppm_init, PPM_MODULE_INIT,PPM_INIT)(&ndim,&MK,&tolexp,&Fcomm,&debug,info,&ppm_log_unit,&err,&out); + F2C_MODULE(ppm_module_init,ppm_init, PPM_MODULE_INIT,PPM_INIT)(&ndim,&MK,&tolexp,&Fcomm,&debug,info,&ppm_log_unit,&err,&out); } /** Terminates ppm library @@ -67,7 +67,7 @@ namespace PPM */ static void finalize(int& info) { - PPM_MODULE(ppm_module_finalize, ppm_finalize,PPM_MODULE_FINALIZE,PPM_FINALIZE)(info); + F2C_MODULE(ppm_module_finalize, ppm_finalize,PPM_MODULE_FINALIZE,PPM_FINALIZE)(info); } /** Wrapper to ppm substart function @@ -80,7 +80,7 @@ namespace PPM size_t size = msg.size()+1; char * msgF = new char[size]; strncpy(msgF, msg.c_str(),size); - PPM_MODULE(charfunctions, start, CHARFUNCTIONS, START)(t0,info,msgF,strlen(msgF)); + F2C_MODULE(charfunctions, start, CHARFUNCTIONS, START)(t0,info,msgF,strlen(msgF)); } /** Wrapper to ppm substopt function @@ -93,7 +93,7 @@ namespace PPM size_t size = msg.size()+1; char * msgF = new char[size]; strncpy(msgF, msg.c_str(),size); - PPM_MODULE(charfunctions, stop, CHARFUNCTIONS, STOP)(t0,info,msgF,strlen(msgF)); + F2C_MODULE(charfunctions, stop, CHARFUNCTIONS, STOP)(t0,info,msgF,strlen(msgF)); } }; diff --git a/HySoP/src/main/Plouhmans.f90 b/HySoP/src/main/Plouhmans.f90 index 5e693b909f37bbf613c14384f29ad04d54a577ed..e57fea596069a3f7c891fdd612d7879e84ac0645 100644 --- a/HySoP/src/main/Plouhmans.f90 +++ b/HySoP/src/main/Plouhmans.f90 @@ -5,6 +5,8 @@ module ppmExample use ppm_module_data use ppm_module_mktopo use ppm_module_finalize + use ppm_module_mg_init + ! For ppm_param use client_io use client_data use mpi @@ -13,6 +15,8 @@ module ppmExample implicit none + include "ppm_numerics.h" + integer, private :: info contains @@ -21,6 +25,7 @@ contains integer prec,tol integer assigning, decomposition + dime = 3 ! Get MPI rank and size @@ -140,57 +145,57 @@ contains !----------------------------------------------------------------------------! ! send vortex_verbose !----------------------------------------------------------------------------! - call MPI_BCast(verbose,1,MPI_LOGICAL,0,MPI_COMM_WORLD,info) + call mpi_bcast(verbose,1,mpi_logical,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send number of levels !----------------------------------------------------------------------------! - call MPI_BCast(maxlev,1,MPI_INTEGER,0,MPI_COMM_WORLD,info) + call mpi_bcast(maxlev,1,mpi_integer,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send number of modes !----------------------------------------------------------------------------! - call MPI_BCast(vortex_noise_nmodes,1,MPI_INTEGER,0,MPI_COMM_WORLD,info) + call mpi_bcast(vortex_noise_nmodes,1,mpi_integer,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! noise amplitude !----------------------------------------------------------------------------! - call MPI_BCast(vortex_noise_amp,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(vortex_noise_amp,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! noise fundamental wavelength !----------------------------------------------------------------------------! - call MPI_BCast(vortex_noise_basemode,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(vortex_noise_basemode,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send trailing vortices spans !----------------------------------------------------------------------------! - call MPI_BCast(trailvortex_b1,1,mpi_prec,0,MPI_COMM_WORLD,info) - call MPI_BCast(trailvortex_b2,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(trailvortex_b1,1,mpi_prec,0,mpi_comm_world,info) + call mpi_bcast(trailvortex_b2,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send trailing vortices radii !----------------------------------------------------------------------------! - call MPI_BCast(trailvortex_a1,1,mpi_prec,0,MPI_COMM_WORLD,info) - call MPI_BCast(trailvortex_a2,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(trailvortex_a1,1,mpi_prec,0,mpi_comm_world,info) + call mpi_bcast(trailvortex_a2,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send trailing vortices vertical offset !----------------------------------------------------------------------------! - call MPI_BCast(trailvortex_z12,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(trailvortex_z12,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send trailing vortices gamma !----------------------------------------------------------------------------! - call MPI_BCast(trailvortex_gamma,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(trailvortex_gamma,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! send trailing vortices gamma ratio !----------------------------------------------------------------------------! - call MPI_BCast(trailvortex_r,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(trailvortex_r,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! noise symmetry, angles !----------------------------------------------------------------------------! - call MPI_BCast(trailvortex_noise_symmetry,1,MPI_LOGICAL,0,MPI_COMM_WORLD,info) - call MPI_BCast(trailvortex_noise_amp1,1,mpi_prec,0,MPI_COMM_WORLD,info) - call MPI_BCast(trailvortex_noise_amp2,1,mpi_prec,0,MPI_COMM_WORLD,info) - call MPI_BCast(trailvortex_noise_theta1,1,mpi_prec,0,MPI_COMM_WORLD,info) - call MPI_BCast(trailvortex_noise_theta2,1,mpi_prec,0,MPI_COMM_WORLD,info) + call mpi_bcast(trailvortex_noise_symmetry,1,mpi_logical,0,mpi_comm_world,info) + call mpi_bcast(trailvortex_noise_amp1,1,mpi_prec,0,mpi_comm_world,info) + call mpi_bcast(trailvortex_noise_amp2,1,mpi_prec,0,mpi_comm_world,info) + call mpi_bcast(trailvortex_noise_theta1,1,mpi_prec,0,mpi_comm_world,info) + call mpi_bcast(trailvortex_noise_theta2,1,mpi_prec,0,mpi_comm_world,info) !----------------------------------------------------------------------------! ! n dump !----------------------------------------------------------------------------! - call MPI_BCast(ndump,1,MPI_INTEGER,0,MPI_COMM_WORLD,info) + call mpi_bcast(ndump,1,mpi_integer,0,mpi_comm_world,info) if(dt.le.0.0_mk) dt = 1.0e-9_mk @@ -202,7 +207,7 @@ contains dz = (max_physg(3)-min_physg(3))/real(nx(3)-1,mk) !----------------------------------------------------------------------------! - ! Setup for topology + ! setup for topology !----------------------------------------------------------------------------! bcdef = ppm_param_bcdef_periodic topo_id = 0 @@ -214,44 +219,54 @@ contains decomposition = ppm_param_decomp_cartesian assigning = ppm_param_assign_internal ghostsize = 2 - ! Topology + ! topology call ppm_mktopo(topo_id, mesh_id, xp, np, decomposition, assigning, min_physg, max_physg, bcdef, ghostsize, sub_cost, & istart, ndata, nx, info) print *, "topo id : ", topo_id, " mesh_id : ", mesh_id - ! Allocations of fields ... + ! allocations of fields ... call allocfield(field_up,dime,info) call allocfield(field_wp,lda,info) call allocfield(field_wps,dime,info) call allocfield(field_dwp,lda,info) !----------------------------------------------------------------------------! - ! Init Multigrid solver @@@ + ! init multigrid solver @@@ !----------------------------------------------------------------------------! - ibcvalue(:,:,:,:,:)=0.0_MK - ibcdef(1,:)=bcdef(:) - ibcdef(2,:)=bcdef(:) - ibcdef(3,:)=bcdef(:) - mg_order = ppm_param_order_4 - - CALL allocfield(field_rhs,dime,info) - - ! CALL ppm_mg_init(ppm_param_eq_poisson,ghostsize, ppm_param_smooth_rbsor,dime, ibcdef,ibcvalue,mesh_id,maxlev, .TRUE.,.FALSE.,1.15_mk,info) - - print *, "End of Parmes:PPM:init_client" + call init_multigrid() + + call allocfield(field_rhs,dime,info) + + print *, "end of parmes:ppm:init_client" end subroutine init_client - subroutine main_client() bind(C,name='plouhmans') + subroutine main_client() bind(c,name='plouhmans') - print *, 'Run ppm simulation ...' - ! Init ppm ... + print *, 'run ppm simulation ...' + ! init ppm ... call init_client() call ppm_finalize(info) - print *, 'End ppm simulation' + print *, 'end ppm simulation' end subroutine main_client + subroutine init_multigrid() + + integer, dimension(3,6) :: ibcdef + real(mk), dimension(3,1,1,1,1) :: ibcvalue + integer :: mg_order + + + ibcvalue(:,:,:,:,:)=0.0_MK + ibcdef(1,:)=bcdef(:) + ibcdef(2,:)=bcdef(:) + ibcdef(3,:)=bcdef(:) + mg_order = ppm_param_order_4 + call ppm_mg_init(topo_id, ppm_param_eq_poisson,ghostsize, ppm_param_smooth_rbsor,dime, ibcdef,& + ibcvalue,mesh_id,maxlev, .TRUE.,.FALSE.,1.15_mk,info) + + end subroutine init_multigrid -end module ppmExample +end module ppmexample