Fortran A Language with a Past and a

  • Slides: 21
Download presentation
Fortran - A Language with a Past and a Future Peter Crouch pccrouch@bcs. org.

Fortran - A Language with a Past and a Future Peter Crouch pccrouch@bcs. org. uk Chairman BCS Fortran Specialist Group www. fortran. bcs. org BCS Wolverhampton Branch meeting 16 th March 2005

A Brief Career History 1968 - 1984 Industrial research chemist. I started programming early

A Brief Career History 1968 - 1984 Industrial research chemist. I started programming early personal computers in BASIC and Pascal in the late 1970 s. I began to to use FORTRAN in the early 1980 s. 1985 - 2001 Software developer for Computer Aided Design and Manufacturing systems using Fortran and C. 2003 - 2005 Civil servant in the Department for Work and Pensions. 1993 I joined the British Computer Society 1997 - 2002 I was Chairman of the BCS Birmingham Branch 2002 - 2005 I am Chairman of the BCS Fortran Specialist Group

Presentation Outline 8 The Ancient History of FORTRAN - 1954 to 1980 8 Modern

Presentation Outline 8 The Ancient History of FORTRAN - 1954 to 1980 8 Modern Developments in Fortran - 1990 to 2004 8 The BCS Fortran Specialist Group - 1970 to 2005 8 Application Areas for Fortran programs

Computing in the early 1950 s Computer memories of the order of 15 KB,

Computing in the early 1950 s Computer memories of the order of 15 KB, often measured in bits. CPU programmed using octal code, later machine code and assembler. 1954 John Backus and his team at IBM began work on what became the first high level programming language, FORTRAN. 1957 First version of FORTRAN, for the IBM 704, released. It was an immediate success.

Ancient History Links Pioneers of the 'Fortran' Programming Language New York Times Steve Lohr

Ancient History Links Pioneers of the 'Fortran' Programming Language New York Times Steve Lohr June 13, 2001 (HTML) Fortran Automated Coding System For the IBM 704 John Backus, et al. Oct. 1956 The very first Fortran manual (PDF)

The Next Steps 1958 FORTRAN III - Not released to public 1961 FORTRAN IV

The Next Steps 1958 FORTRAN III - Not released to public 1961 FORTRAN IV - A "cleaned up" version of FORTRAN II 1962 First ASA FORTRAN standardization committee meets

Fortran Standards Revision History 1962 First ASA (later ANSI) standardization committee meets 1966 Publication

Fortran Standards Revision History 1962 First ASA (later ANSI) standardization committee meets 1966 Publication of ANSI standard X 3. 9 -1966 (FORTRAN 66) - first programming language standard 1978 Publication of ANSI X 3. 9 -1978 (FORTRAN 77) - also published as ISO 1539: 1980 – relatively minor revision 1991 ISO/IEC 1539: 1991 (Fortran 90) - major revision 1997 ISO/IEC 1539 -1: 1997 (Fortran 95) - minor revision 2004 ISO/IEC 1539 -1: 2004 (Fortran 2003) - major revision

What FORTRAN 77 did for us FORTRAN 77 added: • DO loops with a

What FORTRAN 77 did for us FORTRAN 77 added: • DO loops with a decreasing control variable (index) • Block if statements IF. . . THEN. . . ELSE. . . ENDIF. Before F 77 there were only IF. . . GOTO statements • Pre-test of DO loops. Before F 77 DO loops were always executed at least once, so you had to add an IF. . . GOTO before the loop if you wanted the expected behaviour. • CHARACTER data type. Before F 77 characters were always stored inside INTEGER variables. • Apostrophe delimited character string constants. • Main program termination without a STOP statement.

Example code - FORTRAN 0 2 3 4 8 11 DIMENSION A(11) READ A

Example code - FORTRAN 0 2 3 4 8 11 DIMENSION A(11) READ A DO 3, 8, 11 J=1, 11 I=11 -J Y=SQRT(ABS(A(I+1)))+5*A(I+1)**3 IF (400>=Y) 8, 4 PRINT I, 999. GOTO 2 PRINT I, Y STOP

Example code - FORTRAN I C C 1 4 5 8 9 10 THE

Example code - FORTRAN I C C 1 4 5 8 9 10 THE TPK ALGORITHM FORTRAN I STYLE FUNF(T)=SQRTF(ABSF(T))+5. 0*T**3 DIMENSION A(11) FORMAT(6 F 12. 4) READ 1, A DO 10 J=1, 11 I=11 -J Y=FUNF(A(I+1)) IF(400. 0 -Y)4, 8, 8 PRINT 5, I FORMAT(I 10, 10 H TOO LARGE) GOTO 10 PRINT 9, I, Y FORMAT(I 10, F 12. 7) CONTINUE STOP 52525

Example code - FORTRAN IV or 66 C C 1 4 5 8 10

