Scor­pio News

  

January–March 1987, Volume 1, Issue 1











Page 14 of 63











DATA statement

This is not the the DATA statement in a BASIC program. The function in FORTRAN is to allow the programmer to set up initial valuer

program exccution occurs Por example, the valu

Could be initialised in this vay:

DATA PI/3.142/,BEANS/3.0/

Im each case the variabli

variable,

STATIANT ORDERING

Te te most tmportant, particularly with type declarations and array Gaclarations, ‘to ensure that these are put in in the correct sequence before ANY executable program statements,

‘A suitable order for most FORTRAN versions ie:

REAL INTEGER

DOUBLE PRECISION LoctCAL DIMENSION Common

EXTERNAL EQUIVALENCE DATA

+ (executable statements) xD

This applies co both main program and all subroutine will

be required for most progcame (hank goodne

SUBBOUTINES and FURCTIONS

These ai They do not occur in precisely the the GOSUB- RETURN statements have BASIC uses PROCeduces which are difference between SUBROUTINES them, the SUBROUTINE is CALLed by name u progeam statements contained in it have been processed, control fothe gain program by means of a RETURN statement. Typical Subroutine are where a series of tables have to be set up OF where graphical Gata has to be displayed or a complicated expression has to be evaluated FUNCTIONs ‘are used differently. The function name appears as one of the Variables in an assignment statement and the value af the function (at Eaiculated) le used in the evaluation of the assignment. For example, 1f the Value of pi is required for some calculations involving the area oF Circumference of a circle and the version of FORTRAN you are using does not supply this as one of ite intrinsic functions, then a FUNCTION subprogcam could bevwritten to provide it (only « dodo would actually do this but itis good Slugaereeton!}

program sub-units which are called by the main program as required form in mort versione of

FUNCTION Fr © PROVIDES THE VALUE OF PI AS REQUIRED Pes. 14159 RETURN END


This is an OCR’d version of the scanned page and likely contains recognition errors.











Page 14 of 63