View Issue Details

IDProjectCategoryView StatusLast Update
0001549OpenFOAMBugpublic2015-03-07 15:10
Reporteruser507Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86-64OSLinux MintOS Version17.1
Summary0001549: Paraview build fail with -mpi flag and MPICH
DescriptionTrying to build the Paraview supplied with ThirdParty-2.3.1 with the 'makeParaView4' script with flag '-mpi' fail if using MPICH supplied with the Linux Mint / Ubuntu package repositories, even when all environment variables is set correctly.
Steps To Reproduce1) Install MPICH from the Ubuntu/Linux Mint repositories as your only MPI version
2) Alter the OpenFOAM environment variables accordingly (override some of the variables set by the etc/bashrc script)
3) Try to build ParaView with './buildParaView4 -mpi'
Additional InformationThe cause of this error is in the etc/tools/ParaView4Functions file, line 169 and 174, where the script sets two CMAKE variables:

169: addCMakeVariable "MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so"
174: addCMakeVariable "VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun"

These are not correct for MPICH, since the MPI library is called 'libmpich.so' and the mpirun binary is not found in '$MPI_ARCH_PATH/bin/mpirun'.

They are however not needed at all, CMake will on its own find the neccesary MPI libraries to link against and find the mpirun binary, as long as the desired mpirun is the first in $PATH etc. Just commenting away these two lines makes the compilation successful.
TagsNo tags attached.

Activities

wyldckat

2015-02-28 21:00

updater   ~0003923

Greetings hakostra,

Which exact environment variables did you modify in OpenFOAM's "bashrc" file?

Best regards,
Bruno

Note: This seems somewhat related to issue #1167: http://www.openfoam.org/mantisbt/view.php?id=1167

user507

2015-03-01 19:39

  ~0003926

I actually use "modulefiles", via the "enviromnent-modules" package in the Ubuntu/Linux Mint repos. I think this is a great way to manage different source-compiled software. The variables are however mostly the same as set by etc/bashrc. I attach my modulefile for reference.

And I totally agree that the build system by OpenFOAM is a pain. Just look at the modulefile. So many variables? Why??? Why not use CMake?

user507

2015-03-01 19:40

 

modulefile.txt (3,998 bytes)   
#%Module1.0#####################################################################
##
## OpenFOAM 2.3.x
## -----------------------------------------------------------------------------
## 2015-02-27
## -----------------------------------------------------------------------------

set modulefile [lrange [split [module-info name] {/}] 0 0]

set appname    "OpenFOAM"
set apphome    /opt/$appname

set modulefile openfoam
set release    2.3.x

module-whatis   "Finite Volume CFD code"

setenv WM_OSTYPE                POSIX
setenv WM_ARCH                  linux64
setenv WM_ARCH_OPTION           64
setenv WM_CC                    mpicc
setenv WM_CFLAGS                "-O3 -march=native -ffast-math -m64 -fPIC"
setenv WM_COMPILER              Gcc
setenv WM_COMPILE_OPTION        Opt
setenv WM_PRECISION_OPTION      DP
setenv WM_CXX                   mpicxx
setenv WM_CXXFLAGS              "-O3 -march=native -ffast-math -m64 -fPIC"
setenv WM_LINK_LANGUAGE         c++
setenv WM_LDFLAGS               -m64
setenv WM_MPLIB                 MPICH
setenv WM_OPTIONS               $env(WM_ARCH)$env(WM_COMPILER)$env(WM_PRECISION_OPTION)$env(WM_COMPILE_OPTION)
setenv WM_COMPILER_LIB_ARCH     $env(WM_ARCH_OPTION)
setenv WM_NCOMPPROCS            2

setenv WM_PROJECT               OpenFOAM
setenv WM_PROJECT_INST_DIR      $apphome
setenv WM_PROJECT_VERSION       $release
setenv WM_PROJECT_DIR           $apphome/OpenFOAM-$release
setenv WM_THIRD_PARTY_DIR       $apphome/ThirdParty-$release
setenv WM_DIR                   $env(WM_PROJECT_DIR)/wmake
setenv WM_PROJECT_USER_DIR      $env(HOME)/OpenFOAM/$env(USER)-$release

