Minutes of the BCS Fortran Specialist Group Meeting

    held at BCS HQ, 13 Mansfield Street, London

on 7 February 1991


Present:   David Bailey         Salford University

           Stephen Brazier      Oscar Faber Partnership

           Robert Chafer        Salford University

           Peter Edwards        CAD Centre Ltd

           Miles Ellis          Oxford University

           Mike Geary           NAG

           E Golton             RAL

           Carol Hewlett        LSE

           Peter Holland        SSL

           David Holmes         Rolls-Royce plc

           M J Roth             AEA Technology

           Les Russell          AWE

           Lindsey Savage       MCC

           Nick Saville         Private Consultant

           Tony Webster         Salford University

           John Wilson          Leicester University

           John Young           PE-MOD


1.      APOLOGIES FOR ABSENCE


        The Chairman, John Wilson, opened the meeting late with

apologies from himself and the Secretary, John Young, for their

late arrival due to the adverse weather conditions affecting

British Rail.


        Apologies for absence were received from Chris Lazou, Brian

Meek, David Muxworthy, John Reid, Lawrie Schonfelder and Dave

Vallance who was due to introduce the afternoon session.


2.      MINUTES OF THE LAST TWO MEETINGS


[The following points relate to the minutes of 25 October 1990.]


        On page 4 the date of the talk on FORCHECK by Erik Kruyt

should have read 6 December 1990.


        On page 3 several points should be corrected on the summary

in the Report from the X3J3 Representative. These corrections

will be included in the next minutes.


3.      MATTERS ARISING


        The paper on 'Dynamic Strings in ISO Fortran' by Lawrie

Schonfelder and J S Morgan was published recently in 'Software

Practice and Experience'.


        Mike Ellis confirmed that nobody was interested in joining

DISC, the BSI initiative to create a group to formally approve

programming languages. Minor changes to the Report on DISC had

not improved the situation to any large extent.


        It was noted that there had been no official move to

transfer this formal task to the BCS and that if it did happen

the Group would obviously be responsible for Fortran only.


4.      REPORT ON X3J3 AND ISO ACTIVITIES


        The ISO ballot on the Draft Fortran 90 Standard was nearly

completed. The UK vote had apparently gone missing but would be

YES, the US had also voted YES, but Japan had voted NO. The

Canadian vote had a long list of comments which were all

editorial changes.


        The next WG5 meeting was in London in mid-March. At the end

of this meeting there should be a final agreement on the document

which would be ready for type-setting and the ISO bureaucracy.


        The X3J3 Committee met just before Christmas with only about

half the members attending. The American public review had a

small response which generated a set of amendments. However, the

meeting accepted the Draft Standards with editorial changes


        The next meeting of X3J3 was scheduled for early April in

Minneapolis but there were problems with travel. WG5 were likely

to "tell" X3J3 that the current Draft Standard is the final

document. However, there were minor technical problems to be

sorted out and a large number of editorial changes to be made.

Then the new International Standard for Fortran 90 should be

ready for publication.


        As to the future, WG5 will possibly debate the way the next

Standard will be implemented. Current books on Fortran 90 are

likely not to contain the full standard. The full standard can

be obtained through the BSI when it is available. A short

discussion on various aspects of Fortran ensued.


        There then followed a general discussion on the new

standard.


5.      PROGRAMME


        WG5/IST5 Reception at BSI


        The meeting noted the item in the February Newsletter on the

21st Birthday Celebrations proposed by Brian Meek. The meeting

endorsed the idea of FSG members joining in the WG5-IST/5

Reception on Tuesday, 19 March, 1991. Following discussion of

the event and the finances of the Group it was agreed that up to

£100 would be donated towards the costs of the Reception. John

Wilson was to contact Brian Meek about this event.


        Annual General Meeting


        The Annual General Meeting would take place on Thursday, 16

May, 1991 at 2 pm. (There will be normal business in the

morning). This will be followed by a report and a debate on

Fortran 90. The Secretary was asked to include a nomination form

for the 1991/92 Committee in the next mailing.


        Proposed visit to Jodrell Bank


        The provisional date for this meeting is Thursday, 5

September 1991.


        November Meeting


        The last meeting of 1991 will be on Thursday, 28 November,

probably at BCS in London. Mike Nunn has offered to organise a

buffet lunch if there are sufficient members interested.


6.      ANY OTHER BUSINESS


        Cutback of printing services at BCS


        The Chairman, John Wilson, had received a letter from the

