Fortran compiler does not work and I think it's kind of PATH problem.
I'm using MacOS Mojave 10.14.5. I was trying to run a fortran code I got from someone else. It compiled fine but when running it I got error. First it was segmentation fault so I was not sure what is wrong. But I'm 90% sure the code is not wrong because it have been run by other person. But compiling and running simple code like HelloWorld ran fine.
I found that my gfortran is using anaconda version (4.8.5?), so I changed it to Homebrew version (9.1.0) editing bashrc file. After that (I'm not sure what exactly changed the problem. I was trying many things I can find on Google, like reinstalling gcc. I may have messed up paths) my fortran compiler failed to compile even the HelloWorld code.
PRINT *, "Hello World!"
END
.
(base) dyn-137-229-27-249:~ jjung11$ gfortran hello.f90 -o hello
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd
ld: symbol dyld_stub_binder not found (normally in libSystem.dylib). Needed to perform lazy binding to function __gfortran_set_args for architecture x86_64
collect2: error: ld returned 1 exit status
It says I need to do lazy binding but I have no idea what it means and even though I googled for it I couldn't learn how to do it.
Also the error I've seen lots of times trying to run my own code is following:
(base) dyn-137-229-27-249:~ jjung11$ /Volumes/easystore/code/mhdread_sc ; exit;
dyld: Library not loaded: /sasbuild/local/xmac01/GNU_CC_CXX_7.1/gcc_7.1.0/lib/libgfortran.4.dylib
Referenced from: /Volumes/easystore/code/mhdread_sc
Reason: image not found
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
I was trying to change dyld path but not successfully. In fact I have not a good idea about what it means.
The error I get for the my own code currently is following:
/Volumes/easystore/code/mhdread_sc -grid ../openggcm_run/2008Jun28_002/2008Jun28_002.grid -fin ../openggcm_run/2008Jun28_002/target/2008Jun28_002.3df. -diptime 2008:06:28:10:00:0.000 -fth 2008Jun28_002.TB_GSEorbit.mhd -fsc TB.GSE.orbit -t0 3600 -tt 43200 -dt 60
test
3600
At line 55 of file mhdread_sc.f
Internal Error: get_unit(): Bad internal unit KIND
Actually even though I was struggling with this problem for days I'm just a beginner in programming (Brew/Xcode/PATH/bashrc/mac) so please be kind for the solution. I may not understand it if it's difficult.
Edit- new error
(base) dyn-137-229-27-249:~ jjung11$ which gfortran -a
/usr/local/bin/gfortran
(base) dyn-137-229-27-249:~ jjung11$ gfortran -o hello.f90 hello
ld: can't link with a main executable file 'hello' for architecture x86_64
collect2: error: ld returned 1 exit status
This looks like there are conflicting version of the compilers and/or of the runtime libraries.
Remove the anaconda setting from ~/.bashrc
.
Then, make sure that the "developer tools" provided by Apple are up-to-date, update homebrew, update the gcc/gfortran install from homebrew. If that does not work I can't think of ways to diagnose and/or fix the install remotely.