Update compilation authored by Rémy Mozul's avatar Rémy Mozul
# Compilation # # Compilation #
After downloading and uncompressing you must have the `lmgc90_user_xxx` directory somewhere. Inside, you should have the following After downloading and uncompressing you must have the `lmgc90_user_xxx` directory somewhere. Inside, you should have the following
subdirectories: subdirectories:
* *src* : the sources of LMGC90 software * *src* : the sources of LMGC90 software
* *examples* : the user examples working with the sources * *examples* : the user examples working with the sources
* *manuals* : a list of manuals/documentation for the software in pdf format * *manuals* : a list of manuals/documentation for the software in pdf format
* *docs* : the html documentation generated from the sources * *docs* : the html documentation generated from the sources
* *build* : (empty) where to build the LMGC90 libraries * *build* : (empty) where to build the LMGC90 libraries
If an error arises during the compilation step please first check if there is not a solution If an error arises during the compilation step please first check if there is not a solution
in the [FAQ](Faq#compile_error) in the [FAQ](Faq#compile_error)
You must run a set of commands from the terminal to build LMGC90 software for your system. You must run a set of commands from the terminal to build LMGC90 software for your system.
## Unix like system (linux, MacOS, WSL) ## ## Unix like system (linux, MacOS, WSL) ##
Run the following commands: Run the following commands:
```shell ```shell
cd build cd build
cmake .. cmake ..
make make
``` ```
#### Python selection #### _In case of error during the `make` step on macOS, check [this part of the FAQ](faq#an-error-arise-when-building-on-mac-os)_
It is really important that the compilation process get access to the python version #### Python selection ####
that the user want to use with lmgc90. As such, it possible to specify the absolute path
to the python executable. For an example, to use python3 on ubuntu 18, It is really important that the compilation process get access to the python version
one must run the next line by replacing `[absolute path to python]` by `/usr/bin/python3` ( that the user want to use with lmgc90. As such, it possible to specify the absolute path
whereas a macos user will use `/opt/local/bin/python`). to the python executable. For an example, to use python3 on ubuntu 18,
```shell one must run the next line by replacing `[absolute path to python]` by `/usr/bin/python3` (
cd build whereas a macos user will use `/opt/local/bin/python`).
cmake .. -DPython_EXECUTABLE=[absolute path to python] ```shell
make cd build
``` cmake .. -DPython_EXECUTABLE=[absolute path to python]
make
Or if the user prefers to use *virtual environment* (with or without a manager like [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/#) or [miniconda](https://virtualenvwrapper.readthedocs.io/en/latest/#), then there is two changes: ```
1. the path to the environment must be provided to cmake
2. lmgc90 must be installed in the environment. Or if the user prefers to use *virtual environment* (with or without a manager like [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/#) or [miniconda](https://virtualenvwrapper.readthedocs.io/en/latest/#), then there is two changes:
1. the path to the environment must be provided to cmake
For example when using *virtualenvwrapper* and with an environment called *lmgc90* the compilation steps becomes: 2. lmgc90 must be installed in the environment.
```shell
workon lmgc90 For example when using *virtualenvwrapper* and with an environment called *lmgc90* the compilation steps becomes:
cd build ```shell
cmake .. -DVENV_PATH=$VIRTUAL_ENV workon lmgc90
make cd build
make install cmake .. -DVENV_PATH=$VIRTUAL_ENV
``` make
make install
#### Optional compilation #### ```
#### Optional compilation ####
Instead of simply running `cmake`, you can run `ccmake` or `cmake-gui` to help you changing some
configuration parameters. For examples to be able to write HDF5 file (assuming you installed the dependancies),
you have to compile with: Instead of simply running `cmake`, you can run `ccmake` or `cmake-gui` to help you changing some
```shell configuration parameters. For examples to be able to write HDF5 file (assuming you installed the dependancies),
cmake . -DWITH_HDF5=True you have to compile with:
make ```shell
``` cmake . -DWITH_HDF5=True
make
If you want to re-build the documentation run: ```
```shell
make docs If you want to re-build the documentation run:
``` ```shell
It will build the sphinx documentation in `build/docs` directory, make docs
but the one provided should be up-to-date ```
It will build the sphinx documentation in `build/docs` directory,
#### Installation #### but the one provided should be up-to-date
If a *virtual environment* is used, then the `make install` command has already taken car of this step. It is directly possible to check on the [first steps](./first step) section. #### Installation ####
In any other case, our policy is to not mess with default system paths. So our recommendation is If a *virtual environment* is used, then the `make install` command has already taken car of this step. It is directly possible to check on the [first steps](./first step) section.
to use an environment variable to add to python the path to our build directory.
In general adding the following lines to your *.bashrc* (Linux) or *.zshrc* (MacOS) file In any other case, our policy is to not mess with default system paths. So our recommendation is
does the trick. Of course you have to replace *mysourcepath* by the path to your own `lmgc90_user_xxx` directory (something like `/users/name/LMGC90/lmgc90_user_xxx/` to use an environment variable to add to python the path to our build directory.
and replacing `xxx` by the version you downloaded). In general adding the following lines to your *.bashrc* (Linux) or *.zshrc* (MacOS) file
```shell does the trick. Of course you have to replace *mysourcepath* by the path to your own `lmgc90_user_xxx` directory (something like `/users/name/LMGC90/lmgc90_user_xxx/`
if [ -z ${PYTHONPATH} ]; then and replacing `xxx` by the version you downloaded).
export PYTHONPATH=mysourcepath/build ```shell
else if [ -z ${PYTHONPATH} ]; then
export PYTHONPATH=${PYTHONPATH}:mysourcepath/build export PYTHONPATH=mysourcepath/build
fi else
export PATH=${PATH}:mysourcepath/src/addons export PYTHONPATH=${PYTHONPATH}:mysourcepath/build
``` fi
On the use of LMGC90 itself, read the [first steps](./first_steps) section. export PATH=${PATH}:mysourcepath/src/addons
```
## Windows Anaconda ## On the use of LMGC90 itself, read the [first steps](./first_steps) section.
If you strictly followed the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager) ## Windows Anaconda ##
you can use a powershell script to build LMGC90 with HDF5 feature activated by default.
If you strictly followed the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager)
This script needs to download the sources of HDF5, so make sure that you can use a powershell script to build LMGC90 with HDF5 feature activated by default.
you have an active connexion to the world wide web before trying to run it.
This script needs to download the sources of HDF5, so make sure that
To run the script, navigate to `lmgc90_user_xxx/conda` in your windows explorer, you have an active connexion to the world wide web before trying to run it.
then right click on `build_with_hdf5.ps1` and select `execute with powershell`.
To run the script, navigate to `lmgc90_user_xxx/conda` in your windows explorer,
If you cannot or would not run script, you can make a standard build by opening then right click on `build_with_hdf5.ps1` and select `execute with powershell`.
the powershell and activate the *lmgc90* environment
(or whatever the name you choose during the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager) If you cannot or would not run script, you can make a standard build by opening
step) with the following command: the powershell and activate the *lmgc90* environment
```cmd (or whatever the name you choose during the [dependencies installation](./win_dependencies_install#by-using-python-anaconda-environment-manager)
conda activate lmgc90 step) with the following command:
``` ```cmd
Then move to `lmgc90_user_xxxx` folder with `cd` command conda activate lmgc90
and build lmgc90 by issuing the following commands: ```
```cmd Then move to `lmgc90_user_xxxx` folder with `cd` command
cd build and build lmgc90 by issuing the following commands:
cmake .. -DVENV_PATH="$env:CONDA_PREFIX" -G "MinGW Makefiles" -DBUILD_rTree_BINDING=OFF ```cmd
mingw32-make install cd build
..\finalize_conda_env.bat cmake .. -DVENV_PATH="$env:CONDA_PREFIX" -G "MinGW Makefiles" -DBUILD_rTree_BINDING=OFF
``` mingw32-make install
..\finalize_conda_env.bat
If you made any mistake, it is recommended to close the prompt, to ```
delete the content of the build directory and start again from scratch.
It is especially important TO NOT RUN the `cmake` command from the If you made any mistake, it is recommended to close the prompt, to
`lmgc90_user_xxxx` directory (see the [faq](./faq#known-compilation-errors)) delete the content of the build directory and start again from scratch.
in this case. It is especially important TO NOT RUN the `cmake` command from the
`lmgc90_user_xxxx` directory (see the [faq](./faq#known-compilation-errors))
Currently building LMGC90 with openMP is not supported in Anaconda environment. in this case.
Whatever the method, if everything went well, then you can start the _Anaconda Navigator_ application. Currently building LMGC90 with openMP is not supported in Anaconda environment.
The first thing is to activate the environment to use LMGC90 by
selection _lmgc90_ in the menu next to _Applications on_ on the upper part of the window. Whatever the method, if everything went well, then you can start the _Anaconda Navigator_ application.
The first thing is to activate the environment to use LMGC90 by
Then start spyder or jupyter notebook application for example to start using python selection _lmgc90_ in the menu next to _Applications on_ on the upper part of the window.
with lmgc90 python module available.
Then start spyder or jupyter notebook application for example to start using python
On the use of LMGC90 itself, read the [first steps](./first_steps) section. with lmgc90 python module available.
**** On the use of LMGC90 itself, read the [first steps](./first_steps) section.
| [back](./Download_and_install) | [home](./Home) | [next](./First_steps) | ****
|:-------------------------------|:--------------:|-----------------:|
| [back](./Download_and_install) | [home](./Home) | [next](./First_steps) |
|:-------------------------------|:--------------:|-----------------:|