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

kneeslasher

macrumors member
Original poster
Jun 6, 2004
45
0
Greetings,

In the lab, I use LaTeX, IDL and Fortran 77 on Linux machines. On my pBook, I can seem to use LaTex (TeXshop) and IDL (6.0 for OS X). But after installing g77 on the Mac, I can't seem to figure out how to use it.

Forgive me, I have been, previously, someone who just used Fortran rather than understood its intricacies. When I was using Linux machines, I therefore only wrote the code in Emacs as an xxxx.for file, compiled using "ifc xxx.for" to produce an a.out file which I simply ran via typing "a.out".

Now what is the equivalent of those two steps above using g77? Any help?
 

scottwat

macrumors regular
Oct 9, 2003
118
0
Ohio USA
kneeslasher said:
Greetings,

In the lab, I use LaTeX, IDL and Fortran 77 on Linux machines. On my pBook, I can seem to use LaTex (TeXshop) and IDL (6.0 for OS X). But after installing g77 on the Mac, I can't seem to figure out how to use it.

Forgive me, I have been, previously, someone who just used Fortran rather than understood its intricacies. When I was using Linux machines, I therefore only wrote the code in Emacs as an xxxx.for file, compiled using "ifc xxx.for" to produce an a.out file which I simply ran via typing "a.out".

Now what is the equivalent of those two steps above using g77? Any help?

OK I don't use fortran but I do know enough about commandline compiling to help. The first thing to do is in the terminal once g77 is installed run "g77 --help" I couldn't get a manpage to come up by typing "man g77" normally this would be a better option but the help page is good gives you everything you need.
From the help I can see the basic usage is "g77 [options] file" the options are optional but are listed under the the help page there. Maybe a good one for you is "g77 -o nameofoutput nameofinput" this will compile the nameofinput file into the nameofoutput program. then you can run it with ./nameofoutput.
 

kneeslasher

macrumors member
Original poster
Jun 6, 2004
45
0
What about interoperability? I have been told that using g77 is equivalent to what I used at the lab... there a.out files from the lab should work on the Mac. But how do I run an a.out file? ./ doesn't work... And I definitely can<not> for some reason, compile .for files from the lab using g77: error free files give errors when using g77... ...
 

BornAgainMac

macrumors 604
Feb 4, 2004
7,275
5,212
Florida Resident
kneeslasher said:
What about interoperability? I have been told that using g77 is equivalent to what I used at the lab... there a.out files from the lab should work on the Mac. But how do I run an a.out file? ./ doesn't work... And I definitely can<not> for some reason, compile .for files from the lab using g77: error free files give errors when using g77... ...

FORTRAN compiled on another CPU type won't work on another CPU unless the lab has Macs with a PowerPC chip. The ones in the lab are probably Intel based so it won't run without taking the FORTRAN source over and recompiling.

Also it's a good practice to rename your a.out to what you want the executable to be called or specify a name when you compile.
 

MisterMe

macrumors G4
Jul 17, 2002
10,709
69
USA
kneeslasher said:
What about interoperability? I have been told that using g77 is equivalent to what I used at the lab... there a.out files from the lab should work on the Mac. But how do I run an a.out file? ./ doesn't work... And I definitely can<not> for some reason, compile .for files from the lab using g77: error free files give errors when using g77... ...
Type "a.out" at the command prompt if you are in a.out's directory. Include the complete path if you are not.
 

kneeslasher

macrumors member
Original poster
Jun 6, 2004
45
0
Ah yes. I had forgotten about the fact that compiled a.out's were specific... well in that case I will, obviously, limit myself to working with the source .for program text file. Typing a.out does not work. I don't think the a.out is recognised as an executable at all.
 

bousozoku

Moderator emeritus
Jun 25, 2002
15,602
1,760
Lard
kneeslasher said:
What about interoperability? I have been told that using g77 is equivalent to what I used at the lab... there a.out files from the lab should work on the Mac. But how do I run an a.out file? ./ doesn't work... And I definitely can<not> for some reason, compile .for files from the lab using g77: error free files give errors when using g77... ...

Shouldn't the extension be either .f or .f77? I thought that .for was meant to signify FORTRAN IV files.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.