setenv FOAM_APP                 $env(WM_PROJECT_DIR)/applications
setenv FOAM_APPBIN              $env(WM_PROJECT_DIR)/platforms/$env(WM_OPTIONS)/bin
setenv FOAM_INST_DIR            $apphome
setenv FOAM_JOB_DIR             $apphome/jobControl
setenv FOAM_LIBBIN              $env(WM_PROJECT_DIR)/platforms/$env(WM_OPTIONS)/lib
setenv FOAM_EXT_LIBBIN          $env(WM_THIRD_PARTY_DIR)/platforms/$env(WM_OPTIONS)/lib
setenv FOAM_SOLVERS             $env(WM_PROJECT_DIR)/applications/solvers
setenv FOAM_SRC                 $env(WM_PROJECT_DIR)/src
setenv FOAM_TUTORIALS           $env(WM_PROJECT_DIR)/tutorials
setenv FOAM_UTILITIES           $env(WM_PROJECT_DIR)/applications/utilities
setenv FOAM_SIGFPE              ""
setenv FOAM_SETTINGS            ""

setenv FOAM_SITE_LIBBIN         $apphome/site/$release/platforms/$env(WM_OPTIONS)/lib
setenv FOAM_SITE_APPBIN         $apphome/site/$release/platforms/$env(WM_OPTIONS)/bin

setenv FOAM_RUN                 $env(HOME)/OpenFOAM/$env(USER)-$release/run
setenv FOAM_USER_APPBIN         $env(HOME)/OpenFOAM/$env(USER)-$release/platforms/$env(WM_OPTIONS)/bin
setenv FOAM_USER_LIBBIN         $env(HOME)/OpenFOAM/$env(USER)-$release/platforms/$env(WM_OPTIONS)/lib
system "mkdir -p $env(FOAM_RUN)"
system "mkdir -p $env(FOAM_USER_APPBIN)"
system "mkdir -p $env(FOAM_USER_LIBBIN)"

setenv FOAM_MPI                 mpich-system
setenv MPI_ARCH_PATH            /usr/lib/mpich
setenv MPI_BUFFER_SIZE          20000000

setenv SWAK4FOAM_SRC            $env(HOME)/OpenFOAM/$env(USER)-$release/swak4Foam/Libraries

setenv ParaView_VERSION         4.1.0
setenv ParaView_MAJOR           4.1
setenv ParaView_DIR             $env(WM_THIRD_PARTY_DIR)/platforms/$env(WM_ARCH)$env(WM_COMPILER)/ParaView-$env(ParaView_VERSION)
setenv ParaView_INCLUDE_DIR     $env(ParaView_DIR)/include/paraview-4.1
setenv PV_PLUGIN_PATH           $env(FOAM_LIBBIN)/paraview-4.1

prepend-path LD_LIBRARY_PATH    $env(FOAM_LIBBIN):$env(FOAM_LIBBIN)/$env(FOAM_MPI):$env(FOAM_LIBBIN)/dummy:$env(WM_THIRD_PARTY_DIR)/platforms/$env(WM_OPTIONS)/lib:$env(WM_THIRD_PARTY_DIR)/platforms/$env(WM_OPTIONS)/lib/$env(FOAM_MPI):$env(FOAM_USER_LIBBIN):$env(FOAM_SITE_LIBBIN):$env(ParaView_DIR)/lib/paraview-4.1

prepend-path PATH               $env(WM_PROJECT_DIR)/bin:$env(FOAM_APPBIN):$env(WM_PROJECT_DIR)/wmake:$env(FOAM_USER_APPBIN):$env(FOAM_SITE_APPBIN):$env(ParaView_DIR)/bin

modulefile.txt (3,998 bytes)   

henry

2015-03-01 20:34

manager   ~0003928

@Bruno, does removing the addCMakeVariable lines work for your builds?

wyldckat

2015-03-01 21:07

updater   ~0003932

@Henry: I haven't tested that yet. And probably I will only be able to do it next weekend, namely a few battery of tests for a few MPI versions (custom Open-MPI, system Open-MPI, system MPICH and custom MPICH).


@Hakostra: There's SCONS, Gyp and a few other alternatives to CMake, precisely because CMake isn't the solution for all situations ;)
In addition, if I'm not mistaken, CMake is 10 or more years younger than "wmake": http://en.wikipedia.org/wiki/CMake

wyldckat

2015-03-07 13:58

updater  

ParaViewFunctions (14,136 bytes)   
#---------------------------------*- sh -*-------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM.
#
#     OpenFOAM is free software: you can redistribute it and/or modify it
#     under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
#     for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
#
# File
#     etc/tools/ParaViewFunctions
#
# Description
#     ParaView make/install helper functions
#
#------------------------------------------------------------------------------

# buildBASE, installBASE defined from tools/ThirdPartyFunctions

