Skip to content

Commit

Permalink
Initial pececillo import
Browse files Browse the repository at this point in the history
git-svn-id: pececillo/trunk@2
  • Loading branch information
nncarlson committed Sep 25, 2014
1 parent dd391ff commit d7de76b
Show file tree
Hide file tree
Showing 181 changed files with 38,345 additions and 0 deletions.
87 changes: 87 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
cmake_minimum_required(VERSION 2.8.12)

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}"
"${CMAKE_SOURCE_DIR}/cmake/Modules"
"${CMAKE_SOURCE_DIR}/cmake/Utils")

project(Pececillo Fortran C)

# Override the default installation prefix (/usr/local).
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${Pececillo_SOURCE_DIR}/install
CACHE PATH "Installation prefix" FORCE)
endif()

# External project (netCDF, HDF5, HYPRE,etc.) install prefix
if (NOT EXTERNAL_INSTALL_PREFIX)
set(EXTERNAL_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/external)
endif()

# ---------------------------------------------------------------------------- #
# Build Options
# ---------------------------------------------------------------------------- #

option(ENABLE_TESTS "Build test programs" ON)

# Build the tests
if (ENABLE_TESTS)
enable_testing()
endif()

#-------------------------------------------------------------------------------
# Compiler Definitions
#-------------------------------------------------------------------------------

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

