Please see below link for newer version of gcc and gfortran:
In order to get gcc 4.8 or gfortran 4.8 do below steps. (You cannot use gcc 4.8 or gfortran 4.8 with MPI programs.) Do not put below steps in your .bashrc or .bash_profile.
srun -p build --time=2:00:00 --mem=100G --pty /bin/bash
Issue below command to verify that you have access to gcc 4.8 and gfortran 4.8: