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.
- 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'
sudo apt-get update
- Install Motif packages
sudo apt-get install libmotif4* libmotif-dev
- 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
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).
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
- Download the appropriate deb file
to your e.g. downloads directory (~/Downloads).
- Ubuntu (32-bit): ftp://ftp.gwdg.de/pub/grafik/dislin/linux/i586/
- Ubuntu (64-bit): ftp://ftp.gwdg.de/pub/grafik/dislin/linux/i586_64/
- Install DISLIN: For 32-bit:
sudo dpkg -i ~/Downloads/dislin-10.4.linux.i586.deb
sudo dpkg -i ~/Downloads/dislin-10.4.linux.i586_64.deb
- 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
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.
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
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-libgfortranseems 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.
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.
- DISLIN Homepage
- Test Installations for DISLIN and Linux – DISLIN Homepage
- Google Group dislin-users
- Using DISLIN to make a GUI – Dr. Clive Page (University of Leicester)
- German Wikibooks for DISLIN