Program won't compile (Fortran 77)

  • Fortran
  • Thread starter Nano-Passion
  • Start date
  • Tags
    Program
In summary, the program is a simple Fortran 77 code that uses the Force 2.0 compiler. The output issues were caused by the file not having a proper file extension, which was easily fixed by using ".f" as the extension.
  • #1
Nano-Passion
1,291
0
This is my program:

PROGRAM practice

integer:: A

Read*, A

print*, A

END PROGRAM

Very simple program, just a test. I'm using "Force 2.0" for Fortran 77

But this keeps coming out

C:\Program Files\Force 2.0\bin\ld.exe:C:\Users\Dr. Ghobrial\Desktop\Source2.~f: file format not recognized; treating as linker script
C:\Program Files\Force 2.0\bin\ld.exe:C:\Users\Dr. Ghobrial\Desktop\Source2.~f:1: syntax error
collect2: ld returned 1 exit status


Any ideas?
 
Technology news on Phys.org
  • #2
Judging from the output problems have nothing to do with the syntax, rather the compiler is trying to read wrong file.

But that's just a guess, I have never used Force (too low level of midi-chlorians).
 
  • #3
Using ".~f" as a file name suffix seems a strange idea, unless the Force 2.0 documentation told you to do that.

Try .f77, .F77, or even just .f or .F (often f and F indicate the source code is in fixed format or free format).
 
  • #4
Borek said:
Judging from the output problems have nothing to do with the syntax, rather the compiler is trying to read wrong file.

But that's just a guess, I have never used Force (too low level of midi-chlorians).

:smile:

AlephZero said:
Using ".~f" as a file name suffix seems a strange idea, unless the Force 2.0 documentation told you to do that.

Try .f77, .F77, or even just .f or .F (often f and F indicate the source code is in fixed format or free format).

I didn't put .~F, the program did that automatically.

.F worked though, thank you!
 
  • #5
I'm guessing that you didn't have a file extension at all - that your file's name was Source2, with no extension. The compiler was probably looking for any files with a .F or similar file extension.
 
  • #6
Mark44 said:
I'm guessing that you didn't have a file extension at all - that your file's name was Source2, with no extension. The compiler was probably looking for any files with a .F or similar file extension.

Yep you guessed right. It was a silly mistake, I haven't programmed in a while.
 

FAQ: Program won't compile (Fortran 77)

Why won't my Fortran 77 program compile?

There could be several reasons why your program won't compile. Some common causes include syntax errors, mismatched variable types, missing libraries or modules, and incorrect compiler settings.

How do I fix syntax errors in my Fortran 77 code?

Syntax errors occur when your code does not follow the proper syntax rules of Fortran 77. To fix these errors, carefully review your code and make sure all statements and keywords are spelled correctly, and that all parentheses, brackets, and quotation marks are properly closed.

Why am I getting "undefined reference" errors during compilation?

This error occurs when the compiler cannot find a function or variable that has been referenced in your code. Make sure all necessary libraries and modules are included in your program and that the function or variable is properly defined.

How do I specify the correct compiler settings for my Fortran 77 program?

The specific compiler settings may vary depending on the compiler you are using. Refer to the documentation for your compiler to determine the appropriate settings for your program. You may also need to specify the Fortran 77 standard and any relevant compiler directives in your code.

Can I use modern Fortran features in my Fortran 77 program?

Fortran 77 is an old programming language and does not support many modern features. However, some compilers may have extensions that allow you to use certain modern features. It is best to refer to the documentation for your specific compiler to determine which features are supported.

Similar threads

Replies
4
Views
2K
Replies
5
Views
1K
Replies
16
Views
6K
Replies
5
Views
2K
Replies
4
Views
4K
Replies
6
Views
3K
Replies
2
Views
4K
Replies
19
Views
6K
Replies
6
Views
2K
Back
Top