Google
 

Trailing-Edge - PDP-10 Archives - integ_tools_tops20_v7_30-apr-86_dumper - tools/transfort_v1_5/test.for
There are 3 other files named test.for in the archive. Click here to see a list.
C	FORTRAN program to illustrate each transformation performed
C	by TRANSFORT.
C
C	10/21/85	jke
C
	PROGRAM TTEST

C	TRANSFORM 1
C
C	DEC-20 FORTRAN allows comment lines to begin with several characters
C	the VAX does not allow.  The translated program has all comment lines
C	beginning with an asterisk.

C	This comment line begins with C
c	This comment line begins with c
$	This comment line begins with $
!	This comment line begins with !
/	This comment line begins with /

C	TRANSFORM 2
C
C	Statements on multi-statement lines are separated so that each
C	is contained on its own individual line.  A statement label is
C	associated with the first statement on the line, and a "!"
C	comment is associated with the last.

10	A = B;	CONTINUE;	IF (A.EQ.3) 20,30,40	! If statement is last

C	TRANSFORM 3
C
C	Identifiers longer than 6 characters are truncated to 6 characters.
C	The DEC-20 and VAX both allow longer identifiers, but they are only
C	significant to 6 characters whereas they are significant to 31 on
C	the VAX.
C
C	In the example given, the identifiers A VERYLONGIDENTIFIER and
C	AVERYLITTLEID are considered to be the same identifier on the DEC20.
C	This transform insures that the VAX will do the same.
C
C	This transformation generates an IDTRNC6 warning.

	LONGIDENTIFIER = AMUCHLONGERIDENTIFIER + AVERYLONGIDENTIFIER
     1		+ AVERYLITTLEID

C	TRANSFORM 4
C
C	Hollerith constants used as actual arguments to subprograms are
C	detected because the bit patterns actually passed to the subprogram
C	may be different.
C
C	This transformation generates a HOLCNSARG warning.
C	This transformation does not alter the target code.

	CALL SAMPLE ( 3HABC )

C	TRANSFORM 5
C
C	Octal constants, when found, are converted to use the VAX syntax.
C
C	This transformation generates a BITHACKAS warning.

	A = "777

