Anyone using Snow Leopard & FORTRAN?

Discussion in 'Mac Programming' started by Saladsamurai, Sep 2, 2010.

  1. macrumors regular

    Joined:
    Dec 8, 2009
    #1
    If so, how did you install it? I have been looking at this site as well as this one 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.

    I know that this is probably not the right forum, but I am really unsure of where to put this.
     
  2. macrumors member

    Joined:
    Jul 20, 2010
    #2
    I pretty much just followed the directions. Worked perfectly, come to think of it!
     
  3. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #3
    What directions? Here is the section I am looking at
    The parts I have highlighted do not make sense to me. How are these directions?

    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. What is the next step?

    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? Where do I type this now?
     
  4. macrumors regular

    Joined:
    May 26, 2009
    #4

    While I believe this should go into the PROGRAMMING forum, as a Software Engineer and fairly familiar with unix I will gladly walk you through it.

    1. Go to spotlight (top right) and type terminal. Hit enter and command prompt should pop up.

    2. Type the following command:

    cd $HOME/Downloads

    That should change your directory (which folder you are looking in) to downloads where the "binary" (the file you downloaded and need to compile) should be.

    3. The command "sudo tar -xvf gcc-bin.tar -C /" simply means to execute that exact command (yes copy and paste it) while you are in the downloads folder. It should unzip the file and use the GNU C compiler (the C compiler) to compile that. And that should be it. Also, note that when using sudo it will require a password... but that is obvious... at least I hope everyone knows that...

    4. "You invoke F95 by typing gfortran"

    This simply means that if you want to run the "fortran" program you simply type gfortran in terminal. Yes, you have to use this program in the terminal. Meaning you will probably use vi, vim or the emacs built in terminal text editor to code in. I'm assuming this is for a programming class since fortran really isn't many peoples cup of tea for recreation... and hence you will probably be familiar with vi/vim/emacs if not I can help you with that but its a long tutorial...


    Hope that helps.
     
  5. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #5
    Thanks some guy!

    I wish this were working for me, but it is not. 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:

    And as an FYI, no, not a programming class. My research group uses FORTRAN. I am familiar with a little C++ and VB, but I am not sure what these mean: "vi/vim/emacs "

    My only programming experience has been in Windows.

    Thanks again for your help :)
     
  6. macrumors regular

    Joined:
    May 26, 2009
    #6

    ok so after you typed in cd $HOME/Downloads type in this "ls" what that will do is "list" whats in the "downloads" folder. From the error description it is basically saying that the file you are trying to run the subsequent command on is not there. Give me a printout of what "LS" shows.

    Also, "vi", "vim" and "emacs" are really nice text editors that can do all sorts of wizardry. They are confusing to use if you have never touched them before but nothing rivals them in terms of efficiency when you get the basic commands down in them. Great thing about OS X is that all 3 are already installed on your mac. To activate them just type the name of it (vi/vim/emacs). DO NOT actually run them though (by typing the name)... because you cannot actually exit out of them if you don't know the exit command.

    But yeah, give me the print out of LS and I will see if I can change the command around to work that they gave you.
     
  7. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #7
    Ok! Give me 5 minutes. I am going to delete everything in my Downloads folder and then start from scratch one more time. In OSX, when I want to "unzip" this file, I simply double click it right? And it extracts everything to the same folder that the compressed file is in correct? That is what seems to be happening.
     
  8. macrumors regular

    Joined:
    May 26, 2009
    #8
    Just re-read one of your previous posts where it says:

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

    Ok so the first command (the one that the browser, safari or whatever, should have done) needs to be done... although give me a printout of "ls" first and that will answer whether or not it has been done automatically. The second command is where you are getting the error so I am assuming the gunzip command:

    gunzip gcc-bin.tar.gz has not been done. Again though, give me the ls printout.

    The next things there are all referring to where all the fortran related files will be put (/usr/local folder). Also, make sure you have the Dev tools installed... they are not by default (you get them by installing xcode, they are an optional option). Without them I do not believe you will have the gcc C compiler which is required to do everything the instructions are asking you to do.
     
  9. macrumors regular

    Joined:
    May 26, 2009
    #9
    Yeah if you double click it, then it should unzip it... but don't do that. Just download it to the downloads folder and proceed with the instructions (leave it zipped so the terminal command will unzip it AND compile it).
     
  10. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #10
    Ok. And just to be double check, I DON'T need the other zipped folder from the "wesite: "gcc-snwleo-intel-bin.tar.gz" ?

    I just need the "gfortran-snwleo-intel-bin.tar.gz" file?
     
  11. macrumors regular

    Joined:
    May 26, 2009
    #11
    I believe you only need the "gfortran" one. But download both, it won't do any harm. If it turns out that other file never gets touched/whatever then just delete it later.

    To reiterate what to do after downloading:

    1. Open terminal.
    2. Go to downloads:

    cd $HOME/Downloads

    3. Type ls and let me know what the print out is (that way I will know if the command they give you will error or not).

    4. After that proceed with the commands tried earlier that error'd out (the sudo gcc command to compile everything).
     
  12. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #12

    Ok. I think the problem should be clear. We are using the command "sudo tar -xvf gcc-bin.tar -C /" which is trying to do something with the file "gcc-bin.tar" which I have NOT downloaded because I want to install gfortran.

    If I download both as you suggested, I have a feeling that the command will work. BUT it will succeed on installing the compiler that I DON'T want. I am thinking that we should change the command from "sudo tar -xvf gcc-bin.tar -C /" to "sudo tar -xvf gfortran-bin.tar -C /" OR perhaps "sudo tar -xvf gfortran-snwleo-intel-bin.tar


    As for typing ls in the terminal it returns
    I think that we NEED to unzip it (that's what it says on site) and then change that command. What do you think?
     
  13. macrumors regular

    Joined:
    May 26, 2009
    #13
    I am nearly positive you don't need to unzip it first since the whole idea of using the "tar" command is to unzip compressed files. Try this:

    sudo tar -xvf gfortran-snwleo-intel-bin.tar -C /

    If that doesn't work then try:

    sudo tar -xvf gfortran-snwleo-intel-bin.tar.gz -C /

    I doubt you need the last command, the first should do it. If that fails tell me the error and you may need to just use the GUI (double click the thing) to uncompress it. Then there will be files inside the folder that will be created that you need.

    I hope this works for you, but if it doesn't just post back here and in the morning I will check back. It's getting late for me right now (1 in the morning and I got to get up early).
     
  14. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #14
    I used this one and I think it worked! This is the what it returned:

    The only thing is this ... I may have done this twice :eek: Actually I know that I did. Do you think that this will cause any issues?

    Also: How do I use this again? If I type "gfortran" in the terminal, I get the following

    So I believe that it needs something else form me as well. Let's say I want to run the following code:

    Code:
    	implicit real*8 (a-h, o-z)
    	
    	
    	a=1
    	b=2
    	c=a+b
    	write(*,*) c
    
    	stop
    	
    	
    	
    	end 
    
    
    
    
    
    What is the procedure?

    Thanks again for all of your help!
     
  15. macrumors newbie

    Joined:
    Mar 24, 2006
    #15
    I don't know if you need the specific version of gfortran that you're trying to install, but if its just any version you want then there is a compiled version provided as part of R on this page:

    http://cran.r-project.org/bin/macosx/tools/

    Just download the 'gfortran-4.2.3.dmg' file and double click to install as any other program. This also means you don't need gcc installed to install gfortran, although you will probably want to install it anyway (part of Xcode tools). I imagine you are also going to need to brush up on your terminal usage if you want to be able to compile anything!

    Hope this helps,

    Matt
     
  16. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #16
    OK. So I think that I figured out how to actually run stuff from the terminal. But I am getting an error on the simple program in my last post. It worked on my Windows fortran compiler, so I know the code is fine. Here is the terminal print out:

    Not sure where to go from here.
     
  17. macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #17
    Completely off topic but...

    This is completely off topic but anytime I hear the word fortran I think of this creeeeeepy weirdo that was one of the users I had to support. Any time you touched his computer (which was often since he always screwed it up) it didn't matter what you were doing (usually I was adding him a pst file or reinstalling his printer) he would ask if you were programming in fortran and would write in a little notebook anything you typed on the keyboard and then retype it in word since he was convinced you were programming fortran and he wanted to do it too.

    He thought the IT department was made up of all programmers and told HR we were holding out on him since we wouldn't teach him programming...yea...

    Now that I wasted a minute of your life :p ....
     
  18. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #18
    Yeah, but I laughed my ass off at this :) Thanks for sharing!
     
  19. macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #19
    No problem ;) If you want a metal picture of this guy to a T, he talks just like big gay al from south park, wears only hawaiin shirts, and looks like a really fat gargamel off of smurfs.

    Oh, and one time, when he wasn't looking, I looked in his notebook that he carries everywhere (the one with the "fortran code" in it). It is a trip! He has all of these drawings of usb cables, and cat 5 cables, parallel cables, and pretty much any cable you can think of that connects to computer equipment and he has a whole section dedicated to serial numbers of office equipment he finds and all kinds of crap.

    REALLY strange dude...
     
  20. macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #20
    I just gotta say how strange it is for me to see "Snow Leopard" and "FORTRAN" in the same sentence! I didn't realize anyone still used FORTRAN! I've been out of the programming world for quite a while, but I wrote my first FORTRAN program on an IBM mainframe computer about 40 years ago! :eek: DAMN, I'm old!
     
  21. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #21
  22. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #22
    Hey b! Yes I have Xcode (3.2.2) installed. I am just noticing that this is not the latest build. I am wondering if that is the problem.

    So here's a newb question: by having the Xcode installed, does that mean that I have gcc installed? Or is that something I need in addition to Xcode?

    ***

    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.
     
  23. macrumors regular

    Joined:
    May 26, 2009
    #23
    K I am back now (after some sleep). Yes you have it compiled now, and running the sudo tar command will not harm anything if you did it twice.

    As for running the program "gfortran" I believe it probably wants the command done in this type of format:

    gfortran yourFortranFile

    Where "yourFortranFile" is the file containing the fortran code you want to run. I am quite sure this is how it expects it since that is the way gcc works and it seems similar. If it complains about the file not being of a certain type (such as it wants the extension to be something in particular just change that with a text editor).

    EDIT:

    If you have xcode installed it does not necessarily mean you have the gcc compiler installed. It is *optional* to install the "developer tools" which includes gcc. If memory serves me correctly I think the optional install was something like 600-700mb in size. Insert your application install dvd (that came with your mac) and go about as if you were going to install xcode, but only select the developer tools) and that should do it.
     
  24. Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #24
    It may also be that you actually do need the gcc that was distributed with gfortran. A simple
    Code:
    which gcc
    gcc -v
    
    Will tell you if gcc is installed an on the path and also what options were used to compile gcc and which version you have.

    e.g.
    Code:
    $ which gcc
    /usr/bin/gcc
    $ gcc -v
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5664~38/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5664)
    $ 
    
    EDIT: The default version doesn't have --enable-languages=fortran set.

    B
     
  25. thread starter macrumors regular

    Joined:
    Dec 8, 2009
    #25
    Hi b! I ran the code at the terminal and the results were:

    Code:
    Last login: Fri Sep  3 17:22:35 on ttys000
    Casey-Bennetts-MacBook-Pro:~ caseybennett$ which gcc
    /usr/bin/gcc
    Casey-Bennetts-MacBook-Pro:~ caseybennett$ gcc -v
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5646~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10
    Thread model: posix
    Casey-Bennetts-MacBook-Pro:~ caseybennett$ 
    
    
    So it appears that gfortran is not enabled. Is that correct? Do you think I should now install the gcc included on that site?

    Thanks!

    EDIT: So I went ahead and impatiently installed the gcc compiler on the HPC Website. I again ran the command gcc -v and it returned the exact same info. --enable gfortran was NOT included. So I am thinking that the compilers are the same. And I am still getting the same "error trying to exec 'f951': execvp: No such file or directory" error.


    Edit 2: I really don't understand now. I ran the command
    Code:
    ls /usr/local/libexec/gcc/x86_64-apple-darwin10/4.6.0/f951
    and it echoed back just fine. So clearly f951 IS there.
     

Share This Page