Questions tagged [fortran90]

USE TOGETHER WITH THE fortran TAG. Fortran 90, the standardized successor to FORTRAN 77, released as an ISO standard in 1991 and an ANSI Standard in 1992. Questions using this tag should be specific to the language defined as Fortran 90 rather than being general Fortran questions.

This major revision of

Please note all version specific fortran questions should also use the generic tag

Fortran90 added many new features to its predecessor :

  • Free-form source input, also with lowercase Fortran keywords
  • Identifiers up to 31 characters in length
  • Inline comments
  • Ability to operate on arrays (or array sections) as a whole, thus greatly simplifying math and engineering computations.
  • RECURSIVE procedures
  • Modules, to group related procedures and data together, and make them available to other program units, including the capability to limit the accessibility to only specific parts of the module.
  • A vastly improved argument-passing mechanism, allowing interfaces to be checked at compile time
  • User-written interfaces for generic procedures
  • Operator overloading
  • Derived/abstract data types
  • New data type declaration syntax, to specify the data type and other attributes of variables
  • Dynamic memory allocation by means of the ALLOCATABLE attribute and the ALLOCATE and DEALLOCATE statements
  • POINTER attribute, pointer assignment, and NULLIFY statement to facilitate the creation and manipulation of dynamic data structures
  • Structured looping constructs, with an END DO statement for loop termination, and EXIT and CYCLE statements for "breaking out" of normal DO loop iterations in an orderly way
  • SELECT . . . CASE construct for multi-way selection
  • Portable specification of numerical precision under the user's control
  • New and enhanced intrinsic procedures.

The introduction of free-form source led to many compilers using the f90 file suffix to distinguish between free-form and fixed-form source. This was perhaps a poor choice of suffix as free-form source is the preferred form in all later revisions of the language. Seeing a f90 suffix does not indicate that the code contained within conforms to, or only to, the Fortran 90 standard.

Fortran 90 was itself revised to form Fortran 95 which is widely implemented. Most newly written Fortran code is not strictly Fortran 90: questioners thinking of using this tag should consider the more generic .

1581 questions
51
votes
3 answers

Fortran SAVE statement

I've read about the save statement in the (Intel's) language reference document, but I cannot quite grasp what it does. Could someone explain to me in simple language what it means when the save statement is included in a module ?
Friedrich Schwartz
  • 653
  • 1
  • 5
  • 6
46
votes
2 answers

What flags do you set for your GFORTRAN debugger/compiler to catch faulty code?

I think I won't find that in any textbook, because answering this takes experience. I am currently in the stage of testing/validating my code / hunting bugs to get it into production state and any errors would lead to many people suffering e.g. the…
tarrasch
  • 2,630
  • 8
  • 37
  • 61
41
votes
3 answers

How to initialize two-dimensional arrays in Fortran

In C you can easily initialize an array using the curly braces syntax, if I remember correctly: int* a = new int[] { 1, 2, 3, 4 }; How can you do the same in Fortran for two-dimensional arrays when you wish to initialize a matrix with specific test…
Fludlu McBorry
  • 413
  • 1
  • 4
  • 4
41
votes
7 answers

How do you USE Fortran 90 module data

Let's say you have a Fortran 90 module containing lots of variables, functions and subroutines. In your USE statement, which convention do you follow: explicitly declare which variables/functions/subroutines you're using with the , only : syntax,…
Pete
  • 10,310
  • 7
  • 53
  • 59
39
votes
4 answers

Fortran intent(inout) versus omitting intent

Good practice dictates that subroutine arguments in Fortran should each have a specified intent (i.e. intent(in), intent(out) or intent(inout) as described this question): subroutine bar (a, b) real, intent(in) :: a real, intent(inout) :: b …
Andrew Walker
  • 2,451
  • 2
  • 18
  • 15
38
votes
1 answer

Arrays of pointers

I am trying to implement an array of pointers, so that I can loop over the elements. However I am not sure how to do this correctly: TYPE(domain),POINTER :: d01,d02,d03 TYPE(domain),DIMENSION(:),POINTER :: dom ... dom(1) => d01 dom(2)…
milancurcic
  • 6,202
  • 2
  • 34
  • 47
37
votes
1 answer

How to check if Fortran array contains value?

I've seen this asked for other languages, but having just found out how nicely Fortran can handle arrays, I thought there might be an easy way to do this without loops. Currently I'm searching over a 3D array looking at 'nearest neighbours' to see…
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
37
votes
4 answers

Where to put `implicit none` in Fortran

Do I need to put implicit none inside every function and subroutine? Or is it enough to put it at the beginning of the module containing these functions and subroutines? Or is it enough to put it at the beginning of the program that is using these…
Fabricator
  • 12,722
  • 2
  • 27
  • 40
37
votes
3 answers

What does "real*8" mean?

The manual of a program written in Fortran 90 says, "All real variables and parameters are specified in 64-bit precision (i.e. real*8)." According to Wikipedia, single precision corresponds to 32-bit precision, whereas double precision corresponds…
Andrew
  • 1,499
  • 9
  • 25
  • 37
34
votes
4 answers

Standard input and output units in Fortran 90?

How can I read and write to the standard input, output and error streams stdin, stdout and stderr in Fortran? I've heard writing to stderr, for example, used to be write(5, fmt=...), with 5 the unit for stderr, and I know the way to write to stdout…
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
34
votes
2 answers

Assumed size arrays: Colon vs. asterisk - DIMENSION(:) arr vs. arr(*)

Is there any difference between these two methods of declaring an assumed-size array? e.g. real, dimension(:) :: arr and real :: arr(*)
DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119
28
votes
3 answers

Correct use of modules, subroutines and functions in Fortran

I've recently learnt about interface blocks when adding a function to my Fortran program. Everything works nice and neatly, but now I want to add a second function into the interface block. Here is my interface block: interface function…
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
27
votes
1 answer

Can not install gfortran via homebrew

I got this message when i tried to install gfortran. ~$ brew install gfortran Error: No available formula for gfortran GNU Fortran is now provided as part of GCC, and can be installed with: brew install gcc My question is how to install gfortran…
fronthem
  • 4,011
  • 8
  • 34
  • 55
27
votes
3 answers

How to get proper text-color-highlighting for Fortran 90 in Sublime Text 2?

There are a couple of links on sublime forum, on how to get Sublime Text 2 to work with Fortran 90 here http://www.sublimetext.com/forum/viewtopic.php?f=4&t=770, but they don't quite seem to work as the comment identifier "!" is not treated well. I…
Timur B
  • 323
  • 2
  • 4
  • 8
26
votes
2 answers

Proper use of the PURE keyword Fortran

I'm currently delving into Fortran and I've come across the pure keyword specifying functions/subroutines that have no side effects. I have a book, Fortran 90/95 by S Chapman which introduces the pure keyword but strangely provides no "good coding…
River
  • 8,585
  • 14
  • 54
  • 67
1
2 3
99 100