Do you happen to use Anaconda? I had a similar problem, and noticed that without condo base environment, everything worked fine. Here is the related post.
https://stackoverflow.com/questions/74318052/cant-compile-fortran-on-macos-monterey-ld-unsupported-tapi-file-type-tapi-t