How to Install and use NeoPZ library under Linux


This tutorial was tested successfully under Linux Ubuntu 16.04 LTS 64 bits, but may succeed under other versions of Linux as all steps here can be run in either identical or analogous forms. Versions of third party libraries mentioned here are garanteed to work, so you should stick to them at first to make sure you end succesfully this tutorial. Once you have full understanding of the whole process, you can then try to use updated versions of those libraries.

Steps below are the steps necessary to download, install and use NeoPZ as a library in Linux. They are divided in two major parts:

A) Building NeoPZ so it can be installed as a library;

B) Building an example of a project that uses NeoPZ as a library;

Note: commands mentioned below may be run on both GUI terminal or pure text terminal.


PART A - Building NeoPZ so it can be used as a library

1) Installing CMake (required minimum version: 3.11.0)

 Unfortunatley, CMake version bundled with Ubuntu 16.04 is too old for our purpose here,
 so in case it is already installed it is strongly recommended to uninstall it with
   sudo apt-get uninstall cmake

1.1) To install an appropriate version of CMake, download file .tgz available in https://cmake.org for Linux 64 bits;

   This file is not an installer, but actually a tree that is ready to be used, with
   executable files and other necessary files. On the download page, look for
   'Binary distributions'. Then, as an example, you will see file 'cmake-3.13.1-Linux-x86_64.tar.gz'.

1.2) Unpack the .tgz file in your Downloads folder;

1.3) To make cmake “visible” as a command in bash, edit your file .profile, which is located at your home folder. You must append cmake binary full path to environment variable PATH present in this file. For instance:

     PATH="$PATH:$HOME/Downloads/cmake-3.11.2-Linux-x86_64/bin"

1.4) To make that modification effective, you must logout and then login again. To test if new version of cmake is now “visible” to bash, run:

     cmake --version
     (This should show you same downloaded version of cmake on step 1.1.)	   

2) NeoPZ can OPTIONALLY use some third party libraries. Their use will depend on the way NeoPZ will be used by an application and must be decided before you configure and build NeoPZ. The following steps cover the installation of third party libaries.

 Note: you may skip third party libraries installation for now and go directly to step 3 to install a
 "plain" NeoPZ library, if you wish. After successful installation of "plain" NeoPZ, you can then install
 some third party libraries and reconfigure, rebuild and reinstall a NeoPZ that uses these libraries.

2.1) log4cxx library

   Fortunately, this library is available under Ubuntu 16.04 LTS and can be easily installed bu running:
     sudo apt-get install liblog4cxx-dev 
   Some dependencies will need to be installed too. (Tipically: apr and apr-util)     	 

2.2) lapack library

This library must be locally compiled, linked and installed. Please follow steps 2.2.1 to 2.2.6.

2.2.1) Install gnu fortran compiler (assuming it is not installed yet):

       sudo apt-get install gfortran

2.2.2) Download lapack library source code file (for example: lapack-3.8.0.tar.gz) from site http://www.netlib.org/lapack and unpack it in a working folder.

2.2.3) 'cd' into the initial folder of lapack source tree just unpacked and run the command:

   ccmake
   (Then, turn on the options LAPACKE, CBLAS and SHARED_LIBS) 

2.2.4) Press 'c' to configure and, if there is no error, press 'g' to generate Makefile. If all goes right, ccmake will terminate at this point.

2.2.5) Run the command:

     make 

2.2.6) If no error was generated in previous step, run the command:

     sudo make install
     (You should see output reporting installation.)

2.3) metis library

   This library must be locally compiled, linked and installed. Follow steps 2.3.1 to 2.3.3 to install it.

2.3.1) Download source code tree file at http://glaros.dtc.umn.edu/gkhome/metis/metis/download .

     For example, you can download file 'metis-5.1.0.tar.gz' and unpack it in a working folder.

2.3.2) 'cd' into the initial folder of metis source tree just unpacked and run the commands:

      make config
      make

2.3.3) If no error was generated in previous steps, run the command:

     sudo make install
     (You should see output reporting installation.)

2.4) boost library

    This library must be locally compiled, linked and installed, but uses different tools to accomplish this.
    Follow steps 2.4.1 and 2.4.2 to install it.

2.4.1) Download source code tree file at https://www.boost.org/.

     For example, you can download file 'boost-1.66.0.tar.gz' and unpack it in a working folder. 

2.4.2) 'cd' into the initial folder of boost source tree just unpacked and run the commands:

      ./bootstrap.sh
      sudo ./b2 install