BCS Services Director, Tim Hackworth, detailing staff cutbacks

at BCS. The main item affecting the Group is the curtailment of

in-house printing which means that urgent mailings would no

longer be possible.


        BISL Conference Organisation


        The Chairman had received information from the British

Informatics Society Ltd (BISL), the commercial "arm" of the BCS,

about arranging conferences for Specialist Groups.


        BCS Distinguished and Honorary Fellowships and BCS Medals


        John Wilson had received details and a form for nominating

people for Distinguished and Honorary Fellowships, and Medals.

The closing date for recommendations is Friday, 31 May, 1991.


        Committee for 1991/92


        The Chairman, John Wilson, confirmed that he would be

standing down at the AGM. The Secretary, John Young, said he

would stand down if somebody would like to take over this year

but would have to stand down next year. There followed a

discussion on the role of the Secretary. It was suggested that

the job could possibly be split into Secretary and Minute

Secretary.


7.      WORKSHOP ON COMPILERS FOR FORTRAN


        The afternoon session was to be introduced by Dave Vallance

of Salford Software Marketing Ltd. Dave was unable to attend the

meeting but his colleagues David Bailey, Tony Webster and Robert

Chafer were able to come. Tony Webster introduced the subject

of 'Compilers for Fortran' and then talked on aspects of Fortran

90 compilers (see Appendix A1). David Bailey then talked on

compilers in general and the Salford FTN77 in particular (see

Appendix A2).


John Young, Secretary

21 March 1991




  APPENDIX A1

      FORTRAN 90 - IMPLEMENTATION ISSUES

  BY

TONY WEBSTER


slide 1

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


FORTRAN 90 - implementation issues




slide 2

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

Key differences from FORTRAN 77



slide 3

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

