diff --git a/CMake-for-ppm/Core/CMakeLists.txt b/CMake-for-ppm/Core/CMakeLists.txt
index 546d06c72d3e9269779284e03869bf05e2f34d24..f5fc86bc22e8dfbc2a1f6410be4e84d3d354c077 100644
--- a/CMake-for-ppm/Core/CMakeLists.txt
+++ b/CMake-for-ppm/Core/CMakeLists.txt
@@ -1,85 +1,41 @@
 #=======================================================
-# cmake utility to compile and install ppm_core library
+# cmake utility to compile and install ppmcore library
 #
-# F. Pérignon, 10 jan 2011
+# F. Pérignon, LJK,CNRS, jan 2011
 #
 #=======================================================
 
-# ============= Global Settings ============= 
+# ============= Global cmake Settings ============= 
 # Set minimum version
 cmake_minimum_required(VERSION 2.8)
 # Set policy
 cmake_policy(VERSION 2.8)
 # Set cmake modules directory (i.e. the one which contains all user-defined FindXXX.cmake files among other things)
-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake ${CMAKE_SOURCE_DIR})
 # Force out-of-source build
 include(OutOfSourceBuild)
 # Some usefull macros
 include(MyTools)
 
-# User defined options
-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)
+# ============= 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 ... 
+include(PPMCoreSettings)
 
-# default library type
-set(BUILD_SHARED_LIBS 1)
-
-# ============= The ppm_core project =============
 # Set project name and project languages 
 # => this automatically defines:
 #   - ${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 ppm_core)
-project(${PROJECT_NAME} Fortran CXX)
-# Package name, used for ###Config.cmake files
-set(PACKAGE_NAME "PPMCore")
-# Set a version number for the package
-set(${PACKAGE_NAME}_version 1.2)
-
-# set __Linux var in ppm_define.h depending on the OS
-if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-  set(__Linux 1)
-endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-
-# ============= 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:
-# -free or -ffree-form is required since we compile f90 files that have f ext ...
-include(TestFortranAcceptsFlag)
-# Try -ffree-form option (GNU)
-CHECK_Fortran_ACCEPTS_FLAG(-ffree-form Fortran_HAVE_ffree_form)
+project(${PROJECT_NAME} Fortran)
 
-if(Fortran_HAVE_ffree_form)
-  set(Fortran_Free_Flag "-ffree-form")
-else(Fortran_HAVE_ffree_form)
-  # Try -free (IFORT)
-  CHECK_Fortran_ACCEPTS_FLAG(-free Fortran_HAVE_free)
-  if(Fortran_HAVE_free)
-    set(Fortran_Free_Flag "-free")
-  else(Fortran_HAVE_free)
-    message(FATAL_ERROR "Can not find Fortran compiler free-form flag.")
-    # No other tests ... todo  if we need exotic compilers ...
-  endif(Fortran_HAVE_free)
-endif(Fortran_HAVE_ffree_form)
-
-append_Fortran_FLAGS(${Fortran_Free_Flag})
-append_Fortran_FLAGS("-cpp -w")
+# ============= Search for libraries  =============
 
-# --------------------------------------------
 # We search for libraries ppm depends on and 
 # and set the compile/link conf (-I and -L opt)
-# --------------------------------------------
+
 # ---- Metis ----
 if(USE_Metis)
   find_package(Metis 4.0 REQUIRED)
@@ -93,7 +49,6 @@ if(USE_Metis)
     message(STATUS "Metis include dir : ${Metis_INCLUDE_DIR}")
     message(STATUS "Metis library : ${Metis_LIBRARY}")
   endif(VERBOSE_MODE)
-
   # for ppm_define.h
   if(Metis_FOUND)
     set(__METIS 1)
@@ -121,8 +76,46 @@ if(USE_MPI)
   set(__MPI 1)
 endif(USE_MPI)
 
-# ----------------------
-# Generate ppm_define.h 
+# set __Linux var in ppm_define.h depending on the OS
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  set(__Linux 1)
+endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+# ============= Prepare compilation =============
+
+# Force a default build type if not provided by user
+# CMAKE_BUILD_TYPE = empty, Debug, Release, RelWithDebInfo or MinSizeRel.
+# This will have an impact on the compilation options.
+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)
+
+# Set module files directory (i.e. where .mod will be created) 
+set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules)
+
+# Add compilation flags:
+# -free or -ffree-form is required since we compile f90 files that have f ext ...
+include(TestFortranAcceptsFlag)
+# Try -ffree-form option (GNU)
+CHECK_Fortran_ACCEPTS_FLAG(-ffree-form Fortran_HAVE_ffree_form)
+if(Fortran_HAVE_ffree_form)
+  set(Fortran_Free_Flag "-ffree-form")
+else(Fortran_HAVE_ffree_form)
+  # Try -free (IFORT)
+  CHECK_Fortran_ACCEPTS_FLAG(-free Fortran_HAVE_free)
+  if(Fortran_HAVE_free)
+    set(Fortran_Free_Flag "-free")
+  else(Fortran_HAVE_free)
+    message(FATAL_ERROR "Can not find Fortran compiler free-form flag.")
+    # No other tests ... todo  if we need exotic compilers ...
+  endif(Fortran_HAVE_free)
+endif(Fortran_HAVE_ffree_form)
+append_Fortran_FLAGS(${Fortran_Free_Flag})
+append_Fortran_FLAGS("-cpp -w")
+
+# ============= Generates ppm_define.h =============
+# The file ppm_define.h will be generated from config.h.cmake;
+# its content depends on the values of __MPI, __Metis ...
 if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
   if(NOT CONFIG_H_GLOBAL_CONFIGURED)
     set(CONFIG_H_GLOBAL_CONFIGURED 1 CACHE BOOL "ppm_define.h global generation." )
@@ -131,23 +124,11 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
   include_directories(${CMAKE_BINARY_DIR}/src)
 endif(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
 
-
-
-# --------------------------------------------
-# We create the ppm_core library
-# --------------------------------------------
-# The list of all dirs containing sources to be compiled for the Parmes lib
-set(${PROJECT_NAME}_SRCDIRS 
-src
-)
-
-# Matching expr for files to be compiled. 
-set(EXTS ppm_module*.f *.h *.f90)
-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}
-
-# Source and header files list:
+# ============= Source and header files list =============
+# We scan all files with matching extension in directories 
+# containing sources.
+# Matching ext and directories for sources have been defined
+# in PPMCoreSettings
 foreach(_DIR ${${PROJECT_NAME}_SRCDIRS})
   set(_DIR_FILES)
   foreach(_EXT ${EXTS})
@@ -169,19 +150,24 @@ include_directories(${${PROJECT_NAME}_SRCDIRS})
 include_directories(${CMAKE_Fortran_MODULE_DIRECTORY})
 include_directories(${${PACKAGE_NAME}_EXTRA_INCLUDE_DIRS})
 
