Anyone using Snow Leopard & FORTRAN?

  • Fortran
  • Thread starter Saladsamurai
  • Start date
  • Tags
    Fortran
In summary: I then typed sudo ./gfortran-snwleo-intel to launch the compiler.If you want to compile with auto-vectorization, you need to install the GNU compilers. You can get them at gcc.gnu.org. To compile, you need to type gfortran and then the -O3 flag. You can also get a binary for the compiler by downloading gfortran-snwleo-intel-bin.tar.gz. After you unzip it, you can type sudo ./gfortran-snwleo-intel to launch the compiler.
  • #1
Saladsamurai
3,020
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.
 
Last edited by a moderator:
Technology news on Phys.org
  • #3
DavidSnider said:
It looks like this site has a plain ol' mac install package:
http://www.macresearch.org/gfortran-leopard

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).

Thanks though :smile:
 
Last edited by a moderator:
  • #4
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
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. :redface:
 
  • #6
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
 
  • #7
Saladsamurai said:
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
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 :smile: 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 :redface: 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
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.
 
  • #10
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
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.
 
  • #12
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

Here's the program:

Code:
      print *, 'Hello, world!'
      end

I compiled and ran it successfully as follows:

Code:
Jon-Bells-iMac:programs sysadmin$ gfortran hello.f -o hello
Jon-Bells-iMac:programs sysadmin$ ./hello
 Hello, world!

Then I noticed that you used .for as your source file extension, so I renamed hello.f to hello.for, and this compiled and ran successfully, too.

As for your 'f951' error, I don't know (yet) what caused it, but here are a few things you can try.

1. There is a file by that name in the installation package, which got installed on my Mac as

/usr/local/libexec/gcc/x86_64-apple-darwin10/4.6.0/f951

To see if it's really there, give the command

Code:
ls /usr/local/libexec/gcc/x86_64-apple-darwin10/4.6.0/f951

and it should simply echo the path name back at you, without a "No such file or directory" error message.

2. The shell variable named PATH lists directories where the system expects to find executable programs. To check yours, give the command

Code:
echo $PATH

On my system, this gives me

Code:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

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
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!
 
  • #14
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
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 :smile:

Now ... if you know anything about Windows 7 and FORTRAN, feel free to have a look https://www.physicsforums.com/showthread.php?t=426355". :redface:

~Casey
 
Last edited by a moderator:

Related to Anyone using Snow Leopard & FORTRAN?

1. How do I install FORTRAN on Snow Leopard?

First, make sure you have the Snow Leopard operating system installed on your computer. Then, you can download and install the appropriate version of FORTRAN for Snow Leopard from the official website of the FORTRAN compiler you wish to use. Follow the installation instructions provided by the compiler.

2. Is FORTRAN compatible with Snow Leopard?

Yes, there are versions of FORTRAN that are specifically designed to work with Snow Leopard. Make sure to download and install the appropriate version for your operating system to ensure compatibility.

3. Can I use FORTRAN on Snow Leopard for scientific computing?

Yes, FORTRAN is a popular programming language for scientific computing and is fully compatible with Snow Leopard. Many scientific libraries and programs are written in FORTRAN, making it a valuable tool for scientific research on Snow Leopard.

4. How do I compile and run FORTRAN code on Snow Leopard?

To compile and run FORTRAN code on Snow Leopard, you will need to use a FORTRAN compiler. Most compilers have a command line interface, so you will need to use the terminal to compile and run your code. Alternatively, you can use an integrated development environment (IDE) that supports FORTRAN, which will provide a user-friendly interface for compiling and running code.

5. Are there any alternative programming languages for scientific computing on Snow Leopard?

Yes, there are several alternative programming languages that are commonly used for scientific computing on Snow Leopard, such as Python, MATLAB, and C++. However, FORTRAN remains a popular choice due to its strong capabilities in numerical and scientific computing.

Similar threads

  • Programming and Computer Science
2
Replies
62
Views
5K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
8
Views
1K
Back
Top