0

I am trying to run a simple Fortran file but I get the error

unexpected ',',expecting '='

The program is as follows.

program circle
real r, area

c This program reads a real number r and prints
c the area of a circle with radius r.

    write (*,*) 'Give radius r:'
    read (*,*) r
    area = 3.14159*r*r
    write (*,*) 'Area = ', area

    stop
    end

How do I fix this?

francescalus
  • 30,576
  • 16
  • 61
  • 96
  • It would be better if you included your code as text on SO. To declare a var, you declare the TYPE then :: and then the var names, e.g. REAL :: r, area – Shawn Mehan Mar 14 '17 at 23:03
  • @ShawnMehan, in many cases (such as the example you give) the `::` is optional. – francescalus Mar 14 '17 at 23:07
  • @francescalus thank you for your answer.What do you mean by line length. This is the first code i write on fortran. I was reading Fortran77 tutorial and this code was on the first page. I could not run the simplest code. – Ali Yılmaz Mar 14 '17 at 23:22
  • 1
    It's the source form that is the problem. With the fixed-form​ source you are using you cannot start the first two lines before the seventh column of each line. However, the real fix is to learn about free-form source (introduced in Fortran 90). – francescalus Mar 14 '17 at 23:28
  • @francescalus thank you very much it works when i start after seventh column – Ali Yılmaz Mar 14 '17 at 23:36
  • @francescalus can i ask you one more thing? It ask the value for radius, i write and press enter and the window is closed where can i see the result of the program – Ali Yılmaz Mar 14 '17 at 23:51
  • That depends on the way how you are executing your program... Put there one more read at the end so that your program stops once more. For a specific solution about keeping Windows terminal window open search StackOverflow. It was treated here before, probably many times. – Vladimir F Героям слава Mar 15 '17 at 07:59
  • In Visual Studio http://stackoverflow.com/questions/454681/how-to-keep-the-console-window-open-in-visual-c if you use something else, search yourself. – Vladimir F Героям слава Mar 15 '17 at 08:01

0 Answers0