-# Create the lib
-set(PROJECT_LIBRARY_NAME ${PROJECT_NAME})
-add_library(${PROJECT_LIBRARY_NAME} SHARED ${${PROJECT_NAME}_SRC})
+# ============= Create the library =============
+if(BUILD_SHARED_LIBS) # shared library
+  add_library(${PROJECT_LIBRARY_NAME} SHARED ${${PROJECT_NAME}_SRC})
+else() # static library
+  add_library(${PROJECT_LIBRARY_NAME} STATIC ${${PROJECT_NAME}_SRC})
+endif()
 
 if(${PROJECT_NAME}_LINK_FLAGS)
   set_target_properties(${PROJECT_LIBRARY_NAME} PROPERTIES LINK_FLAGS ${${PROJECT_NAME}_LINK_FLAGS})
 endif(${PROJECT_NAME}_LINK_FLAGS)
-# Link with other libs
+
+# ============= Link the created library with dependencies  =============
+# The var LIBS must have been filled during 'find_package' process (for MPI, Metis ...)
 target_link_libraries(${PROJECT_LIBRARY_NAME} ${LIBS})
 
-# --------------------------------------------
-# RPATH
-# --------------------------------------------
+# ============= 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)
 # when building, don't use the install RPATH already
@@ -193,55 +179,13 @@ 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)
 
-# ============= Prepare install =============
-
-# Offer the user the choice of overriding the installation directories
-set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
-set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
-set(INSTALL_INCLUDE_DIR include CACHE PATH
-  "Installation directory for header files")
-set(INSTALL_DATA_DIR share CACHE PATH
-  "Installation directory for data files")
- 
-# Make relative paths absolute (needed later on)
-foreach(p LIB BIN INCLUDE DATA)
-  set(var INSTALL_${p}_DIR)
-  if(NOT IS_ABSOLUTE "${${var}}")
-    set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
-  endif()
-endforeach()
-
-# The library
-install(TARGETS ${PROJECT_LIBRARY_NAME} 
-  EXPORT ${PACKAGE_NAME}LibraryDepends
-  ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"  # static libs
-  LIBRARY DESTINATION "${INSTALL_LIB_DIR}"  COMPONENT shlib # shared libs
-  PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev
-  )
-
-# The headers and modules
-install(FILES ${${PROJECT_NAME}_HDRS} DESTINATION "${INSTALL_INCLUDE_DIR}")
-install(DIRECTORY ${CMAKE_BINARY_DIR}/Modules DESTINATION "${INSTALL_INCLUDE_DIR}")
-
-export(TARGETS ${PROJECT_LIBRARY_NAME} FILE "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}LibraryDepends.cmake")
- 
-# Install the export set for use with the install-tree
-install(EXPORT ${PACKAGE_NAME}LibraryDepends DESTINATION
-  "${INSTALL_DATA_DIR}/CMake" COMPONENT dev)
- 
-set(${PACKAGE_NAME}_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}")
-set(${PACKAGE_NAME}_LIB_DIR "${INSTALL_LIB_DIR}")
-set(${PACKAGE_NAME}_CMAKE_DIR "${INSTALL_DATA_DIR}/CMake")
-configure_file(${PACKAGE_NAME}Config.cmake.in
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}Config.cmake")
-configure_file(${PACKAGE_NAME}ConfigVersion.cmake.in
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}ConfigVersion.cmake" @ONLY)
-install(FILES
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}Config.cmake"
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}ConfigVersion.cmake"
-  DESTINATION "${${PACKAGE_NAME}_CMAKE_DIR}" COMPONENT dev)
-
-# Summary ...
+# ============= 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 =============
 if(VERBOSE_MODE)
   message(STATUS "====================== Summary ======================")
   message(STATUS " Compiler : ${CMAKE_Fortran_COMPILER}")
diff --git a/CMake-for-ppm/Core/PPMCoreSettings.cmake b/CMake-for-ppm/Core/PPMCoreSettings.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..024e9a1816fd5e0697b5f8117889edf3221ddfd1
--- /dev/null
+++ b/CMake-for-ppm/Core/PPMCoreSettings.cmake
@@ -0,0 +1,36 @@
+#=======================================================
+# cmake utility to compile and install ppm_core library
+#
+# F. Pérignon, LJK-CNRS, april 2011
+#
+# This fill is used to set basic options to compile and
+# install the PPMCore package. 
+#
+# Usage : in CMakeLists.txt,
+# include(PPMCoreSettings)
+#
+#=======================================================
+
+# User defined options
+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)
+
+# --- 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 ---
+# This name will be used to install PPMCore (library, headers, ...) and when another lib or soft will need to search for PPMCore.
+set(PACKAGE_NAME "PPMCore")
+# --- Set a version number for the package ---
+set(${PACKAGE_NAME}_version 1.2)
+# --- The name (without extension) of the lib to be created ---
+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)
+# --- 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 e5a9d2aa20cfabb161b05e9e8e252371d6112e5b..5b6dcdea04745753a4c9f22555e7b9ec857f7c7e 100644
--- a/CMake-for-ppm/Numerics/CMakeLists.txt
+++ b/CMake-for-ppm/Numerics/CMakeLists.txt
@@ -1,5 +1,5 @@
 #=======================================================
-# cmake utility to compile and install ppm_core library
+# cmake utility to compile and install ppm_numerics library
 #
 # F. Pérignon, 10 jan 2011
 #
@@ -11,24 +11,18 @@ cmake_minimum_required(VERSION 2.8)
 # Set policy
 cmake_policy(VERSION 2.8)
 # Set cmake modules directory (i.e. the one which contains all user-defined FindXXX.cmake files among other things)
-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake ${CMAKE_SOURCE_DIR})
 # Force out-of-source build
 include(OutOfSourceBuild)
 # Some usefull macros
 include(MyTools)
 
-# User defined options (some other options may be read from PPMCore config)
-option(VERBOSE_MODE "enable verbose mode for cmake exec" ON)
-option(USE_FFTW "enable fftw use for ppmnumerics, default = ON" ON)
-option(USE_VECTOR "vector mode - See ppm numerics doc, default = OFF" OFF)
-option(USE_MATHKEISAN "mathkeysan mode, default = OFF" OFF)
-option(USE_ETIME "etime mode, default = OFF" OFF)
-option(USE_CRAYFISHPACK "Enable crayfishpack, defaut = OFF" OFF)
-option(USE_HYPRE "Enable Hypre, default = OFF" OFF)
-option(USE_NOMICROINSTRUCTION "microinstruction mode (?), default = OFF" OFF)
-
-# default library type
-set(BUILD_SHARED_LIBS 1)
+# ============= Specific settings for PPMNumerics =============
+# In this file (PPMNumericsSettings.cmake) we set all variables
+# required to compile and install PPMNumerics 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 ... 
+include(PPMNumericsSettings)
 
 # ============= The ppm_numerics project =============
 # Set project name and project languages 
