Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bonestruca

macrumors newbie
Original poster
Nov 16, 2007
15
0
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
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
There is also g95.

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

macrumors newbie
Original poster
Nov 16, 2007
15
0
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

macrumors 6502a
Jan 20, 2003
798
6
TN
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

macrumors G4
Nov 3, 2005
10,434
12,250
UK
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

macrumors newbie
Original poster
Nov 16, 2007
15
0
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 ?
 

ChrisA

macrumors G5
Jan 5, 2006
12,914
2,163
Redondo Beach, California
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.