Install DISLIN 10.6 on Ubuntu 16.04 Xenial Xerus

For the new Ubuntu 20.04-LTS-version Focal Fossa and Dislin 11.3 refer the new article Install DISLIN 11.3 on Ubuntu 20.04 Focal Fossa

DISLIN is a very nice and well-documented 2-D and 3-D plotting framework for Fortran and some other programming languages. Furthermore DISLIN provides some widgets to create simple graphic user interfaces (GUIs).

This how-to describes how to install DISLIN (version 10.6) on an arbitrary Ubuntu system (here: 16.04 – Xenial Xerus) and how to compile and link a sample Fortran 90 program with the shared and static libraries.

This how-to should work on Ubuntu-related distributions as Linux Mint, etc.

In this how-to Gfortran is used as the standard Fortran 90 compiler of GNU/Linux.

Install and setup Motif libraries

DISLIN needs the Motif libraries for the GUI widgets and tools. But Motif is not installed on Ubuntu by default.

  1. Xenial Xerus has the Version 4 libraries of Openmotif in its multiverse repository which work with DISLIN 10.4. But first you have to enable multiverse/universe repositories. Ensure that you have Internet access. Write in one line in the terminal:

    Take care of the back tics (`): You find the `-key to the left of the key “1” on the standard English keyboard.
    The `lsb_release -sc` makes this command independent of the Ubuntu version.

    sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` universe multiverse'

    And then:

    sudo apt-get update
  2. Install Motif packages now:
    sudo apt-get install libmotif* libmotif-dev
  3. And you need the package gfortran of course.
    sudo apt-get install gfortran

Make ‘pkexec’ working with Gedit

Since Trusty Tahr (version 14.04) Ubuntu does not have “gksu” installed by default to open graphical applications as root. On Xenial it is possible to install “gksu” manually but in future versions it  will not be provided anymore maybe. The successor is the command “pkexec”.

Unfortunately “pkexec” needs PolicyKit files for every graphical application it wants to start. There are no PolicyKit-files for Gedit and Nautilus installed by default. Because we need Gedit as root later we catch up this now by typing two commands in the terminal:

wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.gedit.policy -O /tmp/org.gnome.gedit.policy
sudo cp /tmp/org.gnome.gedit.policy /usr/share/polkit-1/actions/

Refer this webupd8.org-article for details in this matter.

64-bit specifics

On 64-bit Ubuntu systems, you have to consider the following points. These are optional on 32-bit systems!

Set the LD_LIBRARY_PATH variable

If you are on a 64-bit system you have to specify the environment variable “LD_LIBRARY_PATH”. Start a text editor (here “gedit”) with root privileges and open the file bash.bashrc. Open a terminal and type:

pkexec gedit /etc/bash.bashrc &

or alternatively: sudo nano /etc/bash.bashrc

and append the following lines:

LD_LIBRARY_PATH=/usr/local/dislin
export LD_LIBRARY_PATH

Save bash.bashrc. You just need to restart your terminal (window).

Capability to start 64-bit GUI-programs from the desktop file manager

To start a self-compiled DISLIN program with a graphical user interface (GUI) from your file manager fails on 64-bit Ubuntu. The DISLIN Compiling script “gf95link” does not produce such binaries. You have to start the GUI-programs from the terminal. To change this behavior you need to compile/link your programs statically with the DISLIN library. To do this you have to install the following development packages first. On the terminal, type:

sudo apt-get install libx11-dev libxt-dev libgl1-mesa-dev

Then perform the steps in the following chapter. Instead of compiling/linking your program as mentioned in chapter “Compile programs with shared the DISLIN library via gf95link-script” use the instructions in chapter “Compile programs with the DISLIN library statically”.

Download and install DISLIN

  1. Download the appropriate deb file to your e.g. downloads directory (~/Downloads).
  2. Install DISLIN: For 32-bit:
    sudo dpkg -i ~/Downloads/dislin-10.6.linux.i586.deb

    For 64-bit:

    sudo dpkg -i ~/Downloads/dislin-10.6.linux.i586_64.deb
  3. DISLIN is now installed in “/usr/local” in the directory “dislin”. Dependent on your Fortran compiler version you may need to recompile the MODULE files “dislin.f90” in “/usr/local/dislin/” (for Gfortran: /usr/local/dislin/gf). For Gfortran:
    cd /usr/local/dislin/gf/
    sudo gfortran -c dislin.f90
    cd real64
    sudo gfortran -c dislin.f90

Compile programs with the shared DISLIN library

The DISLIN way via gf95link script

To get started have a look at “/usr/local/dislin/README”. To compile the sample program map_f90, copy the source file to your home directory, move to home and compile/link it with “gf95link”:

cp /usr/local/dislin/examples/map_f90.f90 ~
cd ~
gf95link -a map_f90

You can compile all single precision programs the same way.

Link your program with the double precision DISLIN library, if your program uses double precision reals (map_f90 does not), by adding the -r8 option:

gf95link -a -r8 doubleprec-app

Note: Take care that you do not append the filename suffix – e.g. “.f90” – to the filename when you use gf95link or the other compile scripts provided by DISLIN.

The classic way

If you want to compile/link your program the classic way or to integrate DISLIN to your IDE you call DISLIN via “-ldislin”, the necessary “dislin.mod” file is located in “/usr/local/dislin/gf” for single precision. For double precision use “-ldislin_d” and find the mod-file in “gf/real64”.

gfortran map_f90.f90 -I/usr/local/dislin/gf -ldislin

or for double precision:

gfortran doubleprec-app.f90 -I/usr/local/dislin/gf/real64 -ldislin_d

Exchange “doubleprec-app.f90” to the real file/app name.

You get in both cases an a.out binary file. To specify a n arbitrary app-name use the “-o” option, e.g.: gfortran map_f90.f90 -I/usr/local/dislin/gf -ldislin -o map_f90. The binary file name is then map_f90.

Screenshot map_f90 on Ubuntu Linux

Screenshot map_f90 on Ubuntu Linux

Drawbacks of shared linking

“gf95link” and linking via “-ldislin(_d)” links the shared DISLIN library to your program. That reduces the footprint of your application on your hard disk. However if you intend to run this program on other machines, you have to install DISLIN on these machines, too.

Another issue is that if you are on an 64-bit Ubuntu you can not start your DISLIN application from your file manager (Nautilus, Dolphin, etc). You need to start it from the command-line.

To avoid both issues go to the next chapter and compile/link your program statically instead.

Compile/link programs with the DISLIN library statically

To add the missing capability of starting 64-bit DISLIN GUI-programs from a desktop file manager and to make your programs (32- and 64-bit) independent from an installed DISLIN, compile your program as described for “map_f90” below. But first, make sure that the development packages mentioned in chapter “Capabilities to start 64-bit GUI-programs from the desktop file manager” are installed. Type for map_f90 (and for other single precision apps):

gfortran map_f90.f90 -static-libgfortran -I/usr/local/dislin/gf /usr/local/dislin/libdislin.a -lXm -lXt -lX11 -lGL -o map_f90

If you use double precision real variables, type:

gfortran doubleprec-app.f90 -static-libgfortran -I/usr/local/dislin/gf/real64 /usr/local/dislin/libdislin_d.a -lXm -lXt -lX11 -lGL -o doubleprec-app

instead. Now you can start your 64-bit GUI-program from your file manager. Furthermore you can copy it to any other machines without DISLIN (and gfortran) installed. This is valid for 32-bit systems, too. But you still need the Motif4 libraries (package: libmotif4) on these machines.

Completely static-linked, distribution-independent DISLIN applications?

Did you notice the question mark in the upper headline? In GNU/Linux it is complicated to provide distribution-independent applications. In Ubuntu it is not differently, of course.

The Motif libraries depend on a lot of XServer libraries (libXm, libXt, etc.) which are not all provided in a static form (.a-libs) or depend themselves on other libraries. That means it is not possible to link statically against Motif out-of-the-box.

However, you can provide a third-party-independent deb-package to Ubuntu users which depends “only” on Motif (package “libmotif4”), if you link your app as described in the previous chapter. In comparison to Precise Pangolin -static-libgfortran works on Xenial Xerus. As far as I know Ubuntu provides Motif 4 in the universe repository since Natty Narwhal (11.04). That means your deb-package will work from Ubuntu 11.04 onwards.

For people who want to provide fully static-linked applications, the project CDE could help. But I have not tested it yet.

Acknowledgment

I want to thank the developer and maintainer of DISLIN – Helmut Michels – for his assistance. He helped me a lot, especially to get DISLIN binaries linked statically.

Related Links

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *