Scorpio News |
January–March 1987 – Volume 1. Issue 1. |
Page 20 of 63 |
---|
This command also stops the execution of the program. It either takes the form:
PAUSE or PAUSE (string of 1 – 6 characters)
The characters, if present are displayed as before and program execution can be resumed if needed by typing any character other than ‘T” – which terminates the program at that point. This statement should be used with care since not all Fortran compilers support it in precisely this fashion.
This statement transfers control into subroutines and provides parameters for use by the subroutine. It has the general form:
CALL subroutine name (dummy arguments)
Dummy arguments are values of expression which need to be transferred from the CALLing program to the subroutine so that it can work properly. A more detailed explanation it given in Alcock (pp 68-69) or in the Microsoft F-80, NFortran or ProFortran documentation.
These are always used when control is to be passed back from the subroutine to the CALLing program.
These provide a means for executing series of statements repetitively, just in the FOR – NEXT loop in BASIC. The DO statement takes the following form:
DO J K=M1,M2,M3 | – or, where M3 is 1, it may be omitted [J is a statement label, K is an integer or variable and M1, M2 end M3 are integer constants or integer or variables] |
A typical example might be:
DO 14 I=1,5 . . (a series of executable statements) . 14 PROD=PROD + A(I) WRITE(5,100) PROD 200 FORMAT(F6.3)
in which the program executes the DO loop five times (as I goes from 1 to 5) before writing out the result. The statement label J must actually occur and it must not be a STOP, PAUSE, RETURN, arithmetic IF, GOTO or another DO. The controlling index K must be an integer and always positive: M3 is the increment thus if the first line of the DO loop was replaced by:
DO 14 I=1,9,2
successive loops would increment the value of I by 2 (1,3,5,7,9) rather than singly: this is analogous to the STEP statement in BASIC and some versions of Pascal. DO loops can be nested so that one or more may exist within the range of a larger loop but these nested loops must terminate inside the main loop. Other features of DO loops are noted in the Microsoft or Prospero reference manuals.
Page 20 of 63 |
---|