Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Fortran
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Evolution== {| class="wikitable floatright" style="margin-left: 1.5em;" |+Timeline of Fortran language |- ! Year ! Informal name ! Official Standard |- | 1957 | FORTRAN | {{n/a}} |- | 1958 | FORTRAN II | {{n/a}} |- | 1958 | FORTRAN III | {{n/a}} |- | 1961 | FORTRAN IV | {{n/a}} |- | 1966 | FORTRAN 66 | ANSI X3.9-1966 |- | 1978 | FORTRAN 77 | ANSI X3.9-1978 |- | 1991 | Fortran 90 | ANSI X3.198-1992<br />ISO/IEC 1539:1991 |- | 1997 | Fortran 95 | ISO/IEC 1539-1:1997 |- | 2004 | Fortran 2003 | ISO/IEC 1539-1:2004 |- | 2010 | Fortran 2008 | ISO/IEC 1539-1:2010 |- | 2018 | Fortran 2018 | ISO/IEC 1539-1:2018 |- | 2023 | Fortran 2023 | ISO/IEC 1539-1:2023 |} ===FORTRAN II=== IBM's ''FORTRAN II'' appeared in 1958. The main enhancement was to support [[procedural programming]] by allowing user-written subroutines and functions which returned values with parameters passed by [[Call by reference#Call by reference|reference]]. The COMMON statement provided a way for subroutines to access common (or [[global variable|global]]) variables. Six new statements were introduced:<ref>{{cite manual|url=http://bitsavers.org/pdf/ibm/704/C28-6000-2_704_FORTRANII.pdf |archive-url=https://web.archive.org/web/20051030200524/http://www.bitsavers.org/pdf/ibm/704/C28-6000-2_704_FORTRANII.pdf |archive-date=October 30, 2005 |url-status=live|title=Reference Manual, FORTRAN II for the IBM 704 Data Processing System|year=1958|id=C28-6000-2}}</ref> * {{code|SUBROUTINE}}, {{code|FUNCTION}}, and {{code|END}} * {{code|CALL}} and {{code|RETURN}} * {{code|COMMON}} Over the next few years, FORTRAN II added support for the {{code|DOUBLE PRECISION}} and {{code|COMPLEX}} data types. Early FORTRAN compilers supported no [[Recursion (computer science)|recursion]] in subroutines. Early computer architectures supported no concept of a stack, and when they did directly support subroutine calls, the return location was often stored in one fixed location adjacent to the subroutine code (e.g. the [[IBM 1130]]) or a specific machine register ([[IBM 360]] ''et seq''), which only allows recursion if a stack is maintained by software and the return address is stored on the stack before the call is made and restored after the call returns. Although not specified in FORTRAN 77, many F77 compilers supported recursion as an option, and the [[Burroughs large systems|Burroughs mainframes]], designed with recursion built-in, did so by default. It became a standard in Fortran 90 via the new keyword RECURSIVE.<ref>{{cite web |url= http://www.ibiblio.org/pub/languages/fortran/ch1-12.html |title=Recursion |work=User Notes on FORTRAN Programming (UNFP) |access-date=September 15, 2014}}</ref> ====Simple FORTRAN II program==== This program, for [[Heron's formula]], reads data on a tape reel containing three 5-digit integers A, B, and C as input. There are no "type" declarations available: variables whose name starts with I, J, K, L, M, or N are "fixed-point" (i.e. integers), otherwise floating-point. Since integers are to be processed in this example, the names of the variables start with the letter "I". The name of a variable must start with a letter and can continue with both letters and digits, up to a limit of six characters in FORTRAN II. If A, B, and C cannot represent the sides of a triangle in plane geometry, then the program's execution will end with an error code of "STOP 1". Otherwise, an output line will be printed showing the input values for A, B, and C, followed by the computed AREA of the triangle as a floating-point number occupying ten spaces along the line of output and showing 2 digits after the decimal point, the .2 in F10.2 of the FORMAT statement with label 601. <syntaxhighlight lang="fortranfixed"> C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION C INPUT - TAPE READER UNIT 5, INTEGER INPUT C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING READ INPUT TAPE 5, 501, IA, IB, IC 501 FORMAT (3I5) C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO IF (IA) 777, 777, 701 701 IF (IB) 777, 777, 702 702 IF (IC) 777, 777, 703 703 IF (IA+IB-IC) 777, 777, 704 704 IF (IA+IC-IB) 777, 777, 705 705 IF (IB+IC-IA) 777, 777, 799 777 STOP 1 C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE 799 S = FLOATF (IA + IB + IC) / 2.0 AREA = SQRTF( S * (S - FLOATF(IA)) * (S - FLOATF(IB)) * + (S - FLOATF(IC))) WRITE OUTPUT TAPE 6, 601, IA, IB, IC, AREA 601 FORMAT (4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2, + 13H SQUARE UNITS) STOP END </syntaxhighlight> ===FORTRAN III=== IBM also developed a ''FORTRAN III'' in 1958 that allowed for [[inline assembler|inline assembly]] code among other features; however, this version was never released as a product. Like the 704 FORTRAN and FORTRAN II, FORTRAN III included machine-dependent features that made code written in it unportable from machine to machine, as well as Boolean expression support.<ref name="history-fortran-i-ii-333"/>{{rp|76}} Early versions of FORTRAN provided by other vendors suffered from the same disadvantage. ===FORTRAN IV=== IBM began development of '''FORTRAN IV''' in 1961 as a result of customer demands. FORTRAN IV removed the machine-dependent features of FORTRAN II (such as {{code|READ INPUT TAPE}}), while adding new features such as a [[Boolean data type|{{code|LOGICAL}} data type]], logical [[Boolean expression]]s, and the ''logical IF statement'' as an alternative to the ''arithmetic IF statement.'' Type declarations were added, along with an {{code|IMPLICIT}} statement to override earlier conventions that variables are {{code|INTEGER}} if their name begins with {{code|I}}, {{code|J}}, {{code|K}}, {{code|L}}, {{code|M}}, or {{code|N}}; and {{code|REAL}} otherwise.<ref name=s360fortran4>{{cite manual|title=IBM System/360 FORTRAN IV Language, Form C28-6515-6|url=http://www.bitsavers.org/pdf/ibm/360/fortran/C28-6515-6_FORTRAN_IV_Language_1966.pdf|publisher=IBM|date=April 1966}}</ref>{{rp|pp.70,71}}<ref name=":0" />{{rp|p.6-9}} FORTRAN IV was eventually released in 1962, first for the [[IBM 7030 Stretch|IBM 7030]] ("Stretch") computer, followed by versions for the [[IBM 7090]], [[IBM 7090|IBM 7094]], and later for the [[IBM 1401]] in 1966.<ref>{{cite manual|title=Fortran IV Language Specifications, Program Specifications, and Operating Procedures, IBM 1401, 1440, and 1460|url=http://bitsavers.org/pdf/ibm/1401/C24-3322-2_Fortran_IV_Language_Specifications_IBM_1401_1440_1460_Apr66.pdf |archive-url=https://web.archive.org/web/20170923222805/http://www.bitsavers.org/pdf/ibm/1401/C24-3322-2_Fortran_IV_Language_Specifications_IBM_1401_1440_1460_Apr66.pdf |archive-date=September 23, 2017 |url-status=live|date=April 1966|publisher=IBM|id=C24-3322-2}}</ref> By 1965, FORTRAN IV was supposed to be compliant with the ''standard'' being developed by the [[American National Standards Institute|American Standards Association]] X3.4.3 FORTRAN Working Group.<ref name="McCracken">{{cite book|last=McCracken|first=Daniel D.|title=A Guide to FORTRAN IV Programming|chapter-url=https://archive.org/details/guidetofortraniv00mccr|chapter-url-access=registration|year=1965|publisher=Wiley|location=New York|isbn=978-0-471-58281-6|page=v|chapter=Preface}}</ref> Between 1966 and 1968, IBM offered several FORTRAN IV compilers for its [[IBM System/360|System/360]], each named by letters that indicated the minimum amount of memory the compiler needed to run. <ref>{{cite web | url = http://www.fortran.bcs.org/2007/jubilee/implementations.php |website= BCS Fortran Specialist Group | title = List of FORTRAN Implementations 1957 – 1967 | publisher = IEEE Annals | year = 2017 | access-date = October 17, 2017 }}</ref> The letters (F, G, H) matched the codes used with System/360 model numbers to indicate memory size, each letter increment being a factor of two larger:<ref>{{cite manual|url=http://www.bitsavers.org/pdf/ibm/360/functional_characteristics/A22-6898-1_360-50_funcChar_1967.pdf |via=bitsavers |archive-url=https://web.archive.org/web/20211029211006/http://bitsavers.org/pdf/ibm/360/functional_characteristics/A22-6898-1_360-50_funcChar_1967.pdf |archive-date=October 29, 2021 |url-status=live|title=IBM System/360 Model 50 Functional Characteristics|publisher=IBM|year=1967|id=A22-6898-1}}</ref>{{rp|p. 5}} * 1966 : FORTRAN IV F for DOS/360 (64K bytes) * 1966 : FORTRAN IV G for OS/360 (128K bytes) * 1968 : FORTRAN IV H for OS/360 (256K bytes) [[Digital Equipment Corporation]] maintained DECSYSTEM-10 Fortran IV (F40) for [[PDP-10]] from 1967 to 1975.<ref name=":0">{{cite web |title=DECSYSTEM-10 FORTRAN IV (F40) Programmers Reference Manual |url=https://github.com/PDP-10/f40/blob/master/doc/DEC-10-LFLMA-B-D%20FORTRAN%20IV%20(F40)%20Programmer's%20Reference%20Manual.pdf |website=Github |publisher=Digital Equipment Corporation |access-date=April 15, 2022}}</ref> Compilers were also available for the [[UNIVAC 1100/2200 series|UNIVAC 1100 series]] and the [[Control Data Corporation|Control Data]] [[CDC 6000 series|6000 series]] and [[CDC 7600|7000 series]] systems.<ref name=":1">{{Cite web |title=FORTRAN IV |url=https://search.worldcat.org/title/20673993 |access-date=2023-12-10 |website=WorldCat.org |language=en}}</ref> At about this time FORTRAN IV had started to become an important educational tool and implementations such as the University of Waterloo's WATFOR and [[WATFIV]] were created to simplify the complex compile and link processes of earlier compilers. In the FORTRAN IV programming environment of the era, except for that used on Control Data Corporation (CDC) systems, only one instruction was placed per line. The CDC version allowed for multiple instructions per line if separated by a {{char|$}} (dollar) character. The FORTRAN [[Punched card|sheet]] was divided into four fields, as described above. Two compilers of the time, IBM "G" and UNIVAC, allowed comments to be written on the same line as instructions, separated by a special character: "master space": V (perforations 7 and 8) for UNIVAC and perforations 12/11/0/7/8/9 (hexadecimal FF) for IBM. These comments were not to be inserted in the middle of continuation cards.<ref name=":0" /><ref name=":1" /> ===FORTRAN 66=== Perhaps the most significant development in the early history of FORTRAN was the decision by the ''American Standards Association'' (now [[American National Standards Institute]] (ANSI)) to form a committee sponsored by the [[Business Equipment Manufacturers Association]] (BEMA) to develop an ''American Standard Fortran''. The resulting two standards, approved in March 1966, defined two languages, ''FORTRAN'' (based on FORTRAN IV, which had served as a de facto standard), and ''Basic FORTRAN'' (based on FORTRAN II, but stripped of its machine-dependent features). The FORTRAN defined by the first standard, officially denoted X3.9-1966, became known as ''FORTRAN 66'' (although many continued to term it FORTRAN IV, the language on which the standard was largely based). FORTRAN 66 effectively became the first industry-standard version of FORTRAN. FORTRAN 66 included: * Main program, {{code|SUBROUTINE}}, {{code|FUNCTION}}, and {{code|BLOCK DATA}} program units * {{code|INTEGER}}, {{code|REAL}}, {{code|DOUBLE PRECISION}}, {{code|COMPLEX}}, and {{code|LOGICAL}} [[data type]]s * {{code|COMMON}}, {{code|DIMENSION}}, and {{code|EQUIVALENCE}} statements * {{code|DATA}} statement for specifying initial values * [[Intrinsic function|Intrinsic]] and {{code|EXTERNAL}} (e.g., library) functions * Assignment statement * {{code|GO TO}}, computed {{code|GO TO}}, assigned {{code|GO TO}}, and {{code|ASSIGN}} statements * Logical {{code|IF}} and arithmetic (three-way) {{code|IF}} statements * {{code|DO}} loop statement * {{code|READ}}, {{code|WRITE}}, {{code|BACKSPACE}}, {{code|REWIND}}, and {{code|ENDFILE}} statements for sequential I/O * {{code|FORMAT}} statement and assigned format * {{code|CALL}}, {{code|RETURN}}, {{code|PAUSE}}, and {{code|STOP}} statements * [[Hollerith constant]]s in {{code|DATA}} and {{code|FORMAT}} statements, and as arguments to procedures * Identifiers of up to six characters in length * Comment lines * {{code|END}} line The above Fortran II version of the Heron program needs several modifications to compile as a Fortran 66 program. Modifications include using the more machine independent versions of the {{code|READ}} and {{code|WRITE}} statements, and removal of the unneeded {{code|FLOATF}} type conversion functions. Though not required, the arithmetic {{code|IF}} statements can be re-written to use logical {{code|IF}} statements and expressions in a more structured fashion. <syntaxhighlight lang="fortranfixed"> C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION C INPUT - TAPE READER UNIT 5, INTEGER INPUT C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING READ (5, 501) IA, IB, IC 501 FORMAT (3I5) C C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO IF (IA .GT. 0 .AND. IB .GT. 0 .AND. IC .GT. 0) GOTO 10 WRITE (6, 602) 602 FORMAT (42H IA, IB, AND IC MUST BE GREATER THAN ZERO.) STOP 1 10 CONTINUE C IF (IA+IB-IC .GT. 0 + .AND. IA+IC-IB .GT. 0 + .AND. IB+IC-IA .GT. 0) GOTO 20 WRITE (6, 603) 603 FORMAT (50H SUM OF TWO SIDES MUST BE GREATER THAN THIRD SIDE.) STOP 1 20 CONTINUE C C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE S = (IA + IB + IC) / 2.0 AREA = SQRT ( S * (S - IA) * (S - IB) * (S - IC)) WRITE (6, 601) IA, IB, IC, AREA 601 FORMAT (4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2, + 13H SQUARE UNITS) STOP END </syntaxhighlight> ===FORTRAN 77=== [[File:Ftn-elim-1240x1709.jpg|thumb|upright|FORTRAN-77 program with compiler output, written on a [[Control Data Corporation|CDC]] [[CDC Cyber|175]] at [[RWTH Aachen University]], Germany, in 1987]] [[File:4.3 BSD UWisc VAX Emulation f77 Manual.png|thumb|[[4.3BSD|4.3 BSD]] for the [[Digital Equipment Corporation]] (DEC) [[VAX]], displaying the [[man page|manual]] for FORTRAN 77 (f77) compiler]] After the release of the FORTRAN 66 standard, compiler vendors introduced several extensions to ''Standard Fortran'', prompting ANSI committee X3J3 in 1969 to begin work on revising the 1966 standard, under sponsorship of [[CBEMA]], the Computer Business Equipment Manufacturers Association (formerly BEMA). Final drafts of this revised standard circulated in 1977, leading to formal approval of the new FORTRAN standard in April 1978. The new standard, called ''FORTRAN 77'' and officially denoted X3.9-1978, added a number of significant features to address many of the shortcomings of FORTRAN 66: * Block {{code|IF}} and {{code|END IF}} statements, with optional {{code|ELSE IF}} and {{code|ELSE}} clauses, to provide improved language support for [[structured programming]] * {{code|DO}} loop extensions, including parameter expressions, negative increments, and zero trip counts * {{code|OPEN}}, {{code|CLOSE}}, and {{code|INQUIRE}} statements for improved I/O capability * Direct-access file I/O * {{code|CHARACTER}} data type, replacing Hollerith strings with vastly expanded facilities for character input and output and processing of character-based data * {{code|PARAMETER}} statement for specifying constants * {{code|SAVE}} statement for persistent local variables * Generic names for intrinsic functions (e.g. {{code|SQRT}} also accepts arguments of other types, such as {{code|COMPLEX}} or {{code|REAL*16}}). * A set of intrinsics ({{code|LGE}}, {{code|LGT}}, {{code|LLE}}, {{code|LLT}}) for ''lexical'' comparison of strings, based upon the [[ASCII]] [[collating sequence]]. (These ASCII functions were demanded by the [[United States Department of Defense|U.S. Department of Defense]], in their conditional approval vote.{{Citation needed|date=October 2011}}) * A maximum of seven dimensions in arrays, rather than three. Allowed subscript expressions were also generalized. In this revision of the standard, a number of features were removed or altered in a manner that might invalidate formerly standard-conforming programs. (Removal was the only allowable alternative to X3J3 at that time, since the concept of "[[deprecation]]" was not yet available for ANSI standards.) While most of the 24 items in the conflict list (see Appendix A2 of X3.9-1978) addressed loopholes or pathological cases permitted by the prior standard but rarely used, a small number of specific capabilities were deliberately removed, such as: * [[Hollerith constant]]s and [[Herman Hollerith|Hollerith]] data, such as <syntaxhighlight lang="fortran" inline> GREET = 12HHELLO THERE!</syntaxhighlight> * Reading into an H edit (Hollerith field) descriptor in a FORMAT specification * Overindexing of array bounds by subscripts <syntaxhighlight lang="fortranfixed"> DIMENSION A(10,5) Y = A(11,1) </syntaxhighlight> * Transfer of control out of and back into the range of a DO loop (also known as "Extended Range") A Fortran 77 version of the Heron program requires no modifications to the Fortran 66 version. However this example demonstrates additional cleanup of the I/O statements, including using list-directed I/O, and replacing the Hollerith edit descriptors in the {{code|FORMAT}} statements with quoted strings. It also uses structured {{code|IF}} and {{code|END IF}} statements, rather than {{code|GOTO}}/{{code|CONTINUE}}. <syntaxhighlight lang="fortranfixed"> PROGRAM HERON C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION C INPUT - DEFAULT STANDARD INPUT UNIT, INTEGER INPUT C OUTPUT - DEFAULT STANDARD OUTPUT UNIT, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING READ (*, *) IA, IB, IC C C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO IF (IA .LE. 0 .OR. IB .LE. 0 .OR. IC .LE. 0) THEN WRITE (*, *) 'IA, IB, and IC must be greater than zero.' STOP 1 END IF C IF (IA+IB-IC .LE. 0 + .OR. IA+IC-IB .LE. 0 + .OR. IB+IC-IA .LE. 0) THEN WRITE (*, *) 'Sum of two sides must be greater than third side.' STOP 1 END IF C C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE S = (IA + IB + IC) / 2.0 AREA = SQRT ( S * (S - IA) * (S - IB) * (S - IC)) WRITE (*, 601) IA, IB, IC, AREA 601 FORMAT ('A= ', I5, ' B= ', I5, ' C= ', I5, ' AREA= ', F10.2, + ' square units') STOP END</syntaxhighlight> ===Transition to ANSI Standard Fortran=== The development of a revised standard to succeed FORTRAN 77 would be repeatedly delayed as the standardization process struggled to keep up with rapid changes in computing and programming practice. In the meantime, as the "Standard FORTRAN" for nearly fifteen years, FORTRAN 77 would become the historically most important dialect. An important practical extension to FORTRAN 77 was the release of MIL-STD-1753 in 1978.<ref>{{cite book | title = MIL-STD 1753 - FORTRAN, DoD Supplement To American National Standard X3.9-1978 |date=November 9, 1978 | publisher = [[United States Government Printing Office]] | url = https://wg5-fortran.org/ARCHIVE/mil_std_1753.html | access-date = April 21, 2024 }}</ref> This specification, developed by the [[United States Department of Defense|U.S. Department of Defense]], standardized a number of features implemented by most FORTRAN 77 compilers but not included in the ANSI FORTRAN 77 standard. These features would eventually be incorporated into the Fortran 90 standard. * {{code|DO WHILE}} and {{code|END DO}} statements * {{code|INCLUDE}} statement * {{code|IMPLICIT NONE}} variant of the {{code|IMPLICIT}} statement * [[Bit manipulation]] intrinsic functions, based on similar functions included in [[Industrial Real-Time Fortran|Industrial Real-Time Fortran (ANSI/ISA S61.1 (1976))]] The [[Institute of Electrical and Electronics Engineers|IEEE]] 1003.9 [[POSIX]] Standard, released in 1991, provided a simple means for FORTRAN 77 programmers to issue POSIX system calls.<ref>{{cite book |title = IEEE 1003.9-1992 – IEEE Standard for InformationTechnology – POSIX(R) FORTRAN 77 Language Interfaces – Part 1: Binding for System Application Program Interface (API) |url = https://standards.ieee.org/ieee/1003.9/1440/ |publisher = [[IEEE]] |access-date = November 24, 2018 }}</ref> Over 100 calls were defined in the document{{snd}} allowing access to POSIX-compatible process control, signal handling, file system control, device control, procedure pointing, and stream I/O in a portable manner. ===Fortran 90=== The much-delayed successor to FORTRAN 77, informally known as ''Fortran 90'' (and prior to that, ''Fortran 8X''), was finally released as ISO/IEC standard 1539:1991 in 1991 and an ANSI Standard in 1992. In addition to changing the official spelling from FORTRAN to Fortran, this major revision added many new features to reflect the significant changes in programming practice that had evolved since the 1978 standard: * [[free-form language|Free-form source input]] removed the need to skip the first six character positions before entering statements. * Lowercase Fortran keywords * Identifiers up to 31 characters in length (In the previous standard, it was only six characters). * Inline comments * Ability to operate on arrays (or array sections) as a whole, thus greatly simplifying math and engineering computations. ** whole, partial and masked array assignment statements and array expressions, such as <syntaxhighlight lang="fortran" inline>X(1:N)=R(1:N)*COS(A(1:N))</syntaxhighlight> ** {{code|WHERE}} statement for selective array assignment ** array-valued constants and expressions, ** user-defined array-valued functions and array constructors. * [[recursion (computer science)|{{code|RECURSIVE}}]] procedures * [[Modular programming|Modules]], to group related [[Subroutine|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 [[type signature|interfaces]] to be checked at compile time * User-written interfaces for generic procedures * [[Operator overloading]] * Derived (structured) data types * New data type declaration syntax, to specify the data type and other attributes of variables * [[Dynamic memory allocation]] by means of the {{code|ALLOCATABLE}} attribute and the {{code|ALLOCATE}} and {{code|DEALLOCATE}} statements * [[Pointer (computer programming)|{{code|POINTER}}]] attribute, pointer assignment, and {{code|NULLIFY}} statement to facilitate the creation and manipulation of dynamic [[data structure]]s * Structured looping constructs, with an {{code|END DO}} statement for loop termination, and {{code|EXIT}} and {{code|CYCLE}} statements for terminating normal {{code|DO}} loop iterations in an orderly way * {{code|SELECT CASE}}, {{code|CASE}}, . . . {{code|CASE DEFAULT}}, {{code|END SELECT}} construct for [[Switch statement|multi-way selection]] * Portable specification of numerical precision under the user's control * New and enhanced intrinsic procedures. ====Obsolescence and deletions==== Unlike the prior revision, Fortran 90 removed no features.<ref>ANSI X3.198-1992 (R2002) (Fortran 90), Appendix B.1.</ref> Any standard-conforming FORTRAN 77 program was also standard-conforming under Fortran 90, and either standard should have been usable to define its behavior. A small set of features were identified as "obsolescent" and were expected to be removed in a future standard. All of the functionalities of these early-version features can be performed by newer Fortran features. Some are kept to simplify porting of old programs but many were deleted in Fortran 95. {| class="wikitable sortable" |+ Obsolescence and deletions |- ! Obsolescent feature ! Current status |- | [[Arithmetic IF]]-statement | Obsolescent in F90, deleted in F2018 |- | Non-integer DO parameters or control variables | Obsolescent in F90, deleted in F95 |- | Shared DO-loop termination or termination with a statement other than END DO or CONTINUE | Obsolescent in F90, deleted in F2018 |- | Branching to END IF from outside a block | Obsolescent in F90, deleted in F95 |- | PAUSE statement | Obsolescent in F90, deleted in F95 |- | ASSIGN statement and assigned GO TO statement | Obsolescent in F90, deleted in F95 |- | Assigned statement numbers and FORMAT specifiers | Obsolescent in F90, deleted in F95 |- | H edit descriptor | Obsolescent in F90, deleted in F95 |- | Vertical format control | Deleted in F2003 |- | Alternate return | Obsolescent in F90 |- | Computed GO TO statement | Obsolescent in F90 |- | Statement functions | Obsolescent in F90 |- | DATA statements among executable statements | Obsolescent in F90 |- | Assumed length character functions | Obsolescent in F90 |- | Fixed form source code | Obsolescent in F90 |- | CHARACTER* form of CHARACTER declaration | Obsolescent in F90 |- | ENTRY statements | Obsolescent in F2008 |- | Label form of DO statement | Obsolescent in F2018 |- | COMMON and EQUIVALENCE statements, and the BLOCK DATA program unit | Obsolescent in F2018 |- | Specific names for intrinsic function | Obsolescent in F2018 |- | FORALL construct and statement | Obsolescent in F2018 |} ===="Hello, World!" example==== <syntaxhighlight lang="fortran"> program helloworld print *, "Hello, World!" end program helloworld </syntaxhighlight> ===Fortran 95=== {{Redirect|F95|the Düsseldorf-based football club nicknamed "F95"|Fortuna Düsseldorf}} {{Main|Fortran 95 language features}} ''Fortran 95'', published officially as ISO/IEC 1539-1:1997, was a minor revision, mostly to resolve some outstanding issues from the Fortran 90 standard. Nevertheless, Fortran 95 also added a number of extensions, notably from the [[High Performance Fortran]] specification: * {{code|FORALL}} and nested {{code|WHERE}} constructs to aid vectorization * User-defined [[pure function|{{code|PURE}} and {{code|ELEMENTAL}} procedures]] * Default initialization of derived type components, including pointer initialization * Expanded the ability to use initialization expressions for data objects * Initialization of pointers to {{code|NULL()}} * Clearly defined that {{code|ALLOCATABLE}} arrays are automatically deallocated when they go out of scope. A number of intrinsic functions were extended (for example a {{code|dim}} argument was added to the {{code|maxloc}} intrinsic). Several features noted in Fortran 90 to be "obsolescent" were removed from Fortran 95: * {{code|DO}} statements using {{code|REAL}} and {{code|DOUBLE PRECISION}} index variables * Branching to an {{code|END IF}} statement from outside its block * {{code|PAUSE}} statement * {{code|ASSIGN}} and assigned {{code|GO TO}} statement, and assigned format specifiers * {{code|H}} Hollerith edit descriptor. An important supplement to Fortran 95 was the [[International Organization for Standardization|ISO technical report]] ''TR-15581: Enhanced Data Type Facilities'', informally known as the ''Allocatable TR.'' This specification defined enhanced use of {{code|ALLOCATABLE}} arrays, prior to the availability of fully Fortran 2003-compliant Fortran compilers. Such uses include {{code|ALLOCATABLE}} arrays as derived type components, in procedure dummy argument lists, and as function return values. ({{code|ALLOCATABLE}} arrays are preferable to {{code|POINTER}}-based arrays because {{code|ALLOCATABLE}} arrays are guaranteed by Fortran 95 to be deallocated automatically when they go out of scope, eliminating the possibility of [[memory leak]]age. In addition, elements of allocatable arrays are contiguous, and [[aliasing (computing)|aliasing]] is not an issue for optimization of array references, allowing compilers to generate faster code than in the case of pointers.<ref>{{cite web|title=Fortran 95 Reference|url=https://gcc.gnu.org/onlinedocs/gcc-4.1.0/gfortran/|publisher=Gnu.Org|access-date=May 10, 2014}}</ref>) Another important supplement to Fortran 95 was the [[International Organization for Standardization|ISO]] technical report ''TR-15580: Floating-point exception handling'', informally known as the ''IEEE TR.'' This specification defined support for [[IEEE 754-2008|IEEE floating-point arithmetic]] and [[floating-point arithmetic|floating-point]] [[exception handling]]. ====Conditional compilation and varying length strings==== In addition to the mandatory "Base language" (defined in ISO/IEC 1539-1 : 1997), the Fortran 95 language also included two optional modules: * Varying length character strings (ISO/IEC 1539-2 : 2000) * Conditional compilation (ISO/IEC 1539-3 : 1998) which, together, compose the multi-part International Standard (ISO/IEC 1539). According to the standards developers, "the optional parts describe self-contained features which have been requested by a substantial body of users and/or implementors, but which are not deemed to be of sufficient generality for them to be required in all standard-conforming Fortran compilers." Nevertheless, if a standard-conforming Fortran does provide such options, then they "must be provided in accordance with the description of those facilities in the appropriate Part of the Standard".
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)