@@ -36,23 +30,19 @@ 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 ppm_numerics)
 project(${PROJECT_NAME} Fortran)
-# Package name, used for ###Config.cmake files
-set(PACKAGE_NAME "PPMNumerics")
-# Set a version number for the package
-set(${PACKAGE_NAME}_version 1.2)
 
-# set __Linux var in ppm_define.h depending on the OS
-if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-  set(__Linux 1)
-endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+# ============= Search for libraries  =============
+
+# --- PPMCore ---
 
-# ---- PPM Core ----
 # Find PPMCore package and all related information.
 # 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 1.2 REQUIRED) 
+# Search for and Read PPMCoreConfig.cmake and PPMCoreConfigVersion.cmake.
+# It results in a set of all the PPMCore related variables.
 if(VERBOSE_MODE)
   if(PPMCore_FOUND)
     message(STATUS "Found PPMCore config file: ${PPMCore_CONFIG}")
@@ -61,16 +51,16 @@ if(VERBOSE_MODE)
     message(STATUS " PPMCore modules: ${PPMCore_MODULE_DIR}")
     message(STATUS " PPMCore headers: ${PPMCore_INCLUDE_DIRS}")
     message(STATUS " PPMCore extra headers: ${PPMCore_EXTRA_INCLUDE_DIRS}")
-    display(PPMCore_USE_Metis)
-    display(PPMCore_USE_MPI)
     message(STATUS " Fortran compiler for PPMCore was ${PPMCore_Fortran_COMPILER}".)
   endif(PPMCore_FOUND)
 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})
 
@@ -78,7 +68,44 @@ set(LIBS ${LIBS} ${PPMCore_LIBRARIES})
 set(USE_MPI ${PPMCore_USE_MPI})
 set(USE_Metis ${PPMCore_USE_Metis})
 set(CMAKE_Fortran_COMPILER ${PPMCore_Fortran_COMPILER})
-#set(CMAKE_Fortran_FLAGS ${PPMCore_Fortran_FLAGS})
+
+# Set options that will be used to generate ppm_define.h
+if(USE_Metis)
+  set(__Metis 1)
+endif()
+
+# set __Linux var in ppm_define.h depending on the OS
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  set(__Linux 1)
+endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+# ---- MPI ----
+if(USE_MPI)
+  set(__MPI 1)
+endif(USE_MPI)
+
+# --- FFTW ---
+if(USE_FFTW)
+  find_package(FFTW REQUIRED)
+  include_directories(${FFTW_INCLUDE_DIRS})
+  set(LIBS ${LIBS} ${FFTW_LIBRARIES})
+  if(VERBOSE_MODE)
+    message(STATUS "FFTW include dirs : ${FFTW_INCLUDE_DIRS}")
+    message(STATUS "FFTW libraries : ${FFTW_LIBRARIES}")
+  endif(VERBOSE_MODE)
+  set(__FFTW 1)
+endif(USE_FFTW)
+
+# ============= Generates ppm_define.h =============
+# The file ppm_define.h will be generated from config.h.cmake;
+# its content depends on the values of __MPI, __Metis ...
+if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
+  if(NOT CONFIG_H_GLOBAL_CONFIGURED)
+    set(CONFIG_H_GLOBAL_CONFIGURED 1 CACHE BOOL "ppm_define.h global generation." )
+    configure_file(config.h.cmake src/ppm_define.h)
+  endif(NOT CONFIG_H_GLOBAL_CONFIGURED)
+  include_directories(${CMAKE_BINARY_DIR}/src)
+endif(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
 
 # ============= Prepare compilation =============
 
@@ -111,75 +138,15 @@ else(Fortran_HAVE_ffree_form)
     # No other tests ... todo  if we need exotic compilers ...
   endif(Fortran_HAVE_free)
 endif(Fortran_HAVE_ffree_form)
-
 append_Fortran_FLAGS(${Fortran_Free_Flag})
 append_Fortran_FLAGS("-cpp -w")
 
+# ============= Source and header files list =============
+# We scan all files with matching extension in directories 
+# containing sources.
+# Matching ext and directories for sources have been defined
+# in PPMNumericsSettings
 # --------------------------------------------
-# We search for libraries ppm depends on and 
-# and set the compile/link conf (-I and -L opt)
-# --------------------------------------------
-if(USE_Metis)
-  set(__Metis 1)
-endif()
-
-# ---- MPI ----
-if(USE_MPI)
-#  find_package(MPI REQUIRED)
-#  find_package(MPI_Fortran REQUIRED)
-  
-#  if(MPI_Fortran_COMPILER)
-#    set(CMAKE_Fortran_COMPILER mpif90)
-#  elseif(MPI_Fortran_COMPILER)
-    # -I
-#    include_directories(${MPI_Fortran_INCLUDE_PATH})
-    # Add compilation flags
-#    append_Fortran_flags(${MPI_Fortran_COMPILE_FLAGS})
-#    set(${PROJECT_NAME}_LINK_FLAGS ${${PROJECT_NAME}_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS})
-#  endif(MPI_Fortran_COMPILER)
-  
- # set(LIBS ${LIBS} ${MPI_Fortran_LIBRARIES} )
-
-  # for ppm_define.h ...
-  set(__MPI 1)
-endif(USE_MPI)
-
-
-if(USE_FFTW)
-  find_package(FFTW REQUIRED)
-  include_directories(${FFTW_INCLUDE_DIRS})
-  set(LIBS ${LIBS} ${FFTW_LIBRARIES})
-  if(VERBOSE_MODE)
-    message(STATUS "FFTW include dirs : ${FFTW_INCLUDE_DIRS}")
-    message(STATUS "FFTW libraries : ${FFTW_LIBRARIES}")
-  endif(VERBOSE_MODE)
-  set(__FFTW 1)
-endif(USE_FFTW)
-# ----------------------
-# Generate ppm_define.h 
-if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
-  if(NOT CONFIG_H_GLOBAL_CONFIGURED)
-    set(CONFIG_H_GLOBAL_CONFIGURED 1 CACHE BOOL "ppm_define.h global generation." )
-    configure_file(config.h.cmake src/ppm_define.h)
-  endif(NOT CONFIG_H_GLOBAL_CONFIGURED)
-  include_directories(${CMAKE_BINARY_DIR}/src)
-endif(EXISTS ${CMAKE_SOURCE_DIR}/config.h.cmake)
-
-# --------------------------------------------
-# We create the ppm_numerics library
-# --------------------------------------------
-# The list of all dirs containing sources to be compiled for the Parmes lib
-set(${PROJECT_NAME}_SRCDIRS 
-src
-)
-
-# Matching expr for files to be compiled. 
-set(EXTS ppm_module*.f *.h)
-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}
-
-# Source and header files list:
 foreach(_DIR ${${PROJECT_NAME}_SRCDIRS})
   set(_DIR_FILES)
   foreach(_EXT ${EXTS})
