1 (edited by JohnWasilewski 2016-08-23 21:05:35)

Topic: DISLIN with SF on Raspberry Pi: full instructions: corrected 16-07-16

Last updated 16-07-16.

This post sets out in detail how to install DISLIN on a Raspberry Pi, and
then how to compile/build executables that make calls to DISLIN.

Although it assumes that the operating system is Raspbian, I'd expect it to work equally
well with Ubuntu MATE, subject only to a v. slightly different procedure at step (4).

If any of this is unclear or does not work, please post comments telling me
how I need to correct or clarify it, and I'll try to keep it up to date

(1) Download the Rpi distribution from
      → Downloads
      → Distributions
      → Linux
      → ARM
      → dislin-10.6.linux.arm.tar.gz

     OR from:
      → Downloads
      → Distributions
      → Linux
      → ARM
      → dislin-10.6.linux.arm.tar.gz

(2) Unpack to some convenient folder.

(3) Read the README file.
      Do what the instructions say, especially this part:
      "f) To make DISLIN available for general use, write the
          following commands to your .profile or to /etc/profile"

             export DISLIN

       NB Ignore this note in the instructions:
            "The environment variable DISLIN is not necessary if DISLIN
             is installed in the default directory '/usr/local/dislin'. "

       It is NOT true that f) can be disregarded when DISLIN is installed in /usr/local/dislin. 

(4) It is necessary to run the ./INSTALL script 'as root' because Dislin is
      going to be installed into a system directory.  Snag is, if one types 'sudo ./INSTALL' then
      ./INSTALL will try to run as root, but the environment variable DISLIN is known only to the
       user account, not the 'root' account, and the install will fail.

      Therefore, CHANGE TO the 'root' account, teach 'root' about the DISLIN
      environment variable and the required PATH, and install from there:
             sudo su
             export DISLIN
      ..and install:

(5) Now teach Raspbian Linux where it can find the DISLIN shared object libraries.
      To do this, one has to edit a system file and then rebuild
      the cached list of shared object files.
      Add the following line to the end of your /etc/ld.so.conf file:
             (don't add "include /usr/local/dislin")
       Rebuild shared object files cache:
             sudo ldconfig

LIBRARIES + FONTS (as might be needed)
(6) I was at first unsure whether these next commands were definitely necessary, to install
     some libraries and fonts.  After further testing, I'm now sure they really are needed:
      sudo apt-get install lesstif2
      sudo apt-get install libmotif4 libmotif4* libmotif-dev
      sudo apt-get install xfonts-75dpi xfonts-100dpi

COMPILE dislin.f90
(7) Make sure that dislin.mod has been compiled with your currently-installed gFortran version:
      cd /usr/local/dislin/gf/
      sudo gfortran -c dislin.f90
      This must be repeated whenever you update gFortran to a new version.
      Each new version of Simply Fortran shows on the 'Help/About' panel
      which version of gFortran it is using.  Watch out for when this changes, or for when
      'sudo apt-get update && sudo apt-get upgrade' updates gFortran to a new version.


(8) The example files provided with DISLIN can now be successfully
      compiled and linked with commands from the CLI:
      Copy the file /usr/local/dislin/examples/exa_f90.f90 to a work directory.
      cd to that directory.
      For readability, perhaps rename the file exa_f90.f90, to, egprog.f90
      To compile:
      gfortran -c egprog.f90 -I/usr/local/dislin/gf

      To link:
      gfortran -o egprog egprog.o -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin

      To compile-and-link:
      gfortran -o egprog egprog.f90 -L/usr/local/dislin/ -I/usr/local/dislin/gf -ldislin

      Test run the executable:  ./egprog  →  it should run.


(9) Create a new project, such as egprog.f90
      Add the source file to it.
      Make these settings in Project Options:
      General tab: enter a Target name.
      Linker tab: Static linking: un-tick All-static.
      Compiler flags tab: Linker: add -ldislin
      In the File locations tab, in Search directories:
        - To the Modules/Include files list, add /usr/local/dislin/gf
        - To the Libraries files list, add /usr/local/dislin/gf

SF should now compile and build example.
You can run it from Simply Fortran, or run it from the CLI with ./egprog.


(1) In the CLI commands to gFortran and the Simply Fortran settings that are both explained above, compiling and building projects that call DISLIN functions produce executables reliant on shared libraries.  Using the Dislin example, Exa_F90.for (renamed in my explanations to egprog.f90, the resulting executable is around 43k.  Step(4) enables Raspbian to run executables with Dislin CALLs.

(2) I cannot, yet, do the same, to produce stand-alone executables.

(3) It seems I am short of just one static library, without which, I cannot do (2).  The missing library is OpenGL.  Without this, Simply Fortran is throwing a build error  when linking the libraries.  The SF Linker flag, -lGL, produces an error message, "cannot fine libGL.a".

(4) Apparently, Raspbian does include OpenGL, but, as at 30-June-2016, it is still experimental.  It is not accessible unless it has been enabled, with the Advanced tab of Raspbi-Config, which modifies /boot/config.txt. For me, selecting this option wrote the extra line,
dtoverlay=vc4-kms-v3d, and commented out my line, gpu_mem=256.  It also prevented my RPi from booting, so I had to edit /boot/config.txt on the SD card with another laptop to put it back to how it was.  I am hoping that OpenGL will be working fully before long.

See also:
http://www.linuxjournal.com/content/ras … gl-support
https://benosteen.wordpress.com/2012/04 … x-windows/
https://www.raspberrypi.org/forums/view … p;t=138798


Re: DISLIN with SF on Raspberry Pi: full instructions: corrected 16-07-16

I've updated the instructions to install and use Dislin with the Pi.
There were some mistakes in it.  I think it's now correct.