Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

need to run some code in FORTRAN IV

need to run some code in FORTRAN IV

need to run some code in FORTRAN IV


I'm not a programming guy, but I've got some code I need to run, written in FORTRAN IV. I have the punch cards, and a hardcopy of the input. I've learned that I can send the cards out and have the input sent to me electronically for a small price. What are my options for running this code? Is there a reasonably priced application out there that can compile and run FORTRAN IV code on a PC? Anyone recommend an alternative approach?

Thank You
Old Man K

RE: need to run some code in FORTRAN IV

Plenty of freebie FORTRAN compilers for the PC, though I would consider paying a highschool student recode it for C if you plan on having anyone update it in the future.

Dan - Owner

RE: need to run some code in FORTRAN IV


I agree with Dan.  You can get Visual C++ Express for free from Microsoft, so getting some cheap conversion from Fortran to C or C++ would seem to make sense.

However, I'm wondering what code in Fortran IV could still be relevant if it came on punch cards.  That would make the code around 30 years old.  Has there been no further developments since then?


FAQ731-376: Eng-Tips.com Forum Policies

RE: need to run some code in FORTRAN IV

Thanks for the quick response; I want to clarify if I can..

Fortran IV is the language it is written in, from before the days of Fortran 66, 77, 90, etc. I didn't know if that was being interpreted as a compiler platform, but it's an early version of the language.. Are these available compilers capable of compiling Fortran IV?

RE: need to run some code in FORTRAN IV

We understand the Fortran numbering convention.  The point is that anything code written in Fortran IV is probably so old as to be nearly obsolete and probably superceded by newer and more accurate/correct code.

ANY current Fortran compiler will probably compile Fortran IV with minimal changes.


FAQ731-376: Eng-Tips.com Forum Policies

RE: need to run some code in FORTRAN IV

OK thanks IRstuff,

Not surprised you understood my meaning; I am easily confused due to my minimal experience.  Thank you again for your help.  I'll proceed with Fortran, but I have a sneaking suspicion I'll be searching for a local C++ wiz kid in the near future.

Take Care
Old Man K

RE: need to run some code in FORTRAN IV


Fortran (I believe a newer version) is available free on linux distributions.  Yep Fortran 77.



Although they say that you have to have the source for gcc and compile the compiler I believe they still have RPMs for it on some of the Red Hat linux distros.


    Rich S.

RE: need to run some code in FORTRAN IV

There are a truckload of free Fortran compilers:


You still haven't said what the program does.  If you can share that information, someone might be able to point you to a more current incarnation.


FAQ731-376: Eng-Tips.com Forum Policies

RE: need to run some code in FORTRAN IV

Fortran IV is Fortran 66.
Fortran 77 is compatible with Fortran IV.

You may have to change the file opening/record access/file closing bits - that was non-standard in IV/66.

You may have to change any character handling code: all character strings were stored in integer arrays.  If it is just straight number crunching, you shouldn't have any problems.

RE: need to run some code in FORTRAN IV

I'm a bit curious as to what possible reason there might be for suggesting that an old fortran code be converted to either C or C++ or any other language, especially, if you don't even know what the code is for?

If OldManK isn't sure what he needs to recompile the code using fortran,  he certainly won't be equiped to handle a conversion of the code to C.

If it's some type of structural analysis program ( I note that OldMan is listed as "structural" )  chances are... fortran is probably a good language for the job anyway.  In this situation, it's not likely your average C programmer will be a lot of help either, as a straight and simple conversion between an old fortran IV program and a new C program is likely to require a LOT of effort and a knowledge of the science behind what the code is attempting to do.

  Of course,  if it's a structural analysis program, it is almost a given that there are more recent, and quite possibly better programs already available for the same task.  However,  I caution against the assumption that just because the program is old...  that it is outdated or not as good.  Some of the most powerful programs being used today are just as old.

Dan   smile

RE: need to run some code in FORTRAN IV

Quote (DanTex):

a straight and simple conversion between an old fortran IV program and a new C program is likely to require a LOT of effort and a knowledge of the science behind what the code is attempting to do.
Say wha?  How do you figure?  FORTRAN is pretty darn simple, and conversion to C would be a breeze... time-consuming for a long piece of code, but nothing that would require much thought.  FORTRAN is almost as simple as BASIC in many respects.  Considering the age of the program, I imagine most of it is straight math, very little output change to contend with.

Unless it deals with floating point numbers, a "newer" program isn't necessarily any better.  There are only so many ways you can work with 2+2.  I can imagine quite a few calculations that would be better done with a fast computer (or even a slow one) than attempting to do it in your head or on a calculator, and even the simple stuff doesn't change as the years drag on.

Dan - Owner

RE: need to run some code in FORTRAN IV

It really depends on how old the Fortran IV is.  If it was in its infancy when everyone was a Fortran II coder, it will have loads of 3 way jumps.

It really depends on how well the Fortran IV coder knew Fortran.  If they start using assigned gotos and assigned labels, it isn't that easy.  Also, there were no character types so everything from LOGICAL to DP can be a character.

If it is just calcs, then as you say, it is quite easy.

