Fortran Need help installing fortran compiler

  • Thread starter Thread starter logix88
  • Start date Start date
  • Tags Tags
    Compiler Fortran
Click For Summary
The user is attempting to install an f77 compiler on Windows 7 using MinGW 5.1.3 but encounters errors when compiling a simple Fortran program. The error messages indicate that the compiler is not recognizing the code due to invalid first characters in the source file. A contributor suggests that the issue may stem from the historical formatting rules of Fortran, which dictate that specific columns in the code have designated purposes. It is recommended to adjust the code's indentation so that it begins in column 7 or higher, as this may resolve the compilation errors. The discussion emphasizes the importance of adhering to Fortran's formatting conventions to successfully compile programs.
logix88
Messages
12
Reaction score
0
Hi!

I wanted to install a f77 compiler, I am running Win7 but also have WinXP, I installed MinGW 5.1.3 and did everything mentioned in this pdf (https://docs.google.com/viewer?url=http://www.pns.anl.gov/instruments/scd/subscd/Fortran_and_C.pdf)

So, basically its an automatic installer, I just had to add the Enivormental Variables bit

I went into Advanced settings, created new User variable called PATH and set variable value to C:\MinGW\bin as it says... but when I compiled ( g77 hello.f -o hello ) simple helloworld prg it gave me this:


C:\>cd MinGW

C:\MinGW>g77 hello.f -o hello
hello.f:1:
PROGRAM MAIN
^
Invalid first character at (^) [info -f g77 M LEX]
hello.f:2:
PRINT *, 'HELLO WORLD'
^
Invalid first character at (^) [info -f g77 M LEX]
hello.f:3:
STOP
^
Invalid first character at (^) [info -f g77 M LEX]
hello.f:4:
END
^
Invalid first character at (^) [info -f g77 M LEX]

Any clue what might have gone wrong?

Pls do help...
 
Technology news on Phys.org
Back in the days when FORTRAN programs were punched onto Hollerith cards (AKA IBM cards, there were some rules about what could go where on the card.

If I'm remembering correctly, the only thing that could go in column 1 was the character C, for comment. Columns 2 through 6 were for line numbers that were used as format statements for READ and WRITE statements.

Columns 7 through 72 were for program code. The documentation that comes with your compiler (or is available on-line) should tell you if there limitations about which columns program code can go it. That's what I think you're running up against.

If that's the problem, see if indenting all your code 1 space makes a difference. If that doesn't help, indent your program code so that it starts on column 7 or higher.
 
Close, so close.

Column 1 can only contain a C, indicating that the line is a comment.
Column 2-5 can contain line numbers for format statements, or for some of the wonderful and wacky FORTRAN features like the computed GOTO.
Column 6 can only be used to indicate a continuation of the preceding line.
Column 7-72 can contain code.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 27 ·
Replies
27
Views
7K
  • · Replies 18 ·
Replies
18
Views
6K