Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Anyone using Snow Leopard & FORTRAN?

  1. Sep 2, 2010 #1
    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: Apr 25, 2017
  2. jcsd
  3. Sep 3, 2010 #2

    DavidSnider

    User Avatar
    Gold Member

    Last edited by a moderator: Apr 25, 2017
  4. Sep 3, 2010 #3
    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: Apr 25, 2017
  5. Sep 3, 2010 #4

    jtbell

    User Avatar

    Staff: Mentor

    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.
     
  6. Sep 3, 2010 #5
    That would be great! I already have XCode installed (Version 3.2.2).

    I am looking at the website and it says:

    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:
     
  7. Sep 3, 2010 #6

    DavidSnider

    User Avatar
    Gold Member

    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
     
  8. Sep 3, 2010 #7

    jtbell

    User Avatar

    Staff: Mentor

    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...
     
  9. Sep 3, 2010 #8
    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:

    "Downloads" folder
    Yes and yes.
    I am not sure what this means :redface: where is the Unx command line and how does one inzip a file "at it"?.
    Perfectly understandable. I might keep posting anyway just to keep a "history" of what I have tried so far.

    THanks again folks!!
     
  10. Sep 3, 2010 #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 (Text):
        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:

    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.
     
  11. Sep 3, 2010 #10

    jtbell

    User Avatar

    Staff: Mentor

    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 (Text):

    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: Sep 3, 2010
  12. Sep 3, 2010 #11
    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.
     
  13. Sep 3, 2010 #12

    jtbell

    User Avatar

    Staff: Mentor

    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 (Text):

    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 (Text):

    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 (Text):

          print *, 'Hello, world!'
          end
     
    I compiled and ran it successfully as follows:

    Code (Text):

    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 (Text):

    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 (Text):

    echo $PATH
     
    On my system, this gives me

    Code (Text):

    /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!
     
  14. Sep 3, 2010 #13
    Jeez. This is getting ridiculous. I ran
    Code (Text):
    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 (Text):
    echo $PATH
    and got a result identical to yours. But I still get the same error when I attempt to run the code:

    Code (Text):
    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!
     
  15. Sep 3, 2010 #14

    jtbell

    User Avatar

    Staff: Mentor

    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 (Text):

    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 (Text):

    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.
     
  16. Sep 3, 2010 #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: Apr 25, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Anyone using Snow Leopard & FORTRAN?
  1. Anyone Using C# ? (Replies: 20)

Loading...