@@ -199,21 +166,26 @@ endforeach(_DIR ${${PROJECT_NAME}_SRCDIRS})
 # -I
 include_directories(${${PROJECT_NAME}_SRCDIRS})
 include_directories(${CMAKE_Fortran_MODULE_DIRECTORY})
+include_directories(${${PACKAGE_NAME}_EXTRA_INCLUDE_DIRS})
 
-# Create the lib
-set(PROJECT_LIBRARY_NAME ${PROJECT_NAME})
-add_library(${PROJECT_LIBRARY_NAME} SHARED ${${PROJECT_NAME}_SRC})
+# ============= Create the library =============
+if(BUILD_SHARED_LIBS) # shared library
+  add_library(${PROJECT_LIBRARY_NAME} SHARED ${${PROJECT_NAME}_SRC})
+else() # static library
+  add_library(${PROJECT_LIBRARY_NAME} STATIC ${${PROJECT_NAME}_SRC})
+endif()
 
 if(${PROJECT_NAME}_LINK_FLAGS)
   set_target_properties(${PROJECT_LIBRARY_NAME} PROPERTIES LINK_FLAGS ${${PROJECT_NAME}_LINK_FLAGS})
 endif(${PROJECT_NAME}_LINK_FLAGS)
-# Link with other libs
+
+# ============= Link the created library with dependencies  =============
+# The var LIBS must have been filled during 'find_package' process (for MPI, Metis ...)
 target_link_libraries(${PROJECT_LIBRARY_NAME} ${LIBS})
 
+# ============= RPATH =============
+# Concerning rpath see for example http://www.itk.org/Wiki/CMake_RPATH_handling
 
-# --------------------------------------------
-# RPATH
-# --------------------------------------------
 # do not skip the full RPATH for the build tree
 set(CMAKE_SKIP_BUILD_RPATH  FALSE)
 # when building, don't use the install RPATH already
@@ -225,56 +197,13 @@ 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})
 
-# ============= Prepare install =============
-
-# Offer the user the choice of overriding the installation directories
-set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
-set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
-set(INSTALL_INCLUDE_DIR include CACHE PATH
-  "Installation directory for header files")
-set(INSTALL_DATA_DIR share CACHE PATH
-  "Installation directory for data files")
- 
-# Make relative paths absolute (needed later on)
-foreach(p LIB BIN INCLUDE DATA)
-  set(var INSTALL_${p}_DIR)
-  if(NOT IS_ABSOLUTE "${${var}}")
-    set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
-  endif()
-endforeach()
-
-# The library
-install(TARGETS ${PROJECT_LIBRARY_NAME} 
-  EXPORT ${PACKAGE_NAME}LibraryDepends
-  ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"  # static libs
-  LIBRARY DESTINATION "${INSTALL_LIB_DIR}"  COMPONENT shlib # shared libs
-  PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev
-  )
-
-# The headers and modules
-install(FILES ${${PROJECT_NAME}_HDRS} DESTINATION "${INSTALL_INCLUDE_DIR}")
-install(DIRECTORY ${CMAKE_BINARY_DIR}/Modules DESTINATION "${INSTALL_INCLUDE_DIR}")
-
-export(TARGETS ${PROJECT_LIBRARY_NAME} FILE "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}LibraryDepends.cmake")
- 
-# Install the export set for use with the install-tree
-install(EXPORT ${PACKAGE_NAME}LibraryDepends DESTINATION
-  "${INSTALL_DATA_DIR}/CMake" COMPONENT dev)
- 
-set(${PACKAGE_NAME}_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}")
-set(${PACKAGE_NAME}_LIB_DIR "${INSTALL_LIB_DIR}")
-set(${PACKAGE_NAME}_CMAKE_DIR "${INSTALL_DATA_DIR}/CMake")
-configure_file(${PACKAGE_NAME}Config.cmake.in
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}Config.cmake")
-configure_file(${PACKAGE_NAME}ConfigVersion.cmake.in
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}ConfigVersion.cmake" @ONLY)
-install(FILES
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}Config.cmake"
-  "${PROJECT_BINARY_DIR}/InstallFiles/${PACKAGE_NAME}ConfigVersion.cmake"
-  DESTINATION "${${PACKAGE_NAME}_CMAKE_DIR}" COMPONENT dev)
-
-# Summary ...
+# ============= Summary =============
 if(VERBOSE_MODE)
   message(STATUS "====================== Summary ======================")
   message(STATUS " Compiler : ${CMAKE_Fortran_COMPILER}")
diff --git a/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in b/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in
index d618c7fbf82b54ea334add95fc638caa4be2de2a..ec02fc620bffb4ef79df60eff1a66eda714f8edf 100644
--- a/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in
+++ b/CMake-for-ppm/Numerics/PPMNumericsConfig.cmake.in
@@ -30,7 +30,8 @@ set(@PACKAGE_NAME@_LIBRARIES @PROJECT_LIBRARY_NAME@)
 set(@PACKAGE_NAME@_USE_MPI @USE_MPI@)
 set(@PACKAGE_NAME@_USE_Metis @USE_Metis@)
 set(@PACKAGE_NAME@_USE_FFTW @USE_FFTW@)
-# TODO : add all other options (use_vector, use_mathkeisan ...)
+# TODO?  add all other options (use_vector, use_mathkeisan ...)
+# 
 
 # Set var for compilers used by @PACKAGE_NAME@
 set(@PACKAGE_NAME@_Fortran_COMPILER @CMAKE_Fortran_COMPILER@)
