How can I execute a fortran program?

By skierplus ·
I have a fortran program I wrote about 20 years ago. I think it's fortran 77. Would like to revive it!

The cgywin icon puts me into command prompt with a $.

I think I saw someting in a document that implied that I could have the program in notepad and reference it there.


This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Fortran program or source code?

by seanferd In reply to How can I execute a fortr ...

You'll need to compile it for the environment in which it is expected to run. If it is a binary application, it will probably only run in the original or similar environment.

Since you are using Cygwin, can we assume this originally ran on a Unix?

Collapse -

Reponse To Answer

by skierplus In reply to Fortran program or source ...

I haven't been able to run it yet. Hoping to learn how to reference the code when it resides in say notepad. I recently downloaded emacs. Looks like a good editor.

Collapse -

Reponse To Answer

by skierplus In reply to Fortran program or source ...

I have the souce code, but don't know how to compile/execute.

Thanks for your consideration of this 85 year old who wrote the program 20 years ago and resurrected it EDSTC.

Collapse -

Try this..

by ThePickle In reply to How can I execute a fortr ...

Hello Jim,

It's an honor to have an 85-year-old techie in the forums here.

While I'm not a Fortran programmer, I looked around and was able to find a simple Fortran compiler for Windows. It's called G95, and you can download it here:

If you're not using Windows, here's a list of G95 for other platforms:

I've never used Fortran before, but I was able to download G95 and managed to successfully compile 3 or 4 sample Fortran programs in under 5 minutes.

G95 is a command line application, so you would go into the directory where you've installed it, and type "g95 hello.f" to compile a program whose source code is in a file called "hello.f". When the compiler finishes, it creates an executable called "a.exe" by default. Once you have the compiled file, you're ready to use it by running it.

Hopefully this helps you with your quest to resurrect your old code.

P.S. If you're looking for sample Fortran code, here is the link where I downloaded a few files just to test the G95 compiler:

Collapse -

Reponse To Answer

by skierplus In reply to Try this..

I tried:
g95 -o lk lk3.f90

But it cannot find lk3.f90, which is in notepad. I was hoping to get an executable file lk or lk.exe.

Beginning of the fortran code. I wrote it 20 years ago!

program lk3

c Programmer: Jim Mullaney, BCSR/703/127/700 area
c Phone : 376-3022
c Date : January 1989
c Revisions : April 1991: Version 3.1 writes selected lines to string.fil
c : April 1991: Version 3.2 gives usage when arguments are needed
c : May 1991: Version 3.3 has enhanced help information (hc etc)
c : May 1991: Version 3.4 enhanced search
c : Aug 1991: Version 3.5 faster re-position (subroutine posit)
c : Sep 1991: Version 3.6 can look at file list ('d' option)
c : Sep 1991: Version 3.7 Added column number option (|)
c : Sep 1991: Version 3.8 Added plot file extractor (p)
c : Oct 1991: Version 3.9 Added explode cabability (!)
c : Oct 1991: Version 4.0 Ctrl-M (CFS) removed from end-of-line
c : Nov 1991: Version 4.1 Minor changes to Version display

c Purpose : provide a way to peruse large files without the
c overhead of an editor

c Features :

c Refer to Menu in subroutine help

common /integers/ kount,ktab1,ktab2,ltarg,keepcol

common / chars / chara,line,target,old,lno,pipe
character chara*1,line*200,target*32,old*32,lno*1,pipe*1
common /colors/ in, f, b, colrstat, colr, color
character in*1, f*2, b*2, colrstat*3, colr*11, color*1

character*1 slash

character inptfil*200, merge*1

character ln*10, tab*10, help*79
logical firstime, endf
data firstime /.TRUE./

data slash /'/'/, endf /.FALSE./

data help /
+'Options: a c d e f g h i k l m n # p q r s t v w x + - / ~ \ | !
+ <CR> = page '/

ktab1 = 1
ktab2 = 79
kount = 0
merge = 'N'
lno = 'Y'
pipe = 'N'
endf = .FALSE.
f = 'xx'
in = 'h'
keepcol = 0
open (unit=1,file='tuvwxyz.123')
read (1,800) inptfil
open (unit=3,file=inptfil)

call view(20,endf)
color = 'N'
colrstat = 'OFF'

907 format(1h ,a)

target = ' '

20 write(ln,'(i10)') kount
write(tab,'(i9)') ktab1
ln(1:4) = 'Line'
tab(1:6) = ', Tab '

if (firstime) then
print *,'Version 4.1, Help: hx <cr> explains extract; hc <cr> -> c
+olor; h <cr> -> ALL'
firstime = .FALSE.
print *, ' '

print *, help
print *,ln,tab,inptfil(1:lchar(inptfil)),' Highlight: ',colrstat

* write(6,'(t30,a,a)') 'File: ', inptfil
old = target


Collapse -

I don't think you can

by seanferd In reply to How can I execute a fortr ...

<i>reference the code when it resides in say notepad.</i> Or in a text file, if that's what you mean.

If you are reading it in Notepad, you probably are looking at the source code. You are reading what you originally wrote, yes? You can just compile it, then, for any platform you like. ThePickle posted a reference to a compiler above. You can also look up Fortran debuggers if you want to play with the code some more - a debugger could be handy, then.

Some notes on Fortran under Cygwin:

Collapse -

Get out the DeLorean and charge up the flux capacitor

by oldbaritone In reply to How can I execute a fortr ...

and wait for a big lightning bolt!


Failing that, it's probably easier to do a re-write. I'll bet that takes less time and fewer headaches for you.

Collapse -

Your source file..

by ThePickle In reply to How can I execute a fortr ...

If you're getting a "file not found" error message, simply save a copy of the source file in the same directory where the G95 compiler resides (in the G95/bin directory).

Or, you can specify the path of the source file on the command line. So instead of typing "g95 -o lk lk3.f90", you would instead type "g95 -o lk c:\g95\bin\lk3.f90", assuming of course that you created a G95 directory off the root, and you put your source file into the bin subdirectory.

But file location problems aside, the thing is that I tried compiling your source, and G95 seems to be having problems with it. At first, it was having problems with the first few lines in your source which were obviously comment lines, so the compiler should ignore them...but it was trying to compile them. As I said, I know nothing about Fortran, so I didn't know the correct way to declare comments...but after quickly looking at some of the other sample source files I downloaded yesterday, it seems everything is I don't know why the compiler won't accept your comments even though they appear to be declared correctly.

I'm trying to figure out what's going on, and I'll post an update here once I have something useful.

Back to Software Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums