dislin-ubuntu.featured

Install DISLIN 10.4 on Ubuntu 14.04 Trusty Tahr

For the new Ubuntu 16.04-LTS-version Xenial Xerus and Dislin 10.6 refer the new article Install DISLIN 10.6 on Ubuntu 16.04.

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 on an arbitrary Ubuntu system and how to compile and link a sample Fortran 90  program with the shared and static libraries.

Since Ubuntu 12.04 (Precise Pangolin) and DISLIN 10.2 came out, things are easier for Debian-based Systems now. However 64-bit users have to consider some points.

I updated this article for Ubuntu 14.04 (Trusty Tahr) and DISLIN 10.4 users. Obsolete instructions for Ubuntu 12.04 and lower as well as DISLIN 10.0 were crossed.

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.

Just for your information: On the DISLIN page Test-Installations they recommend to download Openmotif 2.3.3-1 for Ubuntu 10.04 (Lucid) from openmotif.org. Currently (06/10/2012) this is not possible. The access is denied even if you have an account. However I found the direct links (see below). But the following instructions of this How-to make use of the Openmotif libraries provided by the Ubuntu 12.04 multiverse repository. That means I did not installed the following Openmodif-version! 32-bit: http://www.openmotif.org/files/public_downloads/openmotif/2.3/2.3.3/openmotif_2.3.3-1_lucid_i386.deb 64-bit: http://www.openmotif.org/files/public_downloads/openmotif/2.3/2.3.3/openmotif_2.3.3-1_lucid_amd64.deb But feel free to go the “DISLIN-way” described on the Test-Installation page. Furthermore they recommend to install the packages “xfonts-75dpi” and “xfonts-100dpi” from the Ubuntu repositories. But I could not see any big improvements in font quality.
  1. Trusty Tahr 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:
    sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty universe multiverse'

    And then:

    sudo apt-get update
  2. Install Motif packages now:
    sudo apt-get install libmotif4* libmotif-dev
  3. And you need the package gfortran of course. In comparison to Precise Pangolin (12.04) Trusty Tahr has not installed gksu by default. Strange.
    sudo apt-get install gfortran gksu

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. Press ALT-F2 or open a terminal and type:

gksu gedit /etc/bash.bashrc

on Ubuntu. If you use Kubuntu type:

kdesudo kate /etc/bash.bashrc

instead 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).

Thanks to “mathmal” to point me to this issue!

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.4.linux.i586.deb

    For 64-bit:

    sudo dpkg -i ~/Downloads/dislin-10.4.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

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

Tip: To get ~ (tilde) on Ubuntu you have to press “~” twice.

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.

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

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

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.

  • Firstly, the Gfortran option -static-libgfortran seems not working on Ubuntu 12.04 to get rid of the libgfortran dependency.
  • Secondly, 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”) and Gfortran, if you link your app as described in the previous chapter. In comparison to Precise Pangolin -static-libgfortran works on Trusty Tahr. As far as I know Ubuntu provides Motif 4 in the universe repository since Natty Narwhal (11.04). The Gfortran dependency is not a problem at all in this case. 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.

10 thoughts on “Install DISLIN 10.4 on Ubuntu 14.04 Trusty Tahr”

  1. when i run this “gf95link -a map_f90” command i got error below

    ./map_f90: error while loading shared libraries: libdislin.so.10: cannot open shared object file: No such file or directory

    can you help please

    1. Thanks mathmal to point me to this issue. It is a 64-bit thing. As I updated this how-to for Ubuntu 12.04 I did it on a 32-bit system.

      That means you have to specify the environment variable LD_LIBRARY_PATH on 64-bit systems. This is not optional on 64-bit Ubuntu.

      Do the following steps:

      • Press “ALT-F2”
      • Type in the appearing text box: “gksu gedit /etc/bash.basrc” when you are on a Gnome-based Ubuntu system or “kdesudo kate /etc/bash.basrc” on a KDE-based Kubuntu.
      • Append the following lines:
        LD_LIBRARY_PATH=/usr/local/dislin
        export LD_LIBRARY_PATH
      • Save and restart your terminal window.
      • You are done and have fun
  2. Added the chapter “Set the LD_LIBRARY_PATH environment variable on 64-bit systems” to solve a 64-bit issue. Again thanks to “mathmal”.

  3. Added the section “Compile/link programs with the Dislin library statically”. Thanks to Helmut Michels for assistance.

    This makes your programs independent from a Dislin installation on target machines and allows you to start GUI programs from a desktop filemanager on 64-bit Ubuntu systems.

  4. I have this problem doing all installations described above. Could you help me?

    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libdislin.so when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libdislin.a when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/../lib/libdislin.so when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/../lib/libdislin.a when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../libdislin.so when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../libdislin.a when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/libdislin.so when searching for -ldislin
    /usr/bin/ld: skipping incompatible /usr/lib/libdislin.a when searching for -ldislin
    /usr/bin/ld: cannot find -ldislin
    collect2: error: ld returned 1 exit status

Leave a Reply

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