diff --git a/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake b/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..0d6ac19dce58237957d3b769c12de2787b09a72e
--- /dev/null
+++ b/CMake-for-ppm/Numerics/PPMNumericsSettings.cmake
@@ -0,0 +1,44 @@
+#=======================================================
+# cmake utility to compile and install ppm_numerics library
+#
+# F. Pérignon, LJK-CNRS, april 2011
+#
+# This fill is used to set basic options to compile and
+# install the PPMNumerics package. 
+#
+# Usage : in CMakeLists.txt,
+# include(PPMNumericsSettings)
+#
+#=======================================================
+
+# User defined options
+# User defined options (some other options may be read from PPMCore config)
+option(VERBOSE_MODE "enable verbose mode for cmake exec" ON)
+option(USE_FFTW "enable fftw use for ppmnumerics, default = ON" ON)
+option(USE_VECTOR "vector mode - See ppm numerics doc, default = OFF" OFF)
+option(USE_MATHKEISAN "mathkeysan mode, default = OFF" OFF)
+option(USE_ETIME "etime mode, default = OFF" OFF)
+option(USE_CRAYFISHPACK "Enable crayfishpack, defaut = OFF" OFF)
+option(USE_HYPRE "Enable Hypre, default = OFF" OFF)
+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 ---
+# This name will be used to install PPMCore (library, headers, ...) and when another lib or soft will need to search for PPMCore.
+set(PACKAGE_NAME "PPMNumerics")
+# --- Set a version number for the package ---
+set(${PACKAGE_NAME}_version 1.2)
+# --- The name (without extension) of the lib to be created ---
+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)
+# --- 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/FindMetis.cmake b/CMake/FindMetis.cmake
index fa7b1cf0f5836948358b254d5fc00542d7e1c7a3..bfb7411c17438b44610246ba4c78867865b005fe 100644
--- a/CMake/FindMetis.cmake
+++ b/CMake/FindMetis.cmake
@@ -27,7 +27,7 @@ find_path(
   Metis_INCLUDE_DIR
   NAMES metis.h 
   #NO_CMAKE_ENVIRONMENT_PATH
-  PATHS ${With_Metis} PATHS ENV INCLUDE ENV PATH ${Metis_PKGCONF_INCLUDE_DIRS}
+  PATHS ${Metis_DIR} PATHS ENV INCLUDE ENV PATH ${Metis_PKGCONF_INCLUDE_DIRS}
   PATH_SUFFIXES Lib metis
   NO_DEFAULT_PATH
 )
@@ -41,7 +41,7 @@ find_path(
 find_library(
   Metis_LIBRARY
   NAMES metis
-  PATHS ${With_Metis} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH  ${Metis_PKGCONF_LIBRARY_DIRS} 
+  PATHS ${Metis_DIR} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH  ${Metis_PKGCONF_LIBRARY_DIRS} 
   NO_DEFAULT_PATH
   )
 find_library(
@@ -66,6 +66,7 @@ else(EXISTS ${PathToMetisLib}/VERSION)
   else(EXISTS ${PathToMetisLib}/libmetis${CMAKE_SHARED_LIBRARY_SUFFIX})
     get_filename_component(_metisDir ${PathToMetisLib} NAME)
     string(SUBSTRING ${_metisDir} 6 5 version_number)
+    display(_metisDir)
   endif(EXISTS ${PathToMetisLib}/libmetis${CMAKE_SHARED_LIBRARY_SUFFIX})
 endif(EXISTS ${PathToMetisLib}/VERSION)
 
@@ -77,7 +78,7 @@ if(Metis_FIND_VERSION)
     set(Metis_FIND_VERSION ${Metis_FIND_VERSION_MAJOR}.${Metis_FIND_VERSION_MINOR}.0)
   endif (NOT Metis_FIND_VERSION_PATCH)
   # if version number didn't specify a patchlevel, it's 0.
-  string  (REGEX MATCHALL "[.]" nbPoints ${version_number})
+  string(REGEX MATCHALL "[.]" nbPoints ${version_number})
   list(LENGTH nbPoints l_version)
   set(extended_version_number ${version_number})
   if(l_version LESS 2 )
@@ -95,7 +96,7 @@ if(Metis_FIND_VERSION)
     message(STATUS "Found Metis version ${version_number}")
   else(Metis_HAVE_PROPER_VERSION)
     if(Metis_FIND_REQUIRED)
-      message(FATAL_ERROR "Metis expected version not found : found ${version_number} while ${Metis_FIND_VERSION} was required. Try to set another metis location (for example by using With_Metis option) with a more recent version.")
+      message(FATAL_ERROR "Metis expected version not found : found ${version_number} while ${Metis_FIND_VERSION} was required. Try to set another metis location (for example by using Metis_DIR option) with a more recent version.")
     else(Metis_FIND_REQUIRED) # else just a warning
       message(WARNING "Found Metis ${version_number} while ${Metis_FIND_VERSION} was expected")
     endif(Metis_FIND_REQUIRED)
diff --git a/CMake/FindPPMCore.cmake b/CMake/FindPPMCore.cmake
deleted file mode 100644
index bc41a5c79fb9a279e6d4c48bb46113a0ca288ec3..0000000000000000000000000000000000000000
--- a/CMake/FindPPMCore.cmake
+++ /dev/null
@@ -1,51 +0,0 @@
-# - Try to find ppm_core library
-# Once done, this will define
-#
-#  PPMCore_FOUND - system has ppm_core
-#  PPMCore_INCLUDE_DIRS - the ppm_core include directories
-#  PPMCore_LIBRARIES - link these to use ppm_core
-#
-# LJK, Franck Perignon, jan. 2011
-#
-#
-include(LibFindMacros)
-
-#dependency
-libfind_package(PPMCore Metis 4.0)
-if(Metis_FOUND) 
-  set (__METIS 1)
-endif(Metis_FOUND)
-
-# Use pkg-config to get hints about paths
-#libfind_pkg_check_modules(PPMCore_PKGCONF PPMCore)
-
-# Modules and headers location 
-find_path(
-  PPMCore_MODULES_DIR
-  NAMES ppm_module_alloc.mod
-  HINTS ${PPMCore} ${PPMCore_PKGCONF_INCLUDE_DIRS}
-  PATHS ENV INCLUDE ENV PATH 
-  PATH_SUFFIXES include include/Modules
-)
-
-find_path(
-  PPMCore_INCLUDE_DIR
-  NAMES ppm_error.h
-  HINTS ${PPMCore} ${PPMCore_PKGCONF_INCLUDE_DIRS}
-  PATHS ENV INCLUDE ENV PATH
-  PATH_SUFFIXES include
-)
-
-# Finally the library itself
-find_library(
-  PPMCore_LIBRARY
-  NAMES ppm_core
-  HINTS ${PPMCore} ${PPMCore_PKGCONF_LIBRARY_DIRS}
-  PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH
-  PATH_SUFFIXES lib
-  )
-
-set(PPMCore_PROCESS_INCLUDES PPMCore_INCLUDE_DIR PPMCore_MODULES_DIR Metis_INCLUDE_DIR)
-set(PPMCore_PROCESS_LIBS PPMCore_LIBRARY Metis_LIBRARIES)
-libfind_process(PPMCore)
-
diff --git a/CMake/InstallPackage.cmake b/CMake/InstallPackage.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..39063be8dd0a7f59e33a80405a0ae2e5a31589fa
--- /dev/null
+++ b/CMake/InstallPackage.cmake
@@ -0,0 +1,56 @@
+#===========================================================
+# Macro to install a package (ppmcore or ppmnumerics indeed)
+#
+# F. Pérignon, LJK-CNRS, april 2011
+#
+#===========================================================
+
+macro(install_package _PACK _LIB_NAME _HEADERS)
+  
+  # Offer the user the choice of overriding the installation directories
+  set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
+  set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
+  set(INSTALL_INCLUDE_DIR include CACHE PATH
+    "Installation directory for header files")
+  set(INSTALL_DATA_DIR share CACHE PATH
+    "Installation directory for data files")
+
+  # Make relative paths absolute (needed later on)
+  foreach(p LIB BIN INCLUDE DATA)
+    set(var INSTALL_${p}_DIR)
+    if(NOT IS_ABSOLUTE "${${var}}")
+      set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
+    endif()
+  endforeach()
+  
+  # The library
+  install(TARGETS ${_LIB_NAME} 
+    EXPORT ${_PACK}LibraryDepends
+    ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"  # static libs
+    LIBRARY DESTINATION "${INSTALL_LIB_DIR}"  COMPONENT shlib # shared libs
+    PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev
+    )
+  
+  # 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")
+  
+  # Install the export set for use with the install-tree
+  install(EXPORT ${_PACK}LibraryDepends DESTINATION
+    "${INSTALL_DATA_DIR}/CMake" COMPONENT dev)
+  
+  set(${_PACK}_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}")
+  set(${_PACK}_LIB_DIR "${INSTALL_LIB_DIR}")
+  set(${_PACK}_CMAKE_DIR "${INSTALL_DATA_DIR}/CMake")
+  configure_file(${_PACK}Config.cmake.in
+    "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}Config.cmake")
+  configure_file(${_PACK}ConfigVersion.cmake.in
+    "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}ConfigVersion.cmake" @ONLY)
+  install(FILES
+    "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}Config.cmake"
+    "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}ConfigVersion.cmake"
+    DESTINATION "${${_PACK}_CMAKE_DIR}" COMPONENT dev)
+  
+endmacro()
diff --git a/HySoP/CMakeLists.txt b/HySoP/CMakeLists.txt
index f31d685834f710a109a787d2decf56032c909634..a7fc758b5245f0935303ee7e52539fa312cc5d61 100644
--- a/HySoP/CMakeLists.txt
+++ b/HySoP/CMakeLists.txt
@@ -91,8 +91,6 @@ if(WITH_MPI)
   endif(MPI_Fortran_COMPILER)
   
   set(LIBS ${LIBS} ${MPI_LIBRARIES} ${MPI_Fortran_LIBRARIES} )
-  # for ParmesConfig.hpp
-  #set(WITH_MPI 1)
 endif(WITH_MPI)
 
 # Find PPM Core
@@ -124,15 +122,15 @@ endif(EXISTS ${CMAKE_SOURCE_DIR}/config.hpp.cmake)
 # --------------------------------------------
 # 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
-)
+  src
+  src/interfaces/Fortran2Cpp
+  src/interfaces/ppm
+  )
 
 # A main file to create an executable (test purpose)
 set(${PROJECT_NAME}_MAINSRCDIRS 
-src/main
-)
+  src/main
+  )
 
 # Matching expr for files to be compiled. 
 set(EXTS *.cxx *.hpp *.h *.f90 *.f95)
