Follow the installation instructions on http://hpc.sourceforge.net/ to install the latest binaries of gcc and gfortran for Mac OS X.
The important part is, download the gcc-8.1 binary, then do, quote
cd
to the download folder. Thengunzip gcc-8.1-bin.tar.gz
(if your browser didn't do so already) and thensudo tar -xvf gcc-8.1-bin.tar -C /
"