I assume you're using something later than Trusty. This isn't a problem in Trusty as gfortran is still at 4.8.
Assuming a downgrade isn't a real solution, I'll just show you how Trusty has things laid out. You might want to check it's similar in whatever you're running to make sure my conclusions are sound:
$ dpkg -S $(which gfortran) $(which gfortran-4.8)
gfortran: /usr/bin/gfortran
gfortran-4.8: /usr/bin/gfortran-4.8
$ file /usr/bin/gfortran
/usr/bin/gfortran: symbolic link to `gfortran-4.8'
So basically here, the gfortran
command is just redirecting to /usr/bin/gfortran-4.8
. I expect in your version it's redirecting to /usr/bin/gfortran-4.9
.
We can override packaged path binaries without touching them. I suggest (and this may undermine things that use gfortran
so be careful) we create a new symlink in /usr/local/bin
(note the local
). When you call gfortran
, the system will find the /usr/local/bin/gfortran
version first. Note that anything calling /usr/bin/gfortran
explicitly will still get the 4.9 version.
Anyway, creating the symlink is easy:
sudo ln -s /usr/bin/gfortran-4.8 /usr/local/bin/gfortran
This has the pleasant side-effect that you can leave your packages in place, fulfilling whatever dependencies you might need to fulfil. And upgrades to the gfortran
package won't nuke our changes.