Dynamic storage



                C = CFUNC(C1//'ABC')

                where C1 is CHARACTER*(*)


slide 4

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

Derived types



                TYPE ARRAYS

                        REAL, DlMENSlON(10,10) :: A

                        REAL, DlMENS|ON(20) :: B

                END TYPE ARRAYS


                TYPE(ARRAYS), DlMENSlON(10,20) :: ARR

        Then

                        ARR( : , 15 )


        is a vector with 10 elements of type ARRAYS,

        with a stride of 120 real storage units


slide 5

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

      Example


            Discrete solution of Laplace's equation


discretisation diagram


slide 6

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


FORTRAN 90:


        A =  (EOSHIFT(A,1,DIM=1) + EOSHIFT(A,-1,DIM=1)

             + EOSHIFT(A,1,DIM=2) + EOSHIFT(A,-1,DIM=2)



FORTRAN 77:


                REAL A(0:N+1,0:N+1), TEMP(N), T

                DO 10 J = 1,N

                        TEMP(J) = A(0,J)

        10     CONTINUE

                DO 20 I = 1,N

                        DO 30 J = 1,N

                                T = A(I,J)

                                A(I,J) = ( TEMP(J) + A(I,J-1) + A(I,J+1) + A(I+1,J) ) / 4

                                TEMP(J) = T

        30            CONTINUE

        20    CONTINUE


slide 7

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

Modules



slide 8

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

The forward reference problem


MODULE MOD

CONTAINS

        SUBROUTINE A

                . . .

                CALL B (X = 1.23 )

                Y = SlN( 0.456 )

                . . .

        END SUBROUTINE A


        SUBROUTINE B(X,Y)

                REAL :: X

                REAL, OPTIONAL Y

        END SUBROUTINE B

END MODULE MOD


slide 9

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

Generic names (1)


The non-module case:


INTERFACE MAX


        INTEGER FUNCTION INT_MAX(I, J)

                INTEGER, INTENT(IN) :: I, J

        END FUNCTION INT_MAX


        REAL FUNCTION REAL_MAXIX, Y)

                REAL, INTENT(IN) :: X, Y

        END FUNCTION REAL_MAX

END INTERFACE


slide 10

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

Generic names (2)


Module case - another forward reference example:


MODULE MOD


        INTERFACE MAX

                MODULE PROCEDURE INT_MAX, REAL_MAX

        END INTERFACE


CONTAINS

        . . .

        INTEGER FUNCTION INT_MAX(I, J)

                INTEGER, INTENT(IN) :: I, J

        END FUNCTION INT_MAX


        INTEGER FUNCTION REAL_MAX(X,

                REAL, INTENT(IN) :: X, Y

        END FUNCTION REAL_MAX

END MODULE MOD


slide 11

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

Generic names (3)


The old version (S8.104):


INTERFACE

        INTEGER FUNCTION MAX(I, J)

        INTEGER, INTENT(IN) :: I, J

END INTERFACE


INTERFACE

        REAL FUNCTION MAX(X, Y)

        REAL, INTENT(IN) :: X, Y

END INTERFACE


slide 12

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

Kurt's paradox


Optionality of arguments to certain intrinsics controls rank of result


- cannot generate code till run-time


SUBROUTINE SUB1(DIM)

INTEGER, OPTIONAL :: DIM

INTEGER A(100,100), B(2)


INTERFACE OPERATOR(.XX.)

        FUNCTION F1(ARG1, ARG2)

                INTEGER ARG1, ARG2, F1

        END FUNCTION F1


        FUNCTION F2(ARG1, ARG2)

                INTEGER ARG1(:), ARG2, F2(2)

        END FUNCTION F2

END INTERFACE


B = LBOUND(A, DIM) * 10


B = LBOUND(A, DIM) .XX. 99


slide 13

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

Performance


Will you pay a penalty for using a FORTRAN 90 compiler to compile FORTRAN 77?



But you may pay a penalty for starting to exploit FORTRAN 90 syntax - e.g. assumed

shape arrays


slide 14

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

Other areas

lntrinsics


        No particular difficulties, but many of them


l/O


        Some new concepts (e.g. non- advancing l/O)

        No real problems on modern O/S


Control structures


New syntactic variety, but no real problems


slide 15

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

Run-time checking



slide 16

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

Implementation effort


The problems are not in the individual features but in interactions and the sheer volume.


Estimates by several well-known implementors range from 10 man-years to 30 man-years

(DEC ADA took 25 man-years)


Will compilers be expensive as a result?



slide 17

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




  APPENDIX A2

   COMPILERS FOR FORTRAN

          THE SALFORD FTN77

     BY

  DAVID BAILEY


slide 1

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

Salford FTN77 (1)

Philosophy:



slide 2

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

Salford FTN77 (2)



FTN77 implementations (in chronological order):


ICL 1900 series

Prime 50-series

MS-DOS 886/486

UNIX 386/486


slide 3

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

  Structure of a compiler



structure diagram


slide 4

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

Lexical analysis (1)

FORTRAN 77 -



        e.g. - the Mariner example:


        DO 56  I = 1 , 20                        - DO loop


        DO 56  l = 1 . 20                         - assignment


slide 5

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

Lexical analysis (2)


The FTN77 approach -


        - Comma at level 0 w.r.t. brackets & quotes

         See previous example

        - Equals "=" at level 0 w.r.t. brackets & quotes

         Assumed to be assignment

        - Letter at zero level following right bracket

         To distinguish between:

                lF(...)J=2        logical IF statement

                lF(...)=2        array element assignment


slide 6

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

  Parsing


Operator precedence used for expressions, everything else done ad-hoc


FTN77 creates n-ary trees - nodes are then sorted



Common subexpressions give directed graphs rather than trees


slide 7

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

 Parsing - example


             X= F(X+2+Y+1) + G(4+Y+X-1)


parsing diagram



slide 8

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

Forward references


Routine calls fixed up by linker


References to labels



slide 9

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

Code generation



slide 10

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

Checking options (1)


FORTRAN 77 has a reputation as an uncheckable language - but it is possible to check almost

everything!



slide 11

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

Checking options (2)


Other checks include:



These options find bugs in most programs (even the FIPS validation suite)


Work is proceeding for other languages to extend these techniques to pointers


slide 12

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

    Porting (1)


Features to help with porting FORTRAN 66 codes, both to let it run as-is and to fix it:



slide 13

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

    Porting (2)


Many popular extensions to allow non-standard code to run unmodified



slide 14

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

Optimisation (1)


Tree-level optimisation:


Concentrate on loops

"Candidate expressions" - either independent of, or linear in, the loop variable (loop

invariants and induction expressions)


                DO 10 l = 1,N                                        I1 = J+K

                     A(l) = J+K                      =>               |2 = -5

                    B(l) = 2*l - 7                                      DO 10 l = 1,N

         10  CONTINUE                                                 A(l) = l1

                                                                                   B(l) = l2

                                                                                   |2 = |2+2

                                                                       10 CONTINUE


slide 15

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

Optimisation (2)


"Peep-hole" optimisation:



slide 16

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

Target architecture


Approach is modified by the intended target machine



slide 17

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

Other activities



slide 18

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