Users are seeking guidance on installing FORTRAN compilers on Snow Leopard, particularly gfortran. The installation process requires Apple's Developer Tools, which can be downloaded from the Mac Dev Center. After downloading the gfortran binary, users must unzip it and run specific terminal commands to install it correctly. Some users encounter errors related to missing files, such as 'f951', when attempting to compile code, indicating potential installation issues. The discussion also touches on the desire for a free FORTRAN compiler compatible with Windows 7.
#1
Saladsamurai
3,009
7
If so, how did you install it? I have been looking at http://gcc.gnu.org/wiki/GFortran" and apparently you have to be a rocket scientist to install the compiler. I'm a little desperate here. I really know nothing about compilers. Most compilers I have dealt with simply require me to run a .exe and I'm done. I can then open it and started writing code.
As much as I hate to ask for someone to hold my hand through the install process, I'm asking. Has anyone here done this that can offer me some guidance? I really need to get this code up and running.
Hi David. I had actually looked at this. I am holding out before trying it since it does not explicitly say that it works on Snow Leopard since Leopard is not the same OS (it's the previous OS).
If nobody posts about having actually done it himself, I can have a go at it this weekend. (I have to teach classes tomorrow.) Do you want Fortran 77 (GNU g77) or Fortran 95 (GNU gfortran)?
Using either of those from near the beginning of your first link, requires that you first install Apple's Developer Tools. That's as far as I've gotten at the moment (did it so I could compile and install other software on my Mac).
Go to Apple's Mac Dev Center and register as an Apple developer. It's free. If you've already bought something online from Apple, you have an AppleID (account) with Apple already; use it for registering. Then download Xcode 3.2.3 and install it. It's a standard Apple .dmg file (a huge one!) with a clickable installer.
It looks like g77 and gfortran install on top of Xcode. That's where I have to start.
Warning: Xcode includes an IDE, but I've never used it. I'm an old-school guy so I do all my programming at the Unix command line in a Terminal window, using a plain text editor to write source code.
#5
Saladsamurai
3,009
7
jtbell said:
If nobody posts about having actually done it himself, I can have a go at it this weekend. (I have to teach classes tomorrow.) Do you want Fortran 77 (GNU g77) or Fortran 95 (GNU gfortran)?
Using either of those from near the beginning of your first link, requires that you first install Apple's Developer Tools. That's as far as I've gotten at the moment (did it so I could compile and install other software on my Mac).
Go to Apple's Mac Dev Center and register as an Apple developer. It's free. If you've already bought something online from Apple, you have an AppleID (account) with Apple already; use it for registering. Then download Xcode 3.2.3 and install it. It's a standard Apple .dmg file (a huge one!) with a clickable installer.
It looks like g77 and gfortran install on top of Xcode. That's where I have to start.
Warning: Xcode includes an IDE, but I've never used it. I'm an old-school guy so I do all my programming at the Unix command line in a Terminal window, using a plain text editor to write source code.
That would be great! I already have XCode installed (Version 3.2.2).
I am looking at the website and it says:
Computation Tools :: Fortran
GCC 4.6 (auto-vectorizing gcc with openmp) :
Compiled using source code from the GNU CVS servers. This contains current versions of gfortran (GNU F95, this is a version of the much awaited, free, open source, F95 compiler), gcc (GNU C) and g++ (GNU C++) compilers that can perform auto-vectorization (i.e. modify code to take advantage of AltiVec/SSE, automatically). Use flag -O3 -ftree-vectorize to enable that option. For more information, see this webpage. Download my binaries, and cd to the download folder. Then gunzip gcc-bin.tar.gz (if your browser didn't do so already) and sudo tar -xvf gcc-bin.tar -C /. It installs everything in /usr/local. You invoke F95 by typing gfortran. You will also need to have Apple's Developer Tools installed. They are included on a separate CD in the retail version of OS X and also available as a free download from Apple's Developer Site. Please install the most current version of Developer Tools. Finally, note that there is an alternate g95 project, that is not part of GCC. They seem to have recently released their own official version of g95 for OS X which you may wish to try. Again, note that that g95 is not the same as this version here. Some reports suggest that this alternate g95 is ahead in the implementation of F95 features, but there are mixed reports regarding its optimization capabilities.
I downloaded gfortran-snwleo-intel-bin.tar.gz and unzipped it. The result is a folder called "usr" It is filled with other folders that I have no idea what to do with. I'm just not sure what the next step is?
I also don't see this "sudo tar -xvf gcc-bin.tar -C /" anywhere. Perhaps that is just for the C compilers?
And I don't know what "You invoke F95 by typing gfortran" means? I am really a bad programmer.
#6
DavidSnider
Gold Member
511
147
You're supposed to run that from the terminal while in the directory that has gcc-bin.tar
It will install it in the system folders.
"You invoke F95 by typing gfortran" means to type gfortran from the terminal
I downloaded gfortran-snwleo-intel-bin.tar.gz and unzipped it. The result is a folder called "usr" It is filled with other folders that I have no idea what to do with. I'm just not sure what the next step is?
Where did you download the .gz file to, and how did you unzip it? Simply by double-clicking on it? Is that 'usr' folder in the same place where you downloaded the .gz file? If so, in order to install the stuff into the right places (so it goes into the Mac OS pre-existing /usr folder) you probably need to do the unzipping etc. at the Unix command line. I can't try it right now because I'm downloading something else (big) over a slow Internet connection so I can't download gfortran just yet. Sometime late tomorrrow...
#8
Saladsamurai
3,009
7
DavidSnider said:
You're supposed to run that from the terminal while in the directory that has gcc-bin.tar
It will install it in the system folders.
"You invoke F95 by typing gfortran" means to type gfortran from the terminal
Hey David Let me tell you what I have done so far:
1) Downloaded " gfortran-snwleo-intel-bin.tar.gz " and unzipped it inside of the "Downloads Folder." (Do I need to download "gcc-snwleo-intel-bin.tar.gz" as well?)
2) Gone to Terminal and typed "cd $HOME/Downloads" and hit Enter
3) Gone to Terminal and typed "sudo tar -xvf gcc-bin.tar -C /
" and hit Enter. At this point I got the following error:
Error opening archive: Failed to open 'gcc-bin.tar': No such file or directory
jtbell said:
Where did you download the .gz file to...
"Downloads" folder
... and how did you unzip it? Simply by double-clicking on it? Is that 'usr' folder in the same place where you downloaded the .gz file?
Yes and yes.
If so, in order to install the stuff into the right places (so it goes into the Mac OS pre-existing /usr folder) you probably need to do the unzipping etc. at the Unix command line
I am not sure what this means where is the Unx command line and how does one inzip a file "at it"?.
I can't try it right now because I'm downloading something else (big) over a slow Internet connection so I can't download gfortran just yet. Sometime late tomorrrow...
Perfectly understandable. I might keep posting anyway just to keep a "history" of what I have tried so far.
THanks again folks!
#9
Saladsamurai
3,009
7
OK folks! Here is what I have done to get it installed:
1) Downloaded " gfortran-snwleo-intel-bin.tar.gz " and did NOT unzip it
2) Gone to Terminal and typed "cd $HOME/Downloads" and hit Enter
3) Gone to Terminal and typed "sudo tar -xvf gfortran-snwleo-intel-bin.tar.gz -C /"
This installed gfortran.
Unfortunately, I am getting errors when trying to run a simple code. I have the following code saved as "test1.for" and it works fine in my DIGITAL Visual FORTRAN compiler from like 1942:
Code:
implicit real*8 (a-h, o-z)
a=1
b=2
c=a+b
write(*,*) c
stop
end
Then when I go to run it in Terminal I get the following error:
Casey-Bennetts-MacBook-Pro:~ caseybennett$ cd $HOME/Desktop/FORTRAN
Casey-Bennetts-MacBook-Pro:FORTRAN caseybennett$ ls
test.for
Casey-Bennetts-MacBook-Pro:FORTRAN caseybennett$ gfortran test.for
i686-apple-darwin10-gfortran-4.2.1: error trying to exec 'f951': execvp: No such file or directory
Casey-Bennetts-MacBook-Pro:FORTRAN caseybennett$
Anyone know what this error means?
ALSO: I really wish I could just get Visual FORTRAN to run on Windows7 properly; however, it will only run on XP without errors (at least the version I have). Does anybody know of a free compiler that is compatible with Windows7 that they have used and like? I would like to install it on my Windows partition as a back up.
That means it can't find a file named 'f951', that it wants to execute. Either the file is completely missing, or maybe it exists but is not in the list of directories (folders) that are supposed to contain executable files. Try two things for diagnostics:
First, look for the file. The File --> Find command in the Finder doesn't search through Unix system directories, so you'll have to use the command line:
Code:
sudo find / -name f951 -print
Make sure you include all the spaces!
This will take a while. It searches your entire file structure, on all disks that are currently mounted. If it doesn't give you anything at all, then the file is completely missing. If the file is there, it will show the complete directory-path to the file, which might give a clue as to what's wrong.
Last edited:
#11
Saladsamurai
3,009
7
jtbell said:
That means it can't find a file named 'f951', that it wants to execute. Either the file is completely missing, or maybe it exists but is not in the list of directories (folders) that are supposed to contain executable files. Try two things for diagnostics:
First, look for the file. The File --> Find command in the Finder doesn't search through Unix system directories, so you'll have to use the command line:
Code:
sudo find / -name f951 -print
Make sure you include all the spaces!
This will take a while. It searches your entire file structure, on all disks that are currently mounted. If it doesn't give you anything at all, then the file is completely missing. If the file is there, it will show the complete directory-path to the file, which might give a clue as to what's wrong.
I will give this a try. Thanks! But first, I just realized that my version of XCode is NOT the latest (3.2.2). So I wonder if installing it will fix that.
***
ALSO: I really wish I could just get Visual FORTRAN to run on Windows7 properly; however, it will only run on XP without errors (at least the version I have). Does anybody know of a free compiler that is compatible with Windows7 that they have used and like? I would like to install it on my Windows partition as a back up.
OK, I tried it when I got back to my office after lunch.
I downloaded gfortran-snwleo-intel-bin.tar.gz and put it in my Documents/sources folder, where I keep my downloaded source code and binaries for Unix-type stuff. Then I launched the Terminal and did the following:
Code:
Jon-Bells-iMac:sources sysadmin$ cd Documents/sources
Jon-Bells-iMac:sources sysadmin$ gunzip gfortran-snwleo-intel-bin.tar.gz
Jon-Bells-iMac:sources sysadmin$ tar -tf gfortran-snwleo-intel-bin.tar
Jon-Bells-iMac:sources sysadmin$ sudo tar -xvf gfortran-snwleo-intel-bin.tar -C /
The first step (g)unzipped the file and left me with the file gfortran-snwleo-intel-bin.tar.
The second step simply displayed a list of the files contained the .tar file, with the directory paths where they would be installed.
The third step actually did the installation. The '-C /' at the end tells 'tar' to prefix each of the file paths in the .tar file with '/' (the filesystem root).
Then I went into my Documents/programs folder, where I keep miscellaneous programs that I write, and created a little test program using my usual command-line text editor (I could have also used TextEdit from the Finder):
Code:
Jon-Bells-iMac:sources sysadmin$ cd
Jon-Bells-iMac:sources sysadmin$ cd Documents/programs
Jon-Bells-iMac:sources sysadmin$ pico hello.f
If yours is different, that might be a problem. But it doesn't look like the 'f951' file needs to be in one of those directories, since it's actually in /usr/local/libexec.
3. As you mentioned, you could try upgrading Xcode from 3.2.2 to 3.2.3. I find it hard to believe that this gfortran package could be tied to such a specific version of Xcode, but strange things do happen sometimes!
At least I now have my own Fortran compiler running!
#13
Saladsamurai
3,009
7
Jeez. This is getting ridiculous. I ran
Code:
ls /usr/local/libexec/gcc/x86_64-apple-darwin10/4.6.0/f951
and it did indeed echo back the path. So apparently f951 IS there. I also ran
Code:
echo $PATH
and got a result identical to yours. But I still get the same error when I attempt to run the code:
Code:
Casey-Bennetts-MacBook-Pro:Fortran caseybennett$ gfortran test.for
i686-apple-darwin10-gfortran-4.2.1: error trying to exec 'f951': execvp: No such file or directory
Casey-Bennetts-MacBook-Pro:Fortran caseybennett$
I don't know what to do now. I don't even know how the hell I can UNINSTALL all of this stuff since we went through the terminal!
I'm sorry that didn't work out! At the moment, I don't have any ideas except for upgrading Xcode to see if that fixes it.
I wouldn't worry too much about uninstalling the stuff. The 'tar' command simply copies files, and they all go into /usr/local and subdirectories of it. If you've never installed anything else that goes into /usr/local, you could simply
Code:
cd /usr/local
sudo rm -r *
to wipe out everything in that directory. The problem is, it's hard to be sure there isn't something non-Fortran related in there that you want to keep!
You can easily make a list of all the files (with directory paths) that 'tar' copied:
Code:
tar -tf gfortran-snwleo-intel-bin.tar
(add .gz on the end if you still have the .gz file)
The files are the entries that don't have slashes at the end. In principle you can delete them one by one, which would be very tedious. If I really had to do something like that, I'd write a shell script or Perl script to read the list and do the deleting. But I don't think it's worth the trouble for a few dozen megabytes.
#15
Saladsamurai
3,009
7
OK! Thanks for all of your help jtbell! I appreciate you staying with me through this. And I am glad (though a bit jealous) that you got it to work