Installing kratos in macOS

From KratosWiki
(Difference between revisions)
Jump to: navigation, search
(Install Xcode)
 
(20 intermediate revisions by one user not shown)
Line 30: Line 30:
  
 
Agree if you are asked to download necessary additional packages and, after a while, you should have LLVM installed in "/usr/local/opt/llvm" and the Clang version compatible with OMP in "/usr/local/opt/llvm/bin".
 
Agree if you are asked to download necessary additional packages and, after a while, you should have LLVM installed in "/usr/local/opt/llvm" and the Clang version compatible with OMP in "/usr/local/opt/llvm/bin".
 
== Download Kratos  ==
 
 
Next we must download the Kratos Multiphysics source code by means of a subversion manager. The Command Line Tools installed with Xcode already include Apache Subverison, thus we just need to open a Terminal and use the following command:
 
 
svn co https://svn.cimne.upc.edu/p/kratos/kratos
 
 
It is possible that you get an error message in the validation of the server certificate, for which you will be asked to either reject, accept temporarily or accept permanently the certificate. You need to accept it permanently, thus write ''p'' and then press ''enter''. If the download does not start, use again the command "svn co https://svn.cimne.upc.edu/p/kratos/kratos" and wait until you see a message like
 
 
Checked out revision 17106.
 
 
with the latest revision number. After that, you should have the latest revision of Kratos in the folder "/Users/''youruser''/kratos".
 
  
 
== Install Python  ==
 
== Install Python  ==
  
'''Download''' the latest version of '''Python 3''' compatible with your mac from https://www.python.org/downloads/mac-osx/ . In the moment of writing this text the latest version was Python 3.5.2. '''Right-click''' on the downloaded file, e.g. "python-3.5.2-macosx10.6.pkg", and open it to initialise the '''installation wizard of Python'''. Once Python 3 is installed, you can erase the downloaded package to save space. Moreover, to check that Python 3 is properly configured, open a Terminal and run the following command to see the version  
+
Download the latest version of Python 3 compatible with your mac from https://www.python.org/downloads/mac-osx/ . In the moment of writing this text the latest version was Python 3.5.2. Right-click on the downloaded file, e.g. "python-3.5.2-macosx10.6.pkg", and open it to initialise the installation wizard of Python. Once Python 3 is installed, you can erase the downloaded package to save space. Moreover, to check that Python 3 is properly configured, open a Terminal and run the following command to see the version  
  
 
  python3 --version
 
  python3 --version
Line 51: Line 39:
 
== Install Boost  ==
 
== Install Boost  ==
  
Kratos Multiphysics needs Boost libraries to support some of its functions. '''Download''' the latest compatible version of '''Boost''' from its official website http://www.boost.org/users/history/ . This tutorial has been tested with version 1.62.0. You can use any version from 1.54 onward '''except for 1.60'''.  
+
Kratos Multiphysics needs Boost libraries to support some of its functions. Download the latest compatible version of Boost from its official website http://www.boost.org/users/history/ . This tutorial has been tested with version 1.62.0. You can use any version from 1.54 onward '''except for 1.60 and 1.63'''.  
  
Open the downloaded file "boost_1_62_0.tar.bz2" to obtain a folder named "boost_1_62_0". You can then erase the compressed file and move the resulting folder into "/Users/''youruser''/kratos/external_libraries/".
+
Open the downloaded file "boost_1_62_0.tar.bz2" to obtain a folder named "boost_1_62_0". You can then erase the compressed file and move the resulting folder to the desired location for Boost.
  
 
Open a Terminal and navigate to the Boost folder, i.e.
 
Open a Terminal and navigate to the Boost folder, i.e.
  
  cd
+
  cd /full/path/to/boost_1_62_0
cd kratos/external_libraries/boost_1_62_0/
+
  
 
Then execute the following command:
 
Then execute the following command:
Line 68: Line 55:
 
  open -e project-config.jam
 
  open -e project-config.jam
  
and modify the Python configuration section substituting the line in red by the one in green:
+
and modify the Python configuration section as:
  
 
  # Boost.Build Configuration
 
  # Boost.Build Configuration