@@ -162,7 +160,6 @@ endforeach(_DIR ${${PROJECT_NAME}_MAINSRCDIRS})
 # -I
 include_directories(${${PROJECT_NAME}_SRCDIRS})
 include_directories(${CMAKE_Fortran_MODULE_DIRECTORY})
-# 
 
 include(FortranCInterface)
 FortranCInterface_HEADER(${CMAKE_Fortran_MODULE_DIRECTORY}/FCMangle.h
diff --git a/HySoP/src/callPPM.f90 b/HySoP/src/callPPM.f90
index a6ff04c11c9e21b88ffc577addf6bf49cc42128e..d934225342b1f5442b94bc361e756c138a18ae01 100644
--- a/HySoP/src/callPPM.f90
+++ b/HySoP/src/callPPM.f90
@@ -28,10 +28,11 @@ contains
   subroutine mult(A,x,sizeA)
     real, dimension(:) :: A
     real :: x
-    integer :: sizeA,i,j
+    integer :: sizeA,j
     
     real*8, dimension(sizeA) :: B
     
+    x = 3
    print *, "otot"
    print *, A(1)
    print *, "titi"
diff --git a/HySoP/src/interfaces/ppm/ppm_wrapper.hpp b/HySoP/src/interfaces/ppm/ppm_wrapper.hpp
index 518e76b7a2e248cae428e0da66655b6211bd6e44..822f0b0e2cb71fc4e0a938257423601c5ba8de28 100644
--- a/HySoP/src/interfaces/ppm/ppm_wrapper.hpp
+++ b/HySoP/src/interfaces/ppm/ppm_wrapper.hpp
@@ -45,7 +45,7 @@ namespace PPM
 
   public : 
     
-    /** PPM initialization
+    /** PPM initialization 
 	\param problem dimension
 	\param precision for real numbers
 	\param exp tolerance
diff --git a/HySoP/src/interfaces/ppm/wrap_ppm_topologies.f95 b/HySoP/src/interfaces/ppm/wrap_ppm_topologies.f95
index 579ea43c4768dfdef18ecc12cebb19ffca26c0f8..3f9ee30247d00dae9584cdb5510ca1a264bc328e 100644
--- a/HySoP/src/interfaces/ppm/wrap_ppm_topologies.f95
+++ b/HySoP/src/interfaces/ppm/wrap_ppm_topologies.f95
@@ -46,6 +46,8 @@ contains
     
     !call aliasF2C(costPerProc, cost, nbProcs)    
 
+    print *, "topoid ", topoid
+
   end subroutine create_topology_geom
 
 
diff --git a/HySoP/src/main/Plouhmans.f90 b/HySoP/src/main/Plouhmans.f90
new file mode 100644
index 0000000000000000000000000000000000000000..5e693b909f37bbf613c14384f29ad04d54a577ed
--- /dev/null
+++ b/HySoP/src/main/Plouhmans.f90
@@ -0,0 +1,257 @@
+!> Temp modules for ppm_client
+module ppmExample
+
+  use ppm_module_init
+  use ppm_module_data
+  use ppm_module_mktopo
+  use ppm_module_finalize
+  use client_io
+  use client_data
+  use mpi
+  use WrapFort
+  use Tools
+
+  implicit none
+
+  integer, private :: info 
+
+contains
+
+  subroutine init_client()
+
+    integer prec,tol
+    integer assigning, decomposition
+    dime = 3
+
+    ! Get MPI rank and size
+    call MPI_Comm_Rank(MPI_COMM_WORLD, rank, info)
+    call MPI_Comm_size(MPI_COMM_WORLD, nproc, info)
+    !-----------------------------------------------------
+    !  Default values
+    !-----------------------------------------------------  
+    ! default values for time stepping
+    dt_adapt = .false.
+    lagcfl_omega = 0.125_mk
+    lagcfl_nablau = 0.25_mk
+    lagcfl_deform = 0.125_mk
+    fourier_diff = 0.16_mk
+
+    ! default values for vortices
+    vortex_noise_amp = 0.0_mk
+    vortex_noise_basemode = 0.0_mk
+    vortex_noise_nmodes = 1
+
+    trailvortex_a1 = 0.0_mk
+    trailvortex_a2 = 0.0_mk
+    trailvortex_b1 = 0.0_mk
+    trailvortex_b2 = 0.0_mk
+    trailvortex_z12 = 0.0_mk
+    trailvortex_r = 0.0_mk
+    trailvortex_gamma = 0.0_mk
+    trailvortex_noise_symmetry = .true.
+    trailvortex_noise_amp1 = 0.0_mk
+    trailvortex_noise_amp2 = 0.0_mk
+    trailvortex_noise_theta1 = 0.0_mk
+    trailvortex_noise_theta2 = 0.0_mk
+
+    allocate(cow(4))
+    cow(1) = 1.0_mk
+    cow(2) = 1.0_mk
+    cow(3) = 1.0_mk
+    cow(4) = 0.0_mk
+
+    ! default values for dumps
+    ndump = 10
+
+    !----------------------------------------------------------------------------!
+    !  dimension 3, lda = 3
+    !----------------------------------------------------------------------------!
+    dime  = 3; lda = 3
+    time  = 0.0_mk
+    itime = 0
+    itend = 1000
+    maxsubs = 1000
+
+
+
+    ! Some allocations 
+    allocate(nx(dime),min_physg(dime),max_physg(dime))
+    allocate(min_sub(dime,maxsubs),max_sub(dime,maxsubs))
+    allocate(bcdef(2*dime), ghostsize(dime))
+
+    ! Read input parameters on proc 0
+    if(rank == 0) call readparams()
+
+    ! Set precision
+    mpi_prec = MPI_DOUBLE_PRECISION
+    prec     = ppm_kind_double
+
+    ! Init ppm 
+    debug = 2
+    tol = -10
+    call ppm_init(dime,prec,tol,MPI_COMM_WORLD,debug,info)
+
+
+    call MPI_BCast(runtag,256,MPI_CHARACTER,0,MPI_COMM_WORLD,info)
+    call MPI_BCast(iruntag,1,MPI_INTEGER,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send nx
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(nx,dime,MPI_INTEGER,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send min_physg/max_physg
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(min_physg,dime,mpi_prec,0,MPI_COMM_WORLD,info)
+    call MPI_BCast(max_physg,dime,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send timestep
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(dt,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send timestep adaptivity flag
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(dt_adapt,1,MPI_LOGICAL,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send max timestep
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(dt_max,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send Lagrangian CFL based for omega, nablau, deformation
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(lagcfl_omega,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    call MPI_BCast(lagcfl_nablau,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    call MPI_BCast(lagcfl_deform,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send Fourier number for diffusion
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(fourier_diff,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send end time
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(tend,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send iteration end time
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(itend,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send nu
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(nu,1,mpi_prec,0,MPI_COMM_WORLD,info)
+    !----------------------------------------------------------------------------!
+    ! send vortex_verbose 
+    !----------------------------------------------------------------------------!
+    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)
+    !----------------------------------------------------------------------------!
+    ! send number of modes
+    !----------------------------------------------------------------------------!
+    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)
+    !----------------------------------------------------------------------------!
+    ! noise fundamental wavelength
+    !----------------------------------------------------------------------------!
+    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)
+    !----------------------------------------------------------------------------!
+    ! 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)
+    !----------------------------------------------------------------------------!
+    ! send trailing vortices vertical offset
+    !----------------------------------------------------------------------------!
+    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)
+    !----------------------------------------------------------------------------!
+    ! send trailing vortices gamma ratio
+    !----------------------------------------------------------------------------!
+    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)  
+    !----------------------------------------------------------------------------!
+    !  n dump
+    !----------------------------------------------------------------------------!
+    call MPI_BCast(ndump,1,MPI_INTEGER,0,MPI_COMM_WORLD,info)
+
+    if(dt.le.0.0_mk)   dt    = 1.0e-9_mk
+
+    !----------------------------------------------------------------------------!
+    !  mesh spacing
+    !----------------------------------------------------------------------------!
+    dx = (max_physg(1)-min_physg(1))/real(nx(1)-1,mk)
+    dy = (max_physg(2)-min_physg(2))/real(nx(2)-1,mk)
+    dz = (max_physg(3)-min_physg(3))/real(nx(3)-1,mk)
+
+    !----------------------------------------------------------------------------!
+    !  Setup for topology
+    !----------------------------------------------------------------------------!
+    bcdef         = ppm_param_bcdef_periodic
+    topo_id = 0
+    mesh_id = -1
+
+    nullify(ndata,isublist,sub2proc,sub_cost,proc_speed)
+    allocate(proc_speed(nproc))
+
+    decomposition = ppm_param_decomp_cartesian  
+    assigning     = ppm_param_assign_internal
+    ghostsize = 2
+    ! 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 ...
+    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 @@@
+    !----------------------------------------------------------------------------!
+    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"
+    
+  end subroutine init_client
+
+  subroutine main_client() bind(C,name='plouhmans')
+
+    print *, 'Run ppm simulation ...'
+    ! Init ppm ...
+    call init_client()
+
+    call ppm_finalize(info)
+    print *, 'End ppm simulation'
+  end subroutine main_client
+
+
+end module ppmExample
diff --git a/HySoP/src/main/Tools.f90 b/HySoP/src/main/Tools.f90
new file mode 100644
index 0000000000000000000000000000000000000000..2e63caef486eba22b387eafb7f856337b1f20ebd
--- /dev/null
+++ b/HySoP/src/main/Tools.f90
@@ -0,0 +1,36 @@
+module Tools
+
+  use client_data
+
+  implicit none
+
+contains
+
+  subroutine allocfield(vfield_up, ilda, info)
+
+    real(mk), DIMENSION(:,:,:,:,:), POINTER :: vfield_up
+    integer, INTENT(out) :: info
+    integer, INTENT(in ) :: ilda
+
+    integer, dimension(3) :: vndata, ldl, ldu
+  
+    IF(ASSOCIATED(vfield_up)) THEN
+       DEALLOCATE(vfield_up,stat=info)
+       NULLIFY(vfield_up)
+    END IF
+
+    if(info.NE.0) stop 'allocation error'
+    
+    vndata(1) = MAXVAL(ndata(1,isublist(1:nsublist)))
+    vndata(2) = MAXVAL(ndata(2,isublist(1:nsublist)))
+    vndata(3) = MAXVAL(ndata(3,isublist(1:nsublist)))
+
+    ldl = 1 - ghostsize
+    ldu = vndata + ghostsize
+    
+    ALLOCATE(vfield_up(ilda,ldl(1):ldu(1),ldl(2):ldu(2),ldl(3):ldu(3),nsublist),&
+         & stat = info)
+
+  end subroutine allocfield
+  
+end module Tools
diff --git a/HySoP/src/main/main.cxx b/HySoP/src/main/main.cxx
index 98764ab03bfd5bcab3fd9d995a523746d51c2eab..fcdecbadfb85ba2a39ca952cfe33c1414581d102 100644
--- a/HySoP/src/main/main.cxx
+++ b/HySoP/src/main/main.cxx
@@ -12,38 +12,40 @@
 #include "WrapC.hpp"
 
 using namespace std ;
+using Parmes::Def::real_t;
 
 extern "C" void createTopoG(int*, int*, int*, double*, double*, int*, double*);
+extern "C" void plouhmans();
 
-int main(int argc, char* argv[])
+void testPlouhmans()
 {
-  float p1_x,p1_y,p2_x,p2_y;
+  MPI::Init();
+  assert(MPI::Is_initialized());
+
+  plouhmans();
+  
+  MPI::Finalize();
 
-  p1_x = 0.0;
-  p1_y = 0.0;
-  p2_x = 3.0;
-  p2_y = 4.0;
+}
 
+
+void test0()
+{
   double t0; 
   int info;
-	
-  string str = "une chaîne de caractères";
-  // créer le buffer pour copier la chaîne
-  size_t size = str.size() + 1;
-  char * buffer = new char[ size ];
-  // copier la chaîne
-  strncpy( buffer, str.c_str(), size );
-	
-  //	__ppm_module_substart_MOD_substart(buffer, &t0, &info);
+  
 
 
   // =====  Physical domain definition =====
-  // dimensions 
+  // Problem dimension
+  int pbDim = 3;
+  // dimensions of the domain 
   Parmes::Def::vector3D dimsD = { { 1.0, 3.1, 4.3} };
   // "Lowest" point
   Parmes::Def::vector3D startPoint = { { 0., 1., 2.} };
   // The domain
   Parmes::Model::Domain<3> domain(dimsD, startPoint);
+  
   // =====  Grid definition =====
   // Number of points in each dir ...
   boost::array<size_t, 3>  nbSteps = { { 3, 4, 5} };
@@ -52,76 +54,45 @@ int main(int argc, char* argv[])
   std::cout << grid << std::endl;
 
   std::string msg = "Main Programm in c++";
-
+  
   MPI::Init();
+  assert(MPI::Is_initialized());
+  
   MPI::Intracomm Comm = MPI::COMM_WORLD;
-  PPM::wrapper::init(3, 8, -15, Comm, 2, &info, 99, 98,97);
+  
+  // ==== Initialize  ppm ====
+  PPM::wrapper::init(pbDim, 8, -15, Comm, 2, &info, 99, 98,97);
   PPM::wrapper::substart(msg, &t0, &info);
-
-  MPI::Finalize();
-  PPM::wrapper::substop(msg, &t0, &info);
-
-  double A[1][1];
-  double x = 2.0;
-  double B[1];
-  int sizeA = 1;
-  for (int i = 0; i<sizeA; ++i)
-    for(int j =0; j<sizeA;++j)
-      A[i][j] = i+j;
-  B[0] = 12;
-  //B[1] = 4;
-  //B[2] =2;
-
-	
- //  for (int i = 0; i<sizeA; ++i)
-//     {
-//       for(int j =0; j<sizeA;++j)
-// 	std::cout << A[i][j] << " ";
-//       std::cout << std::endl;
-//     }
-	
-  //	PPM::PPM_MODULE(testppm,mult,TESTPPM,MULT)(B,&x,&sizeA);
-
-//   for (int i = 0; i<sizeA; ++i)
-//     {
-//       std::cout<< "B " << B[i] << std::endl;
-//       for(int j =0; j<sizeA;++j)
-// 	std::cout << A[i][j] << " ";
-//       std::cout << std::endl;
-//     }
-
-  std::vector<double> vect(2);
-	
-  vect[0] = 12;
-  vect[1] =14.8;
-	
-  double * vect2 = NULL;
-  double * vect3;
-
-  int sizeV = 2;
-  //	PPM::PPM_MODULE(modtest, cas1, MODTEST,CAS1)(&vect[0]);
-  //PPM::PPM_MODULE(modtest, cas2, MODTEST,CAS2)(&vect[0]);//, &sizeV);
-  //PPM::PPM_MODULE(modtest, cas3, MODTEST,CAS3)(vect.data(), &sizeV);//, &sizeV);
-  //	PPM::PPM_MODULE(modtest, cas4, MODTEST,CAS4)(vect2);//, &sizeV);
-  //	PPM::PPM_MODULE(modtest, testglob, MODTEST,TESTGLOB)();
-  // 	std::cout << "iauziazuizauzi" << std::endl;
-  // 	double** adrVec;
-  // 	adrVec = new(double*);
-  // 	*adrVec = &vect[0];
-
-  // 	cout << " titi" << (*adrVec)[0] << endl;
-
-  //	PPM::PPM_MODULE(modtest, cas6, MODTEST,CAS6)(adrVec);//, &sizeV);
-  //	std::cout << "yiha" << vect2[1] << std::endl;
-	  
-  //Mesh* p_obj = 0 ;
-
-  int topoid, decomp, dim = 3;
   
-  Parmes::Def::vector3D minPhys = {{0.0,0.0,0.0}}, maxPhys ={{ 10.0,10.0,10.0}};
+  Parmes::Def::vector3D minPhys = {{0.0,0.0,0.0}}, maxPhys ={{ 3.14, 3.14, 6.28}};
+  Parmes::Def::vector3D minSub, maxSub;
   boost::array<int,6> bc = {{ 1, 1 ,1 ,1 ,1,1}}; 
-  double ghostsize = 1;
+  boost::array<int,3>  nx ={{ 65, 65, 129}};
+  Parmes::Def::real_t ghostsize = 1.0;
+  int topoid = -1, decomp, dim = 3;
+  int meshid = -1;
+  // Time step
+  real_t dt = 0.96;
+  real_t finalT = 1000;
+  real_t nu = 0.001;
+  
   Parmes::Def::real_t * costPerProc;
   createTopoG(&dim, &topoid, &decomp,&minPhys[0], &maxPhys[0], &bc[0], &ghostsize);
+  
+  
+  cout << topoid << endl;
 
+  PPM::wrapper::finalize(info);
+  
+  
+  // ==== Finalize everything ====
+  MPI::Finalize();
+  PPM::wrapper::substop(msg, &t0, &info);
+  
 }
+
+int main(int argc, char* argv[])
+{
+  testPlouhmans();
+}
+