Install older version of gfortran

6,343

Ubuntu 16.04 LTS

You can try to use the option -std described in the manual,

man gfortan

   -std=std
       Specify the standard to which the program is expected to conform,
       which may be one of f95, f2003, f2008, gnu, or legacy.  The default
       value for std is gnu, which specifies a superset of the Fortran 95
       standard that includes all of the extensions supported by GNU
       Fortran, although warnings will be given for obsolete extensions
       not recommended for use in new code.  The legacy value is
       equivalent but without the warnings for obsolete extensions, and
       may be useful for old non-standard programs.  The f95, f2003 and
       f2008 values specify strict conformance to the Fortran 95, Fortran
       2003 and Fortran 2008 standards, respectively; errors are given for
       all extensions beyond the relevant language standard, and warnings
       are given for the Fortran 77 features that are permitted but
       obsolescent in later standards. -std=f2008ts allows the Fortran
       2008 standard including the additions of the Technical
       Specification (TS) 29113 on Further Interoperability of Fortran
       with C and TS 18508 on Additional Parallel Features in Fortran.

Ubuntu 14.04 LTS

Ubuntu 14.04.1 LTS has long time support for 5 years, until April 2019. I tested in a persistent live system created from the iso file ubuntu-14.04.1-desktop-amd64.iso with mkusb.

When I installed gfortran into this system, it was version 4.8.4

GNU Fortran (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

The following command line dialogue illustrated what I had and what I did. If you have no luck with Ubuntu 16.04 LTS, you can try with Ubuntu 14.04 LTS. Maybe it works better with the software you want to compile.

ubuntu@ubuntu:~$ sudo lsblk -fm
NAME   FSTYPE   LABEL                    MOUNTPOINT            NAME     SIZE OWNER GROUP MODE
sda                                                            sda     29.1G root  disk  brw-rw----
├─sda1 ntfs     usbdata                  /media/ubuntu/usbdata ├─sda1     7G root  disk  brw-rw----
├─sda2                                                         ├─sda2     1K root  disk  brw-rw----
├─sda3 vfat     usbboot                  /media/ubuntu/usbboot ├─sda3   244M root  disk  brw-rw----
├─sda4 iso9660  Ubuntu 14.04.1 LTS amd64 /cdrom                ├─sda4 999.5M root  disk  brw-rw----
└─sda5 ext4     casper-rw                                      └─sda5  20.9G root  disk  brw-rw----
sr0                                                            sr0     1024M root  cdrom brw-rw----
loop0  squashfs                          /rofs                 loop0  938.7M root  disk  brw-rw----
ubuntu@ubuntu:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/cow             21G   71M   20G   1% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           384M  1.2M  383M   1% /run
/dev/sda4       981M  981M     0 100% /cdrom
/dev/loop0      939M  939M     0 100% /rofs
none            4.0K     0  4.0K   0% /sys/fs/cgroup
tmpfs           1.9G  4.0K  1.9G   1% /tmp
none            5.0M     0  5.0M   0% /run/lock
none            1.9G   76K  1.9G   1% /run/shm
none            100M   56K  100M   1% /run/user
/dev/sda5        21G   71M   20G   1% /media/ubuntu/casper-rw
/dev/sda3       241M   46M  196M  19% /media/ubuntu/usbboot
/dev/sda1       7.0G   37M  7.0G   1% /media/ubuntu/usbdata
ubuntu@ubuntu:~$ sudo apt-get update
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty InRelease
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/main Translation-en_US
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/main Translation-en
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/restricted Translation-en_US
Ign cdrom://Ubuntu 14.04.1 LTS _Trusty Tahr_ - Release amd64 (20140722.2) trusty/restricted Translation-en
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]      
Ign http://archive.ubuntu.com trusty InRelease                            
Get:2 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:3 http://security.ubuntu.com trusty-security/main amd64 Packages [643 kB]
Hit http://archive.ubuntu.com trusty Release.gpg                    
Get:4 http://archive.ubuntu.com trusty-updates/main amd64 Packages [999 kB]
Get:5 http://security.ubuntu.com trusty-security/restricted amd64 Packages [14.0 kB]
Get:6 http://security.ubuntu.com trusty-security/main Translation-en [345 kB]  
Get:7 http://security.ubuntu.com trusty-security/restricted Translation-en [3,491 B]
Get:8 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [17.1 kB]
Get:9 http://archive.ubuntu.com trusty-updates/main Translation-en [491 kB]
Get:10 http://archive.ubuntu.com trusty-updates/restricted Translation-en [3,978 B]
Hit http://archive.ubuntu.com trusty Release                             
Hit http://archive.ubuntu.com trusty/main amd64 Packages
Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://archive.ubuntu.com trusty/main Translation-en
Hit http://archive.ubuntu.com trusty/restricted Translation-en
Ign http://archive.ubuntu.com trusty/main Translation-en_US
Ign http://archive.ubuntu.com trusty/restricted Translation-en_US
Fetched 2,648 kB in 2s (1,235 kB/s)
Reading package lists... Done
ubuntu@ubuntu:~$ sudo apt-get install gfortran
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  cpp-4.8 gcc-4.8 gcc-4.8-base gfortran-4.8 libasan0 libatomic1 libgcc-4.8-dev
  libgfortran-4.8-dev libgfortran3 libgomp1 libitm1 libquadmath0 libstdc++6
  libtsan0
