DISLIN is a high-level graphics library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours, and maps. Several output formats are available, like SVG, PNG, PDF, or X11.

The library is developed at the Max Planck Institute for Solar System Research and supports several operating systems and programming languages, including FreeBSD ≥ 10 and Fortran ≥ 90. The first version was released in 1986. Since then, it has been constantly updated and improved.

DISLIN example
Fig. 1: Shaded surface plot with DISLIN

To use DISLIN within your Fortran project, you have to download a distribution suitable for your operating system. The software is not open source, but can be used freely for non-commercial purposes.


An installation script is provided to those who like to install DISLIN globally. But the easiest way to utilise the library is to copy the distribution files to your Fortran project workspace directory and then link the library statically. On FreeBSD 10/11/12 (amd64), you will need:


Some examples written in Fortran 90/95 are listed on the official project website. The following one plots a 3D surface (fig. 1):

! example.f90
program example
    use :: dislin
    implicit none
    integer, parameter :: n = 50

    character(len=32) :: title1 = 'Shaded Surface Plot'
    character(len=32) :: title2 = 'f(x, y) = 2 * sin(x) * sin(y)'
    real              :: z_mat(n, n)
    real              :: x_ray(n), y_ray(n)
    real              :: pi, step
    real              :: x, y
    integer           :: i, j

    pi = acos(-1.0) / 180.
    step = 360. / (n - 1)

    do i = 1, n
        x = (i - 1) * step
        x_ray(i) = x

        do j = 1, n
            y = (j - 1) * step
            y_ray(j) = y
            z_mat(i, j) = 2 * sin(x * pi) * sin(y * pi)
        end do
    end do

    call scrmod('REVERS')
    call setpag('DA4P')
    call metafl('XWIN')

    call disini()
    call pagera()
    call simplx()

    call axspos(200, 2600)
    call axslen(1800, 1800)

    call name('X-Axis', 'X')
    call name('Y-Axis', 'Y')
    call name('Z-Axis', 'Z')

    call titlin(title1, 2)
    call titlin(title2, 4)

    call view3d(-5., -5., 4., 'ABS')
    call graf3d(0., 360., 0., 90., 0., 360., 0., 90., -3., 3., -3., 1.)
    call height(50)
    call title()

    call shdmod('SMOOTH', 'SURFACE')
    call surshd(x_ray, n, y_ray, n, z_mat)

    call disfin()
end program example

Just compile the DISLIN Fortran module dislin.f90 and then build the example:

$ gfortran10 -c dislin.f90
$ gfortran10 -I/usr/local/include/ -L/usr/local/lib/ -static-libgfortran \
  -o example example.f90 dislin.o dislin-11.1.a -lm -lXm -lXt -lX11 -lGL


We can simplify the compilation by writing a Makefile:


FC      = gfortran10
FFLAGS  = -Wall -static-libgfortran -Ofast
LDFLAGS = -I/usr/local/include/ -L/usr/local/lib/
LDLIBS  = dislin-11.1.a -lm -lXm -lXt -lX11 -lGL
TARGET  = example

.PHONY: all clean

all: dislin.o
	$(FC) $(FFLAGS) $(LDFLAGS) -o $(TARGET) example.f90 $? $(LDLIBS)

dislin.o: dislin.f90
	$(FC) -c $?

	rm $(TARGET) *.mod *.o

Compile the example program by calling make:

$ make