Google
 

Trailing-Edge - PDP-10 Archives - tops10and20_integ_tools_v9_3-aug-86 - tools/crc/help/f66-f77.lbr
There are no other files named f66-f77.lbr in the archive.
E/
hlpf77.LBR.1)eTCHANGES

3:vCHARS
3:vDECLARE3:wDO#3IVIF$93:yOPEN'ND3:zIO+w)eT	Fortran 77 is largely an extension of Fortran 66. Complete
compatability, however, has not been achieved, also some of the new features
were provided by manufacturers as extensions to Fortran 66, but not always in
an identical manner. The guidance given here is should indicate most of the
latter type of inconsistancy on the Dec 20, as well as pointing to the changes
brought about by the standard, with some indication of the new features now
available, notably the introduction of a CHARACTER type, and the block IF ELSE.


--------------------------------------------------------------------------------

			New Features in Fortran 77

--------------------------------------------------------------------------------
Character variables
~~~~~~~~~~~~~~~~~~~
	These are a new type of variable. A character variable has a fixed
number of characters in it, which if declared without a length defaults to 1.

	CHARACTER A,B
		  ^ ^ length of 1 character each

	CHARACTER*80 BUFFER*132,INPUT,OUTPUT
				  ^	^
				 length of 80 characters
In a subroutine, arguments may assume the length passed to the routine.

	CHARACTER*80 WORK,INPUT*(*),OUTPUT*(*)
			     ^	       ^
			   arguments passed to the routine

You may move them around.

	OUTPUT=INPUT

You may take substrings.

	OUTPUT=BUFFER(N:M)

however, N must be less than M, and both must be in range. A null string is not
permitted. You can omit either N or M to specify the appropriate end of the
original string.

You may concatenate strings, with the // operator.

	OUTPUT=INPUT(:N)//BUFFER(M:)//'ZZ Z'	!the beginning of INPUT, the
						!end of BUFFER and a character
						!constant

Since they are of fixed length, you should note that OUTPUT in the examples
will be either padded out with blanks, or have the string truncated, if the
right hand side is of a different length.

Testing for equality of strings, will blank pad a shorter string, before
the test, thus :-

	('ABCD    '.EQ.'ABCD')  is  .TRUE.

Character functions return a string of the length, as declared in the calling
routine.

	CHARACTER ALPHA*3,TEXT*9
	TEXT=ALPHA()
	:
	CHARACTER*(*) FUNCTION ALPHA ()
	APLHA='abcdefghijklmnopqrstuvwxyz'
	RETURN

TEXT will contain 'abc      '.

You may have an array of character variables.

	CHARACTER*(*) FUNCTION MONTH (I)
	CHARACTER M(12)*9
	DATA (M(J),J=1,12)/'January','February',
     +			   'March','April',
     +			   'May','June',
     +			   'July','August',
     +			   'September','October',
     +			   'November','December'/
	MONTH = M(I)
	RETURN
	END

This will return the name of the Ith month of the year, but only the number of
characters as specified in the calling program.
	CHARACTER*3 MONTH,MTEXT*4
	MTEXT=MONTH(2)
gives MTEXT as 'Feb '

You are supplied with the following functions:-

	LEN(TEXT)	returns the declared length of the character variable
			TEXT, NOT the number of non-blank characters in it.
	INDEX(LONG,SHORT) returns the start position of SHORT within LONG,
			if it occurs, or 0 if not, i.e. a search is performed.
	ICHAR(LETTER)	returns the position of the character LETTER in the
			collating sequence, i.e. the ASCII value, on the Dec 20
	CHAR(NUMBER)	returns the character associated with NUMBER in the
			collating sequence, i.e. the ASCII value, on the Dec 20
	LGE(TEXT,STRING)compares the 2 character strings using the ASCII
			collating sequence, and returns .TRUE. if TEXT is
			.GE. STRING
	LGT,LLE,LLT	are similar to LGE. These use ASCII on any machine.
			unlike the relational operators .LT. etc. Note that
			.EQ. and .NE. are independant of the collating sequence.

Character variables can neither be stored in the same common block as numerical
variables, nor equivalenced to them.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
				       |
	fortran version 6	       |	fortran 77
				       |
--------------------------------------------------------------------------------
				  Declarations
				       -
EXTERNAL used to pass an intrinsic     |used to indicate a user written routine
function to a subroutine.	       |of the same name as an intrinsic one.
				       |Use INTRINSIC to pass an actual function
				       |as a subroutine argument.
				       -
PARAMETER I=65.0,B=66		       |PARAMETER (I=65.0,B=66)
I real B integer, defined by values    |I integer B real (unless typed)
This is a Dec 20 extension	       |The old style will be treated as such
				       -
	REAL X(10,10)		       |This is now invalid. To turn on array
	:			       |bounds checking execute thus:-
	Y=X(15,2)		       |
				       |@EXE /COMP/DEBUG