Line 90: Line 77:
 
  if ! [ python.configured ]
 
  if ! [ python.configured ]
 
  {
 
  {
     <span style="color:red">'''using python : 2.7 : /System/Library/Frameworks/Python.framework/Versions/2.7 ;'''</span>
+
     using python : 3.5 : /Library/Frameworks/Python.framework/Versions/3.5 : /Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m ;
    <span style="color:green">'''using python : 3.5 : /Library/Frameworks/Python.framework/Versions/3.5 : /Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m ;'''</span>
+
 
  }
 
  }
 
   
 
   
Line 110: Line 96:
 
  option.set keep-going : false ;
 
  option.set keep-going : false ;
  
Finally we will compile Boost in "/Users/''youruser''/kratos/external_libraries/boost_1_62_0/stage". Being inside "/Users/''youruser''/kratos/external_libraries/boost_1_62_0" in the Terminal, run the following command
+
We finally compile Boost with the following command:
  
 
  ./b2 stage --with-python --with-serialization cxxflags="-std=c++11" link=shared,static
 
  ./b2 stage --with-python --with-serialization cxxflags="-std=c++11" link=shared,static
Line 120: Line 106:
 
== Install CMake  ==
 
== Install CMake  ==
  
CMake is the tool used to compile Kratos. '''Download''' the '''CMake''' latest release for your Mac version in https://cmake.org/download/ . In our case it was CMake 3.7.1. Open the downloaded file, e.g. "cmake-3.7.1-Darwin-x86_64.dmg", and agree the License Agreement terms. Then '''drag and drop''' the CMake application into your Applications folder.  After that you can eject "cmake-3.7.1-Darwin-x86_64" and erase it to save space.
+
CMake is the tool used to compile Kratos. Download the CMake latest release for your Mac version in https://cmake.org/download/ . In our case it was CMake 3.7.1. Open the downloaded file, e.g. "cmake-3.7.1-Darwin-x86_64.dmg", and agree the License Agreement terms. Then drag and drop the CMake application into your Applications folder.  After that you can eject "cmake-3.7.1-Darwin-x86_64" and erase it to save space.
  
Finally go to your Applications folder and '''right-click CMake.app''' to open it. Then you can quit CMake (''cmd+q'').
+
Finally go to your Applications folder and right-click CMake.app to open it. Then you can quit CMake (''cmd+q'').
 +
 
 +
== Download Kratos  ==
 +
 
 +
Next we must download the Kratos Multiphysics source code by means of a git manager. The Command Line Tools installed with Xcode already includes git, thus we just need to open a Terminal and use the following command:
 +
 
 +
git clone https://github.com/KratosMultiphysics/Kratos Kratos
 +
 
 +
After that, you should have the latest revision of Kratos in the folder "/Users/''youruser''/Kratos".
  
 
== Configure Kratos ==
 
== Configure Kratos ==
  
When compiling Kratos for the first time, one needs to properly customise the configuration file. Open a Terminal, navigate to your "kratos/cmake_build" folder and make a copy of the template file:
+
When compiling Kratos for the first time, one needs to properly customise the configuration file. Open a Terminal, navigate to your "Kratos/cmake_build" folder and make a copy of the template file:
  
 
  cd
 
  cd
  cd kratos/cmake_build/
+
  cd Kratos/cmake_build/
 
  cp example_configure.sh.do_not_touch release_configure.sh
 
  cp example_configure.sh.do_not_touch release_configure.sh
  
Open "release_configure.sh" file with any text editor and modify it like follows.  First, indicate the full path of '''CMake''':
+
Open "release_configure.sh" file with any text editor and modify it like follows.  First, indicate the full path of CMake:
  
  <span style="color:red">cmake ..                              \</span>
+
  /Applications/CMake.app/Contents/bin/cmake ..                                                \
<span style="color:green">/Applications/CMake.app/Contents/bin/cmake ..                                                \</span>
+
  
Next, specify the '''path of the Clang compiler''' installed with Homebrew:
+
Next, specify the path of the Clang compiler installed with Homebrew:
  
  <span style="color:red">-DCMAKE_C_COMPILER=/usr/bin/gcc                                     \</span>
