Marco
Your problem is that you have gfortran installed both under MacPorts (/usr/local/bin/gfortran) and homebrew (usr/local/Cellar/gcc/7.2.0/bin/gfortran).
I do NOT recommend using MacPorts.
Please send the output of following commands
ls -lrt /usr/local/bin/gfortran
brew reinstall gcc
brew doctor