message(STATUS "CMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}")
if (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
set (CMAKE_Fortran_FLAGS_RELEASE "-u -O3 -w=uda -DNDEBUG")
set (CMAKE_Fortran_FLAGS_DEBUG "-u -g90")
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -xhost -DNDEBUG -assume realloc_lhs")
set (CMAKE_Fortran_FLAGS_DEBUG "-g -assume realloc_lhs")
message(STATUS "${CMAKE_Fortran_COMPILER_VERSION}")
endif()

#-------------------------------------------------------------------------------
# TPLs
#-------------------------------------------------------------------------------

# Find and/or build the required TPLs.
add_subdirectory(external)

# We need to incorporate netcdf and exodus into the TPL build process, but for
# now we require them to be prebuilt and installed someplace. EXODUS_LIB_DIR
# must be set on the command line to the directory containing the libraries.
# Source tarballs for the packages are in external/tarballs.
if(NOT EXODUS_LIB_DIR)
message(FATAL_ERROR "ERROR! EXODUS_LIB_DIR must be set to the directory "
"containing the netcdf and exoIIv2c libraries.")
endif()
find_library(EXODUS_LIBRARY exoIIv2c ${EXODUS_LIB_DIR} NO_DEFAULT_PATH)
find_library(NETCDF_LIBRARY netcdf ${EXODUS_LIB_DIR} NO_DEFAULT_PATH)
if(EXODUS_LIBRARY STREQUAL "EXODUS_LIBRARY-NOTFOUND" OR
NETCDF_LIBRARY STREQUAL "NETCDF_LIBRARY-NOTFOUND")
message(FATAL_ERROR "ERROR! Could not find the netcdf and/or exoIIv2c "
"libraries in EXODUS_LIB_DIR=${EXODUS_LIB_DIR}")
endif()
add_library(exodus STATIC IMPORTED)
set_target_properties(exodus PROPERTIES
IMPORTED_LOCATION ${EXODUS_LIBRARY}
IMPORTED_LINK_INTERFACE_LIBRARIES ${NETCDF_LIBRARY})
message(STATUS "NETCDF_LIBRARY=${NETCDF_LIBRARY}")

#-------------------------------------------------------------------------------
# Installation Definitions
#-------------------------------------------------------------------------------

add_subdirectory(petaca)
set(Petaca_MODULE_DIR ${Petaca_BINARY_DIR}/mod_files/)

set(Pececillo_MODULE_DIR ${Pececillo_BINARY_DIR}/mod_files/)
set(CMAKE_Fortran_MODULE_DIRECTORY ${Pececillo_MODULE_DIR})
add_subdirectory(src)

112 changes: 112 additions & 0 deletions cmake/Modules/FindHYPRE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# - Find the HYPRE (High Performance Preconditioners) Implementation
# HYPRE is a popular software package that implements several scalable
# linear solvers. This module searches for a HYPRE installation and
# returns the pointers to the include path and library
#
# === Variables ===
#
# HYPRE_FOUND Flag indicating if HYPRE is found
# HYPRE_VERSION HYPRE version
# HYPRE_INCLUDE_DIRS List of paths required to compile
# with HYPRE
# HYPRE_LIBRARIES List libraries (targets?) required
# to link against HYPRE.
# HYPRE_IS_PARALLEL HYPRE was found
#
# HYPRE_INSTALL_PREFIX Hypre installation prefix. Used in the
# library and include file search.
# === Usage ===
#
# Call this module with FIND_PACKAGE(HYPRE) in any CMakeLists.txt
# that requires HYPRE include directories or libraries. The search
# can be bypassed by explicitly setting HYPRE_INCLUDE_DIRS and
# HYPRE_LIBRARIES variables.
#
# The variables HYPRE_INSTALL_PREFIX or ENV HYPRE_ROOT control
# search locations for include and libraries.
#
include(FindPackageHandleStandardArgs)
include(PrintVariable)

# --- MACROS/FUNCTIONS
FUNCTION(_search_hypre_config_file config_h defmacro outvar)
if ( EXISTS "${config_h}" )
set(_regexp ".define[ \\t]+${defmacro}")
set(_quote "\"")
FILE(STRINGS "${config_h}" _tmp_string REGEX "${_regexp}")
STRING(REGEX REPLACE ".define ${defmacro}[ \\t]+(.*)$" "\\1" _result "${_tmp_string}")
STRING(REPLACE "${_quote}" " " _result "${_result}")
STRING(REGEX REPLACE "[ \t\n]+" "" _result "${_result}")
else()
set(_result ${outvar}-NOTFOUND)
endif()
set(${outvar} ${_result} PARENT_SCOPE)

ENDFUNCTION()

# --- Begin main

# Search for HYPRE.h
find_path(HYPRE_INCLUDE_DIR
NAMES HYPRE.h
HINTS ENV HYPRE_ROOT ${HYPRE_INSTALL_PREFIX}
PATH_SUFFIXES include)

# Search for HYPRE library
find_library(HYPRE_LIBRARY
NAMES HYPRE
HINTS ENV HYPRE_ROOT ${HYPRE_INSTALL_PREFIX}
PATH_SUFFIXES lib)

# Define the cofig header file, will mine this to determine version
# and build type (MPI, non-MPI)
if ( HYPRE_INCLUDE_DIR )
set(HYPRE_CONFIG_FILE ${HYPRE_INCLUDE_DIR}/HYPRE_config.h)
endif()

# Define the version
if ( NOT HYPRE_VERSION AND HYPRE_CONFIG_FILE )
_search_hypre_config_file(${HYPRE_CONFIG_FILE} HYPRE_RELEASE_VERSION HYPRE_VERSION)
endif()

# Define the build (MPI or non-MPI)
if (HYPRE_CONFIG_FILE)
_search_hypre_config_file(${HYPRE_CONFIG_FILE} HYPRE_HAVE_MPI HYPRE_IS_PARALLEL)
if(HYPRE_IS_PARALLEL)
set(HYPRE_IS_PARALLEL True)
else()
set(HYPRE_IS_PARALLEL False)
endif()
if (HYPRE_IS_PARALLEL)
find_package(MPI)
endif()
endif()

# Define the include directories, append MPI if needed
if ( NOT HYPRE_INCLUDE_DIRS)
set(HYPRE_INCLUDE_DIRS ${HYPRE_INCLUDE_DIR})
if (HYPRE_IS_PARALLEL)
if (MPI_C_FOUND)
list(APPEND HYPRE_INCLUDE_DIRS ${MPI_C_INCLUDE_PATH})
endif()
endif()
endif()

# Define the libraries
if ( NOT HYPRE_LIBRARIES )
set(HYPRE_LIBRARIES ${HYPRE_LIBRARY})
if (HYPRE_IS_PARALLEL)
list(APPEND HYPRE_LIBRARIES ${MPI_C_LIBRARIES})
endif()
endif()

# Send a useful message if everything is found
find_package_handle_standard_args(HYPRE
VERSION_VAR HYPRE_VERSION
REQUIRED_VARS HYPRE_LIBRARY HYPRE_INCLUDE_DIRS HYPRE_LIBRARIES)

mark_as_advanced(
HYPRE_INCLUDE_DIR
HYPRE_CONFIG_FILE
HYPRE_LIBRARY)

Loading

0 comments on commit d7de76b

Please sign in to comment.