+
  -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang                 \
<span style="color:green">-DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang                 \</span>
+
  
  <span style="color:red">-DCMAKE_CXX_COMPILER=/usr/bin/g++                             \</span>
+
  -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++                                        \
<span style="color:green">-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++                                        \</span>
+
  
In order to '''detect OpenMP_FLAG''' during the compilation, it is necessary to specify the path to the libraries for the Clang compiler in the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS:
+
In order to detect OpenMP_FLAG during the compilation, it is necessary to specify the path to the libraries for the Clang compiler in the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS:
  
  <span style="color:red">-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11"                                    \</span>
+
  -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -L/usr/local/opt/llvm/lib"          \
<span style="color:green">-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -L/usr/local/opt/llvm/lib"          \</span>
+
  
  <span style="color:red">-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3"                                                    \</span>
+
  -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib"                          \
<span style="color:green">-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib"                          \</span>
+
  
Now, provide the path of '''Boost''' and '''Python 3''' directories, and the location of '''Lapack''' and '''Blas''' libraries. If you followed the steps in this tutorial, just add the following lines <span style="color:red">changing "''youruser''" by the name of your home folder</span>:
+
Now, provide the path of Boost and Python 3 directories, and the location of Lapack and Blas libraries. If you followed the steps in this tutorial, just add the following lines '''setting the path to Boost properly''':
  
  -DBOOST_ROOT="/Users/<span style="color:red">''youruser''</span>/kratos/external_libraries/boost_1_62_0"                        \
+
  -DBOOST_ROOT="/full/path/to/boost_1_62_0"                        \
  -DBOOST_LIBRARYDIR="/Users/<span style="color:red">''youruser''</span>/kratos/external_libraries/boost_1_62_0/stage/lib"        \
+
  -DBOOST_LIBRARYDIR="/full/path/to/boost_1_62_0/stage/lib"        \
 
  -DPYTHON_LIBRARY="/Library/Frameworks/Python.framework/Versions/3.5/Python"                  \
 
  -DPYTHON_LIBRARY="/Library/Frameworks/Python.framework/Versions/3.5/Python"                  \
 
  -DPYTHON_INCLUDE_DIR="/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m"  \
 
  -DPYTHON_INCLUDE_DIR="/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m"  \
Line 162: Line 151:
 
  -DBLAS_LIBRARIES="/usr/lib/libblas.dylib"                                                    \
 
  -DBLAS_LIBRARIES="/usr/lib/libblas.dylib"                                                    \
  
Furthermore, in order to compile EXTERNAL_SOLVERS_APPLICATION without installing the iterative solver and avoiding a Clang compilation error, you also need to '''exclude "ITSOL"''' :
+
Furthermore, in order to compile EXTERNAL_SOLVERS_APPLICATION without installing the iterative solver and avoiding a Clang compilation error, you also need to exclude "ITSOL" :
  
 
  -DEXCLUDE_ITSOL=ON                                                                          \
 
  -DEXCLUDE_ITSOL=ON                                                                          \
  
Note that you can also specify which '''applications''' are going to be compiled by setting them to '''ON''' or '''OFF'''.
+
Note that you can also specify which applications are going to be compiled by setting them to ON or OFF.
  
 
In the end, the configuration file could look like this:
 
In the end, the configuration file could look like this:
Line 172: Line 161:
 
  /Applications/CMake.app/Contents/bin/cmake ..                                                \
 
  /Applications/CMake.app/Contents/bin/cmake ..                                                \
 
  -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang                 \
 
  -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang                 \
  -DCMAKE_INSTALL_RPATH="/Users/<span style="color:red">''youruser''</span>/kratos/libs"                                          \
+
  -DCMAKE_INSTALL_RPATH="/Users/youruser/Kratos/libs"                                          \
 
  -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE                                                    \
 
  -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE                                                    \
 
  -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++                                        \
 
  -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++                                        \
