How to install gfortran?

I don't know if I should even pose my question in this forum because all the discussions here are hi-tech. Anyways, I just graduated from college with chemical engineering degree and am going to grad school in fall 2009. I am new with Mac and programming. However, I need to learn programming because I am sure I can't go around it for my future research projects.
Ok, I downloaded the gfortran installer and it seemed I installed it too. I also downloaded the plugins and binaries ( I hope). Also have a simple code written in textedit (input.rtf). I don't know what to do next. Please help!!!!!
I know most of you will take this forgiven but trust me I have spent two full days trying to find out how to do these things. Any help would be appreciated very much.

Sincerely
Santosh Koirala

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Make sure the file is

Make sure the file is formatted as plain text and save it as a .f90 file (presuming it's Fortran 90 or later).

On the terminal, type gfortran -o name_of_program name_of_code.f90

In addition,

In addition, if the above doesn't work, try
$ gfortran
if your terminal answers "command not found", we will need to know what installer you used.
You can try
$ export PATH=$PATH:/usr/local/bin
to see if that changes.

Well it seems like I have

Well it seems like I have installed the fortran correctly because when I type gfortran in the terminal it says no input file. The problem now is I can't save the input file in .f90 or any free format in textedit. Any solution to that?

Thank you all for your help.

Santosh Koirala

I figured out how to save as

I figured out how to save as plain text and name it as input.f90 however, the file still doesn't execute. Here is the snapshot of my terminal.

santosh-koiralas-macbook:~ Santosh$ gfortran --version
GNU Fortran (GCC) 4.3.0 20070810 (experimental)
Copyright (C) 2007 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

santosh-koiralas-macbook:~ Santosh$ gfortran input.f90
gfortran: error trying to exec 'as': execvp: No such file or directory
santosh-koiralas-macbook:~ Santosh$

What am I missing now?

Santosh Koirala

GCC

Did you install Apple's developper tools (XCode) ?

If a full install of gcc is missing, you may not be able to run other compilers.

TextEdit is not a good editor for code

Use a different editor: vi, Emacs (Aquamacs is a nice Mac implementation), TextWrangler are all free editors.

You get a lot of extra features using those other editors, the most helpful of which is language context. (Those editors "recognize" Fortran code, and highlight it appropriately, making it a lot easier to edit.)

I did install Xcode from the

I did install Xcode from the website. Now I have another problem. This is the snapshot of my terminal.

Last login: Sat Jun 27 11:38:24 on console
santosh-koiralas-macbook:~ Santosh$ gfortran input.f90
ld warning: duplicate dylib /usr/local/lib/libgcc_s.1.dylib
santosh-koiralas-macbook:~ Santosh$

I have no idea whats going on. Any suggestions. Thank you.

Suggestion

Hello,

It seems now that the gfortran you installed is redundant.

I don't know if gfortran is installed with XCode (I am still under Tiger), but if it is the case, you should remove the user-installed gfortran. One way is to remove the whole "/usr/local" directory if you have nothing else installed there.

Else, you should, from the installer, list the files installed with gfortran and remove them.

I hope this will work. I won't be able to help in the next two weeks, but will be happy to do so when I get back.

Pierre

Thank ya'll for your help

I have been finally able to install the fortran. The trick was to install the X-Code first and install the gfortran compiler. Thank ya'll for your help.

Sincerely
Santosh Koirala

P.S. For anyone having a similar problem please visit this site: http://www.webmo.net/support/fortran_osx.html. It might be helpful.

Hi Santosh, I'm a very

Hi Santosh,

I'm a very beginner of gfortran. In the previous poster, you said you had figure out how to save plain text to .f90.
Could you please show me how you made it? and where do you save your files?

sincerely,
Kathy

Ahhhh!

I have having trouble trying to get gfortran (or any Fortran compiler to work). I am kind of new to programming, I have a little bit of experience. So I have Mac OSX 10.5.8. I installed a version of gfortran... here is some information that I typed in the terminal that may be helpful:

macintosh-10:PHY 480 john-michaelraguse$ $ gfortran
-bash: $: command not found
macintosh-10:PHY 480 john-michaelraguse$ gfortran
gfortran: no input files
macintosh-10:PHY 480 john-michaelraguse$ gfortran ising.f90
gfortran: error trying to exec 'as': execvp: No such file or directory
macintosh-10:PHY 480 john-michaelraguse$

So... I downloaded Xcode version 2.5 off of Macs website and it I don't think it is in my /usr/bin folder (truthfully I don't even know where it is located but I am able to run it). I don't know whats going on but I really need help! I got gnuplot to work! :). I'm being forced to use microsoft excell to plot some functions and it is really killing me!

cheers,

-goose