J3/01-396 Date: 2001 December 5 To: J3 From: Walt Brainerd Subject: Program Concepts I think there are some problems with the descriptions of these concepts. Background: The standard distinguishes between the text of a program (e.g., program unit and subprogram) and the process (e.g., procedure) it defines. In olden days, there was “executable program” to contrast with “program”. [ ... execute the executable program ! ] Problem 1: Currently, a main program is a program unit, so it cannot be anything except Fortran source. I have heard we would like to have C main programs. Problem 2: The current wording confuses these two things. A program is like lunch at a Chinese restaurant: some from column A and some from column B: 2.2.1: “A program consists of ... program units and ... external procedures ...” Problem 3: Sometimes a text (program unit) gets executed; sometimes a procedure gets executed. Here is what we have now: Program units (Fortran source text) nonFortran source main program ? ??? ? C main? function subprogram ? function ? ??? subroutine subprogram ? subroutine ? ??? Proposal: Call the ??? in the main program line “main”, by analogy with the other two. Proposal: Allow a C (companion) program to define a main. Proposal: A program is made up of procedures, not text (exectable program). Proposal: A program (and its procedures) are executed, with the understanding that “executing the third statement in a subprogram” is shorthand for “executing the part of the procedure that corresponds to the third statement”. Here are some of the changes that might be made. If we decide to do this, I'll make an attempt to find more (the Glossary is another place that needs fixing). 1.5,line 2: “2.2.1” ? “2.2” 1.5, line 2: “it” ? “each component defined by a Fortran program unit (2.2.1) ” [ Or does the description of the requirements on nonFortran procedures constitute a “relationship” described in the standard? ] [ Need to say something about the conformance of the other stuff (companion processor)? ] [ This sentence seems to be pretty important to get right! ] R201: “program” ? “fortran-program” [ It doesn't allow for anything nonFortran. ] 2.2,lines 1,2 Replace with: “2.2 Program concepts A program consists of exactly one main and any number (including zero) of procedures. A Fortran program is a program defined exclusively by Fortran program units. [ Put Note 2.2 here. ] 2.2.1.Program unit A program unit may be a” 2.2.1: Delete 2.2.2: Replace with: 2.2.2Main [ Maine ? ] The main encapsulates an arbitrary sequence of actions that is invoked when execution of the program begins. The main may be defined by a main program (11.1) or a companion processor (2.5.10). 2.2.3.1,line 2: “main program” ? “main” 2.3.4,Add after first sentence: “If the main is defined by a companion processor, execution is begun by the companion processor.” [ This case not covered currently. ] 11.1,line 4-: “main program“ ? “main” [ A main program is Fortran! ] 11.1,lines 4-,3-: Delete “; in that case, ... program-unit.” [ Already said you can't have more than one main, and a program does not contain a program unit. ]