2.5) Intel MKL® library

   Although this library is free to use, Intel requires you to register before downloading it.
   Usually, Linux versions are prefixed with small letter 'L'. Versions carry the year on their name,
   for example, 'l_mkl_2017.3.196.tgz' is a Linux version released in 2017.

2.5.1) Once you have registered and downloaded a .tgz MKL library file, unpack it in a working folder.

2.5.2) 'cd' into the initial folder of MKL library tree just unpacked and look for a file named 'install.sh'. Run it as a command:

       sudo ./install.sh    (On a GUI environment you can optionally run script 'install_GUI.sh')
       
       Note: It may be necessary to enable execution of script through command
       chmod +x install.sh.

3) Configuring and building NeoPZ

3.1) NeoPZ Project is hosted at github.com. In case your Ubuntu Linux doesn't have 'git' installed yet, you can easily install it by running:

     sudo apt-get install git

3.2) As a suggestion, create a folder to store NeoPZ source and build trees, for instance, 'projects'. Do not create as 'NeoPZ' because that might get confusing, as a folder named 'neopz' will be automatically created by git in the cloning process below.

3.3) 'cd' into the 'projects' folder and run the command:

     git clone https://github.com/labmec/neopz
    (This will download the latest source tree of NeoPZ in a folder named 'neopz'. DO NOT 'cd' into it!) 

3.4) Create a build tree for NeoPZ. It is recommended to create a sibiling folder of folder 'neopz', named 'neopz-build'. To do this, run the command:

     mkdir neopz-build

At this point, we have the following folder structure:

	 projects
	    |
	    | --- neopz
	    |
	    | --- neopz-build

3.5) Now you should 'cd' into folder 'neopz-build' and run the command:

     ccmake ../neopz

3.6) To configure a “plain” NeoPZ, you should accept initial configurations. Or, to select third party libraries to be used by NeoPZ, mark the ones needed and press:

   'c' to configure and, if no error so far, press 'g' to generate Makefile

3.7) If all goes right, ccmake will terminate at this point and once you are at the command prompt, run the command:

     make
     
    Note: you can run 'make -jx' where 'x' is the amount of cpu's or cores available in your Linux box.
    This will speed up building NeoPZ considerably.

3.8) Once last step finishes with no errors, you can finally install NeoPZ by running the command:

   
     sudo make install
     
     Note: 'sudo' is necessary here because NeoPZ default installation folder is '/usr/local'.
     This may be changed in ccmake configuration time of NeoPZ. You can choose any folder that
     suits you better. 
     Nevertheless, when installed in /usr/local, NeoPZ will be visible and usable by other users, as well.

3.9) To check if installation of NeoPZ finished successfully, you should find folders '/usr/local/CMake' and '/usr/local/pzlib' in your filesystem, with expected files in them.

—————————————————————————————————————————————————— PART B - Building an example project that uses NeoPZ as a library

Now, an example project that uses NeoPZ as an installed library will be built using cmake. For this, let's use SBFem project, which is also available at github.com:

1) 'cd' back into the 'projects' folder and run the command:

     git clone https://github.com/labmec/SBFem
     (A folder named 'SBFem' will automatically be created by git. DO NOT 'cd' into it!) 

2) Create a place for build tree of SBFem, or a sibiling folder of folder 'SBFem', named 'SBFem-build'. To do this, run the command:

     mkdir SBFem-build

At this point, we have the following folder structure:

	 projects
	    |
            | --- SBFem
	    |
	    | --- SBFem-build

3) To configure and generate SBFem, run the commands:

       cd  SBFem-build
       ccmake  ../SBFem

4) At this point, you should edit variable 'PZ_DIR' and have it point to the path where file 'PZConfig.cmake' is located ('/usr/local/CMake' if NeoPZ was installed in default installation folder).

5) Once 'PZ_DIR' is found by 'ccmake', press 'c' to configure and, if no error reported, press 'g' to generate Makefile. If all succeeds, 'ccmake' ends.

6) To build SBFem, run the command:

      make

7) If compilation and linking suceeds in previous step, you may now run program executables generated in directories 'SBFem2D' or 'SBFem3D'. For example:

      cd SBFem2D
      ./SBFem2D

HINT: The SBFem project needs a NeoPZ library built with third party Intel MKL library, so please configure NeoPZ with 'USING_MKL' option turned on before building and installing NeoPZ, otherwise SBFem will fail.

Updated: Feb/2019 at LabMeC - UNICAMP - Brazil by LCCM

QR Code: URL of current page
QR Code: URL of current page howto:roteiro_pzlinux_eng (generated for current page)