is valid as the element was still      |
within the array !		       |
				       -
Different functions available for      |Generic functions available which look
different types.		       |after the argument types for you, up to
				       |a point.
	X=AMAX0(I,4)		       |	X=MAX(I,4)
				       -
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
				       |
	fortran 66	               |	fortran 77
				       |
--------------------------------------------------------------------------------
				    DO loops
				       -
Although strictly not allowed, DO loops|A DO loop with an iteration count of
could be entered, and executed once    |zero will not be executed.
with conditions implying no execution  |
				       |
	DO 100 I=1,0		       |	DO I=1,0
	WRITE (5,200)		       |	   WRITE (UNIT=5,FMT=*)
  100	CONTINUE		       |      +		'This is not printed'
  200	FORMAT(' This is printed once')|	END DO
				       |
				       -
				       |The Dec 20 allows the label in a DO
				       |loop to be replaced by an END DO
				       |statement. See above.
                                       |This is an extension to the standard.
				       -
				       |The Dec 20 allows a DO WHILE (...)
                                       |This is an extension to the standard.
				       |
				       |	DO WHILE (I.GT.1984)
				       |	   ANS(I)=42.0
				       |	   I=YEAR(I)
				       |	END DO
				       -
The parameters of a DO loop must be    |The parameters may be any numerical
either positive INTEGER variables or   |expression other than of type complex.
constants. 			       |
				       -
You are allowed to jump out of a DO    |This is disallowed by the standard.
loop, and then jump back in.	       |
				       -
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

			New Features in Fortran 77

--------------------------------------------------------------------------------
IF-THEN-ELSE-END IF
Expressions in output lists, including character constants.
e.g.:-
	IF (X > 0) THEN
	   WRITE (UNIT=5,FMT=*) 'The square root of ',X,' is ',SQRT(X)
	   MINUS=.FALSE.
	ELSE IF (X == 0) THEN
	   WRITE (UNIT=5,FMT=*) 'The square root of 0 is ',0
	   MINUS=.FALSE.
	ELSE
	   X=-X
	   MINUS=.TRUE.
	   WRITE (UNIT=5,FMT=*) 'The square root of ',-X,' is ',SQRT(X),'j'
	END IF

The logical operators .GT. .EQ. etc. are still available.
The ELSE IF (...)THEN and ELSE statements are both optional.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
				       |
	fortran version 6	       |	fortran 77
				       |
--------------------------------------------------------------------------------
				OPEN statements
				       -
If FORM= not specified, defined by     |If FORM= not specified, assumes
first i/o statment		       |'FORMATTED' unless ACCESS='DIRECT'
				       |'RANDOM' or 'RANDIN' when 'UNFORMATTED'
				       -
Files with mixed formatted and	       |Prohibited by the standard, tolerated
unformatted records not prohibited     |on the 20 but no file positioning
				       |allowed. (BACKSPACE & SKIPRECORD)
				       -
If RECORDSIZE in an OPEN on a BINARY   |Fatal error
file conflicts with actual record      |
then no error.			       |
				       -
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
				       |
	fortran version 6	       |	fortran 77
				       |
--------------------------------------------------------------------------------
				I/O  statements
				       -
Formatted input from a file of fixed   |The requisite number of characters will
length, terminated by CR LF FF or VT.  |be input, including CR LF FF VT and NUL
NULL's are ignored.		       |
				       -
Variable length input ignores NULL's.  |Leading NULL's ignored, imbedded NULL's
				       |read in.
				       -
A formatted output replaces NULL's with|NULL's output.
blanks.				       |
				       -
Fixed length records padded with NULL's|Padded with spaces by default, use
				       |PADCHAR= to specify any other character.
				       -
Default BLOCKSIZE for a mag tape is 512|512 words. New programs can read old
characters.			       |tapes (if defaulted) but not vice versa.
				       -
multi-record ENCODE/DECODE (!!!!)      |Different (see me...)
has changed.			       |
				       -
Input to Hollerith or quoted text      |Not allowed in the standard.
allowed (!!!!!!)		       |Will be disallowed sooner or later on 20
				       -
Only variables accepted in an output   |Expressions accepted.
list.				       |WRITE(UNIT=5,FMT=*)'Answer=',SQRT(X+Y)
				       -
Format details are given on a labelled |Formats may be given in quotes.
line.				       |
	WRITE(5,10) NUMBER	       |      WRITE (UNIT=5,FMT='1X,A,I3')
   10	FORMAT (' Number = ',I3)       |     +  'number = ',NUMBER
				       |
				       |The UNIT= and FMT= specifiers are
				       |optional but recomended.
--------------------------------------------------------------------------------