C	TRANSFORM 6
C
C	Alternate syntax for relational operators: The symbolic forms of
C	the relational operators are converted to the standard form.

	IF ( A == B ) THEN		! equal
	IF ( A #  B ) THEN		! not equal
	IF ( A <  B ) THEN		! less than
	IF ( A >  B ) THEN		! greater than
	IF ( A <=  B ) THEN		! less than or equal
	IF ( A >= B ) THEN		! greater than or equal

	END

C	TRANSFORM 7
C
C	The symbolic form of the exponentiation operator "^" is converted to
C	"**".

	SUBROUTINE A
	LOGICAL LV

	SQRT( A ) = A ^ 0.5		! ^

C	TRANSFORM 8
C
C	The precedences of unary + and - differ on the VAX and DEC.
C	Expressions involving these operators may be altered so that
C	the expressions are evaluated in the same manner.  Parentheses
C	are placed around the unary term.

	A = A * - B * C + D		! B * C is negated
	END

C	TRANSFORM 9
C
C	Mixing logical and numeric values in an expression - this is
C	detected because logical values have different representations
C	on the two machines.  This also occurs during equivalence.
C
C	This transform produces a BITHACKAS warning, a BITHACKEQ warning,
C	or a BADLOGOP warning.

	FUNCTION FN
	LOGICAL LV
	EQUIVALENCE (LV,I)

	I = .TRUE.
	LV = (.TRUE. .AND. 3)
	END

C	TRANSFORM 10
C
C	The additional return label indicator "$" available on the DEC
C	is converted to "*" so it will compile on the VAX.

	SUBROUTINE TEST	( A,*,B,$,C,& )	! List is (A,*,B,$,C,&)
	CALL TEST	(*10,$20,&30)	! List is (*10,$20,&30)

C	TRANSFORM 11
C
C	Two-branch IF statement converted to an equivalent 3-branch IF.

	IF (A <= B) 10,20

C	TRANSFORM 12
C
C	Obsolete or untranslatable statements are flagged.  These statements
C	include DECODE, ENCODE, PUNCH,

	DECODE( A,B,C )
	ENCODE( A,B,C )
	PUNCH 3
	UNLOAD 3
	BACKFILE 3
	REREAD (FMT=100) A,B,C

C	TRANSFORM 13
C
C	Default write unit - this form of statement is illegal on the VAX.
C	TRANSFORT can, via the control file, create write statement to
C	UNIT 6 (or a user-specified unit), or ignore them.
C
C	This transformation produces a WRTUNTMOD warning.
	WRITE 10, A,B,C
	WRITE * , A,B,C

	END

C	TRANSFORM 14
C
C	FMT specification of a namelist - FMT is converted to NML.

	FUNCTION WRTTST

	NAMELIST /AAA/B,C,D
	DIMENSION BBB(10)
	CHARACTER BBB
	COMMON A,B,C,D,E

	WRITE (3,FMT=AAA) 		! FMT should be changed to NML
	WRITE (3,FMT=BBB)		! This one should not be

C	TRANSFORM 15
C
C	Default field widths for edit descriptors I,F,E,D,G,O,Z,L, and A
C
C	This transform produces a BDDFLTFMT warning.

100	FORMAT(X,I,F,E,D,G,O,Z,L,A)

C	TRANSFORM 16
C
C	R-Hollerith Edit Descriptor is converted to A edit descriptor.
C
C	This transformation produces a warning.

110	FORMAT(X,3R5)

C	TRANSFORM 17
C
C	Argument passing: because of the different methods used, certain 
C	situations can cause different results to occur from the same
C	code ont he two machines.  TRANSFORT attempts to warn about 
C	these situations.
C
C	This transform produces a COMPARM warning or a VARUSED2 warning.

	CALL SUB( A,E,E )
	X = 1 + FN( E, A, E)

C	TRANSFORM 18
C
C	Assigned GOTO statement.  Since the VAX ignores the list of labels
C	in the statement, these statements are detected.
C
C	This transform produces an ASGOTOLST warning.

	GOTO LV (10,20,30)

C	TRANSFORM 19
C
C	Unit 5 for output.  Like the default output unit, unit 5 WRITES can
C	be altered to unit 6, a user-defined unit, or ignored.  This is
C	provided because the DEC allows input and output both using unit 5,
C	but the VAX does input from unit 5 and output from unit 6.  
C	(Terminal I/O)
C
C	This transform produces a WRTUNTMOD warning.

	WRITE( 5, *) A,B,C
	WRITE(UNIT=5, FMT=*) A,B,C

C	TRANSFORM 20
C
C	OPEN STATEMENT QUALIFIERS

	OPEN(5,STATUS='NEW')

C	TRANSFORM 21
C
C	CLOSE STATEMENT QUALIFIERS

	CLOSE(5,DISPOSE='DELETE')

C	TRANSFORM 22
C
C	The final X edit descriptor of a format statement is replaced with
C	a blank character.
C
C	This transform produces a BADFRMTNX warning.

120	FORMAT(X,3I5,10X)
130	FORMAT(X,3I5,X)
140	FORMAT(X)

C	TRANSFORM 23
C
C	Floating point descriptors with empty decimal field widths are
C	converted to explicitly indicate an empty decimal field.
C
C	This transform produces a warning.

150	FORMAT(X,F5,E5,G5,D5)

C	TRANSFORM 24
C
C	Quoted strings as actual arguments are detected because the bit
C	patterns actually passed to the subroutines may differ.
C
C	This transform produces a CHRCNSARG warning.

	CALL SUB ( 'A' )
	X = VAL( '123' )

C	TRANSFORM 25
C
C	Mixing numbers and quoted strings: Again, due to differing bit
C	patterns, these are detected and warned about.
C
C	This transform produces a BITHACKAS warning or a BADRELOP warning.
	A = 'ABC'
	IF (A <= '3') 10,20,20

C	TRANSFORM 26
C
C	A edit descriptor - detected due to number of A items which appear
C	per word - 5 on DEC but only 4 on VAX.
C
C	This transform produces a SZMSMTCHF warning.

160	FORMAT (X,A5)

C	TRANSFORM 27
C
C	DO Loops may be converted to execute once if the ONE-TRIP flag is
C	set (ONE-TRIP appears in the control file).  Order of expression
C	evaluation is insured.
C
C	This transform produces a ONETRIP warning.

	DO 10 I=1,2,3
	DO 10 J=A,B
	DO 10 K=A,FN(3)
	DO 10 L=A,FN(3),B

C	TRANSFORM 28
C
C	Program format: Look above!