Example code - FORTRAN IV or 66 C C 1 4 5 8 10 THE TPK ALGORITHM FORTRAN IV STYLE DIMENSION A(11) FUN(T) = SQRT(ABS(T)) + 5. )*T**3 READ (5, 1) A FORMAT(5 F 10. 2) DO 10 J = 1, 11 I = 11 - J Y = FUN(A(I+1)) IF (400. 0 -Y) 4, 8, 8 WRITE (6, 5) I FORMAT(I 10, 10 H TOO LARGE) GO TO 10 WRITE(6, 9) I, Y FORMAT(I 10, F 12. 6) CONTINUE STOP END

Example code - FORTRAN 77 C C 9 5 10 PROGRAM TPK THE TPK

Example code - FORTRAN 77 C C 9 5 10 PROGRAM TPK THE TPK ALGORITHM FORTRAN 77 STYLE REAL A(0: 10) READ (5, *) A DO 10 I = 10, 0, -1 Y = FUN(A(I)) IF (Y. LT. 400) THEN WRITE(6, 9) I, Y FORMAT(I 10. F 12. 6) ELSE WRITE (6, 5) I FORMAT(I 10, ' TOO LARGE') ENDIF CONTINUE END REAL FUNCTION FUN(T) REAL T FUN = SQRT(ABS(T)) + 5. 0*T**3 END

Modern Developments Fortran 90 added: • • • Free format source code form (column

Modern Developments Fortran 90 added: • • • Free format source code form (column independent) Modern control structures (CASE & DO WHILE) Records/structures - called "Derived Data Types" Powerful array notation (array sections, array operators, etc. ) Dynamic memory allocation Operator overloading Keyword argument passing The INTENT (in, out, inout) procedure argument attribute Control of numeric precision and range Modules - packages containing variable and code

Example code - Fortran 90 & 95 PROGRAM TPK ! The TPK Algorithm !

Example code - Fortran 90 & 95 PROGRAM TPK ! The TPK Algorithm ! Fortran 90 style IMPLICIT NONE INTEGER : : I REAL : : Y REAL, DIMENSION(0: 10) : : A READ (*, *) A DO I = 10, 0, -1 ! Backwards Y = FUN(A(I)) IF ( Y < 400. 0 ) THEN WRITE(*, *) I, Y ELSE WRITE(*, *) I, ' Too large' END IF END DO CONTAINS ! Local function FUNCTION FUN(T) REAL : : FUN REAL, INTENT(IN) : : T FUN = SQRT(ABS(T)) + 5. 0*T**3 END FUNCTION FUN END PROGRAM TPK

Example code - F (1) module Functions public : : fun contains function fun(t)

Example code - F (1) module Functions public : : fun contains function fun(t) result (r) real, intent(in) : : t real : : r r = sqrt(abs(t)) + 5. 0*t**3 end function fun end module Functions

Example code - F (2) ! ! program TPK The TPK Algorithm F style

Example code - F (2) ! ! program TPK The TPK Algorithm F style use Functions integer : : i real : : y real, dimension(0: 10) : : a read *, a do i = 10, 0, -1 ! Backwards y = fun(a(i)) if ( y < 400. 0 ) then print *, i, y else print *, i, " Too large" end if end do end program TPK

Fortran 2003 International Standard, ISO/IEC 1539 -1: 2004, published in November 2004 Fortran 2003

Fortran 2003 International Standard, ISO/IEC 1539 -1: 2004, published in November 2004 Fortran 2003 notably added: • Support for object orientated programming • Interoperability with C Overview of new features in Fortran 2003 by John Reid Convenor, ISO Fortran Working Group (PDF)

BCS Fortran Specialist Group The Group was founded in 1970 with the objectives of:

BCS Fortran Specialist Group The Group was founded in 1970 with the objectives of: • forming a focus in the United Kingdom for work concerned with establishing and maintaining FORTRAN standards. • working in association with national and international standardisation bodies The convenor (chairman) of the ISO WG 5 committee responsible for the Fortran language is a member of the FSG committee as is the convenor of the BSI (UK) Fortran panel. For the last few years the Fortran SG has provided financial support to enable several UK representatives to attend ISO meetings abroad. Fortran Standardisation Activities - FSG web site

Fortran SG continued In October 2002 the Group held a meeting to discuss some

Fortran SG continued In October 2002 the Group held a meeting to discuss some of the remaining features to go into Fortran 2003. Of the seven proposals put forward five were taken forward to the BSI Fortran Panel. At the next WG 5 meeting, where three of the five UK representatives were funded by the BCS through the FSG, ten of the eleven UK proposed technical changes were accepted, as were thirteen of the UK’s fifteen minor technical changes and seventeen of the twenty-two minor edits put forward by the UK. “One could argue that the BCS funds were well invested. ”

Application Areas for Fortran programs Fortran users include the UK Meteorological Office, the Ministry

Application Areas for Fortran programs Fortran users include the UK Meteorological Office, the Ministry of Defence, the Atomic Weapons Establishment, oil companies, the aircraft and automobile industries, engineering consultancies, universities, research laboratories and other scientific institutions. It is also used in the finance industry, which does complex calculations to analyse stock market and financial market data. Examples from FSG presentations

Thank you, any questions? www. fortran. bcs. org

Thank you, any questions? www. fortran. bcs. org