HomeBrew and Macports cannot coexist well on the same machine.
The simplest solution to install FLUKA (and Flair) is to remove HomeBrew from your machine.
If you need HomeBrew for any other scope, please let me know and we can find a hack, which - I stress - is not the recommended approach.
Thanks for your reply.
I can remove HomeBrew, without any attachments.
So how should I solve this problem?
How to change the gfortran version?
Just now I removed the Homebrew.
gcc -v and gfortran -v are now consistent, "gcc version 9.3.0 (MacPorts gcc9 9.3.0_0) "
Re-install MacPorts
Install gcc8 by the following commands:
sudo port install gcc8
Change the default gcc version by the following, I got gcc version 8.5.0 (MacPorts gcc8 8.5.0_1)
sudo port select --set gcc mp-gcc8
Type “make” in the /pathtofluka/src directory, an error occurs:
gfortran -o /Users/Danny/Documents/Fluka/fluka4-2.1//bin/fluka -fuse-ld=bfd -L/Users/Danny/Documents/Fluka/fluka4-2.1//lib -lfluka
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make: *** [/Users/Danny/Documents/Fluka/fluka4-2.1//bin/fluka] Error 1
I see another post in this forum, and I did the same procudeures:
Nevertheless, from the file you attached, now you have gcc8 and gcc9 on your machine, so the default gcc version should point to one of these two with the command
sudo port select --set gcc mp-gcc8
or (exclusively!) sudo port select --set gcc mp-gcc9
After that, let me know what is the message when you compile FLUKA.
MacPorts seems to obsolete, so step2-3 are performed.
I set the gfortran version to 8.5 (GNU Fortran (MacPorts gcc8 8.5.0_1) 8.5.0), using
sudo port select --set gcc mp-gcc8
I recompiled the fluka, error shows as follow:
gfortran -o /Users/Danny/Documents/Fluka/fluka4-2.1//bin/fluka -fuse-ld=bfd -L/Users/Danny/Documents/Fluka/fluka4-2.1//lib -lfluka
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make: *** [/Users/Danny/Documents/Fluka/fluka4-2.1//bin/fluka] Error 1
Warning: found dylibs in your /usr/local/lib directory. These are known to cause problems. We'd recommend you remove them.
Warning: it seems you have Homebrew installed on this system -- Because Homebrew uses /usr/local, this can potentially cause issues with MacPorts. We'd recommend you either uninstall it, or move it from /usr/local for now.
you upgraded to a newer version of Xcode, but MacPorts was installed with an older version.
The simplest (and dirtier) solution is to create a symbolic link: cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ sudo ln -s MacOSX.sdk MacOSX10.15.sdk
then you should be able to compile FLUKA.
The appropriate solution (and more time consuming) is to reinstall MacPorts as well.
You can follow the instructions here
Let us know if this solves your installation problem.
Now the problem is when I ran the fluka in Flair, it still can not run properly, showing:
Dir: /Users/Danny/Desktop/simulation
Cmd: /usr/bin/nohup /Users/Danny/Documents/Fluka/fluka4-2.1/bin/rfluka -M 5 fssV3
F L U K A
Dir: /Users/Danny/Documents/Fluka/fluka4-2.1
Data: /Users/Danny/Documents/Fluka/fluka4-2.1/data
/Users/Danny/Documents/Fluka/fluka4-2.1/bin/rfluka: line 108: gfortran: command not found
/Users/Danny/Documents/Fluka/fluka4-2.1/bin/rfluka: line 112: [: -eq: unary operator expected
/Users/Danny/Documents/Fluka/fluka4-2.1/bin/rfluka: line 112: [: -ge: unary operator expected
Error: Incompatible gfortran version!
System gfortran version:
FLUKA package version: 8
When running the input file in a terminal, it works fine.
Don’t know how the solve this.
Here is the peference setting in the configuration of Flair.
No, there is no need to install a newer version of Flair (nevertheless, it would be a good idea since your version is about TWO year old…)
The message says that gfortran is not found, but it IS available in your machine since you compiled FLUKA. So the problem is that the Terminal from which you are running Flair does not have all the environment variables set up.
If you open a new terminal, this should normally fix the problem.
Otherwise, can you provide the output of these commands? which gfortran gfortran --version