Line 178: Line 167:
 
  -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib"                          \
 
  -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib"                          \
 
  -DCMAKE_BUILD_TYPE=Release              \
 
  -DCMAKE_BUILD_TYPE=Release              \
  -DBOOST_ROOT="/Users/<span style="color:red">''youruser''</span>/kratos/external_libraries/boost_1_62_0"                        \
+
  -DBOOST_ROOT="/full/path/to/boost_1_62_0"                        \
  -DBOOST_LIBRARYDIR="/Users/<span style="color:red">''youruser''</span>/kratos/external_libraries/boost_1_62_0/stage/lib"        \
+
  -DBOOST_LIBRARYDIR="/full/path/to/boost_1_62_0/stage/lib"        \
 
  -DPYTHON_LIBRARY="/Library/Frameworks/Python.framework/Versions/3.5/Python"                  \
 
  -DPYTHON_LIBRARY="/Library/Frameworks/Python.framework/Versions/3.5/Python"                  \
 
  -DPYTHON_INCLUDE_DIR="/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m"  \
 
  -DPYTHON_INCLUDE_DIR="/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m"  \
Line 199: Line 188:
 
== Compile Kratos ==
 
== Compile Kratos ==
  
In order to compile Kratos, you just need to run the following command from the same "kratos/cmake_build/" folder:
+
In order to compile Kratos, you just need to run the following command from the same "Kratos/cmake_build/" folder:
  
 
  sh release_configure.sh
 
  sh release_configure.sh
Line 219: Line 208:
 
One may suppress such warning by adding the flag '''"-Qunused-arguments"''' to the configuration file.  
 
One may suppress such warning by adding the flag '''"-Qunused-arguments"''' to the configuration file.  
  
Moreover since the flags "-Wundefined-var-template" and "-Wexpansion-to-defined" are set by default in Clang 3.9.0, one may see many other warnings appearing during the compilation of Kratos. To disable them, one just needs to add the flags '''"-Wno-undefined-var-template"''' and '''"-Wno-expansion-to-defined"''' in the configuration file.
+
Moreover since the flags "-Wundefined-var-template" and "-Wexpansion-to-defined" are set by default in Clang 3.9.0, one may see many other warnings appearing during the compilation of Kratos. To disable them, one just needs to add the flags '''"-Wno-undefined-var-template"''' and '''"-Wno-expansion-to-defined"''' to the configuration file.
  
 
Taking that into account, the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS could be finally defined as follows:
 
Taking that into account, the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS could be finally defined as follows:
Line 228: Line 217:
 
== Set up your shell environment ==
 
== Set up your shell environment ==
  
After compiling Kratos, you need to tell macOS where to find the libraries by adding some paths to your shell environment. First execute the following commands to create or open (if it already exists) the '''".bash_profile"''':
+
After compiling Kratos, you need to tell macOS where to find the libraries by adding some paths to your shell environment. First execute the following commands to create or open (if it already exists) the ".bash_profile":
  
 
  cd
 
  cd
 
  nano .bash_profile
 
  nano .bash_profile
  
Now add the following two lines containing the path to your kratos folder and the path to the compiled libraries. If you followed the steps in this tutorial they are:
+
Now add the following two lines containing the path to your Kratos folder and the path to the compiled libraries. If you followed the steps in this tutorial they are:
  
  export PYTHONPATH="/Users/<span style="color:red">''youruser''</span>/kratos:$PYTHONPATH"
+
  export PYTHONPATH="/Users/youruser/Kratos:$PYTHONPATH"
  export DYLD_LIBRARY_PATH="/Users/<span style="color:red">''youruser''</span>/kratos/libs:/Users/<span style="color:red">''youruser''</span>/kratos/external_libraries/boost_1_62_0/stage/lib:$DYLD_LIBRARY_PATH"
+
  export DYLD_LIBRARY_PATH="/Users/youruser/Kratos/libs:/full/path/to/boost_1_62_0/stage/lib:$DYLD_LIBRARY_PATH"
  
 
Save the file by pressing ''ctrl+o'' and then hitting ''enter'', exit nano with ''ctrl+x'', and quit the Terminal with ''cmd+q''. After this, every time you open a new Terminal window, the paths will be set automatically.
 
