File FORTX.DC (file description)

Directory of image this file is from
This file as a plain text file





               FFFFFFFF  OOOOOO  RRRRRRR  TTTTTTTT XX    XX
               FF       OO    OO RR    RR    TT     XX  XX
               FF       OO    OO RR    RR    TT      XXXX
               FFFFFF   OO    OO RRRRRRR     TT       XX
               FF       OO    OO RR  RR      TT      XXXX
               FF       OO    OO RR   RR     TT     XX  XX
               FF        OOOOOO  RR    RR    TT    XX    XX





                          FORTRAN ( Extended )

                   An Improved and Extended version of
                      the OS/8 FORTRAN II compiler.

                               Version 1.2


                              Developed by:

                             George Gonzalez
                          Hearing Research Lab
                         University of Minnesota

                                June 1978





                    (C) 1977 University of Minnesota



      This  document describes the salient differences between FORTX and

 the OS/8 Fortran II compiler. It assumes the reader  is  familiar  with

 the  FORTRAN IV language and with OS/8 Fortran II. See 'OS/8 Handbook',

 Chapter 7 for a description of OS/8  Fortran  II.  See  Chapter  8  for

 FORTRAN IV.















                                   1 


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


    Introduction.

        This  writeup  describes  'FORTX',  an  enhanced  and improved
    version of the DEC OS/8 Fortran II compiler (FORT). The extensions
    include most of the useful features  of  Fortran  4  (1977)  which
    could  be  added  within  the  limitations  of the OS/8 Fortran II
    compiler, assembler, and loader. They include:

    Commands:       DATA
                    Logical and Block IF Statements
                    Structured DO loops
                    WHILE Statement
                    INTEGER, LOGICAL, REAL Statements
    Operators:      .LT. .GT. .LE. .GE. .EQ. .NE. .AND. .OR. .NOT.
    Constants:      Logical, Hollerith, quoted, ASCII, and octal

            ( Plus many miscellaneous improvements described below )

        The compiler remains  downward-compatible  with  all  standard
    OS/8  Fortran  II  programs,  i.e.  any  standard  OS/8 Fortran II
    program  will  compile  correctly  under  FORTX,  with  one  minor
    exception (see Strings). Users who have made use of  some  of  the
    undocumented  features  of  OS/8  Fortran II may have to make some
    minor changes. All known  'incompatibilities'  of  this  sort  are
    flagged by '**' in this document.

                       A D D E D   F E A T U R E S

    Declarative statements.

        The  variable  declaration  statements  are  used to declare a
    variable or function to be of a different type  than  is  normally
    implied  by the variable name. The statement is followed by a list
    of variables, arrays, and function names separated by commas. This
    list is herein called a D-list.
    Example D-lists:
            X, Y, Z                 [ scalar variables ]
            Q(10), W(5,5)           [ arrays ]
            SINH, COSH, TANH        [ external function names ]
            X, Q(10), W(5,5)        [ combination ]

    INTEGER Statement

            INTEGER D-list

        The INTEGER statement declares the items in the D-list  to  be
    of  type integer, independent of their implicit type determined by
    the first character of their name. An array may be dimensioned  in
    an  INTEGER  statement  or a separate DIMENSION statement, but not
    both.

    REAL Statement

            REAL D-list

        The REAL statement declares the items in the D-list to  be  of
    type REAL.



                                  -2-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


    LOGICAL Statement

            LOGICAL D-list

        The  LOGICAL  statement declares the items in the D-list to be
    of type LOGICAL.

    FUNCTION Statement

        The word FUNCTION can  be  optionally  prefixed  by  the  word
    INTEGER, LOGICAL, or REAL to declare the function as that type.

    DATA Statement

    The DATA statement assigns initial values to variables and arrays:

            DATA var1,..., varn/val1,...,valn/, .etc..

        The  list  of variables may consist of simple variables, array
    names, array elements, or implied array sections. For every simple
    variable or array element there must be a value of the same type:

            DATA X / 5.0 /
            DATA Z(5) / 9.9 /

        For every array name there must be enough values to  fill  the
    array, with the first subscript varying the fastest:

            DIMENSION LIST(5)
            DATA LIST / 1, 2, 3, 4, 5 /

        For implied array sections there must be enough values to fill
    the specified section:

            DIMENSION X(10)
            DATA (X(I),I=1,4) / 1.0, 2.0, 3.0, 4.0 /

        A  repeat  factor can be used to set many elements of an array
    to the same value. The repeat factor  is  an  integer  and  a  '*'
    preceding the value to be repeated:

            INTEGER BIG(1000)
            DATA BIG / 500*1111, 500*1234 /

        The type of value must match the type of the variable. However
    character strings may be stored into any type of variable, up to 2
    characters per integer, 6 characters per real variable:

            REAL STRING(2)
            DATA STRING / 6HABCDEF, 'GHIJKL' /

        Variables  in COMMON, EQUIVALENCE, or formal parameters cannot
    be preset by a DATA statement. The DATA statement requires 12K  at
    compile-time.  If  the system has only 8K, then DATA is treated as
    an 'INVALID STATEMENT'. Once compiled,  programs  using  the  DATA
    statement do not have this restriction.




                                  -3-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


    Character strings.

        Character  strings  may  be denoted in 'H' format or in quoted
    string form. Examples:

            16HTHIS IS A STRING
            'THIS IS A STRING, TOO'
        Strings of 1 or 2 characters are treated as integer  constants
    and may appear anywhere a integer is allowed:

            MINUS = 1H-
            MULT = '*'

        Strings of 3 to 6 characters are treated as real constants:

            HELLO = 5HHELLO
            BYE   = 'BYE'

        Strings  longer than 6 characters are a special case. They may
    only appear as an actual parameter. As  an  actual  parameter  the
    string appears to the calling routine as an array of packed (A2 or
    A6) characters, terminated by a zero character ('@'):


            CALL PRINT(17HPROGRAM COMPLETE.)

        **Note  that  FORTX  does  not  zero-fill  strings  out  to  6
    characters  like  FORTRAN  II.  Routines  that  expect 6-character
    strings  (  like  IOPEN/OOPEN/CHAIN  )  should  be   called   with
    6-character strings:
    Not:    CALL CHAIN('A')         ( FORTRAN II padded to 'A@@@@@' )
    But:    CALL CHAIN('A@@@@@')

        **Also,  FORTX  strings  of  1  or  2  characters  are of type
    INTEGER, whereas FORTRAN II strings are  all  of  type  REAL.  The
    temporary  solution  is  to fill strings to 6 characters with zero
    characters ('@').

    ASCII constants.

        A full ASCII character may be denoted by placing the character
    in quotation (") marks. All characters have the  parity  bit  set.
    Examples:

    Character:      "A"     "a"     "Z"     "z"
    Octal value:    301     341     332     372

        Note  that  ASCII  characters  can  only  be  input and output
    through user-written routines,  as  OS/8  Fortran  II  uses  6-bit
    characters for all user-level Input-Output.

    Octal constants.

        An  integer  octal  constant can be specified by following the
    number by  the  letter  'B'.  Up  to  four  octal  digits  may  be
    specified:

            DATA ( MASK(I), I=1,4) / 0001B, 0010B, 0100B, 1000B /


                                  -4-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


            BELL = 207B

        Using  non-octal  digits  (8  or  9)  with a 'B' suffix is not
    detected as an error and results in an  undefined  value  for  the
    constant. The constant 4000B cannot be used.

    Comments.

        A comment may be placed on any line by preceding it with an at
    sign. The compiler will ignore any text on a line after an at sign
    (@):

            IF ( CHAR .EQ. "$" ) RETURN     @ End of file, return

        Also, any line with a '*' in columm 1 is treated as a comment.

    Logical constants.

        The  logical  constants of 'true' and 'false' are symbolically
    represented as:
                    .TRUE.  and     .FALSE.

    The internal representation of false is 12 '0' bits, an integer 0.
    True is represented as 12 '1' bits, an integer -1.

    Logical operators.

        The logical operators are:

            .AND.           .OR.            .NOT.

        .AND. and .OR. perform the logical product and  sum  of  their
    arguments  as  represented  in  the table below. .NOT. returns the
    logical negation of its one argument:


    X       Y    X .OR. Y       X .AND. Y       .NOT. X
    F       F       F               F               T
    F       T       T               F               T
    T       F       T               F               F
    T       T       T               T               F


        The logical operators can also  be  used  to  perform  Boolean
    operations  on  integers.  The operators will perform 12-bit .AND.
    .OR. and .NOT. operations:

            CHAR = CHAR .AND. 177B          @ Ignore parity bit
            WORD = HICHAR .OR. LOWCHAR      @ Combine characters

    Logical variables.

        A logical variable is a variable of type LOGICAL, as  declared
    by  the  LOGICAL statement. The only operations defined on logical
    variables are:

    Logical assignment:     MONDAY = .TRUE.
    Logical operations:     WEEKDY = (.NOT. SUNDAY) .AND. (.NOT. SATDY)


                                  -5-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


    Logical comparison:     IF( WEEKDY ) WAKEUP = 7.00 [ see 'IF' below ]

    Relational operators.

        The standard Fortran 4 relational operators are implemented:

            Relation           Operator symbol

            Equal                   .EQ.
            Not equal               .NE.
            Greater than            .GT.
            Less than               .LT.
            Greater or equal        .GE.
            Less or equal           .LE.

        The relational operators take two integer or two real operands
    and return a LOGICAL result:

            LOGICAL FEVER, GENIUS
            FEVER = TEMP .GT. 98.6
            GENIUS = IQ .GT. 140

        The relational and logical operators, and  the  exponentiation
    operator  have an alternate one-character representation, which is
    non-standard but have the same effect as the standard symbols. The
    operators, their  alternate  symbols,  and  their  precedence  are
    summarized below:

            Operator    Alternate       Precedence
               **           ^               7       Highest

             unary -                        6
              .NOT.         \               6

               *                            5
               /                            5

               +                            4
               -                            4

              .EQ.          :               3
              .NE.          #               3
              .LT.          <               3
              .GT.          >               3
              .LE.          $               3
              .GE.          %               3

              .AND.         &               2
              .OR.          !               2




    Logical IF statement.

        The  logical  IF  statement conditionally executes one Fortran
    statement:



                                  -6-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


            IF( condition ) statement

        'statement' is executed only if 'condition' is TRUE.
    Examples:
            IF( I .LT. 1000 ) I = I + 1
            IF( TEMP .GT. 98.6 ) CALL DOCTOR
            IF( DELTA .LT. 0.00001 ) RETURN
            IF( DAY .EQ. SAT  .OR.  DAY .EQ. SUN ) WEEKEND = .TRUE.

        'statement' cannot be a declarative statement or Block IF, DO,
    or WHILE statement. It cannot have a statement number.

    Block IF Statement

        The  Block  IF  statement  is  used  to  execute  a  block  of
    statements if a given condition is true. The block  of  statements
    executed  is  from  the  statement  following  the  IF  up  to the
    corresponding ENDIF statement:

            IF ( X > MAX ) THEN     @ Swap Variables
                    TEMP = X
                    X = MAX
                    MAX = TEMP
            ENDIF

        The indenting of the statements is optional,  but  recommended
    to clearly show the block of controlled statements.

        An optional ELSE statement introduces a block of statements to
    be executed if the condition is false:

            IF ( SPEED < 50 ) THEN
                    RPM = 3000.0
                    GEAR = 3
            ELSE
                    RPM = 4000.0
                    GEAR = 4
            ENDIF

        Block IF's may be nested 16 levels deep. The word 'THEN' after
    the if condition is optional.


    WHILE Statement

        The  WHILE statement is used along with the ENDWHILE statement
    to delimit a block of statements to be repeatedly executed while a
    given condition is true:

            WHILE ( CHAR .NE. '$' )     @ SEARCH FOR '$'
                    I = I + 1
                    CHAR = LINE(I)
            ENDWHILE

        If the condition is initially false, the block  of  statements
    is not executed at all.




                                  -7-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


    Structured DO

        The  structured  DO loop works like a standard DO loop, but it
    is terminated by a  ENDDO  statement  instead  of  by  a  specific
    statement number:

            DO ? I = 1, 10
                    X(I) = X(I) + Y(I)
            ENDDO

        The  '?'  is  required  to  inform the compiler that this is a
    structured DO loop.

    Run-time Error checking

                             Error Traceback

        FORTX  normally  emits  extra  instructions   to   provide   a
    meaningful error traceback in case an error is detected at program
    run  time.  These extra instructions allow a helper program (DIAG)
    to diagnose the error and pinpoint  the  exact  routine  and  line
    number  where  the  error occurred. For example, the program below
    will generate the following output:

    160     X = 0.0
            CALL BADDY(X)
            END

            SUBROUTINE BADDY(Z)
            DO 105 I = 1,10
    105     Z = ALOG(Z) / 3.14159
            RETURN
            END

    ?LOGARITHM OF NUMBER <= 0.0? AT STATEMENT 105 OF ROUTINE "BADDY"
    CALLED FROM STATEMENT 160.1 OF MAIN PROGRAM.

        This error traceback is very handy when debugging  a  program,
    but  a  price  is  paid  for the convenience as the traceback code
    makes most compiled programs about 10% longer than they  would  be
    without  traceback.  Specifying  the  /T  option  to  the compiler
    instructs it  to  not  generate  instructions  for  a  full  error
    traceback.  If  the  above program was compiled with the /T switch
    then the above error message would be less useful,  as  the  exact
    line  number of the error would not be available (DIAG prints 0 if
    it can't determine the correct line number).

    ?LOGARITHM OF NUMBER <= 0.0? AT STATEMENT 0 OF ROUTINE "BADDY"
    CALLED FROM STATEMENT 0 OF MAIN PROGRAM.

        The /T option should only be specified if the program will not
    otherwise fit into memory.

                          Array bounds checking

        The FORTX compiler normally generates  extra  instructions  to
    check   at  program  run-time  that  all  array  references  (with
    subscripts) are within the dimensioned bounds of the array. If the


                                  -8-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


    array bounds are exceeded, a fatal error is generated:

            SUBS ERROR AT XXXXX

    Or if DIAG is available:

        ?SUBSCRIPT OUT OF BOUNDS? AT STATEMENT XXX OF ROUTINE "YYYYY".

        In  unusual  cases  it  might  be  desireable  to  not   check
    subscripts.  Compiling  with the /C option turns off all subscript
    range checking. This will shrink the size of the compiled  program
    by about 5% but makes no measureable difference in program speed.

    Compiler options.



/C     **Disables array bounds checking.

/D        Enables  'debug'  mode.  Fortran statements with 'C$' in the
          first two  columms  are  treated  as  compilable  statements
          instead  of as comments. This feature allows the conditional
          compilation of certain statements for  debugging,  or  other
          purposes.

/T     ** Disables error traceback code.

/V     Prints  the current version number and patch level of the FORTX
          compiler.


 Improvements in code generation.

     The index variable in a computed GO TO is always checked to be in
 the range of 1 to J, where J is the number of statement labels in the
 statement. If the index is in range, the normal branch occurs. If  it
 is  out  of  range,  the  program  continues with the next sequential
 statement. The  OS/8  Fortran  II  generated  code  would  jump  into
 undefined regions, never to return.

     The  code  generated  for  accessing  arguments  of a function or
 subroutine is much faster  and  smaller  than  the  OS/8  Fortran  II
 compiler  code.  The  amount  of code generated is independent of the
 number of arguments.

     If 16K is available at compile-time, the compiler  stores  FORMAT
 statements  in  a  contiguous  area  of  memory.  This  allows FORMAT
 statements to be of any length (not limited to  248  characters)  and
 they do not waste memory due to paging. Up to 20% less memory is used
 by programs with many long FORMAT statements.

     The  code generated for doing integer subtraction and unary minus
 is usually shorter.

 ** Branching to a FORMAT statement ( a guaranteed  disaster  in  OS/8
 Fortran  II ) is diagnosed. The SABR assembler will flag any jumps to
 a FORMAT as 'undefined', and abort the assembly.



                                  -9-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


     A subprogram argument used as a  DO-loop  index  works  properly.
 OS/8  Fortran  II  would  generate  incorrect  code  if  the  DO-loop
 increment was 1.

     Subroutines  and  functions do not contain an unreachable call to
 the OPEN routine.


 Miscellaneous improvements.

     All compiler error messages now print the sequential line  number
 of the erroneous line.

     If  12K  is  available  at  compilation-time  then  duplicate  or
 undefined  statement numbers are diagnosed by the compiler instead of
 generating a cryptic error message late in SABR assembly.

     The compiler symbol table has been expanded about  20%,  allowing
 the compilation of programs with more symbols.

     A  RETURN  statement  in  a main program acts as a STOP statement
 instead of causing a COMPILER MALFUNCTION message.

     A function need not set its returned variable.

     Specifing no input file now repeats the  '*'  prompt  instead  of
 generating a spurious error message.

     Missing commas in implied-DO loops are diagnosed.

     The format array in a read/write statement may be of type real.

     A labeled GOTO statement to the next line generates correct code.

     A  overly-complex  expression  generates  a diagnostic instead of
 crashing the compiler and perhaps the system.

     Placing a variable in COMMON more than once is diagnosed.

     If 16K is available at compilation time, then  FORMAT  statements
 without statement numbers are diagnosed.

 Restrictions.

     The  size  of internal compiler tables sets some numerical limits
 on FORTX programs. These limits are identical to or higher  than  the
 OS/8 Fortran II limits.


     A  maximum  of  265 different variable names, floating constants,
 3-6 character strings, and arrays.

     A maximum of 128 strings longer than 6 characters, except in DATA
 statements, where there is no limit on the number of strings.

     A maximum string length of 247 characters.

     A maximum of 248 characters in one FORMAT statement.


                                  -10-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


     (No compiler limit if 16K is available to the compiler.)

     A maximum of 21 nested Do loops, block IF's and WHILE's.

     A maximum of 125 labels in a computed GOTO statement.

     No more than 62 actual parameters in a CALL or function  argument
 list.

     A maximum of 63 unclosed left parentheses at any one time.

 **  The  statements  must  be ordered (by category) as defined below.
 Statements in the same category can appear in any order.


 Statement category              Statements

 subprogram header               SUBROUTINE statement
                                 FUNCTION statement

 type and array declarations     DIMENSION
                                 COMMON
                                 INTEGER
                                 REAL
                                 LOGICAL


 data declarations               DATA

 executable statements           Any other statements.

 ** Any violation of this ordering will  give  a  'INVALID  STATEMENT'
 error for the offending statement.

 FORTX vs. FORTRAN IV

     FORTX does not have the following FORTRAN IV features:

 1)      No DOUBLE PRECISION or COMPLEX types.
 2)      No ASSIGN # TO var statement.
 3)      No ASSIGNed GO-TO statement.
 4)      No L,T,P,G,D format specs.
 5)      No '0' or '+' format controls.
 6)      No binary or random-access Input/Output.
 7)      No BACKSPACE, REWIND, or ENDFILE.
 8)      No labeled or numbered COMMON.
 9)      No BLOCK DATA subprograms.
 10)     No EXTERNAL statement or routine name as a parameter.
 11)     No multiple equivalencing.
 12)     No 3-dimensional arrays.
 13)     No variable dimensions in subprograms.
 14)     No arithmetic statement functions.
 15)     No overlays (except thru CHAIN).







                                  -11-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


 Error Messages.

     In  addition  to  the  standard  set of FORTRAN II compiler error
 messages, FORTX includes the following error messages:

 TYPE CONFLICT           A variable was declared twice.

 STRING TOO LONG         A hollerith constant exceeded 256 characters.

 STRING TOO SHORT        The end of statement was found before the 'H'
                         character count was satisfied.

 TOO MANY STRINGS        Over 128 long strings were encountered.

 INVALID DATA STATEMENT  Syntax error in DATA statement, or
                         incompatible types.

 INVALID ORDERING        The statements were not ordered properly.
                         See 'Restrictions' section for proper order.

 INVALID NESTING         Improperly nested DO, WHILE, or IF's.

 MISSING END's           At least one IF, WHILE, or DO did not
                         have its corresponding closing ENDIF,
                         ENDWHILE, ENDDO, or Statement #.

 DOUBLY DEFINED LABEL    The statement number was encountered before.

 UNDEFINED LABEL         The statement number was not defined.

 Installation.

     Installing FORTX in the system consists of copying the  compiler,
 its  library,  and  its error diagnosis program to device SYS: . This
 can be done by placing the FORTX  distribution  floppy  in  RX01  and
 typing:

         .COPY SYS:<RX01:FORT.SV,DIAG.SV,LIB8.RL

     FORTX  is  now  installed. To run it, follow the instructions for
 running OS/8 Fortran II given in the  OS/8  Handbook.  The  following
 options  are  defined in addition to the standard Fortran II and SABR
 options:

         Option          Action

         /C              Turn off array bounds checking.
         /D              Compile statements with C$ in cols. 1 and 2.
         /T              Turn off error traceback generation.
         /V              Print the version number of FORTX.


 Installation Notes

     If the system uses a nonstandard LIB8.RL  then  do  not  use  the
 LIB8.RL from the distribution floppy, but use LIBSET to add the files
 ERROR.RL  and  SUBS.RL  to  the  end  of  your special library. These
 routines are needed  to  properly  do  run-time  error  checking  and


                                  -12-


      FORTX : Extended FORT II Compiler       [ Version 1.2 ] 24-Jun-78


 traceback.

     DIAG.SV should remain on the system device as it is automatically
 called to diagnose FORTRAN run-time errors. If DIAG.SV is not on SYS:
 then the standard cryptic error message will be generated.


 Bugs.

     There  are  no  known 'bugs' in FORTX Version 1.2. This is not to
 imply that none exist. Problems with FORTX should be reported to:

         GEORGE GONZALEZ
         HEARING RESEARCH LAB
         2630 UNIVERSITY AVENUE
         MINNEAPOLIS, MINN. 55414

     All reasonable problems will be investigated.










































                                  -13-



Feel free to contact me, David Gesswein djg@pdp8online.com with any questions, comments on the web site, or if you have related equipment, documentation, software etc. you are willing to part with.  I am interested in anything PDP-8 related, computers, peripherals used with them, DEC or third party, or documentation. 

PDP-8 Home Page   PDP-8 Site Map   PDP-8 Site Search