Fortran is a programming language specially designed to perform numerical calculations, in order to fully exploit the arithmetic capabilities of all types of computers, from home PCs to supercomputers. Its name is an abbreviation: Formula Translating System, which refers to the niche to which the language is addressed: to scientists and engineers who require an easy-to-use but powerful language.
Historically, Fortran began as a language designed to be written on punch cards used by the IBM 704 mainframe computer. Today, this version of the language is known as FORTRAN I. Subsequent versions were released (II, III and IV), which added new features. The language was standardized in 1966 by the Association of Standards of the United States (American Standards Association).
For the year of 1978, the committee approved a new version of the language, FORTRAN 77, which improved the support for structured programming, in addition to adding new features. Among several versions of the language that existed (such as Minnesota FORTRAN), FORTRAN 77 became the most important, and it stayed that way for almost two decades. The constant development of programming practices led to the publication of a new standard: Fortran 90 (ANSI, 1992) with which the language implemented many novelties: for the first time it allowed the development of programs in free format, in addition to it allowed writing the keywords in lowercase, and the length of the identifiers could be up to 31 characters, among many other improvements.
On the other hand, Fortran 90 did not remove any FORTRAN 77 feature, in such a way that old code could be reused without any change; nevertheless, I mark some as obsolete, condemned to disappear in future versions. A few years later Fortran 95 (ISO / IEC 1539-1: 1997) emerged, which turned out to be a minor revision of the language, adding several extensions directed to the parallel computation according to Fortran’s specification for High Performance (HPF). Following its evolution, Fortran 2003 (ISO / IEC 1539-1: 2004), was published as a major revision of the language that added numerous characteristics: it introduced the support for Object-Oriented Programming: inheritance, polymorphism, and encapsulation, support was incorporated for floating-point arithmetic IEEE 754-2008 and for the handling of floating-point exceptions, and interoperability with the programming language C was implemented.
The most recent revision of the language, Fortran 2008 (ISO / IEC 1539-1: 2010), approved in 2010, is to Fortran 2008 what Fortran 95 to Fortran 90: a minor revision, It includes corrections and a few. Having been used for more than 50 years, and chosen as the de-facto language for scientific computing, there is an immense amount of code in Fortran, which is still used in the most intensive computations: simulations of the climate and weather, fluid dynamics, linear algebra, computational physics, etc. Some of the most optimized pieces of software for digital computing, such as the BLAS (Basic Linear Algebra Subroutines) libraries ATLAS and Netlib BLAS, as well as LAPACK, use Fortran substantially. This, in conjunction with the large base of existing code, the ease of learning the language, the high quality of both commercial and free compilers, to which the language has data structures widely superior to those of other comparable languages.
Note: this article is compiled to cover and explain in basic what's FORTRAN and it's basic use... So to make easy, it's divided into two series. Please find the link to the second face at the end of this part.
Starting with Fortran 90
Programming, regardless of the language, is more pleasant if the right tools are used. And what is meant by adequate tools? Are those made to fulfill a given task in the fastest, easiest and most comfortable way? To program with Fortran in this way you need only two tools: a good text editor and a compiler.
A program starts as a set of files with a series of instructions written in the plain text called source code. Compared to files with rich text that are used by certain software packages such as Microsoft Word or Libre Office, the text of the source code does not have any format: there are no titles, headers, bold text, etc. Within the code, however, there are portions of code that define the structure of the program, and others serve to define information: numbers, letters, and punctuation characters. Visualizing the structure of the source code is essential for scheduling, and for this, an editor that provides facilities to view it is required. The following is a non-exhaustive list of such facilities:
There are many very good text editors for all major operating systems: Linux, Windows, and MacOS. Not all are very good when it comes to Fortran since language is not very popular in non-scientific or engineering environments. Among the recommended editors are:
To this list, we can add other editors such as emacs or vim, just as capable as the previous ones but with a steeper learning curve. In the next phase, we talk about Integrated development environment (IDE), compilers and basic use of Fortran.
Note: This is the second part of learning Fortran (Introduction) please refer to the first part to know fully about the history of Fortran.
Integrated Development Environments (IDE)
There are programs that in addition to integrating the features of a text editor include capabilities to inspect the code, compile and link it, debugging tools, version control systems (VCS), even to document and transfer it from one development environment to another. production (deploy). This type of software is called an Integrated Development Environment, or IDE. The biggest drawbacks of these programs are their large size and high memory consumption, in addition to being slower than text editors.
The use of an IDE can be unnecessary in many cases, for example, when you have programs of a single file; In such cases, it is advisable to use a text editor.
The source code contains the body of the program with instructions that human beings can understand, however, the computer only understands the binary language, so we must translate the source code into code that the computer can understand. This process is called compilation and the programs that do it are called compilers. Specifically, compilation is the translation of instructions in one programming language to another set of instructions in another language, the result of which is equivalent. Some compilers translate to machine code that the computer understands directly, others translate to a type of intermediate code called bytecode, which is not executable by the computer directly but by another type of program called virtual machine, but which is independent of the computer in which it is generated, unlike the machine code that is unique for each type of computational architecture.
Fortran is a language for high-performance numerical applications that must be compiled into machine code to be executed. For this there is a wide variety of compilers, most of the commercial, some of which are listed below:
Basic use of gfortran
Let’s start writing our first program, for which we will take the following fragment of code, we will copy it and we will save it in a file called hello world f95:
program Main print * , "Hello World" end program Main
It is worth mentioning that this example is the Fortran version of the “Hello world” program, frequently used to present a new language to the user. It is a very simple program that all it does is write the text “Hello World” in the terminal and it closes immediately. To see it in action you have to compile it and then execute it. From a terminal in Linux and MacOS we proceed as follows:
~ gfortran helloworld . f95 ~ . / a . out
whereas in Windows we would proceed like this:
~ gfortran helloworld . f95 ~ . / a . out
The first command invokes the compiler, in this case, gfortran, and space is left between the compiler and the name of the file to be compiled. The result is an executable file named a.outin Linux / Mac and a.exein Windows. The second command executes said file, with the difference that in Linux the name of the executable is preceded by the characters ./. The character ~ in Linux and >in Windows indicate that we are in a terminal session since these characters are the ones shown in the terminals of both systems. However, here we will limit ourselves to the first form and assume that the default file name is a.out, although it is understood that Windows will be a.exe.
The result of executing these commands looks like this:
When you want to compile single-file programs, this is the simplest way to do it. It can be invoked gfortranin another way so that the executable program has a different name than :a.out/a.exe.
~ gfortran helloworld . f95 - or helloworld . out
In this case after the name of the file to be compiled space is left and it is written -o, another space is left and the name that we want the final executable program (helloworld.out) is written. Then to execute it we would write:
~ . / Helloworld . out
The text -o is an option that indicates that the text that follows is the name of the output executable file.
Fortran is what is called a high-level programming language, static type and whose code must be compiled into machine language before it can be used. It can be classified as a language that preferably follows the procedural programming paradigm. In the next phase of Fortran series, we will be talking about the basic concept. Stay tuned!!!
Most Read Articles
Translate Our Site
Notice : Please be careful, after translation commands will change.
This website uses marketing and tracking technologies. Opting out of this will opt you out of all cookies, except for those needed to run the website. Note that some products may not work as well without tracking cookies.Opt Out of Cookies