#
# where things are or should be put
#   ParaView_VERSION and ParaView_MAJOR should already have been set
#
#   ParaView_SOURCE_DIR : location of the original sources
#   ParaView_BINARY_DIR : location of the build
#   ParaView_DIR        : location of the installed program
#
setDirs()
{
    ParaView_SOURCE_DIR=$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION

    [ -d "$ParaView_SOURCE_DIR" ] || {
        echo "did not find ParaView-$ParaView_VERSION in these directories:"
        echo "  WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
        echo
        echo "abort build"
        exit 1
    }

    # ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION-$OBJ_ADD
    ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION

    # ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION-$OBJ_ADD
    ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION

    export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR

    echo
    echo "ParaView_SOURCE_DIR=$ParaView_SOURCE_DIR"
    echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR"
    echo "ParaView_DIR=$ParaView_DIR"
}


#
# set ParaView_VERSION and adjust ParaView_MAJOR accordingly
#
setVersion()
{
    [ "$#" -ge 1 ] && ParaView_VERSION="${1##paraview-}"

    # the major version is "<digits>.<digits>"
    ParaView_MAJOR=$(echo $ParaView_VERSION | \
        sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')

    export ParaView_VERSION ParaView_MAJOR
}


#------------------------------------------------------------------------------

#
# extract and echo date stamp information from
#     VTK/Utilities/kwsys/kwsysDateStamp.cmake
# since the order of the entries is already correct, can use simple sed script
#
echoDateStamp()
{
    (
        set -- $(
            sed -ne 's/^SET(KWSYS_DATE_STAMP_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
            $ParaView_SOURCE_DIR/VTK/Utilities/kwsys/kwsysDateStamp.cmake
        )

        IFS='-'
        echo "date-stamp: $*"
    )
}


#
# extract version information from
#     CMakeLists.txt
# since the order of the entries is already correct, can use simple sed script
#
getVersion()
{
    (
        set -- $(
            sed -ne 's/^SET(PARAVIEW_VERSION_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
            $ParaView_SOURCE_DIR/CMakeLists.txt
        )

        IFS='.'
        echo "$*"
    )
}

#
# compare version information
#
checkVersion()
{
    local ver=$(getVersion)
    if [ "$ParaView_VERSION" != "$ver" ]
    then
        echo "MISMATCH!"
        echo "    specified $ParaView_VERSION"
        echo "    found     $ver"
    fi
}

#
# set CMake cache variables
#
addCMakeVariable()
{
    while [ -n "$1" ]
    do
        CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
        shift
    done
}


#
# verbose makefiles
#
addVerbosity()
{
    [ "$withVERBOSE" = true ] && addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
}


#
# define options for mpi support
#
addMpiSupport()
{
    [ "${withMPI:=false}" = true ] || return
    OBJ_ADD="$OBJ_ADD-mpi"

    addCMakeVariable  "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
    addCMakeVariable  "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
}


#
# define options for python support
#
addPythonSupport()
{
    [ "${withPYTHON:=false}" = true ] || return
    OBJ_ADD="$OBJ_ADD-py"

    if pythonBin=$(which python 2>/dev/null)
    then
        if [ -n "$PYTHON_LIBRARY" ]
        then
            # check $PYTHON_LIBRARY if it has been set
            if [ ! -e "$PYTHON_LIBRARY" ]
            then
                echo "*** Error: libpython not found at location specified " \
                     "by -pythnon-lib input: PYTHON_LIBRARY=$PYTHON_LIBRARY"
            fi
        else
            # Try to get $PYTHON_LIBRARY from dynamically linked binary
            PYTHON_LIBRARY=$(ldd $pythonBin | \
                sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')

           [ -e "$PYTHON_LIBRARY" ] || {
               echo "*** Error: Unable to determine path to python library."
           }
        fi

        [ -e "$PYTHON_LIBRARY" ] || {
            echo "    Please set the full path to the python library "
            echo "    (including libpython) using the -python-lib option, "
            echo "    or deactivate python support by not using the -python "
            echo "    option"
            exit 1
        }

        pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
        pythonInclude=/usr/include/python$pythonMajor

        # note - we could also allow for a PYTHON_INCLUDE variable ...
        [ -d "$pythonInclude" ] || {
            echo "    No python headers found in $pythonInclude/"
            echo "    Please install python headers or deactivate "
            echo "    python support by not using the -python option"
            exit 1
        }

        addCMakeVariable  "PARAVIEW_ENABLE_PYTHON=ON"
        addCMakeVariable  "PYTHON_INCLUDE_PATH=$pythonInclude"
        addCMakeVariable  "PYTHON_LIBRARY=$PYTHON_LIBRARY"

        echo "----"
        echo "Python information:"
        echo "    executable     : $pythonBin"
        echo "    version        : $pythonMajor"
        echo "    include path   : $pythonInclude"
        echo "    library        : $PYTHON_LIBRARY"

        unset pythonBin pythonInclude pythonMajor
    else
        echo "*** Error: python not found"
        echo "***        Deactivate python support by not using the -python "
        echo "***        option"
        exit 1
    fi
}


#
# define options for mesa support
#
addMesaSupport()
{
    [ "${withMESA:=false}" = true ] || return

    if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
    then
        OBJ_ADD="$OBJ_ADD-mesa"

        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA=ON"
        addCMakeVariable  "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
        addCMakeVariable  "OSMESA_LIBRARY=$MESA_LIBRARY"

    else
       echo "*** Error: no MESA information found"
       echo "***        Deactivate MESA support by not using the -mesa option, "
       echo "***        or set the correct paths for:"
       echo "***        -mesa-include ($MESA_INCLUDE)"
       echo "***        -mesa-lib ($MESA_LIBRARY)"
       exit 1
    fi
}


addQtSupport()
{
    QtVersion=none
    [ "${withQT:=false}" = true ] || return

    addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"

    unset qmakeExe
    if [ -n "$QMAKE_PATH" ]
    then
        if [ -d "$QMAKE_PATH" ]
        then
            if [ -x "$QMAKE_PATH/qmake" ]
            then
                qmakeExe=$QMAKE_PATH/qmake
            elif [ -x "$QMAKE_PATH/bin/qmake" ]
            then
                qmakeExe=$QMAKE_PATH/bin/qmake
            fi
        elif [ -x "$QMAKE_PATH" ]
        then
            qmakeExe=$QMAKE_PATH
        fi

        if [ -n "$qmakeExe" ]
        then
            # use absolute path
            if [ "${qmakeExe#/}" = "$qmakeExe" ]
            then
                qmakeExe="$(cd ${qmakeExe%/qmake} 2>/dev/null && pwd)/qmake"
            fi
        else
            echo
            echo "qmake not found under specified QMAKE_PATH"
            echo "    QMAKE_PATH=$QMAKE_PATH"
            echo "leaving unspecified"
            echo
        fi
    fi

    # default to using qmake from the path
    if [ -n "$qmakeExe" ]
    then
        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmakeExe"
    else
        qmakeExe=qmake
    fi


    # Check qmake can be found
    if type $qmakeExe >/dev/null 2>&1
    then
        # Check the Qt version selected
        # parse -> "Using Qt version X.Y.Z in ..."
        QtVersion=$($qmakeExe -query QT_VERSION)

        # split Major.Minor.Revision - could also use IFS hacking
        set -- $(echo "$QtVersion" | sed -e 's/\./ /g')

        QtMajor=$1
        QtMinor=$2

        if [ $QtMajor -lt 4 -o $QtMinor -lt 5 ]
        then
            echo "*** Error: Qt version provided < 4.5"
            echo "***     Please use the -qmake option to specify the location of a version of Qt >= 4.3 "
            echo "***     e.g."
            echo "***         -qmake /usr/local/qt-4.6.2/bin/qmake"
            echo "***         -qmake $installBASE/qt-4.6.2/bin/qmake"
            exit 1
        fi
    else
        echo "*** Error: cannot find qmake either at \$QMAKE_PATH or in current \$PATH"
        exit 1
    fi
}


#
# configure via cmake, but don't actually build anything
#
configParaView()
{
    unset cmakeExe
    if [ -n "$CMAKE_PATH" ]
    then
        if [ -d "$CMAKE_PATH" ]
        then
            if [ -x "$CMAKE_PATH/cmake" ]
            then
                cmakeExe=$CMAKE_PATH/cmake
            elif [ -x "$CMAKE_PATH/bin/cmake" ]
            then
                cmakeExe=$CMAKE_PATH/bin/cmake
            fi
        elif [ -x "$CMAKE_PATH" ]
        then
            cmakeExe=$CMAKE_PATH
        fi

        if [ -n "$cmakeExe" ]
        then
            # use absolute path
            if [ "${cmakeExe#/}" = "$cmakeExe" ]
            then
                cmakeExe="$(cd ${cmakeExe%/cmake} 2>/dev/null && pwd)/cmake"
            fi
        else
            echo
            echo "cmake not found under specified CMAKE_PATH"
            echo "    CMAKE_PATH=$CMAKE_PATH"
            echo "leaving unspecified"
            echo
        fi
    fi

    # default to using cmake from the path
    [ -n "$cmakeExe" ] || cmakeExe=cmake

    # remove any existing build folder and recreate
    if [ -d $ParaView_BINARY_DIR ]
    then
        echo "removing old build directory"
        echo "    $ParaView_BINARY_DIR"
        rm -rf $ParaView_BINARY_DIR
    fi
    mkdir -p $ParaView_BINARY_DIR

    cd $ParaView_BINARY_DIR || exit 1  # change to build folder

    echo "----"
    echo "Configuring paraview-$ParaView_VERSION (major version: $ParaView_MAJOR)"
    echo "    MPI    support : ${withMPI:-false}"
    echo "    Python support : ${withPYTHON:-false}"
    echo "    MESA   support : ${withMESA:-false}"
    echo "    Qt dev support : ${withQT:-false}"
    echo "    Source         : $ParaView_SOURCE_DIR"
    echo "    Build          : $ParaView_BINARY_DIR"
    echo "    Target         : $ParaView_DIR"
    echo "----"
    echo
    echo "$cmakeExe" \
        -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
        $CMAKE_VARIABLES \
        $ParaView_SOURCE_DIR
    echo
    echo "----"
    echo

    # run cmake to create Makefiles
    $cmakeExe \
        -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
        $CMAKE_VARIABLES \
        $ParaView_SOURCE_DIR
}


#
# invoke make
# also link bin/ to lib/paraview-* for development without installation
#
makeParaView()
{
    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
    echo "    Starting make"
    time make -j $WM_NCOMPPROCS
    echo "    Done make"

    # remove lib if it is a link
    # (how this was previously handled before 'make install' worked)
    [ -L lib ] && rm lib 2>/dev/null
}


#
# install the program
#
installParaView()
{
    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
    echo "    Installing ParaView to $ParaView_DIR"

    make install

# hack for missing files after install of version 3.14.1
    echo "Copying missing files to install folder"
    CMAKE_SRC_DIR=$ParaView_SOURCE_DIR/CMake
    CMAKE_INSTALL_DIR=$ParaView_DIR/lib/paraview-$ParaView_MAJOR/CMake
    cp -f $ParaView_SOURCE_DIR/ParaViewUse.cmake $CMAKE_INSTALL_DIR
    cp -f $CMAKE_SRC_DIR/generate_proxydocumentation.cmake $CMAKE_INSTALL_DIR
    cp -f $CMAKE_SRC_DIR/smxml_to_xml.xsl $CMAKE_INSTALL_DIR
    cp -f $CMAKE_SRC_DIR/xml_to_html.xsl $CMAKE_INSTALL_DIR
    cp -f $CMAKE_SRC_DIR/xml_to_wiki.xsl.in $CMAKE_INSTALL_DIR
    cp -f $CMAKE_SRC_DIR/generate_qhp.cmake $CMAKE_INSTALL_DIR
    unset CMAKE_SRC_DIR CMAKE_INSTALL_DIR
# --- end hack

cat<< INFO
    ---
    Installation complete for paraview-$ParaView_VERSION
    Set environment variables:

        export ParaView_DIR=$ParaView_DIR
        export PATH=\$ParaView_DIR/bin:\$PATH
        export PV_PLUGIN_PATH=\$FOAM_LIBBIN/paraview-$ParaView_MAJOR
    ---
INFO
}


#------------------------------------------------------------------------------

# clear the referenced variables before using any of the functions
unset withMPI  withVERBOSE
unset withQT      QMAKE_PATH
unset withMESA    MESA_INCLUDE    MESA_LIBRARY
unset withPYTHON  PYTHON_INCLUDE  PYTHON_LIBRARY
unset CMAKE_VARIABLES
unset OBJ_ADD


# start with these general settings
addCMakeVariable  "VTK_USE_TK:BOOL=OFF"
addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"
addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=Release"

# include development files in "make install"
addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON"

# don't build test tree
addCMakeVariable  "BUILD_TESTING:BOOL=OFF"

# remove dependency on WebKit
# addCMakeVariable  VTK_QT_USE_WEBKIT:BOOL=OFF

# ----------------------------------------------------------------- end-of-file
ParaViewFunctions (14,136 bytes)   

wyldckat

2015-03-07 13:58

updater  

ParaView4Functions (13,494 bytes)   
#---------------------------------*- sh -*-------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
#   \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM.
#
#     OpenFOAM is free software: you can redistribute it and/or modify it
#     under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
#     for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
#
# File
#     etc/tools/ParaViewFunctions
#
# Description
#     ParaView make/install helper functions
#
#------------------------------------------------------------------------------

# buildBASE, installBASE defined from tools/ThirdPartyFunctions

#
# where things are or should be put
#   ParaView_VERSION and ParaView_MAJOR should already have been set
#
#   ParaView_SOURCE_DIR : location of the original sources
#   ParaView_BINARY_DIR : location of the build
#   ParaView_DIR        : location of the installed program
#
setDirs()
{
    ParaView_SOURCE_DIR=$WM_THIRD_PARTY_DIR/ParaView-$ParaView_VERSION

    [ -d "$ParaView_SOURCE_DIR" ] || {
        echo "did not find ParaView-$ParaView_VERSION in these directories:"
        echo "  WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
        echo
        echo "abort build"
        exit 1
    }

    # ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION-$OBJ_ADD
    ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION

    # ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION-$OBJ_ADD
    ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION

    export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR

    echo
    echo "ParaView_SOURCE_DIR=$ParaView_SOURCE_DIR"
    echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR"
    echo "ParaView_DIR=$ParaView_DIR"
}


#
# set ParaView_VERSION and adjust ParaView_MAJOR accordingly
#
setVersion()
{
    [ "$#" -ge 1 ] && ParaView_VERSION="${1##paraview-}"

    # the major version is "<digits>.<digits>"
    ParaView_MAJOR=$(echo $ParaView_VERSION | \
        sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')

    export ParaView_VERSION ParaView_MAJOR
}


#------------------------------------------------------------------------------

#
# extract and echo date stamp information from
#     VTK/Utilities/kwsys/kwsysDateStamp.cmake
# since the order of the entries is already correct, can use simple sed script
#
echoDateStamp()
{
    (
        set -- $(
            sed -ne 's/^SET(KWSYS_DATE_STAMP_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
            $ParaView_SOURCE_DIR/VTK/Utilities/kwsys/kwsysDateStamp.cmake
        )

        IFS='-'
        echo "date-stamp: $*"
    )
}


#
# extract version information from
#     CMakeLists.txt
# since the order of the entries is already correct, can use simple sed script
#
getVersion()
{
    (
        set -- $(
            sed -ne 's/^SET(PARAVIEW_VERSION_[A-Z]*\([ 0-9]*\)).*$/\1/p' \
            $ParaView_SOURCE_DIR/CMakeLists.txt
        )

        IFS='.'
        echo "$*"
    )
}

#
# compare version information
#
checkVersion()
{
    local ver=$(getVersion)
    if [ "$ParaView_VERSION" != "$ver" ]
    then
        echo "MISMATCH!"
        echo "    specified $ParaView_VERSION"
        echo "    found     $ver"
    fi
}

#
# set CMake cache variables
#
addCMakeVariable()
{
    while [ -n "$1" ]
    do
        CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
        shift
    done
}


#
# verbose makefiles
#
addVerbosity()
{
    [ "$withVERBOSE" = true ] && addCMakeVariable  "CMAKE_VERBOSE_MAKEFILE=TRUE"
}


#
# define options for mpi support
#
addMpiSupport()
{
    [ "${withMPI:=false}" = true ] || return
    OBJ_ADD="$OBJ_ADD-mpi"

    addCMakeVariable  "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON"
    addCMakeVariable  "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS"
}


#
# define options for python support
#
addPythonSupport()
{
    [ "${withPYTHON:=false}" = true ] || return
    OBJ_ADD="$OBJ_ADD-py"

    if pythonBin=$(which python 2>/dev/null)
    then
        if [ -n "$PYTHON_LIBRARY" ]
        then
            # check $PYTHON_LIBRARY if it has been set
            if [ ! -e "$PYTHON_LIBRARY" ]
            then
                echo "*** Error: libpython not found at location specified " \
                     "by -pythnon-lib input: PYTHON_LIBRARY=$PYTHON_LIBRARY"
            fi
        else
            # Try to get $PYTHON_LIBRARY from dynamically linked binary
            PYTHON_LIBRARY=$(ldd $pythonBin | \
                sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')

           [ -e "$PYTHON_LIBRARY" ] || {
               echo "*** Error: Unable to determine path to python library."
           }
        fi

        [ -e "$PYTHON_LIBRARY" ] || {
            echo "    Please set the full path to the python library "
            echo "    (including libpython) using the -python-lib option, "
            echo "    or deactivate python support by not using the -python "
            echo "    option"
            exit 1
        }

        pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
        pythonInclude=/usr/include/python$pythonMajor

        # note - we could also allow for a PYTHON_INCLUDE variable ...
        [ -d "$pythonInclude" ] || {
            echo "    No python headers found in $pythonInclude/"
            echo "    Please install python headers or deactivate "
            echo "    python support by not using the -python option"
            exit 1
        }

        addCMakeVariable  "PARAVIEW_ENABLE_PYTHON=ON"
        addCMakeVariable  "PYTHON_INCLUDE_PATH=$pythonInclude"
        addCMakeVariable  "PYTHON_LIBRARY=$PYTHON_LIBRARY"

        echo "----"
        echo "Python information:"
        echo "    executable     : $pythonBin"
        echo "    version        : $pythonMajor"
        echo "    include path   : $pythonInclude"
        echo "    library        : $PYTHON_LIBRARY"

        unset pythonBin pythonInclude pythonMajor
    else
        echo "*** Error: python not found"
        echo "***        Deactivate python support by not using the -python "
        echo "***        option"
        exit 1
    fi
}


#
# define options for mesa support
#
addMesaSupport()
{
    [ "${withMESA:=false}" = true ] || return

    if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
    then
        OBJ_ADD="$OBJ_ADD-mesa"

        addCMakeVariable  "VTK_OPENGL_HAS_OSMESA=ON"
        addCMakeVariable  "OSMESA_INCLUDE_DIR=$MESA_INCLUDE"
        addCMakeVariable  "OSMESA_LIBRARY=$MESA_LIBRARY"

    else
       echo "*** Error: no MESA information found"
       echo "***        Deactivate MESA support by not using the -mesa option, "
       echo "***        or set the correct paths for:"
       echo "***        -mesa-include ($MESA_INCLUDE)"
       echo "***        -mesa-lib ($MESA_LIBRARY)"
       exit 1
    fi
}


addQtSupport()
{
    QtVersion=none
    [ "${withQT:=false}" = true ] || return

    addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"

    unset qmakeExe
    if [ -n "$QMAKE_PATH" ]
    then
        if [ -d "$QMAKE_PATH" ]
        then
            if [ -x "$QMAKE_PATH/qmake" ]
            then
                qmakeExe=$QMAKE_PATH/qmake
            elif [ -x "$QMAKE_PATH/bin/qmake" ]
            then
                qmakeExe=$QMAKE_PATH/bin/qmake
            fi
        elif [ -x "$QMAKE_PATH" ]
        then
            qmakeExe=$QMAKE_PATH
        fi

        if [ -n "$qmakeExe" ]
        then
            # use absolute path
            if [ "${qmakeExe#/}" = "$qmakeExe" ]
            then
                qmakeExe="$(cd ${qmakeExe%/qmake} 2>/dev/null && pwd)/qmake"
            fi
        else
            echo
            echo "qmake not found under specified QMAKE_PATH"
            echo "    QMAKE_PATH=$QMAKE_PATH"
            echo "leaving unspecified"
            echo
        fi
    fi

    # default to using qmake from the path
    if [ -n "$qmakeExe" ]
    then
        addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmakeExe"
    else
        qmakeExe=qmake
    fi


    # Check qmake can be found
    if type $qmakeExe >/dev/null 2>&1
    then
        # Check the Qt version selected
        # parse -> "Using Qt version X.Y.Z in ..."
        QtVersion=$($qmakeExe -query QT_VERSION)

        # split Major.Minor.Revision - could also use IFS hacking
        set -- $(echo "$QtVersion" | sed -e 's/\./ /g')

        QtMajor=$1
        QtMinor=$2

        if [ $QtMajor -lt 4 -o $QtMinor -lt 5 ]
        then
            echo "*** Error: Qt version provided < 4.5"
            echo "***     Please use the -qmake option to specify the location of a version of Qt >= 4.3 "
            echo "***     e.g."
            echo "***         -qmake /usr/local/qt-4.6.2/bin/qmake"
            echo "***         -qmake $installBASE/qt-4.6.2/bin/qmake"
            exit 1
        fi
    else
        echo "*** Error: cannot find qmake either at \$QMAKE_PATH or in current \$PATH"
        exit 1
    fi
}


#
# configure via cmake, but don't actually build anything
#
configParaView()
{
    unset cmakeExe
    if [ -n "$CMAKE_PATH" ]
    then
        if [ -d "$CMAKE_PATH" ]
        then
            if [ -x "$CMAKE_PATH/cmake" ]
            then
                cmakeExe=$CMAKE_PATH/cmake
            elif [ -x "$CMAKE_PATH/bin/cmake" ]
            then
                cmakeExe=$CMAKE_PATH/bin/cmake
            fi
        elif [ -x "$CMAKE_PATH" ]
        then
            cmakeExe=$CMAKE_PATH
        fi

        if [ -n "$cmakeExe" ]
        then
            # use absolute path
            if [ "${cmakeExe#/}" = "$cmakeExe" ]
            then
                cmakeExe="$(cd ${cmakeExe%/cmake} 2>/dev/null && pwd)/cmake"
            fi
        else
            echo
            echo "cmake not found under specified CMAKE_PATH"
            echo "    CMAKE_PATH=$CMAKE_PATH"
            echo "leaving unspecified"
            echo
        fi
    fi

    # default to using cmake from the path
    [ -n "$cmakeExe" ] || cmakeExe=cmake

    # remove any existing build folder and recreate
    if [ -d $ParaView_BINARY_DIR ]
    then
        echo "removing old build directory"
        echo "    $ParaView_BINARY_DIR"
        rm -rf $ParaView_BINARY_DIR
    fi
    mkdir -p $ParaView_BINARY_DIR

    addCMakeVariable  "CMAKE_BUILD_TYPE:STRING=$buildType"

    cd $ParaView_BINARY_DIR || exit 1  # change to build folder

    echo "----"
    echo "Configuring paraview-$ParaView_VERSION (major version: $ParaView_MAJOR)"
    echo "    MPI    support : ${withMPI:-false}"
    echo "    Python support : ${withPYTHON:-false}"
    echo "    MESA   support : ${withMESA:-false}"
    echo "    Qt dev support : ${withQT:-false}"
    echo "    Source         : $ParaView_SOURCE_DIR"
    echo "    Build          : $ParaView_BINARY_DIR"
    echo "    Target         : $ParaView_DIR"
    echo "    Build type     : $buildType"
    echo "----"
    echo
    echo "$cmakeExe" \
        -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
        $CMAKE_VARIABLES \
        $ParaView_SOURCE_DIR
    echo
    echo "----"
    echo

    # run cmake to create Makefiles
    $cmakeExe \
        -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
        $CMAKE_VARIABLES \
        $ParaView_SOURCE_DIR
}


#
# invoke make
# also link bin/ to lib/paraview-* for development without installation
#
makeParaView()
{
    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
    echo "    Starting make"
    time make -j $WM_NCOMPPROCS
    echo "    Done make"

    # remove lib if it is a link
    # (how this was previously handled before 'make install' worked)
    [ -L lib ] && rm lib 2>/dev/null
}


#
# install the program
#
installParaView()
{
    cd $ParaView_BINARY_DIR || exit 1  # change to build folder
    echo "    Installing ParaView to $ParaView_DIR"

    make install

cat<< INFO
    ---
    Installation complete for paraview-$ParaView_VERSION
    Set environment variables:

        export ParaView_DIR=$ParaView_DIR
        export PATH=\$ParaView_DIR/bin:\$PATH
        export PV_PLUGIN_PATH=\$FOAM_LIBBIN/paraview-$ParaView_MAJOR
    ---
INFO
}


#------------------------------------------------------------------------------

# clear the referenced variables before using any of the functions
unset withMPI  withVERBOSE
unset withQT      QMAKE_PATH
unset withMESA    MESA_INCLUDE    MESA_LIBRARY
unset withPYTHON  PYTHON_INCLUDE  PYTHON_LIBRARY
unset CMAKE_VARIABLES
unset OBJ_ADD
unset buildType

# start with these general settings
addCMakeVariable  "BUILD_SHARED_LIBS:BOOL=ON  VTK_USE_RPATH:BOOL=OFF"

# include development files in "make install"
addCMakeVariable  "PARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON"

# don't build test tree
addCMakeVariable  "BUILD_TESTING:BOOL=OFF"

# remove dependency on WebKit
# addCMakeVariable  VTK_QT_USE_WEBKIT:BOOL=OFF


# ----------------------------------------------------------------- end-of-file
ParaView4Functions (13,494 bytes)   

wyldckat

2015-03-07 14:09

updater   ~0003996

Last edited: 2015-03-07 14:14

Attached are the updated files "ParaView*Functions" for "ThirdParty-2.3.x/etc/tools".

I've tested in Ubuntu 14.04 and the system's CMake 2.8.12.2, with:
 - system's MPICH2
 - system's Open-MPI
 - Custom Open-MPI

CMake is able to pick up automatically the include folder, library paths and mpiexec/mpirun binaries respective to the active MPI toolbox, without us telling it.

henry

2015-03-07 15:10

manager   ~0003998

Thanks Bruno for testing the change with a selection of MPI versions.

Resolved commit 3bb1c31947821f891f85dfebeddedb311f9a8c9d

Issue History

Date Modified Username Field Change
2015-02-27 08:55 user507 New Issue
2015-02-28 21:00 wyldckat Note Added: 0003923
2015-03-01 19:39 user507 Note Added: 0003926
2015-03-01 19:40 user507 File Added: modulefile.txt
2015-03-01 20:34 henry Note Added: 0003928
2015-03-01 21:07 wyldckat Note Added: 0003932
2015-03-07 13:58 wyldckat File Added: ParaViewFunctions
2015-03-07 13:58 wyldckat File Added: ParaView4Functions
2015-03-07 14:09 wyldckat Note Added: 0003996
2015-03-07 14:14 wyldckat Note Edited: 0003996
2015-03-07 15:10 henry Note Added: 0003998
2015-03-07 15:10 henry Status new => resolved
2015-03-07 15:10 henry Resolution open => fixed
2015-03-07 15:10 henry Assigned To => henry