Lecture 5 – September 11, 2007

 

We talked about the first FORTRAN programs and we compiled code that had compilation errors to see how to correct them.

Both the erroneous code and the fixed code have been posted.

 

Reminder:  code submitted should NOT be zipped and shouldn’t be in drop box

 

Things we forgot:

·         We forgot to declare the array in the function

·         We used a real for the size of the array in the function,  and the size of an array should be an integer

·         We set ANSWER by assigning a value to it, but we never used it elsewhere in the program.  We didn’t use it in a computation, nor did we print it.

·         We picked variable names that defaulted to real when we wanted them to be integer

·         We misspelled one of our variable names calling the array  ANARRAY in the function header and ANNARRAY   inside a DO loop.

·         We found these things out because the Force compiler told us about them.

YOUR GOALS ARE

·         TO HAVE NO HITS AND NO ERRORS  WHEN YOUR PROGRAM COMPILES

·         TO PRODUCE THE CORRECT ANSWERS USING DESIRED FORMAT

 

We discussed the grade sheet used for the first FORTRAN program and it has been posted.

We looked at Mike Garrett’s example of how to compile subprograms separately in Force and it has been posted.

We looked at some of the text book’s chapter 3 slides – and they have been posted

We discussed the elements of a grammar: 

·         set of non-terminals

·         set of terminals

·         set of productions (or rules)

  • start (or goal symbol)

BNF is an example of a context-free grammar

Handed out yellow sheet with mini-language Core developed by Ledgard and Marcotty on it.

·         non-terminals were enclosed in angle brackets  <     >

·         terminals were not

·         program was the start symbol

·         A metalanguage is a language used to describe a language

·         ::= replaced the à  in the BNF grammar on the yellow sheet

·         the vertical bar | means or

·         We discussed (listed) the elements on the yellow sheets that were neither terminals nor non-terminals (i.e. the ones that would have been bolded if they had been included in the slides: 

o        words such as: program  begin  end  if  then 

o        symbols such as:  :=   ,     +  -   _  *  ;

 

We looked at the syntax diagrams on the yellow sheets which were used by Wirth  to describe Pascal but are used here to describe mini-language Core.

We discussed the five (5) basic statements that every programming language MUST have

·         assignment statement

·         if statement (selection)

·         loop statement (iteration)

·         input statement

·         output statement

 

We looked at the last page on the yellow sheets and saw an alternate way of describing the syntax using

·         [         ]  to mean optional inclusion

·            to mean repetition

·          {        }   to mean 0, 1 or many inclusions

 

The following URL (already in the list of useful URLs talks about changes between FORTRAN77 and 90.

 

 

Below is a diagram of the data types in the Ada programming language which clarifies the

distinction between composite and non-composite data types.  Not all of these types are

available in FORTRAN 77.  Note that because there are no pointers in FORTRAN77,  I chose

to use the terms composite and scalar when  atomic and  composite would have been a better choice.