Need help installing fortran compiler

In summary: However, certain columns are reserved for different purposes- for example, column 7 is reserved for the program's main() function.If the code that you're trying to compile is not in one of those columns, your compiler will tell you that you're not allowed to compile it.In summary, the compiler says that you can't compile your program because it's not in one of the designated columns.
  • #1
logix88
12
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
  • #2
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.
 
  • #3
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.
 

What is a Fortran compiler and why do I need it?

A Fortran compiler is a software program that translates Fortran code into machine-readable instructions that can be executed by a computer. Fortran is a programming language commonly used in scientific and engineering applications. You need a Fortran compiler to transform your code into a format that the computer can understand and execute.

How do I install a Fortran compiler?

The installation process for a Fortran compiler may vary depending on the specific compiler you are using and your operating system. Generally, you can download the compiler from the manufacturer's website and follow the installation instructions provided. It may also be available as part of a software package, such as a development environment, that you can install on your computer.

Can I use a free Fortran compiler?

Yes, there are several free Fortran compilers available for use. Some popular options include GNU Fortran (gfortran), Intel Fortran Compiler (ifort), and the open-source compiler from the Flang project. These compilers are typically available for download and use on various operating systems.

Do I need any additional software to use a Fortran compiler?

In most cases, you will need a text editor or integrated development environment (IDE) to write your Fortran code. However, some Fortran compilers may come with a built-in editor or IDE. It is also helpful to have a basic understanding of programming concepts and the Fortran language itself.

What should I do if I encounter problems during the installation process?

If you encounter any issues while installing your Fortran compiler, it is best to consult the compiler's documentation or seek assistance from the manufacturer's support team. You can also reach out to online communities or forums for help. It may also be helpful to check your computer's system requirements and make sure you have all necessary dependencies installed.

Similar threads

  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
8
Views
5K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
2
Views
5K
  • Programming and Computer Science
Replies
18
Views
6K
  • Programming and Computer Science
Replies
6
Views
3K
Back
Top