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).

:rofl:

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.
 

1. 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.

2. 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.

3. 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.

4. 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.

5. 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

  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
16
Views
5K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
33
Views
4K
  • Programming and Computer Science
Replies
12
Views
6K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
19
Views
5K
Back
Top