Save the file by pressing ''ctrl+o'' and then hitting ''enter'', exit nano with ''ctrl+x'', and quit the Terminal with ''cmd+q''. After this, every time you open a new Terminal window, the paths will be set automatically.
Line 248: Line 237:
 
Once you are in Python 3, execute the following line:
 
Once you are in Python 3, execute the following line:
  
  from KratosMultiphysics import *
+
  import KratosMultiphysics
  
 
If everything is properly installed you should see this message:
 
If everything is properly installed you should see this message:

Latest revision as of 14:30, 7 April 2017

Contents

Introduction

This section is devoted to explain the necessary steps for the installation of Kratos in macOS. This tutorial has been tested in OS X El Capitan (OS X 10.11) and macOS Sierra (macOS 10.12). If someone is interested in the old installation tutorial of Kratos in OS X Leopard see http://kratos-wiki.cimne.upc.edu/index.php/MacOSX_Installation.

The tutorial assumes that the user has a basic knowledge of macOS and Unix (navigate between directories in Terminal, copy files, execute commands...).

Install Xcode

The first step is to obtain the latest version of Xcode. Open the App Store and look for "xcode" in the search box. Select Xcode and start the installation. Bear in mind that all the packages require 4.4 GB of disk space and so this step can take quite a lot of time.

If you had previously installed Xcode, it is advisable to open the App Store and go to Updates to check whether you have the latest version of Xcode. In the moment of writing this tutorial, the latest version was Xcode 8.0.

Once the installation finishes, open Xcode in order to agree the terms of the software license agreements and complete the installation of components. After that you can quit Xcode (cmd+q). Before going on, it is also recommended to verify that the Command Line Tools are properly installed. To do so, open a Terminal (press cmd+space, write "terminal" and hit enter) and use the following command:

xcode-select --install

If a window appears asking whether you want to install the tools now, click on "Install". You must agree the Command Line Tools License Agreement to proceed with the installation. When Xcode is properly installed, you will see the following message every time you run the "xcode-select --install" command.

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Install Clang with OMP support

