Scor­pio News


January–March 1987, Volume 1, Issue 1

Page 15 of 63

‘The form of the FUNCTION statement is as follows:

FUNCTION name (dummy arguments – if needed)

or, more explicitly. type FUNCTION neme (dummy arguments)

The reason for the second form is that the type can be explicitly declared a INTEGER, REAL, DOUBLE PRECTSTON, LOGICAL or (In Profortran) COMPLEX. Thus, if che function required was called LENGTH and it was a REAL number rather than sn INTEGER, the correct form for the FUNCTION subprogram which gave the single value for LENGTH would


The same rule applies {f the function name is one which by default would bea REAL If an INTEGER value was required Por example:



In all high-level languages, there is a range of particular functions for which the necessary code ie supplied – such as INT or ANG in BASIC. These are termed Intrinsic functions and afe called by name to produce « particular velue. There ire rather gore intrinsic functions in FORTRAN than will be found in most, BASICS ince some are available in integer, real and double precision forms There is Alvays » list of these in the documentation associated with the version of FORTRAN ‘you are using. Some old favourites Like CHRS and LEFTS ere never found in FORTRAN, othere are spelt differently = SIGN rather than SGN – but most are readily interpreted


Again, these have their counterparts in BASIC although many are available in Goubis precision or even complex number forms in addition to the conventional Feal number form – typical of these are the etigonometric functions, SIM, 00S OF TAN, and Sgat spelt differently to the BASIC way (SQR). There is 10g base © (ALG) ‘and log base 10 <ALOGIO) and a random number generator – variously spelt BND or RAND, ‘A’list of these will also be found in the documentation, together with a Llse of restrictions on the type of variable with which they can be used “thus i8’you want the equare root of # variable {t must be of type real of Gouble precision and if it ta an integer, this must be converted to eal by the vse of & cunning Litele intrinsic function called FLOAT. Failure co do th: First will lead to an execution error and the progran grinding to an unprofitable halt An external function called TPIK dees just that to REAL hunbers, converting thes to INTEGER type.

DATA Inpor /oozPoT

on fizet acquaintance, this appears co be rather more complicated than in BASIC, but it is a great deel more flexible. Data to be read into or results output fron s progtam can dein alaoat any desired form provided the machine is properly instructed by meant of t FORMAT statement. Data is read in from either Keyboard or disk file uring @ READ statement and written to the screen, disk Eile’oe peincer by means of WRITE statement in their beste form these a follows:

READ (uf) k of © WRITE (u,) k

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

Page 15 of 63