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. Fortran 2008 introduced coarrays for SPMD parallel 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 2023, 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

12868 questions
458
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
  • 11,175
  • 8
  • 32
  • 41
164
votes
8 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
  • 13,996
  • 19
  • 70
  • 94
146
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,971
  • 5
  • 29
  • 36
84
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,222
  • 3
  • 17
  • 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,456
  • 3
  • 31
  • 25
66
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
  • 1,107
  • 2
  • 11
  • 7
63
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,869
  • 6
  • 56
  • 81
61
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
  • 10,677
  • 21
  • 72
  • 135
61
votes
6 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
  • 2,158
  • 4
  • 26
  • 34
58
votes
10 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
  • 298,606
  • 55
  • 578
  • 516
56
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,313
  • 6
  • 37
  • 46
56
votes
5 answers

Fortran vs C++, does Fortran still hold any advantage in numerical analysis these days?

With the rapid development of C++ compilers,especially the intel ones, and the abilities of directly applying SIMD functions in your C/C++ code, does Fortran still hold any real advantage in the world of numerical computations? I am from an applied…
user0002128
  • 2,785
  • 2
  • 23
  • 40
55
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
  • 27,279
  • 27
  • 74
  • 92
54
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,456
  • 3
  • 31
  • 25
53
votes
6 answers

Fortran 90 kind parameter

I am having trouble understanding Fortran 90's kind parameter. As far as I can tell, it does not determine the precision (i.e., float or double) of a variable, nor does it determine the type of a variable. So, what does it determine and what…
Lana
1
2 3
99 100