Since the default Clang compiler on Xcode does not have an OpenMP implementation, here we will install a Clang version compatible with OMP. First, you need to install Homebrew (http://brew.sh), a package manager for macOS. Paste the following line at a Terminal and follow the instructions:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once the installation is completed, type this command:

brew install llvm

Agree if you are asked to download necessary additional packages and, after a while, you should have LLVM installed in "/usr/local/opt/llvm" and the Clang version compatible with OMP in "/usr/local/opt/llvm/bin".

Install Python

Download the latest version of Python 3 compatible with your mac from https://www.python.org/downloads/mac-osx/ . In the moment of writing this text the latest version was Python 3.5.2. Right-click on the downloaded file, e.g. "python-3.5.2-macosx10.6.pkg", and open it to initialise the installation wizard of Python. Once Python 3 is installed, you can erase the downloaded package to save space. Moreover, to check that Python 3 is properly configured, open a Terminal and run the following command to see the version

python3 --version

Install Boost

Kratos Multiphysics needs Boost libraries to support some of its functions. Download the latest compatible version of Boost from its official website http://www.boost.org/users/history/ . This tutorial has been tested with version 1.62.0. You can use any version from 1.54 onward except for 1.60 and 1.63.

Open the downloaded file "boost_1_62_0.tar.bz2" to obtain a folder named "boost_1_62_0". You can then erase the compressed file and move the resulting folder to the desired location for Boost.

Open a Terminal and navigate to the Boost folder, i.e.

cd /full/path/to/boost_1_62_0

Then execute the following command:

./bootstrap.sh

Now we must modify the generated configuration file "project-config.jam" to indicate that we are going to use Python 3 instead of Python 2. Open the file with the following command:

open -e project-config.jam

and modify the Python configuration section as:

# Boost.Build Configuration
# Automatically generated by bootstrap.sh

import option ;
import feature ;

# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! darwin in [ feature.values <toolset> ]
{
    using darwin ; 
}

project : default-build <toolset>darwin ;

# Python configuration
import python ;
if ! [ python.configured ]
{
    using python : 3.5 : /Library/Frameworks/Python.framework/Versions/3.5 : /Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m ;
}

# List of --with-<library> and --without-<library>
# options. If left empty, all libraries will be built.
# Options specified on the command line completely
# override this variable.
libraries =  ;

# These settings are equivalent to corresponding command-line
# options.
option.set prefix : /usr/local ;
option.set exec-prefix : /usr/local ;
option.set libdir : /usr/local/lib ;
option.set includedir : /usr/local/include ;

# Stop on first error
option.set keep-going : false ;

We finally compile Boost with the following command:

./b2 stage --with-python --with-serialization cxxflags="-std=c++11" link=shared,static

In the end you should see a message like:

...updated 171 targets...

Install CMake

CMake is the tool used to compile Kratos. Download the CMake latest release for your Mac version in https://cmake.org/download/ . In our case it was CMake 3.7.1. Open the downloaded file, e.g. "cmake-3.7.1-Darwin-x86_64.dmg", and agree the License Agreement terms. Then drag and drop the CMake application into your Applications folder. After that you can eject "cmake-3.7.1-Darwin-x86_64" and erase it to save space.

Finally go to your Applications folder and right-click CMake.app to open it. Then you can quit CMake (cmd+q).

Download Kratos

Next we must download the Kratos Multiphysics source code by means of a git manager. The Command Line Tools installed with Xcode already includes git, thus we just need to open a Terminal and use the following command:

git clone https://github.com/KratosMultiphysics/Kratos Kratos

After that, you should have the latest revision of Kratos in the folder "/Users/youruser/Kratos".

Configure Kratos

When compiling Kratos for the first time, one needs to properly customise the configuration file. Open a Terminal, navigate to your "Kratos/cmake_build" folder and make a copy of the template file:

cd
cd Kratos/cmake_build/
cp example_configure.sh.do_not_touch release_configure.sh

Open "release_configure.sh" file with any text editor and modify it like follows. First, indicate the full path of CMake:

/Applications/CMake.app/Contents/bin/cmake ..                                                \

Next, specify the path of the Clang compiler installed with Homebrew:

-DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang	   	  		             \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++                                         \

In order to detect OpenMP_FLAG during the compilation, it is necessary to specify the path to the libraries for the Clang compiler in the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS:

-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -L/usr/local/opt/llvm/lib"           \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib"                          \

Now, provide the path of Boost and Python 3 directories, and the location of Lapack and Blas libraries. If you followed the steps in this tutorial, just add the following lines setting the path to Boost properly:

-DBOOST_ROOT="/full/path/to/boost_1_62_0"                        \
-DBOOST_LIBRARYDIR="/full/path/to/boost_1_62_0/stage/lib"        \
-DPYTHON_LIBRARY="/Library/Frameworks/Python.framework/Versions/3.5/Python"                  \
-DPYTHON_INCLUDE_DIR="/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m"  \
-DLAPACK_LIBRARIES="/usr/lib/liblapack.dylib"                                                \
-DBLAS_LIBRARIES="/usr/lib/libblas.dylib"                                                    \

Furthermore, in order to compile EXTERNAL_SOLVERS_APPLICATION without installing the iterative solver and avoiding a Clang compilation error, you also need to exclude "ITSOL" :

-DEXCLUDE_ITSOL=ON                                                                           \

Note that you can also specify which applications are going to be compiled by setting them to ON or OFF.

In the end, the configuration file could look like this:

/Applications/CMake.app/Contents/bin/cmake ..                                                \
-DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang	   	  		             \
-DCMAKE_INSTALL_RPATH="/Users/youruser/Kratos/libs"                                          \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE                                                     \
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++                                         \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -L/usr/local/opt/llvm/lib"           \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib"                          \
-DCMAKE_BUILD_TYPE=Release  							             \
-DBOOST_ROOT="/full/path/to/boost_1_62_0"                        \
-DBOOST_LIBRARYDIR="/full/path/to/boost_1_62_0/stage/lib"        \
-DPYTHON_LIBRARY="/Library/Frameworks/Python.framework/Versions/3.5/Python"                  \
-DPYTHON_INCLUDE_DIR="/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m"  \
-DLAPACK_LIBRARIES="/usr/lib/liblapack.dylib"                                                \
-DBLAS_LIBRARIES="/usr/lib/libblas.dylib"                                                    \
-DINCOMPRESSIBLE_FLUID_APPLICATION=OFF  						     \
-DMESHING_APPLICATION=OFF 							             \
-DEXTERNAL_SOLVERS_APPLICATION=ON						             \
-DPFEM_APPLICATION=OFF 							                     \
-DSTRUCTURAL_APPLICATION=OFF 							             \
-DCONVECTION_DIFFUSION_APPLICATION=ON 						             \
-DINSTALL_EMBEDDED_PYTHON=ON                                                                 \
-DEXCLUDE_ITSOL=ON                                                                           \

Warn_icon.gif Warning. Please, note that:

  • Cmake requires all definitions in a single line! Therefore, the line concatenation character '\' MUST NOT be followed by any whitespace in the same line as this would prevent cmake from running the lines below

Compile Kratos

In order to compile Kratos, you just need to run the following command from the same "Kratos/cmake_build/" folder:

sh release_configure.sh

Please, bear in mind that depending on which applications are being compiled, the first compilation of Kratos may take a lot of time.

Compilation issues

We are aware of three warnings appearing after each linking of libraries:

ld: warning: path '/Library/Frameworks/Python.framework/Versions/3.5/Python' following -L not a directory
ld: warning: path '/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib' following -L not a directory
ld: warning: path '/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib' following -L not a directory

Furthermore, the introduction of the path to the libraries of Clang in the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS causes the following warning to appear:

clang-3.9: warning: argument unused during compilation: '-L/usr/local/opt/llvm/lib'

One may suppress such warning by adding the flag "-Qunused-arguments" to the configuration file.

Moreover since the flags "-Wundefined-var-template" and "-Wexpansion-to-defined" are set by default in Clang 3.9.0, one may see many other warnings appearing during the compilation of Kratos. To disable them, one just needs to add the flags "-Wno-undefined-var-template" and "-Wno-expansion-to-defined" to the configuration file.

Taking that into account, the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS could be finally defined as follows:

-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11 -L/usr/local/opt/llvm/lib -Qunused-arguments -Wno-undefined-var-template -Wno-expansion-to-defined" \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 -L/usr/local/opt/llvm/lib -Qunused-arguments -Wno-undefined-var-template -Wno-expansion-to-defined"                \

Set up your shell environment

After compiling Kratos, you need to tell macOS where to find the libraries by adding some paths to your shell environment. First execute the following commands to create or open (if it already exists) the ".bash_profile":

cd
nano .bash_profile

Now add the following two lines containing the path to your Kratos folder and the path to the compiled libraries. If you followed the steps in this tutorial they are:

export PYTHONPATH="/Users/youruser/Kratos:$PYTHONPATH"
export DYLD_LIBRARY_PATH="/Users/youruser/Kratos/libs:/full/path/to/boost_1_62_0/stage/lib:$DYLD_LIBRARY_PATH"

Save the file by pressing ctrl+o and then hitting enter, exit nano with ctrl+x, and quit the Terminal with cmd+q. After this, every time you open a new Terminal window, the paths will be set automatically.

Test Kratos

The easiest way to test if Kratos is properly installed is to reproduce the Kratos Multiphysics message. Open a Terminal and execute Python 3 with:

python3

Once you are in Python 3, execute the following line:

import KratosMultiphysics

If everything is properly installed you should see this message:

 |  /           |             
 ' /   __| _` | __|  _ \   __|
 . \  |   (   | |   (   |\__ \ 
_|\_\_|  \__,_|\__|\___/ ____/
           Multi-Physics 5.0.17106

To quit Python 3 just run

exit()

And that's all. You can now run your own python scripts to test that everything works.

Personal tools
Categories