Fortran I'm Having a lot of Problems with Fortran (77)

  • Thread starter womfalcs3
  • Start date
I'm new to this language, and my programming experience is limited (I've only done Assembly). My issues do not necessarily lie in the coding itself, but in the compiling and building.

I'm using Eclipse, on which I installed Photran. The syntax recognition and formatting of the GUI is very nice.

I've tried many compilers. From G77, to GCC 4.3.3 with Fortran, and others (BCF12b, and so on).

Eclipse never builds or runs though. It sometimes brings up binary parser errors, and I don't see a makefile anywhere in the navigation bar.

I wrote and saved my relatively simple *.f file (Simpson's 1/3 Rule). I just need to run it and see if it works.

Thank you.
My suggestion is to compile and run a simple program (like printing "hello world!") onto the screen and see if it works. If it doesn't, then you have some configuration work to do.
Alternatively you can post your simpson's ruel program (probably 15 lines) and see if there is an inherent problem. There are less and less people using F77. Many have converted to later versions.
I don't think it's the program; I have it shown below. Sure it's not the most memory-efficient, but that's not my objective right now. I'm just trying to get a simple program to work.

I was finally able to get a makefile generated automatically, but now it can't launch it whenever I use the program in conjunction with any of the compiles mentioned above.

I realize people have moved on from F77, but that's what I'm using since I was instructed it would be sufficient for what I am doing.

Forgot to mention, I still use F77, although I use other languages as well. I have nothing against an established language that is efficient, as long as its capability is not limited for what I need to do.
If you have not run the program yet, make a copy of simpson.txt before you do so. Your code declares the file as new, so it will most probably erase the old one and replace an empty one. By the time you try to read from it, it will probably fail, or read garbage, or read zeroes (most unlikely for Fortran).
If the file simpson.txt is existing, Fortran expects status='old'.
I did not check the rest of the code, but I think you should be sailing smoothly after that.
A Statement Function in Fortran is defined with an argument:
not with f=sin(y)
An example follows:
      REAL*8 A,B,H,FUN,X
C     following is a statement function definition
...   do your Simpson's rule programme here using FUN(X) instead of sin(x)
...   print results
Also, the variable int defaults to integer, as all variables commencing with A-H, O-Z are real*4, and I-N are integers. If you write
at the beginning of all your programs, you will not forget the default prefix letter convention.
I usually use SUM, which defaults to REAL.
If you want to use double precision by default, write the following at the beginning.

Hope that helps you to get started.
Thanks a lot. I really appreciate it.
If you don't mind to provide further assistance, I would appreciate it if you checked over my program again.

I finally found a compiler that will work. It's standalone though. I can't seem to integrate it with Eclipse. It gives back a message saying I have 1 severe error.

I'm trying to follow a Fortran book as to how to enter the inputs from within the program rather than using an external text file. It just shows a data card after the "end" command in which it has the inputs. Is that correct?

Your program looks OK, except for a couple of minor errors.
The older fortran compilers ran on punched cards, so data would immediately follow the program, sometimes separated by a separator card, such as /* (end of program) or // (end of input).
So your data line that follows the end statement will cause a compiler error because modern compilers do not expect data following immediately the program.
What you'll need to do is to remove that line, or make a C in column 1 to make it a comment (so the line will stay for information).
Back to the program:
the line for requesting input would preferably be
which will request input in free format, so you don't have to respect the number of spaces between data when you type in your data on the screen. The format statment can be used for output as you have done, but the I3 at the end can be changed for I5 to leave spaces before the integer (100 needs three characters).
There is an error for the calculation of y inside the two loops, see if you can find what is the correct coding.
The answer for area should be 0.99999 or around there, depending on the compiler and precision.
If you cannot find the error for calculation of y inside the loops, post the formula for simpson's rule and check again according to the formula you found.
Keep it up, you are just a couple of lines away!
It gives me problems with the function. "Assignment operation illegal to external procedure fun" Then it gives me the line in which the function is written.

I went online to find examples of how to input functions in F77, but other methods I've tried resulted in more errors in relation to the function.

Also, I believe I have fixed the error of which you speak in relation to the y-value. I can deal with computational errors right now though. I just need to get the program to work. If the solution is wrong, I can go back and work it out by hand then translate that over to the source file.
Last edited:
"Assignment operation illegal to external procedure fun"
Sorry, I forgot to mention that the definition of the statement function
must be placed before any executable statement. In your case, a safe bet would be to place it after the declaration of variables (i.e. after real a,b,h....).
Thanks a lot!! Your help was great.

It worked. I had to also include a "go to" statement so that the *.exe file generated wouldn't close on me immediately after the solutions were output. I also added some "print" statements to simplify input and data recognition.

Good results too. Here were some results with varied number of intervals:

Good job, efforts (almost) always pay off!
By the way Math, what compiler do you use?

For this initial practice run, I spent a lot of time going through compilers. I ran into this one called PGI Fortran Workstation. It's the one I used for this program.

In just one command line in Command Prompt, it gave me an executable file. Which is what I needed. It's a really really awesome compiler.

The problem is, this PGI application costs 500 dollars + subscription. I used the trial version.

I've been examining Open Watcom F77. It compiles into *.obj files, and there doesn't seem any option to build an *.exe file.

I have 14 days on the trial version, and I don't know if I'll end up spending that much money on it. I was looking for a free alternative.
The one I use is not free, it's a very respectable compiler called Lahey. They have been in the business for a very long time, namely providing Fortran compilers on PC's. (

The following link lists a number of free fortran compilers, I have heard of people using the G77 compiler, but haven't had much feedback. Be aware: read the contract carefully for each compiler you want to try. Sometimes they are not as free as one thinks.

Other than that, you can start a new thread asking for opinions of others. There are many Fortran users around here.

Related Threads for: I'm Having a lot of Problems with Fortran (77)

  • Posted
  • Posted

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving