Gfortran on mac m2 silicon - PATH problem with Hello World

Wondering if I should modify my PATH . I have a hello.90 file on my desktop. ( Not sure if it’s supposed to be there, or some dedicated folder ). I have installed Homebrew, and the required Xcode updates via homebrew. Then via Homebrew I installed gcc for gfortran. I’m confident that I have given the homebrew versions of gcc priority over the Apple versions. I am on an Apple silicon machine. I assume that when I run a .90 fortran file - it looks for /opt/homebrew or /opt/homebrew/bin. But when I type in the zsh shell on terminal ‘gfortran hello.f90 -o hello’ the following is a portion of what is returned – ‘as: assembler (/opt/local/bin/…/libexec/as/arm64/as or /opt/local/bin/…/local/libexec/as/arm64/as) for architecture arm64 not installed’
Here is a portion of my PATH PATH=/opt/homebrew/Cellar/pyenv-virtualenv/1.2.4/shims:/Users/bBird/.pyenv/shims:/Users/bBird/.pyenv/bin:/opt/local/bin:/opt/local/sbin:/usr/local/cmake/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin In the path opt/homebrew/bin comes after opt/local/bin is that the source of my problem?

On my m1 machine my PATH does not have /opt/local/bin, and I do not have a /opt/local directory in my filesystem.

All of my homebrew environment is set in my .profile by bash with the command

test -r /opt/homebrew/bin/brew && eval "$(/opt/homebrew/bin/brew shellenv)"

I forget where I got that line, but it was somewhere on the homebrew site or in the homebrew documentation. I have not yet switched to zsh, but I think that shell is supposed to work the same as bash in this respect.

Something else that might be relevant is the output of xcode-select --print-path. Here is what mine says:

$ xcode-select --print-path
/Library/Developer/CommandLineTools

I have only the command line tools installed on this machine, not the full xcode package.

thanks for this. Before I attempted to install gfortran - I used Homebrew to install Stable Diffusion and the Python. I think maybe I should uninstall Homebrew and start over. Only this time install the gfortran first.

You did disable too much of the native MacOS paths, GCC (including Gfortran) uses /usr/bin/as, it does not come with its own (to be precise, nothing GNU can handle ARM64 on Mach-O, so no gas and no GDB).
If you are only using GFortran, there is no need to change the PATH or anything else at all, apart from the changes done by Homebrew. And if you are using GCC too, I’d propose you use the one with the version suffix, like gcc-14.