RE: need to run some code in FORTRAN IV

I've seen a fair number of people try to do fortran to C conversions.  It's often not nearly as easy as originally perceived.  I agree that fortran is relatively simple and if the original code is fairly simple and straight forward, a conversion is probably pretty simple.  But... I've known of several cases where the conversion ended up being a nightmare.

Consider vendor extensions to the language.  A lot of programmers used to use a lot of extensions.  Such use is often a major obstacle for quick conversions.  They even often make it difficult to recompile under a modern fortran compiler.  Then, there's the question of things such as multidimensional arrays, different default bounds for array subscripts, radically different styles of character string manipulation, loop variables that work differently between the languages.  If the code is non-trivial,  optimizations for speed might also come into play.  If the existing code uses multi-dimensional arrays and it was written with speed in mind, just doing a straight conversion to a C-family language will often kill execution speed.  This can be programmed around, but... it may not be a trivial recoding to do so.

And...  in the case that the original programmer kept things clean and followed the basic rules... well...  in that case..  any current fortran compiler should be able to recompile the code with no headaches at all.  And...  adding future updates would continue to be a breeze if desired (as there are plenty of both commercial and free compilers available ).

Off the top of my head, the only reason I can think of to recode to C or C++ is if the person desiring the program is primarily a C programmer and he wants to continue to build the code using C as his language of choice (which of course, is a completely valid reason).

Dan   smile

RE: need to run some code in FORTRAN IV

There is always f2c.exe , a free fortran to C convertor.
I used it for some small programs and it worked. I don't
know how much of a pain it would be for a large program.

RE: need to run some code in FORTRAN IV

I agree with Dan. Though he did not say so, I am sure the conversion nightmare he referred to included debugging the converted code. The conversion process itself creates a point where errors, read bugs, can be introduced. If the original program is relatively small one could possibly live with the debugging effort. However, if the original program is sizable and reliable, then the debugging effort with converted code might be formidable.

Even if the code can be made to run on a current fortran compiler debugging may still be required. There is no guarantee the program, even if it can be a compiled with a current fortran compiler will generate error free results.

Testing remains an issue. One should have test data, both input and output, from the original use/installation. One could compare the output data with the output from an executable generated with a current compiler using the same input data to see if they are the same.

If the outputs differ, the debugging may be limited to the compiler and the platform and not the program itself.

OT but to date myself, I grew up with punch cards and Fortram IV. I have even used WatIV, a core resident Fortran IV compiler, before I knew what "core resident" meant. Before WatIV people would have to load both the compiler and their program as card decks into the card reader for processing. The program could be the "data" for the compiler.

Good luck. JVJ

RE: need to run some code in FORTRAN IV

I also agree with Dan. Converting from FORTRAN to C can be extremely difficult or almost impossible in some cases.

>>FORTRAN is almost as simple as BASIC in many respects.

Top of the line Finite Element Analysis software like ANSYS and NASTRAN are written in FORTRAN. All computationally intensive analysis software is still being written in FORTRAN.

RE: need to run some code in FORTRAN IV

Being caught in the transition from card reader to PC light years ago, I started to transfer fortran programs to turbo pascal, it was easier to get a hold on the fluxogram or programming logic (especially for big programs) then try to converting by translating.
Especially the massive use of goto in the older Fortan routines was a pain in the neck.
At that time I didn't had access to Fortan on PC

If in Pascal it was difficult, imagine #@!C

RE: need to run some code in FORTRAN IV

It really does depend on how the logic of the original program was written.  With the older programs it is often easier to flowchart it, pull the string straight and recode it.  Most FIV programs I've translated are written by the average programmer and are quite easy.

It gets difficult when you get a devious programmer who really knows the language.  For instance, those who go to town with the assign statement and arithmetic ifs.  Not very often that you see something like


if (a .gt. b .and. a .lt. c) if (a) 10, 20, 30
Even going from FIV to F95 takes a lot more code.  The good thing is there are not many of those about.

Same can be said of C, C++ and C#.  They're layered and it takes ages picking through to figure out how data gets from one side to the other.  Nowadays, nobody writes programs anymore: they just type them in without any thought or design so you end up with an even bigger mess.

Have you ever tried translating from Assembler to a High Level Language?  If you get an assembler wiz, it is really difficult.  What they do in 10 assembler statements can be double or even triple the size in HLL, sometimes, purely because the compiler doesn't generate that code.

You can't get clever with Pascal or Basic: they have too many restrictions.

RE: need to run some code in FORTRAN IV

Yes.   I've seen plenty of codes written by language experts who can cram an amazing amount into a single line of code.   I'm impressed by their capability to do that, however, attempting to understand their code or debugging it can be a nightmare.

I like to keep the code as simple as possible.  The complex stuff is only warranted when you have an absolute need for it and there is no simple solution that will yield sufficient results (regardless of the language used).

Even in some of the Fortran code I write,  I'll often skip the incredibly nice, clean, compact array math capabilities just to make the code more transparent for when I'm looking at it a year or two down the line ( ie. I put the code in a loop that anyone can understand... several lines of code instead of just one or two).


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close