Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 16, 2007, 02:35 PM   #1
bonestruca
macrumors newbie
 
Join Date: Nov 2007
Fortran Compiler

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
bonestruca is offline   0 Reply With Quote
Old Nov 16, 2007, 02:55 PM   #2
antibact1
macrumors 6502
 
Join Date: Jun 2006
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.
antibact1 is offline   0 Reply With Quote
Old Nov 16, 2007, 04:13 PM   #3
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: 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 .
__________________
Actually it does make sense. Man created god, so if we exist, He exists. - obeygiant
Eraserhead is online now   0 Reply With Quote
Old Nov 16, 2007, 04:54 PM   #4
bonestruca
Thread Starter
macrumors newbie
 
Join Date: Nov 2007
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 ?
bonestruca is offline   0 Reply With Quote
Old Nov 16, 2007, 05:00 PM   #5
Nuc
macrumors 6502a
 
Nuc's Avatar
 
Join Date: Jan 2003
Location: TN
Quote:
Originally Posted by bonestruca View Post
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
__________________
rMBP 2.6/16/512
&
2.33GHz 17" MBP C2D
Nuc is offline   0 Reply With Quote
Old Nov 16, 2007, 05:01 PM   #6
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: 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.
__________________
Actually it does make sense. Man created god, so if we exist, He exists. - obeygiant
Eraserhead is online now   0 Reply With Quote
Old Nov 16, 2007, 05:41 PM   #7
bonestruca
Thread Starter
macrumors newbie
 
Join Date: Nov 2007
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 ?
bonestruca is offline   0 Reply With Quote
Old Nov 16, 2007, 06:17 PM   #8
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
What about g95?
__________________
Actually it does make sense. Man created god, so if we exist, He exists. - obeygiant
Eraserhead is online now   0 Reply With Quote
Old Nov 16, 2007, 08:33 PM   #9
Nuc
macrumors 6502a
 
Nuc's Avatar
 
Join Date: Jan 2003
Location: TN
I installed the gfortran compiler from this Link or via the download link.

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

Nuc
__________________
rMBP 2.6/16/512
&
2.33GHz 17" MBP C2D
Nuc is offline   0 Reply With Quote
Old Nov 17, 2007, 12:13 AM   #10
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: Redondo Beach, California
Quote:
Originally Posted by bonestruca View Post
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.
ChrisA is offline   0 Reply With Quote
Old Nov 17, 2007, 08:05 AM   #11
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Quote:
Originally Posted by ChrisA View Post
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.
__________________
Actually it does make sense. Man created god, so if we exist, He exists. - obeygiant
Eraserhead is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Where is my gcc and g++ compiler sysProgrammer Mac Programming 10 Nov 24, 2013 07:47 PM
How to run fortran on mac phamnu Mac Programming 1 Aug 25, 2013 10:56 PM
Fortran g77 on Mac nicolaus Mac Programming 5 Feb 7, 2013 09:09 AM
Fortran and Netcdf dukebound85 Mac Programming 3 Jun 21, 2012 12:31 AM
Broken C compiler dancks Mac Programming 2 Jun 15, 2012 04:04 PM

Forum Jump

All times are GMT -5. The time now is 05:55 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC