Skip to content

Installing MBDyn

Andrea Zanoni edited this page May 3, 2019 · 20 revisions

A Blendyn-friendly configuration

Therefore chances are, if you are here, that you already are an MBDyn user, and thus you don't need to install it. This section is here for the convenience of the inexperienced users. It could be also useful to highlight which is the recommended MBDyn configuration that allows to get the most out of Blendyn.

MBDyn pre-requisites

MBDyn is a software that is designed and developed mostly by people using GNU/Linux and it is distributed only in source code form. It is compiled from the source code using GNU's autotools. It can be built also on Windows using MinGW or, under Windows 10, the Windows Subsystem for Linux. Look here for a complete guide to install both MBDyn and Blendyn under Windows 10 using the WSL. Note that the same guide contains also, in practical terms, MBDyn installation instructions for Debian/Ubuntu.

In this guide I'll assume that you are working in a GNU/Linux environment. I'll use my currently preferred distribution, Arch (particularly its flavor Manjaro ) as a reference for the commands. Differences with other distributions, as it pertains to this guide, are only related to the package manager: for example, Arch relies on pacman, Debian/Ubuntu and OpenSuse on Apt, Fedora on dnf, etc... So the name of the packages and the commands might change a bit for you if you do not use Arch, but the general procedure remains the same.

The basic packages needed to be able to compile MBDyn are GNU's autotools and a fortran compiler, for example gfortran.

In Arch, you can install both with

# pacman -S base-devel gcc-fortran

Please note that in all the terminal code listed in this page, the $ prefix indicates commands to be issued as normal-user, while the # prefix indicates that normally superuser privileges are needed.

Now you are ready to download MBDyn:

$ wget https://www.mbdyn.org/userfiles/downloads/mbdyn-1.7.3.tar.gz

extract the archive and cd to the directory that is created:

$ tar xzvf mbdyn-1.7.3.tar.gz
$ cd mbdyn-1.7.3/

Now you need to configure the package, using the configure script that is found in the root of the source code

$ ./configure --prefix=/usr/local

the choice of changing the prefix to /usr/local is arbitrary: one can choose to keep the default prefix /usr/local/mbdyn and add the /usr/local/mbdyn/bin directory to the systems' PATH environment variable (look here, for example, for more information).

The script will output the result of a number of checks, designed to enable to proceed to the building phase only if the required software libraries are found, and to enable several optional functionalities if additional libraries are found:

$ ./configure --prefix=/usr/local
Configuring MBDyn Devel ...
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
[...]
config.status: creating build/Makefile
config.status: creating include/mbconfig.h
config.status: executing depfiles commands
config.status: executing libtool commands

If something goes wrong, errors will be raised. If instead the script does not find a library that is not strictly required, it will generally just raise a warning. If the configuration step is completed with success, you can proceed to build the package:

$ make -j4

note that the -jN switch it is optional: it instructs make to perform the compilation in parallel mode, using N instances in background. When the build is completed, you can install it (i.e. make the binaries available to every user from every location) with

# make install

Please notice that this command should be issued in superuser mode, if the prefix is in one of the system's directories (that is the default behavior). If you did not use the --prefix=/usr/local option, then the MBDyn binaries will be installed in /usr/local/mbdyn/bin, which is not in the default PATH of the distribution. Therefore, the mbdyn command cannot still be found by the terminal in any location of the system. You can amend this by adding the /usr/local/mbdyn/bin directory to the default PATH of your terminal. For example, if you are using bash, you can add this line to the .bashrc file that is found in your home directory:

export PATH=${PATH}:/usr/local/mbdyn/bin

The change will take effect at the next session (a log-in, log-out should suffice), or you can force it to have immediate effect using this command

$ source ~/.bashrc

(this will have an effect on a single session of a single terminal window or tab).
Now you can check if everything went smoothly:

$ mbdyn -v

you should get something like this:

MBDyn - MultiBody Dynamics 1.7.3
configured on Oct 22 2018 at 10:42:17
MBDyn terminated normally

MBDyn optional libraries for Blendyn

NetCDF

To to get the most out of Blendyn, it is recommended to at least enable the binary (NetCDF) output feature of MBDyn. This is accomplished by installing the NetCDF/C++ library. Currently (although that should change quickly), MBDyn relies on version 3 of the NetCDF interface, which is now referred to as legacy in most GNU/Linux packages.

To install it in Arch, either you build it directly from source or you can install this convenient AUR package . In the second case, just clone the AUR repository and call makepkg -si in the root folder

$ git https://aur.archlinux.org/netcdf-cxx-legacy.git
$ cd netcdf-cxx-legacy
$ makepkg -si

If you use a different distribution, keep in mind that often library packages are available in two versions: one without headers, the other with the headers, usually having a name containing a suffix dev or devel. This is not the case in Arch: all the Arch packages contain header files (and are therefore directly suitable to be linked by software that is compiled from source).

Once the NetCDF library has been installed, get back to the MBDyn folder and re-configure the package. If you want to force a check for the NetCDF library, use the following command:

$ ./configure --enable-netcdf=yes --prefix=/usr/local

the --enable-netcdf=yes switch will force configure to raise an error if NetCDF is not found properly.

After the configure step, you should re-build the package with make and install it with make install. Be aware that is not necessary to build it before installing NetCDF: you can of course install this and other optional libraries before making the first configuration.

Eigenanalysis support - LAPACK

If you are interested in performing eigenanalyses in MBDyn and visualize the eigensolutions (i.e. the vibration modes) in Blendyn, you need to install one of the libarries that MBDyn relies on for this particular problem.

The recommended one is LAPACK. You can install it in Arch with

# pacman -S lapack

Remember than in other distributions it might be needed to install the development version of the library.
From now on, the procedure is the same as in the previous cases: re-configure (optionally, force a strict check on LAPACK with ./configure --with-lapack=yes), re-build (make) and install (make install) the package.

Run-time modules support

MBDyn functionalities are often extended through run-time modules , i.e. libraries that are loaded during the execution, only if they are requested by the specific problem MBDyn is asked to solve.

To enable modules , the GNU Libtool library has to be made available.

In Arch, the related package is called libtool, and can be installed with

# pacman -S libtool

other frequently used names for the same package contain the acronym ltdl: for example, the Debian/Ubuntu equivalent package is libltdl-dev.

To build a module (e.g. module-muscles), you have to instruct configure accordingly:

$ ./configure --with-module=muscles --enable-runtime-loading

and as always, build (make) and install (make install) the package.

Recap

At the cost of being pedantic, I'll remind you that there is no need build the package multiple times: you can install all required and additional libraries before configuring MBDyn for the first time. Remember also that the configure options can be combined, so if you want to enable NetCDF output, runtime modules and the eigenanalysis support, installing MBDyn in a folder that is already in the system's PATH, after having installed the related libraries listed in the previous sections just use

$ ./configure --prefix=/usr/local --with-netcdf=yes --with-lapack=yes \
  --with-module=muscles --enable-runtime-loading

and then if all goes smoothly build (make) and install (make install) the package, as usual.