# Fortran

Revision as of 00:37, 7 November 2019 by GerdIsenberg (talk | contribs)

**Home * Programming * Languages * Fortran**

**Fortran**, (FORTRAN)

a general purpose, procedural and imperative programming language. Fortran was proposed and designed by John W. Backus as alternative for the IBM 704 assembly language. A draft specification for the IBM mathematical **For**mula **Tran**slating System was completed by mid 1954. The first Fortran compiler appeared in 1957 and was the first widely used high-level programming language. Successive versions have added varios features over the years, such as recursive routines and dynamic memory allocation in Fortran 90. Many early chess programs were written in Fortran.

## Contents

# Punched card

Punched card from a Fortran program: Z(1) = Y + W(1) ^{[1]}

# Sample Chess Code

A recursive Fortran 90 Alpha-Beta search routine ^{[2]}:

RECURSIVE FUNCTION EVALUATE (ID, PRUNE) RESULT (RES) USE GLOBALS IMPLICIT INTEGER(A-Z) DIMENSION XX(0:26), YY(0:26), CC(0:26) LEVEL=LEVEL+1 BESTSCORE=10000*ID DO B=7,0, -1 DO A=7,0, -1 ! generate the moves for all the pieces ! and iterate through them IF (SGN(BOARD(B,A))/=ID) CYCLE CALL MOVELIST (A, B, XX, YY, CC, NDX) DO I=0,NDX,1 X=XX(I); Y=YY(I); C=CC(I) OLDSCORE=SCORE; MOVER=BOARD(B,A); TARG=BOARD(Y,X) ! make the move and evaluate the new position ! recursively. Targ holds the relative value of the piece ! allowing use to calculate material gain/loss CALL MAKEMOVE (A, B, X, Y, C) IF (LEVEL<MAXLEVEL) THEN SCORE=SCORE+EVALUATE(-ID, & BESTSCORE-TARG+ID*(8-ABS(4-X)-ABS(4-Y))) END IF SCORE=SCORE+TARG-ID*(8-ABS(4-X)-ABS(4-Y)) ! we want to minimize the maximum possible loss ! for black IF ((ID<0 .AND. SCORE>BESTSCORE) .OR. & (ID>0 .AND. SCORE<BESTSCORE)) THEN BESTA(LEVEL)=A; BESTB(LEVEL)=B BESTX(LEVEL)=X; BESTY(LEVEL)=Y BESTSCORE=SCORE IF ((ID<0 .AND. BESTSCORE>=PRUNE) .OR. & (ID>0 .AND. BESTSCORE<=PRUNE)) THEN BOARD(B,A)=MOVER; BOARD(Y,X)=TARG; SCORE=OLDSCORE LEVEL=LEVEL-1 RES = BESTSCORE RETURN END IF END IF BOARD(B,A)=MOVER; BOARD(Y,X)=TARG; SCORE=OLDSCORE END DO END DO END DO LEVEL=LEVEL-1 RES=BESTSCORE RETURN END FUNCTION EVALUATE

# See also

# Publications

- James Gillogly (
**1970**).*MAX : A FORTRAN Chess Player*. RAND paper - John Backus (
**1978**)*The history of Fortran I, II, and III*. in Richard L. Wexelblat (ed) History of programming languages I - Alfio Marazz, Johann Joss, Alex Randriamiharisoa (
**1993**).*Algorithms, routines, and S functions for robust statistics: the FORTRAN library ROBETH with an interface to S-PLUS*. Wadsworth And Brooks/Cole Statistics/Probability Series, amazon

# Forum Posts

- Any Fortran coder ? by Laurent Laborde, CCC, November 15, 2018

# External Links

- Fortran from Wikipedia
- Microsoft® FORTRAN Version Features
- Intel Fortran Compiler
- History of FORTRAN and FORTRAN II — Software Preservation Group from The Computer History Museum
- comp.lang.fortran Discussion about Fortran