Suggested packages:
  gcc-4.8-locales gcc-4.8-multilib gcc-4.8-doc libgcc1-dbg libgomp1-dbg
  libitm1-dbg libatomic1-dbg libasan0-dbg libtsan0-dbg libquadmath0-dbg
  gfortran-multilib gfortran-doc gfortran-4.8-multilib gfortran-4.8-doc
  libgfortran3-dbg
The following NEW packages will be installed:
  gfortran gfortran-4.8 libgfortran-4.8-dev libgfortran3
The following packages will be upgraded:
  cpp-4.8 gcc-4.8 gcc-4.8-base libasan0 libatomic1 libgcc-4.8-dev libgomp1
  libitm1 libquadmath0 libstdc++6 libtsan0
11 upgraded, 4 newly installed, 0 to remove and 687 not upgraded.
Need to get 17.4 MB of archives.
After this operation, 19.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main gfortran amd64 4:4.8.2-1ubuntu6 [1,252 B]
Get:2 http://security.ubuntu.com/ubuntu/ trusty-security/main libtsan0 amd64 4.8.4-2ubuntu1~14.04.3 [94.9 kB]
Get:3 http://security.ubuntu.com/ubuntu/ trusty-security/main libquadmath0 amd64 4.8.4-2ubuntu1~14.04.3 [126 kB]
Get:4 http://security.ubuntu.com/ubuntu/ trusty-security/main libitm1 amd64 4.8.4-2ubuntu1~14.04.3 [28.5 kB]
Get:5 http://security.ubuntu.com/ubuntu/ trusty-security/main libgomp1 amd64 4.8.4-2ubuntu1~14.04.3 [23.1 kB]
Get:6 http://security.ubuntu.com/ubuntu/ trusty-security/main libatomic1 amd64 4.8.4-2ubuntu1~14.04.3 [8,636 B]
Get:7 http://security.ubuntu.com/ubuntu/ trusty-security/main libasan0 amd64 4.8.4-2ubuntu1~14.04.3 [63.1 kB]
Get:8 http://security.ubuntu.com/ubuntu/ trusty-security/main gcc-4.8 amd64 4.8.4-2ubuntu1~14.04.3 [5,047 kB]
Get:9 http://security.ubuntu.com/ubuntu/ trusty-security/main cpp-4.8 amd64 4.8.4-2ubuntu1~14.04.3 [4,595 kB]
Get:10 http://security.ubuntu.com/ubuntu/ trusty-security/main libgcc-4.8-dev amd64 4.8.4-2ubuntu1~14.04.3 [1,688 kB]
Get:11 http://security.ubuntu.com/ubuntu/ trusty-security/main gcc-4.8-base amd64 4.8.4-2ubuntu1~14.04.3 [16.2 kB]
Get:12 http://security.ubuntu.com/ubuntu/ trusty-security/main libstdc++6 amd64 4.8.4-2ubuntu1~14.04.3 [259 kB]
Get:13 http://security.ubuntu.com/ubuntu/ trusty-security/main libgfortran3 amd64 4.8.4-2ubuntu1~14.04.3 [248 kB]
Get:14 http://security.ubuntu.com/ubuntu/ trusty-security/main libgfortran-4.8-dev amd64 4.8.4-2ubuntu1~14.04.3 [269 kB]
Get:15 http://security.ubuntu.com/ubuntu/ trusty-security/main gfortran-4.8 amd64 4.8.4-2ubuntu1~14.04.3 [4,883 kB]
Fetched 17.4 MB in 23s (724 kB/s)                                              
(Reading database ... 169556 files and directories currently installed.)
Preparing to unpack .../libtsan0_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libtsan0:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../libquadmath0_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libquadmath0:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../libitm1_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libitm1:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../libgomp1_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libgomp1:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../libatomic1_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libatomic1:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../libasan0_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libasan0:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../gcc-4.8_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking gcc-4.8 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../cpp-4.8_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking cpp-4.8 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../libgcc-4.8-dev_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libgcc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Preparing to unpack .../gcc-4.8-base_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking gcc-4.8-base:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up gcc-4.8-base:amd64 (4.8.4-2ubuntu1~14.04.3) ...
(Reading database ... 169556 files and directories currently installed.)
Preparing to unpack .../libstdc++6_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libstdc++6:amd64 (4.8.4-2ubuntu1~14.04.3) over (4.8.2-19ubuntu1) ...
Setting up libstdc++6:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Processing triggers for libc-bin (2.19-0ubuntu6) ...
Selecting previously unselected package libgfortran3:amd64.
(Reading database ... 169568 files and directories currently installed.)
Preparing to unpack .../libgfortran3_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libgfortran3:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Selecting previously unselected package libgfortran-4.8-dev:amd64.
Preparing to unpack .../libgfortran-4.8-dev_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking libgfortran-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Selecting previously unselected package gfortran-4.8.
Preparing to unpack .../gfortran-4.8_4.8.4-2ubuntu1~14.04.3_amd64.deb ...
Unpacking gfortran-4.8 (4.8.4-2ubuntu1~14.04.3) ...
Selecting previously unselected package gfortran.
Preparing to unpack .../gfortran_4%3a4.8.2-1ubuntu6_amd64.deb ...
Unpacking gfortran (4:4.8.2-1ubuntu6) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up libtsan0:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libquadmath0:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libitm1:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libgomp1:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libatomic1:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libasan0:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up cpp-4.8 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libgcc-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up gcc-4.8 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libgfortran3:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up libgfortran-4.8-dev:amd64 (4.8.4-2ubuntu1~14.04.3) ...
Setting up gfortran-4.8 (4.8.4-2ubuntu1~14.04.3) ...
Setting up gfortran (4:4.8.2-1ubuntu6) ...
update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode
Processing triggers for libc-bin (2.19-0ubuntu6) ...
ubuntu@ubuntu:~$ gfortran --version
GNU Fortran (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

ubuntu@ubuntu:~$ gfortran -dumpversion
4.8
ubuntu@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:    14.04
Codename:   trusty
ubuntu@ubuntu:~$ uname -a
Linux ubuntu 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ubuntu:~$ 

Please notice that I have not tested what happens after updating & upgrading an installed system of 14.04 LTS.

Share:
6,343
DWK
Author by

DWK

Research fellow at the Simmons Center for Cancer Research (SCCR)

Updated on September 18, 2022

Comments

  • DWK
    DWK over 1 year

    I am using Ubuntu 16.04.2 LTS and want to install gfortran version 5.3. When I use either of the inputs below gfortran 5.4 is installed, which is not compatible with the program I am trying to run.

    sudo apt-get install gfortran
    apt-get install csh gfortran
    

    I am trying to run the quantum mechanics software GAMESS, which as far as I know, needs specific modifications for each compiler. When I try to install GAMESS with gfortran 5.4, I get an output saying unrecognized version of gfortran. I looked at the code and the newest supported version is 5.3.

    How could I install the older gfortran version 5.3? Also, would something like the following work to delete version 5.4 so there are no conflicts? Thanks!

    sudo apt-get remove --auto-remove gfortran
    

    For clarification, I am not sure why gamess will not accept versions after 5.3 but I get too many errors to finish the instillation with version 5.4. Also, when I input apt-cache policy gfortran I get the following output:

    gfortran:
    Installed: 4:5.3.1-1ubuntu1
    Candidate: 4:5.3.1-1ubuntu1
    Version table:
    *** 4:5.3.1-1ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
    
    • Eliah Kagan
      Eliah Kagan over 6 years
      Does GAMESS document why it needs gfortran 5.3?
    • steeldriver
      steeldriver over 6 years
      AFAIK the main xenial repository should provide gfortran-5.3.1 by default - do you have the toolchain-r PPA enabled by any chance? Please edit your question to include the output of apt-cache policy gfortran
    • Eliah Kagan
      Eliah Kagan over 6 years
      @steeldriver The gfortran package (at least on Xenial) doesn't actually provide the gfortran executable. On my 16.04 system gfortran -dumpversion shows 5.4.0; /usr/bin/gfortran is a symlink to gfortran-5 and /usr/bin/gfortran-5 is provided by the gfortran-5 package, which the gfortran package declares as a dependency. From launchpad.net/ubuntu/+source/gcc-defaults I downloaded and unpacked launchpad.net/ubuntu/+archive/primary/+files/…. The /usr/bin/gfortran it provides is that symlink.
    • Eliah Kagan
      Eliah Kagan over 6 years
      @DWK Can you show the errors? (You can use paste.ubuntu.com and include a link here, if they're too long to reasonably include in your post.)
  • Eliah Kagan
    Eliah Kagan over 6 years
    I strongly suspect you may actually have the same version as the OP. What's the output of gfortran -dumpversion and gfortran --version on your system?
  • sudodus
    sudodus over 6 years
    @EliahKagan, you are right. Those command lines produce the version 5.4.0. So the information produced by apt-cache policy is not correct. I will remove that part of my answer.
  • DWK
    DWK over 6 years
    @sudodus, thanks for the reply. If I understand your answer correctly, are you saying that the only way to get an older gfortran version is to remove ubuntu Xenial and install an older ubuntu version? This would be a shame because I have a lot of programs that have been configured for the 16.04 system.
  • sudodus
    sudodus over 6 years
    @DWK, No, I am only saying that one way is to run Trusty (14.04 LTS) booted from a persistent live USB drive. I guess it would work in an installed Trusty system too (when fully up to date), but I have not tested it. -- Let us hope that someone else will show you a way to get an older version of the fortran compiler in Xenial (16.04 LTS). -- Does GAMESS explain why it needs gfortran 5.3? -- Did you try the option -std with any of its possible parameters?
  • Eliah Kagan
    Eliah Kagan over 6 years
    @DWK Did this work? Can you tell us what Fortran dialect you specified via -std that made it work, if that's the method you used? Or did you end up using an older release of Ubuntu? (Or something else?)
  • DWK
    DWK over 6 years
    I ended up changing the code in GAMESS so that it thought it was looking for gfortran version 5.4 instead of 5.3. I was hoping that the changes between the two programs would be minor enough not to cause problems later on. So far I haven't seen any issues. Unfortunately, I still haven't found I way to install an older version of gfortran.
  • Eliah Kagan
    Eliah Kagan over 6 years
    @DWK I recommend posting that solution--with a specific explanation of how to do it--as an additional answer. ...Do you still want to install an older version of gfortran? This is possible, but it may be cumbersome because you may need to build it from source code, installed in its own prefix, and the build will take a while (and possibly take up a good bit of space) because you'll need to build more of GCC than just the gfortran frontend. (Then, software compiled with it may depend on shared libraries built and installed along with the compiler.)