PDA

View Full Version : Fortran Compiler




bonestruca
Nov 16, 2007, 01:35 PM
Hey there,
I have to do a Fortran project but I am absolutely new to programming on a mac, I really don't know how to use the terminal or xcode. I've found some tutorials about installing g95 but they were too difficult. I've installed Xcode, but I haven't come any further. What do I have to do next ? Is there any other freeware compiler, which is easier to handle than g95 ? On the WinPC, i just downloaded an app, startet it, wrote my code, compiled and built it. Is there any similar app for macs ?

// powerbook g4, mac osx 10.4.10



antibact1
Nov 16, 2007, 01:55 PM
For a compiler, try gfortran. More info on downloads here:

http://hpc.sourceforge.net/

I'm not sure of any IDE based Fortran solutions for OS X. You may have to get comfortable with a regular text editor and the terminal.

Eraserhead
Nov 16, 2007, 03:13 PM
There is also g95 (http://www.g95.org/).

I believe Eclipse has a Fortran Plugin, what did you use before and on what OS?

Remember that Mac OS X is a Unix ;).

bonestruca
Nov 16, 2007, 03:54 PM
I used Salford Plato on WinXP to write, compile and build Fortran Code.
That was so easy, type the code, click on compile and build. I don't have to do a huge project, just few small files but I don't have a clue how to get a compiler startet. I downloaded and installed g95 and gfortran. But what do I have to do know ? What commands do I have to type in the terminal ?

Nuc
Nov 16, 2007, 04:00 PM
I used Salford Plato on WinXP to write, compile and build Fortran Code.
That was so easy, type the code, click on compile and build. I don't have to do a huge project, just few small files but I don't have a clue how to get a compiler startet. I downloaded and installed g95 and gfortran. But what do I have to do know ? What commands do I have to type in the terminal ?

gfortran is what I've used: Open up terminal change to your appropriate directory and then type: gfortran filename.f

It will compile and give an output file in same directory or if you specify another directory.

Good luck and you can find further instructions on the HPC website.

Nuc

Eraserhead
Nov 16, 2007, 04:01 PM
Assuming you are using Fortran 90.

I have only done a very small amount of Fortran, just compiling examples from a book.

You can use the -c prefix to g95 to compile the library files , and then g95 MainFile.f90 -L *.o

to build the file called MainFile and then -L *.o to link in the library files in with the main file.

bonestruca
Nov 16, 2007, 04:41 PM
I edited the .bash_profile after I got an error message when I tried to use the gfortran command. but now, when I try to compile fortran files I get this message:

/usr/bin/ld: warning can't open dynamic library: /libgcc_s.1.dylib referenced from: /usr/local/gfortran/lib/gcc/powerpc-apple-darwin8.10.0/4.3.0/../../../libgfortran.dylib (checking for undefined symbols may be affected) (No such file or directory, errno = 2)

whats wrong ?

Eraserhead
Nov 16, 2007, 05:17 PM
What about g95?

Nuc
Nov 16, 2007, 07:33 PM
I installed the gfortran compiler from this Link (http://www.macresearch.org/gfortran-leopard) or via the download link (http://www.macresearch.org/files/gfortran/gfortran-4.3-Nov.mpkg.zip).

I haven't had any problems with it. Try and see if this works.

Nuc

ChrisA
Nov 16, 2007, 11:13 PM
Hey there,
I have to do a Fortran project but I am absolutely new to programming on a mac, I really don't know how to use the terminal or xcode. I've found some tutorials about installing g95 but they were too difficult. I've installed Xcode, but I haven't come any further. What do I have to do next ? Is there any other freeware compiler, which is easier to handle than g95 ? On the WinPC, i just downloaded an app, startet it, wrote my code, compiled and built it. Is there any similar app for macs ?

// powerbook g4, mac osx 10.4.10

What exactly is it you can't do. All FORTRAN compilers requite that you write the same "do loops", "if" statments and so on. I've written a lot of FORTRAN but none since the early 1980's It's still a good language for some things, easy to learnand write. But what I can't see is how one compiler can be "easier". FORTRAN is FRORAN.

The gcc compiler used in Apple's Xcode is very widely used and it's free. THat's why Apple uses it, they got it for free. gcc has several "front ends" to handle different programming languages like C, C++, Objective C, Ada, Java and FORTRAN. Using the compilr is the same for all ofthese except of course for the code you write.

I'd suggest using the "standard" xcode system and if you have specific questions about how something works to ask on this forum. If you do decde to go with something else VERY few oters here would have used it while with xcode everyone here would have. Later you might want to leverage you experiance with xcode and try C++ or something else.

If you want to work at the command line it is easy you simply type the name f the compiler followed by the filename that holds you code. By default the result is a program called a.out. If you don't like the funny name you can add "-o foobar" and the output will be called "foobar" or whatever like.

I geuss the basic answer is "no" there is nothing more simple. If you get stuck the more details you can give the better.

Eraserhead
Nov 17, 2007, 07:05 AM
gcc has several "front ends" to handle different programming languages like ... FORTRAN.

The Mac version of gcc doesn't include a FORTRAN compiler, so you have to download another one.