Rationale :
Primary objective of this document is to keep a consize document of installing different Linux packages that I use. It is always wise to keep all the non-default version of packages in one master directory (eg. /home/softwares/packs/). We would also make the same parent directoy (eg. /home/softwares/) as a location to install these packs.
Download the latest / required version of the compiler source from https://gcc.gnu.org/ , we consider the relavent source file to be <gcc-9.3.0.tar.gz>, one should change the name accordingly.
Go to terminal :
mv gcc-9.3.0.tar.gz /home/softwares/packs/
tar -zxvf gcc-9.3.0.tar.gz
cd gcc-9.3.0/
./contrib/download_prerequisites ##[Note: this downloads all the required packs and keep them in proper places, a must do for old machines]
./configure --prefix=/home/softwares/--enable-languages=c,c++,fortran --disable-multilib ##[Note: there are other flags also, but this should do for now]
make -j16 ##[Note: -j16 flag, asks for a parallel compilation on 16 processors]
make install
Make a shell file to export proper path, instead of adding them to ~/.bashrc, if you do this, you can use system's default versions also when required.
vi /home/softwares/RC_gnu.sh
#! /bin/bash
export PATH=/home/softwares/bin:/home/softwares/usr/bin:$PATH
export LD_LIBRARY_PATH=/home/softwares/lib64:/home/softwares/lib:/home/softwares/usr/lib64:/home/softwares/usr/lib:$LD_LIBRARY_PATH
chmod +x /home/softwares/RC_gnu.sh
source /home/softwares/RC_gnu.sh ##[Note: One needs to do this everytime a new terminal is opened to use this version of compilers]
4. Check Gfortran version:
gfortran -v ##[Note: this should return required version of compiler, different from system default. ]