Fortran 77 Programming on Windows 7 32-bit: A Complete Guide
Fortran 77 Download for Windows 7 32-bit OS
Fortran 77 is a general-purpose, compiled, imperative programming language that is especially suited for numeric computation and scientific computing. It is one of the oldest and most widely used programming languages in the world, with applications in engineering, physics, chemistry, mathematics, biology, and many other fields. In this article, we will show you how to download and install Fortran 77 on Windows 7 32-bit OS, as well as how to use it for writing, compiling, and running simple programs.
Fortran 77 Download For Windows 7 32bit Os
Fortran 77 overview
Fortran 77 is a version of the Fortran programming language that was proposed in 1977 and officially standardized in 1978 by ANSI (American National Standards Institute). It is the successor of Fortran 66 and the predecessor of Fortran 90. It added a number of significant features to address some of the shortcomings of Fortran 66, such as:
Block IF and END IF statements, with optional ELSE and ELSE IF clauses, to provide improved language support for structured programming
Character data type and string manipulation functions
Implicit NONE statement to require explicit declaration of variables
DO WHILE loop construct for indefinite iteration
OPEN, CLOSE, INQUIRE, and REWIND statements for file input/output operations
SAVE statement to preserve the values of local variables between subprogram invocations
PARAMETER statement to define named constants
INCLUDE statement to insert external source code files
Generic intrinsic functions for mathematical operations on different data types
Fortran 77 also retained most of the features of Fortran 66, such as:
Fixed source code format with columns and line numbers
Arithmetic IF statement for conditional branching
GOTO statement for unconditional branching
COMMON blocks for sharing variables between subprograms
EQUIVALENCE statement for aliasing variables
DATA statement for initializing variables
DIMENSION statement for declaring arrays
FUNCTION, SUBROUTINE, CALL, RETURN statements for defining and invoking subprograms
FORMAT statement for specifying input/output formats
READ, WRITE, PRINT statements for input/output operations
Fortran 77 download and installation
To use Fortran 77 on Windows 7 32-bit OS, you need to have a Fortran compiler that can generate executable files that are compatible with your system. A compiler is a program that translates source code written in a programming language into machine code that can be executed by a computer. There are many Fortran compilers available online, both free and commercial. Some of the most popular ones are:
NameDescriptionWebsite
GFortranA free, open-source compiler that is part of the GNU Compiler Collection (GCC). It supports most of the Fortran standards, including Fortran 95, 2003, and 2008.[GFortran](^7^)
Intel Fortran CompilerA commercial compiler that is optimized for Intel processors and supports most of the Fortran standards, including Fortran 95, 2003, and 2008. It also offers advanced features such as parallelization, vectorization, and debugging tools.[Intel Fortran Compiler]
Lahey/Fujitsu Fortran 95A commercial compiler that supports the Fortran 95 standard and some features of Fortran 2003 and 2008. It also provides a graphical user interface (GUI) for editing, compiling, and debugging Fortran programs.[Lahey/Fujitsu Fortran 95]
Absoft Pro FortranA commercial compiler that supports the Fortran 95, 2003, and 2008 standards and offers high performance and compatibility with other compilers. It also includes an integrated development environment (IDE) with a GUI, a debugger, and a profiler.[Absoft Pro Fortran]
Simply FortranA commercial compiler that supports the Fortran 95 standard and some features of Fortran 2003 and 2008. It also features a simple and user-friendly IDE with a GUI, a debugger, and a code editor.[Simply Fortran]
g95A free, open-source compiler that supports the Fortran 95 standard and some features of Fortran 2003 and 2008. It is based on the GCC backend and can be used as a standalone compiler or as a cross-compiler.[g95]
In this article, we will use GFortran as an example of how to download and install a Fortran compiler on Windows 7 32-bit OS. However, you can choose any other compiler that suits your needs and preferences. The steps and instructions may vary slightly depending on the compiler you choose.
Requirements and prerequisites for Fortran 77
Before you download and install GFortran on your Windows 7 32-bit OS, you need to make sure that you have the following requirements and prerequisites:
A Windows 7 32-bit OS with at least 1 GB of RAM and 500 MB of free disk space
An internet connection to download the compiler files
A text editor or an IDE to write your Fortran source code files
A command prompt or a terminal to execute your Fortran programs
Sources and options for GFortran compilers
GFortran is available for download from various sources and options. You can choose the one that best suits your needs and preferences. Some of the most common sources and options are:
Source/OptionDescription
GFortran official websiteYou can download the latest version of GFortran from its official website [GFortran]. You can choose between different binary packages for different platforms, such as Windows, Linux, Mac OS X, etc. You can also download the source code if you want to build the compiler yourself.
Mingw-w64 projectYou can download GFortran as part of the Mingw-w64 project [Mingw-w64], which provides a complete runtime environment for GCC on Windows. You can choose between different versions of Mingw-w64, such as i686 (32-bit) or x86_64 (64-bit), depending on your system architecture.
Cygwin projectYou can download GFortran as part of the Cygwin project [Cygwin], which provides a Linux-like environment for Windows. You can install GFortran using the Cygwin setup program, which allows you to select from a list of available packages.
MSYS2 projectYou can download GFortran as part of the MSYS2 project [MSYS2], which provides a Unix-like environment for Windows. You can install GFortran using the MSYS2 package manager (pacman), which allows you to update and manage your packages easily.
-GCC project]You can download GFortran as part of the TDM-GCC project [TDM-GCC], which provides a modified version of GCC for Windows. You can choose between different editions of TDM-GCC, such as 32-bit or 64-bit, SJLJ or SEH, etc.
Steps and instructions for downloading and installing GFortran
In this article, we will use the Mingw-w64 project as an example of how to download and install GFortran on Windows 7 32-bit OS. However, you can follow similar steps and instructions for other sources and options. The steps and instructions are:
Go to the Mingw-w64 project website [Mingw-w64] and click on the "Downloads" link.
Select the "Mingw-builds" option from the list of available downloads.
Choose the version, architecture, threads, and exception options that match your system and preferences. For example, you can choose version 10.3.0, i686 (32-bit), posix, sjlj.
Click on the "Download" button and save the file to your desired location.
Run the downloaded file and follow the installation wizard. You can choose the default settings or customize them according to your needs.
Make sure to add the bin directory of the Mingw-w64 installation to your system PATH environment variable. This will allow you to access the GFortran compiler from any directory using the command prompt or terminal.
Fortran 77 usage and examples
Once you have downloaded and installed GFortran on your Windows 7 32-bit OS, you can start using it for writing, compiling, and running Fortran 77 programs. Here are some examples of how to do that:
How to write, compile, and run a simple Fortran 77 program
A simple Fortran 77 program that prints "Hello, world!" to the standard output is:
PROGRAM HELLO PRINT *, 'Hello, world!' END
To write this program, you can use any text editor or IDE that supports Fortran syntax highlighting and indentation. For example, you can use Notepad++, Visual Studio Code, Atom, etc. You can also use the built-in Notepad application in Windows, but it may not provide any syntax highlighting or indentation features.
To save this program, you need to use a .f or .for extension for your file name. For example, you can save this program as hello.f or hello.for in your desired location.
To compile this program, you need to open a command prompt or terminal window and navigate to the directory where you saved your program file. Then, you need to use the gfortran command followed by the name of your program file. For example, you can type:
gfortran hello.f
This will generate an executable file named a.exe in the same directory as your program file. You can also specify a different name for your executable file using the -o option. For example, you can type:
gfortran hello.f -o hello.exe
This will generate an executable file named hello.exe in the same directory as your program file.
To run this program, you need to type the name of your executable file in the command prompt or terminal window. For example, you can type:
a.exe
or
hello.exe
How to use common Fortran 77 commands and statements
Fortran 77 has a rich set of commands and statements that allow you to perform various operations and tasks in your programs. Here are some examples of how to use some of the common Fortran 77 commands and statements:
How to declare variables and constants
To declare variables and constants in Fortran 77, you need to use the IMPLICIT NONE, DIMENSION, PARAMETER, and TYPE statements. For example, you can declare a variable named x as an integer, an array named y as a real, a constant named pi as a double precision, and a character string named z as follows:
IMPLICIT NONE INTEGER x REAL y(10) DOUBLE PRECISION pi PARAMETER (pi = 3.14159) CHARACTER*20 z
The IMPLICIT NONE statement tells the compiler to require explicit declaration of all variables and constants. The DIMENSION statement specifies the size and shape of an array. The PARAMETER statement defines a named constant with a fixed value. The TYPE statement specifies the data type of a variable or constant.
How to assign values to variables and constants
To assign values to variables and constants in Fortran 77, you need to use the assignment operator (=) or the DATA statement. For example, you can assign values to the variables and constants declared above as follows:
x = 5 y(1) = 1.0 y(2) = 2.0 y(3) = 3.0 z = 'Hello, world!' DATA y(4), y(5), y(6) /4.0, 5.0, 6.0/
The assignment operator (=) assigns the value on the right-hand side to the variable or constant on the left-hand side. The DATA statement assigns values to one or more variables or constants in a list. The values are separated by commas and enclosed by slashes (/).
How to perform arithmetic operations on variables and constants
To perform arithmetic operations on variables and constants in Fortran 77, you need to use the arithmetic operators (+, -, *, /, ). For example, you can perform some arithmetic operations on the variables and constants declared above as follows:
x = x + 1 y(7) = y(1) * y(2) / y(3) pi = pi 2
How to perform logical operations on variables and constants
To perform logical operations on variables and constants in Fortran 77, you need to use the logical operators (.NOT., .AND., .OR., .EQV., .NEQV.). For example, you can perform some logical operations on the variables and constants declared above as follows:
x = .NOT. (x .EQ. 6) y(8) = y(7) .AND. (y(7) .GT. 0.0) pi = pi .OR. (pi .LT. 0.0)
The logical operators (.NOT., .AND., .OR., .EQV., .NEQV.) perform negation, conjunction, disjunction, equivalence, and non-equivalence respectively. The order of precedence of the operators is: .NOT. > .AND. > .OR. > .EQV. > .NEQV.. You can use parentheses () to change the order of precedence or to group expressions.
How to perform input/output operations on variables and constants
To perform input/output operations on variables and constants in Fortran 77, you need to use the READ, WRITE, PRINT, OPEN, CLOSE, INQUIRE, and REWIND statements. For example, you can perform some input/output operations on the variables and constants declared above as follows:
OPEN (UNIT=10, FILE='input.txt', STATUS='OLD', ACTION='READ') READ (10, *) x CLOSE (UNIT=10) OPEN (UNIT=20, FILE='output.txt', STATUS='NEW', ACTION='WRITE') WRITE (20, *) y CLOSE (UNIT=20) PRINT *, z
The OPEN statement opens a file for input/output operations and assigns a unit number to it. The unit number is an integer that identifies the file in subsequent statements. The FILE parameter specifies the name of the file. The STATUS parameter specifies whether the file is old (existing), new (non-existing), or scratch (temporary). The ACTION parameter specifies whether the file is opened for reading, writing, or both.
The READ statement reads data from a file or the standard input and assigns it to one or more variables or constants. The WRITE statement writes data from one or more variables or constants to a file or the standard output. The PRINT statement writes data from one or more variables or constants to the standard output.
How to use control structures and loops in Fortran 77
To use control structures and loops in Fortran 77, you need to use the IF, ELSE, ELSE IF, END IF, DO, END DO, DO WHILE, CONTINUE, GOTO, and STOP statements. For example, you can use some of these statements to implement a simple algorithm that calculates the factorial of a given number as follows:
PROGRAM FACTORIAL IMPLICIT NONE INTEGER n, i, f PRINT *, 'Enter a positive integer:' READ *, n IF (n .LT. 0) THEN PRINT *, 'Invalid input.' STOP ELSE f = 1 DO i = 1, n f = f * i END DO PRINT *, 'The factorial of', n, 'is', f END IF END
The IF statement evaluates a logical expression and executes a block of statements if the expression is true. The ELSE statement executes a block of statements if the expression is false. The ELSE IF statement evaluates another logical expression if the previous expression is false. The END IF statement marks the end of the IF block.
The DO statement initiates a loop that iterates over a range of values. The END DO statement marks the end of the loop. The DO WHILE statement initiates a loop that iterates while a logical expression is true. The CONTINUE statement marks the end of the loop.
The GOTO statement transfers the control flow to a specified statement label. The STOP statement terminates the program execution.
Conclusion
In this article, we have shown you how to download and install Fortran 77 on Windows 7 32-bit OS, as well as how to use it for writing, compiling, and running simple programs. We have also covered some of the main features and benefits of Fortran 77, as well as some of the common commands and statements that you can use in your programs.
Fortran 77 is a powerful and versatile programming language that is widely used for scientific computing and numeric computation. It has a long history and a large user base, and it is compatible with many other programming languages and platforms. It also offers high performance and efficiency for solving complex problems and handling large data sets.
If you want to learn more about Fortran 77 or improve your skills in using it, we recommend you to check out some of the following resources:
[Fortran 77 Tutorial]: A comprehensive and easy-to-follow tutorial that covers the basics and advanced topics of Fortran 77.
[Fortran 77 Reference Manual]: A complete and detailed reference manual that describes the syntax and semantics of Fortran 77.
[Fortran Wiki]: A collaborative website that provides information and resources about Fortran in general.
[Fortran Online Compiler]: An online tool that allows you to write, compile, and run Fortran programs in your browser.
FAQs about Fortran 77
Here are some of the frequently asked questions (FAQs) about Fortran 77:
Q: What does Fortran stand for?
A: Fortran stands for FORmula TRANslation. It was originally designed to translate mathematical formulas into machine code.
Q: What are the differences between Fortran 77 and Fortran 90?
A: Fortran 90 is a newer version of Fortran that was standardized in 1991 by ANSI. It introduced many new features and enhancements to Fortran 77, such as:
Free source code format with no column or line restrictions
Dynamic memory allocation and pointer data type
Array operations and intrinsic functions
Modules and interfaces for encapsulation and abstraction
Derived data types and user-defined operators
Recursion and generic subprograms
Select Case construct for multiple branching
Exit and Cycle statements for loop control
Comments starting with ! instead of C
Q: How can I convert my Fortran 77 code to Fortran 90?
A: There are several tools and programs that can help you convert your Fortran 77 code to Fortran 90 automatically or semi-automatically. Some of them are:
[F2C]: A program that converts Fortran 77 code to C code, which can then be compiled by a C compiler or converted to Fortran 90 by another tool.
[F90]: A program that converts Fortran 77 code to Fortran 90 code, with some manual intervention required for some features.
[FTNCHEK]: A program that checks the syntax and semantics of Fortran 77 code and suggests possible changes to make it compatible with Fortran 90.
[FORTRAN 77 to Fortran 90 Translator]: An online tool that converts Fortran 77 code to Fortran 90 code, with some options and limitations.
Q: How can I use Fortran 77 with other programming languages?
A: Fortran 77 can be used with other programming languages in various ways, such as:
Calling Fortran 77 subprograms from other languages, such as C, C++, Python, etc. This requires using the appropriate interface and naming conventions for the subprograms and the arguments.
Calling other languages' subprograms from Fortran 77, such as C, C++, Python, etc. This requires using the appropriate interface and naming conventions for the subprograms and the arguments.
Linking Fortran 77 object files with oth