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 inside 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, you will need:


Some examples written in Fortran 90/95 are listed on the project’s 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, dimension(n, n) :: zmat
    real, dimension(n)    :: xray, yray
    real                  :: pi, step
    real                  :: x, y
    integer               :: i, j

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

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

        do j = 1, n
            y          = (j - 1) * step
            yray(j)    = y
            zmat(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(xray, n, yray, n, zmat)

    call disfin()
end program example

Just compile the DISLIN Fortran module dislin.f90 and then build and link the example using GNU Fortran or Flang:

$ gfortran7 -c dislin.f90
$ gfortran7 -I/usr/local/include/ -L/usr/local/lib/ -Wl,-rpath=/usr/local/lib/gcc7/ \
  -static-libgfortran -o example example.f90 dislin.o dislin-11.1.a -lm -lXm -lXt -lX11 -lGL


You can simplify the build process by writing a Makefile:

FC      = gfortran7
CFLAGS  = -I/usr/local/include/ -L/usr/local/lib/ -Wl,-rpath=/usr/local/lib/gcc7/ -static-libgfortran -Ofast
LDFLAGS = dislin-11.1.a -lm -lXm -lXt -lX11 -lGL
SRC     = example.f90
TARGET  = example

all: dislin.o
	$(FC) $(CFLAGS) -o $(TARGET) $(SRC) $? $(LDFLAGS)

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

.PHONY: clean

	rm $(TARGET) *.mod *.o

Compile the example programme by calling BSD make:

$ make