To give an idea of what fpt can do, here is an example from the Linux and Windows distributions:
wumpus.txt 25-Oct-23 John Collins
Modernising Wumpus
==================
wumpus.f is a slightly extended FORTRAN 77 implementation of "Hunt the Wumpus". To my surprise,
it compiles and runs under gfortran and the game is playable. The code needs modernisation.
For example, the code which sets up the cave system where the Wumpus lives begins:
SUBROUTINE PASSAG
INCLUDE 'ints.inc'
INTEGER DEST,IPASS(3,20)
DO 230 I = 1,20
DO 220 J = 1,3
IPASS(J,I) = 0
220 CONTINUE
230 CONTINUE
DO 300 I = 1,3
N = 20
J = 0
DO 280 WHILE (N .GT. 0)
J = J+1
IF (IPASS(I,J) .EQ. 0) THEN
240 CONTINUE
M = N*RAND()
IF ((M .EQ. 0) .OR. (M .EQ. N)) GOTO 240
K = 0
DEST = J
DO 260 WHILE (K .LT. M)
DEST = DEST+1
IF (IPASS(I,DEST) .EQ. 0) K = K+1
260 CONTINUE
DO 270 L = 1,I-1
IF (DEST .EQ.IPASS(L,J)) GOTO 240
270 CONTINUE
IPASS(I,J) = DEST
IPASS(I,DEST) = J
N = N-2
ENDIF
280 CONTINUE
300 CONTINUE
C WRITE(6,310)(J,(IPASS(I,J),I = 1,3),J=1,20)
310 FORMAT(4I5)
C
END
There is no indentation, implicit typing, the DO loop control constructs are DO <label> -
<label> CONTINUE, variables are passed between routines in a COMMON block and there are labels
everywhere.
fpt runs on this code with the script modernise_fortran.fsp to produce:
SUBROUTINE passag
!
!
! ****************************************************************************
!
!
USE fpt_module_kinds
!
USE module_ints
IMPLICIT NONE
!
! ****************************************************************************
!
INCLUDE 'ints.i90'
!
INTEGER(KIND=ki4)dest,ipass(3,20)
INTEGER(KIND=ki4) :: i
INTEGER(KIND=ki4) :: j
INTEGER(KIND=ki4) :: k
INTEGER(KIND=ki4) :: l
INTEGER(KIND=ki4) :: m
INTEGER(KIND=ki4) :: n
REAL(KIND=kr4) :: rand
!
DO i=1,20
DO j=1,3
ipass(j,i)=0
ENDDO
ENDDO
DO i=1,3
n=20
j=0
DO WHILE (n>0)
j=j+1
IF (ipass(i,j)==0) THEN
240 CONTINUE
m=n*rand()
IF ((m==0) .OR. (m==n)) THEN
GOTO 240
ENDIF
k=0
dest=j
DO WHILE (k<m)
dest=dest+1
IF (ipass(i,dest)==0) THEN
k=k+1
ENDIF
ENDDO
DO l=1,i-1
IF (dest==ipass(l,j)) THEN
GOTO 240
ENDIF
ENDDO
ipass(i,j)=dest
ipass(i,dest)=j
n=n-2
ENDIF
ENDDO
ENDDO
!
DO i=1,20
DO j=1,3
passage(j,cave_alias(i))=cave_alias(ipass(j,i))
ENDDO
ENDDO
! WRITE(6,310)(j,(pass(i,j),i = 1,3),j=1,20)
!
END
The text of the script modernise_fortran.fsp is:
! modernise_fortran.fsp 20-May-24 John Collins
! Please edit this file to customise the changes for your system
! File handling
! =============
! We assume that the top-level directory structure is:
!
! project_base_directory
! ! original_source
! ! ! directories containing the code
! ! modified_source
! ! ! empty directories matching original_source
! ! fpt_output
! ! ! empty directories matching original_source
!
! If your directory structure is different (and it may be) comment-out the following
! Set a default for new files (if any)
% output directory "../fpt_output"
% keep directories
% edit output file names: replace "original_source" by "fpt_output"
% edit output file names: replace "modified_source" by "fpt_output"
! Note - specify the input file name extensions in the list of input files
% primary output file name extension: ".f90"
% include output file name extension: ".i90"
% overwrite changed files
! modified_source contains files changed by hand. Look in modified source for changed files
% check modified source
! Code changes
! ============
% specify implicit none
% specify numeric kinds
% change do continue to do enddo
% change if to if-then
% remove labels from enddo statements
% remove labels from executable statements
% change relational operators to symbolic form
! Choose a number (or comment-out)
% remove format statements used fewer than 3 times
% change common to module
% make makefile
! Suppress the diagnostics which mark these changes
% suppress diagnostic 2255 4243 4495
! Code formatting
! ===============
% free format
% no column format
! Choose numbers appropriate for your system
% output code line length: 130
% page width: 132
% write continuation character in column 88
! Choose between:
!!! % lower case keywords
% upper case keywords
!!! % lower case intrinsics
% upper case intrinsics
% lower case symbols
!!! % upper case symbols
!!! % lower case parameters
!!! % upper case parameters
% default case parameters
% lower case kind tags
!!! % upper case kind tags
!!! % default case kind tags
!!! % lower case exponent characters
% upper case exponent characters
! Optionally:
% space before "::"
% space after "::"
% space before "="
% space after "="
! End of modernise_fortran.fsp