Home

HEP PARALLEL FORTRAN USER`S MANUAL

image

Contents

1. EQ and NE only Relational operators have lower precedence than arithmetic operators 22 Logical Operators The logical operators are NOT AND and OR denoting respectively logical negation logical multiplication and logical addition The enclosing periods are part of the operators and must be present The logical operators are defined as follows where P and Q are logical expressions NOT P true f P is false false if P is true P AND Q true if P and Q are both true otherwise false P OR 0 false if P and Q are both false otherwise true A logical expression may consist of a single logical element For example TRUE BOOL N X GE 3 14159 Single elements ma y be combined through use of the logical operators AND and OR to form compound expressions such as TVAL AND INDEX BOOL M OR K EQ LIMIT 38 Any logical expression may be preceded by the operator NOT as in NOT T NOT X 7 GT Y 2Z BOOL K AND NOT TVAL OR R By repeated use of these rules all permissible logical expressions may be formed When the precedence of operation is not given by parentheses it is understood to be the following in decreasing order of precedence OPERATOR OPERATION NOT logical negation AND logical multiplication OR logical addition Thus the expression T AND NOT S OR NOT P AND R is interpreted T AND NOT S OR NOT P AND R 4 3 Summary of Operator Precedence
2. could be used to output the line 32 17 60 5 9625478777541E03 on the output listing The type of conversion used should correspond to the type of the variable in the input output list I conversion is used for integer type variables and E F or G conversion is used for real type variables There is no format conversion for double precision variables 675 The decimal fixed point number type F has a decimal point but no exponent whereas the decimal floating point type E has an exponent On output the exponent always has the form shown i e an E followed by a signed two digit integer On input however the E or the sign or the entire exponent may be omitted on the external form For example the following are all valid El5 6 fields 317250 2 317250E2 042739 45 31064 The field width w includes all of the characters decimal point signs blanks etc which comprise the number If a number is too long for its specified field the excess characters are lost Since numbers are right justified in their fields the loss is from the most significant part of the number During input the appearance of a decimal point in an E or F type number overrFides the d specification of the field In the absence of an explicit decimal point the point is positioned d places from the right of the field not counting the exponent if present For example a number with external appearance 271828E 1 and specification El
3. 3 The types of the right and left hand sides di an assign ment are improper UNDIMENSIONED A simple variable is followed by a left parenthesis UNRECOGNIZABLE The entire statement was unrecognizable UNSUCCESSFUL COPY A COPY statment could not be performed B 3 Program Error Diagnostics After the source program has been listed summary error messages pertaining to the program as a whole are listed The following describes each of these messages or set of messages FUNCTION NAME NOT REFERENCED This message appears at the end of any FUNCTION subprogram in which the function name does not appear on the left hand side of an assignment statement 90 OPEN DO LOOPS Following this heading all DO loops which were not closed are listed in the form statement number OPENED AT LINE line number UNDEFINED LABELS All undefined statement numbers are listed after this heading Each undefined statement number appears as statement number FIRST REFERENCED AT LINE line number ALLOCATION ERRORS This heading is followed by a list of identifiers that were incorrectly assigned memory locations by the program These errors are caused by COMMON and or EQUIVALENCE statements Such errores as EQUIVALENCE statement references variables for different COMMON blocks Extending a COMMON block backward Specifying an impossible equivalence group 91 APPENDIX C COMPILER OPTIONS C 1 Introduction The following
4. 6 2 GO TO Statements GO TO statements unconditionally transfer control from one part of the program to another There are three forms of the GO TO statement unconditional computed and assigned 6 2 1 Unconditional GO TO Statement FORM GO TO n where n is a statement number ab This statement transfers control to the statement num bered n EXAMPLE GO TO 345 6 2 2 Computed GO TO Statement FORM GO TO n n k variable where nn i sese Mg are statement number The variable must be of integer type The statement transfers control to the statement numbered DjsM r o o if the variable has the value 1 2 k re spectively Values outside the range 1 through k cause transfer of control to the following statement The comma preceding the variable may be omitted EXAMPLES GO TO 22 3 7 SWITCH GO TO 1 2 62 78 Y 6 2 3 Assigned GO TO Statements FORMS GO TO variable GO TO variable n n O where Aj gy are statement numbers The second form is allowed for compatibility only the labels Nj Mg are not used The comma following the variable may be omitted The variable must be a scalar of integer type and must not be 245 an asynchronous variable This statement transfers control to the statement whose number was last assigned to the variable The assignment must take place in a previously executed ASSIGN statement The variable is a control variable having a lab
5. When the precedence of operators is not given explicitly by parentheses it is understood to be as follows in order of decreasing precedence 39 OPERATOR OPERATION 4k exponential multiply divide add subtract negate JOT e A A LE EQ NE relational NOT logical negation AND logical multiply OR logical add For example the logical expression NOT ZETA 2 Y MASS GT K 2 OR PARITY AND X EQ Y is interpreted NOT ZETA 2 Y MASS GT K 2 OR PARITY AND X EQ Y SOS SECTION V ASSIGNMENT STATEMENTS de Introduction Assignment statements are the basic executable statements of the FORTRAN language Two types of assignment state ments are available arithmetic and ngical e an cae Arithmetic Assignment Statement The arithmetic assignment statement specifies an arithmetic expression to be evaluated and a variable to which the expression value is to be assigned FORM variable expression The character is an operational symbol signifying replacement not equality Thus the first example below means take the current value of Y double it and assign the result to Y EXAMPLES Y 2 Y A A X N N ZETA ALPHA M P1 1 0 1 0 Type conversion is provided if the variable is of a type different from the expression Da 2 Mixed Type Assignment Mixed type assignment involves arithmetic assignment state ments in which the type of the expression on the
6. Column 1 Conditional Compilation All source lines with the character D in column one are compiled as ordinary source statements when the compiler is run with the Conditional Compilation option selected When Conditional Compilation is not selected these lines are treated as comments 1 4 COPY Statement zi The copy feature enables parts of the program to be stored in more than one file This statement appears as follows COPY name where name is a file path name The name must be completely contained on one line not extended across continuation lines and must not contain blanks A program may contain any number of COPY statements but they must not be nested deeper than three The contents of the named file are inserted into the source program so that the first record of the file is the next line after the COPY statement Thus COPY statements may be labeled and referenced the same as CONTINUE statements A COPY statement must not precede Group 1 statements and must not follow a Group 6 statement ik SECTION II DATA 2 Introduction Data is represented as constants and variables A constant is a quantity whose value is explicitly stated a variable is a quantity whose value may change Each variable is referenced by an identifier that symbolically identifies the variable o 2 1 Identifiers Identifiers are used to give names to Variables Subprograms Common blocks An identifier is a string of alph
7. character after the dollar sign is used EXAMPLE IMPLICIT INTEGER A C X DOUBLE PRECISION D LOGICAL L This statement would cause the following implicit declarations to be in ef ect l Identifiers beginning with A B C I J K M N X are integer 2 Identifiers beginning with D are double precision 3 Identifiers beginning with L are logical 4 Identifiers beginning with E F G H O P Q R S T U V W Y Z are real 3 4 COMMON Statement FORM COMMON block list The COMMON statement specifies that certain variables or arrays are to be stored in an area also available to other programs By means of COMMON statements a program and its subprograms may share a common storage area This area is located in Data memory 2 3 The common area may be divided into separate blocks identified by block names A block is specified thus identifier identifier identifier identifier The identifier enclosed in slashes is the block name The identifiers which follow are the names of the variables or arrays assigned to the block These elements are placed in the block in the order in which they appear in the block specification The block list of the COMMON statement consists of a sequence of one or more block specifications For example the statement COMMON R X Y T C U V W Z indicates that the elements X Y and T in that order are to be placed in block R and that U V W Z are to be placed in
8. for exponentiation which is performed right to left EXAMPLES W X Y 7 is evaluated as W X Y 7 AR BrRx cC is evaluated as A B C 4 1 2 Evaluation of Mixed Type Expressions The value of an arithmetic expression may be of integer real double precision or complex type The type of the expression is determined by the types of its elements according to the rules which follow The arithmetic types are ranked as follows RANK TYPE 1 Integer 2 Real 3 Double 4 Complex e x The type of an expression is the type of the highest ranking element in the expression Each operation within an expression is evaluated in the type of the highest ranking operand Thus the evaluation of an expression is not changed to a higher rank until necessary EXAMPLE I J R DP C is evaluated as CMPLX FLOAT I J 0 CMPLX REAL DBLE R DP 0 C Integer expressions are evaluated using binary integer arithmetic throughout In integer arithmetic fractional parts arising in division are truncated not rounded For example 7 3 yields 2 3 7 yields 0 All other calculations use binary floating point arithmetic Conversions to higher rank are performed as follows 1 An integer quantity becomes the integer part of a real quantity The fractional part is zero 2 A real quantity becomes the most significant part of a double precision real quantity The least significant part is zero 3 A real quantity becomes the real part
9. found under the most logical assumption of statement type A comment specifying the reason for the failure is output directly after the marked line There may be more than one diagnostic per line The diagnostics are listed left to right Each diagnostic is followed by a sequence of characters E E E E or W W W W indicating error or warning respectively An alphabetic list of possible statement diagnostics follows ARGUMENT CONVERTED Warning The type of the indicated parameter for an intrinsic function was converted to agree with the type required by the function ARGUMENT COUNT Warning The number of parameters to a subprogram is wrong either because it is an intrinsic function which the compiler knows about or because the same subprogram was called previously with a different number of parameters BLOCK DATA ONLY A DATA statement not in a BLOCK DATA subprogram attempted to initialize a variable in COMMON An executable statement has been included in a BLOCK DATA subprogram 85 CONSTANT SIZE The size of the indicated constant is outside the allowable range DATA TYPE The type of a constant in a DATA statement does mot agree with the type of the variables it is to initialize DATA COUNT The number of variables in a DATA statement does not agree with the number of constants DECLARATION CONFLICT An attempt has been made to declare an identifier as a FORTRAN entity simple variable arr
10. that is transmitted to a listing device for printing is assumed to have a carriage control character as the first character of the record The carriage control character itself is not printed The carriage control characters are Character Function Before Printing blank Space one line 0 Space two lines 1 Skip to first line of next page any other character is treated as a blank EXAMPLE 10 FORMAT 9H1 PAGE 13 1H0 7 5 Auxiliary 1 0 Statements These statements are used to control the positioning and file marking of sequential files 66 7 5 1 REWIND Statement FORM REWIND u where u is an I O unit designation This statement directs the 1 0 unit designated to reposition to the first record u must not be an asynchronous variable EXAMPLES REWIND 2 REWIND K 7 5 2 BACKSPACE Statement FORM BACKSPACE u where u is an 1 0 unit designation This statement directs the I O unit designated to backspace one record u must not be an ansynchronous variable EXAMPLES BACKSPACE 5 BACKSPACE N B67 7 5 3 END FILE Statement FORM END FILE u where u is an 1 0 designation The statement directs the I O unit designated to write an end file mark u must not be an asynchronous variable EXAMPLE END FILE 4 END FILE T 68 SECTION VIII PROGRAM UNITS 8 Introduction A FORTRAN program consists of one main program and optionally SUBROUTINE subprograms FUNCTION subprograms and
11. the characters are packed eight per word The two forms on the left are equivalent and imply left justification with trailing blanks if necessary to pad n to a multiple of 8 The R and L forms indicate right and left justification respectively however these two forms indicate binary zero padding if necessary not blanks All characters including blanks are significant in the string The apostrophe may be included in an apostrophe delimited Hollerith con stant by using two consecutive apostrophes in the string EXAMPLES Storage Bi alefelefelelele ASCII e efafojojofo ojo ASCIT me Aleja ASCIT gt 15 Storage vector alalel jelelrle ASCII LRA 0000 0000 0000 0041 HEX 5LABCDE 4142 4344 4500 0000 HEX 2 4 7 Hexadecimal Constants Hexadecimal constants are written as follows X D D gt where the Di collectively represent a string of up to 16 hexadecimal digits 0 9 A F Internally hexadecimal constants are stored right justified in one word They are treated as integers within expressions EXAMPLES X FF X 000FF000 alos SECTION III SPECIFICATION STATEMENTS l Introduction Declarations are used to supply descriptive information about the program other than to specify computation or other action This descriptive information primarily concerns the interpretation of source program identifiers and object program storage allocation The following declaration stateme
12. the equivalence only the relative positions of the references are important In the examples below EQUIVALENCE BETA 1 ALPHA 7 or EQUIVALENCE BETA ALPHA 7 will do as well Note that the relation of equivalence is transitive e g the two statements EQUIVALENCE A B B C EQUIVALENCE A B C have the same effect 27 3 5 1 EQUIVALENCE and COMMON Identifiers may appear in both COMMON and EQUIVALENCE statements provided the following rules are observed No two quantities in common may be set equivalent to one another Quantities placed in a common block by means of equivalences may cause the end of the common block to be extended For example the statements COMMON R X Y Z DIMENSION A 4 EQUIVALENCE A Y causes the common block R to extend from X to A 4 arranged as follows X Y A 1 Z A 2 A 3 A 4 Equivalence statements which cause extension of the start of a common block are not allowed For example the sequence COMMON R X Y Z DIMENSION A 4 EQUIVALENCE X A 3 28 is not permitted since it required block R to be arranged A 1 A 2 X A 3 Y A 4 X A 1 and A 2 extend the start of block R 3 6 EXTERNAL Statement FORM EXTERNAL identifier identifier centifier This statement declares the listed identifiers to be subprogram names Any subprogram name given as an argument to another subprogram must appear in an EXTERNAL declaration in the calling pro
13. 1 62 62 63 63 64 64 64 66 66 67 67 68 69 69 69 69 70 70 70 71 71 72 73 73 CONTENTS Continued Page SECTION VIIT Continued 8 7 2 FUNCTION Type 74 8 7 3 Library Functions 75 8 8 SUBROUTINE Subprograms 73 8 8 1 SUBROUTINE Statement 75 8 8 2 CALL Statements 76 8 8 3 CREATE Statement 17 APPENDIX A LIBRARY FUNCTIONS 78 APPENDIX 8 FORTRAN LISTING FORMAT 83 APPENDIX C COMPILER OPTIONS 92 APPENDIX D FORTRAN RUNTIME LIBRARY 93 PREFACE This manual contains the user s instructions for the FORTRAN compiler associated with the Heterogeneous Element Processor HEP It is directed to the FORTRAN programmer and the programming staff responsible for main taining the compiler Its purpose is to explain the HEP version of the FORTRAN language the various inputs and outputs of the compiler and to give some examples SECTION I FORTRAN SOURCE PROGRAM FORM l1 Introduction A FORTRAN source program consists of one main program and any number of subprograms The main program and subprograms are made up of statements using the FORTRAN character set 1 1 Character Set The character set has two subsets alphanumeric characters and special characters ALPHANUMERIC CHARACTERS Letters A Z and Digits 0 9 SPECIAL CHARACTERS Blank Equals Plus Minus Asterisk Slash Left parenthesis Right parenthesis Comma Decimal point Dollar sign Apostrophe single quote Blanks
14. 2 5 is interpreted as 2 71828E 1 7 4 2 Scale Factors Scale factors may be specified for E and F type conversions A scale factor is written nP where P is the identifying character and n is a signed or unsigned integer specifying the scale factor For F type conversion the scale factor speciiies a power of ten such that external number internal number power of ten 58 For E type conversions the scale factor multiplies the number by a power of ten but the exponent is changed accordingly leaving the number un changed except in form For example if the statement FORMAT F8 3 E16 5 corresponds to the line 26 451 4 1321E 02 the the statement FORMAT 1PF8 3 1PE16 5 corresponds to the line 2 645 41 32100E 03 The default scale factor is 0 However once a scale factor is given it holds for all following E and F type conversions within the same format The scale factor is reset to zero by giving a scale factor of zero Scale factors have no effect on I conversions Output under control of a G field is dependent on the magnitude of the floating point number being converted Where m represents the magnitude of the number the following table shows the relationship between m and the conversion field to be used 59 Magnitude Conversion Field 0 1 lt m lt 1 F w 4 d 4X 1 lt m lt 10 F w 4 d 1 4X 102101 F w 4 1 4X 1071 lt m lt 10 F w 4 0 4X m lt l or m gt 10 sEw d s is the current scale f
15. 3 Formal parameters must not appear in DATA statements 8 5 3 Correspondence Between Actual and Formal Parameters When a subprogram is called the formal parameters must agree with the actual parameters as to number order type and length For example if an actual parameter is an integer constant then the corresponding formal parameter must be of INTEGER type Also the formal and actual parameters must be either both synchronous or both asynchronous they must not be mixed 271s If a formal parameter is an array name the corresponding actual parameter may be either an array name or an array element If a formal parameter is assigned a value in the subprogram the corres ponding actual parameter must be a simple variable array element or array name A constant or expression should not be used as an actual parameter if the corresponding formal parameter may be assigned a value e 8 6 Statement Function Definition Statement FORM identifier identifier identifier expression This statement defines an internal subprogram The entire definition is contained in a single statement The first identifier is the name of the subprogram being defined Statement function subprograms are functions they are single value and must have at least one argument The type of the function is determined by the type of the function identifier The identifiers enclosed in parentheses represent the arguments of the function The
16. 5 61E2 4 32E1 specifies 5 values for the array A the value 6100 for A 1 and the value 320 for A 2 through A 5 P When an unsubscripted array name is included in the variable list it implies that all elements of the array are to be initialized It is equivalent to writing out all elements of the array in sequence EXAMPLE The above example could be written DIMENSION A 5 DATA A 61E2 4 32E1 The form of the constant rather than the type of the variable determines the data type of the stored constant Hollerith constants or alphanumeric strings are treated specially in the DATA statement A single Hollerith constant may initialize more than one variable element whereas any other type of constant corresponds to a single element A Hollerith constant may not contain excess characters but it will be extended with blanks so as to fill an integral number of elements EXAMPLES DIMENSION I 2 DATA I A B implies I 1 1 2 ABBEBBEB BBBEBBBE als DIMENSION 1 2 DATA 1 ABCDEFGHIJK implies I 1 ABCDEFGH 1 2 LIKBBBBE DATA J ABCDEFGHIJK is an error DIMENSION R 2 DATA R 2 A implies R 1 APBBYBBK R 2 ABBBBBEB 3 7 2 CONST Statement The CONST statement has the same form and general meaning as the DATA state ment FORM CONST v d v d where v is a variable list and d is a data l isi The syntax and semantics of these lists are identical wit
17. BLOCK DATA subprograms Each of these is termed a program unit 8 1 PROGRAM Statement FORM PROGRAM identifier The PROGRAM statement defines the program name that is used as the entry point name for the object module The identifier must not appear any where else in the program unit This statement if present must be the first statement of a main program If not present the main program name defaults fo F MAJN 8 2 END Statement FORM END The END statement must be the last physical statement of each program unit It informs the compiler of the end of the program unit The END statement must be on a single source line continuation lines are not allowed 8 3 RETURN Statement FORM RETURN 69 This statement returns control from a FUNCTION or SUBROUTINE subprogram to the calling program unit Normally the last statement executed in a subprogram is a RETURN statement It need not be the last statement of the program Any number of RETURN statements may be used 8 4 RESUME Statement FORM gt RESUME This statement is used to place a function or subroutine in the asynchronous or parallel mode It allows the calling program unit to continue execution however the function or subroutine continues to execute as well until a RETURN statement is executed 8 5 Subprogram Communications The main program and subprograms communicate with each other by means of COMMON variables and parameters If the means of com
18. HEP PARALLEL FORTRAN USER S MANUAL DENELCOR PUBLICATION 10002 00 DENELCOR INC 3115 EAST 40th AVENUE DENVER COLORADO 80205 NOTICE This manual describes the facilities provided by the Heterogeneous Element Processor FORTRAN Compiler It reflects with reasonable accuracy specifi cations in effect at the time the manual was written Users are cautioned the Denelcor reserves the right to make changes to these specifications without notice Denelcor assumes no liability for any damage resulting from or caused by reliance on the information presented This includes but is not limited to typographical errors and the omission of any information Comments regarding this manual or its contents should be directed to Corporate Communication Department Denelcor Inc 3115 East 40th Avenue Denver Colorado 80205 SECTION 1 L 1 1 ae 121 1 2 2 1 2 3 1 2 4 L62 lt 5 1 3 1 4 SECTION II 2 2 1 2 2 2 2 1 D 2622721 2 2 2 2 2 3 2 4 2 4 1 2 4 2 2 4 3 2 4 4 2 4 5 2 4 6 2 4 7 CONTENTS FORTRAN SOURCE PROGRAM FORM Introduction Character Set Source Statements Statement Labels Statements Comments Blank Lines Source Statement Ordering D in Column 1 Conditional Compilation COPY Statement DATA Introduction Identifiers Variables Simple Variable Arrays Array Storage Allocation Array References Data Types Constants Integer Constants Real Constants Double Precision Constants Complex Co
19. K 1 M N The indexing may be compounded as in the Porvewiaes READ 1 13 MASS K L K 1 5 L 1 4 This statement reads the elements of array MASS in the order MASS 1 1 MASS 2 1 MASS 5 1 MASS 1 2 MASS 5 4 If an entire array is to be transmitted the indexing may be omitted and only the array identifier written The array is transmitted in order of increasing subscripts with the first subscript varying most rapidly Thus the example above can be written READ 1 13 MASS 7 2 Input Output Statement Parameters Many input output statements have similar formats The following defini tions apply to all input output statements in which they may appear u logical I O unit number which may be an unsigned integer constant or an integer simple variable and may not be an asynchronous variable The correspondence between unit number and actual 1 0 device is determined by the system configuration and the operating system asia f format declaration identifier which is the statement number of a FORMAT statement in the program list I O list as defined in section 7 1 S statement number to which program control is transferred in the event an end of file indication is detected on the 1 0 unit while processing the statement Sa statement number to which program control is transferred if any error is detected while processing the statement 7 3 Sequential Input Output Statements These statements treat input and ou
20. R CEF N ROOTS SUBROUTINE RESIDUE NUM D DEN M RES 8 8 2 CALL Statement FORMS CALL identifier CALL identifier argument argument argument The CALL statement is used to transfer control to a subroutine subprogram The identifier is the subprogram name The parameters may be expressions array identifiers alphanumeric strings Or subprogram identifiers as in the case of a function reference Unlike a function however a subroutine cannot be referenced as a basic element in an expression A subroutine may use one or more of its arguments to return results to the calling program If no arguments at all are required the first form is used EXAMPLES CALL EXIT CALL SWITCH SIN 2 LE BETA X 4 Y CALL MULT A B C The identifier used to name the subroutine is not assigned a type and has no relation to the types of the arguments 76 8 8 3 CREATE Statement FORMS CREATE identifier CREATE identifier argument argument argument The CREATE statement is used to execute a subroutine as a parallel pro cess The identifier is the subroutine name The CREATE statement is the only way to directly initiate execution of an asynchronous subroutine Note however that parallel execution is also obtained through the use of the RESUME statement EXAMPLES CREATE GRAPH IN X CREATE PROC aJi APPENDIX A LIBRARY FUNCTIONS A l Intrinsic Functions FUNCTION ABS a TABS a DABS
21. R REAL DOUBLE DOUBLE PRECISION COMPLEX or LOGICAL and the identifier are identifiers or array descriptors An identifier may appear in only one Explicit type statement Explicit type statements may be used to declare arrays that are not dimensioned in DIMENSION or COMMON statements 3 3 1 1 INTEGER Statement FORM a INTEGER identifier identifier This statement declares the listed identifiers to be integer type with each datum occupying one word EXAMPLES INTEGER ALPHA PVAL INTEGER TABLESIZE 10 3 3 1 2 REAL Statement FORM REAL identifier identifier This statement declares the listed identifiers to be real type with each datum occupying one word in floating point format EXAMPLES REAL LOGX MASS 10 4 REAL 1 J K 20 3 3 1 3 DOUBLE PRECISION Statement FORM DOUBLE PRECISION identifier identifier This statement declares the listed identifiers to be of double precision type Each datum occupies two words in floating point format The key word PRECISION may be omitted 7 EXAMPLES DOUBLE PRECISION RATE Y FLOW DOUBLE TIME 27 9 3 3 1 4 COMPLEX Statement FORM COMPLEX identifier identifier This statement declares the identifiers to be of complex type Each datum occupies two words two floating point numbers representing the real and imaginary parts EXAMPLE COMPLEX ZETA W ROOT 3 3 1 5 LOGICAL Statement FORM LOGICAL identifier identif
22. a AINT a INT a IDINT a AMOD a az MOD a a2 AMAXO a a2 AMAX1 a a2 MAXO a1 22 MAXI a a2 DMAXI a a2 AMINO a1 a2 AMIN1 a1 22 MINO a a2 MIN1 a1 a2 DMIN1 a a2 FLOAT a FULL a Type of Parameter Real Integer Double Real Real Double Real Integer Integer Real Integer Real Double Integer Real Integer Real Double Integer Any asynchronous type Type of Result Real Integer Double Real Integer Integer Real Integer Real Real Integer Integer Double Read Real Integer Integer Double Real Logical 78 Definition lal i Truncation a mod ao Max a Aj Min a1 a2 Conversion from integer to real Test FULL access state Function EMPTY a IFIX a SIGN ai a2 ISIGN ai a2 DSIGN a gt ao DIM ai a2 IDIM a a2 SNGL a REAL a AIMAG a DBLE a CMPLX a1 a2 CONJG a TOR a a2 LAND a1 a2 Type of Parameter Any asynchronous type Real Real Integer Double Real Integer Double Complex Complex Real Real Complex Integer Integer Type of Result Logical Integer Real Integer Double Real Integer Real Real Real Double Complex Complex Integer Integer 7103 Definition Test EMPTY access state Conversion from re
23. actor and applies only when the E conversion field is used 4X denotes a field of four spaces Input under control of a G field is the same as for the F field 7 4 4 Logical Fields Logical data can be transmitted in a manner similar to numeric data by use of the form Lw where L is the control character and w is an integer specifying the field width Data is transmitted as the value of a logical variable in the input output list On input the data field is inspected for a T or F If one is found the value of the logical variable is stored as true or false respectively If the data field contains no T or F a value of false is stored On output w l blanks followed by T or F is output if the value of the logical variable is true or false respectively 60 7 4 5 Alphanumeric Fields Alphanumeric data can be transmitted in a manner similar to numeric data by use of the form Aw or Rw A and R are the control characters and w is the number of characters in the field The alphanumeric characters are transmitted as the value of a variable in an input output list The variable may be of any type For example the sequence READ 2 5 V 5 FORMAT A4 causes four characters to be read and placed in memory as the value of the variable V The character information is transferred as 8 bit ASCII characters stored 8 characters per 64 bit word Although w may have any value the number of characters transmitted is limit
24. ai mod a2 Complex Absolute value of Complex APPENDIX B FORTRAN LISTING FORMAT B 1 Introduction The printed output from the FORTRAN compiler is organized as follows for each program or subprogram in a compilation Program listing Allocation of variables for each COMMON block and for non COMMON variables gives location within the block variable name data type size and whether scalar or array Cross reference optional lists each symbol followed by the line number of each statement in which the symbol appears A line number surrounded by slashes indicates appearance in a speci fication statement A line number surrounded by asterisks indicates assignment of a value to the variable Object code listing optional lists the program again with the generated machine language code following each statement The generated code portion shows the memory type location hexa decimal contents and dis assembly assembly language equivalent of each instruction generated Subprograms called lists name type and number of arguments Statement labels lists memory location label name and how used Statement locations gives source line number and memory loca tion within a block of each non comment and non continuation line in the program es oe 8 Number of warnings and errors B 2 Statement Error Diagnostics During compilation statements which violate the syntactic or semantic rules of the la
25. al to integer Sign of az times lar aj Min a az2 Conversion from double to real Obtain real part of complex Obtain imaginary part of complex Conversion from real to double ai a2v 1 Obtain conjugate of complex Inclusive OR Logical AND Function NOT aj IEOR a a2 ISHFT ai a2 Type of Parameter Integer o Integer Integer 30 Type of Result Integer Integer Integer Definition Logical negation Exclusive OR Shift a by az bits A 2 Basic External Functions Function EXP a DEXP a CEXP a ALOG a DLOG a CLOG a ALOG10 a DLOG10 a SIN a DSIN a CSIN a COS a DCOS a CCOS a TANH a SQRT a DSQRT a CSQRT a ATAN a DATAN a ATAN2 a1 a2 DATAN2 a1 a2 Type of Parameter Real Double Complex Real Double Complex Real Double Real Double Complex Real Double Complex Real Real Double Complex Real Double Real Double Result_ e Type of Real Double Complex Real Double Complex Real Double Real Double Complex Real Double Complex Real Real Double Complex Real Double Real Double Definition a e In a log10 a sin a cos a tanh a a i 2 arctan a arctan a a2 Function DMOD a1 az2 CABS a Type of Parameter Double Complex Type of Result Definition Double
26. and returns control to the calling program by means of a RETURN or RESUME statement It is a program unit and consequently must terminate with an END statement 8 7 1 FUNCTION Statement FORM FUNCTION identifier identifier identifier This statement declares the program which follows to be a function subpro gram The first identifier is the name of the function being defined This ey ic identifier must appear as a simple variable 2741 be assigned a value during execution of the subprogram This value is the function value Identifiers appearing in the list enclosed in parentheses are formal parmeters representing the function arguments EXAMPLE FUNCTION FLOAT 1 FLOAT I RETURN END 8 7 2 FUNCTION Type The type of the function is the type of identifier used to name the function This identifier may be typed implicitly or explicitly in the same way as any other identifier Alternately the function may be explicitly typed in the FUNCTION statement itself by replacing the word FUNCTION with one of the following INTECER FUNCTION REAL FUNCTION DOUBLE FUNCTION DOUBLE PRECISION FUNCTION COMPLEX FUNCTION LOGICAL FUNCTION for example the statement COMPLEX FUNCTION HPRIME S N is equivalent to the statements FUNCTION HPRIME S N COMPLEX HPRIME 74 EXAMPLES FUNCTION MAY RANG XP YP ZP REAL FUNCTION COT ARG 8 7 3 Library Functions The FORTRAN system supplies a library of standard fu
27. anumeric characters the first of which must be alphabetic Any number of characters is allowed in an identifier but only the first eight are recognized Certain identifiers may be preceded by a dollar sign see section 2 2 The dollar sign is not included as one of the significant characters of an identifier EXAMPLES X15 PERMUTATION STRAIN 2 2 Variables Variable names are identifiers that represent quantities which may assume a number of different values Each variable has an associated data type integer logical real double precision or complex The variable may only assume values of that data type 7 A variable may be either synchronous the FORTRAN standard or asynchronous An asynchronous variable is actually a pair a standard variable and an access control Assigning a value to the variable causes a wait until its access state is EMPTY and sets its access state to FULL with the new value Conversely each use of any asynchronous variable causes a wait until the access state of the variable is FULL and leaves the access State EMPTY The access state may be interrogated with an intrinsic function FULL or EMPTY to determine its state An asynchronous variable is indicated by a dollar sign preceding the first character of the identifier Also the same variable must not be used as both a syn chronous and an asynchronous variable i e A and A must not both appear in the same program unit Variables may be
28. atical convention and the rules given below An arithmetic expression has a single nume rical value which is the result of the calculations speci fied by the quantities and operators comprising the expression The arithmetic operators are SYMBOL OPERATION Addition Subtraction Multiplication Division 4k Exponentiation variable or function reference 2 71828 Z N TAN THETA Compound expressions may be formed by using operators to combine basic elements 3 3a X 3 TOTAL POINTS TAN PI M Any expression may be enclosed in parentheses and treated as a basic element X Y 2 ZETA COS SIN PI M X Any expression may be preceded by a or sign For example X ALPHA BETA SQRT GAMMA However note that two operators must not occur consecutively ane expression below is improper XX Use of parentheses yields the correct form X Y By applying the rules above all permissable arithmetic expressions may be formed 4 1 1 Operator Precedence If the precedence of operations is not given explicitly by parentheses it is understood to be the following in order of decreasing precedence he OPERATOR OPERATION kk Exponentiation and Multiplication and division and Addition and subtraction or negation For example the expression ARB C D E P is executed as A B C D E Sequences of operations of equal precedence are performed left to right except
29. ay subprogram statement function name which has already been used otherwise DUPLICATE DUMMY A formal parameter has been declared twice in a statement func tion definition FUNCTION or SUBROUTINE statement EXTRA COMMA Warning More than one comma has been encountered at a point where a single comma was expected 86 FORMAT LABEL The indicated statement number was declared in the label field of a FORMAT statement and is being used in some manner other than as a format reference ILLEGAL DO CLOSE Warning A DO loop was closed with an illegal statement ILLEGAL LABEL l1 Statement number is less than lor greater than 99999 2 A DO statement references a previously defined label or a label previously referenced as a FORMAT ILLEGAL NUMBER 1 FORMAT DATA or CONST repeat count not greater than zero 2 Unary minus of Hollerith or Hexadecimal constant 3 Illegal complex number format JUMP LABEL l Statement number which is not a FORMAT label has been used as if it were 2 A FORMAT label has been previously referenced by an IF or GO TO statement 87 LABEL MISSING Warning 1 Indicated statement cannot be executed because it has no statement number 2 The indicated FORMAT cannot be used because it has no statement number MISSING COMMA Warning A comma was missing at a point where one was expected but com pilation could continue MISUSED NAME An identifier has been used in the
30. block C Block entries concatenate throughout the program beginning with the first COMMON statement For example the statements COMMON D ALPHA R A B C S COMMON C X Y R U V W have the same effect as the statement COMMON D ALPHA R A B U V W C S X Y One block of common storage may be left unlabeled and is called blank common Blank common is indicated by two consecutive slashes For instance COMMON R X Y B C D indicates that B C and D are placed in blank common 24 The slashes may be omitted when blank common is the first block of the statement COMMON B C D Storage allocation for blocks with the same name begins at the same loca tion for all programs executed together For example if a program contains COMMON A B R X Y Z as its first COMMON statement and a subprogram has COMMON R U V W D E F as its first COMMON statement then the quantities represented by X and U are stored in the same location A similar correspondence holds for A and D in blank common Labeled blocks of a given name must have the same length in all programs executed together Blank common may be any length in any program Array names appearing in COMMON statements may have dimension information appended as in a DIMENSION statement For example COMMON ALPHA T 15 10 5 GAMMA specifies the dimensions of the array T while entering T in blank common iD s 3 5 EQUIVALENCE Statement The EQUIVALENCE statement allows more than one iden
31. by the calling program when the subprogram is called Quantities needed for reference to the array are evaluated upon entry to the subprogram and unchanged by any subsequent modifications of the dimen sion variables lO EXAMPLE DIMENSION BETA L M G The identifiers BETA L M and G must all be formal parameters 3 2 DIMENSION Statement The DIMENSION statement is used to declare identifiers to be array identifiers and to specify the number and bounds of the array subscripts The informa tion supplied in a DIMENSION statment is required for the allocation of memory for arrays Any number of arrays may be declared in a single DIMEN SION statement FORM DIMENSION 51552506055 where S is an array declarator Each array variable appearing in the program must represent an element of an array declared in a DIMENSION statement unless the dimension information is given in another statement When the dimension information is provided in a COMMON or Explicit type statement it may not appear in a DIMENSION statement The DIMENSION keyword may be abbreviated DIM 3 3 TYPE Declarations The Explicit type statements INTEGER REAL DOUBLE PRECISION COMPLEX and LOGICAL and the IMPLICIT statement are used to specify the type of the identifiers appearing in the program 3 3 1 Explicit Type Statements The general form of the Explicit type statement is type identifier identifier2 identifier 19 Type may be INTEGE
32. compiler options are placed in parentheses on the compiler invocation control card Conditional Compilation CO This option causes lines containing a D in column one to be compiled Statements with a D in column one are treated as comments if this option is not selected Cross Reference XR This option causes the compiler to print an alphabetic listing of each identifier and where it was defined altered or referenced List Object LO This option causes the compiler to print pseus assembly language state ments corresponding to the object code generated 92 APPENDIX D FORTAN RUNTIME LIBRARY D 1 Introduction The programs involved with the process of executing a FORTRAN program may be divided into two categories Funtion Library Arithmetic Larbrary D 2 Function Library The Function Library consists of the basic external functions and non inline intrinsic functions These are all referenced directly by the FORTRAN program therefore the module name is the same as the FORTRAN function name The Function Library contains the following modules ALOG CLOG DCOS l EXP ALOG1O cos DEXP IDINT ATAN COSH DLOG SIN ATAN CSIN DLOGLO SINH CABS CSQRT DMOD SQRT CCOS DATAN DSIN TANH CEXP DATAN2 DSQRT D 3 Arithmetic Library The Arithmetic Library consists of the functions indirectly referenced by the FORTRAN program These modules all have the prefix F to identify them as part of the FORTRAN run time librar
33. cript expression may be any expression see section 4 1 The expres sion is converted to type integer after evaluation 9 EXAMPLES Y 1 STATION K Q LINE N X RHO N The value of a subscript must be within the limits specified for the array The number of subscripts must equal the number of dimensions specified gt for the array 2 3 Data Types The following data types are defined Integer Logical Real Double precision Complex The name assigned to a variable is associated with a data type either implicitly or explicitly The explicit type declaration statements section 3 3 1 assign the type explicitly If the data type of a variable is not declared explicitly the compiler types it implicitly according to the following conventions If the data identifier begins with one of the letters I J K L M or N the type is INTEGER Any other first letter implies REAL The IMPLICIT statement may be used to alter the above conventions and or introduce similar rules for data types other than integer and real See section 3 3 2 105 For an asynchronous identifier the first character after the dollar sign is used for implicit typing 2 4 Constants The data type of a constant is determined by its form 2 4 1 Integer Constants An integer constant is a signed or unsigned string of decimal digits It consists of up to 19 decimal digits in the range 293 v 9 2x10 3 to 2 1 v9 2
34. e for the convenience of the programmer and permit program descriptions to be embedded in the code Comments do not influence the compiler pro gram except that they are printed in the program listing Columns 2 72 may be used in any desired format A comment line can be followed only by another comment line or the initial line of a statement 1 2 4 Blank Lines Blank lines may be included in the source text Columns 1 72 must be blank A blank line can be followed only by a comment line another blank line or the initial line of a statement 1 2 5 Source Statement Ordering Table 1 1 shows the sequence in which the source statement groups of each program must be written Within each group the statements may be written in any sequence a EE DATA and CONST statements may appear anywhere after Group 2 and before Group 6 but must appear after any declarations COMMON DIMENSION or type affecting the variables to be initialized FORMAT statements may appear anywhere before Group 6 Table 1 1 SOURCE STATEMENT GROUP PROGRAM 1 FUNCTION SUBROUTINE BLOCK DATA IMPLICIT 2 COMMON 3 COMPLEX DIM ENSION DOUBLE PRECISION EQUIV ALENCE EXTERNAL INTEGER LOGICAL REAL Statement Function 4 Assignment 5 ASSIGN Assign and Unconditional GO TO BACKSPACE CALL Computed GO TO CONTINUE CREATE DO ENDFILE IF PAUSE PURGE READ RESUME RETURN REWIND STOP WRITE END 6 1 3 D in
35. ed by the maximum number of characters which can be stored in the space allotted for the variable This maximum depends on the variable type If w exceeds the maximum leading characters are lost on input and replaced with blanks on output When w is less than the maximum the A format causes left justification with blanks filled on input Only the left most w characters are used for output The R format causes right justification with binary zeros filled on input Only the right most w characters are used for output 7 4 6 Alphanumeric Constant Fields An alphanumeric constant may be specified within a format by preceding the alphanumeric string by the form nH H is the control character and n is the number of characters in the string counting blanks For example the statement FORMAT 17H PROGRAM COMPLETE 61 can be used to output PROGRAM COMPLETE on the output listing Alphanumeric strings delimited by single quotes may be used in the same manner j 7 4 7 Mixed Fields An alphanumeric format field may be placed among other fields of the format For example the statement FORMAT 15 8H FORCE F10 5 can be used to output the line 22 FORCE 17 68901 Note that the separating comma may be omitted after an alphanumeric format field 7 4 8 Blank or Skip Fields Blanks may be introduced into an output record or characters skipped on an input record by use of the specification nX The control character is X and n is the
36. el as a value not a numerical quantity EXAMPLES GO TO ERROR GO TO X 100 200 6 2 4 ASSIGN Statement FORM ASSIGN statement number TO variable The variable must be a scalar of integer type and must be an asynchronous variable This statement assigns the value of the variable for a subsequent assigned GO TO statement The statement number represents the statement to which the assigned GO TO will transfer control EXAMPLES ASSIGN 7 TO LABEL ASSIGN 13 TO ERROR 6 3 Arithmetic IF Statement FORM IF expression n n n where nj1 N2 n3 are statement numbers This statement transfers control to the statement numbered 46 ni n2 or n3 if the value of the expression is less than equal to or greater than zero respectively The expres sion must be of integer real or double precision type EXAMPLES IF ETA 4 7 12 IF KAPPA L 10 20 14 14 6 6 Logical Statement FORM IF expression S where S is a complete statement The expression must be a logical expression S may be any imperative executable statement other than a DO statement or another logical IF statement If the value of the expression is false then control passes to the next sequential statement If the value of the expression is true statement S is executed After execution of S control passes to the next sequential statement unless S is an arithmetic ir statement or GO TO type statement in which case control is transferred as i
37. ent FORMAT 2E15 4 2 F8 3 F8 5 could be used in the transmission of three complex quantities 7 4 13 Multiple Record Formats To handle a group of input output records where different records have different field specifications a slash is used to indicate a new record For example the statement FORMAT 318 15 2F8 4 is equivalent to FORMAT 318 64 for the first record and FORMAT 15 2F8 4 for the second record The separating comma may be omitted when a slash is used Blank records may be written on output or records skipped on input by using consecutive slashes Both the slash and the closing parenthesis at the end of the format indicate the termination of a record If the list of an input output statement dictates that transmission of data is to continue after the closing paren thesis of the format is reached the format is repeated from the last open parenthesis level of one or zero If this parenthesis is preceded by a repeat specification the repeat specification is reused Thus the statement FORMAT F7 2 2 E15 5 E15 4 17 causes the format F7 2 2 E15 5 E15 4 17 to be used on the first record and the format 2 15 5 E15 4 17 on succeeding records As a further example consider the following statement FORMAT F7 2 2 E15 5 E15 4 17 65 The first record has the format below F7 2 Successive records have the following format 2 E15 5 E15 4 17 7 4 14 Carriage Control for Printing Every record
38. execution of the range control passes to the statement immediately following the range The exit from the range is called the normal exit 48 Exit may also be accomplished by a transfer from within the range The range of a DO statement may include other DO state ment provided that the range of each contained DO state maent is entirely within the range of the containing DO statement Within the range of a DO statement the index is available for use as an ordinary variable After a transfer exit from the range the index retains its current value and is available for use as an ordinary variable After a normal exit from the range the index retains the value which caused the exit The values of the index limit and step may be altered within the range of the DO statement Altering the value of limit or step does not affect the loop The range of a DO statement must not end with a GO TO type statement or an arithmetic IF statement A logical IF statement is allowed as the last statement of the range provided the logical IF does not contain a GO TO type statement or an arithmetic IF In this case control is transferred thus The range is considered ended when and if control would normally pass to the statement following the logical IF statement As an example consider the sequence DO 5K 1 4 5 IF X K GT Y K Y X K O 49 eee rm ee ue aom a Ar veaa A aman a e A R AO r re A A a ver e O A
39. gram EXAMPLE EXTERNAL SIN COS CALL TRIGF SIN 1 5 ANSWER CALL TRIGF COS 87 ANSWER END SUBROUTINE TRIGF FUNC ARG ANSWER ANSWER FUNC ARG RETURN END 29 3 7 DATA Specification The data specification statements DATA CONST and BLOCK DATA are used to declare constants and specify initial values for variables These values are compiled into the object program They become the values assumed by the variables when execution begins 3 7 1 DATA Statement The data to be compiled into the object program is specified in a DATA statement FORM DATA v d v d where v is a variable list and d is a data list The variable lists in a DATA statement consist of simple variable array names or array elements separated by commas Variables in common may appear on the lists only if the DATA statement occurs in a BLOCK DATA subprogram Asynchronous variables may appear in a DATA statement The data items of each data list correspond one to one with the variables of each variable list Each data item specifies the value given to its corresponding variable Data items may be numerical constants or alphanumeric strings For example DATA ALPHA BETA 5 16 E 2 specifies the value 5 for ALPHA and the value 16 for BETA 302 Any data item may be preceded by an integer followed by an asterisk The integer indicates the number of times the item is to be repeated For example DATA A 1 A4 2 A 3 4 4 A
40. h those of the DATA statement with one exception The CONST statement causes the variables to be allocated in constant memory This implies that they are not variables but symbolic constants Constants may not appear in I O statements be passed as parameters be assigned to or be asynchronous 3 7 3 BLOCK DATA Statement FORM BLOCK DATA a ye This statement declares the program which follows to be a data specification subprogram Data specification for variables in common blocks requires the use of a BLOCK DATA subprogram The first statement of the subprogram must be the BLOCK DATA statement The subprogram may contain only declarative statements associated with the data being defined EXAMPLE BLOCK DATA COMMON R X Y C Z W V DIMENSION Y 3 COMPLEX Z DOUBLE PRECISION X DATA Y 1 Y 2 Y 3 1E 1 2 3E2 DATA X Z 11 877D0 1 41421 1 41421 END Data may be entered into more than one block of common in one subprogram however any common block mentioned must be listed in full In the example above W and V are listed in block C although no data values are defined for them cds SECTION IV EXPRESSIONS 4 Introduction Expressions are strings of operands separated by operators There are two types of FORTRAN expressions arithmetic and logical 4 1 Arithmetic Expressions An arithmetic expression is a sequence of basic elements separated by arithmetic operators and parentheses in accordance with mathem
41. ier This statement declares the listed identifiers to be of logical type Each datum occupies one word where zero represents false and non zero represents true 21 EXAMPLE LOGICAL BOOL P 0 ANSWER 3 3 2 IMPLICIT Statement The IMPLICIT statement defines the data identifier first letter parameters for implicitly specifying data types should the programmer desire para meters different from the compiler defaults which are DEFAULTS Identifiers beginning with the letters I J K L M and N imply INTEGER data Identifiers beginning with all other letters imply REAL data The format of the IMPLICIT statement is FORM IMPLICIT type Ay A2 go 5 typez A3 Ay go go where type is the data type INTEGER REAL DOUBLE DOUBLE PRECISION COMPLEX LOGICAL implied by data identifiers beginning with the letters listed subsequently Ai A42 Or Az Ay are lists or ranges of alphabetic characters for the preceding data type Lists of single characters are separated by commas ranges of characters are denoted by the first and last character or the range in alphabetic sequence separated by a minus sign e g A D ajja This statement causes any variable not mentioned in an Explicit type state ment and whose first character is one of those listed to be typed according to the type appearing before the list in which the character appears For an asynchronous identifier the first
42. ithout type conversion The string is stored as indicated in sec tion 2 4 6 The number of characters cannot be greater than the number of bytes in the variable EXAMPLE X AB implies the eight bytes and represented by X will appear as 5 3 Logical Assignment Statement The logical assignment statement specifies a logical expres Sion to be evaluated and a logical variable to which the expression value is to be assigned FORM variable expression Both the variable and expression must have logical type EXAMPLES LOGICAL LA LB LC LD LA LB AND LC AND LD LB NOT LA LC A GT B OR C EQ D 7 Biss SECTION VI CONTROL STATEMENTS 6 Introduction The normal flow of a FORTRAN program is sequentially through the statements in the order in which they are given to the compiler By means of control statements the programmer may specify the flow of the program 6 1 Statement Numbers FORTRAN statements may be given numbers to be referenced by control statements A statement number is written as an unsigned integer of five digits or less Leading zeros and embedded blanks are ignored Although statement numbers are written as integers they do not represent numerical quantities Statement numbers repre sent statement labels a distinct basic quantity Statement numbers are used for program control not numerical calculation Statement numbers must be unique i e no two statements may have the same number
43. may appear anywhere in a source program They are significant only in Hollerith constants and format specifications ala 1 2 Source Statements Standard FORTRAN statements are accepted as formatted lines or records of eighty or fewer characters Each line is divided into four fields COLUMNS FIELDS 1 5 Statement label 6 i Continuation indicator 7 72 Statement 73 80 Identification The identification field is ignored by the FORTRAN compiler and is provided for the convenience of the programmer 1 2 1 Statement Labels The statement label is made up of digits placed anywhere in columns l 5 of the init al line of a statement Blanks and leading zeros are ignored 1 2 2 Statements A statement consists of an initial line and any number of continuation lines An initial line is a line that is neither a comment line nor an END line and contains either a blank or a zero in column 6 A continuation line is not a comment line and contains any character other than blank or zero in column 6 An END line is a line containing an END statement which cannot be continued EXAMPLE 112 3 4 5 6 7 8 9 10 11 12 21 0 0 Ail Bi X C X D The first line of this example is an initial line The second and third lines are continuation lines The statement label is 200 The statement is equivalent to A B C D 1 2 3 Comments Comment lines have the character C or an asterisk in column 1 Comments ar
44. mi Se rs Statement 5 is executed four times whether the state ment Y K X K is executed or not Statement 6 is not executed until statement 5 has been executed four times EXAMPLES DO 22 L 1 30 DO 45K 2 LIMIT 3 6 6 CONTINUE Statement This statement is a dummy statement used primarily as a target point for transfers particualrly as the last Statement in the range of a DO statement For example in the sequence FORM CONTINUE DO 7K START END IF X K 22 13 7 7 CONTINUE a positive value X K begins another execution of the range The CONTINUE provides a target address for the IF statement and ends the range of the 6 7 PAUSE Statement FORMS PAUSE PAUSE n PAUSE character string where n is an integer constant 5Q This statement causes the operand to be displayed on the system output device If no operand is given zero is displayed EXAMPLE PAUSE 167 6 8 STOP Statement FORMS STOP STOP n STOP character string where n is an integer constant This statement terminates the program It does not stop the system and may be used to transfer control to the operating system 6 9 PURGE Statement FORM PURGE Ni No N where the Ny are asynchronous variables The statement causes the access state of all the named variables to be set empty regardless of their existing state 51 SECTION VII INPUT OUTPUT 7 Introduction Input output statements specify
45. munication is by parameters the arguments of the subroutine or function call are known as actual parameters Corresponding arguments in the subroutine or function argument list are known as formal parameters 8 5 1 Actual Parameters The actual parameters which appear in a subroutine call or a function reference may be any of the following An arithmetic expression A logical expression A constant A simple variable An array element reference An array name A FUNCTION name A SUBROUTINE name 705 8 5 2 Formal Parameters The formal parameters appearing in the parenthetical list of a FUNCTION or SUBROUTINE statement may be any of the following An array name A simple variable A subprogram name either function or subroutine The formal parameters are replaced at each execution of the subprogram by the actual parameters supplied in the CALL statement or function reference Formal parameters representing array names must appear within the sub program in type or DIMENSION statements giving dimension information In a type or DIMENSION statement formal parameters may be used to specify variable dimensions for array name formal parameters Variable dimensions may be given only for arrays which are formal parameters Within a subprogram the use of formal parameters is restricted as follows 1 Formal parameters must not appear in COMMON statements 2 Formal parameters must not appear in EQUIVALENCE statements
46. nctions which may be referenced from any program Appendix A lists these library functions These are divided into two sets basic external functions and intrinsic functions The basic external functions are called by the object program in the same manner as normal user supplied functions Intrinsic func tion names are known to the compiler and intrinsic function references may be treated in non standard ways such as expanding the function in line The programmer can supply his own function in place of an intrinsic function by including the name in EXTERNAL statements in all calling programs 8 8 SUBROUTINE Subprograms A SUBROUTINE subprogram is not a function it can be referred to only by a CALL or CREATE statement A SUBROUTINE subprogram begins with a SUBROUTINE declaration and returns control to the calling program by means of a RETURN or RESUME statement 8 8 1 SUBROUTINE Statement FORMS SUBROUTINE identifier SUBROUTINE identifier identifier identifier This statement declares the program which follows to be a SUBROUTINE sub program The first identifier is the subroutine name The identifiers in the list enclosed in parentheses are formal parameters 75 A SUBROUTINE subprogram may use one or more of its formal parameters to represent results The subprogram name is not used for return of results A SUBROUTINE subprogram need not have any parameters at all EXAMPLES N SUBROUTINE EXIT SUBROUTINE FACTO
47. ndicated As an example consider the statements IF B Y X SIN Z W Y x2 If the value of B is true the statements Y X SIN Z and W Y 2 are executed in that order If the value of B is false the statement Y X SIN Z is not executed aTa EXAMPLES IF T OR S X Y 1 IF Z GT X K CALL SWITCH X Y IF K EQ INDEX GO TO 15 6 5 DO Statement FORMS 3 j DO n index initial limit DO n index initial limit step where n is a statement number The index must be a simple integer variable and must not be an asynchronous variable The initial and limit may be integer simple variables signed integer constants or integer expressions The step must be an integer simple variable an integer constant or an integer expression If the step is not given it is understood to be one The DO statement causes the statements which follow up to and including the statement numbered n to be executed repeatedly This group of statements is called the range of the DO statement Initially the initial value is assigned to the index Thereafter after each execution of the range the step value is added to the index value and the result assigned to the index Prior to each execution of the range the index value is compared to the limit value If the index value does not exceed the limit value the range is executed This differs from Standard FORTRAN in which the range is always executed once before the first test After the last
48. nguage are recognized and error indications are printed There are two levels of statement diagnostics warnings and errors Warnings are issued for minor infractions where the compiler can still determine what is to be done and compile the statement Errors are severe violations of the language In the case of errors compilation proceeds as if the statement was never encountered The statement label if any remains defined If the error statement is ever executed it will cause a link to a system routine which will terminate execution of the program and notify the user that an attempt has been made to execute an erroneous statement The name of the program and the line number of the statement will be displayed One character of the statement is marked with an up arrow symbol A output directly beneath the erroneous character for example ZATA X Y A A The character is marked as an error In the case of a syntax error the marked character itself was unacceptable as in the example above In the case of a semantic error an identifier or other construct is in error The mark indicates the last character of the construct in error For example in the line COMMON ALPHA BETA ALPHA GAMMA A the mark indicates that the identifier ALPHA is misused 84 The compiler attempts all interpretations of statement type before dis carding a statement The marked position indicates the greatest amount of correct information
49. nstants Logical Constants Hollerith Constants Hexadecimal Constants E w OD GL EW NN N FF Pi ow woo on N N 10 11 11 11 13 14 14 14 16 CONTENTS Continued ii Page SECTION III SPECIFICATION STATEMENTS 3 Introduction 17 3 1 Array Declarators 17 3 1 1 Variable Dimensions 18 3 2 DIMENSION Statement 19 3 3 Type Declarations e 19 82361 Explicit Type Statements 19 Jade del INTEGER Statements 20 ee re ee REAL Statement 20 Id les DOUBLE PRECISION Statement 21 3 3 1 4 COMPLEX Statement 21 3 3 1 3 LOGICAL Statement 21 3 352 IMPLICIT Statement 22 3 4 COMMON Statement 23 3 5 EQUIVALENCE Statement 26 ee ree EQUIVALENCE and COMMON 28 3 6 EXTERNAL Statement 29 37 DATA Specifications 30 l 3 7 1 DATA Statement 30 3 7 2 CONSTANT Statement 32 34 40 BLOCK DATA Statement 32 SECTLON IV EXPRESSIONS 4 Introduction 33a 4 1 Arithmetic Expressions 33 4 1 1 Operator Precedence 34 4 1 2 Evaluation of Mixed Mode Expressions 35 4 2 Logical Expressions 37 4 2 1 Relations 37 4 2 2 Logical Operators 38 4 3 Summary of Operator Precedence 39 SECTION V 5 3 1 id 5 3 SECTION VI 6 6 1 6 2 6 2 1 6 2 2 6 2 3 6 2 4 6 3 6 4 6 5 6 6 6 7 6 8 6 9 SECTION VII 7 7 1 7 2 7 3 Fe ded 753 2 7 4 7 4 1 7 4 2 CONTENTS Continued ASSIGNMENT STATEMENTS Introduction Arithmetic Assignment Statement Mixed Type Assignment Logical Assignment Statement CONTROL STATEMENTS Introduction Statement Number
50. nts must all appear in the program prior to any non declarative statements and statement function definition state ments Explicit type statements IMPLICIT statement DIMENSION statement EXTERNAL statement COMMON statement EQUIVALENCE statement MAXREGS statement DATA statements are not required to appear in the program prior to any non declarative statements 3 1 Array Declarators Arrays may be defined by several statements Explicit type statements COMMON statement DIMENSION statement Niy Array declarators are used in these statements Each array declarator gives the array identifier and the maximum values each of its subscripts may assume thus identifier max max2 max3 The maxima must be integers An array may have one two or three dimen sions For example the statement gt DIMENSION EDGE 10 8 specifies EDGE to be a two dimensional array whose first subscript may vary from 1 to 10 inclusive and the second from 1 to 8 inclusive EXAMPLES DIMENSION PLACE 3 3 3 HI 2 4 K 256 Arrays may also be declared in the COMMON and Explicit type statements in the same way COMMON X 20 4 Y Z INTEGER A 7 32 B DOUBLE PRECISION K 6 10 3 1 1 Variable Dimensions Within a subprogram array declarations may use integer variables provided that the array name and variable dimensions are formal parameters of the subprogram The actual array name and values for the dummy variables are given
51. number of blanks or characters skipped n must be greater than zero For example the statement FORMAT 5H STEPI5 10X 3HY F7 3 62 may be used to output the line STEP 284KBBKHBHHBY 3 872 where ten blanks separate the two quantities 7 4 9 Tabulation The position in the record where the transfer of data is to begin can be specified by T format conversion The specification is Tn where n is the character position For printed output the first character is for carriage control and should not be counted EXAMPLE FORMAT T20 NAME T40 AGE T1 6H GRADE would print a line Position 1 Position 19 Position 39 y y 4 GRADE NAME AGE 7 4 10 Repetition of Field Specifications Repetition of a field specification may be specified by preceding the control character E F G I by an unsigned integer giving the number of repetitions desired For example FORMAT 2E12 4 315 is equivalent to FORMAT E12 4 E12 4 15 15 15 63 7 4 11 Repetition of Groups A group of field specifications may be repeated by enclosing the group in parentheses and preceding the whole with the repetition number For example FORMAT 218 2 E15 5 2 F8 3 is equivalent to FORMAT 218 E15 5 2F8 3 E15 5 2F8 3 7 4 12 Complex Fields Complex quantities are transmitted as two independent real quantities The format specification is given as two successive real specifications or one repeated real specification For instance v2 statem
52. of a complex quantity The imaginary part is zero 4 A double precision quantity is converted to single precision and becomes the real part of a complex quantity The imaginary part is zero 36 4 2 Logical Expressions There are four basic elements used FORTRAN logical expres sions logical constants logical type variables logical type functional references and relations All of these basic elements represent logical quantities A logical quantity may have either of two values true or false Logical quantities occupy one word of memory 4 2 1 Relations Relations are constructed from numerical expressions of intetger real or double precision type through the use of relational operators The relational operators are OPERATOR RELATION GT greater than GE greater than or equal to LT less than LE less than or equal to EQ equal to NE not equal to The enclosing periods are part of the operator and must be present Two expressions of integer real or double precision type separated by a relational operator form a relation For example X 2 LE 3 Y is a relation The entire relation constitutes a basic logical element The value of such an element is true if the relation ex pressed is true and false otherwise In the example above 075 the element has the value true if X is 2 and Y is 2 and the value false if X is 2 and Y is 1 Complex operands are allowed for the opertors
53. right differs e A from the type of the variable on the left The evaluated expression is converted to the type of the variable Table 5 1 gives the conversions for all combinations of expressions and variables Type of Variable INTEGER INTEGER INTEGER INTEGER REAL REAL REAL REAL DOUBLE PRECISION DOUBLE PRECISION COMPLEX COMPLEX continued Type of Expression INTEGER REAL DOUBLE PRECISION COMPLEX INTEGER REAL DOUBLE PRECISION COMPLEX INTEGER COMPLEX INTEGER REAL Table 5 1 ye Conversion None Truncate fractional part convert to integer form Truncate fractional part convert to integer form Truncate fractional part of real part convert to integer form Convert to floating point form None Take first word of ex tended floating point Take real part Convert to extended floating point form Extend real part to extended floating point form Convert to real forn assign to real part assign zero imaginary Assign to real part assign zero imaginary Type of Variable Type of Expression Conversion COMPLEX DOUBLE PRECISION Take first word of extended floating point assign to real part assign zero imaginary COMPLEX COMPLEX None Table 5 1 continued Assignment Statements of the form variable Hollerith constant are special cases The character string represented by the Hollerith constant is transferred to the variable w
54. rom internal to external form is specified by the format reference first form 5 When binary data is transmitted to the format reference is omitted second form EXAMPLES WRITE 2 15 ZILCH WRITE K3 4 A K K 2 20 ICHI WRITE 4 NUMB SYMB J J 1 NUMB 7 4 FORMAT specifications The format designator f appearing in formatted I O statements is the statement label of a FORMAT statement FORM FORMAT S 9925 ees S where S is a data field specification 7 4 1 Numeric Fields Conversion of numerical data may be one of six types l type E internal form binary floating point external form decimal floating point 2 type F internal form binary floating point external form decimal fixed point 3 type G internal form binary floating point external form decimal fixed point or floating point 56 4 type I internal form binary integer external form decimal integer 5 type Z internal form binary integer external form hexadecimal integer These types of conversion are specified by the forms l Ew d 2 Fw d 3 Gw d 4 Iw 5 Zw respectively The letter E F G I or Z designates the conversion type w is an integer specifying the field width d is in integer specifying the number of decimal places to the right of the decimal point As an aid in conversion the letter O is allowed and treated as a Z For example the statement PP 15 F10 2 E25 15
55. s GO TO Statements Unconditional GO TO Statement Computed GO TO Statement Assigned GO TO Statement ASSIGN Statement Arithmetic IF Statement Logical IF Statement DO Statement CONTINUE Statement PAUSE Statement STOP Statement PURGE Statement INPUT OUTPUT Introduction Input Output Lists Input Output Statement Parameters Sequential Input Output Statements READ Statement WRITE Statement FORMAT Specifications Numeric Fields Scale Factors iii Page 41 41 41 43 44 44 44 44 45 45 46 46 47 48 50 50 51 51 52 52 53 54 54 55 56 56 58 SECTION VII Continued 7 4 3 7 4 4 Logical Fields 7 4 5 Alphanumeric Fields 7 4 6 Alphanumeric Constant Fields 7 4 7 Mixed Fields 7 4 8 Blank or Skip Fields 7 4 9 Tabulation 7 4 10 Repetition of Field Specifications 7 4 11 Repetition of Groups 7 4 12 Complex Fields 7 4 13 Multiple Record Formats 7 4 14 Carriage Control for Printing Leo Auxiliary 1 0 Statements Week REWIND Statement teed BACKSPACE Statement 7 5 3 END FILE Statement SECTION VIII PROGRAM UNITS 8 Introduction 8 1 PROGRAM Statement 8 2 END Statement RETURN Statement 8 4 RESUME Statement 8 5 Subprogram Communications 8 5 1 Actual Parameters 8 5 2 Formal Parameters 8 5 3 Correspondence Between Actual and Formal Parameters 8 6 Statement Function Definition Statement 8 7 FUNCTION Subprograms Sahel FUNCTION Statement CONTENTS Continued G Fields iv 59 60 61 6
56. s a string of digits and e is a l digit or 2 digit exponent to the base 10 The plus character is optional The magnitude of a double precision constant is in the approximate range of 5 4x10 to 7 2x107 EXAMPLES 31415927D1 3 1415D0 31415 93D 04 Internally a double precision constant appears as a real constant followed by an integer extension of the mantissa EIC le S Sign C Characteristic M Mantissa 56 bits M Mantissaz 64 bits 2 4 4 Complex Constants A complex constant appears as an ordered pair of real constants enclosed in parentheses r r2 The real part is r and the imaginary part is r2 EXAMPLES 0 1 5 2 2 6 3 E12 017E 10 nternally complex data is stored as two real constants see 2 4 2 2 4 5 Logical Constants A logical constant isa truth value TRUE or T FALSE or F A logical constant occupies one word which is either zero FALSE or non zero TRUF 2 4 5 Hollerith Constants A Hollerith constant is a string of characters which is represented in ternally by 8 bit ASCIT codes A Hollerith constant may appear wherever Ls an expression may appear however it must not appear within an expression It is treated as an integer constant There are four forms of Holler th constants FORMS nHC1C2 C_ nRC1C2 C LU CiC2 0 nLC102 C where n s an unsigned integer constant and Ci are characters Internally
57. se are formal parameters which have meaning and must be unique only within the statement They may be identical to identifiers of the same type appearing elsewhere in the program These identifiers must agree in order number type and length with the actual parameters given at execution time The use of a parameter in the defining expression is specified by the use of its parameter identifier Expressions are the only permissible arguments of internal functions hence the parameter identifiers may appear only as simple variables in the defining expression They may not appear as array identifier 72 Identifiers appearing in the defining expression which do not represent parameters are treated as ordinary variables The defining expression may include references to external functions or other previously defined internal functions All statement function definition statements must precede the first exe cutable statement of the program EXAMPLES SSQR K K K 1 2K 1 6 NOR T S NOT T OR S ACOSH X EXP X A EXP X A 2 In the last example above X is a parameter identifier and A is an ordinary identifier At execution the function is evaluated using the current value of the quantity represented by A 8 7 FUNCTION Subprograms A FUNCTION subprogram is a function it returns a single value and is referenced as a basic element in an expression A FUNCTION subprogram begins with a FUNCTION declaration
58. simple or arrays 2 2 1 Simple Variables A simple variable name identifies the location in which a single variable value can be stored EXAMPLES N X4 SVALUE LOOK UP 2 2 2 Arrays An array variable name identifies an ordered set of data having one two or three dimensions Each element of an array is referenced by the array name followed by a set of subscripts An array has an associated data type the same as a simple variable An array must be declared by an array declarator which establishes the number E of dimensions and the size of each The data type of an array is identified the same as for a simple variable The declaration of an array type may occur separately from the declaration of its dimensions 2 2 2 1 Array Storage Allocation The multi dimensional arrays declared by the programmer are assigned to the one dimensional computer memory in such a way that the left most subscript varies most rapidly and the right most subscript least rapidly EXAMPLE Allocation of array K of three dimensions of two elements each Memory Sequence Array Element 1 K 1 1 1 2 K 2 1 1 3 K 1 2 1 4 K 2 2 1 5 K 1 1 2 6 K 2 1 2 7 K 1 2 2 8 K 2 2 2 2 2 2 2 Array References Most FORTRAN statements operate on only one element of an array at a time A member of an array is referenced in the form array S S2 S3 where array is the name of the array and the S are suscript expressions A subs
59. the transfer of information between com puter memory and input output devices or between one part of computer memory and another These statements also allow the program to mani pulate I O devices l Information may be transferred in two different forms formatted and unformatted The unformatted form involves no data conversion data is transferred in its internal format Formatted data is converted from internal to external form or vice versa under control of a FORMAT specification in the program 7 1 Input Output Lists Input output statements may contain a list of variables which are to receive values on input or are to provide values for output The list of a transmission statement specifies the order of transmission of the variable values During input the new values of listed variables may be used in subscript or control expressions for variables appearing later in the list For example READ 1 3 L A L B L 1 reads a new value of L and uses this value in the subscripts of A and B The transmission of array variables may be controlled by indexing similar to the indexing in the DO statement The list of controlled variables followed by the index control is enclosed in parentheses and the whole acts as a single element of the list For example READ 7 23 X K K 1 4 32 is equivalent to READ 7 23 X 1 X 2 X 3 X 4 The initial limit and step values are given as in the DO statement READ 4 2 N GAIN K
60. tifier to represent the same quantity FORM EQUIVALENCE Rj R2 5 eee 5 RR L go si 9 al where Ri is a reference EQUIVALENCE may be abbreviated EQUIV The references of an EQUIVALENCE statement may be simple variables or array identifiers or array element references The subscripts of an array element must be integer constants The number of subscripts must be equal to the array dimension or must be one Synchronous and asynchronous variables may not be made equivalent to each other EXAMPLE EQUIVALENCE A B C 3 T 4 S 1 1 2 The inclusion of two or more references in a parenthesis pair indicates that the quantities referenced are to share same memory locations For example EQUIVALENCE RED BLUE specifies that the quantities RED and BLUE are stored in the same place When no array subscript is given it is taken to be 1 thus EQUIVALENCE X Y is the same as EQUIVALENCE X Y 1 9G Elements of multiple dimensioned arrays may be referenced with a single subscript by use of the element successor function For example in the three dimensional array specified by DIMENSION ALPHA N N2 N3 the position of element ALPHA K K2 K3 is given by element position K3 1 N1 N2 K2 1 N1 K Thus the sequence DIMENSION BETA 4 ALPHA 2 3 4 EQUIVALENCE BETA 2 ALPHA 8 specifies that BETA 2 and ALPHA 2 1 2 are stored in the same place Since the entire arrays are shifted to satisfy
61. tput to and from I O units as if the units contained sequential files each composed of an ordered set of records Each time a READ or WRITE statement is executed at least one record is processed As each record is processed the file is positioned to read or write the next sequential record 7 3 1 READ Statement FORMS READ u END S ERR S2 list READ u END S ERR S2 list where u is an I O unit designation and f is a format reference The parameters END S and ERR Sz are optional and their order may be reversed The READ statement causes information to be rend from the 1 0 unit designated and stored in memory as values of the variables in the list 54 In transmitting formatted data the conversion from external to internal form is specified by the format referenced first form When binary data is transmitted the format reference is omitted second form EXAMPLES READ 1 15 END 100 ETA PI READ K L 10 GSIN ZAI READ M FMT ERR 999 END 100 TABL K K 1 M READ TAPE TEMP L L 1 100 7 3 2 WRITE Statement FORMS WRITE u f END S ERR S2 list WRITE u END S ERR S2 list where u is an I O unit designation and f is a format reference The END S1 and ERR S2 parameters are optional and their order may be reversed The WRITE statement causes the values of the variables in the list to be transmitted from memory to the designated I O unit In transmitting formatted data the conversion f
62. wrong contex such as A formal parameter in a DATA or EQUIVALENCE statement A variable dimension which is not a simple formal parameter A subprogram name used without parameters in an ex pression MULTI DEFINED A statement number is defined more than once NOT ARRAY An identifier which is not an array name has been used where an array name should have appeared 88 NOT INTEGER A variable or expression of type other than integer has been used where only integer type is allowed NUMBER OF SUBSCRIPTS The number of subscripts in an array reference is incorrect RANGE 1 The second character in the declaration of an IMPLICIT range does not alphabetically follow the first character 2 A constant subscript array reference has a subscript which falls outside the size of the array STATEMENT NOT ALLOWED 1 A statement has been used in an illegal context 2 An illegal logical IF secondary statement or the statement is in the wrong order such as a statement function defini tion not preceding executable statements SYNTAX 1 Usually erroneous punctuation or an illegally constructed expression 2 The character marked shows how much of the statement was scanned before it ceased to make sense 892 TYPE CONFLICT 1 The same first character has been declared two different types in an IMPLICIT statement 2 The types of the operands of an arithmetic or logical operator are illegal
63. x10 The internal representation of an integer is a full word 64 bit two s complement number However integer division produces a result accurate to only 56 bits EXAMPLES 1 1234567890 0 2 4 2 Real Constants A real constant is a signed or unsigned string of decimal digits that in cludes a decimal point and or an exponent Any number of digits may be included but only the first fifteen are significant A real constant has one of the following forms lis FORMS ti ti Ete EL 1 iE re tisi tiE e i iE e where i is a string of digits and e is a l digit or 2 digit exponent to the base 10 The plus character is optional The magnitude of a real con stant is in the approximate range of 5 4x10 7 to 7 2x10 EXAMPLES 3 1415 0 031415E 2 031415E2 31 415E 1 Internally real data is stored as follows O 1 78 63 spero o where S is the sign of the mantissa 0 1 C is the base sixteen characteristic plus 64 M is the mantissa 56 bits represented as a sign magnitude number The mantissa is hex normalized 12 2 4 3 Double Precision Constants A double precision constant is a signed or unsigned string of decimal digits that includes an optional decimal point and an exponent Any number of digits may be included but only the first twenty nine are significant A double precision constant has one of the following forms FORMS t iDie t Dte where i i
64. y and to limit conflicts with user names 93 Name FZCVDI FZCVID FZDADD FZDSUB FZDMUL FZDDIV FZCMUL FZCDIV FZDTNE FZDTEO FZDTLE FZDTLT FZDTGE FZDTGT FZCTNE F CTEQ FZPWII FZPWIR FZPWID FZPWIC FZPWRI FZPWRR FZPWRD FZPWRC FZPWDI FZPWDR FZPWDD F PWDC FZPWCI FZPWCR FZPWCD FZPWCC Function Convert double precision to integer Convert integer to double precision Double precision add Double precision subtract Double precision multiply Double precision divide Complex multiply Complex divide Double precision test Double precision Test Double precision test Double precision test Double precision test Double precision test Complex test NE Complex test EQ I I power I R power 1 D power I C power R T power R R power R D power R C power D I power D R power D D power D C power C x T power C R power C D power C C power routine routine routine routine routine routine routine routine routine routine routine routine routine routine routine routine 94

Download Pdf Manuals

image

Related Search

Related Contents

Wireless Handheld Transmitter Modular Mute Switch User Guide    CA070 Manual  Handbook Manuel Handbuch Handleiding  Régulateur de procédé avec PROFIBUS DP Modbus Maître/Esclave  Using Kitchen Scales - University of Minnesota Extension  取扱説明書 - ダイワインダストリ  Philips Ledino Wall light 16810/93/16  Honeywell HWB2052B/HWB101B Use and Care Manual  Rollofix_Gurtwickler  

Copyright © All rights reserved.
Failed to retrieve file