Simple program in Fortran, I get an error

In summary, the conversation is about someone trying to learn Fortran by completing simple problems from a website. They share their program and ask for help with an error they are receiving. They later realize their mistake and solve the issue. They mention encountering another problem with executing the program, but are confident they will be able to solve it.
  • #1
fluidistic
Gold Member
3,923
261
It's not an assignment. Rather I'm trying to learn back some fortran.
I've found a website with some simple problems to do, that's where I got this one. See the first problem of this page : http://www.chem.ox.ac.uk/fortran/.

Here's my program :
Program vasy
implicit none

Integer :: C
Real :: F

C=0
F=0
do while (C<=100)
F=(9./5.)*C+32
C+1
write(*,*)C,F

end do


end program vasy

Here's the error I'm getting : "
C+1
1
Error: Unclassifiable statement at (1)
"
I know I didn't have to set F=0, but I tried several things in case the error was there... I can't get rid of the problem. My compiler is goftran and I'm under Ubuntu.
 
Technology news on Phys.org
  • #2
Nevermine, I just saw my problem. I had to write a=a+1 instead of just a+1.

Now I'm getting a permission denied when executing the program, but I think I'll solve it.
Thanks anyway!
 
  • #3


I would suggest checking the Fortran syntax and making sure all statements are properly structured and formatted. It is also important to check for any missing or incorrect punctuation marks, as they can cause errors in the program. Additionally, it may be helpful to review basic programming concepts and principles to better understand and troubleshoot the error. If the issue persists, it may be helpful to consult with a more experienced programmer or refer to online resources for further assistance.
 

1. Why am I getting an error when running my Fortran program?

There are several potential reasons for receiving an error when running a Fortran program. Some common issues include syntax errors, incorrect variable declarations or usage, and missing or incorrect input/output statements. It is important to carefully check your code for any mistakes and to run it through a compiler to identify any errors.

2. How can I fix a syntax error in my Fortran program?

If you are receiving a syntax error, it means that there is a mistake in the structure or formatting of your code. To fix this, carefully review your code and compare it to the syntax rules for Fortran. Make sure all statements and operators are correctly spelled and used in the proper order. You may also want to use an editor or IDE that has syntax highlighting to help identify any mistakes.

3. What should I do if my Fortran program is not producing the expected output?

If your program is not producing the expected output, there may be an error in your logic or calculations. Check your code for any mistakes or missing steps, and make sure your variables are being used correctly. You may also want to add print statements or use a debugger to track the flow of your program and identify where the issue is occurring.

4. How can I troubleshoot my Fortran program if I am not familiar with the language?

If you are new to Fortran and are having trouble troubleshooting your program, it may be helpful to consult online resources, such as documentation or forums, for help. You can also reach out to other Fortran programmers or enlist the assistance of a tutor or mentor. It may also be beneficial to practice writing smaller, simpler programs before attempting more complex ones.

5. What are some common best practices for writing Fortran programs?

Some common best practices for writing Fortran programs include using consistent and descriptive variable names, properly commenting your code, and breaking larger programs into smaller, more manageable modules. It is also important to regularly test and debug your code to catch any errors early on. Additionally, staying up-to-date on new versions or features of Fortran can help improve the efficiency and accuracy of your programs.

Similar threads

  • Programming and Computer Science
Replies
4
Views
619
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
5
Views
4K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
2
Replies
37
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
Back
Top