Need help installing fortran compiler

  • Context: Fortran 
  • Thread starter Thread starter logix88
  • Start date Start date
  • Tags Tags
    Compiler Fortran
Click For Summary
SUMMARY

The discussion focuses on installing the Fortran 77 (f77) compiler using MinGW 5.1.3 on Windows 7 and Windows XP. The user encountered compilation errors related to invalid first characters in their Fortran source code. The solution involves adhering to Fortran's fixed-format rules, specifically ensuring that code starts in column 7 or higher, as outlined in the documentation. Adjusting the indentation of the code is necessary to resolve these issues.

PREREQUISITES
  • Understanding of Fortran 77 syntax and fixed-format rules
  • Familiarity with MinGW 5.1.3 installation and configuration
  • Knowledge of setting environment variables in Windows
  • Basic command line usage in Windows
NEXT STEPS
  • Research Fortran 77 fixed-format coding standards
  • Learn about MinGW configuration and troubleshooting
  • Explore advanced features of g77 compiler
  • Investigate modern alternatives to Fortran 77 for new projects
USEFUL FOR

This discussion is beneficial for software developers, particularly those working with legacy Fortran code, as well as anyone involved in compiling Fortran programs using MinGW on Windows systems.

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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 12 ·
Replies
12
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
7K