Questions tagged [fortran]

Fortran is a general-purpose, procedural, imperative programming language that is especially suited for numeric computation and scientific computing. Since 2003, standard Fortran also supports object-oriented programming. This tag should be applied to all questions about the Fortran language; other specific tags can be added for compilers, language revisions and particular aspects of use.

Fortran is a general-purpose, procedural, imperative programming language that is especially used for numeric computation and scientific computing.

It has a long history and is still evolving: the first language proposal was put together by J. W. Backus in 1953, the first international standard was approved in 1966, and the latest major standard revision (with new features), Fortran 2018, was published in 2018. The next revision, Fortran 202X (previously known as Fortran 2020), is under development.

Fortran is widely used in the scientific computing community and accounts for an important part of numerical codes run in supercomputing facilities.

Hello world in Fortran

program hello
  print *, 'Hello, world!'
end program

Related tags

Language feature tags:

Compiler tags:

There are also language revision tags: , , , and . These tags are rarely necessary as there is limited incompatibility introduced in succeeding revisions and context should make language feature support clear.

Useful Links

Standard Documents

Books

11531 questions
423
votes
23 answers

Is Fortran easier to optimize than C for heavy calculations?

From time to time I read that Fortran is or can be faster then C for heavy calculations. Is that really true? I must admit that I hardly know Fortran, but the Fortran code I have seen so far did not show that the language has features that C doesn't…
quinmars
  • 10,419
  • 6
  • 30
  • 39
123
votes
6 answers

Reading a binary file with python

I find particularly difficult reading binary file with Python. Can you give me a hand? I need to read this file, which in Fortran 90 is easily read by int*4 n_particles, n_groups real*4 group_id(n_particles) read (*) n_particles, n_groups read (*)…
Brian
  • 10,312
  • 14
  • 55
  • 85
119
votes
8 answers

How does BLAS get such extreme performance?

Out of curiosity I decided to benchmark my own matrix multiplication function versus the BLAS implementation... I was to say the least surprised at the result: Custom Implementation, 10 trials of 1000x1000 matrix multiplication: Took: 15.76542…
DeusAduro
  • 5,541
  • 4
  • 26
  • 35
82
votes
2 answers

How can numpy be so much faster than my Fortran routine?

I get a 512^3 array representing a Temperature distribution from a simulation (written in Fortran). The array is stored in a binary file that's about 1/2G in size. I need to know the minimum, maximum and mean of this array and as I will soon need to…
user35915
  • 1,062
  • 3
  • 15
  • 23
80
votes
10 answers

Learning FORTRAN In the Modern Era

I've recently come to maintain a large amount of scientific calculation-intensive FORTRAN code. I'm having difficulties getting a handle on all of the, say, nuances, of a forty year old language, despite google & two introductory level books. The…
David J. Sokol
  • 3,356
  • 3
  • 28
  • 25
65
votes
7 answers

Writing robust and "modern" Fortran code

In some scientific environments, you often cannot go without FORTRAN as most of the developers only know that idiom, and there is lot of legacy code and related experience. And frankly, there are not many other cross-platform options for high…
Blklight
  • 1,593
  • 1
  • 13
  • 14
59
votes
5 answers

Why is fortran used for scientific computing?

I've read that Fortran is still heavily used for scientific computing. For code already heavily invested in Fortran this makes sense to me. But is there a reason to use Fortran over other modern languages for a new project? Are there language design…
user782220
  • 9,199
  • 16
  • 64
  • 127
59
votes
6 answers

Why define PI = 4*ATAN(1.d0)

What is the motivation for defining PI as PI=4.D0*DATAN(1.D0) within Fortran 77 code? I understand how it works, but, what is the reasoning?
ccook
  • 5,682
  • 5
  • 51
  • 81
57
votes
3 answers

Fortran: integer*4 vs integer(4) vs integer(kind=4)

I'm trying to learn Fortran and I'm seeing a lot of different definitions being passed around and I'm wondering if they're trying to accomplish the same thing. What is the difference between the following? integer*4 integer(4) integer(kind=4)
Sam
  • 927
  • 2
  • 10
  • 7
52
votes
7 answers

Best Fortran IDE

Is there anybody using Fortran on stackoverflow? What IDE do you use and which one do you think to be the best? Seems lots of people surround me are quite inconvenient with Intel Visual Fortran. Because there is no support for intellisense,…
Roy
  • 2,253
  • 6
  • 35
  • 46
52
votes
1 answer

Packaging legacy Fortran in Python. Is it OK to use setuptools and numpy.distutils?

I am trying to make a python package distribution for some popular Fortran codes in my field. I want it to use the most standard approach with a setup.py file. The related qustion was helpful for learning how to wrap Fortran extensions. When using…
Will Martin
  • 933
  • 6
  • 17
52
votes
9 answers

Convert integers to strings to create output filenames at run time

I have a program in Fortran that saves the results to a file. At the moment I open the file using OPEN (1, FILE = 'Output.TXT') However, I now want to run a loop, and save the results of each iteration to the files 'Output1.TXT', 'Output2.TXT',…
Alasdair
  • 253,590
  • 43
  • 477
  • 449
51
votes
3 answers

Calling 32bit Code from 64bit Process

I have an application that we're trying to migrate to 64bit from 32bit. It's .NET, compiled using the x64 flags. However, we have a large number of DLLs written in FORTRAN 90 compiled for 32bit. The functions in the FORTRAN DLLs are fairly…
David J. Sokol
  • 3,356
  • 3
  • 28
  • 25
49
votes
5 answers

Still can't install scipy due to missing fortran compiler after brew install gcc on Mac OS X

I have read and followed this answer to install scipy/numpy/theano. However, it still failed on the same error of missing Fortran compiler after brew install gcc. While HomeBrew installed the gcc-4.8, it didn't install any gfortran or g95 commands.…
teddy
  • 1,940
  • 3
  • 20
  • 33
48
votes
3 answers

Purpose of LDA argument in BLAS dgemm?

The Fortran reference implementation documentation states: * LDA - INTEGER. * On entry, LDA specifies the first dimension of A as declared * in the calling (sub) program. When TRANSA = 'N' or 'n' then * LDA must be…
Setjmp
  • 23,834
  • 23
  • 67
  • 90
1
2 3
99 100