Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Fortran
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
===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>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Fortran
(section)
Add topic