Digital PDFs
Documents
Guest
Register
Log In
AA-0944E-TB
January 1977
362 pages
Original
117MB
view
download
OCR Version
49MB
view
download
Document:
DECsystem10 FORTRAN Programmer's Reference Manual
Order Number:
AA-0944E-TB
Revision:
0
Pages:
362
Original Filename:
OCR Text
gecsUscenio FORTRAN PROGRAMMERS REFERENCE MANUAL dlilgliltiall January 1977 This document describes the language elements of the FORTRAN-10 compiler for the DECsystem-10. aecsyscenito FORTRAN PROGRAMMER'S| REFERENCE MANUAL Order No. AA-0944E-TB SUPERSESSION/UPDATE INFORMATION: This document supersedes the document of the same name, Order No. DEC-10-LFORA-D-D, published June 1975. OPERATING SYSTEM AND VERSION: Any Digital-supported operating system for the DECsystem-10. SOFTWARE VERSION: FORTRAN-10, Version 5 To order additional ccpies of this document, contact the Software Distribution Center, Digital Equipment Corporation, Maynard, Massachusetts 01754, digital equipment corporation - maynard, massachusetts First Printing, Revised: June 1973 January 1974 October 1974 May 1975 June 1975 November 1975 January 1977 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Digital Equipment Corporation assumes no responsibility Corporation. for any errors that may appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. Digital Equipment Corporation assumes no responsibility for the use or reliability of its software on equipment that is not supplied by DIGITAL. Copyright (C) 1973, 1974, 1975, 1977 by Digital Equipment Corporation The postage prepaid READER'S COMMENTS form on the last page of this document requests the user's critical evaluation to assist us in preparing future documentation. The following are trademarks of Digital Equipment Corporation: DIGITAL DECsystem-10 MASSBUS DEC DECtape OMNIBUS PDP DIBOL 0S/8 DECUS EDUSYSTEM UNIBUS FLIP COMPUTER LABS FOCAL RSX COMTEX DDT DECCOMM INDAC LAB-8 DECsystem-20 TYPESET-8 TYPESET-10 TYPESET-11 CHIP PHA RSTS PREFACE This manual has two parts: with SOS, and PART II1, PART I, FORTRAN-10 Introduction to LanguagJe Using Manual. FORTRAN-10 System. Operating DECsystem-10 Part I is a short guide to using the It describes the minimum set of commands necessary to input, edit, and execute FORTRAN programs. It assumes that the reader implementing FORTRAN on the DECsystem-10. has a rudimentary knowledge of or is presently learning FORTRAN programming. It is a guide The complete DECsystem—-10 The SOS to set of Operating text editor Operating Systems System Commands commands is described completely Manual in the 1is given 1in the (DEC-10-OSCMA-A-D). SOS User's Guide (DEC-10-0US0OSA-A-D) . Part II describes the FORTRAN language as 1implemented for the FORTRAN-10 Language Processing 3System (referred to as FORTRAN-10). The language manual (PART II) is intended for reference purposes only. The reader 1is expected to have some experience in writing FORTRAN programs and to be familiar with the standard FORTRAN language set and terminology as defined 1in the American National Standard FORTRAN, X3.9-19566. Descriptions of FORTRAN-10 extensions and additions to the standard FORTRAN language set are printed with gray shading. Operating procedures and descriptions of the DECsystem-10 environment are included in the appendixes. ' iii programming MASTER TABLE OF CONTENTS Page CHAPTER PART 1II FORTRAN-10 SOME INPUT HELPFUL SAYING AND INTRO OUTPUT OF DATA GOODBYE TO THE INTRO COMPUTER INTRO EXAMPLES FORTRAN-10 LANGUAGE CHAPTER INTRODUCTION CHAPTER CHARACTERS CHAPTER DATA TYPES, AND VARIABLES, AND EXPRESSIONS CHAPTER COMPILATION CHAPTER SPECIFICATION CHAPTER DATA CHAPTER ASSIGNMENT CHAPTER CONTROL MANUAL LINES CONSTANTS, CHAPTER SYMBOLIC ARRAYS CONTROL STATEMENTS STATEMENTS STATEMENT STATEMENTS STATEMENTS CHAPTER I1/0 CHAPTER NAMELIST CHAPTER FILE INTRO INTRO COMMAWDS STATEMENTS STATEMENTS CHAPTER FORMAT STATEMENT CHAPTER DEVICE CONTROL CHAPTER SUBPROGRAM CHAPTER BLOCK APPENDIX ASCII-1968 DATA APPENDIX USING APPENDIX WRITING APPENDIX FOROTS THE STATEMENTS STATEMENTS SUBPROGRAMS CHARACTER CODE SET COMPILER USER APPENDIX FORDDT APPENDIX COMPILER APPENDIX FORTRAN-10 APPENDIX FOROTS NAMES, 11-1 STATEMENTS CONTROL e INTRO PROGRAM e YOUR I CHANGING INTRO PROGRAM ULWD YOUR PROGRAM e RUNNING YOUR e CHAPTER INTRO 1IN IN — CHAPTER SOS QO ~JO CHAPTER WITH N = | P CHAPTER FORTRAN-10 1o HFRHHHRPRR CHAPTER LOGGING TYPING USING OWJO U W CHAPTER TO PROGRAMS MESSAGES REALTIME ERROR SOFTWARE MESSAGES e e CHAPTER INTRODUCTION .’EQ"‘JL‘?UOU‘J I O ~JOYU & WK PART PART Introduction to Using I FORTRAN-10 with SOS CONTENTS LOGGING CHAPTER TYPING CHAPTER CHAPTER INTRO 1IN IN YOUR INTRO PROGRAM INTRO RUNNING INTRO THE YOUR EXECUTE CTRL/C PROGRAM ("C) (GETTING THE MONITOR'S INTRO Stopping Your Deleting a CTRL/U ("U) CHANGING THE R YOUR INTRO INTRO INTRO (CORRECTING MISTAKES 1IN INTRO PROGRAM) COMMANDS INTRO — - Inserting Lines Into Your Program Deleting Lines From Your Program Replacing Lines In Your Program Printing Lines Of Your Program On The Terminal Changing The Line Numbers End (Ends Editing and Stores INTRO the INTRO | 3 FEW TAB 5 INTRO PROGRAM - Program) Returning Storing CHAPTER Execution Command COMMAND EQ A Program's (CHANGING A LINE) YOUR SOS U O H SOS 50S To Your the Monitor Program FORTRAN-10 INPUT INTRO AND OUTPUT OF DATA UNIT ACCEPT STATEMENT INTRO INTRO NUMBERS TYPE STATEMENT DATA FILES INTRO INTRO INTRO FORTRAN Use a Predefined INTRO Filename Your HELPFUL Own Filename COMMANDS TYPE COMMAND (PRINTING OUT YOUR PROGRAM) DIRECT COMMAND (LISTING ALL STORED PROGRAMS AND FILES) DELETE COMMAND (ERASING A PROGRAM OR INTRO INTRO STATEMENT DEVICE SOME INTRO INTRO STATEMENT Letting 6 INTRO INTRO MISTAKES Using INTRO INTRO (CTRL/I) WRITE INTRO Without CONVENTIONS CORRECTING READ CHAPTER INTRO INTRO COMMAND ATTENTION CHAPTER INTRO TO 3TOP ENTERING LINES INTO YOUR PROGRAM ENDING OR STORING YOUR PROGRAM(E) THE RUBOUT OR DELETE KEY (CORRECTING TYPING MISTAKES) INTRO INTRO INTRO INTRO INTRO FILE) ix CONTENTS RENAME A NEW COMMAND (CONT.) (GIVING A PROGRAM OR FILE INTRO NAME) CTRL/O (SUPPRESSNG PRINTED OUTPUT) INTRO INTRO GRIPES CHAPTER 7 SAYING GOODBYE TO THE KJOB COMMAND (LOGGING K/F Command HELP WHAT TO DO YOUR JOB FORGOT CHAPTER 8 IF YOU Logout) INTRO (Getting ARE Assistance) DISCONNECTED NUMBER? INTRO FROM INTRO (ATTACH) YOUR JOB EXAMPLES INTRO (Fast Command INTRO COMPUTER OUT) (SYS) INTRO INTRO CHAPTER 1 LOGGING-IN To begin programming you need an need you to make a need the information on the account DECsystem-10 Timesharing number and a password. telephone connection to computer's telephone You Systenm, may also the computer; 1if so, number. Write this here: Telephone Number: (1f needed) Account Number: Password: NOTE Before logging-in, be sure to read Chapter 7 on KJOB (logging-out) . If you do not log out, but merely disconnect your terminal, the DECsystem-10 accounting and WILL system CONTINUE will TO not CHARGE know you have YOU FOR TERMINAL finished TIME. First, make sure that the terminal is turned on to LINE. If you are to make a telephone connection to the computer, turn on the acoustic coupler and then dial the telephone number to make the connection to the DECsystem-10. The computer now may print and will print: FLEASE LOGIN OR a few 1lines identifying 1itself ATTACH followed by a line beginning with a period (.). This period signifies the computer's readiness to accept your LOGIN command. If the computer does not orint a period, type CTRL/C ("C). The may appear as an + on some terminals. The computer will respond with a period. | NOTE To type CTRL/C, hold the Control (CTRL) key down while typing C. This causes the computer to print the characters "C on the terminal. 1In this book, the symbols “C will mean that you are to type CTRL/C. 1In order to signal that vyou wish to give it a “"C. This attention is your way of so that vyou command. INTRO-1-1 the computer system command, you can type getting the computer's <can give 1t vyour next LOGGING-IN MONITOR Monitor: In system the executive what follows we shall often call the computer monitor; this 1s the operating system or program that directs the execution of all the programs and performs the record-keeping duties for the computer. You may now log .LOGIN in by typing: account number <CR> ("<CR>" means carriage return.) Example: 1If LOGIN your account number were 27,240 you would type 27y 240<CR> NOTE We shall to use press labelled the the CR or "carriage job RET type will be to key. and show This is key often To where vyou may referred to distinguish and those used for the the are also be as a between computer prints, characters you, the type. monitor JOB CAR you uderlining The <CR> return". characters user, symbol RETURN will now number respond system with number the lines: TTY terminal 1line number You should PASSWORD: (The PASSWORD The job number monitor respond Since by many password is now asking your users prefer 1s and would appear not 1f by the for your password and to keep ©printed. everything If you monitor.) password. pressing the their passwords your password typed were RETURN secret, were printed, the key. the word the output account number as: PASSWORD: what assigned typing TROLL, But is TROLL actually appears is FASSWORD S The monitor and signals password message. by Then ready to will look accept passages it types your something are its those acceptance typing a that date, period (.) indicating this you What LOGIN have typed). 274 240<CR> 28 ROG72510 FASSWORTE 1242 18-NOV--76 BYS #4072 <CR> TTYLQ6 THUR INTRO-1-2 you (remember Example: 0B your time, command. like of the and now have that the perhaps that on it the a 1is page underlined CHAPTER TYPING To type called in o SOS your SOS. IN YOUR program, Call SOS 2 PROGRAM you by will giving use the an editing monitor program command: HOSKCR> responds with: L¢ asking your you for program the name on a of your file. disk.) You must (The give which you and the computer can refer to it of this name as the name of your program. from one to six handle several declare that letters or different this file computer the Because computer languages, be used stores a name by - you may think This name must be digits. will file to the computer you store must a can also program written 1in FORTRAN language. This is done by extending the name of your file with the letters FOR. These letters will be separated from the filename (or program name) by a period. Some examples of filenames in which you may store programs written for FORTRAN are: ASPEN.FOR ASC123.FOR INSPIR.FOR Whenever you refer to your program, use its full name with extension. Now you should Example: type (Here in the the name name of of your the file/program. file or program is ASPEN.FOR.) R SOS<KCR> FILES SOS will now INFUT?: ASFEN.FORKCR> print: ASFEN.FOR Q0100 and the carriage will move 1) for you to begin typing your FORTRAN through program, columns 1 to the correct program. INTRO-2-1 5 are position (column in a Remember that reserved for the TYPING IN YOUR PROGRAM statement number, column 6 is the continuation field, and The columns 7 through 72 are for the FORTRAN statement. 00100 that SOS has printed 1is not part of your number program, but is S0S's line number for the first statement of If this first statement is not a numbered or your program. (to column 7) spaces comment statement, you must skip 6 1in the statement. When you have before beginning to type the RETURN press typed in the first line of your program, and SOS will print the next line number (in increments key, vyou may enter of 100); the next 1line of your program. Thus, when SOS prints a line number, you know that it is (For a fast way of ready to accept a line of your program. on TAB, page INTRO section the see field, skipping the label 4-6.) TO STOP ENTERING LINES INTO YOUR PROGRAM (ESCAPE) ESCAPE when you wish to stop entering lines into your program, Yyou should press the ESCape key (on some terminals labeled ESC, key as this to We shall refer ALT, ALTMODE, or PREFIX). Pressing the ESCape key causes a $§ to be printed on ESCape. the terminal. (In this example, the first statement is a comment Example: the character C is in column 1.) statement: ~C R 505<CR> FILE? ASFEN.FORCCRY INFUT? ASFEN.FOR C THIS IS AN EXAMFLE .KCR> 00100 TYFE_10<CR> 00200 00300 10 00400 00500 % FORMAT (' ASFEN IS A NICE FLACE TO SKI!‘)XCR> ENIKCR> X SOS Note that we have two programs that are already stored in As you - the system monitor program and SOS. computer the your accept to readiness know, the monitor indicates its 1its indicates SOS (.): command by printing a period jm readiness to accept your command by printing an asterisk When you press the ESCape key, SOS returns with an (*). asterisk (*) showing that it is ready to accept a command. ENDING OR STORING YOUR PROGRAM (E) finished writing your It is very important, when you have that you tell SOS you are done and that it should program, You store your program until you are ready to use it again. for a command by typing the End respond to SOS's request command (the letter E) and the RETURN key. Example: XE<CR> COSKC:ASFEN.FOR] INTRO-2-2 TYPING IN YOUR PROGRAM In this example, SOS tells us that the program ASPEN.FOR has been stored on the disk (named DSKC:). Then S0OS turns control over to the monitor, which signals its readiness to accept your next command by printing a period. NOTE The SOS END command, E, is essential. tell SOS to store your file befors you monitor, your program will be lost. RUBOUT THE RUBOUT OR DELETE KEY (CORRECTING 1If you return TYPING don't the to MISTAKES) If you make a mistake while tyving a 1line, the RUBOUT (DELETE or DEL) key allows vyou to correct your mistake without having to retype the entire line. Press the RUBOUT key once for each character you wish deleted. This causes the deleted characters to be printed with a backslash (\) before and after them. Then, type the correct 'N' has been characters. Example: FILES In this ASFNAMNNENFORSCR> example, the character (7 AFENEFNSFEN the RUBOUT rubbed out. Example: QO300 In 10 this the FORMAT example, unwanted characters Think of are the IS5 key was characters PE. printed reverse RUBOUT key in as a INTRO-2-3 A Note NICE FLACE TO SKI!7)<CR> twice to erase the deleted erasure" key! pressed also that order. "backspace plus 3 CHAPTER RUNNING THE EXECUTE EXECUTE BEX YOUR PROGRAM COMMAND To execute or cause the computer to follow the given by the program, command the monitor to: instructions filename.extension<CR> .EXECUTE Example: EAECUTE ASFEN. FORCCR> FORTRAM: ASFEN MALM. (] LOAOTING CLNKXCT ASFEN EXECUTIONI] ASFEN 16 A NICE FLACE TO ENG QF CRU TIMES SKI! EXECUTION 0,05 ELAFSED TIMED 0.13 EXIT EXECUTE may be abbreviated to EX. NOTE You may have been puzzled at the occurrence of lines the monitor before the actual execution by written in the above example. They appear because before your FORTRAN source program can be executed, it must language machine a be translated or compiled into orogram (the object program) that the computer can execute. This is done during the step 1labeled FORTRAN: filename. This object program, like the original source program, is stored in a disk file. Before the program can be executed, a copy of the compiled or object program must be placed (loaded) into the working memory of the computer - this copy is often called a core image of the object vprogram. This 1is accomplished during the LINK: LOADING step. Finally, the execution step is performed. INTRO-3-1 RUNNING YOUR PROGRAM Few programs will complete execution the very first time you try to execute them. Do not be discouraged! Chances are that the compiler will find at least one mistake 1in your program. To help you find your mistake(s), it will type out a message to you. For example, suppose that you have made the following mistake in the program on page INTRO 2-2: 1in the FORMAT statement in line 300 the closing quote has been omitted. The program would look like this: QO1LAD C THIS 0200 00300 10 10 EXAMFLE. ¢’ ASFEN 1S A NICE cause the FLACE TO SKI!) END attempt EX AN FORMAT 00400 An IS TYFE to EXECUTE it will following: ASFENFORCCR> FORTRAN: ASHFEN Q0300 PEFTNCAL LLINE:OOI00 10 FORMAT (7 ASFEN IS NO CLOSING QUOTE TFTNFUWE LINE:OO300 FOUND END OF A NICE FLACE IN LITERAL STATEMENT WHEN TO SKI!) EXFECTING A fl)l‘ UNDEFINED LARELS 10 TFTNFTL MAIN. LINK? FLNKNSA LOADING NO START 3 FATAL ERRORS AND NO WARNINGS ANDRESS] EXTT If the compiler has found errors in your program that make execution impossible, you will again have to call on SOS to help you correct your program. Do this by using the R SOS command discussed in Chapter 4. NOTE The compiler will only print error messages for cases where the program is not clearly understood. It is possible to have a program that consists of valid FORTRAN statements, but gives the wrong answers. For example, suppose you intended to enter TAX but by = RATE*AMOUNT mistake TAX = typed RATE+AMOUNT INTRO-3-2 RUNNING YOUR PROGRAM The compiler both type cannot detect this as because an error Errors of this wvalid formulas. possibly are (logic errors) are the most difficult to find. The program will run, but the answers will be wrong. the read Frequently the author of the program will and see what he meant to write instead of statement valuable extremely One wrote. actually what he of finding errors of this kind is to attempt method should program the to explain to someone else why of explaining will often highlight act The work. to Another method of locating errors is the error. @ have another programmer your code. (GETTING THE MONITOR'S ATTENTION) ("C) CTRL/C "proofread" a it to _give that you wish CTRL/C informs the monitor interrupts whatever the computer 1is The monitor command. to ready 1is doing and prints a period to indicate that it hold the Control To type CTRL/C, accept your command. key down while typing C. (CTRL) Stopping Your Program's Execution CTRL/C interrupts control to a program the monitor. CTRL/C twice to during execution, returning Sometimes it is necessary to type interrupt a program. Example: JEXECUTE FORTRAN: ASFEN.FORSCR> ASFEN I‘\Cl‘\C Deleting a Command You may also use CTRL/C to delete the line you are presently typing and return control to the monitor. Example: JEXECUTE ASFEN.FORTC Typing "CONT" in answer to a monitor prompt will return to your previous activity IF AND ONLY IF you have not: . . tampered with the core image, OR caused the FORTRAN compiler image in <core to you Dbe overwritten. 1f, for instance, message a send to program executing the you interrupt another terminal, you can on someone to INTRO-3-3 RUNNING YOUR PROGRAM return. If you, say, request a directory activity, then the FORTRAN compller 1is overwritten and you cannot return to your previous activity. When in doubt, wait until the execution 1s complete, unless vyou want to restart the execution anyway. B CTRL/U ("U) (CHANGING A LINE) CTRL/U deletes the entire line you are typing and moves the carriage to the beginning of the next line. You may then retype the line. Note that CTRL/U only deletes that vart of the 1line vyou have typed and not the part the computer prints, i.e., in the following example the 1line number |is not deleted. CTRL/U is typed by holding the Control (CTRL) key down while typing U. Example: Q1800 490 SEHQAT 40 SRQAOT = SQRT = ST (0I8CY U (NISCIKCR> 01900 In this example, CTRL/U deletes your input line, which vyou then reenter. CTRL/U does not delete the line number, 1800, printed by If you wish the RETURN SOS. to delete the line key. INTRO-3-4 entirely, follow CTRL/U with CHAPTER YOUR CHANGING THE R SOS COMMAND 4 PROGRAM (CORRECTING MISTAKES IN YOUR PROGRAM) S0S. to To correct a mistake in a program, you must return we saw on page INTRO 2-1, we turn control over to SOS by As commanding o SOS the monitor: SOESCR> responds with: FrLE: QuUAD. FORKCR> case this 1in extension, and filename the type and we But now SOS recognizes that this program already QUAD.FOR. a inputting of exists and correctly assumes that, instead you wish to edit file, FEOLTe it. SOS thus types: QUATT. FOR X The The asterisk (*) indicates that SOS is at your command. that are commands SOS 1lists section this of remainder FORTRAN simple essential for typing and editing Use the ESCape to terminate these commands. SOS I INSERT - programs. COMMANDS Inserting Lines Into Your Program To Insert lines into your program beginning with line for instance, you give SOS 2700, the command: X 1L2700<CR> SOS types out each line number, and you respond by inserting When you press the RETURN key the program. into 1line the number. after typing each line, SOS will type the next line (This is called "Insert Mode".) INTRO-4-1 CHANGING YOUR PROGRAM Example: ¥ L2 700<KCR> QD00 PFOCOEaCY D200 41) FOOQTL = 20y 30y (- 4KCR> GURT (DLEST)Y) /C2¥AXWCRY WEP0O0 Terminate the Insert (ALTMODE/PREFIX) ; command this causes by a §$ typing to be ESCape printed on the terminal. Example: K LAO00OKCR> Q3050 W) DA1L00 i # WRITE (5. 701KCR> - Note that in the above examples, S50S has numbered the 1lines in 1ncrements of 100. The reason for providing this increment 1is to allow you room to maneuver - suppose you have accidentally omitted lines that must now be Inserted, or suppose you now find 1t necessary to —changes vyour original program. If you have left out 2 lines that should have gone lines by command: between lines changing the L3210 and 3300, you may increment 3200 size, say, to Insert 20, these using the E0KCR> This allows you to Insert lines 3210, 3230, 3250, 3270, and 3290 1into your program. The size of the increment is of no importance as long as it 1s small enough to accommodate all additional 1lines. Each time you change the increment size, the new size is kept until you change it. Example: XI32100 20<CRY WRITE (52 50) OB230 50 (/7 0XRE0 T 0F210 FORMAT ROOTL1r ROOTS ROOT2CR> ARE‘y F10.2y ‘ANI‘y F10.2)<CR> & « If you try to or equal than . . insert a line whose that of the next to 1line use a different line number, ignore the command entirely INTRO-4-2 number line, existing or 1s greater SOS will: CHANGING YOUR PROGRAM Deleting O - D DELETE To delete Lines line From Your Program from program, 500 your type XO5H00<KCR> Example: XHQO<KCR> 1 LINES (0050071) DELETED X through 1400 I1f you wish to delete lines program, 1600 from vyour use: *¥N1400:1800KCR> Example: AN14002 LEOOKCRD ZLINES (0140071816000 DELETED in Your Program X R REPLACE R - Lines Replacing command Delete a of The Replace command is a combination To instruct SOS to delete Insert command. an by followed line 1700 and to begin inserting lines at line 1700, use the Replace command: ¥R1700<KCR> This is equivalent to the command command D1700 followed Dby the I1700. Example: ¥R1700<CR> 01700 1 LLINES &0 FORMAT (7 ROOT (0170071) DELETED 1572 F10.2)XCR> ¥ To replace lines 500 through 700 use: ¥RG00: 700<CR> delete to SOS commanding D500:700 This is equivalent to I500 command the by followed 700, through 500 lines instructing SOS to begin inserting INTRO-4-3 lines at 500. CHANGING YOUR PROGRAM Example: MRG0 70GLCR> QOUNO0 QDAHQ0 QOO0 &0 SO (OGQEO0Q/L FORMAT (7 QGIVE CQEFFTCIENTS " 3KCR> READ iy 102 Ay ke CKCR> FORMAT (F10..23<CR> IR, LINES 007000 NELETED X If you also wish Replace to change the increment size to 10, use the by the command: ARLOO00: 1100 LOGSCRY This is command equivalent I1000,10. to the command D1000:1100 (DISCIKCRY followed Example: ¥ELOOO 1100y 1OCCRY GLO00 SROOT = SOART 01010 40 [ENOM = 2%A<CR> 01020 ROOTL = (~E + SROOT) 7/ DENOMCCRD> 01030 ROOT2 = (~K - SGROOT) / UENOM<CR> 01040 % 2 (0100071601100 LINES UELETED * As with | o command, P PRINT If - the use Printing you wish 1Insert the Lines to command, ESCape of print as in Your line to the Program 1800 of terminate above on the your the example. Terminal program, type *F 1 8OOKCR> Example: A LB8O0QKCR> 01800 40 SROAT = HSART (DI&SC)H through 3000 of X To print lines 2700 XFZ700QE3000<KCR> INTRO-4-4 your program, use Revlace CHANGING PROGRAM YOUR Example: 27000 3000KCR> G200 2800 DRS00 XY FOQT = B WRITE (50 &) FORMAT (7 GOOTAO 16O DRO00 /7 (2HKAD 600 ROQT ROOT IS 79 F10.2) ¥ - the Changing N N NUMBER The Number Line command Numbers instructs SOS to renumber your vrogram SOS does not 100 in increments of 100. 1line at beginning the see to wish you If print anything on the terminal. renumbered program, you must use the Print command. Example: *N<CR> X Editing and Stores the Program) | &3 (Ends E - End END 350OS inform program, your when you have completed editing typing by disk the on program your store now should it that If you do not instruct 50S to store your E (end). the editing you have just completed will be lost. program, Example: ¥ KCR> 924011 QUAD. FOREZ27 COSKCI been QUAD.FOR has named program This indicates that the The End command turns control over to the on DSKC:. stored monitor, which prints a period to indicate its readiness accept your next to command. EQ - Returning to the Monitor Without Storing Your Program QUIT If you decide that the current editing session is worthless, return to the monitor without storing your program may you by using the Quit command. INTRO-4-5 CHANGING YOUR PROGRAM Example: *EQSCR> This restores the original copy of the program as 1it was when vyou last typed R SOS. If the program is a new one, 1t is deleted since an original program did not exist. A FEW SOS CONVENTIONS 1. A range of lines is first and last line indicated by a colon between the numbers of the range, i.e., 500:700. 2. A period represents the current delete the current line. line. Thus, D. means Example: D700 80 FORMAT (70GIVE COEFFICIENTS?) X1 <CR> (00700/1) LINES 1 DELETED X In the above example the current is 3. TAB TAB line is line 700 and it deleted. An asterisk is used to represent the last 1line of the file. Thus, to instruct SOS to print out your entire file use: X0 ¥<CR> (CTRL/I) The TAB or Horizontal Tab (sometimes labeled HT or-|) is handy when vyou are entering lines into your program. The TAB, similar to that on a typewriter, is set at 8-character intervals. It moves the carriage to the next column that is a multiple of 8; no characters are output on the terminal. As you know, a FORTRAN statement must be located within columns 7 through 72, although it may appear at any point within this range. Using the TAB to skip over all or part of the label field will bring the <carriage to column 8, enabling you to begin your FORTRAN statement in that column. If your terminal does not have a key labeled TAB, use CTRL/I instead. while To typing CORRECTING type CTRL/I, INTRO To change the Control (CTRL) key the key (see MISTAKES To correct one page hold down I. or more characters use RUBOUT 2-3). an entire line use CTRL/U INTRO-4-6 (see page INTRO 3-4). CHANGING YOUR PROGRAM Example: ¥NO1500 "LUKCR> T2000<KCR> 2000 In the above example, CTRL/U (~ U) allows you to command "Delete line 1500" to an insert command. change the Example: L SOS<KCRY FILES ZELDA.FORKCR> INFUTS ZELDA.FOR 00100 00200 00300 00400 00500 £ THIS FROGRAM DOES NOTHING.<CR> 10 TYENENFE 00400 *1500<CR> 00500 00700 00800 20 ACCEFT 30 00900 40 01000 $ ¥RPOOLCRY 00900 40 01100 50 01000 01200 01300 1 LINES TYFE 20 FORMAT (¢ WHAT I8 YOUR NAME?’)<CR> ACEFT 30y YORNAM "U 30y YORMAMCCRY FORMAT (A5)<CR> YORNAMCCR> TYFE_40y ‘HIy’s FORMAT (‘0°y FORMAT (‘OHIy’ TYFE 50<CR> FORMAT _( » ASy A%Ss ’ ‘IO YOU EANT?IKCR> sD00 YOU’)ISCR> WANT TO EE FRIENDS?’)<CR> ENIKCR> $ (00900/1) *R9OO ¢ 11 00<CR> 00900 40 01000 & 3 LINES 20<CR> B KE400< CR> 004600 TYFE 10<CR> FORMAT (7 1T//5 WORKING!’)<CR> DELETED FORMAT (00900/1:01100) (‘OHIs ‘s ASs ‘y WANT TO RE FRIENDS?Z)<CR> LELETED KN<CR> T XSCR> KFO C THIS FROGRAM DOES NOTHING. 00100 00200 00300 00400 00%00 D0600 00700 00800 00900 01000 10 20 30 40 TYFE 10 TYFE 20 ¢/ IT’’S WORKING!’) FORMAT (/ WHAT IS YOUR NAME?’) FORMAT (‘OHIy FORMAT ACCEFT 30y YORNAM FORMAT (AS) TYFE 40, YORNAM END ¥ <E CR> [NSKE: ZELDAFOR INTRO-4-7 ‘» ASs ‘s WANT TO EE FRIENDS?/) CHANGING PROGRAM YOUR Let us look at the above example in detail. e HOBKCR> <control over to SOS requests the name of the file you wish to Commands the monitor to turn program the editor SOS. FILE: ZELOA.FORKCR> respond with the name of your INFUTe Q0100 ZELDA FOR C THIS FROGEAM file or program: DOAES edit. You ZELDA.FOR. NOTHING.KCR> <concludes 1t name, this When SOS fails to find a file by SOS then prints the intend to create a new file. you that are vyou Now number. name of the file and the first line ' ready to enter the first line of the program. Q0200 TYFE 10<CR> Each time you finish typing a line and press the RETURN key, SOS prints out 00300 10 the next line number so that you may input In typing line 200, the first character actually that line. typed was a TAB (CTRL/I), which caused the label field to be spaces this avoids the necessity of counting skipped over; would begin in the proper statement FORTRAN our that so TAB is a non-printing character. column. FORMAT (7 IT’’S WORKING! )<CR> This statement 1is 1labeled. After tyoing the FORTRAN vyou type the non-printing character (10), 1label statement TAB (CTRL/I) to skip over the remainder of the label field. a printing FORMAT of character first the that Remember which statement must be the carriage control (here a blank, Notice that because apostrophes means single space output). allowable not are used to enclose literal fields, they are 1instead be must but field 1literal a within characters words, 1In other represented by two successive apostrophes. although line 300 appears in the program with two successive word the causes it avostrophes (IT''S), in the execution IT'S to be printed (see the EXECUTION which follows). 00400 Again, label TYENENFE 20<CR> here a non-printing TAB is used field. The D0E00 % The ESCape key RUBOUT key terminates erases the program. ¥400<CR> INTRO-4-8 the input to skip over the 1lines 1into the E. of CHANGING YOUR PROGRAM You ask it 1lines into your SOS is now ready for a new command. line print to 400. SOS prints 20 TYFE 00400 line 400. ¥ LHOOKCR> Your next step DOL0O0 20 1s beginning with line You type 500 line to insert FORMAYT (7 into your ACEFT 0600 ACCEFT ©program 500. 30y WHAT 18 YOUR NAMET”)<KCR> program. 30y YORNAM U YORNAMCCRY After typing in line 600 but before pressing the RETURN key, that you have misspelled ACCEPT. notice and you pause retype then vyou which 1line, the deletes ("U) CTRL/U beginning with the non-printing TAB. 00700 00800 FORMAT (ABIKCR> TYFE 40+ YORNAMCCRY> A0 QOY00 49 R1GO0 & FORMAT A% ‘10 YOU EANT”)<CR> (707y'HIy program and into vyour 900 through 700 You enter lines '0' in the The carriage control 1insert. terminate the spaced. double be to output the causes FORMAT statement XRYOOLCR> R900 The 900. 1line At this point, you decide to replace deleted and initiates an Insert be to it causes command command beginning with line GOYQ0 01000 00100 FORMAT 40 TYFE (~ s ASy 7 D10 YOU’IKCR> WANT TO RE FRIENDSTZ)KCR> ENIKCR> 01200 01300 (/0OHI»’ SOKCR> FORMAT a0 900. $ 1 LINES (00900/1) NELETED When you use the ESCape key to terminate the insert command (initiated by the replace command), SOS informs you that one line (line 900) has been deleted. XRPO0:1L100KCR> INTRO-4-9 You decide to CHANGING YOUR replace lines 900 QP00 A) 01000 % GOLINES (0092001201100 Line 900 confirms FORMAT PROGRAM through (“OHTy "» Ay’ sy 1100. WANT TO RE FRIENIS?’)IKCR> DELETEDR is replaced and the that three 1lines command 1is terminated. (900 through 1100) have SOS been deleted. ¥N<CR> 505 and 1s in ¥ You now asked to renumber steps of 100. the lines beginning with 100 GO HLCRY instruct SOS to print out your entire program. ¥E<CR> To conclude the editing on the disk. session, instruct SOS to store vyour program FOSKCTZELDAFOR] Your program in control. The has been of the EXECUTION e EX stored above on DSKC:. program: ZELUAFORCCR> FORTRANS: ZELDA MAIN. LINICS L.OALIING LLNKXCT ZELOA LT85 WORKING! WHAT T& YOUR EXECUTIONI NAME? HAL<SCR> HIs HAL v END OF CFU TIME: WANT TO RE FRIENDS? EXECUTION 0.10 ELAFSED TIME:? EXTT INTRO-4-10 10.20 The monitor 1is now CHAPTER FORTRAN-10 INPUT AND 5 OUTPUT OF DATA Although FORTRAN-10 is essentially the same as standard FORTRAN, a few minor differences do arise in statements that involve The input and output of data. STATEMENT READ READ the statement READ (u,f)list where u=device unit number f=FORMAT statement and number the reads data from the device with unit number u (refer to below) according to the Numbers, Unit Device on section specifications given by FORMAT statement f. Example: 00800 READI OO0 WRITE WRITE (3 FORMAT 35) IGHRADE <(13) STATEMENT This has WRITE where 3% the form (u,f) 1list u=device unit number f=FORMAT statement and number Example: 01000 01100 WRITE 30 FORMAT (1s 30) (8AGy (STUONTC(I)»I=1y8)ys IGRALE 13D NOTE The ERR option of the OPEN and CLOSE also Refer applicable to Chapter to 12 the READ INTRO-5-1 and statements WRITE 1is statements. FORTRAN-10 DEVICE UNIT INPUT AND OUTPUT OF DATA NUMBERS In READ and WRITE statements, we must specify to which device (Disk, Line Printer, Terminal, etc.) we are referring. For the DECsystem-10, the device wunit numbers, u, are uniform - they are the same on all DECsystem-10s. The most commonly used are: Device Device Disk a Number,u 01 Card Reader 02 Line Printer 03 Terminal (For Unit 05 complete list see FORTRAN-10 Language Manual, Table 10-1.) Thus, WRITE (5,7) causes outnut terminal; READ (1,25) causes data ACCEPT ACCEPT To be printed be read from on the vyour disk. STATEMENT input where to to data from ACCEPT f,list f=the FORMAT the terminal statement you may use number. Example: 0O%00 NDO&LOO TYPE 20 Thus, "ACCEPT TYPE STATEMENT To have where 20 FORMAT (13) f,list" output TYPE ACCERFT tyved is on TGRADE equivalent your to terminal "READ (5,f) list". FPLACE TOQ use f,list f=the FORMAT statement number. Example: Q0200 QO300 Thus, "TYPE TYFE 10 f,list" 10 FORMAT is (7ASFEN equivalent I5 to A NICE "WRITE (5,f) SKI!7) list". NOTE To print carriage something on your control character a line prnter. your terminal, QDA200 Q0300 For use TYFE 101 terminal, you must similar to the way example, to print the word format statement below: the 101 FORMAT (7 INTRO-5-2 HELLQ?) include a you do for HELLO on FORTRAN-10 The new DATA space line. INPUT before AND HELLO OUTPUT tells OF DATA the system two ways: to start on a FILES You may use 1. In the data files in first method, one of you let FORTRAN use a vpredefined filename. 2. In the the second method, OPEN Letting you choose the filename by wusing statement. FORTRAN Use A Predefined Filename There are six Device Unit Numbers for disk files; whenever you use one of them, FORTRAN uses a predetermined filename. Te device numbers and their filenames are listed below. Device Unit Number Filename 1 20 21 FOR(QO1l.DAT FOR20.DAT FOR21 .DAT 22 FOR22 .DAT 23 FOR23 .DAT 24 FOR24 .DAT NOTE If you omit the filename from an OPEN statement, FORTRAN uses the filename <corresponding to the device unit number. Examples: QO200 WRITE (1yl101) X Writes the value of X 1in the file FORO1.DAT, according to FORMAT statement 00300 READ Using OPEN Your To use first OPEN (23+109) Own your READ own or statement OPEN n is the the file Y 101. Reads the value of Y from the file FOR23.DAT, according to FORMAT statement 109. Filename filename, place WRITE statement has (UNIT=n, the an OPEN statement that accesses the before file. the The format: FILE='filename.ext') device unit you want to number, use. INTRO-5-3 and filename.ext is the name of FORTRAN-10 INPUT AND OUTPUT OF DATA Example: 0200 (UNIT=20y OFEN ) FILE='TEST.DAT Instructs FORTRAN to oven on TEST.DAT file the logical unit number 20. DOIH0 SEAN (204108) Y Reads Y from logical unit file (The 20. number same name implied 1is the file name in the the as OPEN same with statement logical the unit number.) After the last READ or WRITE statement that accesses a file, recommended (though not required) that you include a 1is it CLOSE statement. CLOSE CLOSE The CLOSE statement has the format: (UNIT=n, FILE='filename.ext') n is the device unit number, and filename.ext is the name of the file you are closing. Example: QOH00 CLOSE (UNIT=20y ) FILE=TEST.DAT Closes the file TEST.DAT on logical unit number INTRO-5-4 20. 6 CHAPTER SOME HELPFUL COMMANDS TYPE TYPE COMMAND (PRINTING OUT YOUR PROGRAM) If Usually you will have made many changes in your program. you would like the monitor to TYPE out your terminal as it now stands, command 1t to: .TYPE program oOn your filename.extension<CR> Example: +TYFPE ASFEN.FORKCR> C Q0100 Q0200 THIS FORMAT 10 Q0300 IS AN EXAMFLE. TYFE 10 (7 ASFEN IS A NICE FLACE TO SKI!7) ENII 20400 ¢+ DIRECT COMMAND DIR (LISTING ALL THE The DIRECT command programs and files causes stored STORED PROGRAMS AND the to monitor in disk files 1list under FILES) all your the account number. It also lists the length of each program or file 1in terms of DECsystem-10 disk blocks (a disk block is 640 characters) and the data on which each was created. This command may be abbreviated to DIR. Example: + NI KR<CR> ASFEN ASFEN ASFEN NEW QAUAT NEW AUAT GNOW QUAD REL QA0OR FOR QOR REL FOR QAOK FOR FOR 1 1 1 2 3 2 2 1 2 055 0SS Q55 w055k 085 w059 w055 =055 Q85 18-NOV-76 18-NOV~-76 18~NOV~76 18-~-NOV~-76 18-NOQV-76 18-NOV--76 18-NOV-76 18-NOV~76 18~NOV-76 NSKEC$ [272240] TOTAL OF 15 BLOCKS fN 9 FILES ON DS8KC?: [275240] ¢ These files belong to the programmer(s) 27,240. INTRO-6-1 with account number SOME HELPFUL COMMANDS You may find that files you did not create are also listed. These may be programs and files created by the computer in editing and compiling your program. The compiled program 1is contained in a file named "filename.REL" where the filename is the same one that you used. If you have edited vyour program there will be a program whose name is identical to yours except that it has a Q as the first 1letter of the extension. This is a backup file containing your program as it existed prior +to your most recent editing of 1it. Each time vyour orogram is edited, the program immediately before editing becomes the backup, and the previous backup - 1f it existed - is lost. 1In the foregoing example, the only files explicitly created were ASPEN.FOR, NEW.FOR, SNOW.FOR, and QUAD.FOR. The backups are ASPEN.QOR, NEW.QOR, and QUAD.QOR. SNOW.FOR has not been edited, so it has no backup. DELETE COMMAND DELETE (ERASING A PROGRAM OR FILE) To erase a file from the disk, .DELETE command the monitor to: filename.extension<CR> Example: JDELETE ASFEN.FORCCR> FILES DELETEIDS . FOR ASFEN 01 RLOCKS FREED RENAME COMMAND RENAME (GIVING A PROGRAM OR FILE A NEW NAME) file use To rename a the command .RENAME newfilename.extension = oldfilename.extension<CR> Example: « RENAME EXAMF FOR=8N0OW.FORKCR> FILES RENAMEL:? . FOR SNOW This will cause the name of SNOW.FOR to be changed to EXAMP.FOR lo CTRL/O (SUPPRESSING PRINTED OUTPUT) CTRL/O ("0O) stops printed output on the terminal The program sending the output CONTINUES TO RUN. Use CTRL/O, for example, to stop the message of the day during LOGIN or to stop the monitor as it TYPEs a program you have asked for. CTRL/O is typed by holding the Control (CTRL) key down while typing the letter O. INTRO-6-2 SOME HELPFUL COMMANDS Example: ¢ TYFE ASFENFORCCR> DOLO0 COTHIS 40200 IS AN TYFE QOIA0 EXAMEFLE. 10 ~0 [3 Although CTRL/C also stops output on the terminal, stops program it also execution. Complaints to the Computer - the "Court of Last Resort” GRIPE Wnen all else fails and you must gripe the computer by commanding the monitor e to someone, to: to GRIFECCRY The computer will YEST respond with: (DEFRESS ESCAFE KEY WHEN Now enter your gripe and press the finisned. Remember that typing THROUGH) ESCape key when you have ESCape <causes a $ to be printed. Example: e GRIPE GRIFECCRD YEST THIS THANK (NEFRESS ESCAFE KEY WHEN THROUGH) CONSOLE I8 ALMOST OUT OF FAFER.$ YQOU INTRO-6-3 CHAPTER SAYING KJOB COMMAND GOODBYE TO 7 THE COMPUTER (LOGGING-0UT) To say goodbye (K111J0B) : to the computer, command the monitor to KJOB type CTRL/C ("C). ¢ [LIOB<KCR> KJOB The monitor will respond with CONMFLTRM? KILL Should you now decide to abort the logout, If you still wish to logout, you must instruct the monitor to kill, preserve, or save each of your disk files. If a file 1is killed, it 1is erased from the computer memory; saved and preserved files, on the other hand, are retained in the computer memory. Preserve and save are essentially alike except in the matter of protection against inadvertent loss or destruction. Preserve, unlike save, protects your files from accidental destruction by another user who shares your account number. This may occur if, for instance, the other user fails to recognize the name of your program during his 1logout and, failing to see any need for its preservation, kills it. To take advantage of the protection afforded by the preserve file status, it is best to respond to the CONFIRM with CONFIRM: U the letter U: <CR> This will automatically preserve any files that have already been preserved during a previous logout. After you have typed in the letter U and pressed the RETURN key, the monitor will 1list the name and storage information of each unpreserved file stored in your disk area, pausing after each name for vyour response. Following the name of each file you must a o) C respond by typing one of the g’ SAVE K if you wish to kill e’ N’ PRESERVE P S to to it, and Please space preserve save 1it. remember on the the saved or the three commands: file, preserved files occupy valuable disk. In general, the only files you need preserved have the extension FOR. If you have no further changes to make 1in your program, you may preserve the compiled version this will have the extension REL. INTRO-7-1 SAYING GOODBYE TO THE COMPUTER NOTE The DECsystem-10 offers the option of detaching the terminal from your job, thereby freeing the terminal and the telephone line for another task while vyour program is executing. (This option is, of course, only used for programs with long execution times; for details see the DECsystem—-10 Operating System Commands Manual.) Therefore, TURNING OFF THE TERMINAL OR BREAKING THE TELEPHONE CONNECTION TO TiHE COMPUTER DOES NOT END COMPUTER CLOCK; ONLY YOUR JOB, NOR DOES IT THE COMMAND KJOB WILL STOP THE DO THIS. If you should inadvertently hang up without wusing KJOB, the computer clock, thinking that you have not yet completed vyour job, will keep ticking and CHARGING YOU FOR TERMINAL TIME. So please remember to USE KJOB BEFORE LEAVING THE TERMINAL. If vyou should be accidentally disconnected, always call again and end your Jjob properly. (See page INTRO 7-3.) Example + RJOR<CR> U<CR> CONFIRKM: NSKAL NHREGS BLKS ¢ H<CR> ASFEN +REL ~QEGx G NEW QUAD EXAME « QOK . REL. JFOR QGG SN nOBG QNG SR ORI QGG OSG QGG O« BLLKS e BLKS e BLKS ¢+ ¢+ ¢ G BLKS 9« BRLKS e BLLKS a9 RLKS ¢ ¢ ¢+ + K<CR> H<CR> S<CR> K<CR> F<CR> F<CR> K<CR> G ¢+ F<CR> ASFEN +QOR QUALD SNOW QUAL NEW ASFEN . QOR L FOR FOR + FOR +FOR G+ BLKS OSG BLKS ¢ K<CR> NOKR JOR 25y USER [2752401 DELETED 4 FILES SAVED FILES (30 RUNTIME K/F 32.34 K/F Command For a fast LOGGED OFF TTY106 1430 18-NOV-76 (20 RBLOCKS) RLOCKS) GEC (Fast Logout) logout in which all programs and files are saved, use e K/F<CR> Although this form being fast, vyou keep nor kill those of the KJOB command has the advantage cannot preserve the programs you wish you no longer INTRO-7-2 need. of to SAYING GOODBYE TO THE COMPUTER Example: « KZF<CR> JUB 25 ¢USERE2792407 LOGGED OFF TTYL106 1432 18-NOV-74 FILES SAVED ALL FUNTIME 1.358 (30 RLOCKS) HEC (Getting Assistance) HELP Command and To get assistance during logout, type H (for Help) monitor ATTACH the respond. will WHAT TO DO IF YOU ARE DISCONNECTED FROM YOUR JOB (ATTACH) it will anyone, Although this can happen to lines connecting telephone happen when the If necessary, computer break that connection. most often vyou and the redial the telephone number to the computer. will the computer Under normal conditions, print: FLEASE LOGIN OR ATTACH You will wish to attach yourself to the job on which you had this you must know 1its job number. To do been working. For example, in the This is given after your LOGIN command. is 25. number job the 1-3, INTRO page on LOGIN example You may attach to a job by using your account number .ATTACH job number [account number] The programmer with account number 27,240 may attach to 25 by job typing: ATTACH 2% [2792401<CR> If the programmer with this account number 1is the owner or originator of Jjob 25, the monitor asks for his password. As during Otherwise, access to the program 1is denied. If the password is LOGIN, the password 1is not printed. accepted, the monitor prints a period and the programmer now is attached to his job. Example: ATTACH 2% FASSWORIE [27y5y2401<CR> <CR> NOTE Project-Programmer Account numbers are often called the account command, ATTACH the In (PPNs). Numbers If number must be enclosed in square brackets [ ]. not have keys labeled [ and ], does terminal your and [, bracket, square 1left use SHIFT/K for the SHIFT/M for the right sguare bracket, ]. INTRO-7-3 SAYING FORGOT GOODBYE TO THE COMPUTER YOUR JOBNUMBER? (5YS) You have thrown Suppose you have forgotten your job number. LOGIN, or perhaps you are using a Visual Display away vyour (CRT) terminal and the LOGIN has long since disappeared from You may find out which Jobs are now? What screen. the run under your being .S5YS [account account number by typing: number]<CR> Example: c0YS LR7v32401<CR> v ¢ BLJOR<CR> SATTACH 2% G A DET | BW 1274240 1<CR> FaSSWORT <CR> ¢ to wishes 27,240 Here, the ovrogrammer with account number out which jobs are logged in under his account number. find account under The monitor answers that job 25 is logged in number 27,240 and that this job is DETached from a terminal. Then the programmer ATTACHes to job 25. The SYS command may be given whether or not the user is not logged in, If 1in. logged automatically ends with the KJOB command. INTRO-7-4 the user 1is the 5YS command CHAPTER 8 EXAMPLES Example 1 (Executing a Program More than Once): This program computes the roots of the quadratic equation ax +bx+c=0. Note that FORTRAN statement labels may be in any order and also that carriage control characters are necessary for each of the printing FORMAT statements. cTYFE D . FOR<CR> QUA ODLO0 D200 NO300 C C C 00400 C DOHO0 C DO700 80 OEQ0 QO8O0 DDP00 01000 01100 01200 01300 01400 013500 10 (: C C C 01600 C (1800 01900 40 01700 02000 02100 02200 - 02300 10 O2H00 C 02900 60 02400 02600 02700 02800 C 30 N3000 THIS FROGRAM COMPUTES THE ROOTS OF A QUADRATIC EQUATION OF THE FORM? AX WRITE FORMAT = 0 80) (/0GIVE COEFFICIENTS”) C Ry CALCULATE THE DISCRIMINANT NISC = RXR - 4%AXC 0 THE KIGHT THING ACCORDING TO THE SIGN OF DnISC IF (DnIsc) 20y 40 30» FOSITIVE DNISCRIMINANT SROOT = SQART NENOM = 2XA (DISCH ROOT1 = (~R 4+ SROOQT) / DENOM ROOT2 = (~R - SROOT) / LENOM WRITE (%5 50) ROOTL» ROOT2 FORMAT ¢/ ROOTS ARE’s F10.2y GO TQ FORMAT GO TO D3300 20 WRITE 03500 03600 100 STOF NI 7 ANDIVy F10.2) 100 ZERD DISCRIMINANT ROQT = ~R / (2%A) WRITE (5. 60) ROOT » 03400 (S € + BX + REA (3y 10) Ay FORMAT (F10.2) 03100 03200 2 (7 ROOT IS’y FL10.2) 100 C NEGATIVE DISCRIMINANT 70 FORMAT (5y 70) (/ ROOQTS ARE COMFLEX’) In the second execution the Below, this program is EXECUTEd twice. QUAD are missing because the program has already been FORTRAN: words INTRO-8-1 EXAMPLES Dbe repeated. compiled, making it unnecessary for the compile step to (See page INTRO program is simply loaded into core and exec ated. The 3-1.) QUAD. FOR<CR> QUATI EXECUTE FORTRAN: MALN. LLINK?S CLNRKXCT GIVE L.OADTING Qual EXECUTIONI COEFFICIENTS 2, <CR> . <CR> ~10 12, <CR> 2,00 AND 3,00 ARE ROOTS STOF EXECUTION TIMES: 0.13 ELAFPSED OF END CHU TIME: 18.95 TIMES: 18.30 EXIT QUADN.FOR<CR> CEXECUTE LINKS LOADING CLNKXCT QUAD GIVE EXECUTIONI COQEFFICIENTS %« <CR> -3 <CR> 10 .<CR> ROOTS ARE COMFLEX STQF ENDC CFPU OF EXECUTION TIME: 0.12 ELAFSED EXTT Example 2 (Reading A Disk File): Student grades are recorded on a disk file named STDGRA.DES. Each record has a student name (40 characters) and his numerical grade (a read the grades and 3-digit integer). The following program will compute the mean and standard deviation. 00100 C THIS Q0200 C STANDARD PROGRAM 00300 C 00400 OFEN OO0 NUMRER Q0600 SUM 00700 SUMSAR (UNIT==1, = 20 READ 0?00 10 FORMAT NUMEER 01200 SUMSAR 01300 GO 100 MEAN STUDRENT AND GRADES FILE=STIHGRA.DES’) = = (1y 01000 01100 SUM THE OF O 00800 01400 COMFUTES DEVIATION = TO 0 10, (40Xy END=100) IGRADE I3) = NUMEER + 1 SUM + IGRADE = SUMSQR + IGRAUEXIGRADE 20 AMEAN = SUM/NUMEER 01300 VARIAN = 01600 STHEV = Q1700 TYPE 30y {(SUMSAR SAKT -~ (SUMXSUM) (VARIAN) NUMRBERy AMEANy INTRO-8-2 HTHEV /NUMEER) / (NUMRER-1) EXAMPLES Q1900 13 / FORMAT (S ONUMRER OF STUDENTS = ‘v 30 01800 17 MEAN GRADE = 7"» Fé6.2 / 1/ STANDARD DNEVIATION = 7y Fé.2) CLLOSE (UNIT =1y FILE=/STOGRA.DES) 02000 02100 ‘ END 02200 X GRADE FOR<CR> FORTRANG GRADE MATM. LOADING L. ENKS CLNEXCT GRADE EXECUTIONI NUMERER OF STURENTS = 80.29 MEAN GRADE = STANDARD NEVIATION = OF END EXECUTION 0.23 SEUOTIMES 17 10.45 ELAFSED TIME: 1.00 EXIT ¢ and, We are opening a disk file, reading the grades stored 1in 1it, Note that the logical (See lines 400 and 2100.) closing the file. is the unit number given in the OPEN and CLOSE statements (UNIT = 1) same as that given in the READ statement (line 800) and refers to the device disk. There 1s a Execution starts at statement 400 (the OPEN statement). The last statement executed controlled loop at statements 800 - 1300. is the END statement at CONTINUATION 2200. LINES Lines 1800, 1900, and 2000 are one FORTRAN statement, lines 1900 and Since TABs have been used at 2000 being continuations of line 1800. the beginning of each line to skip over all or part of the 1label field, a way must be provided to inform the computer that the line 1is a continuation line. The rule is: If the first character (after the TAB) between 1 and 9, then the line is a continuation line. Example 3 1s any number (Writing A Disk File): The following is the program that created the data file STDGRA.DES. Notice that in the OPEN, WRITE, and CLOSE statements (lines 500, 1100, IUNIT and 1400) the device unit number is an integer variable, IUNIT. has been given the value 1 (line 400) before it is used. 508 FILE?: WOE.FOR<CR> E0IT: WOE.FOR ¢ ¥<CR> XEQ 00100 00200 00300 00400 00500 00600 00700 C THIS FROGRAM ENTERS STUDENT GRADES C ENTER GRADE OF -1 AFTER LAST STUDENT GRADE TO END DIMENSION STUDNT TUNIT=1 40 10 (8) OFEN (UNIT=IUNITy FILE='STDOGRA.DES’) ACCEFT 10y (STUDONT(I)sI=1+8) FORMAT (8A3%) INTRO-8-3 EXAMPLES DOEODN DOYO0 Koo 84 ACCERT 20y FORMAT <13 (TGRADE TGRADE D51QO0 IF 01100 WRITE (IUNITy 01200 FORMAT (8A%y LA GO 1400 CLOSE 1500 STOF 3] &O0 N TO EQe ~1) 30) GO TO 100 (STUINTC(I)yI=1+8)y IGRADE 13) 40 (UNIT=IUNITy THIS IS THE FILE=’'STHOGRA.IES ) ENDV X After this orogram listed by command (see s X the has DIRECT page been executed, command INTRO (see page 7-1). WOE FOR<KCR> FORTRAN: WOE: MS N ENEK S LOANING FLNEXCT WOE Gk QR GE EXECUTIONI CLINTONLSCR> B2<CR> ELBRIDGE GERRY<CR> /73<CR> LaNTEL TOMFIINS<CR> I, Ha<CR> JOHN CALHOUN<SCR> QO<CR> RICHARI JOHNSQAN<SCR> M. 79Y<CR> GEQRGE. UALLAS<CR> YU<CR> WILLTAM KING<CR> K. LY<CR> BRECKINRIDGE<CR> JOHN 77<CR> MANNIEAL HAML ITN<CR> 65 <CR> BLHUYLER COLIFAX<CR> /7<CR> WILSOM<CR> HENRY 7/ /7<CR> WILLTAM WHEELER<CR> Y&<CR> CHESTER ARTHUR<CR> B8 <CR> LEVI s MORTON<CR> Y1 <CR> GARRKET HORART<CR> 89 <CR> CHARLES DAWES<CR> Y3<CR> CHAKLES CURTIS<CR> 73<CR> <CR> ~1<CR> THIS IS THE END OF CFU TIME:S END EXECUTION Q.92 ELAFSED TIME: 4:21.,33 EXTT INTRO-8-4 the file INTRO 6-1) STDGRA.DES and during will the be KJOB EXAMPLES Example 4: This program prepares grade reports for the students whose grades recorded on the disk LTYFE QO100 file STDGRA.DES. RT . FOR<CR> REFO DO200 OOA00 C FROGRAM TO FREFARE GRADE REFORT DEMENSTON ANAME(B) OFEN (UNIT=1y FILE=/STOGRA.DES”) 00400 CFPRINT HEADINGS QO&OQ QO7/Q0 10 30 FORMAT (707 TXy ‘STUDENT» 27Xy ‘GRADE’) READ (1ly 20y ENI=S50) (ANAME(I)sI=1,8)s IGRAIE OOH00 00800 20 DLO0O 40 01200 01300 a0 00%00 01100 WRITE (&Sy 100 FORMAT (8A%y FORMAT (7 WRITE (S5y 40) GO ‘9 132 (ANAME(I)»I=1+8)» IGRADE 8Ahy 13) TO 30 CLOSE (UNIT=1)y FILE=’STNGRA.DES’) ENI OF GRADE REFORT’ STOF 7 ENI 01400 JEX REFORT.FOR<CR> FORTRANG REFORT MALN. LINKCS CLNRXCT LOALDING REFORT EXECUTIONI GRAIE 83 73 38 80 79 95 69 77 65 77 77 Y6 88 ?1 89 ?3 75 STUNENT GEOQRGE CLINTON ELBRRIDGE GERRY NANTEL I'. TOMFRKINS JOHN CALHQUN RICHARD M. JOHNSON GEORGE DALLAS WILLIAM R+ KING JOHN BRECKINRIDGE HANNIERAL HAMLIN SCHUYLER COLFAX HENRY WILSON WILLIAM WHEELER CHESTER ARTHUR LEVI F+ MORTON GARRET HORART CHARLES DAWES CHARLES CURTIS NI END OF OF GRADE REFORT EXECUTION CFU TIME: 0.68 ELAFSED TIME: 1:134.77 EXTT INTRO-8-5 are EXAMPLES Example 5 (Trying To Read A Non-Existent File): Now DELETE the data file containing the students' grades, STDGRA.DES, and then EXecute REPORT.FOR (the program in Example 4). The READ statement in line 700 cannot be executed since the file to which 1t refers does not exist. The execution is thus aborted. JOELETE FILES STHGRA.DES<CR> DELETED? STOGRA . ES 01 RLOCKS +EX FREED REFORT,.FOR<CR> LLINK?S LOADING FLNKXCT REFORT EXECUTIONI STUDENT GRADE AFRSDAT ATTEMFT TO READI REYOND VALID INFUT UNIT=1 DOKISTOGRALOESLZy 2401200555 /ACCESS=SEQINOQU/MODE=ASCTL NAME. (L.0C) wiee= o CALLER IN. (402703) il ? JOR END CFU CLOC) MAIN.+11(220) ARORTEI OF EXECUTION TIMES: 0,33 ELAFSED TIME:D 1.22 EXIT INTRO-8-6 “EARGS: LARG <4355 LUTUIU] TYFES PART FORTRAN-10 II Language Manual The FORTRAN-10 Language Manual reflects the software as of Version 5 of the FORTRAN-10 Compiler, Version 5 of the FORTRAN-10 Object Time System (FOROTS), and Version 5 of the FORTRAN-10 Debugging Program . (FORDDT) CONTENTS Page 1-1 PROLOGUE CHAPTER \O) Line-Sequenced DATA OF TYPES, wbdhpDDDDDDDDDDDD - oo Wi - L] [} o e [] [] L] [ SYMBOLIC ARRAYS TYPES Integer Real Constants Constants Double-Precision Complex Octal Constants Constants Constants Logical Literal Constants Constants Statement Label Constants SYMBOLIC NAMES w N [] - |] ARRAYS Array Element Subscripts Dimensioning Arrays Order of ARITHMETIC Stored Array Elements [] [) o e wnH+- Expressions OF EXPRESSIONS Parenthesized Hierarchy Mixed Arithmetic EXPRESSIONS Relational EVALUATION |] EXPRESSIONS Rules for Writing Expressions LOGICAL Mode of Subexpressions Operators Expressions | p— WwWww e | onUTtOn | CONSTANTS, AND VARIABLES Ut L] STATEMENTS CONSTANTS |] b L~ Y [] |] ® e S -~ [] R Input FORTRAN-10 EXPRESSIONS wWwwwWwwwN CHAPTER DATA S WWWWwWwWwwwwwwuwwwww VARIABLES, Types oo ® ® W L] [] |] WD ° [] NN |] SHEWWLwwwwwdoND DD TYPES Initial and Continuation Line Multi-Statement Lines Comment Lines and Remarks Debug Lines Blank Lines ORDERING W CHAPTER Field Remarks LINE = Statement Numbers Line Continuation Statement Field | FORMAT and DD AND Field S Label NAMES, ! DEFINITION, Statement p— STATEMENT, [\ SET CHARACTER o LINES w NN - [NOTN JO I \O) AND WWWWWwWwWwWwwwwwwwww N A I N I HOWwoN~JoouubdwwhbdhdH+= CHARACTERS CHAPTER (O BACKGROUND CONTENTS Use of (CONT.) Logical Operands in Mixed Mode Expressions L] U1 O L w - ® > STATEMENT SPECIFICATION STATEMENTS INTRODUCTION DIMENSION STATEMENT |] Adjustable Dimensions TYPE SPECIFICATION STATEMENTS IMPLICIT STATEMENTS STATEMENTS COMMON Dimensioning L} [] [] e o [ OY O OYON OV OY o) Uy U [] END Y STATEMENTS INTRODUCTION STATEMENT INCLUDE STATEMENT PROGRAM LU WD N CHAPTER CONTROL COMPILATION CHAPTER in Arrays COMMON [} J O [] [] EQUIVALENCE o oy OY O Statements PARAMETER EXTERNAL DATA CHAPTER STATEMENT STATEMENT STATEMENT STATEMENT INTRODUCTION 00 [] OO W N+ D> [] OO o o oo ASSIGNMENT o CHAPTER STATEMENTS INTRODUCTION ARITHMETIC ASSIGNMENT STATEMENTS LOGICAL ASSIGNMENT STATEMENTS ASSIGN (STATEMENT LABEL) ASSIGNMENT STATEMENT Permitted STOP T Operations STATEMENT (TRACE) Option I/0 STATEMENTS 10.1 DATA TRANSFER 10.2 10.2.1 TRANSFER 10.2.2 Random OPERATIONS MODES Sequential Mode Access ii R NN R N [ R N N Transfer STATEMENT STATEMENT PAUSE HIEHHWOOAU & B WWN N Statements Range Mode — DO Extended | STATEMENT Nested O WO WVWWWWIWOWWYWIWOWWOLLWYWOW STATEMENTS CONTINUE CHAPTER Statements Statements p— -~ o o e w N N+~ o e TO TO Arithmetic IF Statements Logical IF Statements Logical Two-Branch IF Statements DO e GO GO o -~ o o Computed Assigned w N e TO CONTROL STATEMENTS Unconditional GO TO Statements IF w bR WLWLWWWNDNDDODND s STATEMENTS INTRODUCTION GO ° WO WO WO W W W WWWWOWOWWOWOWOOLO O CONTROL NS0 CHAPTER 10-1 10-1 10-1 10-1 CONTENTS (CONT.) Page 10.2.3 10.3 10.3.1 10.3.2 10.3.3 10.3.4 10.3.4.1 10.3.5 Append Mode I/0 STATEMENTS, BASIC FORMATS AND COMPONENTS I1/0 Statement Keywords FORTRAN-10 Logical Unit Numbers FORMAT Statement References Random 10-7 The Specification of Records for Access 10.5 READ STATEMENTS ARGUMENTS END-OF-FILE Sequential Formatted READ Transfers Sequential Unformatted Binary READ Transfers 10.5.4 10.5.5 10.5.6 10.6 10.7 10.8 10.8.1 10.8.2 10.8.3 10.8.4 Sequential List-Directed READ 10.8.6 CHAPTER 10-12 10-13 10-13 SUMMARY OF READ STATEMENTS Transfers 10-13 10-14 REREAD STATEMENT WRITE STATEMENTS 10-16 Random Access Unformatted READ Sequential Sequential Sequential Sequential 10-114 10-16 Formatted WRITE Transfers 10-16 Unformatted WRITE Transfer List-Directed WRITE Transfers 10-17 NAMELIST-Controlled WRITE Random Access Formatted WRITE Transfers Random Access Unformatted WRITE SUMMARY OF WRITE STATEMENTS STATEMENT 10.11 10.12 10.13 10.14 PRINT STATEMENT PUNCH STATEMENT TYPE STATEMENT FIND STATEMENT Formatted ACCEPT Transfers ACCEPT Transfers Into FORMAT Statement ENCODE AND DECODE STATEMENTS 10.15.1 ENCODE Statement 10.15.2 DECODE Statement 10.15.3 10-11 Random Access Formatted READ Transfers ACCEPT 10.15 10-11 Transfers 10.10 10.10.1 10.10.2 10-10 10-12 Sequential NAMELIST-Controlled READ Transfers 10.9 10-8 10-10 Transfers Transfers 10.8.5 10-6 10-6 List-Directed I/0 NAMELIST I/0 Lists OPTIONAL READ/WRITE ERROR EXIT AND 10.5.3 10-2 10-3 10-3 10-3 I/0 List Implied DO Constructs 10.3.6 10.3.7 10.4 10.5.1 10.5.2 10-2 Example of ENCODE/DECODE Operations I/0 STATEMENTS 10-17 10-17 10-17 10-18 10-18 10-18 10-19 10-19 10-20 10-21 10-21 10-22 10-23 10-23 10-23 10-25 10.16 SUMMARY OF 11 NAMELIST STATEMENTS 11-1 11.1 11.2 INTRODUCTION NAMELIST STATEMENT 11-1 11.2.1 11.2.2 NAMELIST-Controlled Input Transfers NAMELIST-Controlled Output Transfers iii 11-1 11-2 11-3 CONTENTS (CONT.) Page CHAPTER 12 CONTROL 12.1 INTRODUCTION 12.2 12.2.1 OPEN 12.2.2 CHAPTER FILE AND Summary of FORMAT 13.1 13.1.1 13.2 13.2.1 13.2.2 INTRODUCTION 13.2.4 13.2.5 13.2.6 13.2.7 13.2.8 13.2.9 13.2.10 13.2.11 13.2.12 13.3 FORMAT CHAPTER 14 12-1 STATEMENTS OPEN and OPEN/CLOSE CLOSE Statements Statement Options 12-2 12-10 13-1 STATEMENT FORMAT 13-1 Statement, General 13-1 Form 13-2 DESCRIPTORS Numeric Field Descriptors Interaction of Field Descriptors 13-4 With I/0 List Variables G, General Numeric Conversion Code Numeric Fields with Scale Factors Logical Field Descriptors 13-6 Variable Numeric Field Widths Alphanumeric Field Descriptors Transferring Alphanumeric Data Mixed Numeric and Alphanumeric Fields Multiple Record Specifications Record Formatting Field Descriptors FOR CONTROL 13-10 13-10 13-11 13-12 13-14 13-14 13-15 PRINTING 13-16 RECORDS DEVICE 13-7 13-7 13-16 S Format Descriptor CARRIAGE CONTROL CHARACTERS ASCII CHAPTER for 13 13.2.3 12-1 CLOSE Options 12-1 STATEMENTS 14-1 STATEMENTS 14.1 INTRODUCTION 14-1 14.2 REWIND STATEMENT 14-1 14.3 14.4 14.5 UNLOAD STATEMENT 14-2 BACKSPACE 14.6 14.7 SKIP SKIP 14.8 14.9 BACKFILE 15 SUBPROGRAM 15.1 INTRODUCTION 15.1.1 15.2 15.3 END FILE FILE 14-3 STATEMENT STATEMENT STATEMENT OF Dummy 14-2 STATEMENT RECORD SUMMARY 14-2 STATEMENT DEVICE CONTROL STATEMENTS STATEMENTS and Actual STATEMENT FUNCTIONS INTRINSIC FUNCTIONS Arguments (FORTRAN-10 DEFINED FUNCTIONS) EXTERNAL FUNCTIONS Basic External Functions Defined Functions) Generic Function Names SUBROUTINE (FORTRAN-10 SUBPROGRAMS Referencing Subroutines (CALL Statement) FORTRAN-10 Supplied Subroutines RETURN STATEMENT Referencing AND Subprograms MULTIPLE SUBPROGRAM STATEMENT) iv MULTIPLE External RETURNS FUNCTION ENTRY POINTS (ENTRY CONTENTS BLOCK CHAPTER (CONT.) SUBPROGRAMS DATA INTRODUCTION STATEMENT DATA USING THE RUNNING THE SET | ] e OO0 ~J O U Wb e DD Optimization Test Replacement Uninitialized Variable Detection Function References Programming Techniques for Effective W @] Optimization INTERACTING WITH NON-FORTRAN-10 PROGRAMS FILES WN - Calling Sequences Accumulator Usage Argument Lists Argument Types Description of AU Wwwwww OOO0O0Oa0n AND use with FORTRAN-10 Mixing FORTRAN-10 and F40 Compiled ~J w Arguments Converting Existing MACRO-10 Libraries for = Interaction with COBOL-10 [ W [J o ole o) w [J Programs Calling FORTRAN-10 Subroutines from COBOL-10 Programs \'4 | @) N | | Removal of Inaccessible Code Global Register Allocation Improper W N [ DN | ] [] OO0 O0O00N Loops Constant Folding and Propagation I1/0 = @] Strength Removal of Constant Computation From OO0O00On0 I I B OO0 0Oa0n W w N Elimination of Redundant Computations (N LU j— Do |] L4 Dimensioning of Formal Arrays FORTRAN-10 GLOBAL OPTIMIZATION Optimization Techniques e @] L} [] ~NSNoOY O s W DD OO0OOOOOO0O0O00O000n [] L] [] s Numbers Writing FORTRAN-10 Programs for Execution on Non-DEC Machines Using Floating-Point DO Loops Computation of DO Loop Iterations Subroutines - Programming Considerations Reordering of Computations Reduction of Operator @] | ® GENERAL PROGRAMMING CONSIDERATIONS Accuracy and Range of Double-Precision = ON@ PROGRAMS WRITING USER ONONENN® APPENDIX ) WITH LINK-10 0~ Summary CREATING A REENTRANT FORTRAN PROGRAM 0 Message OOOOOO(PO (I I N [ = . Fatal Errors and Warning Messages N ERROR REPORTING Do wmmwowmow® /DEBUG Switch COMPIL-Class Commands READING A FORTRAN-10 LISTING Compiler-Generated Variables = The — [] |J COMPILER Switches Available with FORTRAN-10 HHRFROWL S WHF COMPILER 0O MO Jd~JJO e O o oo o e o o owwomw APPENDIX B W WWRN N ASCII-1968 w CHARACTER CODE APPENDIX X BLOCK CONTENTS FORSE-Accepable Form N OF ERROR SOFTWARE REQUIREMENTS FOROTS PROCESSING INPUT/OUTPUT FACILITIES Input/Output Channels — AR AND FEATURES wwhho K- O - HARDWARE W Restrictions FOROTS D APPENDIX General OOO0O0OO0 C.3.10.3 Used Internally YOI ) @ (WO File e (WO (6, I ST S wiwlwlw FOROTS Access Modes Sequential Transfer Mode Random Access Mode ACCEPTABLE TYPES OF DATA FILES AND THEIR — |] [ NN [) L4 L] =W [] ® — N W [J [] ° W [ ] ULt ULt oo SO wivlvivlvEvlvRvlwlw FORMATS ASCII Data Files FORTRAN Binary Data Files Format of Binary Files Mixed Mode Data Files Image Files USING FOROTS FOROTS Entry Points Calling Sequences MACRO Calls for FOROTS Functions Formatted/Unformatted Transfer Statements, Sequential Access Calling Sequences NAMELIST I/0 Sequential Access Calling Sequences Array Offsets and Factoring I1/0 Statements Random Access Calling Seguences Calling Sequences for Statements Use Default Devices Statements to Position Magnetic Tape OPEN and CLOSE FUNCTIONS TO FACILITATE LOGICAL/PHYSICAL DEVICE FORDDT VO @ m = INPUT FORMAT Variables and Arrays Numeric Conventions vi Statements Statements, Calling Sequences Memory Allocation Routines Software Channel Allocation De-allocation Routines APPENDIX Which Units List Directed Input/Output Input/Output Data Lists by U?UU N = = Calling COBOL-10 Subroutines from FORTRAN-10 Programs LINK-10 Overlay Facilities Conventions FOROTS/FORSE Compatibility FORTRAN-10/F40 Data File Compatibility Converting FOROTS Data File to W O = O WWwwww OO0O00O0 C. 3.8.2 (CONT. ) and OVERLAYS ASSIGNMENTS (CONT.) W [] > [] L] o RTINIT e D W N LOCK CONECT 0O [] RTSLP = RTWAKE DISMIS = = = VWD KHO [2 L] [] O STATI [] STATO [] ® BLKRW RTREAD DISCON [) Levels RTSTRT RTWRIT [ Interrupt Priority Masks SUBROUTNES UNLOCK GETCOR, A Temporary Subroutine n) FOROTS ERROR MESSAGES RETURNED BY ERRSNS TABLES FORTRAN-10 Character N N S Set Constants I W W N FORTRAN-10 Statement Categories > b D | | 300 W 0 TABLE Use of Symbolic Names Arithmetic Operations and Operators Type of the Result Obtained From Mixed Mode Operations Permitted Base/Exponent Type Combinations Logical Operators Logical Operations, Truth Table Relational Operators and Operations Hierarchy of FORTRAN-10 Operators Rules for Conversion in Mixed Mode Assignments FORTRAN-10 Logical Device Assignments Summary of READ Statements vii = g N ooooouvuumuuude e WwWWwWwWwWLwdDNDDDODDD Modes N o FORRTF Core ’—l INTRODUCTION USING e WWWWWWWwWwWwWwWwwWwWwwww NN ® e o ® e O ® ® [} [] e X2 ko ko koK K2 K2 K K2 K2 K2 K2 K2 K2 K2 N2 R N2 R M2 B SOFTWARE ¢ REALTIME FORTRAN-10 C)C)G)C)C)C)G)C)QC)CRC)OGOOOOG)OG)C) (N NN Y O NS AN N BN B | COMPILER MESSAGES — 7| p— MESSAGES FORDDT = FORTRAN-10 /OPTIMIZE SWITCH N FORDDT COMMANDS ENVIRONMENT CONTROL momoEoDEoEMmEmmE FORDDT STARTING LOADING AND SCOPE OF NAME AND LABEL REFERENCES ! w — [ mmEmmom | . @, (Voo oBEN B o WU Y- N USIN S I O I Commands FORDDT AND THE FORTRAN-10 /DEBUG SWITCH APPENDIX APPENDIX TUTORIAL USER Basic ro APPENDIX Statement Labels and Source Line Numbers NEW (I = 00 00 ~J~JWwwWw A, o)) Q M CONTENTS CONTENTS Summary (CONT.) of WRITE Statements Summary of FORTRAN-10 OPEN/CLOSE Statement I/O Statements Arguments FORTRAN-10 Conversion Codes Action of Field Descriptors On Data Sample Numeric Field Codes Descriptor Conversion of Data According Precision Control Real and Double to Magnitude Characters FORTRAN-10 Print Summary of FORTRAN-10 Device Control Statements == W RN N C)L‘UOU(POOwUJE—‘ |IL|J'| w Intrinsic oy ! s Defined 15-4 15-10 15-19 B-2 /DEBUG Switch and Type Codes Upward Compatibility (FORSE TO FOROTS) Downward Compatibility (FOROTS TO FORSE) Function Numbers and Function Codes FORTRAN Device Table Modifiers to B-3 Argument Types C-12 Commands Table of Error Messages, FOROTS FOROTS Code Format and Full Format I/0 Returned [N} (FORTRAN-10 Basic External Functions (FORTRAN-10 Defined Functions) FORTRAN-10 Library Subroutines FORTRAN-10 Compiler Switches Message us) | Functions Functions) Error Messages and ERRSNS Values Arithmetic Messages viii and Library Error C-24 C-26 D-30 D-33 E-1 CHAPTER 1 PROLOGUE BACKGROUND 1.1 The FORTRAN-10 language set is compatible with and encompasses the FORTRAN, Standard National "American 1in described set standard also FORTRAN-10 X3.9-1966" (referred to as the 1966 ANSI standard). standard set that the to additions and extensions many provides its 1increase and FORTRAN-10 of usefulness the enhance greatly language sets implemented by other major FORTRAN compatibility with In this manual, the FORTRAN-10 extensions and computer manufacturers. additions to the 1966 ANSI standard set are printed with gray shading. A FORTRAN-10 source program consists of a set of statements constructed using the language elements and the syntax described in this manual. A given FORTRAN-10 statement will perform any one of the functions: following It will cause operations such 1. and 2. to be branching It will specify processed. 3. It will the out. type and division, multiplication, as carried format specify the characteristics of of the the data being source orogram. FORTRAN-10 statements are composed of keywords, i.e., words that are recognized by the compiler, used with elements of the language set: constants, variable, and expressions. There are two basic types of executable and nonexecutable. FORTRAN-10 statements: program; the of action the specify statements Executable statements describe the characteristics and arrangement nonexecutable of kind the and of data, editing information, statement functions, The compilation of may be included in the program. that subprograms executable statements results in the creation of executable code in Nonexecutable statements provide information only the object program. to the compiler; manual, this In each categories, name, are definition, given in Table they do not create executable code. 12 1into grouped are statements FORTRAN-10 the The 1is described in a separate chapter. which of and chapter reference for each statement category 1-1. and variables, (constants, elements, The basic FORTRAN-10 language expressions), the character set from which they may be formed, and tne rules that govern their construction and use are described in Chapters 2 through 4. PROLOGUE FORTRAN-10 Chapter Reference Category Name Table 1-1 Statement Categories Description this in Compilation Control | Statements and programs identify Statements 5 and beginning their category 1indicate ending points. Specification Statements 0 DATA 7 3 9 | 12 in Statements the declare category this of properties This statement assigns variables, functions. and to variables initial array ‘Statement values Assignment Statements - Statements in this category cause array and/or variables named by replaced be to elements Control Statements this in Statements determine the order of | File | elements. specified Control (assigned) object the of terminate Statements its the This | Statement category execution and program category this in Statements files close identify, open, and input and for parameters and and FORMAT values. execution. output operations 13 and arrays, between statement is certain files processor. input/output used with statements to specify the form in which data a appears in a FORTRAN record on specified input/output medium. 14 Device Control Statements category this in Statements control enable the programmer to the of positioning certain on files devices. or records peripheral - PROLOGUE (Cont.) Table 1-1 FORTRAN-10 Statement Categories Cnapter Reference Category Name Description 15 Subprogram Statements Statements in this category enable the programmer to define functions and subroutines and their entry points. l6 BLOCK DATA Statements Statements are used in to this category declare data specification may 1nitialize subprograms that common storage areas. CHAPTER CHARACTERS 2.1 CHARACTER Table 2-1 FORTRAN-10 acceptable characters CONTROL-Z, 2 AND LINES SET lists The within cause which, recognized by digits, 1letters, and symbols remainder of the ASCII-1968 character set(l), 1is but these 1literal constants or comment text, An exception 1s fatal errors 1in other contexts. the when used in Teletype input, means end-of-file. NOTE Lower-case treated context strings, alohabet characters are as upper—-case outside the of Hollerith constants, literal and comments. Table FORTRAN-10 2-1 Character Set Letters A,a J,] 3,s B,b K,k T,t C,c D,d L,1 M,m V,V W,w U,u E,e N,n F,f 0,0 X, X G,9 P,p Y,y Hll? qu I,1 R,r ZIZ Digits 1. The 0 5 1 2 7 3 8 4 9 o) X3.4-1958 the complete ASCII-1968 character set is defined in Information the "American National Standard for and is given in Appendix A. of version Interchange,” 2-1 CHARACTERS LINES AND (Cont.) Table 2-1 FORTRAN-10 Character Set Symbols ! Exclamation Point & ' ( ) * + Ampersand Apostrophe Opening Parenthesis Closing Parenthesis Asterisk Plus , Comma : ;s < = > " Colon Semicolon Less Than Equals Greater Than Circumflex - Hyphen (Minus) . Period (Decimal Point) / Slant (slash) " Quotation Marks # Number Sign S Dollar Sign Line Termination Characters Line Feed Form Feed Vertical Tab Formatting Line Characters Carriage Return Horizontal Tab Blank Note that horizontal tabs normally advance the character ©position An 1s an even multiple of 8. to the next position that pointer that tab a as defined is which tab, initial exception to this is the (Refer to Section 2.3.1 includes or starts in character position 6. for a description of initial and continuation line types.) Tabs within literal specifications count as one character even though they may advance the character position as many as eight places. 2.2 STATEMENT, DEFINITION, AND FORMAT Source program statements are divided into physical lines. A line 1is defined as a string of adjacent character positions, terminated by the regardless of first occurrence of a 1line termination character context. Each line is divided into four fields: [ 1 =I| Line Character Positions l‘: 2 3v 4 Statement Label Field 5 e \n 6 — 7 \. Continuation Field 8 . ) . Y . . Statement Field 70 71 72 - - 73 . v Remarks ) — AND LINES CHARACTERS Statement Label Field and Statement Numbers 2.2.1 You may place a number ranging from 1 to 99999 in the statement label Any source the statement. identify to 1line initial an of field a program statement that is referenced by another statement must have zeroes and all blanks in the label field Leading statement number. are both accepted as are ignored, e.g., the numbers 00105 and 105 a You may assign the statement numbers in statement number 105. however, each statement number must be ‘source program in any order; in the program or statements other to all respect ‘unique with than other statements non-executable label cannot You subprogram. END FORMAT and | statements. | statement identical A main program and a subroutine may contain In this case, references to these numbers are understood to - numbers. mean the numbers in the same program unlt in which An made. the reference is examole- both subprogram SUBl1 and MAINMD Assumne that main module A GO TO statement, for 105. statement number contain MAINMD, in instance, in MAINMD will refer to statement 105 control transfer will SUB1l in TO GO A SUBl. 105 in NOT to to 105 2.2.2 in SUBI. | | ' Line Continuation Field in Any alphanumeric character (except a blank or a zero) placed llne. continuation a aa line the identifies 6) (position field Section 2.3.1 for description.) 2.2.3 Statement this (See Field (spaces) Blanks field. Any FORTRAN-10 statement may appear in this tabs do not affect compilation of the statement and may be used and freely in this field for appearance purposes, with the exception of textual data given within either a literal or Hollerith spec1flcat10n where blanks and tabs are significant characters. CHARACTERS AND LINES Remarks 2.2.4 In lines consisting of 73 or more character positions, only the first 72 characters are 1interpreted by FORTRAN-10. (Note that tabs generally occupy more than one character position, wusually advancing the counter to the next character position that is an even multiple of eight.) All other characters in the line (character positions 73, 74 ...etc.) are treated as remarks and do not affect compilation. Note that remarks may through 72, provided "1" (Refer to 2.3 LINE TYPES A line in a also be added to a line in character. positions 7 the text of the remark is preceded by the symbol 2.3.3.) Section FORTRAN-10 initial source 1. An 2. A continuation line, 4., A comment program may be: line, line, 6. A blank line. Each of these line types is described in the following paragraphs. 2.3.1 Inltlal and. Contlnuatlon Line Types A FORTRAN-10 statement may occupy the statement fields. of up to consecutive 1lines. The first line in a multi-line statement group referred to as the initial line; the succeeding lines are referred as continuation lines. Initial lines may be a blank or a zero position assigned in their 20 1is to a statement number and must have either continuation line field, i.e., character 6. Continuation lines cannot be assigned statement numbers; they are identified by any alphanumeric character (except for a blank or zero) placed in character position 6 of the line, 1i.e., continuation 1line field. The 1label field of a continuation line is treated as remark text. CHARACTERS LINES AND Note that blank lines, comments, and debug lines that are treated like comments, i.e., debug lines that are not compiled with the rest of the program (refer to Section 2.3.4) terminate a continuation sequence. using Following is an example of a 4-line FORTRAN-10 FORMAT statement initial tabs: 105 86X, COULOMB, FORMAT (1H1,17HINITIAL CHARGE = ,F10.6,10H OHM/15H CAPACITANCE = ,Fl0.6, 213HRESISTANCE = ,F9.3,6H HENRY/// FARAD,11X,13HINDUCTANCE = ,F7.3,8H 38H MS,10X.2HMA///) CURRENT/7H TIME 421H Continuation Line Characters, i.e., 2, 3, and 4 Comment Lines and Remarks 2.3.3 Lines that contain descriptive text only are referred lines. Comment lines source program, to statements, to as comment are commonly used to identify and introduce a describe the purpose and to introduce subprograms. of a particular set of To structure a comment line: 1. | or $,/,*, You must place one of the characters C (or ¢), 1line to identify it as a the of 1 @position in character comment line. - 2. You may write the text into character positions 2 through the 3. program, source You may place comment lines anywhere in the they cannot precede a continuation line because comments but end of the terminate 4. line. a continuation sequence. ” of You may write a large comment as a sequence of any number identifying the <carry 1line must each however, lines; or !) in its first character position. character (C,$,/,*, CHARACTERS AND LINES The following is line. an example of a comment CSUBROULIVE CTHE CTO occupies more than FORMAT AND PROGRAM | Al2 OF THIS STORE HEAT SUBROUTINE THE RESULTS IS OF TEST-1101 Comment lines are printed on all the one | PURPOSE CTEST by that . llstlngs, but are compiler. otherwise ignored | Note that characters appearing in character positions 73 and beyond are automatically treated as remarks, so that the symbol ! need not be used. (Refer to Section 2.2.4.) = 2.3.5 You may Blank Lines insert lines consisting of only blanks, tabs, or no characters anywhere in a FORTRAN-10 source program except immediately preceding a continuation line, because blank lines are by definition initial lines and as such terminate a continuation sequence. Blank lines are used for formatting purvoses only; they cause blank 1lines to appear 1in their <corresponding positions in they are ignored by the compiler. source program listings; otherwise, CHAARACTERS 2.4 ORDERING OF FORTRAN-10 AND LINES STATEMENTS The order in which you place FORTRAN-10 Statements in a program unit is 1important. That 1s, certain types of statements have to be processed before others to guarantee that compilation takes wvlace as you expect. The poproper sequence for FORTRAN-10 statements 1is summarized by the following diagram. PROGRAM, FUNCTION, BLOCK DATA SUBPROGRAM, or Statements IMPLICIT Comment Lines FORMAT Statements Statements PARAMETER Statements DIMENSION, COMMON, EQUIVALENCE, EXTERNAL NAMELIST, Type or Specification Statements Statement Function Definitions DATA Statements Executable Statements END Horizontal lines indicate executanle statements. Statement the order 1in which FORTRAN-10 statements must appear. That 1is, vyou cannot intersperse horizontal sections. For example, all PARAMETER statements must appear after all IMPLICIT statements and before any DATA statements, i.e., PARAMETER, IMPLICIT, and DATA statements cannot be interspersed. Statement function definitions must appear after IMPLICIT statements and Dbefore Vertical lines indicate the way in which certain types of statements may be interspersed. For example, you may intersperse DATA statements with statement function definitions and executable statements. you may intersperse FORMAT statements with IMPLICIT statements, parameter statements, other specification statements, DATA statements, statement function definitions, and executable statements. The only restriction on the placement of FORMAT statements is that they must appear after any PROGRAM, FUNCTION, subprogram, and BLOCK DATA statements, and before the END statement. CHARACTERS AND Special 1. LINES cases: The placement of an INCLUDE 2. types of statements to be statement is dictated by tne INCLUDEJd. or functions 1in only allowed 1is statement ENTRY The executable references to any of the dummy All suoroutines. unless parameters must physically follow the ENTRY statement appear in the function definition statement, references the the subroutine, BLOCK DATA or in a preceding ENTRY statement. subprograms cannot contain any executable statement functions, FORMAT statements, EXTERNAL statements, (Refer to Section 1lb5.1l.) statements, or NAMELIST statements. When statements are out of place, FORTRAN-10 issues messages, some which may indicate fatal errors. of CHAPTER DATA 3.1 TYPES, CONSTANTS, SYMBOLIC 3 NAMES, VARIABLES, AND ARRAYS DATA TYPES The data types you may use 1in FORTRAN—lO source programs are: l. 1integer, 2. real, 3. double-precision, 4. complex, and 9. logical.. The use and format of each of the foregoing data types in the descriptions of the constant (Sections 3.2.1 through 3.2.8). 3.2 having - the are discussed same data type CONSTANTS Constants are quantltles that do not change value during the execution of the vThe object constants program. S you may use in FORTRAN-10 are listed Table , in Table 3-1. 3-1 Constants Category Constant (s) Numeric Integer, , Truth Values octal Logical real, Types double-precision, | | complex, and DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS 1Integer 3.2.1 Constants An integer constant is a string of from one to eleven digits that (a number without a fractional represents a whole decimal number (-2**35)-1 to Integer constants must Dbe within the range of part). (+2**35)-1 (-343597383567 to +3435973383067). Positive integer constants may optionally be signed; negative integer constants must be signed. You cannot use decimal points, commas, or other symbols on integer Examples of wvalid constants (except for a preceding sign, + or -). constants integer are: 345 +345 -345 Examples of invalid (use of decimal point) (use of comma) +345. 3,450 (use of decimal point; 34.5 Real 3.2.2 integer constants are: not a whole numbper) Constants A real constant may have any of the following forms: 1. a string of decimal digits followed A basic real constant: followed optionally by a point immediately by a decimal decimal 2. e.g., 1557.42. immediately by a decimal A basic real constant followed (exponential notation) notation E in written exponent integer form, 3. fraction, 2.9., 1559.E2. (no decimal point) An integer constant followed by a integer exponent written in E notation, e.g., 1559E2. be however, each will: Real constants may be of any size; digits). decimal 9 to (7 bits 27 of precision the fit decimal rounded to to approximately eight is maintained Precision for real constants the absolute precision depends upon the numbers significant digits; involved. form E notation in constant written The exponent field of a real it must be either a zero or an integer (blank); empty cannot be and The magnitude of the exponent must be greater than -38 constant. (i.e., =38<n< + 38). The following are than +38 less to or equal examples of valid real constants. The ~98.765 7. 0E+0 . 7E-3 SE+5 (7.) (.0007) (500000.) 50115. 50.E1 (500.) following are examples of 72.6E75 .375E 500 (exponent is invalid too large) - real constants. (exponent incorrectly written) (no decimal point given) DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS constants written Double-Precision Constants 3.2.3 Constants of this type are similar to the form; notation direct real 1in E differences between these two constants are: magnitude, their on depending Double-precision constants, precision to either 15 to 17 places (system with a KAlQ have KL10 or KI10 a Processor) or 16 to 18 places (system with the 8-digit precision obtained for than rather Processor), 1. real constants. constant double-precision Each 2. storage two occupies locations. The letter D, instead 3. to constants E, of identify a decimal 1is wused exponent. in double-precision in =zero) (even of an exponent You must use both the letter D and The exponent need only be signed writing a double-precision constant. equal and 1its magnitude must be greater than -38 if it is negative; The range of magnitude =38<n +38). (i.e., than +38 1less to or permitted a double-precision constant depends on the type of processor present and run). in your system (on which the source program is to be compiled The permitted ranges Range Processor KA10 KI10 or The are: 1.97 X 10**(-31) 0.14 X 10**(-38) KL10 to 3.4 X 10**(+38) to 3.4 X 10**(+38) following are valid examples of double-precision constants. 7.9D03 7.9D+03 7.9D-3 79D03 79D0 (= (= (= (= (= 7900) 7900) .0079) 79000) 79) The following are invalid examples of double-precision constants. 7.9D99 7.9E5 3.2.4 Complex (exponent ("E" is too large) denotes a single-precision constant) Constants integer, of pair You can represent a complex constant by an ordered real, or octal constants written within parentheses and separated by a are 2.297) (8.763E3, and -.70712) (.70712, example, For comma. complex constants. In a complex constant the first (leftmost) real constant of the pair the second real constant the number; of vpart real the represents and real the Both number. the of represents the imaginary part imaginary parts of a complex constant can be signed. The real constants that represent the real and imaginary parts of a 1locations in the storage consecutive two occupy constant complex object program. DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VAR'IABLES, AND ARRAYS DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES,‘AND ARRAYS The Constants Logical 3.2.6 values Boolean of truth and falsehood are represented in .TRUE. and FORTRAN-10 source programs as the logical constants .FALSE.. Always write logical constants enclosed by periods as in the preceding sentence. Logical quantities may be operated on in arithmetic and 1logical Only the sign bit of a numeric used in a logical 1IF statements. statement is tested to determine if it is true (sign is negative) or false (sign is positive). 3.2.7 Literal Constants A.literal constant may be either of the following:‘ 2. A Hollerith alphanumeric 1literal, which string 1is written as a of and/or special characters preceded by nH (2T ey a represents n letter the nH, In the prefix nHstring). characters of exact number the specifies that number H letter (including blanks) that follow the letter H; = the a Hollerith literal. identifies the literal as are examples of Hollerith literals: 2HAB 14HLOAD TEST 6H#124-A ' #124 - The following | | DATA TYPES, 3.3 CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS SYMBOLIC NAMES Symbolic names to six characters. a symoolic The may con name following must e an alphapetic are examples of legal are examples of character. symbolic names: Al2345 IAMBIC ABLE The following You names: (symbol used as first character) 1AB (number used as first character) use a symbolic $#AMBIC source of illegal symbolic program; symbolic names to Table 3-2 name and identify lists text reference | Use Symbolic Can Names Variables 2. Arrays | 3. 4. Array elements. Functions 5. 6. Subroutines External library functions o 7. COMMON names | items, for each. ~ PI, TAX of a an . | | ' | For CONST, Example See Section LIMIT 3.4 3.5 CALCSB, SUB2, LOOKUP 'SIN, ATAN, COSH 3.5.1 15.2 ' 15.5 15.4 | | - DATAR, example For a Detailed - Description B TAX (NAME, INCOME) MYFUNC, VALFUN | FORTRAN-10 with Names - - items together 3-2 Symbolic | 1. block Table of I Identify specific these COMDAT 3-06 - 6.5 DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS VARIABLES 3.4 A variable is a datum (storage 1location) that is identified by a symbolic name and 1is not a constant, an array or an array element. Variables specify wvalues that are assigned to them by either arithmetic statements (Chapter 8), DATA statements (Chapter 7), or at run time via I/O references (Chapter 10). Before you assign a value to a variable, it is termed an undefined variable, reference it except to assign a value to it. If you reference an undefined variable, will an be obtained. and you should not unknown value . (garbage) The value you assign to a variable may be either a constant or the of a calculation that is performed during the execution of the result For example, the statement IAB=5 assigns the constant object program. 1in the statement IAB=5+B, however, the value the variable IAB; to 5 the at of IAB at a given time will depend on the value of variable B time the statement was last executed. The type of a variable is the type of the contents of the it identifies. datum Variables may be: l. 1integer 2. real 3. logical 4. double-precision, 5. complex. that or You may declare the type of a variable by wusing either implicit or explicit type declaration statements (Chapter 6). However, if you do not use type declaration statements, FORTRAN-10 assumes the following convention: 1. Variable names that begin with the N are normally integer variables. 2. Variable names that begin with any letter L, M, or N are normally real variables. Examples of determining the of type foregoing convention are given in the Variable | I OTEMP O KA123 K AABLE 1, J, other K, L, M, than I, according J, or K, the to table: Assumed Data Type Integer Real Integer A Real ARRAYS An array is Section 3.3 names variable a following Beginning Letter ITEMP 3.5 letters are an ordered symbolic for set of data names writing and symbolic identified by an array name. must names. conform Array to the rules given in DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, Each datum within an array you varlables, assign may is array 'an <called AND ARRAYS element. a value to an array element. As with Before you undefined; Dbe assign a value to an array element it is considered to If should not reference it until you have assigned 1t a value. you you reference an undefined array element, will be unknown and unpredictable the of value the element (garbage) . a Name each element of an array by using the array name together with subscript that describes the position of the element within the array. Array Element Subscripts 3.5.1 Give the subscrlpt of an array element identifier w1th1n as either one subscript by commas. delimited after the array name. Write the parenthesized | ’ the number of dimensions 3.5.2) | @ specified for the | A subscript can be any compound expression (Chapter 4), for example: that Subscript quantities may contain arithmetic expressions addition, subtraction, multiplication, division, and involve and (A+B,C*5,D/2) example, For exponentiation. (A**3, (B/4+C) *E,3) 4. m] (Section array. 1. subscript '1mmed1ate1y The general form of an array element name 1is AN (sl, S2,...5n), where AN is the arr n number of subscript quantities. equal parentheses, or a set of subscript gquantities quantity are valid subscripts. Subscripts may contain array element identifiers nested to any level as subscripts. For example, 1in the subscript C(I(J(K(L))) ,A+B,C) the first subscrlpt quantity given 1is a nested 3- level subscript. Here are examples of valid array element subscripts:5 1. 1IAB(1,5,3) 2. ABLE(A) DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS 3.5.2 Dimensioning Arrays You must declare the size enable FORTRAN-10 (number of elements) of an array 1in order to to reserve the needed amount of locations in which to store the array. Arrays are stored as a series of sequential storage locations. Arrays, however, are visualized and referenced as if they were single or multi-dimensional rectilinear matrices, dimensioned on a row, column, and "plane basis. For example, following figure represents a 3-row, 3-column, 2-plane array. the 3 ROWS + £ o \,V 3 COLUMNS 10-1058 You specify the size of an array by an array declarator written as a subscripted array name. In an array declarator, however, each an either subscript quantity is a dimension of the array and must be integer variable or For example, declarators. an integer TABLE(I;J,K) and constant. ' MATRIX . (10,7,3,4) . are - valid | array The total number of elements that comprise an array is the product ' of the dimension quantities given in its array declarator. For example, = (2 X 3 X 4 the array IAB dimensioned as IAB (2,3,4) has 24 elements S | | 24) . You use dimension arrays only in the specification & statements DIMENSION, COMMON, and type declaration (Chapter 6). Subscripted are array statements foregoing in any of the array names appearing declarators; subscripted array names appearing 1in any other statements are always array element identifiers. In array declarators the position of a given subscript quantity determines the particular 1t that plane) or column, row, (e.g., array the dimension of The first three subscript positions specify the number of represents. rows, columns and vplanes that comprise, the named array DATA TYPES, CONSTANTS, SYMBOLIC NAMES, VARIABLES, AND ARRAYS Specifies the Array(s) The Dimension Declarator TABQ) ~ TAB (2,2) A | L T L2 12,1122 NOTE FORTRAN-10 dimensions 3.5.3 1n permits any number an array declarator. of Order of Stored Array Elements The The elements of an value of the order. minimum and maximum values most rapidly. The value of the 1last given subscript quantity increases to its maximum value least rapidly. For example, the elements of the array dimensioned as I(2,3) are stored in the following order: I(1,1) 1I(2,1) In the following (B(3,3,3)) are bottom. array first are arranged in storage in ascending subscript quantity varies between its B 1(1,2) | , (2,2) (1,3) list, the elements stored row by row - (2,3) of the from left three-dimensional array to right and from top to | CB(1,L,1) B(2,1,1) _-B(121) B(221) ~-+B(1,3,1) B(2,3,1) | | BG,1,1) —- | BG2D -B(33,1) -~ “SEQL) BGi)___BGLY) L+B(122) B(222) B(322) -~ ETRasY) Be3)_BGAD - L+B(1,13) B(213) BG13) -~ SSB13) 029 629 -] L-+ B (1,3,3) Thus B(3,1,1) B(233) 7 B(333) is stored before B(1,2,1), and so forth. CHAPTER 4 - 4.1 EXPRESSIONS ARITHMETIC EXPRESSIONS either be may Arithmetic expressions simple compound. or arithmetic expressions consist of an operand that may be: Simple 1. ‘a.constant 2. a variable 3. an array elehent 4. 5. a funcfiiOn reference'(seé-Chapter 14 for desctiption), or or arithmetic an parentheses. logical | written _exptession within Operands may be of integer, real, double precision, complex, | type. The following are valid examples of simple arithmetic expressions: (integer constant) (integer variable) (array element) (function reference) | 105 IAB TABLE(3,4,5) SIN (X) | (A+B) - (a parenthetical expression) A compound arithmetic expression consists of two or more operands Table 4-1 lists the arithmetic combined by arithmetic operators. operations permitted in FORTRAN-10 and the operator recognized for each. . Table 4-1 Arithmetic Operations and Operators Operation 1. Exponentiation 2. Multiplication 3. Division 4, Addition 5. Subtraction Operator Example *% * A**B or A*B / + - A/B A+B A-B EXPRESSIONS Rules 4.1.1 Observe the for Writing following Arithmetic Expressions rules structuring in compound arithmetic expressions: 1. The operands comprising a compound arithmetic expression may combinations of data types the be of result different of each. types. Table 4-2 and the illustrates type all assigned permitted to | NOTE An expression cannot contain operators. For example, permitted. two the | adjacent and expression unseparated A*/B 1is not All operators must be included; no operation 1s implied. - For example, the expression A (B) does not specify multiplication although this is implied in standard algebraic notation. The expression - A* (B) 1is required to obtain a multiplication of the elements. ' When you use exponentiation, the base quantity and its exponent may be of different types. For example, the expression ABC** 13 involves a real base and an 1integer exponent. The permitted base/exponent type combinations and the type of the result of each combination are given in Table 4-3. EXPRESSIONS Table 4-3 Permitted Base/Exponent Type Combinations Exponent Operand Base Operand Complex Double Integer Real Integer Integer Real Real Real Real Double Precision Double Double Double Precision|Precision|Precision Complex Complex 4.2 LOGICAL Complex Precision Complex Double Precision Complex Double Precision Complex (Undefined) EXPRESSIONS Simple 1logical Lojical expressions may be either simple or compound. expressions consist of a logical operand, which may be a logical type: 1. constant 2. wvarilable 3. array element 4. function reference 5. another expression written within parentheses. (see Chapter 15), or Compound logical expressions consist of two or more owerands by logical combined operators. Table 4-4 gives the logical operators permitted by description of the operation each provides. FORTRAN-10 and a EXPRESSIONS Table 4-4 Logical Operators Operator . AND. .OR. | o - - AND operator. Description Both of the logical operands this operator must be true Inclusive OR operator. operands combined by to produce a true combined result. If either or both of the are true, .OR. by logical the result will be true. as a wused 1is Complementation operator. This operator that specifies complementation (inversion) of the prefix The it modifies. that expression) or item (operand original item, if true by itself, becomes false, and vice .NOT. versa. P and where Q, P .OP. Write logical expressions in the general form 1is any logical overator but ".NOT.". logical operand and .0OP. QO are you operand; operator complements the value of a logical The .NOT. must write it immediately before the operand that it modifies, e.g., .NOT.P. Table 4-5 is a truth table illustrating all possible 1logical combinations of two logical operands (P and -Q) and the resultant of When an operand complex, only | | each combination. of a 1logical the high-order ~specified logical operation. The assignment of a .TRUE. double-precision or value to a given operand 1is 1is expression word of or a .FALSE. 5 the operand is used in the based only on the sign of the numeric representation of the operand. EXPRESSIONS Table Logical Wwhen P is »=’"Then the Expression: ————— .NOT.P '4—-ef_} - False True True False . | | | | A | True‘ | False True - True True True False' True - False | 1 ~ False | False | | False True | True False False o P .AND, Q | | P .AND, Q | P .AND. Q | .AND. P | '-vIs: - .NOT.P | False | False Truth Table And»Q is: - True 4-5 Operations, Q | - False True » p .OR. Q | P .OR; Q0 - True True ~-. B PV.OR. Q | False P .OR. O | | Examples Assume the following variables: Variable REAL, I,J,K RUN L, A, CpPX,C B | DP,D of valid logical Examples variables Type are: L.AND.B L.AND.A.OR..NOT. (I-K) ~ - Real Integer Double Precision Logical Complex expressions ' consisting' of . the foregoing EXPRESSIONS Logical functions are performed on the full 36-bit Dbinary processor representation of the operands 1involved. The result of a logical operation is found . by verforming the specified function, simultaneously, for each of the corresponding bits in each operand. For example, <consider the expression A=C.OR.D, where C="456 and D="201. The operation performed by the processor and the result is: Bits 0 Operand C 0 Operand D 0 Result A 0 1—24 Q——— 0 Q———— O Q— 0 25 0 0 0 26 O 0 0 27 28 1 0 0 1 1 1 29 0 0 0 30 1 0 1 31 0o 0 0 | , | word 32 1 0 1 33 1 0 1 34 1 0 1 35 0 1 1 Table 4-5 also illustrates all possible logical combinations of two one-bit binary operands (P and Q) and gives the result of each combination. Just read 1 for true and 0 for false. . 4.2.1 Relational Expressions - “Relational expressions relational operator. to test, consist of two expressions combined by a The relational operator permits the programmer quantitatively, the relationship between two arithmetic expressions. The result of a relational expression false is always a logically value. true or 4 In FORTRAN-10, you may write ‘mnemonic enclosed symbolic forms within of relational operators either periods, e.g., .GT., or as a 2-letter ' Table 4-6 lists both the mnemonic an the FORTRAN-10 relational operators and specifies the type of quantitative test performed by each operator. 4-6 | - Table Relational Operators Operators o B and Operations. | Relation Tested Mnemonic .GT. .GE. .LT. .LE. .EQ. .NE. Greater than Greater than or equal Less than Less than or equal to Equal to Not equal to to EXPRESSIONS Write relational expressions in the general form A(l) A represents an arithmetic operand and .OP. You may mix arithmetic operands of type precision in relational expressions. .OP.A(2), where 1is a relational operator. 1integer, real, and double You may compare complex operands using only the operators .EQ. (==) .NE. (#). and Complex quantities are equal if the corresponding parts of are both words equal. Examples Assume following variables: the Variables - REAL, RON I,JdJ,K DP,D L,A,B - - CpX,C ~ | Type Real Integer Double Precision Logical Complex Examples of valid relational expre551ons con51st1ng of varlables the foregoing are: (REAL) .GT.10 5 == C.EQ.CPX Examples of 1nva11d relatlonal expre551ons con51st1ng of the foreg01ng variables | are: | | o (REAL) .GT 10 (cldsing period‘missing from operator) Examples of valid expressions that use operators to combine the .AND. (I.AND.K)# ( (REAL) .OR. (RON)) — (I.GT. 1 ( (I*RON (I/J)) .OR.K PX.OR.RON Dboth 1og1ca1 fore901ng varlables are: and relational EXPRESSTIONS 4.3 EVALUATION The following expression: OF EXPRESSIONS determine 0of order of computation l. the 2. an established hierarchy for the relational, and logical operations 3. the 4.3.1 use the of a FORTRAN-10 parentheses location Parenthetical of operators within an execution and of arithmetic, expression. Subexpressions In an expression, all subexpressions written within parentheses are evaluated first. When parenthetical subexpressions are nested (one contained within another) the most deeply nested subexpression is evaluated first, the next most deeply nested subexpression 1is evaluated second, and so on, until the wvalue of the final parenthetical expression is computed. When more than one operator is contained by a parenthetical subexpression, the required computations are performed according to the hierarchy assigned operators by FORTRAN-10 (Section 4.3.2). Example: The separate computations A+B/((A/B)+C)-C 1. R1=A/B 2. 2=R1+4C 3. R3=B/R2 4. R4=R3-C 5. R5=A+R4 WHERE: R1 THROUGH R5 COMPUTATIONS 4.3.2 performed in evaluating the expression are: REPRESENT THE INTERIM AND FINAL RESULTS OF THE 1is assigned to the PERFORMED. Hierarchy of Operators The following hierarchy (order classes of FORTRAN-10 operators: first, second, third, of operators, relational operators, 1logical operators. execution) arithmetic and EXPRESSIONS Table 4-7 specifies the With the exception of operators of the aésigned precedence foregoing classes. 'integer division and to individual the exponentiation, all subexpressions involving operators of or expressions on operations algebraically that is 1in any order equal precedence are computed correct. | A subéxpression of a given expression may be computed in order. any the expression (F(X) + A*B), the function reference in example, For may be computed either before or after A*B. Table Hierarchy of Class Level | EXPONENTIAL ”FirSt' | o ARITHMETIC | RELATIONAL N | ' | Second | 4-7 FORTRAN-10 Symbbl or Mnemonic k% L —(unary minus) and + (unary plus) | Third Operators +,- | Fourth | k,/ LE.,.EQ.,.NE. Fifth Sixth Seventh | . | .NOT. .AND. Eighth LOGICAL i Operations specifying integer division are evaluated from left to right. For example, the expression I/J*K is evaluated as if it had evaluation process left-to-right But this been written as (I/J)*K. can be not equal overridden by parentheses. I/(J*K),which I/J*K(evaluated as(I/J) *K) does is evaluated as written here. When a series of exponentiatioh operations occurs in an expression, it the expression is evaluated in order from right to left. For example, A**2*%*B jis evaluated in the following order: first Rl = 2**B (intermediate result) second R2 = A**R]1 (final result). Similarly, here too, parentheses alter the evaluation expression . (A**2)**B is evaluated in these two steps: first R1 = A**2 (intermediate result) second R2 = R1**2 (final result) of the EXPRESSIONS CHAPTER 5 COMPILATION CONTROL‘STATEMENTS 5.1 INTRODOUCTION You use compilation control and to specify their statements to termination. identify FORTRAN-10 programs Statements of this type do not affect either the operations performed by the object program manner in which the object program is executed. The th control statements described and END in this chapter statement. are:. or the ilati COMPILATION CONTROL STATEMENTS 5.4 END STATEMENT Use this statement to signal FORTRAN-10 that the physical source program or subprogram has been reached. END is statement. The general form of an END statement is: end of a a nonexecutable o END The following rules govern the use of the END statement: 1. This statement must be the 3. You source may or program label an last subprogram. END statement. - physical , | statement of a | CHAPTER 6 SPECIFICATION 6.1 STATEMENTS INTRODUCTION Use specification statements storage allocations, specification to specify the and data arrangement. statements: 1. DIMENSION 2. Statements that explicitly spec1fy type characteristics, There are seven types of type, such as REAL or INTEGER 4. COMMON 5. EQUIVALENCE 6. EXTERNAL Specification statements are nonexecutable and conform to the ordering guidelines described 6.2 DIMENSION in Section 2.4. STATEMENT to needed information with DIMENSION statements provide FORTRAN-10 the space required for source program arrays. allocate identify and array as names array subscripted of number You may specify any The general form of a DIMENSION declarators in a DIMENSION statement. statement : is DIMENSION S1, form: . S2, ...,Sn - where Si is an array declarator. following ‘ Array declarators are names - of the name (max, ... ,max) min:max where name is the symbolic name of the array, and each pper bounds of an array dimension. represents the value SPECIFICATION STATEMENTS Examples DIMENSION EDGE DIMENSION TABLE (where IAB, J, K, and M are of NET (5,10,4), type integer). TABLE (567) - 6.3 TYPE SPECIFICATION SPECIFICATION STATEMENTS STATEMENTS Type specification statements declare explicitly the data type of variable, array, or function symbolic names. You may give an array name in a type statement either alone (unsubscripted) to declare the type of all its elements or in a subscripted form to specify both its type and dimensions. Write-type specification statements in the following form: typé4list type may be any one 1. INTEGER 2. REAL 3. DOUBLE PRECISION 4. COMPLEX 5. LOGICAL of the following declarators: | ' | NOTE In order to statements the data be compatible used type by other size with the type manufacturers, modifier, *n, 1is accepted by FORTRAN-10. You may append this size modifier to the declarators, | w causing some to elicit messages warning users of the form of the variable specified by FORTRAN-10: o where - SPECIFICATION Declarator Form Full of STATEMENTS Variable Specified INTEGER*2 INTEGER*4 LOGICAL*1 Full Full word integer with word integer word logical with LOGICAL*4 Full wrd loglcal REAL*4 Full word real REAL*8 Double-precision COMPLEX*8 Complex COMPLEX*16 Complex In addition, type size variables, with you , warning message real warning may message append modifier arrays, warning~message the to or data individual function names. Its effect 1s to override, for the particular element, the size modifier (explicit or implicit) of the primary type. For example, REAL*4 ‘A and D A, B*8, | C*8(10), D are single-precision word) real, double-precision and B (two full . (one .and full C words) are real. The list consists of any number of variable, array, or function names that are to be declared the specified type. The names listed must be separated by commas and can appear in only one type statement w1th1n a program unit. Examples INTEGER REAL R, A, M, B, TABL ARRAY +5) NOTE -and functions of a which are not typed either implicitly or explicitly by a specification statement, are typed by FORTRAN-10 accordlng to the following conventions: Variables, source 1. arrays, program, Variable function letters names, names I, integer.. ~Variable function letter N If a name that appears in a refers generic to a are J, K, names, names other type than names, array that L, with the or are type ‘names, and any M, array that I, and begin N begin J, K, with L, M, or real. is the same conflicting user-defined predefined statement, it loses as a predefined FORTRAN-10 function name type statement, it is assumed that the name routine of the given type. If you place a FORTRAN-10 its generic function name properties. in an explicit type SPECIFICATION STATEMENTS 6.5 COMMON STATEMENT The COMMON statement enables you to establish storage that may be shared by two or more programs and/or subprograms and to name the variables and arrays that are to occupy the common storage. The use of common storage conserves storage and provides a means to implicitly transfer arguments between a calling program and a subprogram. Write COMMON statements in the following form: | COMMON/Al/V1,V2,...,Vn.../An/V1,V2,...,Vn where the enclosed letters /Al/, cess /An/ represent optional constructs (referred to as common block names when used). name SPECIFICATION STATHEMENTS The list (e.g., V1,V2...,Vn) appearing after each name construct lists the names of the variables and arrays that are to occupy the common area identified by the construct. The items specified for a common area are ordered within the storage area as they are listed in the COMMON statement. Either label COMMON storage areas or leave them blank (unlabeled). If the common area 1is to be labeled, g9ive a symbolic name within slashes immediately before the list of items that is to occupy the names area. For example, the statement COMMON/AREAl/A,B,C/AREA2/TAB(13,3,3) establishes block names the If same a or two labeled common areas (i.e., AREAl and bear no relation to internal variables or name. common two that 1s AREA2). Common arrays that have area 1is to sSequential to occupy be declared slashes blank (//) common. as unlabeled, give immediately before For example, the either the nothing list of items statement COMMON/AREAl1/A,B,C//TAB(3,3,3) establishes one Unlabeled common 1labeled (AREA1l) and one unlabeled area 1s also called "blank common". A given labeled common name may appear more COMMON statement and in more than one COMMON program or common area. than once in the statement within the same same subprogram. Each labeled common area is treated as a separate, specific storage area. The contents of a common area, i.e., variables and arrays, may be assigned 1initial wvalues by DATA statements in BLOCK DATA subprograms. Declarations of a given common area 1in different subprograms must contain the same number, size, and order of variables and arrays as the reference area. Items to be statements During placed in a blank common area the source program. throughout compilation of a source may program, also be given FORTRAN-10 in COMMON will string together all items listed for each labeled common area and for blank common areas 1n the order in which they appear in the source program statements. For example, the series of source program statements: COMMON/ST1/A,B,C/ST2/TAB(2,2)//C,D,E COMMON/5T1/TST(3,4)//M,N COMMON/3T2/X,Y,2//0,P,Q has the same effect as the single statement cOMMON/ST1/A,B,C,TST(3,4)/SsT2/TAB(2,2) ,X,Y,2//C,D,E,M,N,0,P,0Q All items specified for blank common are placed into one area. Items within blank common are ordered as they are given throughout the source program. Common block names must be unique with respect to all subroutine, function, and entry point names. The largest definition of a given common area must be loaded first. SPECIFICATION 6.5.1 Dimensioning Arrays in COMMON STATEMENTS Statements Subscripted array names may be given in COMMON statements dimension declarators. However, variables cannot be used as quantities in a declarator appearing in a COMMON statement; dimensioning 1s not permitted in COMMON. Each array name given in a COMMON statement must be as array subscript variable dimensioned either by the COMMON statement or by another dimensioning statement within the program or subprogram that contains the COMMON statement but not both. Example cCoMMON /A/B(100), COMMON 6.6 C(10,10) X(5,15) ,Y(5) EQUIVALENCE STATEMENT The EQUIVALENCE statement enables you to control the allocation of shared storage within a program or subprogram. This statement causes specific storage locations to be shared by two or more variables of either the same or different types. Write the EQUIVALENCE statement in the following form: EQUIVALENCE(V1,V2,...,Vn), (Wl,wWw2,...,Wn), (X1,X2,...,Xn) where each parenthetical list contains the names of array elements that are to share the same storage example, the statements EQUIVALENCE (A,B,C) EQUIVALENCE (LOC,SHARE(1l)) specify that the variables named A, B, and C are to storage location, and that the variable LOC and array are to share the same location. The relationship of equivalence is following statements have the same share the same element SHARE(1) two When you use array elements in EQUIVALENCE statements, they must either as many subscript quantities as dimensions of the array or one subscript quantity. In either of the foregoing cases, subscripts must be integer constants. Note that the single treats the array as a one-dimensional array of the given type. have You (A,B), (B,C) EQUIVALENCE (A,B,C) may use the EQUIVALENCE following l. rules You to items given in an and in a statement are cannot be for and For the EQUIVALENCE transitive; effect: wvariables locations. EQUIVALENCE COMMON example, 1list statement 1in only the case both the providing the observed: set two equivalent to quantities one declared another. in a COMMON statement STATEMENTS SPECIFICATION 2. Quantities placed in a common aréa by means of an EQUIVALENCE statement are permitted forwards. For example, to extend the end of the common the statements | area - COMMON/R/X,Y,% DIMENSION A(4)'“ EQUIVALENCE (A,Y) cause the common block R to extend from Z to A(4) arranged as follows: | | 1) 2) | (shared (shared | D location) location) 3) | 4) 3. You cannot use EQUIVALENCE statements that cause the start of a common block to be extended backwards. For example, the o ~ | sequence invalid COMMON/R/X,Y,Z DIMENSION A(4) EQUIVALENCE (X,A{(3)) would require A(l) of block R 1in following diagram: ? A(l) X A(3) Y A(4) and A(2) to extend the a backwards direction as starting 1location illustrated by the - A(2) Z 6.7 STATEMENT EXTERNAL Any subprogram name to be used as an argument to EXTERNAL declares names subprogram must appear 1in an EXTERNAL statement statement distinguish them EXTERNAL statement from in the other to variable following another subprogram in the calling subprogram. form: be or array names. names The to Write the EXTERNAL namel,naméz,...,namen where each name listed is desired, declared to be a subprogram these subprogram names may be FORTRAN-10 defined You may also use (&) within an EXTERNAL subprograms EXTERNAL FORTRAN-10 by prefixing *SIN, statement. &COS defined function the names by an asterisk For example, names (*) or name. functions. for If your an ampersand SPECIFICATION STATEMENTS declares SIN and COS to be user subprograms. (If a prefixed name ‘not a FORTRAN-10 defined function, then the prefix is 1ignored.) 1s Note that specifying a predefined FORTRAN-10 function in an EXTERNAL statement without a prefix, i.e., EXTERNAL SIN, has no effect upon the If the of actual argument lists. usage of the function name outside name has generic properties, they are retained outside of the actual (The name has no generic properties within an argument argument list. o list.) The names declared in a program EXTERNAL statement Care reserved throughout the compilation of the program and cannot be used in any other declarator statement, with the exception of a type statement. CHAPTER DATA 7 STATEMENT INTRODUCTION 7.1 DATA statements are used to supply the initial values of variables, arrays, array elements, and labeled common.(l) Write DATA statements as follows: - | | DATA Listl/Datal/,List2/Data2/,...,Listn/Datan/ where the List portion of each List/Data/ pair 1identifies a set of items to be initialized and the /Data/ portion contains the list of values to be assigned the items in the List. For example, the statement ? - DATA IA/S/,IB/10/,IC/15/ initializes variable and IA to the value the variable IC to the value 15. 5, variable IB to the wvalue 10, The number of storage locations you specify in the list of variables must be less than or equal to the number of storage locations you specify in its associated list of values. If the list of variables is larger (specifies more storage locations) than its associated value 1list, a warning message 1is output. When the value list specifies more storage locations than the variable list, the excess values are ignored. The List portion of each List/Data/ set may contain the names or more variables variabl | array >t The /Data/ portion numeric, 1logical, elements, or Refer to Paragraph 6.5 for a description of labeled common. 7-1 one may contain one or more constants and/or alphanumeric 'strings. 1. of labeled common DATA STATEMENT You may specify literal data as either a Hollerith specification, e.g., BSHABCDE, or a string enclosed in single quotes, e.g., 'ABCDE'. Each ASCII datum is stored left-justified and is padded with blanks up to the right boundary of the variable being initialized. When you assign the same value to more than one item in List, a repeat specification may be used. Write the repeat specification as N*D where N is an integer that specifies how many times the value of item D 1s to Dbe used. For example, a /Data/ specification of /3*20/ specifies that the value 20 is to be assigned to the first three items named in the preceding list. The statement DATA M,N,L/3*%20/ assigns the value 20 to the variables M, N, and L. - Sample Statement | DATA PRINT,I,O/'TEST',30,"77/,(TAB(J),J=1,30)/30*5/ The Use first elements TAB of initialized 30 ~ array are to 5.0. DATA((A(I,J),I=1,5),Jd=1,56)/30*%1.0/ No conversion required. DATA((A(I,J),I=5,10),J3=6,15)/60%2.0/ | | ~ “No conversion required. When a literal string is specified that 1s longer than one variable can hold, the string will be stored left-justified across as many variables as are needed to hold it. If necessary, the last wvariable used will be padded with blanks up to its right boundary. Example Assuming that X, Y, and 7 are single-precision, the statement DATA X,Y,Z2/'ABCDEFGHIJKL"'/ will cause X Y to to be be initialized initialized to 'ABCDE' to 'FGHIJ' 'Z to be initialized to - 'KLPpPY' When a literal string is to be stored in double-precision and/or complex variables and the specified string is only one word long, the second word of the variable is padded with blanks. DATA STATEMENT Example Assuming that the variable C is complex, the statement DATA C/'ABCDE','FGHIJ'/ 1its and 'ABCDE' will cause the first word of C to be initialized to 1is 'FGHIJ' string The 'PpPPPPY'. to initialized second word to be ignored. CHAPTER ASSIGNMENT 8.1 8 STATEMENTS INTRODUCTION Use assignment statements to assign a specific value to one or more program variables. There are three kinds of assignment statements: 8.2 1. Arithmetic assignment statements 2. Logical assignment statements 3. Statement Label assignment (ASSIGN) statements. ARITHMETIC ASSIGNMENT STATEMENT You use statements of this type to assign specific numeric variables and/or statements in the array elements. form Write arithmetic wvalues . to assignment v=e wherev is the name of the wvariable receive the or array element that 1is to specified value and e is a simple or compound arithmetic expression. In assignment statements, the equal symbol (=) does not imply equality as it would 1in algebraic expressions; it implies replacement. For example, the expression v=e is correctly interpreted as "the current contents of the 1location identified as v are to be replaced by the final value of expression e; the current contents of v are lost.” ASSIGNMENT STATEMENTS ASSIGNMENT STATEMENTS ASSIGNMENT STATEMENTS 8.3 Use and LOGICAL ASSIGNMENT STATEMENTS this type of assignment statement to array elements of type logical. statement in the form assign Write | wvalues to variables the logical assignment v=e where v is one or more variables and/or a logical | expression. array element names, and e 1is Examples Assuming that the variables L, F, M, and G are of following type statements are valid: logical, the Statement Sample I,=.TRUE. | The contents of L is replaced by logical truth. F=.NOT.G - The contents of L. logical M=A.GT.T ~ complement 1is of replaced the - of the G. If A M is is greater than T, the contents of replaced by logical truth; if A is less than or equal to T, the contents of M 1s replaced by logical false. can also be read: If A 1is greater This than T, M then M 1is true, otherwise, false. =((I.GT.H) .AND by contents The the is | contents true of or L are false replaced by either resultant of the expression. 8.4 ASSIGN (STATEMENT LABEL) ASSIGNMENT STATEMENT Use the ASSIGN statement to assign a statement label constant, i.e., a l1- to 5dlglt statement number, statement in ASSIGN the n TO form to a variable name. . Write the ASSIGN - I where n represents the statement number and I is a variable name. For example, the statement ASSIGN 2000 TO LABEL specifies that the variable 2000. LABEL repreSents - the | With the exception of complex and double-precision, type of variable in an ASSIGN statement. statement number you may use Once a variable has been assigned a statement number, FORTRAN-10 consider it a label wvariable. If a label variable is used arithmetic statement, the result will be unpredictable. any will an in ASSIGNMENT Use the ASSIGN statements variables statement (Chapter that statements. in 9). TAX=(A+B+C) *.05 ASSIGN GO TO conjunction with The ASSIGN verb assigned sets up GO TO control statement label subsequent GO TO control are then referenced 1in The following sequence illustrates the use of the ASSIGN statement: 555 STATEMENTS 555 LABEL TO LABEL CHAPTER CONTROL 9.1 9 STATEMENTS INTRODUCTION FORTRAN-10 object programs normally execute statement-by-statement 1in the order in which they were presented to the compiler. The following source program control statements, however, enable you to alter the normal 9.2 There sequence of l. GO 2. 1IF 3. DO 4., CONTINUE 6. PAUSE GO TO are statement execution: TO CONTROL three STATEMENTS kinds of 1. Unconditional 2. Computed 3. Assigned GO TO statements: A GO TO control statement causes the statement that it identifies to be executed next, regardless of its position within the program. The following 9.2.1 paragraphs Unconditional describe GO TO Write GO TO statements GO TO where n is statement, of each type of GO TO Statements this type in the form n the 1label, i.e., e.g., GO T0 555. statement number, of an executable When executed, an unconditional GO TO statement transfers control of the program to the specifies. statement. statement that it CONTROL STATEMENTS You may position an unconditional GO TO source program except as the terminating 9.2.2 Write Computed GO TO GO TO GO TO statement anywhere in statement of a DO loop. the Statements statements of this type in the form (N1,N2,...,NK)E where the parenthesized list is a list of statement numbers and E 1is an arithmetic expression. You may include any number of statement numbers in the list of this type of GO TO statement; however, each number you give must be wused as a label within the program or subprogram containing the GO TO statement. NOTE A comma may parenthesized The value that 1s statement optionally list. follow of the expression E must be reducible greater than 0 and 1less than or numbers given in the statement list. expression statement E is does not compute within the the to an integer value equal to the number of 1If the wvalue of the foregoing When a computed GO TO statement 1is executed, the expression, 1i.e., E, is computed first. The value of position within the given list of statement numbers of identifies the statement to be executed next. For statement GO range, the next executed. wvalue of its E specifies the the number that example, in the sequence TO CALL (20, 10, XRANGE (K) 5)K the variable K acts as a switch, causing a transfer to statement 20 if K=1, to statement 10 if K=2, or to statement 5 if K=3. The subprogram XRANGE 1is called 1f K is less than 1 or greater than 3. 9.2.3 Write Assigned GO TO GO TO statements Statements of GO TO K GO TO K, (Ll1,L2,...Ln) this type in either of the following forms: where K 1s a variable name and the parenthesized list of the second form contains a 1list of statement labels, i.e., statement numbers. The statement numbers you give must be within the program or subprogram containing the GO TO statement. Assigned preceded variable GO TO statements of either foregoing by an ASSIGN statement that assigns name represented by K. The value variable it 1s which GO must be used. TO in 1In the same statements K,(Ll1,L2,...Ln) form must be logically a statement label to the of the assigned 1label program unit as written in the the GO TO form statement in CONTROL STATEMENTS if K is not assigned one of the statement list, the next sequential statement statement numbers given is executed. in the 1logical, and Examples GO TO GO TO 9.3 STATI1 STAT1,(177,207,777) STATEMENTS IF There are three kinds logical two-branch. 9.3.1 Write Arithmetic IF IF statements of IF statements: arithmetic, Statements of this type in the form IF(E)L1,L2,L3 where are (E) the is an expression labels, 1.e., enclosed within parentheses and statement numbers, of three L1, L2, L3 executable statements. This the type of IF statement transfers control of the program to one of given statements according to the computed value of the given expressions. If the value of the expression 1. Less than identified 0, control by L1; 2. Equal to identified 0, by 3. Greater than identified <control L2; 0, by control 1is 1is 1is: transferred transferred 1is transferred to to to the statement the statement the statement L3. You must give all three statement numbers the expression given may not compute to a in arithmetic IF complex value. statements; Examples Sample IF(ETA)4, 7, Statement 12 IF (KAPPA-L(10)) 20, Transfers control to statement 4 ETA 1is negative, to statement 7 ETA is 0, and to statement 12 ETA is greater than 0. 14, 14 Transfers control to if KAPPA 1s 1less 1if if 1if statement 20 than the 10th element of array L and to statement 14 if KAPPA 1is greater than or equal to the 10th element of array L. CONTROL 9.3.2 Logical Write IF IF STATEMENTS Statements statements of this type in the form IF(E)S where E 1s any executable expression enclosed in parentheses and S 1s a complete statement. Logical IF statements transfer control of the program either to the next sequential executable statement or the statement given in the IF statement, i.e., S, according to the computed 1logical wvalue of the given expression. If the wvalue of the given logical expression is true (negative), control is given to the executable statement within the IF statement. 1If the value of the expression is false (positive or zero), control is transferred to the next sequential executable program The statement. statement executable you give in a logical statement except a Sample Statement IF DO statement may be statement or any FORTRAN-=10 another logical IF statement. Examples IF (T.OR.S) IF X=Y+1 (Z.GT.X(K)) CALL SWITCH(S,Y) Performs an replacement operation result is Performs the IF (K.EQ.INDEX) GO TO of 15 Write IF IF Two-Branch statements (E) N1, of IF this (negative), the to statement Note portion you IF N1 If is call 1if an true. unconditional 1f the result of IF true. tyve in the form and N1 and N2 are statement is false transferred to (positive zero), or statement Nl. control If is the to the 1is value transferred N2. must number two-branch of 1is statements transfer control of the program or N2, depending on the computed value of the value of the given 1logical expression control expression that logical IF N2 Logical two-branch either statement given expression. true the Statements where E 1s any parenthetical expression, labels defined within the program unit. of 1if true. subroutine of Performs is Logical a result transfer 9.3.3 IF arithmetic code that IF so was the that statement control skipped. can immediately later be following transferred to the the CONTROL STATEMENTS Examples Sample 9.4 Statement IF (LOG1l) 10,20 IF (A.LT.B.AND.A.LT.C) DO STATEMENT Transfers control to statement Transfers control to statement if LOGl transfers 31,32 if A 1is 1less than both B and transfers control to statement if A 1is greater than or equal either B or C. DO statements simplify the coding of iterative procedures; in the following 10 1is negative; otherwise control to statement 20. 31 C; 32 to write them form: Indexing Parameters DO NI Ml M2,M3 = TERMINAL STATEMENT LABEL IVCREMENT PARAMETER TERMINAL INDEX PARAMETER VARIABLE INITIAL PARAMETER where Terminal Statement Label N is the statement number of the last statement of the DO statement range. The range of a DO statement is defined as the series of statements that follows the DO statements up to and including its specified terminal statement. Index Variable I is an unsubscripted variable whose value 1is defined at the start of the DO statement operations. The index variable is available for use throughout each execution of the range of the DO statement, but its value should not be altered within this range. It is also available for wuse 1in the a. program when: 1loop control is transferred outside the range of the DO by a GO TO, arithmetic IF or RETURN statement located within the DO range, b. a CALL is executed from within the DO statement that uses the index variable as an argument, and C. if an input-output statement with options END= or ERR= (Chapter 10) statement range. range either or both the appears within the DO - 3. CONTROL 1Initial Parameter M1 4, 5. assigns initial element, wvalue. This or expression. Terminal Parameter many repetitions of STATEMENTS the may be variable, ‘I; any variable, its array | M2 provides the index parameter DO the value that determines statement range are performed. how Increment Parameter M3 specifies the value to be added to the initial parameter (Ml) on completion of each cycle of the DO loop. If M3 and its preceding comma are omitted, M3 1is assumed to be equal to 1. | An indexing parameter may be any expression resulting in either a positive or negative value. The values of the indexing parameters are calculated only once, at the start of each DO-loop operation. The number of times that a DO 1loop will execute is specified by the formula: MAX ((M2-M1)/M3+1,1) Since the count is computed at the start of a DO 1loop operation, changing the value of the loop index variable within the loop cannot affect the number of times that the loop is executed. At the start of a DO loop operation, the ‘index value 1is set to the value of the initial parameter (Ml), and a count variable (generated by the compiler) 1s set to the negative of the calculated count. At the end of each DO loop cycle, added to the index the value of the variable, If the number of specified cycle of the loop is One execution of a DO initial values of the and increment the parameter count variable is (M3) 1is incremented. iterations have not been performed, another initiated. loop range is always performed regardless of index variable and the indexing parameters.: the Exit from a DO 1loop operation on completion of the number of iterations specified by the 1loop count is referred to as a normal exit. In a normal exit, <control passes to the first executable statement after the DO loop range terminal statement, and the value of the DO statement index variable is considered undefined. Exit from a DO loop may also be accomplished by a transfer of by a range 9.4.]1 statement of the Nested DO within statement DO the DO loop range (Paragraph 9.4.3). | Statements One or more DO statements may be contained, i.e., nested, range of another of DO statements. control to a statement outside the DO statement. The following - rules govern ' within the the nesting CONTROL STATEMENTS 1. The range of each nested DO statement must be entirely within the range of the containing DO statement. Example vValid Invalid DO 1 DO 1 2 DO DO 2 2. The ranges of nested DO The range of DO 2 is outside that of DO 1. statements cannot overlap. ranges of Example Valid Invalid DO 1 DO 1 2 DO DO 2 DO 3 [ 3 DO —EEEE The loop DO 2 and DO 3 overlap. More than one DO loop within a nest of DO loops may end on the same statement. When this occurs, the terminal statement is considered to belong to the innermost DO statement that ends on that statement. The statement label 4 of the shared terminal statement cannot be used in any GO TO or arithmetic IF statement that occurs anywhere other than within the range of the DO statement to which it belongs. Example DO 4 All DO 4 DO 4 the DO statements share the same terminal statement, however, it belongs 4 DO to DO 4. CONTROL Extended 9.4.2 STATEMENTS Range The extended range of a DO statement 1is defined as the set of statements that execute between the transfers out of the innermost DO statement of a set of nested DOs and the transfer back into the range of this 1innermost DO statement. The extended range of a nested DO statement is as follows: DO 1 2 DO DO3 — (out) 4 (in) Extended Range The following 1. rules govern the use of a DO statement extended range: The transfer out statement for an extended range operation must be contained by the most deeply nested DO statement that contains the location to which the return transfer is to be made. 2. A transfer into the range of a DO statement is permitted only if the transfer 1is made from the extended range of that DO statement. 3. The extended DO statement. range of a DO statement must not contain another CONTROL STATEMENTS 4. The extended range of a DO statement cannot change the variable or indexing parameters of the DO statement. 5. You may use and return from a subprogram within an 1index extended range. Permitted Transfer Operations 9.4.3 The following rules govern the transfer of program control a DO statement 1. range or ranges of nested DO statements: the at permitted 1is A transfer out of the range of any DO loop any time. When such a transfer executes, the value of the the as controlling DO statement's index variable is defined current value. 2. A transfer into the range of a DO statement is 3. You may use and return from it is made range of from the extended a. DO nested a of subprogram permitted 1if DO statement. from within the DO loop, or extended range loop (in which you leave the loop via a GO TO, execute statements elsewhere, and return to the loop). The following examples illustrate the from of the ranges nested DO transfer statements: Transfers Dl D2 —_— v extended range 5 Invalid the loop, original within range any: b. c. valid from within Transfer D1 D2 D3 J operations permitted CONTROL 9.5 CONTINUE STATEMENTS STATEMENT You may place CONTINUE statements anywhere 1in the source program without affecting the program sequence of execution. CONTINUE statements are commonly used as the last statement of a DO statement range 1in order to avoid ending with a GO TO, PAUSE, STOP, RETURN, arithmetic IF, another DO statement, or a logical IF statement containing any of the foregoing statements. Write this statement as 12 CONTINUE Example In the following sequence, the labeled CONTINUE statement legal termination DO 45 for the range of the DO loop. provides a ITEM=1,1000 STOCK=NVNTRY (ITEM) CALL UPDATE (STOCK,TALLY) IF(ITEM.EQ.LAST) 9.6 45 CONTINUE 77 PRINT STOP 20, GO TO 77 HEADING,PAGENO STATEMENT Execution of the STOP statement causes the execution of the object program to be terminated and returns control to the DECsystem-10 Monitor. A descriptive message may optionally be included in the STOP statement to be output to your I/O terminal immediately before program execution is terminated. Write this statement like this: STOP or CONTROL 9.7 PAUSE STATEMENTS STATEMENT a PAUSE statement suspends the execution Execution of program and gives you the option to: 1. Continue execution of the program 2. Exit The permitted forms of the PAUSE statements are: 1. PAUSE | of the object CONTROL STATEMENTS 'CONTROL STATEMENTS CHAPTER 10 I/0 10.1 STATEMENTS DATA TRANSFER OPERATIONS FORTRAN-10 processor 1I/0 storage statements (core) permit the and peripheral transfer of data devices and/or between between storage locations. Data in the form of logical records may be transferred b equential, . The areas in core from which data is to be taken during e) operations and into which data is stored during input operations are specified by: (read) The 1. A list in the I/0 statement that initiated the transfer 3. Between type and a specified arrangement of format specificati The following 10.2 TRANSFER MODES required The to sections initiate characteristics statement transferred data the requirements of and the external may be statements and eij in describe I/O and FORMAT transfer operations. the are a) , medium. specified data : by format sequential, described 1in the owing paragraphs. 10.2.1 Sequential Mode Records are transferred during a sequential mode of operation in the same order they appear in the external data file. Each I/O statement executed 1in a sequential mode transfers the record immediately following the last record transferred 10-1 from the accessed source file. 1/0 STATEMENTS 10.3 I/0 STATEMENTS, BASIC FORMATS AND COMPONENTS The majority of the I/0O statements described = in this chapter are written in one of the following basic forms or in some modification of Basic ‘ : forms: these Statement Forms Use where Keyword = the u = FORTRAN-10 f = FORMAT statement number in list statement name logical (READ or WRITE) unit number the currént program unit or the name of an array that contains desired format specifications th ' I/0 list The following paragraphs provide details of the foregoing components. 10-2 I/0 STATEMENTS 10.3.1 1I/0 Statement The keywords this chapter (names) Keywords of the FORTRAN-10 I/O statements are: described in WRITE PRINT PUNCH 10.3.3 A FORMAT FORMAT Statement statement References contains a set of format specifications that defines the structure of a record and the form of the data fields comprising the record. Format specifications may also be stored in an array rather than in a FORMAT statement. (Refer to Chapter 13 for a complete description of the FORMAT statement.) The execution statement of specifications to assume Records I/0 as statements referred data causes the to 1is to form formatting and that name an the structure specified under that the do a in the referenced a of the format Conversely, reference records. one-to-one external of a format During either that data control not includes array and records. "unformatted"” on of 1locations, FORMAT transferred statement or format record array. specification records specification with are transfers, between no are transferred unformatted correspondence (device) a contains internal conversion or operations. Unformatted embedded as statement the "formatted" transferred (processor) I/0 or transferred referred by an number files control are binary words; the files divided control cannot prepare files of this type files are for use only within the words into are records by invisible without using FOROTS. FORTRAN-10 environment. 10-3 FORTRAN-10 to you. You Unformatted I/0 STATEMENTS 10-4 I/0 STATEMENTS 10-5 I1/0 STATEMENTS 1I/0 List 10.3.4 An I/0 list specifies the names of variables, arrays, and array elements to which input data is to be assigned or from which data is to be output. Implied DO constructs (Paragraph 10.3.4.1), which specify sets of array elements, may also be included in I/O lists. The number of items in a statement list determines the amount of data to be transferred during each execution of the statement. 10.3.4.1 Implied DO Constructs - When an array name is given 1in an I/0 1list, all elements of +the array are transferred in the order described in Chapter 3 (Paragraph 3.5.3). 1If only a specific set of array elements 1is involved, they may be specified in the I/O list either individually or in the form of an implied DO construct. Write implied DOs within parentheses in a format similar to that of DO statements. They may contain one or more variable, array, and/or array element names, delimited by commas and followed by indexing parameters that The general are defined form of an as for implied DO DO statements. 1is (name (SL) ,I=M1,M2,M3) where array name name = an SL = the subscript 1list element identifier I = the index subscript M1l,M2,M3 = the indexing respectively, increment values M3 is of 1 of an array or an array control variable that may represent a appearing in a preceding subscript list parameters that specify, the initial, terminal, and that control the range of I. 1If (with its preceding comma), a value omitted assumed. is Examples (A(S) ,S=1,5) Specifies A(3), (A(2,S),5=1,10,2) As stated previously, variable A(4), first five elements of array A, i.e., A(l), the A(2), A(5). Specifies the elements Specifies the integers 1,2,3,4, implied DO constructs may also contain A(2,5), (I,I=1,5) more the one-dimension A(2,7), A(2,9) A(2,1), of A(2,3), array A. and one 5. or names. Example I, J, B, and C must be integer variables. ((A(B,C),B=1,10),C=1,10) ,I,J Specifies a 10 X 10 set of elements of array A, the location identified by I, and the 1location identified by 10-6 J. 1/0 STATEMENTS You may also nest implied DO constructs. one or more sets of indexing Nested implied DOs may share parameters. | Example ((A(J,K);J=l,5),D(K),K=l,10) - Specifies a5 X 10 set of | of array elements A of and array the elements first D. 10 | When you specify an array or set of array elements as either a storage or transmitting area for I/0 purposes, the array elements involved are accessed in ascending order with the value of the first subscript guantity varying most rapidly and the value of the 1last given subscript increasing to its maximum value least rapidly. For example, the elements of an array dimensioned as TAB(2,3) are accessed in the order: 10.3.4.2 Formatted Record Handling - Data is processed under format control so that each item 1in the I/0 list is matched with a field descriptor in the FORMAT statement. If the end of the FORMAT specification 1is reached and more items remain in the I/0 list, a new line or record is established and the data processing 1is restarted, either: 1. 2. , at the first item in the FORMAT specification or, (if parenthesized sets of FORMAT specifications exist the FORMAT specification) with specification. the last , set within | | the within FORMAT | On input, 1f the record is exhausted before the data transfers are completed, the remainder of the transfer is completed as if the record were extended with blanks. See Section 13.2.2 for more details. 10-7 I/0 STATEMENTS 10-8 I/0 STATEMENTS 10-9 I1/0 STATEMENTS 10~-10 I/0 STATEMENTS '10.5 READ S5TATEMENTS READ statements transfer data from'peripheral devices 1into specified processor storage 1locations. The permitted forms of this type of input statment permit READ statments to be used on both sequential and random access transfer modes for formatted, unformatted, list-directed, and NAMELIST-controlled data transfers. 10.5.1 ‘Sequential Formatted READ Transfers Descriptions of the READ . statements that sequential transfer of formatted data follow: 1. Form: Use: Example: 2. Form: Use: , READ may be wused for the (u,f)list Input data from logical unit u, formatted according to the specification given in £, into the processor storage locations identified 1in input list. READ (10,555)TABLE(10,20) ,ABLE,BAKER,CHARL READ (u, £) | - Input the data from logical unit u directly 1into either a Hollerith (H) field descriptor or a literal field descriptor given within the format specifications of the referenced FORMAT statement. If the referenced FORMAT statement does not contain either of the foregoing types of format field descriptors, the input record 1is skipped. If a reqguired field descriptor is present, its contents are replaced by the input data. Example: READ(15,101) 10-11 I/0 STATEMENTS 3. Form: - Use: £ READ Input the data from the READ default device (card reader) directly into either a Hollerith (H) field descriptor or a 1literal field descriptor given within the format specifications of the referenced FORMAT statement. If the referenced FORMAT statement does not contain either of the foregoing types of format field descriptors, the 1input record is skipped. If a required field descriptor is present, its contents are replaced by the input Adata. Example: 4. Form: Use: READ 66 READ f,list Input the data from the READ default device f. Example: 10.5.2 (card reader) into the ©processor storage 1locations identified in the input list. The input data 1is formatted according to the specifications given in ‘ ARRAY READ 15, (20,30) Sequential Unformatted Binary READ Transfer You may use only the following form of the READ statement sequential transfer of unformatted input FORTRAN binary data: Form: Use: READ for (u)list Input one logical record of data from logical unit u into processor storage as the wvalue of the location binary WRITE identified files in list. output statement by this You may read If you wuse the unformatted input READ (10) only by a FORTRAN-10 unformatted type of READ statement. NOTE Example: the form READ (u) , one record will be skipped. BINFIL (10,20,30) I/0 STATEMENTS 10-13 I/0 STATEMENTS 10.6 SUMMARY OF Table 10-2 READ STATEMENTS summarizes the various forms | Tyoe of Transfer | 10-2 Table Summary of of the READ statements. | Transfer Sequential Formatted » | READ Statements READ(u,f)list f) READ(u, READ f,list READ £ 10-14 | Mode I/0 STATEMENTS 10-15 I/0 STATEMENTS WRITE STATEMENTS 10.8 WRITE statements transfer data from specified locations to peripheral devices. The variou statement enable it to be wused 1in sequential, modes for formatted, data transfers. 10.8.1 2. 3. 10.8.2 storage i unformatte - Sequential Formatted WRITE Transfers You may use the following forms of the sequential transfer of formatted data: 1. processor Form: WRITE statement for the WRITE(u,f)list Use: Output the wvalues of the processor storage Example: WRITE(O06,500)0U0T(10,20) ,A,B Form: WRITE f,list Use: Output the wvalues ©0of the processor storage locations identified in list to the default device (line printer). Convert and arrange the output data according to the specifications given in f. Example: WRITE Form: WRITE f Use: Output the contents of any Hollerith (H) literal (''"). field descriptor(s) contained by f the default device (line printer). 1If neither the foregoing types of field specifications found in £, no output transfer is performed. Example: WRITE locations identified in 1list into the associated with 1logical unit u. Convert arrange the output data according to specifications given in f£. file and the 10,SEND(5,10),A,B,C | | or to of is 10 Sequential Unformatted Binary WRITE-Transfer' You may use the sequential following transfer Form: Use: | Example: of form of unformatted WRITE (u)list OQutput the the WRITE statements for the data: wvalues of the processor storage locations identified in 1list into the file associated with logical unit u. No conversion or arrangement of output data is performed. WRITE(12)1TAB(20,20) ,5UMS(10,5,2) 10-16 I1/0 STATEMENTS 10-17 I1/0 STATEMENTS 10.9 SUMMARY Table 10-3 OF WRITE summarizes STATEMENTS the various - Summary Type of forms Table of the WRITE 10-3 of WRITE Statements Transfer Transfer Sequential Formatted WRITE(u,f)list WRITE f,list WRITE statements. £ 10-18 Mode I/0 STATEMENTS PRINT 10.11 STATEMENT The PRINT statement causes data from specified processor storage locations to be output on the standard output device (line printer). Use this statement only for sequential formatted data transfer operation; write it in either of the three following forms: 1. 2. 3. Form: PRINT fi,list Use: | Output the wvalues of the Processor storage locations identified by the contents of list to the line printer. The values output are to be formatted and arranged according to the format specifications given in f. Example: PRINT 55,TABLE(10,20),I,J,K Form: PRINT *,list Use: Output the wvalues of the processor storage locations 1identified by the contents of list to the line printer. The conversion of each datum from internal to external form 1is performed according to the type of the 1list wvariable from which the datum is taken. Example: _PRINT *,C'X)Y'ITAB(IO'lO) Form: PRINT £ Use: Output the contents of Hollerith (H) line printer. the FORMAT statement or literal field descriptors to the 1If neither an H nor a literal field 10-19 STATEMENTS I/0 descriptor statement, Example: 1is present 1in the referenced no operation is performed. FORMAT PRINT 55 The second form of the PRINT statement 1is particularly wuseful when ACCEPT f statements to cause desired data (comments or with employed headings) to be inserted into reports at program execution time. Example The sequence. 55 FORMAT (' END OF ROUTINE') 55 "PRINT results in the printing of the phrase "END OF ROUTINE" on printer. . PUNCH 10.12 - the line STATEMENT The PUNCH statement causes data in one of following from specified processor storage processor storage locations to be output to the system standard paper tape punch. Use this statement only for sequential formatted data transfers; write it l. the three PUNCH Form: Use: to Exanple: of the format specifications given in £f. 10,TABLE(10,20),I,J,K | PUNCH *,list ~ list to values -are to be formatted and arranged according the PUNCH 2. Form: Output the wvalues of - the processor storage locations identified by the contents of list to the paper tape punch unit. The conversion of each datum from internal to external form is performed according to the type of the 1list wvariable from which the datum is taken. - Example: Form: values locations identified by the contents of the standard paper tape punch wunit. The ~output 3. | f,list OQutput the | Use: forms: PUNCH *,I,A,B,M,TAB(5,10) - Use: f PUNCH Output the contents of the referenced FORMAT statement Hollerith (H) or literal field descriptors to the standard paper tape punch unit. If neither an H nor a literal field descriptor is present in the referenced operation is performed. FORMAT statement, , no The third form of the PUNCH statement is particularly useful when employed in- conjunction with an ACCEPT f statement to cause user—-entered data (comments or headings) to be added to an output file at program execution time. 10-20 I/0 STATEMENTS 10-21 I/0 STATEMENTS 10-22 I1/0 STATEMENTS 10-23 I/0 STATEMENTS 10-24 I/0 STATEMENTS 10.16 SUMMARY OF I/0 STATEMENTS Table 10-4 on pages 10-26 and 10-27 presents permitted forms of the FORTRAN-10 I/0O statement. 10-25 a summary of all Tetjusnbag10 Tet3iusnbeg JLITYM aNId dvdaddd mo_mumgasm aviad /TeIrtisujaunsbuwsagjlelis AaLvvTaapdyoI3dM1yI3SARTTA SIWTSI!To’!gIT!’ O0T-NVYdILI0d O/Isjuswailels I/0 STATEMENTS IaSTva(Iy‘n) AILSTIV(FUIM‘n) 10-26 burtuieluod3JewiIOo]UOTJRWIOJUT F jusawslels Iaqunu JO LYWYOd KT3jeuds1abuoaTjtels3Tu10nis2auwqeuiuneuuJOwongAeJiOe0T-NVYIMOd0/Isjuawalels I/0 STATEMENTS |ITAHeSOrTjNuAsun’4boFas 10-27 st | 11 NAMELIST STATEMENTS 11-2 NAMELIST STATEMENTS 11-3 12-1 FILE CONTROL STATEMENTS 12-2 FILE CONTROL STATEMENTS 12-3 FILE CONTROL STATEMENTS 12-4 FILE CONTROL STATEMENTS 12-5 CONTROL 12- STATEMENTS 6] FILE FILE CONTROL STATEMENTS 12-7 FILE CONTROL STATEMENTS 12-8 FILE CONTROL STATEMENTS 12-9 FILE CONTROL STATEMENTS 12-10 FILE CONTROL STATEMENTS 12-11 CHAPTER FORMAT 13.1 Use STATEMENT INTRODUCTION FORMAT statements statements during 1in data fields FORMAT PROGRAM, The FUNCTION, precede must may only the label data each appear that, specify record. almost placement SUBPROGRAM, END the or together the forms anywhere BLOCK in statements so to that a are DATA (Refer 1list of The 1I/0 FORMAT with the 1list of the data and FORTRAN-10 source that follow they statements; Section I/0 I/0 operations. restrictions statement. FORMAT with transfer descriptors statements, comprise statements program. they that conjunction formatted statements contain field items of associated I/0 You 13 and that 2.4.) statements can reference them. 13.1.1 The FORMAT general k Statement, form of a General FORMAT Form statement follows: FORMAT(SAl,sA2,...,5An/SB1,SB2,...,SBn/...) where Kk SAl = the required statement label (which be referenced by I/O statements). through SAn = individual field descriptor can only sets and SBl through SBn In the foregoing statement form, the individual field descriptors delimited by commas (,). Field descriptor sets and records delimited by slashes (/). For example, a FORMAT statement of form: are are the FORMAT (SA1,SA2/5B1,SB2/5C1,SC2) contains format containing two specifications field Adjacent slashes to be skipped output. For descriptor (//) in during example, a for three records a FORMAT statement specify input or 1s to consist of FORMAT with each record sets. statement FORMAT (SAl1,SA2///SB1,SB2) 13-1 of the that a record an empty record form: 1is on FORMAT STATEMENT specifies four records are to be processed; third records are to be You may represent however, the skipped. repeated field descriptors or second groups and of field descriptors by wusing a repeat form. Indicate the repetition of a single field descriptor by preceding the descriptor with an 1integer constant that specifies how many times the descriptor is to be repeated. For example, a FORMAT statement of the form: ~ FORMAT(SAl,SA2,SA3,SAl,SA2,SA3,SAl,SA2,SA3) - may be written as FORMAT (3 (SAl1,SA2,SA3)) You may nest the repeat forms of field descriptors example, a FORMAT statement of the form: to | any depth For FORMAT (SA1,SA2,SA2,SA3,SA1,SA2,5A2,5A3) may also be written in the form: FORMAT (2 (5A1,25A2,5A3)) The following pafagraphs discuss the fiafiner in whicfi you may use the foregoing statement involved. 13.2 forms and the effect - FORMAT each . has R the data - FORMAT statement descriptors describe Descriptors the record structure of rFw.d | Floating point numeric - field | descriptors R rGw.d riw Integer field descriptor rLw Loglcal field descrlptor } - .Alphanumerlc data rRw kHs descrlotor | } Alphanumerlc data in a FORMAT statement fleld 'text' descriptor } | Field formatting descriptors nP / field | B Numerical scale factorddeSCriptor . Record delimiter the the conversion, The following - Comments rEw.d "rAw » DESCRIPTORS data, the format of fields within the record, and scaling, and editing of data within specific fields. descriptors can be used with FORTRAN-10: o rbw.d on - FORMAT STATEMENT where r = | an optional unsigned integer representing a fepeat- count. This times. W = - option enables a an optional integer number characters of field constant descriptor . - to be repeated SR representing the width contained) of the external r (total form of the field being described. All characters, including digits, decimal points, signs, and blanks that are to comprise the external form of the field, must be included in the value of w. ~ | .d = an optional unsigned integer specifying the number of fractional digits that are to appear 1in ‘the external representation of the field being described. Note that w must be specified if .d is included in the descriptor. k = an unsigned integer be processed during S = represents a string of ASCII (alphanumetic) characters. n a signed integer specifying the number of characters the transfer of alphanumeric data. constant (plus signs are to optional). The characters A, D, E, F, G, H, I, L, O, P, and R indicate the manner of conversion and editing to be performed between the internal (processor) and external representations of the data within a specific field; these <characters are referred to as conversion codes. Table 13-1 gives the FORTRAN-10.conversion codes and a brief description of function of the each. Table 13-1 FORTRAN-10 Conversion Codes Code , Function A ‘D E F G H I L Transfer alphanumeric data Transfer real data with a D exponent(1l) Transfer real data with an E exponent(1) Transfer real data without an exponent Transfer integer, real, complex, or logical Transfer literal data= | ' | Transfer integer data Transfer logical data P R Numerical scaling factor Transfer alphanumeric data ‘1. An exponent of 0 is assumed if none is given. The use Qf commas to delineate specification 'is example, be written optional as format 1long déscriptors ‘within a as no ambiguity - FORMAT (3X,A2) can data as FORMAT (3XA2) format exists. - For 'FORMAT STATEMENT 'Since interpretation of a format specification 'is the spec1flcatlon u 1left associative, 3 FORMAT(IZZ,IS) can be written as | FORMAT(IZZIS)‘" However, a comma is- requlred when you w1sh to specify FORMAT (I2,2I5) The,following paragraphs provide detailed!desoripffonsiof!the various types of format descriptors, the manner in which they are written and employed, and their use in FORMAT statements. 13.2.1 Numeric Fleld Descrlptors The forms of the fleld descrlptors used to conversion of numeric-:-data Description Dw.d Ew.d | o - Ew.d,Ew.d Type of ‘ Data Used For the real and imaginary datum Fw.d Fw.d,Fw.d specify thei format and For Double-precision data with a D exponent Real data with an E exponent - - follow. parts of | a complex - Real or double-precision data without an exponent For the real and imaginary parts of a complex datum o Iw Integer data Gw.d,Gw.d Real or double-precision data For integer (or logical) data For the real and 1mag1nary parts of datum TheG conversion code may‘ béf nsed, for but octal numeric data Examples Consider the following program.segment: INTEGER I1,I2 - REAL R1,R2,R3 DOUBLE PRECISION I1 = 506 R2 = 13.1 R3 = 506001.0 D1 = 13.0 D2 = -504.0 complex | " NOTE all a : D1,D2 12 =8 Rl = 506.0 13-4 types. ' | FORMAT Table 13-2 formatted describes the STATEMENT actions performed by WRITE statements on the data given in the several types of foregoing program segment. » Action of Field Item| Descriptor | Sample Form Descriptor Table 13-2 Descriptors On - WRITE Dw.d Ew.d Fw.d D8 .2 E8.2 F5.2 WRITE(-,-)D1| WRITE(-,-)R1| WRITE(-,-)R2| 7 8 9 10 Gw.d Gw.d Gw.d Gw G8.2 G8.2 G8.2 G5 WRITE(-,-)D2{ | WRITE(-,-)R3| - WRITE(-,-)R2| WRITE(-,-)I1| Iw Iw where: I5 12 a. WRITE(-,-)I1l| WRITE(-,=-)I1l| Data External Statement Using the Sample Descriptor 1 2 3 4 5 Sample Form External of Sample | Appearance Field of Sample Described | Data Z.nnD Z.nnE aa.nn aaaan an nn | 0.18D+02 nn| 0.51E+03 18.10 BpB506 ko Z.nnD nn| Z.nnE nn| aa.nn aaan -.50D+02 0.51E+06 »prBle.lo PPB506 n represents a numeric character. b. 2 representsAeither a - or 0. (Note that if‘ n-d>6, T a negative number c. a represents a digit, leading blank (%)'or sign depending on cannot the be output.) numeric output. a minus‘ Notes: 1. 2. 3. In Item 1,'the value D1 has only two significant digits In Item 2, since R1 has 3 signifiéant'digité, it is In Item 5, the descriptor transfer was not made. In 8 and 9, the relationship between G and fixed real data is discussed in Paragraph 13.2.3. d=2, to so no fit rounding will into specifies the occur on input. specified field. width (w) part of a format and rounded an exact field that permits no rounding of its If the w specification is too small for the datum contents. to be transferred, asterisks are output to indicate that the Items floating and In Items 1, 2, 3, 7, and 8, the D and E exponent prefixes are optional. 1in the external form of the floating point constants. For example, 1.1lE+3 may be written as 1.1+3. external Table 13-3 summarizes the internal and specified by the numeric format conversion. code. 13-5 forms of the data FORMAT STATEMENT Table 13-3 Numeric Field Internal Form Codes Conversion | Code External 1 Form | Binary floating—point D Binaryfloatihg—point E Decimal floating-point with E F Decimal I Decimal integer double-precision - a ~ Binary floating-point Binary integer | - " One of the following: single-precision ~ binary floating-point, ~ binary integer, binary logical, or binary complex , | | | G | | ) | Decimal floating-point with D exponent - - exponent fixed-point | Single-precision decimal floating-point, decimal | ~integer, logical (T or F), or | complex (two decimal » | floating-point numbers), depending upon the internal form Complex quantities transfer as two independent real gquantities. The format specification for complex quantities consists of either two successive real field descriptors or one repeated real field descriptor. For example, the_statement FORMAT (2E15.4,2(F8.3,F8.5)) may transfer up to three cbmplex quantities. The equivalent of the_foregoing,stétement isFORMAT (E15.4,E15.4,F8.3,F8.5,F8.3,F8.5) 13.2.2 Interaction of Field Descriptors With I/0 Variables The execution of an I/0 statement that specifies a formatted data transfer operation initiates format control.The actions performed by format control depend on information provided by the elements of the I/0 statement's 1list of variables and the field descriptors that comprise the referenced FORMAT statement's format specifications. In processing each FORMAT controlled I/0 statement that has an I/O list, FORTRAN-10 scans the contents of the 1list and the format specifications in step. Each time another variable or array element name 1is obtained from the 1list, the next field specification is obtained from the format specification. If the end of the format specification is reached and more items remain in the list, a new line or record is established and the scan process is restarted, either at the first item in the format specification or, if parenthesized, sets of format specifications exist within the format specification, with the last set within the format specification. 13-6 FORMAT When the control proceeds to the next statement is exhausted, I/O list STATEMENT the program, but not before the FORMAT statement is scanned either in (That to "its end or to the next variable transfer format descriptor. FORMAT statement is scanned past slashes, literal constants, the is, past not but descriptors, Hollerith field descriptors, and spacing data field A record descriptors.) is terminated by one of the following: in the FORMAT specification 1. a slash 2. the delimiting 3. a lack of 4. a lack of Hollerith FORMAT right parentheses, items in the ), of the FORMAT statement I/O list or 1literal field descriptors 1in the statement On input, an additional record is read only when a single slash, /, is A record is skipped when two statement. FORMAT the in encountered the slashes, //, are encountered or a slash is followed by the end of a statement finishes a record by FORMAT the If statement. FORMAT 1input the slash or the end of the FORMAT statement, any data left in If the input record is exhausted before the data ignored. is record transfers are completed, the remainder of the transfer is completed as if the record were extended with blanks. On output, an additional record is written only when a encountered 1in the FORMAT statement. If a pair slashes, //, or a single slash followed by the end statement is encountered, an empty record is written. 13.2.3 G, slash, /, 1is of consecutive of the FORMAT General Numeric Conversion Code You may use the G conversion code in field descriptors for the format control of real, double-precision, integer, logical, or complex data. With the exception of real and double-precision data, the type of conversion performed by a type G field descriptor depends on the type of its corresponding I/0 list variable. In the case of real and double-precision data, the kind of conversion performed is a function of the external magnitude of the datum being transferred. Table 13-4 illustrates the conversion performed for various ranges of magnitude (external form) of real and double-precision data. 13.2.4 Numeric Fields with Scale You may add scale factors to D, descriptors. The scale factor Factors E, has F, the and G conversion codes in form field npP where n is a signed integer (+ 1is optional) and P identifies the operation. When used, a scale factor is added as a prefix to field descriptors. 13-7 FORMAT STATEMENT Examples -2PF10.5 1PE8.2 When you add a scale factor to an type F field descriptor (or type if the external field 1is a fixed point decimal) a power of 10 specified so External that Form of Number = (Internal Form)*10**(scale For example, assuming the data involwed to be the the field descriptor factor) real number 26.451, F8.3 produces the external field BrY26.451 Table Descriptor 13-4 Conversion of Real and Double-Precision Data According to Magnitude Magnitude of Data in External Form (M) - Equivalent Method of Conversion Performed 0.1 M<l] 1 M<10 F(w=-4) .d,4X F(w-4).(d-1) ,4X 10d-2 M<104-1 10d-1 M<10d ALL OTHERS F(w=-4).1,4X F(w-4) .0,4X Ew.d NOTE In all numeric field conversions, the field width (w) vyou specify should be large enough to include the decimal point, sign, and exponent character in addition to the number of digits. If the specified width 1is too small to accommodate the converted number, the field will be filled with asterisks (*). If the number converted occupies fewer character positions than specified by w, it will be right-justified in the field and leading blanks will be used to fill the field. 13-8 G is FORMAT STATEMENT The addition of the scale factor of -1P -1PF8.3 produces the external field BBB2.645 When you add a scale factor to D, E, and G (external field not a decimal fixed-point) type field descriptors, it multiplies the number by the specified power of ten and the exponent is changed accordingly. In input operations, type F (and type G, if the external field 1is decimal fixed-point) conversions are the only ones affected by scale factors. Once zero. Wwhen you specify no scale factor, it is understood to be you specify a scale factor, however, it holds for all subsequent types specification D, E, F, and G field descriptors within the same format unless another scale factor is specified. A scale factor 1s reset to zero when you specify a scale factor of zero. effect on I and O type field descriptors. Scale factors When you add a scale factor to a D or E field descriptor, a power of 10 so that the external form of the number has multiplied by the specified power of 10; its exponent have no it specifies its mantissa 1is adjusted accordingly. For example, the field assuming the data involved to be the real number 12.493, the number of significant digits printed descriptor E11.3 produces the external field BP0 .125E+02 the addition of The scale factor 2P 2PE11.3 produces the external field bbl2.49E+00 With a scale factor of by a format of the zero, form Ew.d or Dw.d is the number of digits to the right of the decimal point. For a negative scale factor nP, for d<n<0, there will be ABS(n) leading zeros and d-ABS(n) significant digits after the decimal point, for a total of d digits after the decimal point. If n -d, there will be d insignificant digits (zeros) to the right of the decimal point. 1f the scale factor nP is positive, for 0<n<d+2 significant digits to the 1left of the decimal significant digits to the right of the decimal point 13-9 there point (for a will be n and d-n+l total of FORMAT d+1 significant digits and decimal digits). n-d-1 If insignificant STATEMENT n>d+2, trailing there will be d+1 significant zeros on the 1left of the point. "If the data to be printed is 12.493, these formats produce results as follows: FORMAT OUTPUT SIGNIFICANT REASON DIGITS E15.3 1PE15.3 -1PE15.3 2PE15.3 -3PE15.3 bbbbbb0.125E+02 bbbbbbl.249E+01 bbbbbb.012E+03 bbbbbbl2.49E+00 bbbbbb0.000E+05 4PE15.3 6PE15.3 13.2.5 Logical 3 4 3 4 0 bbbbbbl1249.E-02 bbbb124900.E-04 Field 4 4 n=0 n<d+2 -d<n n<d+2 n -d n<d+2 n d+2 Descriptors You may transfer logical to numeric data transfer data under format control in a manner by use of the field descriptor similar Lw where L is the control character and w is an 1integer field width. The data is transmitted as the value of logical variable in the associated input/output list. specifying the a corresponding On input, the first non-blank character in the logical data field must be T or F, the value of the logical variable is stored in the list variable as true or false, respectively. If the entire 1input data field is blank or empty, a value of false is stored. On output, w minus 1 blanks followed by T or F will be output value of the logical variable is true or false, respectively. 13.2.6 Variable Numeric 1f the Field Widths Several of the conversion codes are acceptable without field width specifications, the specification so that can be omitted(l). 1in FORMAT statements w.d portion of the On input, the conversion codes D, E, F, G, I, L, and O are acceptable without field width specifications. The field begins with the first non-blank character encountered and ends with the first 1illegal character in the given field. (Blanks and tabs also terminate a field.) Note that for conversion code L (logical data), all consecutive alphabetics following a T (true) or an F (false) are considered part of the field and are ignored. In succeeding fields the input stream is scanned until a non-blank character 1is encountered. If the character is a comma (,), the next field 1is skipped, and the following input field begins with the character following the comma. Any character other than a comma is assumed to be the first character in the next input field. Null fields are l. If d is given, w must also be specified. 13-10 FORMAT STATEMENT denoted by successive commas optionally separated by blanks or tabs. For to a fixed-field input of blanks. equivalent 1s field null A 1l source the example, code READ 1, X, Y, Z2, L, I, FORMAT (3F, L, I, A3) follows as with data d ,l.OE+5,,TRUEXXXlfibfihABC in results X Y z =0.0 = 1.0E+5 = 0.0 L = I =1 J = TRUE 'ABC' Note that if a comma is included in the input data after the XXX1 | pbefore the blanks, i.e., the data is ,, TRUEXXX1 , BBBPBABC ,1.0E+5 then J = 'Bpp’ On output, the format codes A, D, E, F, G, acceptable without field width specifications. are and I, L, O, and R are The following defaults assumed: Format Code A A D E F G G I L O R R 13.2.7 single-precision double-precision single-precision double-precision single-precision double-precision Assumed Default for KAlO A5 for KI10,KL1O A5 AlO0 D25.18 E15.7 F15.7 Gl15.7 G25.18 I15 L15 015 R5 R10 Al0 D25.16 E15.7 F15.7 Gl5.7 G25.16 I15 L15 015 R5 R10 Alphanumeric Field Descriptors You may accomplish the formatted transfer of alphanumeric data 1in a manner similar to the formatted transfer of numeric data by use of the field descriptors Aw and Rw, where A and R are the control characters and w is the number of characters in the field. The A and R descriptors both transfer alphanumeric data into or from a A input/output list depending on the I/O operation. an in variable list variable may be of any type. READ 5 (6,5) FORMAT For V (A4) 13-11 example, . FORMAT STATEMENT causes four alphanumeric characters to be read from unit6 and stored » ' S in the variable V. The A descriptor deals with wvariables containing left-justified, blank-filled characters; the R descriptor deals with variables containing right-justified, =zero-filled <characters. The following paragraphs summarize the result of alphanumeric data transfer (both internal and external representations) using the A and R descriptors. These paragraphs assume that w represents the field width and m represents the total number of characters possible in - the wvariable. Double ©precision variables contain 10 characters (m=10); all other variables contain 5 (m=5). | A Descriptor 1. INPUT, where w>m -- The rightmost m characters of the field are read in and stored left-justified and blank-filled in the associated variable. 2. INPUT, where w < m -- All w characters are read in and stored left-justified and blank-filled in the associated variable. 3. OUTPUT, | where w>m right-justified blank-filled. 4. in OUTPUT, where w < m associated variable -~ -- the m characters field. The -- The left are output. are remainder most | w output of the field <characters of | I and 1is the R Descriptor 1. 1INPUT, where w>m -- TheAright most m characters of the field ‘are read in associated and stored right-justified, 2. INPUT, where w < right-justified, 3. OUTPUT, where w>m —justified 1in the m characters field. The Transferring of o -- The right most are output. Alphanumeric are remainder | OUTPUT, where w < m associated variable 13.2.8 w ' - output and the field o , characters right is blank of the Data You may transmit alphanumeric data directly into or ’ in the m -- All w characters are read in and stored zero-filled in the associated wvariable. filled. 4. zero-filled variable. di ' from rsion, the FORMAT In H-conversion, the alphanumeric string is specified in the form nH, where H 1is the control character and n 1is the total number of characters (including blanks) in the string. For example, you may use the - following statement sequence to print the words PROGRAM COMPLETE on the device | LPT: PRINT 101 FORMAT ' | 101 (17HPPROGRAMBCOMPLETE) 13-12 : | - | . . FORMAT STATEMENT Read and write operations of this type are initiated by I/O statements a reference that format statement and a logical device, but do not ‘contain an I/O list (see preceding example). Write transfers from a FORMAT statement cause of the contents the statement field descriptor to be output to a specified logical device. The contents of the field descriptor, however, remain unchanged. Read transfers with a FORMAT statement cause the contents of the field to be replaced by the characters input from the involved descriptors specified logical device. If -justified. Alphanumeric data is stored in a field descriptor 1eft field has fewer characters than the field, into a input the data If the data trailing blanks are added to fill the field. the excess field of the descriptor, than the larger characters input | lost. are 1s' rightmost Examples WRITE 101 FORMAT (1,101) (17HMPROGRAMMCOMPLETE) | cause the strlng PROGRAM COMPLETE to be output to the file l. Assuming the string START on device 1, the sequence READ (1,101) 101 FORMAT (17HYPROGRAMPCOMPLETE) WOuld,change the contents of statement 101 to in 101 FORMAT (17HSTARTbeMMMbwb%Mb) 101 FORMAT (17HPPROGRAMPYCOMPLETE) the same manner. - 13-13 on device FORMAT 13.2.9 Mixed You may place the format. output an For FORMAT to Numeric and STATEMENT Alphanumeric alphanumeric field example, may you Fields descriptor use the among other fields of statement: (I4,7HPFORCE=F10.5) the line: BB22BFORCE=pBY17.68901 You as may omit the separating comma after shown in the foregoing statement. an alphanumeric format field, When you omit a comma delimiter from a format specification, format control associates as much information as possible with the leftmost of the two field descriptors. 13.2.10 Multiple To handle different For a group field example, FORMAT is the FORMAT the Specifications of input/output records where descriptors, use a slash to statement to (3083) first FORMAT record, and (I5,2F8.4) for the second You may omit record. separating commas appear at the end written on output or middle records of a format, n-1 skipped on input. Both the different records have indicate a new record. (308/15,2F8.4) equivalent for Record slash and or skipped the when beginning on a use a slash. format, input. blank closing you of When records are parenthesis at n n When blank slashes written the end n slashes records will appear in on output of the be the or n-1 format indicate the termination of a record. If the list of an input/output statement dictates that the transmission of data is to continue after the closing parenthesis of the format 1is reached, the format is repeated, 1. starting that with: group repeat parenthesis 2. level zero of if no Thus, the statement FORMAT level specification the lower level group, higher level group exists. | (F7.2,(2(E15.5,E15.4),17)) 0 level level 1 level level terminated next 1 2 13-14 0 by or the last right FORMAT causes STATEMENT format the ,17 2(E15.5,E15.4) to be used As a The after the first record. further example, FORMAT (F7.2/(2(E15.5,E15.4) ,17)) first record has consider the the statement format F7.2 ‘and the next 5 records havéthe format 2(E15.5,E15.4) ,1I7 13.2.11 Record Formatting You may use two a Field Descriptors field descriptors, record. 13-15 and nX, to position data within FORMAT STATEMENT Examplé statement The FORMAT (5HPSTEP,I5,10X,2HY=,F7.3) may be used to print the line | STEPYBB2 SBBBRBRBPBY=F-3.872 13.2.12 $ Format Descriptor A $ format descriptor at the end of an output FORMAT is wused to suppress the carriage return at the end of the current record. It is mainly used on terminal output but will work on non-terminal devices. A $ format descriptor is ignored in input FORMATs and has no effect if embedded in an output FORMAT. The $ format descriptor must be the next format descriptor to be processed when the corresponding output list is exhausted for the $ descriptor to have the defined effect. '13.3 CARRIAGE CONTROL CHARACTERS FOR PRINTING ASCII RECORDS You may use the first character of an ASCII record to control the spacing operations of the line printer or Teletype terminal printer unit on which the character desired ASCII record to be character. Table FORTRAN-10 and the record 1is being printed. Specify the control by beginning the FORMAT field specification for the output with lHa...where a is the desired control 13-5 describes the control characters permitted in effect each has on the printing device. 13-16 FORMAT STATEMENT Table 13-5 FORTRAN-10 Print Control CharaCters Effect FORTRAN Character | Printer Character | Octal Value space 0 zero l.one | LF 012 Skip to next LF,LF 012 Skip a line 014 Form feed - go FF | to top of next page - Suppress + plus skipping overprint the line 13-17 " CHAPTER 14 DEVICE CONTROL STATEMENTS 14.1 INTRODUCTION You may use the following device control statements in FORTRAN-10 programs: source l. REWIND 3. BACKSPACE (1) 4. ENDFILE The general form of the foregoing device control statements is keyword keyword u (u) where keyword u is the statement is the Table FORTRAN-10 name logical device number (Chapter The operations performed by the device control statement are used only for magnetic tape devices (MTA). In FORTRAN-10, the device control operations are simulated for disk devices. The following paragraphs describe the control 14.2 10, 10-1) form and use of the u to its normally however, device statements. REWIND - STATEMENT Form: REWIND Use: Move the file contained by (load) point, u ©point. this If the statement has device medium no is already at effect. initial its load Subsequent 1. The results of these commands are unprédictable when used on directed and NAMELIST-controlled data. 14-1 READ 1list- DEVICE or WRITE CONTROL statements transfer data to the medium mounted Example: 14.4 BACKSPACE REWIND STATEMENTS that reference or from the on device u. first device record u will located on 16 STATEMENT Form: BACKSPACE u Use: Move the medium the record contained that on device precedes the u to the start current record. If of the preceding record prior to execution of this statement was an endfile record, the endfile record becomes the next record after execution. If the current record 1is the first record of the file, this statement has no effect. NOTE You cannot use this statement for files; set up for random access, list-directed, or NAMELIST-controlled I/0 operations. Example: 14.5 BACKSPACE 16 - END FILE STATEMENT Form: END Use: Write FILE u an endfile record in the file located on device u. The endfile record defines the end of the file that contains it. If an endfile record is reached during an I/0 operation initiated by a statement that does not contain an END= option, the operation of the current program is terminated. Example: END FILE 16 14-2 | DEVICE CONTROL STATEMENTS 14.9 SUMMARY OF DEVICE CONTROL STATEMENTS Table 14-1 summarizes the control form and statements 14-3 use of the FORTRAN-10 device DEVICE Summary of Statement REWIND Table 14-1 | medium to its Move medium back one 14-4 load - Statements Use Rewind u STATEMENTS FORTRAN-10 Device Control Form u BACKSPACE CONTROL point record CHAPTER SUBPROGRAM 15.1 15 STATEMENTS INTRODUCTION Procedures you use repeatedly in a program may be written once and then referenced each time you need the procedure. Procedures that may be referenced are either internal (written and contained within the program in which they are referenced) or external (self-contained executable procedures that may be compiled separately). The kinds of FORTRAN-10 procedures that may be referenced are: 1. statement functions, 2. intrinsic functions 3. external functions, 4. subroutines. (FORTRAN-10 defined functions), and The first three collectively as last category are of the foregoing categories are referred to functions or function procedures; ©procedures of the referred to as subroutines or subroutine procedures. 15.1.1 Actual Dummy and Arguments Since you may reference subprograms at more than one point throughout a program, many of the values used by the subprogram may be changed each time it is used. Dummy arguments in subprograms represent the actual is wvalues Functions the to be used, which are passed to the subprogram when it called. and actual subroutines arguments use they dummy arguments to represent and whether indicate the the actual type of arguments are variables, array elements, arrays, subroutine names, or the names of external functions. Each dummy argument must be used within a function or subroutine as if it were a variable, array, array element, subroutine, or external function 1identifier. Dummy arguments are given in an argument list associated with the identifier assigned to the subprogram; actual arguments are normally given in an argument list associated with a call made to the desired subprogram. (Examples of argument lists are given in the following paragraphs.) The position, number, and type of each dummy list must agree with the position, number, list of the subprogram reference. 15-1 argument and type in of a subprogram each argument SUBPROGRAM STATEMENTS Dummy arguments may be: 1. wvariables, 2. array 3. subroutine'identifiers, 4, function names, identifiers, or When you reference a subprogram, related given its dummy arguments are replaced the corresponding actual arguments supplied in the reference. appearances of a dummy argument within a function or subroutine to the actual arguments. Except for by All are subroutine identifiers and literal constants, a valid association between dummy and actual arguments occurs only 1if both ~are of the same type; otherwise, the results of the subprogram computations will - be unpredictable. Argument association may be carried through more than one level of subprogram reference if a valid association is maintained through each level. The dummy/actual argument associations established when a subprogram is referenced are desired subprogram operations are terminated completed. when .the = The following rules govern the use and form of dummy arguments: 1. 2. The number and type of the dummy must be arguments A variable dummy argument element identifier, an (o) the a should have expression, corresponding representing a subroutine name as A dummy argument or a or wvariable, an a constant array as 1its name Or external its representing function as elements of subroutine the actual identifier array. should actual argument. an external function must 1its actual have argument. ~ A dummy argument may be defined or redefined in a referenced subprogram. only if 1its corresponding actual argument is a variable. If dummy arguments are array names, then elements of Additional given actual argument. A dummy argument an is procedure an array element identifier as its corresponding actual argument. If the actual argument is an array, the length of the dummy array should be less than or equal to that of the actual array. Each element of a dummy array 1is associated have 7. of a type of the referenced. An array dummy argument should have either an array directly with 5. arguments number and procedure is statements. corresponding 4. as the time the Dummy argument names may not appear 1in EQUIVALENCE, DATA, COMMON 3. the same given each the array may information 1in the be redefined. regarding description the of referenced. use how : of dummy - 15-2 and subprograms actual arguments - o are defined and STATEMENTS SUBPROGRAM 15.2 STATEMENT Statement statement. FUNCTIONS functions define The general form an of a internal statement subprogram 1in function is: a single name (argl,arg2,...,argn)=E where name is a name you characters. rules for assign that consists of one to The name you use must conform to symbolic names given in Section six the 3.3. The type of a statement function 1is determined either by the first character of its name or by it being explicitly declared in a type statement. The (argl...argn) represents E is expression E of an a a list arbitrary statement of dummy arguments. expression. function may be any legitimate arithmetic expression that may wuse the given dummy arguments and indicates how they are combined to obtain the desired value. You may use the dummy arguments as variables or indirect function references; but you cannot use them as arrays. The dummy argument names bear no relation to their use outside the context of the statement function except for their data type. The expression may reference FORTRAN-10 defined functions (Paragraph 15.3) or any other defined statement function, or call an external function. It may not reference any function that directly or indirectly references the given statement function or any subprogram in the <chain of references. That 1is, recursive references are not allowed. Statement functions produce only one value, the result of the expression that it contains. A statement function cannot reference itself. You the must define all statement functions within a program unit before first executable statement of the program unit. When used, the statement function name must be followed enclosed within parentheses and may logical expression. by an appear actual argument 1list in any arithmetic or Examples: SSOR (K )= (K* (K+1) *2*K+1) /6 ACOSH (X) = (EXP (X/A)+EXP(-X/A)) /2.0 15.3 INTRINSIC FUNCTIONS (FORTRAN-10 DEFINED FUNCTIONS) Intrinsic functions are subprograms that are defined and supplied by FORTRAN-10. You can reference an intrinsic function by using its assigned name as an operand in an arithmetic or 1logical expression. Table 15-1 describes the names of the FORTRAN-10 intrinsic functions, the type performs. they are of the arguments These preceded names by an that each accepts, always refer to asterisk (*) or the ampersand statement, declared 1in a conflicting explicit specified as a routine dummy parameter. 15-3 and the intrinsic (&) type function function in an it unless EXTERNAL statement, or are -SUBPROGRAM,STATEMENTS | |bie] > , UIx BUT SUOTIOUNTUOOTINPue OTY+ATuO Uaym2y3uoTr3ounyg- 1230 pT9ASR3osU3JRIqSeuDUnOQDwou3OToeSnu3U0dTjo3Ieoun1UyTr 15-4 :UNuUoTrITX3EeYOUN:19gNRA 3sabaeT13bajutr [ead03XoTdwo*xXTdWDbiayg=0+bi¥xTZ1esyXo1duwo) |bae| > | °(32ed 19BLOTT--NSVTILY(O*d3)u0)pauriad(suoT3oung SUBPROGRAM STATEMENTS Auiteu3tqbeowOt)r 15-5 :butaopuUT2WaY SUBPROGRAM STATEMENTS 15-6 SUBPROGRAM 15.4 EXTERNAL External STATEMENTS FUNCTIONS functions are function subprograms that consist of a FUNCTION statement followed by a sequence of FORTRAN-10 statements that define one or more desired operations; subprograms of this type may contain one or more RETURN statements and must be terminated by an END be Function subprograms are independent programs that may statement. programs. referenced by other The FUNCTION statement that identifies an external function has the specification as form: type FUNCTION name (argl,arg2,...,argn) where type is an described INTEGER, optional type 1in Section REAL, DOUBLE 6.3. These PRECISION, 1include COMPLEX or LOGICAL (plus the optional size modifier, *n, for compatibility with other manufacturers.) name is the name you assign to the function. The name may consist of from one to six characters, the first of which must be alphabetic. You may include the optional size modifier (*n) with the name 1if the type is specified. (Refer to Section 6.3.) (argl,...,argn) is a list of dummy arguments. If you omit type in the FUNCTION statement, the type of the function may be assigned, by default, according to the first character of its name, or may be specified by an IMPLICIT statement or by an explicit statement given with the subprogram itself. Note that if you want to use the same name for a user-defined function as the name of a FORTRAN-10 defined function (library basic external function), the desired name must be declared in an EXTERNAL statement and prefixed by an asterisk (*) or ampersand (&) in the referencing routine. (Refer to Section 6.7 for a description of the EXTERNAL statement.) The following 1. rules govern the structuring of a FUNCTION subprogram: You must use the symbolic name assigned a FUNCTION subprogram as a variable name in the subprogram. During each execution of the subprogram, this variable must be defined and, once defined, may be referenced or redefined. The value of the variable at the time of execution on any RETURN statement is the value of the subprogram. NOTE A RETURN statement returns control to the calling statement that initiated the execution of the subprogram. See Section 15.6 for a description of this statement. 15-7 SUBPROGRAM 2. You may not use the any nonexecutable initial 3. FUNCTION symbolic name of statement in the statement Dummy argument names COMMON, or DATA STATEMENTS may statement or a not used a FUNCTION subprogram in subprogram except in the type statement. appear within 1in the any EQUIVALENCE, subprogram. 4. The function subprogram may define or redefine one or more of its arguments so as to effectively return results in addition to the value of the function. 5. The function subprogram may contain any FORTRAN-10 statement except BLOCK DATA, SUBROUTINE PROGRAM, another FUNCTION statement, or any statement that directly or indirectly references the function being defined or any subprogram in the chain of subprograms leading to this function. 6. The function subprogram should contain at least one RETURN statement and must be terminated by an END statement. The RETURN statement signifies a 1logical <conclusion of the computation made by the subprogram and returns the computed function wvalue and control to the <calling program. A subprogram may have more than one RETURN statement. The END statement specifies the subprogram and implies a return. 15.4.1 Basic External FORTRAN-10 contains Functions name, and functions (FORTRAN-10 Defined a group of predefined called basic functions. Table physical external end of the Functions) that are 15-2 describes each basic function, 1its its use. These names always refer unless declared in an EXTERNAL or functions to the basic external conflicting explicit type statement. 15.4.2 Generic Function Names The compiler generates a call to function, depending on the type of generic function names: ABS AMAX1 AMIN1 ATAN ATAN2 COS INT MOD SIGN SIN SQRT EXP ALOG ALOG10 In the following example K=ABS (I) 15-8 the the proper FORTRAN-10 defined arguments, for the following SUBPROGRAM STATEMENTS the type of I dete.mines which function integer, the compiler generates a call to real, the compiler generates a call to the double precision, the compiler generates a is called. If I 1is an the function IABS. If I is function ABS. If I 1is call to the function DABS. The function name loses its generic properties if it appears 1in an explicit type statement, if it 1is specified as a dummy routine parameter, or if it 1is prefixed by "*" or "&" in an EXTERNAL statement. When a generic function name that was specified unprefixed in an EXTERNAL statement 1s used as a routine parameter, it is assumed to reference a FORTRAN-10 defined function of the same name, or if none exists, a user-defined function. Note that IMPLICIT statements have no effect upon name has been removed 15.5 A by SUBROUTINE subroutine a 1is data from type its of generic class by use function of an names EXTERNAL unless the statement. SUBPROGRAMS an SUBROUTINE calling program. subprogram of this SUBROUTINE the external computational statement The type and may or procedure may not SUBROUTINE statement has the form: that return wused to is identified values to tne identify a name (argl,arg2,...,argn) where name is the symbolic defined. (argl,...,argn) is an optional 15-9 name list of of the dummy subroutine arguments. to be twy3TIebor o1seg OT-NTILIOI)paurTIad (suotT3doung SUBPROGRAM STATEMENTS 3i0:1enybg 15-10 :9UTS 1D10yq13jduAsHbu01el: a21V1d1dUgwTQnoSUo)ITdSgXO30D(suetpea)fNSSHeOI0NlJeOSDIl¢VSY!ss(oboagye()gbu)(abtyxyiuy)srges)1IIT11TTd2ge9wn3oo4y)g9X291TT1gdeEqwasen9oyoY)gX29 $9UTSO0) SUBPROGRAM STATEMENTS o1sed 15-11 *TN1(ueVbsaIj3yeL)Y SUBPROGRAM STATEMENTS 10 15-12 Xo1d0wo) SUBPROGRAM STATEMENTS The following subprogram: 1. rules control You may not use the statement within the statement itself. 2; the structuring | ~ of symbolic name of the defined a subroutine - subprogram subprogram except the You may not use the given dummy arguments in an 'COMMON, 3. The of 4. or DATA statement within the EQUIVALENCE, subprogram. subroutine subprogram may define or redefine one or arguments so as to effectively return results. Dummy arguments 6. *, The and S, or statements represent should contain by terminated indicate the END subroutine. 7. that | the labels may be (see description end of signifies the | of have ENTRY as a computational physical end of the entry points as many statement given in Section 15.7). ‘ Referencing Subroutines You must reference subroutine the following form: CALL | (CALL Statement) subprograms by using a CALL statement of name (argl,arg2,...,argn) | name elther at least one RETURN statement an END statement. The RETURN 1logical statement Subroutine subprograms may desired statement &. subprogram must be routine; | o | ~ (argl,...,argn) | is the " The use of agreement in symbolic subroutine is an name subprogram. the optional list 1is type with the CALL l. a constant 2. a variable statement the | desired in order, number, and corresponding dummy arguments in the defining SUBROUTINE statement. literal constants is an exception to of type between dummy and actual a of list of actual arguments. If included, the given actual arguments must agree given argument more its an ‘where any The subroutine subprogram may contain any FORTRAN-10 statement except BLOCK DATA, FUNCTION, another SUBROUTINE statement, or any statement that elther directly or indirectly references the subroutine being defined or any of the subprograms in the chain of subprogram references leading to this subroutine. 5. 15.5.1 in SUBROUTINE may be: name 15-13 the rule arguments. | - requiring An actual SUBPROGRAM STATEMENTS 3. an array element identifier 4. an 5. .an expression 6. the name of an external subroutine, or array name "Example: The subroutine SUBROUTINE MATRIX(I,J,K,M, END may be by referenced CALL MATRIX(10,20,30,40 15.5.2 FORTRAN-10 Supplied Subroutines FORTRAN-10 provides Table subroutines. predefined 15.6 predefined vyou with an extensive group of 15-3 gives the descriptions and names of these subroutines. S o | - = RETURN STATEMENT AND MULTIPLE RETURNS - The RETURN statement causes control to be returned from a This statement has the form: to the calling program unit. RETURN subprogram (standérd return)‘ or The (i.e., standard return) causes control to be returned to the statement of the "calling program that follows the statement that called the subprogram. 15-14 SUBPROGRAM You may use any number of RETURN STATEMENTS (standard return) statements Example Assume the following CALL ?O TO statement sequence EXAMP (1 101 105........... ........... 20 f.;...;..... 15-15 in a main program: in any SUBPROGRAM STATEMENTS Assume the following statement sequence in the called SUBROUTINE subprogram: SUBROUTINE EXAMP (L, *,M, *,N,¥*) RETURN ~ RETURN END Each occurrence of RETURN returns control in the 15.6.1 calling program. Referencing External FUNCTION to the statement GO TO 101 Subprogram Reference an external function subprogram by using its assigned name as an operand 1in an arithmetic or logical expression in the calling program unit. The name must be followed by an actual argument 1list. The actual arguments in an external function reference may be: l. a variable name, 2. an array element 3. an array 4 an expression, identifier, name, 15-16 SUBPROGRAM 6. the name of another STATEMENTS external procedure SUBROUTINE) . NOTE Any subprogram name to be used as an must subprogram another to argument first appear in an EXTERNAL statement (Chapter 6) in the calling program unit. Example The subprogram defined INTEGER FUNCTION as: ICALC(IX,IY,IZ) RETURN END may be referenced in the following manner: TOTAL=ICALC (IAA,IAB,IAC)+500 - 15-17 FUNCTION or SUBPROGRAM STATEMENTS 15-18 SUBPROGRAM STATEMENTS 15-19 SUBPROGRAM STATEMENTS. 15-20 SUBPROGRAM STATEMENTS 15-21 SUBPROGRAM STATEMENTS 15-22 SUBPROGRAM STATEMENTS 15-23 SUBPROGRAM STATEMENTS 15-24 SUBPROGRAM STATEMENTS 15-25 CHAPTER 16.1 SUBPROGRAMS DATA BLOCK 16 INTRODUCTION Use block data subprograms to initialize data to be stored 1in any common areas. You may use only specification and DATA statements, i.e., DATA, COMMON, DIMENSION, EQUIVALENCE, and TYPE, in BLOCK DATA subprograms. A subprogram of this type must start with a BLOCK DATA statement. You may enter in a single initial values subprogram of into more than one labeled this An executable program may contain 16.2 The BLOCK DATA form of the BLOCK DATA common block type. more than one block data subprogram. STATEMENT BLOCK DATA statement 1is: name where name is a symbolic name subprogram. 16-1 given to identify the APPENDIX ASCII-1968 character Ist 2 octal code set CHARACTER defined National Standard for the following matrix. 1in the CODE SET X3.4-1968 Information Version Interchange of the (ASCII) is Last octal digit 0 1 2 3 4 5 6 7 DLE DC1 DC2 DC3 DC4 NAK SYN ETB subsets 03x > Z ESC FS GS RS US 64 (ESC) 3 Characters inside parentheses are ASCII-1963 Standard. NUL Null DLE Data Link Escape SOH Start of Heading DC1 Device Control 1 STX Start of Text DC2 Device Control 2 ETX End of Text DC3 Device Control 3 EOT End of Transmission DC4 Device Control 4 ENQ Enquiry NAK Negative Acknowledge ACK Acknowledge SYN Synchronous Idle BEL Bell ETB End of Transmission Block BS Backspace CAN Cancel HT Horizontal Tabulation EM End of Medium LF Line Feed SUB Substitute VT Vertical Tabulation ESC Escape FF Form Feed FS File Separator CR Carriage Return GS Group Separator SO Shift Out RS Record Separator SI Shift In US Unit Separator DEL Delete (Rubout) (<) o € © m| + w Z2TV O - N’ <3 16x 17x ! 15x g 13x 14x —_—c 11x 12x —,—a O AR 10x O RO 07x ~— 06x * 05x o 04x SUB R0 02x TM ~~ > SI RN BEL SO 0o —cZmil v ACK CR =] ENQ FF H EOT VT N e ETX LF OTM O = - o3| < STX HT = SOH BS <O NUL Olx TR 00x o XTI E ©®O digits X T The American given in A Graphic 95 APPENDIX USING THE B COMPILER This appendix explains how to access FORTRAN-10 and how to make use of the information 1t provides. You should be familiar with the FORTRAN-10 language and the DECsystem-10 TOPS-10 monitor. B.1l RUNNING The command .R THE to COMPILER run FORTRAN-10 is: FORTRA The compiler responds with an asterisk (*) and a command string. A command is of the general object filename, You are given the filename=source filename (s) following options: 1. The 2. You may specify more than one input file in the compilation command string. These files will be logically concatenated by the compiler and treated as one source file. 3. filenames can be fully specified SFD paths. Program units need not be terminated at file may consist of more 4. than one If no object filename file is is file. specified, no boundaries relocatable and binary generated. 5. If no listing 6. If no extension is given, the defaults are .LST .REL (relocatable binary), and .FOR (source) respective B.l.1l listing is then ready to accept form: filename is specified, no listing 1is generated. (listing), for their files. Switches Available with FORTRAN-10 Switches to FORTRAN-10 are accepted anywhere in the command string. They are totally position- and file-independent. Table B-1 lists the switches. USING THE Table COMPILER B-1 FORTRAN-10 Compiler Switches Defaults Meaning Switch Generates a file that can be input to CROSSREF the CREF OFF (See Section B.l.1l.1l.) DEBUG OFF program Includes the octal-formatted version of| OFF EXPAND the object file in the listing. Compiles a D in card column 1 as INCLUDE as Compiles code to run on a KAlQ KA10 processor. Compiles code to run on a KI1O0 KI10 LNMAP OFF space. Compilation processor Compilation pProcessor. processor Produces a line number/octal location OFF map in the listing only if /MACROCODE was not specified. MACROCODE Adds the mnemonic translation of the OFF NOERRORS Does not print error messages OFF NOWARNINGS Does not output warning messages. OFF OPTIMIZE Performs global optimization. OFF SYNTAX Performs syntax check only. OFF object code to the listing file. on the terminal. Switch names need only Each switch must be preceded by a slash (/). contain those 1letters that are required to make the switch name unique. You are encouraged to use at least three letters to prevent conflict with switches in future implementations. Example .R FORTRA *OFILE,LFILE=SFILE/MAC,S2FILE The /MAC switch will cause the MACRO S2FILE to appear in code equivalent of SFILE and LFILE.LST. If you do not specify a processor (KAl0 or KI1O0 switch), the code will be compiled for the processor type on which the compilation occurs. The processor type of the code in the object file and all switches, used or implied, are printed at the top of each listing page. USING B.1.1.1 THE COMPILER The /DEBUG Switch - The /DEBUG switch tells FORTRAN-10 to Several of a series of debugging features into your program. compile FORDDT. with used be to these features are specifically designed By adding the modifiers for more information. E Appendix to Refer listed in Table B-2, you can include specific debugging features. Table B-2 to /DEBUG Switch Modifiers Meaning Modifiers :DIMENSIONS Generates dimension information in Generates references to FORDDT : TRACE .REL file for for its | FORDDT. trace features required (automatically activates :LABELS). form Generates a label for each statement of the L." (This option may be used without " "line-number : LABELS FORDDT.) the at be stored to indices DO LOOP Forces beginning of each iteration rather than held in a : INDEX register for the duration of the loop. array all Generates the bounds checking code for produce will violations Bounds references. technique Note that the run-time error messages. subroutine for 1 dimensions of specifying of : BOUNDS arrays will use (You cause bounds check errors. this option without include any debug may FORDDT.) : NONE Do not features. :ALL Enable all debugging aids. The format of the /DEBUG switch and its modifiers is as follows: /DEBUG:modifier | or /DEBUG: (modifier list) Options available with the /DEBUG modifiers are: 1. No debug features - Either do not specify the or /DEBUG include /DEBUG:NONE. 2. All debug features - Either /DEBUG or /DEBUG:ALL. 3. Selected features - Either a i.e., : LAB /DEBUG:BOU/DEBUG or switch a list of modifiers /DEBUG: (BOU,LAB,...) series of modified switches; USING 4. THE COMPILER Exclusion of features (if vyou wish all but one or do not wish to list them all, you may use and modifiers prefix "NO" before the switch you wish to exclude). exclusion of one or more features implicitly includes all same the is /DEBUG :NOBOU i.e., others, /DEBUG: (DIM,TRA,LAB, IND) . two the The the as If you include more than one statement on first statement will receive a label a single 1line, only the (/DEBUG:LABELS) or FORDDT reference (/DEBUG:TRACE). (The /DEBUG option and the /OPTIMIZE option cannot be used at the same time.) NOTE If a source file contains line sequence numbers that occur more than once in the same subprogram, the /DEBUG option used. cannot be The following formulas may be used to determine the increases in program size that will occur as a result of the addition of various /DEBUG options. :DIMENSIONS For of each array, dimensions, 3+3*N words where N 1s the number and up to three constants for each dimension. : TRACE One instruction per : LABELS No : INDEX One 1instruction instruction for statement. increase. index : BOUNDS executable For of the each per some inner of the loop plus one references to the the formula 1is loop. array, the same as use 5+N DIMENSIONS:. For each words reference where array. If approximately B.1.2 COMPIL-Class You can invoke to an array element, N is the number of dimensions in the you do not specify :BOUNDS, 1+3* (N-1) words will be used. Commands FORTRAN-10 by wusing COMPIL-class commands. These commands cause the monitor to run the COMPIL program, which interprets the command and constructs new command strings for the system program actually processing the command. When both FORTRAN-10 and F40 are present in your DECsystem-10 system, you can specify which compiler is to be used by adding the switches /F10 or /F40 to the following commands: COMPILE LOAD EXECUTE DEBUG | USING THE COMPILER Example .EXEC ROTOR/F10 The compiler switches KA, KI, OPT, CREF, and directly in COMPIL-class commands and w@nay e DEBUG may be specified used globally or locally. Example .EXECUTE/CREF/KA/F10 P1.FOR,P2.FOR/DEBUG:NOBOU in The other compiler switches must be passed specific parentheses for each Commands Manual for file. source Example .EXECUTE Refer to further B.2 the Pl1.FOR(M,I) DECsystem-10 Operating System information. LISTING READING A FORTRAN-10 When you request a listing from the FORTRAN-10 compiler, the following 1. it contains 1internal sequence information: A printout of the an source program plus This internal assigned to each line by the compiler. number warnlng or error any 1in referenced is number sequence If the input file messages generated during the compilation. is line-sequenced, the number from the file is used. If code via the INCLUDE statement, all INCLUDEd lines will added is have an asterisk (*) appended to their line-sequence number. 2. relative A summary of the names and 1in arrays and scalars of octal) compiler generated variables. (in 1locations program the source program plus (in 3. All COMMON blocks and the relative locations 4. A listing of all equivalenced variables or arrays . the variables relative of octal) in each COMMON block. and their locations. 5. A listing of the subprograms referenced 6. A summary of temporary locations generated by the compiler. 7. A heading on each page of the listing containing the program unit name (MAIN., program, subroutine or function, principal entry), the input filename, the list of compiler switches, and the date and time of compilation. Whether a specific and FORTRAN-10 defined processor switch (/KAl0, /KI1l0) was for which the code was generated listing 8. (both library functions). wuser used and the is also at the defined processor top of the page. If you used the /MACRO switch, generated code to the listing. a mnemonic printout (in a format similar to MACRO-10) This section nas four fields: of the is appended USING THE COMPILER LINE: This column contains the internal sequence number of the 1line <corresponding to the mnemonic code. It appears on the first of the code sequence associated with that internal sequence number. An asterisk indicates a compiler inserted line. LOC: The relative location in the object program of the instruction. LABEL: Any Pprogram or compiler generated label. Program labels have the 1letter "P" appended. Labels generated by the compiler are followed by the letter "M". Labels generated by the compiler and associated with the /DEBUG:LABELS switch consist of the 1internal sequence number followed by an "L". GENERATED CODE: The MACRO-10 mnemonic code. If you used the /LNMAP switch and did NOT wuse the /MACRO switch, a 1line number/octal location map 1is appended to the listing. This section lists the line numbers 1in increments of 10 on subsequent lines and each number from 0 through 9 for each line in adjacent <columns. The numbers appearing inside the matrix are the relative octal locations of the statements in the FORTRAN program unit. For example, to find the relative octal location of line number 001043, find the row marked 001040 and then column 3 on that line. The number in that place is the desired relative location. This listing can be very large and sparse for line-numbered files with large increments, such as those produced by SOS. NOTE One FORTRAN line can produce multiple octal locations. In this case the line number map lists only the first location. A list of all argument blocks generated by the compiler. A zero argument appears first followed by argument blocks for subroutine calls and function references (in order of their appearance in the program). Argument blocks for all I/0 operations follow this. 10. Format 11. A summary of during Compiler B.2.1 statement listings. errors detected or warning messages 1ssued compilations. Generated Variables In certain situations the compiler will generate 1internal wvariables. what these wvariables represent can help you read the macro expansion. The variables are of the form: Knowing .letter i.e., .S0001 digit digit digit digit USING THE COMPILER where: Function Letter A Register F Arithmetic Result save a Temporary Result DO of an Result of a or constant function LOOP formal 1initial parameters. wvalue adjustably dimensioned common subexpression (see computation (C.2.1.3). storage of Variable area. statement of parameter of for reduced expression expression or array. Section C.2.1.1) values. operator strength step size loop. expression expression (C.2.1.2). Result of iteration You may find these the DO LOOP count .for a variables The following example pointed out. shows on a the listing under listing where all SCALARS these of computed and ARRAYS. features are USING THE COMPILER e aNd a 01 "NIVNW * USING THE COMPILER [T0 0 0VE9L L]'T T[O000LPLL] CWNS‘’Z 00S°‘'Z 'z £’e (z)o‘e W3Y'TH ‘ 9 T *LASAI dZ214S dAQOU A OW WA OW WIAOR JAOW oLt q (X} = TMM o O AN M< L0~ TMM < N r—{ ¢t ST W- T 9 104°C dsrl TIYD ITIVD 040 00 A LY SNLOHVOVY '£c’zWy 12C 2GS G01A¢€3C AWLWSAIOIAWrOOWH W(ZaNE8’)0egSPT-¥'Y TG LSALWE'OD 9LZ€9L10¢8}T1TC47 L11JL1TTsdaS3AOSa0dyMaWWvOavvLIIyNrWW(r((LrZZ’o’ZG'2)‘e'))‘toeg’0000o'’’’¢¢€g€ "NIVH N&JA’4OWV AeZIV2€YD0€N1IV’DS (W1€I)S9ApTO7-N9’G 01 THE It B-10 £t /Al S1 Go¢€E 26T8 LE WL USING COMPILER 0 :6T Z¢I9T9T1=0T‘RWENCLLL I8LTYWMO4SINTELIATTWITA9I9TLTIY1TILIS-dN0IT)MOT(1H'LI)6N1I°SWOASP( €17€G1LS9 S2TWWTTOT rfLT0HHH’SS‘LAN0NLSdA’L‘'0OTL*TLS*TIONIO‘’LT LT 9ZS IdAoTO‘N’W‘0ov¢WOT’9T1 IWA3IdT‘09OTN WI694TA’TG09W L'90| PT IOTI HO €L 0’‘0 0% G9 0’0 USING THE COMPILER B-11 CSGWTNI9ST O6T=1OT’ USING THE COMPILER L00 CxI=T4 (LT¥IY0ZDOI-TA0I¥WNI) L+01TI0=02Y J0GA1NI0NTO0D a6nT0N0d dSKWYTIOI0dvdns B-12 "NIVRW "NIVW 000 S00900 9¢ B-13 L0 0 60 0 00T ang (JTWIOL*ds13y FANIINOD USING THE COMPILER USING THE COMPILER # | L'9 JAOW 90T9TT 0000S* GOT9TT T1000S* SPOLY v B-14 cc Ve 9¢ LC 0¢ ¢ Ve 1 B-15 9¢ LE A NLdOY dav aav aav WG’Z G'TT W60 (z)0o'’¢ L'¢€ L'9 0b WIT‘9T *LNO‘LT T100d°‘2T v 1987 LY ‘WT +d00T ‘18 ‘WOT dI¥D NIVO NIVO I1ddv JAONW 1a v ST 0¢ W9 - W9‘0 WL’O Wy ‘0 ‘WL W/LdO/IX/ 9.-AON-6T USING THE COMPILER 1adv JdDSOV x X A3 WIAONW ITHAON 9v x x IZL 0’JA0ON0%FWE’'IT S9L0TC1TTTI9991TTT1T ==H1OTC’WW66NN11’S’ C I9Tt ( 6T G *WC 0€AL99S TWE 00’’00 9L L0'’0 XLNIWNDY 01S1ZG9€/ALLY99GG%0T9d+TWWTZT IrZfT0dL3rOWaW/ATHAsN‘L’SSnSEO‘dL‘N0d‘¥0vL'0¢€TLOT1*W*TLLZSITX‘OT90'TIL‘TLT "*L8NN1YIIWVYIKWWOJSINP]ITTAIWOWTINIIOLLTVS"IYdLO¥S0Yd*¥dNYOdIT)3M1ODT03(NL1V)L3YNdIISH LWN[d DOAI4SA(:STS)S°W/LAO/IM/9L-AON-6T USING THE COMPILER 0 :ST B-16 USING B.3 THE COMPILER ERROR REPORTING If an error occurs during the initial pass of the compiler (while the actual source code is being read and processed), an error message 1is printed on the listing immediately following the 1line in which the error occurred. Each error references the internal sequence number of the incorrect line. The error messages along with the statement 1in error are output to the user terminal. For example: .EXECUTE DAY.FOR FORTRAN:DAY 01300 ?FTNNRC LINE:01300 100 01500 ?FTNMSP LINE:01500 01600 K1l STATEMENT NOT RECOGNIZED CONTINE STATEMENT NAME MISSPELLED 2 ?FTNICL LINE:01600 ILLEGAL CHARACTER C ?FTNFTL 3 MAIN. IN LABEL FIELD FATAL ERRORS AND NO WARNINGS LOADING LINK: [LNKNSA NO START ADDRESS] EXIT If errors are detected after the initial pass of the compiler, they appear in the list file after the end of the source listing. They are output to your terminal withocut the statement in error, but they may reference B.3.1 1its Fatal There are two internal Errors sequence number. Warning Messages and levels of messages, warning and fatal error. Warning messages are preceded by "%" and indicate a possible problem. The compilation will continue, and the object program will probably be correct. Fatal errors are preceded by a "?". 1If a fatal error is encountered in any pass of the compiler, the remaining passes will not be called. Additional errors that would be detected in later compiler passes may not become apparent until the first errors are corrected. It 1is not possible to generate a correct object program for a source program containing The format of a fatal messages error. 1is ?FTNXXX LINE:n text $FTNXXX LINE:n text or where: ? = % FTN XXX LINE:n text = warning = FORTRAN mnemonic = 3-letter mnemonic for the error message = line number where error occurred = explanation of error fatal USING THE COMPILER The printing of fatal errors and warning messages on your terminal can be suppressed by the use of the /NOERRORS switch; however, messages will still appear on the 1listing. The /NOWARNINGS switch will suppress warning messages on both user terminal and listing. B.3.2 At is Message Summary the end of the printed after listing file each program and on the terminal, a message unit is compiled. This message summary has two forms: 1. when one or more messages were issued {?FTNWRN} name NO/number FATAL ERRORS AND NO/number WARNINGS ?FTNFTL or 2. when no messages name [NO ERRORS were 1issued DETECTED] where name is the program or subprogram name. appears on the listing only.) Appendix G 1s errors and warning messages. B.4 To CREATING produce give elither a A REENTRANT sharable one of the FORTRAN program from following 1. /SEG:DEFAULT 2. /OTS:NONSHAR MAIN/G PROGRAM the WITH .REL commands ([NO a ERRORS DETECTED] complete list of fatal LINK-10 file, to such as MAIN.REL, LINK-10: MAIN/G The resulting core image can used to produce a .SHR file. be SSAVEd or the /SSAVE switch can be APPENDIX WRITING USER C PROGRAMS This appendix is a guide for writing effective programs with FORTRAN-10. It contains techniques for optimization, interaction with non-FORTRAN programs, mixing of FORTRAN-10 and F40 object programs, and other C.1l useful GENERAL programming PROGRAMMING The following should observe hints. CONSIDERATIONS paragraphs describe when preparing a programming considerations you FORTRAN program to be compiled by FORTRAN-10. C.1l.1 Accuracy and Range of Double-precision Numbers Floating-point and real numbers may consist of up to 16 digits in a double-precision mode. Their range is specified in Chapter 3, Section 3.2 of this manual. You must be careful when testing the value of a number within the specified range since, although numbers up to 10**38 may be represented, FORTRAN-10 can only test numbers of up to eight significant digits (REAL precision) and 16 significant digits (DOUBLE precision). You must for a be also result be of obtained; number tests 1In however, that within careful 0. in Writing FORTRAN-10 If prepare a program non-DIGITAL machine, 1. 2. Avoid using Consider the non-DIGITAL testind cases some approximates statements, C.1.2 you when most cases 0. i.e., run should: the non-ANSI accuracy machine is result may be a an approximation of for both 0 fail. Execution On Non-DEC a of DECsystem-10 of of numbers the will small will cause Machines computer features handling. 0 very to size capable computation i.e., IF, standard and result, the arithmetic on you floating-point anticipated Such an Programs to the the and FORTRAN-10, that a and the WRITING USER PROGRAMS Using Floating-Point DO Loops C.1.3 FORTRAN-10 permits you to employ non-integer double- or single- precision numbers as the parameter variables in a DO statement. This enables you to generate a wider range of values for the DO loop index may, in turn, be wused inside the 1loop for which variables, Be sure to consider the computations. 1loss of that precision may occur. Computation of DO Loop Iterations C.1.4 The number of times through a DO loop is computed outside the loop and is not affected by any changes to the DO index parameters within the The formula for the number of times a DO loop is executed 1is: loop. 10 DO MAX I=M1,M2,M3 (1, ((M2-M1) /M3)+1)=Number of cycles however, The values of the parameters M1, M2, M3 may be of any type; you must logicals. consider the foregoing formula, particularly when using One pass through each DO loop is always performed EVEN IF THE RESULT OF THE FOREGOING CALCULATION IS LESS THAN OR EQUAL TO ZERO. Subroutines - Programming Considerations C.1.5 Consider the following items when preparing and executing subroutines: 1. 2. 3. During execution, no check is the 1if see proper If the number of actual arguments passed to a subroutine 1is If the number of actual arguments passed to a subroutine 1is than the number of dummy arguments given, greater are the values the excess ignored. corresponding 1its and If an actual parameter is a constant 1is set to another value, all references made dummy argument the to the constant in the calling program may be changed to of value 5. to less than the number of dummy arguments specified, of the unspecified arguments are undefined. arguments 4. made of parameters was passed. number the dummy argument. the of No check is made to see if the parameters passed are If an actual parameter is same type as the dummy parameters. Dbe real, type a constant and the corresponding dummy is of If the to include the decimal point with the constant. sure dummy is double-precision, be sure to with a specify the constant "D". Examples 1is A and F(2) If the function F(A) is called by inputting integer 2 as an unnormalized the interprets F real, type floating-point number. called with In this instance, F(A) should be F(2.0). 1is F1(D) function Similarly, if the double-precision, 1is D and F1(2.5) C-2 inputting by <called that its assumes Fl WRITING parameters have and picks up proper method been USER PROGRAMS specified with two words whatever follows the constant is to use F1(2.5D00). 2.5 of in precision core. The NOTE You are given described C.1.6 Reordering of in no notice items if 1,2,3,4, any and of 5 the situations occur. Computations Computations that are not enclosed within parentheses may be reordered by the compiler. Sometimes it 1is necessary to use parentheses to ensure proper results from a specific computation. For example, 1. 2. RL] assuming that represents a large number overflow condition, and RS1 very number, is a small such i.e., that less RL1*RL2 than will 1, the cause an program sequence A=RS1*RL1*RL2 B=RS2*RL2*RL1 will not produce an overflow when evaluated 1left to since the first computation in each expression, i.e., and RS2*RL2, will produce an interim result that is than either large number (RL1 or RL2). However, (see The the compiler will Section C.2.1.1) and temp = RL1*RL2 A = RSl*temp B = RS2*temp computation of temp recognize generate will You should write the program results are obtained: cause as RL1*RL2 the an as following a common right, RS1*RL1 smaller subexpression sequence: overflow. follows to ensure that the desired A=(RS1*RL1)*RL2 B=(RS2*RL2) *RL1 Computations selected. may be reordered even when global optimization is not Dimensioning of Formal C.l1.7 PROGRAMS USER WRITING Arrays When you specify an array as a formal parameter to a subprogram unit, you must indicate to the <compiler that the parameter 1s an array. Dimension the array in a specification statement. This 1is the only way the compiler is able to distinguish a reference to such an array from a function reference. Designating the array with a dimension of 1l is a common practice. Example SUBROUTINE SUB1(A,B) DIMENSION A (1) There are disadvantages to wusing dimension information provided the above technique 1s not adequate 1in specifically: 1. Reading or writing DIMENSION The the ARRAY READ (1) ARRAY above is a binary because the some cases, array by name (10) read that will ARRAY. read ten words 1into ' SUBROUTINE DIMENSION SUB1 (A) A (1) READ(1)A This 2. binary Reading the read will array as SUBROUTINE SUB2 DIMENSION FMT (1) READ cause a one word to be read into A. format (FMT) (1,FMT) This will cause one word with the characters read of the array FMT to be written from the record on unit 1. over When you use the /DEBUG:BOUNDS compilation switch, the dimension information used is that which is specified in the array declaration. SUBROUTINE DO IT(A) DIMENSION A(1) A(2)=0 The reference be generated. to A(2) will cause the out-of-bounds warning message C.2 FORTRAN-10 GLOBAL OPTIMIZATION You have the option of invoking the global optimizer to dur ing The optimizer treats groups of statements in the source compilation. program as a single entity. The purpose of the global optimizer is to prepare a more efficient object program that produces the same results 1less significantly takes but program, as the original unoptimized output execution time. The equivalent (in results) phase of the compiler of is developed to the lexical and syntactic analysis into an the original. optimized source then processed by the standard compiler code generation phase. C-4 program The optimized program is WRITING C.2.1 Optimization C.2.1.1 USER PROGRAMS Techniques Elimination of Redundant Computations - Often the same subexpression will appear 1in more than one computation throughout a program. If the values of the operands of such a common expression are not changed between computations, the subexpression may be written as a separate arithmetic expression, and the variable representing its resultant may then be substituted where the subexpression appears. This eliminates unnecessary recomputation of the subexpression. For example, the instruction sequence: A=B*C+E*F H=A+G-B*C IF((B*C)-H) 10,20,30 contains the computed only once. subexpression B*C three Rewriting times when the foregoing the subexpression it really needs sequence to be as: T=B*C A=T+E*F H=A+G-T DIF((T)-H) eliminates 10,20,30 two computations the number of B*C from the overall seguence. Decreasing program by execution C.2.1.2 the time of arithmetic elimination of the resulting of Operator Reduction of operations performed common in subexpressions a source shortens the object program. Strength - The time required to execute arithmetic operations will vary according to the operator(s) involved. The hierarchy of arithmetic operations according to the amount of execution time required is: MOST TIME OPERATOR * % / * LEAST TIME +, - During program optimization, the global optimizer replaces, where possible (1), some arithmetic operations that require the most time with operations that require less time. For example, consider the following DO loop that is used to create a table for the conversion of from 1 to 20 DO 10 l. 10 to their equivalents in feet. MILES=1,20 IFEET(MILES)=5280*MILES Numerical cases miles where analysis this is considerations possible. C-5 severely 1limit the number of WRITING USER PROGRAMS the 1if shorter be 1loop would The execution time of the foregoing time-consuming multiply operation, i.e., 5280*MILES, could be replaced you Since you increment MILES on each pass, by a faster operation. can replace the multiply operation by an add and total operation. In its optimized form, the foregoing sequence egquivalent to: 1loop would be replaced by a K=5280 DO 10 MILES=1,20 IFEET (MILES) =K 10 K=K+5280 for 5280 In the optimized form of the loop, the value of K is set to 1loop and is increased by 5280 for each the iteration of first the succeeding iteration of the loop. subscript calculations This foregoing situation occurs frequently in the size is two or whenever s multiplication contain implicitly that greater. speed with C.2.1.3 Removal of Constant Computation From Loops - The if increased a given algorithm may be executed can be which instructions and/or computations are moved out of frequently traversed 1less frequently traversed program sequences. into sequences program the 1in arguments the of Movement of code is possible only if none to be moved are redefined within the code sequences from which items of 1loop consisting a within Computations taken. they are to be variables or constants that are not changed in value within the loop computations Decreasing the number of may be moved outside the loop. made within a 1loop greatly decreases the execution time required by the loop. For example, DO 10 in the 10 seqguence: I=1,100 F=2.0*%Q*A(I)+F the value of the computation 2.0*Q, once calculated on the first iterations, will remain unchanged during the remaining 99 iterations Reforming the of the loop. foregoing sequence to: Q0=2.0*Q DO 10 10 I=1,100 F=QQ*A(I)+F moves the calculation 2.0*Q outside the scope of movement of code eliminates 99 multiply operations. the 1loop. This In addition, it is possible to remove entire assignment statements from loops. This action can be easily detected from the macro expanded listings. The internal sequence number remains with the statement and appears out of order in the leftmost column of the macro expanded listing (LINE). WRITING USER PROGRAMS C.2.1.4 Constant Folding and Propagation - In this method of optimization, expressions <containing determinate constant values are detected and the constants are replaced, at compile time, by their defined or calculated value. For example, assume that the constant PI is defined and used in the following manner: PI=3.14159 X=2*PI1*Y At compile time, the optimizer will have used the defined value of PI to calculate the wvalue of the subexpression 2*PI. The optimized sequence then would be: PI=3.14159 X=6.28318*Y thereby eliminating a multiply operation from the object code program. The computation of determinate constant wvalues at compile time 1is termed "folding"; the use of the defined value of a constant for replacement purposes throughout a program sequence is termed "propagation of the constants."” The execution time saved by the foregoing type of compile time optimization is particularly important when the modified instruction occurs in a loop. C.2.1.5 Removal of Inaccessible Code - The optimizer detects and eliminates any code within the source program that cannot be accessed. In general, this will not happen since programmers do not normally include such <code in their programs; however, inaccessible code may appear in a program during the debugging process. The removal of inaccessible code by the optimizer will reduce the size of the object program. A warning message is generated for each 1inaccessible 1line removed. C.2.1.6 Global source program, Register the minimize computation allocation process MOVEM machine executed Allocation optimizer of During the the the that code. will appear <compilation allocation time in the optimized 1is designed to minimize instructions portions - controls in of of registers object program. the number of MOVE the most a to The and frequently WRITING USER PROGRAMS C.2.1.7 1I/0 Optimization - Every effort 1is made to minimize the number of regquired calls to the FOROTS system. This is done primarily through extensive analysis of implied DO 1loop <constructs on READ, WRITE, ENCODE, DECODE, and REREAD statements. The formats of these special blocks are described 1in Appendix E. These optimizations reduce dthe size of the program (argument code plus argument block size is reduced) and greately improve the performance of programs that use implied DO loop I/O statements. C.2.1.8 Uninitialized Variable Detection - A warning message is generated when a scalar variable is referenced before it has received a value. C.2.1.9 Test Replacement - If the only use of a DO loop index 1s to reduce operator strength (D.2.1.2) and the loop does not contain exits (GO TOs out of the loop), the DO loop index is not needed and can be replaced by the reduced variable. For example: DO 10 I=1,10 K=K+7*1I CONTINUE 10 Reduction of operator this loop into po 10 strength and test replacement together transform 1=7,70,7 K=K+I CONTINUE 10 This occurs frequently in subscript computation. Improper C.2.2 Consider P = Function References this statement: F(X) + Q(Y) If: 1. 2. the evaluation of and C, the evaluation of D, and F(X) defines or changes the variables A, B, Q(Y) defines changes the values B, C, and or of then it is possible that different values of P could result, depending on which function 1is -evaluated first. Let's see how this works. Let's assign some values (to begin with) to A, B, C, and D and define the functions F(X) and Q(Y): Let: F(X): Q(Y): A = 2. A = 6. B = 10. B = 3. B = 7. C = 11. C D = = 4. 5. Cc F = 8. =D+ 9. D = 12. Q =A + 13. WRITING USER PROGRAMS Now play computer and evaluate P, calling first F(X), then Q(Y). Now re-evaluate P, <calling Q(Y) first, then F(X). ©Notice that you got different values for P because the variables A, B, C, and D changed value depending on the order in which the functions were called. (Our answers were 33 when F(X) was called first and 36 when Q(Y) was called first.) The ANSI FORTRAN standard prohibits this kind of situation. But the compiler won't <catch it unless you mention the affected variables in the function call itself. The compiler depends on strict adherence to this rule. There's a strong possibility that vyou won't get the results you want if you don't look for situations of this type and avoid them. Your best bet is to define your variables OUTSIDE the function and not change them in the course of the evaluation of the function itself. C.2.3 Programming Techniques Observe the following source program. They C.3 not use for Effective recommendations during the coding will improve the effectiveness of l. Do DO loops with an 2. Specify label lists when using 3. Nest loops so largest range that the innermost of values. 4., Avoid the of 5. Avoid unnecessary use INTERACTING WITH C.3.1 Calling extended associated use of index GO is input/output NON-FORTRAN-10 of the a FORTRAN optimizer. range. assigned COMMON and TOs. the one with the variables. EQUIVALENCE. PROGRAMS AND FILES Sequences The following paragraphs describe DECsystem-10 subroutine calls. l. Optimization the standard procedures for writing Procedure a. The calling accumulator argument in b. c. The The AC d. e. left program must load half of subroutine is AC 16 then must be called set by right address a to of half the of first zero. PUSHJ instruction to 17. The return will be made to the after the PUSHJ 17 instruction. If the (AC) 16 with the the argument list. you use facility, the the /DEBUG:BOUNDS calling MOVEI 16,AP PUSHJ 17,F 1instruction option sequence must of be the immediately FOROTS trace PROGRAMS USER WRITING where AP is the pointer to the argument list. If you use the trace facility, the word preceding the first word of an entry point should have its name in SIXBIT. Restrictions a. Skip returns are not permitted. b. the before located stack The contents of the pushdown address specified by AC 17 belong to the calling program; they cannot be c. that must FOROTS initialized stack or the The specific are as 1. by: 16,RESET. library CALL Accumulator is subprogram. stack; the of control has it not <create your own stack. The assumes FOROTS therefore, you JSP C.3.2 read by the called routine RESET. Usage functions performed by accumulators follows: (AC) 17,16,0, and 1 Pushdown Pointer - AC 17 is always maintained as a pushdown pointer. Its right half points to the last location in use on the stack, and its left half contains the negative of the number of (words-1) allocated to the unused remainder of the stack. (A trap occurs when something is pushed into the next to last location. The trap instruction may itself be a PUSHJ on the KI10 processor, which uses the 1last 1location.) A positive left half is not permitted. Argument List pointer. contents. The called subprogram does not need to preserve its The calling program cannot depend on getting back Pointer - AC 16 1s wused the address of the argument list passed to cannot point to the ACs or to the stack. as the the argument callee. AC 16 Temporary and Value Return Registers - AC 0 and 1 are used as temporary registers and for returning values. The called subprogram does not need to preserve the contents of AC 0 or 1l (even if not returning a value). The calling program must never depend on getting back the original contents of the data passed to the called subprogram. Returning Values subprogram, a the arguments, - At the option of the designer of a <called subroutine may pass back results by modifying returning a single-precision value in AC 0 or a double-precision or complex value in AC 0 and 1. A combination of the above may be used. However, two single-precision values cannot be returned in AC 0 and 1, since FORTRAN would not be able to handle it. USER PROGRAMS WRITING Preserved ACs 2 through 15; - FORTRAN-10 FUNCTION subprograms preserve subroutine subprograms do not. ACs The design of the called the subprogram cannot depend on contents of any of the ACs being set up by the calling subprogram, except for ACs 16 and 17. Passing information must be done explicitly by the argument list mechanism. Otherwise, the called FORTRAN-10 or subprograms cannot be written in either COBOL. Argument Lists C.3.3 The format of the argument list is as follows: Arg Arg list count word addr.---First arg entry Second arg entry entry arg Last The format of the arg count word is: bits 0-17 These contain -n, bits 18-35 entries. where n 1is reserved and must be These are The format of an arg entry is as follows (each the number of arg 0. entry 1is a single to 0 : word) bits 0-8 Reserved for future DEC development (set for . now) bits 9-12 Arg bit 13 bits 14-17 bits 18-35 The following 1. type code. Indirect bit if desired. 1Index field, must be 0 for Address of the argument. restrictions Neither the argument on the stack. can be moved. argument should list be present. observed: nor the arguments themselves can be This restriction is imposed so that the stack The same restriction applies to any indirect pointers. The called program may not modify the argument 1list itself. The argument list may be in a write-protected segment. Note that the arg count word is at position -1 with respect to the contents of AC 16. This word is always required even if the subroutine does not handle a variable number of arguments. A subroutine that has no arguments must still provide an argument list consisting of two words, 1.e., the argument count word with a 0 in it and a zero argument word. WRITING USER PROGRAMS Example MOVEI PUSHJ oo 16,AP 17,SUB s ARGUMENT ; SET UP ARG POINTER ; CALL SUBROUTINE ; RETURN HERE LIST -3,,0 A AP: B C s SUBROUTINE TO SET THIRD ARG TO SUM OF ADD MOVEM POPJ C.3.4 Argument :GET FIRST ARG :ADD SECOND ARG :SET THIRD ARG :RETURN TO CALLER T,R0(16) T,R1(16) T,@2(16) 17, MOVE SUB: FIRST TWO ARGS Types Argument Table C-1 Types and Type Type Code Codes Description FORTRAN Use COBOL Use 0 1 2 3 Unspecified FORTRAN Logical Integer Reserved Unspecified Not applicable l-word COMP Reserved 14 15 16 17 Complex Not applicable Not applicable Byte string descriptor Reserved Not applicable 4 5 6 7 10 11 12 13 Real Reserved Octal Label Double real Not applicable Double Octal Reserved Reserved ASCIZ string COMP-1 Reserved Reserved Procedure address Not applicable 2-word COMP Reserved Reserved Literal arguments are permitted, but they must reside 1in a writable This is because the FORTRAN-10 compiler makes a local of all segment. caller's the to formals back all copies and non-array elements arguments. development. All wunused type codes are reserved for future DIGITAL WRITING C.3.5 The Description types of the l. Type 0 The of calling type if the called 2. Type A it has should assume is A 4. 1 - A the should If binary 2 and - none of the 1If should several assume the 4 value negative 2's - and Real and above handle is of types default called the correct are as conditions the The argument possible, part is of true, as an its the integer 0 to .TRUE.. specify or positive to specify l-word-COMP signed binary integer. COMP-1 DECsystem-10 format sign excess 128 mantissa 36-bit 7 unsigned - Label 23-bit binary and memory floating-point number. exponent Type 10 - value. procedure address address. Double always O indirect 0 the flag address real A double-precision floating-point number code 1s being executed, i.e., KA and KI format on a KI1l0 processor. Type A 9. a containing complement bits 0-12 bit 13 bits 14-17 bits 18-35 8. type. argument logical Integer 36-bit Type A 7. specified that Type 6 - Octal A 6. not types. bit O bits 1-8 bits 9-35 5. are: checking FORTRAN 36-bit Type passed subprogram subprogram 36-bit Type be 2). .FALSE. 3. may program specification. (type that Unspecified subprograms called PROGRAMS Arguments arguments - USER - 2-word Type A 11 2-word COMP (72-bit) 2's word word word word 1, 1, 2, 2, 12 Double 72-bit - complement bit O bits 1-35 bit O bits 1-35 unsigned binary signed sign high order same as word low order octal value. for format on the a CPU on binary integer. 1, 0 bit which KAlO processor WRITING Type 10. PROGRAMS USER - Complex 14 A complex number represented as an ordered pair of 36-bit floating-point numbers. The first represents the real part, and the second represents the imaginary part. Type 11. 15 - Byte String Descriptor The format of the byte string descriptor is: word 1: the at aimed 1i.e., ILDB-type pointer, preceding the first byte of the string word 2: EXP byte The byte descriptor byte count may not be modified by the called The byte string itself must consist of a string of program. any be The byte size may contiguous bytes of uniform size. number of bits from 1 to 36. The byte count must be large enough to encompass 256K words of storage, i.e., 24 bits for l1-bit bytes. 12. Type 17 (See - ASCIZ COBOL Program Reference Manual.) string A string of contiguous 7-bit ASCII bytes 1left justified on the word boundary of the first word and terminated by a null byte in the last word. The length of the string may be from l C.3.6 The to 256K words. Converting Existing MACRO-10 Libraries for use with FORTRAN-10 following sequence. simple example illustrates the FORTRAN-10 calling daTAx13d174x¥91IxLT 0D JHL SINIWLNOY¥° T:Y9AYLIT SHVIVISANVSAVINY]uwxwONILIDITAXTNOILINIJA—w%wIONdaONITITT[ 9990 NIT11VTI1Y4ADnT0d1dW90YNSXO*T°P°9IC§¢IS‘N¥I¥NJ¥V)VVD0ITA¥1YAXT¥‘3Id9dVYINDYTY0LIY9I‘doDY(¥dJOL1DTN)AJIN9YWNOOILVJINLWST‘'YSIE¥YATNDYOI*IDYdNaIAVLANd“O7‘Y9LLdVLEwYNIS¥V(HA,I2L9IY9M,¥ALIYAJ0SLNAWNOYY (NOI0SNTIW)IAd 010 0 ¢10 0 £€T10 0 v10 0 GT000 91000 LT000 ONd SWYIDO0UddnNsS d TIVvD "NIVIW 10000 ¢0000 £€0000 70000 50000 90000 L0000 80000 60000 WRITING USER C-15 PROGRAMS SHIYVIOdNWIL USER PROGRAMS 0¢ M/0T T2 da‘’‘ob WRITING d9’T0¢ C-16 9SLT3I2I0¥¥NTVYx0Id»V1I4OdSAN9PT9)VISAVYYCExNIIVLxxI]OJTwxduWYXO0SZTTNTLJ0IDIATHALXTTPI3Xd«VAxx3SNNdO«IxALNIYT93NI1TINJOAIILAVY—DIJ,A.%I4AOIWONJ0CTWIxIddx3ZTXOYYNWVIUI«YO~IdJALVI¥TSYYIL[IWYWI%xYV€CNdXAXYVY€0T2G L160Z7G8922Z21T1z000000000000000 WNaTT1LIJnIU¥IdIOdNNNdT¥I1LX3ddIY=I =L yYVY==my=D =TM(:IXI)XX£€2TX,d=WDZX‘¥X) (0°0 7628T€701100000000 Nv1X1OXIIS=¥ =T ==T =2 =€ =€ NAWIToLTWJYI¥III0ZVNdTNAX3A1I¥QdNdYVaYWYN(X£)Y (0T) USER C-17 WSHIYVIOd AL *XTdWO0OD €2000 SWY DOUd Ns d TI¥D GTI000 G0000 L0000 WRITING PROGRAMS C-18 X1d JAONW JAONW IZ ¢c £c VI 91 adav dAOKWd WIAONKWA dAOW JAON €'¢ ZX'L T1'T €T r'L WWIIAAOONWW WWWAIIAAOOONNWWW WIAOWN TIYIAN‘0 A(ZIS)S IX’0 G¢ 9¢ LT WIAONW TJAON WIAONW USER 0¢ TXd¥0d° NYIdLIO0d WIAOW JAONW (9T)Z9‘T WIZXEVY’T (9T1)€0‘T JWAIOANOWNW oNdT1daa’y TINI‘Z (9T)¥ve‘?P (9T)SP‘E LJ0’¢€ 9T)9 ‘9 WIAOW (LIT’9 (€X'TWYNXIVY’L L)L L L'L ONS‘LT PX'y P d0IL0VITCN’I‘DZ¥S490€9 WJAIOANOWW ‘9T19’1‘09’09(9T)TO0V"(9T) 201 Td49V'1 W/IM/ 9L-AON-%¥ 6T1:21 d9vdI-1 TIY3Y‘0 0T TT Al ANI'I WRITING PROGRAMS Z1’'€ €19 WIAONW 0¢ I¢ A3 ge G ‘Z LJ0'Z L1200 LIT’'Z WYNXJVY'’E 0’S r‘e WRITING USER PROGRAMS ‘WT aav 1c X4 G¢ 81 LT : 50014 0¢c C-19 99 L9 WRITING To convert still load 1. PROGRAMS existing MACRO-10 programs conveniently so that they will and execute correctly when called from F40 or FORTRAN-10: Transfer the initial entry PUSH Change These are the These macros release) were with both F40 all sequence for a routine to CAIA entry: 2. USER returns 17 ,CEXIT. ## to POPJ 17,0 functions performed by the HELLO and GOODBY macros. (available in the file FORPRM.MAC, part of the FOROTS successfully used to convert the library routines to run and FORTRAN-10. In addition, since the FORTRAN-10 compiler uses the indirect bits on argument 1lists (note that this permits shared, pure code argument lists), it 1is essential for code that accesses parameters to take this into account. Specifically, sequences that obtained the values of parameters through use of operations such as HRRZ to pick up MOVEI R,1(16) the address of the second argument should work when interfacing be changed to R,Q@1(16) The latter operation FORTRAN-10. will with either F40 or Refer to the previous example, which illustrates the code generated by the FORTRAN-10 compiler, for specific details of how each argument is accessed. Note that in the case of the formal array, it 1is the address of the array that 1is accessed. C.3.7 Mixing FORTRAN-10 and F40 Compiled Programs Starting with Version 1A of LINK-10, use of the that results in a degradation of the 1loaded. This feature 1is provided as a It is not intended to be used for other with is will This introduces extra code execution of programs so convenience for conversion. than conversion assistance. Interaction This /MIXFOR and F40 is loaded. C.3.8 programs. switch permit loading FORTRAN-10 modifying the code while it achieved by COBOL-10 The FORTRAN-10 programmer may call COBOL-10 programs as subprograms, and, conversely, the COBOL programmers may call FORTRAN-10 programs as ' subprograms. In either in the of called the foregoing subprogram. cases, I/0 operation must not be performed WRITING C.3.8.1 Calling FORTRAN-10 programmers may write USER PROGRAMS Subprograms subprograms from COBOL-10 Programs - COBOL in FORTRAN-10 to use the conveniences and facilities provided by this language. The COBOL verb ENTER is used to call FORTRAN-10 subroutines. The form of ENTER is as follows: 5 ENTER FORTRAN program name B identifierl |[USING (literall procedure om—— identifier2 » namel ¢literal2 procedure? The USING clause of the foregoing forms names the data within the COBOL program that 1is to be passed to the <called FORTRAN-10 subprogram. The passed data must be 1in a form acceptable to FORTRAN-10. The calling sequence used by COBOL in calling a FORTRAN-10 subprogram is: MOVEI 16, address PUSHJ 17, subprogram of first entry in argument list address 1f the USING clause appears in the ENTER statement, the compiler creates an argument list that contains an entry for each identifier or 1is It USING clause. the 1in appearance of literal in the order preceded by a word containing, in its left half, the negative number present, If no USING clause is of the number of entries in the list. contains an empty word, and the preceding word 1is 1list argument the Each entry in the list is one 36-bit word at the form: set to 0. 0-8 9-12 13-35 0 type address Bits 0-8 are always Bits 9-12 contain a 0. type code that indicates the USAGE of the argument. Bits 13-35 contain the address of the argument of word of the argument; the address can be indexed or Following appear in is a description of addresses. l. For the argument | l-word 2-word CODE: IN ARGUMENT ADDRESS: LIST: For LIST: how CODE: IN ARGUMENT XWD 100, address that of the argument the codes 11 XWD that itself items 440, of address the high-order argument COMPUTATIONAL-1 ADDRESS: codes, 1locations specified by the items COMPUTATIONAL | 3. their the 2 IN ARGUMENT ADDRESS: For types, and COMPUTATIONAL CODE: 2. the 1list, the first indirect. LIST: items 4 XWD 200, that of C-21 address the argument itself word of the WRITING 4. For DISPLAY-6 CODE: IN ARGUMENT ADDRESS: and USER DISPLAY-7 LIST: WORD1: 15 XWD that a PROGRAMS items 640, address of a 2-word argument byte pointer descriptor to the the identifier or literal WORD2: bit bit bit 0 is 1 if the item is numeric 1 is 1 if the item is signed 2 is 1 if the item 1is a figurative constant (including ALL) bit 3 is 1 if the item is a literal bits 4 through 11 are reserved for expansion has 1item bit 12 is 1 if the with one or more Ps just decimal point, e.g., 99PPV. bits 13 through 17 are the is bits the For procedure names the If bit places. decimal 5. for of number 18 through item in PICTURE a before the number of 12 is 1, this Ps. 35 contain the size bytes. of - (which cannot be used for calls to COBOL subprograms) CODE: IN ARGUMENT LIST: ADDRESS: The return from a subprogram the call. C.3.8.2 Calling 7 XWD 340, that of address the procedure (via POPJ 17,) is to the statement COBOL-10 Subroutines from FORTRAN-10 Programs after - To call COBOL subroutines use the standard subroutine calling mechanism: CALL COBOLS (args...) X=COBOLS (args...) subroutine call function call You must have compiled the COBOL subroutine using the COBOL compiler described in the DECsystem-10 COBOL Programmer's Reference Manual. C.3.9 LINK-10 Overlay Facilities LINK-10 provides several routines that are accessible directly from a FORTRAN-10 program. These routines are presented here briefly, together with the FORTRAN-10 specification of their parameters. In general, LINK-10 performs these functions automatically. These routines are available only for your convenience. Full details of the use of Manual. the overlay facilities can be : found in the LINK-10 Reference WRITING USER PROGRAMS Conventions - The following terms are used C.3.9.1 parameters to LINK-10 overlay routines. consisting File spec A literal constant Name A LINK name or number List of link names A filename.ext [directory] variable. or constant name of sequence describe to the of device: a 1literal that 1is items separated by commas. The routines avallable are: (File spec) Used file to be specification is INIOVL (List of link names) GETOVL RUNOVL C.3.10 structure (Name) Loads to the that from (File spec) to change the specified LINK and Removes the specified Used in core. LINK. (List of link names) LINKs LOGOVL For a full overlay transfers REMOVL Reference overlay the specify to found 1if the 1load time to be overridden. core. Used to specify where the If no arguments file is to be written. given, the log file is closed. description of these routines, refer to the 1log are LINK-10 Manual. FOROTS/FORSE Compatibility 1is C.3.10.2 (C.3.10.1 and Sections in information presented The those users who have programs and data files that for only intended FORSE object the and were developed using the F40 FORTRAN compiler The following sections describe the manner in which both time system. upward and downward compatibility between the FORTRAN-10, F40, FORSE FORTRAN systems may be achieved. FOROTS and FORTRAN-10/F40 Data File Compatibility - Table C-2 describes C.3.10.1 Table C-3 TO FOROTS). (FORSE files data of compatibility upward FORSE). TO (FOROTS files data of describes downward compatibility WRITING USER Table Upward PROGRAMS C-2 Compatibility (FORSE TO FOROTS) May FORSE File 1. read Type Be By In FOROTS Sequential ASCII Yes The Following Manner: May be record read directly; positioning operations, BACKSPACE, may 2. Sequential Binary Yes be May be a Sequential Mixed files Yes read directly forward May be RECORD, used. record operations permitted. 3. €.g., SKIP fashion positioning are not read directly a forward record Random Access ASCII Binary Files Files No} No NOTE: We in fashion only; positioning operations permitted. Random Access 1in only; not suggest that a random access file be read (using FORSE) and be rewritten as a sequential file that can be accepted by FOROTS. WRITING USER PROGRAMS C.3.10.2 Converting FOROTS Data Files to FORSE-Acceptable Form - The following paragraphs describe procedures that may be used to convert FOROTS sequential mixed, random access ASCII, and random access binary data files into a form that can be read by FORSE. Conversion of FOROTS Sequential Mixed Files - We suggest the following sequential mixed file into either a FOROTS a convert to procedure sequential ASCII or sequential binary file acceptable to FORSE. 1. 2. Prepare either a and run a FORTRAN-10 sequential ASCII or I/O program that will produce a sequenial binary output file. it must be If a seguential ASCII file 1is produced, Line-blocking line-blocked before 1t can be read by FORSE. system the is accomplished by copying the file using either COPY line is the command (with blocked and will an data example file an A switch) or PIP. be acceptable to FORSE. The copy will be The following of the command sequence needed to line-block FOROT.DAT: .COPY FOROT.DAT=FOROT.DATA/A 3. it must be If a segquential binary file 1s produced, FORSE. by record-blocked before it can be read Record-blocking is accomplished using the /K feature of the program BAKWDS. The following is an example of the command sequence needed to record-block the data file FOROT.DAT: .R BAKWDS *FOROT.DAT=FOROT.DAT/K WRITING USER Table Downward PROGRAMS C-3 Compatibility May 1. (FOROTS Read File FORSE Sequential ASCII File Yes FORSE) Be FOROTS Type TO In By The Following Manner: This | operation is permitted 1f the file is line-blocked. This may be accomplished by making a copy of the file using either the system copy command (with an A switch) or the PIP program. The resulting copy will be line-blocked. An example sequence block using .R of the needed a PIP, command to FOROTS follows: line file, PIP * FOROTS . DAT=FOROTS . DAT/A 2. Sequential Binary File Yes This operation is permitted if the file is record-blocked. This type of blocking is accomplished by using the /K option of the program BAKWDS. The following 1is an example of sequence record-blocks .R a a command which file. BAKWDS * FORSE . DAT=FOROTS . DAT/K 3. Sequential Mixed File No (See Section suggested procedure.) 4. Random Access ASCII File No (See Section suggested C.3.10.2 for conversion C.3.10.2 for conversion procedure.) 5. Random Access Binary File No (See Section suggested procedure.) C.3.10.2 for conversion WRITING USER PROGRAMS Conversion of FOROTS Random Access ASCII Files - We suggest the following procedure to convert a FOROTS random access ASCII file into a form acceptable to FORSE. 1. Prepare and run a FORTRAN-10 I/O program that will <create a sequential ASCII file consisting of the records of the random access 2. file. Line-block the sequential ASCII file using either the system (with an A switch) or the PIP program. The COPY command following is an example of the COPY command: .COPY LNBLK.DAT=SEQFL.DAT/A The foregoing (LNBLK.DAT) 3. command would produce a line-blocked copy the file of the sequential file SEQFL.DAT. Prepare and run an F40 I/O program that will produced step in 2 and will generated random access file. read rewrite the file as a FORSE Conversion of FOROTS Random Access Binary Files - We suggest the following procedure to convert a FOROTS random access binary file into a form acceptable to FORSE. 1. Prepare and run a FORTRAN-10 I1/0 program that will create a sequential binary file consisting of the records of the random access file. 2. Record-block the sequential file. This 1is accomplished by using the /K feature of the program BAKWDS. The following example illustrates the command sequence required to <convert the file FOROTS.DAT into the record-blocked file FORBLK.DAT. .R BAKWDS *FORBLK.DAT=FOROTS.DAT/K 3. An F40 I/O sequential access C.3.10.3 file. program may then be written to convert the record-blocked file into a FORSE generated random General Restrictions - Observe the following restriction during the preparation of FORTRAN-10 programs and data files: are not (as implemented for the F40 compiler) implemented in FORTRAN-10. An overlay capability that is greatly CHAIN functions superior to CHAIN is available with LINK-10 version 2. APPENDIX D FOROTS This appendix describes the facilities that FOROTS provides for the FOROTS implements all standard FORTRAN I/O operations FORTRAN user. as set forth in the "American National Standard FORTRAN, ANSI x3.9-1966." In addition it provides the user with capabilities and programming features beyond those defined in the ANSI standard. The primary function of FOROTS is to act as a direct interface between user object output operations. D.1 and programs the DECsystem-10 monitor during input and Other capabilities include: initialization 1. Job 2. Channel 3. Error handling and reporting 4. File management 5. Formatting of data 6. Mathematical library 7. User library 8. Specialized applications packages 9. Overlay facilities 10. F40 compatibility and core management (non-mathematical) HARDWARE AND SOFTWARE REQUIREMENTS You can run FOROTS on a DECsystem-10 KAl0, KI10, or KL10 processor. FOROTS may interface with all DECsystem-10 peripheral devices. addition to monitor or user program reguirements, a minimum of pages of user core is needed to run FOROTS. In 14 FOROTS The software required with Other software version. FOROTS is items the that 5.06 can monitor be associated or a later with FOROTS include: D.2 1. The MACRO-10 2. The LINK-10 3. The system program 4. The FORTRAN-10 FEATURES OF assembler loader (version (version COMPIL compiler 47 or later) 1A or later) (version 22 or (version 1 or later) later) FOROTS The following list briefly describes many specific information concerning the implementation detailed is given later in this appendix. 1. and features; of these more features Your program may run in either batch or timesharing mode without requiring a program change. All differences between batch mode and timesharing mode operations are resolved by FOROTS. Your programs may access both devices 1n the same manner. FOROTS helps provide complete all DECsystem-10 devices. directory data file may the non-directory compatibility FOROTS does not require 1line-blocking (a each output buffer must contain only an lines). Up to 15 data files number or all of and between requirement that integral number of be accessed simultaneously. Any open data files may be accessed randomly. FOROTS treats local devices. Programs devices written correctly on the commands for disk under needed for You may change specifications Non-FORTRAN located at magnetic remote tape stations similarly operations will FOROTS supervision. FOROTS magnetic tape operations. run simulates or specify object program device and via a FOROTS interactive dialogue mode. binary data files may be read in to 1image file mode by FOROTS. 10. FOROTS provides processing interactive routines. These execution of the program routines whenever designated 11. An error traceback history of all at the address facility program/operating routines permit you to specific error types of errors are for fatal errors system to error route the processing detected. provides subprogram calls made back to the main of the point where the error occurred. a program FOROTS 12. 13. FOROTS provides functions, a including trap handling default values system and error You may mix ASCII and binary records in the may both for arithmetic same file, reports. and accessed in either sequential or random access be . mode 14. WRITE FOROTS permits your program to switch from READ to the same I/0 device without loss of data or buffering. 15. wuse for designed Although primarily FOROTS use also may you compiler, system, for D.3 as an FORTRAN-10 I1/0 system for MACRO-10 F40 object programs. and on FORTRAN-10 the with as an independent I/O object programs, and ERROR PROCESSING the FOROTS error processing Whenever a run-time error is detected, This system determines the system takes control of program execution. class of the error and either outputs an appropriate controlling processing D.4 terminal routine. branches or program the to message at the a predesignated INPUT/OUTPUT FACILITIES except access of modes FOROTS uses monitor-buffered I/0 during all formatted are supported in dump mode; devices Display DUMP mode. unformatted files are accessed as text is handled in ASCII line mode; Monitor Calls Manual.) DECsystem-10 to (Refer files. binary FORTRAN The following paragraphs describe I/O data channel and access modes. Input/Output Channels Used Internally by FOROTS D.4.1 I/0 in are available 15) (1 through Fifteen software channels <channel 0 is reserved for the following system Software operations. functions: 1. 2. The printing The 1loading of error and messages, and initialization of FOROTS (GETSEG uuo wuser program data operations) Software channels 1 through 15 are available for When a request is made for a data channel, a transfer operations. The first free 1is found. table is scanned until a free channel of the completion on program; requesting the to is assigned channel to returned 1is channel software assigned transfer, control of the FOROTS. FOROTS File D.4.2 Modes Access transferred Data may be processor between storage devices in two major modes - sequential and random. and peripheral transfer data sequential D.4.2.1 Sequential Transfer Mode - In the records involved are transferred in the same order as operations, in this Each I/O statement executed they appear in the source file. immediately following the last record mode transfers the record A special version of the transferred from the accessed source file. sequential mode to (referred APPEND) as available for output is to write a record immediately after the last logical record of the accessed file. During the APPEND operation, the records already in the accessed file The special APPEND mode permits you (write) operations. the only function performed is the appending of the remain unchanged; transfY2red records to the end of the file. the You must specify transfer modes (other than SEQINOUT) by setting to one of several FORTRAN-10 OPEN statement a ACCESS option of possible arguments. For the sequential mode, the arguments are ACCESS='SEQIN' (sequential read-only mode) ACCESS='SEQOUT' (sequential write-only mode) (sequential read followed by a sequential ACCESS='SEQINOUT' write) ACCESS='APPEND' (sequential Append mode) Random Access Mode - This transfer mode permits records to be D.4.2.2 source file in any desired order. a from transferred and accessed a and core processor between Random access transfers must be made (disk) that permits random addressing operations to files that device must access random for Files have been set up for random access. number of identically sized records that may be specified a contain individually accessed by a record number. You may accomplish random access transfers in either a read/write mode You must specify random transfer modes special read-only mode. a or several of one by setting the ACCESS option of an OPEN statement to possible arguments. ACCESS='RANDOM' ACCESS='RANDIN' D.5 (random (random read/write mode) special read-only mode) ACCEPTABLE TYPES OF DATA FILES AND THEIR FORMATS The following paragraphs describe the types of acceptable D.5.1 to ASCII data files are that FOROTS. Data Files Each record within an ASCII data file consists of a set of contiguous A vertical paper-motion character, such as, a Form characters. 7-bit ASCII All Feed, a Vertical Tab, or a Line Feed, terminates each set. the last word in a record is padded records start on a word boundary; to ensure that the record with nulls, if necessary, There implied maximum length word boundary. is no also ends on a Logical records may be split across physical blocks. for D-4 logical records. FOROTS NOTE On sequential input, FOROTS does not require conformation to word boundaries; it reads what it sees. Therefore, any file that 1is written by FOROTS will conform to the foregoing format requirements. D.5.2 Each FORTRAN Binary logical record Data in a Files FORTRAN binary data file contains data that the executing program wmay reference with either a READ or WRITE statement. A logical record is preceded by a control word and may have one or more control words embedded within it. In FORTRAN binary data files, there is no relationship between 'logical records and physical device block sizes. There is no implied maximum length for logical records. | | D.5.2.1 Format of Binary Files - A FOROTS binary file may contain three forms of Logical Segment Control Words (LSCW). These LSCWs give FOROTS the ability to distinguish ASCII files from binary files. LSCW START 001+ - the number of words in CONTINUE END LSCWs. If the 'RANDOM', CONTINUE c (exclusive of ‘ all records are the OPEN 'SEQINOUT', specify is of the same length, statement all three 'RANDIN', and there are no LSCWs. The following examples file contains only 001 c segment access you specify for a file (through parameter) 1is 'SEQIN', 'SEQOUT', or appear in a record. If the access you ACCESS = LSCWs may or the any "END" LSCWs) 002 indicates that the segment of a disk block boundary continues 003+ number of words in the preceding segment including illustrate the and 003 LSCWs. LSCW. The random access LOOK AT A BINARY FILE AND SEE THE LOGICAL SEGMEN?Y CONTROL WORDS. OPEN(UN]T=1,ACCESS='RANDOM’ yMODE2/BINARY/, 1 RECORD=1¥9) 135 WRITE(1'Y) (1. J=1,100) SE D WRITE(1'2) END (J,K=3%1,100) binary FOROTS o000 o700y 22002 20003 Pe’R04 @g2005 BpCoRe Qo007 Ppz21@ 201020 200000 geRowes5 2000320 220205 200230 220005 2g2020 eoe200 200200 200000 0002282 29011 200000 Pp2012 Q2013 080200 29014 Pg2@15 2pco16 p2017 P/ 020 PgoR2 000000 coooee 202200 Gooooe ooeloQ 0@2000 002000 20000 0@ 022 2,023 22.*024 ggodece 2pr@25 P 026 20027 2000020 000020 200220 002220 292030 002020 2eI034 2g22020 2020200 P2p"232 2p2R33 2p/234 2p’035% B@R36 Pp2037 Cpr04p 02041 Pp2R42 Pp 2043 Pei044 202045 PpL046 Pp2047 222050 2gue5q PpCR52 /80220 0po000 200200 coolan °p2220 Jged2o 200020 2ged00 eoodes 200200 2000020 cpeleo 200020 02020 2008000 200700 Pp 2054 000020 2000280 @@7055 2020200 2056 200020 22057 200020 092060 200020 200020 o053 Bp72064 B2@1 45 <— Number of words in record counting eegoes Bp 062 2oe020 Ppr063 200220 grgags 208085 goe0as5 220005 g2ga@s 20025 200205 2beees5 220085 202005 220885 geeapgs 220085 aegaas geeaps gegoes APQ2e5 2P0Res5 2200085 220025 eo22e5 220085 p0B025 2oRne5 g2e2p5 02gags5 22090205 p2gags pPRe@s5 228295 200005 200085 gogeas geeass a0Qees g2gepgs 2200025 222005 geeees5 geeens 229705 pepeas aReees a72paoRs 200005 220305 goQaps END LSCW or the number of words following this word to the END LSCW. BRaR64 P 265 Ppr066 2p2Q67 o270 03071 Bp.'072 @P2073 2p2074 22075 204076 Qpd@77 o100 Bp2101 82102 22103 Bpci124 7105 dp7i106 @p2107 2p:119 2p2111 Pp¢112 207113 Bp114 2pd11% Ppzi116 220005 oPgBe5 200205 200000 aRgnAgs 203200 2200025 o0r2030 200025 dgedee gReoes egeeao 22205 egepaoo 298205 2ge002 pe@ags 02220 g2gegs 200020 engepss 002220 208005 200000 a0gags 200000 202285 2022002 220005 202200 2Pgoes 2000200 2200205 200000 peeeRs 2g2P00 2090225 2geoan 2000085 200200 200095 000020 Jgedoe 220900 2000202 200020 ogeceo 2gecep 280000 2pi17 oge230 Gpril2p Bpel21 20002282 Ppa122 22123 e0l20 Bp125 Pp2126 depooe 2912124 Bp0127 P0p0213p Ppo13y 990132 20133 020134 220135 PpR136 202000 202020 200020 2geogo P20000 202000 oge000 dooRoe dpecen 200000 000002 222137 2002022 2000200 Ppni42 P@2143 PR 144 200000 Pg¢140 P@2141 20145 @146 @p’147 Bp*159 200000 200000 200000 202020 2p3220 2019220 20020 2opedan 220225 208225 200005 22QR0e5 oegaes 200005 200085 22Q0es 2200205 209205 829205 R2Q2@s pCoRR5 oP0005 2000es5 2PP005 ePe9p% eoe2es 2Pge95 2900085 2000025 a020p8% 200025 200005 20RARS 329205 290085 2?3@146 —END LSCW P20145 Containing the 220007 in the record including LSCW's. 2eop7 number of words FOROTS 200207 200227 CpoP20 200207 282220 2008007 Age220 2070320 Bpa233 Ppa234 @2.2155 200009 Pp3235 22236 Pp2237 Bp2156 200229 2pit151 2@ 2152 Bp2153 @p2154 20157 200000 Bp7160 Q@2200 Bg’ 161 2,162 202020 2pedon Pp2164 0pa029 202020 #2165 200022 02166 22000 Bpli67 Poooae 294170 200030 202000 2R %163 Ppel171 Q@172 22173 8174 293175 Bpl176 2p.1177 2oadep 22900 200020 200200 202000 2002292 01200 Ppv20oy Apa000 Pp. 202 dpeago R 0p2222 203 202220 02,204 2p208% 2000009 200022 07206 2peRece 212 Joeca0 200020 200222 Jogeden Pp..213 202229 2912207 @p.1210 Ppi1211 g Pp2214 @215 P 216 Q@217 2p2220 Pp2221 200000 200000 2p0000 200000 cpeean 2pp020 p2222 Bpi223 egeeeo dec224 Pp2225 dgoReo 222000 @gi227 Ppe239 Ppa231 000020 Pp0000 ogeron dgedoe Jge000 Pp.2232 2o0200 2p2226 200007 200207 208007 200007 000007 200007 200207 200007 200007 LLErE, 300007 200007 300007 200007 2000807 300207 02007 3002307 220307 2020307 200007 300007 0900087 200007 200007 2008007 200007 200207 200007 302007 a0eaa7 000007 200007 200007 202207 200007 202007 TLLIK, 209007 200007 2208007 3002807 LITTE, 200807 300007 200007 200000 200000 2ogoee 200020 0geP00 Ppvi24p PP 241 @pv 242 PooPag 200029 000000 Bp:243 Bp2244 2p2245 200000 2padop 002020 80246 220700 Bpii247 208000 @p2259 02200 2009082 2@:251 @@7252 202000 8g2253 200200 Pp.2254 7255 PR 256 7oeeae 2p7257 Agr 260 PpZ261 2g2022 22000 000220 200220 200220 Ppr262 263 Ppii2é4 oo 22266 B 267 vgooae @p279 Apc271 202020 @pn272 Je20200 g 273 2ap0ce Pp 200000 202000 @p 265 274 @p2275 Bp 2276 Bpl277 20300 Ppc301 22302 Bp.303 200000 2000280 eo0220 200200 200020 cpooeo Poo@20 200000 Peodan 2ood02 200200 Bpc304 Pp2305 Bp306 ?eo200 dec307 202310 2oe0g2 200000 Bpec3i12 02311 20200 2peleo Pp343 003020 8 L', 200020 4 d gPoee7 aRgae? aepea? 20@0@7 229207 pogap7 aogoa7 2200@7 52g2a7 2080227 2000287 o20287 220007 200227 2oeag7 g22pag7 pogae? go0ae7 B2egag7 20297 graag7 220087 00007 geeog7 2ep0Q7 220207 argaa7 edeeqa? pegoa7 o8e0g7 aeeoe? 2000827 200087 2eg2e7 goeoa7 aegea7 gPe2a7 gageg? oeo0@7 ghgea? gooee? gRRoR7 g2egae? ereeg? geooa7? gegee? 2000207 a%@146 FOROTS In the sequential access binary file, 128-word disk boundary and contains a C C the second 002 record (CONTINUE) LSCW. crosses LOOK AT A BINARY FILE AND SEE THE LOS!CAL SEGMENT CONTROL WORDS, OPEN(UN]T=4,MODE®/B]NARY’) [=5 WRITE(L) (1, J=1.,100) Ja7 WRITE(L) END (J,K=1.,100) 0.2 2012232 220145 Bp3R43 @022 Q022@P5 Pp2003 20204 02Q200p 200085 Q00020 2004025 Pp<046 Pp. 047 202200 20Q2Q5S Q2002002 2208eQ5 Ppl2@1 92002 P0.:905 Pp:>206 Q00002 290005 200222 290025 2J0@220 2P@225 202330 29Q@2@25 Pp:0037 0QC220 220205 2 11 Pp.)012 Pp 013 Pp.214 Pp’0215 Pp:P16 2Q2220 200920 0P3320 Q0020 0@2000 7200020 e 21p PR 017 Pg/028 0p’021 Pp:022 Pp 023 Pp:024 0202230 Pp D44 Pp. 045 Pp2050 Pp.054 Opo052 0@o2Q9 QQoQge 27@7Q5 J0¢22@ 020005 200220 2P00DS 2p062 Pp’*063 PR 064 QApplag 2PBOE5 200022 220805 0p2220 3028005 200205 27P02Q5 2KRAQ25 2P@2Q5 222005 290005 2022720 @70005 200220 Q702085 0290220 P20AQS 0’065 Pp’:066 Pp067 0000208 BPAE05 0Qe2ap 802095 207075 Bp*076 202008 200225 Pp:102 geggag B2Q0Q5 Q00005 2920005 290005 0p:054 99055 2p.:056 9p ;057 Pp 06@ Po.06)1 0p1032 Pg2033 2p2037 Z@gggs 0P000P QACOC25 0paPog 292905 0QP208 P22225 Ppp4p OQQ0220 200005 20042 0Q000Q 2ROOQ5 Ppi:P41 000002 292005 Pp2053 0QCQ02¢p 022000 200028 0OppR3p Pp034 Ppc035 Pp1P36 0200220 239Q2@5 O@02000 200005 220205 Pp 025 PR~ 226 2p0.9027 00..039 ggzg31 200002 200285 202022 220025 290020 290005 Pp:079 Pp~”271 Pp*R72 Ae2073 0PP202Q @P022g AP2000 292222 20222Q 200220 028205 2200095 Q200025 2PQ295 200085 Q20ROE5 2900325 O2Pe220 220005 0QR0pP 208005 C0pR29 220205 CQ00mg 0Q2229 0Q2020 7200000 2908295 028005 0PB2O5 2299285 Bfld074 @flaflflfi 297077 0o 170 2prioy 0C@2000 278725 002000 29PAQS 7209028 208205 2p 183 Pou1%4 BeslpS 990305 002020 20B2R3 002008 0VQ0DS5 002220 278025 200030 290025 2p203p 20005 022200 220005 the FOROTS @pvl106 Rez2127 Ggri11g Bgri111 Bp2112 227113 Pps114 Bp2iis Bedile @p2117 Bprl12p Gp121 @p2122 Pp2123 BRi124 PR212% 2p"126 22127 Pp2i3p 220134 Pp2132 Pp2133 2pv134 Bgri3s 222136 207137 B0i:14@ @141 02142 293143 Bp2144 Rg”145 Peir146 22147 2159 Ppii151 @pir152 222153 Bpir154 Be.15% PR2156 B@2157 /160 PR 2161 Pp1162 P21163 29,164 Bpl165 Bpz166 22167 Gpi:17@ Bp2171 P2@J172 2002292 200220 dpe0pe0 200225 300005 RARBRS 202000 R2Pa25 792000 pegaes5 200000 Q22095 2000200 e2@20e5 22200 PRE2R5 0ge0a0 e2gaes5 Pgoleo po@eas 290020 QPBeR5 200290 GeQOQs Jgoceo peeees 2oeeo0 200005 2peoeae 220205 2gedng RPQ0Q5 2e0o00 200205 0gspae 209205 2pe299 gopoos Peo0ae 222395 0ge000 e0Q22s Po0020 R2Q2ps 202020 ePgops 023220 g2gaes 292000 200025 20002392 pogogs Rpoeoo g2g0@5 200200 2200025 2poRe0 g2ga205 200000 0090¢5 200020 220005 203020 P2B146 201000 220032 -— Number of words to 200020 ergoe? next LSCW. 200000 P2B0p7 202900 2008@7 290200 opedeg opedeg 202020 2oedop 700000 200P0o0 2o2200 280200 2p00ep 200000 200000 0209280 200200 Pee2ap 200020 2p0020 2280027 200207 2gng? gegeg7 280027 220227 2¢Q02@7 200007 negag7 A0@2Q07 290007 Rogap7 p00ap7 200027 gogap?7 plgap7 2000207 27173 174 200000 0opRz0 Bp2176 202000 P2 Pai’r17s 222177 @pv200 Beray Ppc2n2 o203 o204 202205 Gp206 fl29207 Pp.21@ Rpr21} @p2212 202213 Bp2214 2p2215 Ppr216 Pp2217 2220 Bp2221 Bpr222 Pp222y Ppal24 Bp2225 Bpin226 22227 Pp223@ Pp2231 Pp2232 2p2233 Bp.2234 Pp2235 Bpz236 02237 Qo249 epr241 Bpr242 Ppr243 2244 Pp245 Bpl246 0pp229 203000 202200 0goooe Ppedep o0el00 020200 cogop0 200020 eo2000 Pgeeoo 202000 200020 2g0020 202000 2eeoee 2229002 0podae Pp0020 228220 eeed20 2geoge 200000 0g2d00 2000202 egeR30 0go0c0 Pao02e 222020 2oedoe 2po220 2000092 2002020 2ogedoe 202200 2000292 Po2020 2peooo igeeno 230220 Poodoe @pir247 000000 Ppr2sy 203920 @250 gpo2s2 Pp3253 PB0000 200220 Pagoap a0gag7 abpap7 pegoar 209007 gegea7 2281 14 -<—Continue LSCW. 200287 Q0oag?7 eRoeg? 2002087 220027 200027 g20a3p7 gogog7 gegog? 220087 ae00g7 Begog?7 2000207 popea? g2gag? 220007 222227 p20827 eo@ea7 20007 009227 20gop?7 Q20037 g00a337 eReaQ7 2027 200007 200227 gegeg? Q2pag?7 0202097 p2g2@7 groeg? 2200207 gopoe7 geceap7 gPeeg? 2o00e7 p2@oe? 200007 220907 222027 pAgRR7 2254 2255 7000292 Pp.1256 oooceo 22227 290000 eP@207 22ge0? Bp1257 220000 a2@ae7 FOROTS e 260 Ppr261 0p2262 0p2263 700020 200000 0gplo0 20020 Pp2264 2p265 BRc266 Pp 26867 22200 eo0220 2oo0oe 22279 2000080 20p2g0 2ge000 Bp2271 BB 272 0273 ‘oe0a0 0geRoo 2dg274 2ge000 B8ecd?5 202220 Bpin276 Image mode C C 2000020 pogap? gegag? e0p2R7 peeea’? grRRaa? 20007 4 o 22207 pagag7 oepgea? angea? 220007 geooe7 900327 Pe2303 0000020 Ppc300 Pp2301 092304 2000080 Pp2385 202000 22306 000000 002307 Gpc31p Pps311 Bp23312 PR2313 Pp 314 peeaR?7 files contain no Pp2302 0gP008 200000 200000 eopden 0pL277 LSCWs. ggoRoo 20000 202000 202007 2900027 200007 gl00a7 200007 goeoa? e2p0@7? @20007 g0g2007 g20207 g0gog? gogoe?7 20220 g2@ea? 6g3020 02147 ogolon You cannot backspace this LOOK AT AN IMAGE MODE FILE AND SEE NO LOGICAL SEGMENY CONTROL WORDS. OPEN(UNIT=1,MODE®’ [MAGE') [25 WRITE(1) (1, Js7 WRITE(1) END 22001 202220 280920 Pdp30@2 Cp2200 2p2003 2007080 p7004 2000020 Bpuoo5 o006 209000 200000 200000 2p7011 200000 Qg 000 e 20987 2pJ)01p 3012 file. 200000 200000 227013 ¢aedeo 292014 200200 222015 ogeoed Pp7@B16 0pedap 202017 Go0000 Pp2020 Gp2021 200030 200000 Bpre22 200029 Bp2023 Pgo2eo (JrK=1:.108) 220005 p2@205 p2geps 220005 0?0025 20005 270085 P0Q205 oRAgags5 202005 gog9ag5 200005 420005 200005 229805 a000e5 pogREs 220005 pPeoRs 229005 Apl024 2ero25 PpcR26 Pp3027 0p203P Pe2034 002032 200000 200000 000000 2go0ap 2pe0o0 Q00020 200000 PeUR33 220008 GeR034 23035 200020 BplB36 Bp2837 PPA04Q 002044 PprB42 2a2043 2pJ044 2008200 2000080 200000 200020 0g2020 2peR20 0gedoo 2000020 0puR4s egpegn PgR046 202020 2pag4ay 200200 429025 J20005 20goQ5 3090025 gooo05 adgaps 220005 200005 200005 APRRB5 P22005 220005 a2pags 2oPaes M20225 202005 3290025 022025 wepaas negeps FOROTS 204050 Bp205%Y Q052 202053 22054 2972055 PgJ05%56 Bp2057 Pp206P Pp2061 Pp’062 202063 PR 064 oceees aPeoas pe@eRs p2gB25 2@o0em J0P025 200000 2000225 200000 2RP0Qgs 2800200 200205 200920 229205 202000 aeeaogs 290002 pepags 202029 20000295 7o00nQ 280005 200000 220205 coedap 222005 BpR135 Pp2136 2p2155 200020 gondep 220200 2ooRag pr137 2o214¢9 Ppaidy Bp72142 282230 282090 200030 320200 200000 202143 000000 2000020 Bg2145 200000 Ppcidqs @p.2146 200020 700200 @pl2147 202020 Pplis5g@ 07151 TIILT. 202030 Pg¢R67 200020 2’Pegs Pe2152 PR %2153 Poci54 2p2071 A00220 200200 00220 2090@5 220095 Bpcis56 200200 2000025 peeres Gpr157 200000 Gpll6p 200220 Ppr161 200000 2162 208200 2272163 000020 22065 Zel066 0p°0270 2 072 22073 200000 2@’074 200020 2 078 2pr076 292320 2ee002 22077 og 100 2002420 24101 200000 297102 200000 2103 00020 PR:104 702030 2020020 Qe 105 Rar106 Pp107 G211 Pp2111 2p2112 0p2113 222114 02115 Ppr116 22147 Gp2120 Pp212% 200020 2022020 02000 200220 2000020 022000 2pedeo 2gedo0 2000020 2pa0ee 222000 P0e000 22124 202020 2gedng PpAi2s ogenao PpRi126 dgrizy 2pci3g P13y o00020 2pr133 0134 dooeeo 280020 2p000D eg2020 200000 200220 222166 Pp2167 208020 200000 300039 223020 2p.*172 22173 2000790 o174 202200 2e2175% 202220 Be2176 222177 o200 2p:201% 202020 P330730 QR 2203 207204 Bpr2a5 A222@5 200005 oPReRS5 202205 gegaegs 220205 gegees 202005 e2e2e5 p22oe5 p2p2Q5 22002025 Bp 206 Qp2207 200200 000020 2e20200 2@e00p 002030 2000230 202020 LITLY. 200000 Bpr2ig Ppr21iy 000220 2p0213 222214 200009 200000 2pi21s @p221i6 000200 200000 @pa2i2 D-11 2002030 G317 229285 g2gepgs 2pecoo g2200s5 232000 2o0030 0012022 2000205 200000 0p7164 202165 222170 2oodeg P@2122 Pui123 Ppr132 AePaps a22a@5% 20p00ag5 2002Ps 22225 200005 200005 pP@oR5 a000205 p20205 28gRes 029025 2PQ0205 2008025 pogoes5 200005 220025 2p8020 300000 20802230 0pP000 Pe2217 Ppi222@ 280000 2p2221% TTTLY. 282200 229005 2Rneees eogees aep2es pPeaRs 220205 2200025 320007 gReae7 020027 gRe2a7 geeea? eZgen? a20a@7 poegaa7 peoeg? 220007 202ep7 voQea7 200207 200007 020207 200007 eeena7 o2Qen7 229207 argen7 20geg7 gagne? 270007 290207 geege7 gepea7 32@0g7 220007 g20eg? 220027 270007 oPgag7 aog0Q7 Jegea? 200027 Aoag? 220227 222007 20297 greeg? 2Qeg7 22ge97 a002a7 Jegea7 220027 320207 FOROTS Pp0222 QppRod 22@2R7 Q200009 2022Q7 Pp7256 000020 Ppo224 Pp2225 0pl226 Bp2227 0Opolag 0@ePg@ 0200020 0@podee 00007 220007 2290027 292297 897257 0p26p d@7261 2p2262 202070 290207 200700 @92227 Q00020 0220007 909300 00007 0p2234 002232 9p2233 Ppr234 200235 202000 @QQ0R200 0@000Q 0000020 0Qe0go 202027 290007 200027 0ARAEG7 090087 Q0264 0pi26%5 Pp.266 0p~ 267 004279 Ppr237 9pe24p 00a230 020707 0p22pp 2920097 Bp 1242 202020 0p2223 9pr23p Ppve36 Baz24y Pp2243 Bp- 244 2p7245 Pplr246 0p 2247 902590 097251 Pg/252 902253 027254 D.5.3 0200002 000207 2000np 200307 892255 Pp1263 Pp271 @pr272 @p2273 0Qad00 220787 200207 ©00000 200027 0QQ200 220007 0pC0Q3p 290200y Ope023 200007 Opnopp 200327 200009 27077 000000 290Q027 0peoge 000087 000Q%p@ 290007 QJp00Qe alo2R7 PR1274 00000 2920007 2p0o03Q 290007 Pp2276¢ Qp00Pg 290007 Q000007 Apc275 2PQ000p 200007 Q2020 200207 @p2277 200007 290027 222070 Q0@Q2¢0 002020 202000 QQ0030 200000 202320 Pp230¢1 02302 P2.323 Pp/304 207305 007306 Ben3p7 Q00220 Q200000 202000 000007 002200 300000 02poPo0 200000 2280287 2370007 370027 2PQ@0Q7 220097 290007 220007 @202¢7 Mixed Mode Data 004309 000200 000007 220007 20Q02@7 Q2047827 220027 020087 000027 000007 Files FOROTS permits files containing both ASCII and binary data records to be read. Mixed files may be accessed in either sequential or random access mode. Logical ASCII and binary records have the same format as described 1in the ©preceding paragraphs. 1In random access mode, the record size must be large enough to contain the largest record, either ASCII or binary. FOROTS D.5.4 Image Files The image data transfer mode is a buffered mode in which data is transferred 1in a blocked format consisting of a word count located in the right half of the first data wurd of the buffer followed by the number of 36-bit data words. The devices that permit image data transfers and the form in which the data is read or written are: Device Card Data Punch In image mode, bytes. Each Since there (3 X 27) and the last word third one Reader an buffer for 81 are only contains only thrown card to punches EOF three 12-bit card column. to one columns in room 80 2 away. punched the last the columns bytes be of Image for a card, data; the causes mode each partial buffer on card output. and then card. All 12 punches in all 80 columns are packed into the buffer as 12-bit bytes. The first 12-bit byte contains column 1. The last word of the buffer contains columns 79 respectively. bytes, two Disk Tape and 80 Cards buffers. Data is written in the buffer. Magnetic contains corresponds there 1is CLOSE punches Card is byte exactly The each byte Forms Data appears appears on the Data on in disk as the left and middle are not split between exactly consists magnetic the of tape buffer. as it 36-bit appears words. exactly No as it processing or checksumming of any kind 1is performed by the service routine. The parity checking of the magnetic tape system is sufficient assurance that the data 1is <correct. All data, both binary and ASCII, is written with odd parity and at 800 bits per inch unless changed by the installation. Paper Tape Punch Binary words split eighth into hole control routine. by Paper Tape Reader the taken from six 6-bit punched 1in the bytes each or checksumming Data punched in paper Characters tape not reader having buffer is performed this mode is in the output are and punched with the frame. No format the same eighth hole by the I/O read back mode. punched are ignored. Characters are truncated to six bits and packed six to the word without further processing. This mode 1is useful for reading binary tapes having arbitrary blocking format. Plotter D.6 USING FOROTS 6-bit the plotter characters exactly per word are as they appear itself for use other than FORTRAN. general I/0 transmitted in the to buffer. FOROTS has programs Six been designed written programmers may in employ to lend languages FOROTS as a D-13 as an I/0 system Currently, system by for MACRO writing FOROTS simple MACRO calls that simulate the calls made to FOROTS by a FORTRAN to FOROTS are to routines that implement made calls The compiler. FORTRAN I/0 statements such as READ, WRITE, OPEN, CLOSE, RELEASE, FOROTS will provide automatic memory allocation, data conversion, buffering, and device interface operations to the MACRO user. FOROTS D.6.1 Entry Points FOROTS provides the following entry points for calls FORTRAN compiler or a non-FORTRAN program: Entry either Function Point ALCHN. Allocate software channels CLOSE. DBMS. DEC. Close a file DBMS interface DECODE routine Allocate dynamic core blocks ALCOR. De-allocate software channels De-allocate dynamic core blocks DECHN. DECOR. ENCODE routine ENC. Terminate program exeuction Input/Output list termination routine Position to the next record (RANDOM ACCESS) EXIT. FIN. FIND. Error FORER. processor Overlay interface FUNCT. Formatted input routine Input/Output list routine IN. IOLST. File utility processing routine MTOP. NLI. NLO. NAMELIST input routine NAMELIST output routine OuT. RELEA. RESET. RTB. Formatted output routine Release a device (CLOSE implied) Job initialization entry Binary input routine Open a file OPEN. | Trace subroutine calls Binary output routine TRACE. WTB. Calling D.6.2 from Sequences You must use the following general form for all calls made to FOROTS: MOVEI 16,ARGBLK PUSHJ 17,Entry (control Point is returned here) where: 1. formatted specifically ARGBLK is the address of a by needed information contains that block accomplish the desired operation. 2. Entry Point is an entry point identifier Paragraph desired D.6.1) FOROTS that routine. specifies the (see list FOROTS With three exceptions, all returns from FOROTS will be made to the program 1instruction immediately following the call (PUSHJ 17, entry point instruction). The exceptions are: 1. An error or WRITE 2. An end-of-file return to a statement WRITE statement END=option, 3. A fatal return to statement error that a specified ERR=option, returns statement to the number, number, monitor 1i.e., 1i.e., or to READ READ a or debug package. Paragraphs D.6.3.1 through D.6.3.11 give the MACRO calls and required argument block formats needed to initialize FOROTS and FOROTS I/O operations. Argument blocks conform to the subprogram calling convention described in Appendix C. However, there is one exception in dealing with the first word of an I/0 initialization call, i.e., WTB., ENC., RTW., etc., for a FORTRAN 1logical wunit number. In previous versions of FOROTS and FORTRAN-10, if the indirect bit was not set, the argument was immediate; 1if it was set to 1 (one), the argument was the address of the variable. The type field was always 0 (zero). With Version 4 of FORTRAN-10 and Version 4 of FOROTS this convention has been changed. If the type field of the first word of an 1I/0 initialization call for the FORTRAN logical unit number is 0 (zero), the argument 1s an immediate mode (18 bit) constant wherever possible. If the type field is integer, the argument is indirect (see Appendix C, Table C-1, Type 2). This exception should not cause any upward since all previously working programs will compatibility still function. it permits the feature with this convention 1is that construct to be correctly implemented: N=-4 READ 100 D.6.3 The !SET (N,100) FOR problems, An added following TERMINALS I,J FORMAT(2I5) MACRO Calls following for FOROTS paragraphs Functions describe the forms of the MACRO calls to FOROTS that are made by the FORTRAN-10 compiler. The calls described are 1identified according to the 1language statement that they implement. The following terms and abbreviations may be used in the description of the argument block (ARGBLK) of each call: — = pointer is the to calling n = count £ = FORMAT \Y = the list = an the second word to address pointed sequence.) of ASCII of an Input/Output the the argument block. argument ARGBLK characters, statement name in by address, array list, containing ASCII characters, (This the in FOROTS C = the OF d = statement FILE" the to which control statement "ERROR" to which = a NAMELIST name, R = a variable specifying access = 1list directed type = type specification of an "END control 1is transferred on an the 1logical record number for I/0; the a FORMAT statement variable or is not used, constant, 1is 0-8 9-12 13 14-17 18-35 -6 —| on mode, * where ARGBLK transferred condition, name random is condition, 0 Reserved Res;Lved type I X n 7 I X C 7 I X d type I X f type I X type I X Format D.6.3.1 I/O Statements, Sequential Access READ and WRITE statements for formatted operations and their calling sequences are: READ (u, f,END=c, MOVEI 16, ARGBLK PUSHJ 17, IN. ERR=d) list and WRITE (u,f,END=c, MOVEI 16, ARGBLK PUSHJ 17, OUT. ERR=d) list Size (in words) v Calling Sequences - The sequential data transfer FOROTS where ARGBLK 1is 0-8 9-12 13 14-17 18-35 -5 — 0 Reserved type I X u 7 I X C 7 I X d type I X f type I X Format Y Reserved The READ and WRITE statements for unformatted operations and their calling sequences are: READ (u,END=c, ERR=d) MOVEI 16, ARGBLK PUSHJ 17, RTB. Size (in sequential words) data transfer list and WRITE (u,END=c, where ERR=d) MOVEI 16, ARGBLK PUSHJ 17, WTB. ARGBLK list is 0-8 9-12 13 14-17 18-35 -3 — 0 Reserved type I X u l 7 I X C Reserved 7 I X d D.6.3.2 and NAMELIST WRITE operations I/O, statements and their READ (u,name) READ (u, name, Sequential for calling END=c, MOVEI 16, ARGBLK PUSHJ 17, NLI. sequences ERR=d) and WRITE (u, name) WRITE (u, name, MOVEI 16, ARGBLK PUSHJ 17, NLO. END=c, Access Calling NAMELIST-directed ERR=d) are: Sequences sequential - data The READ transfer FOROTS 1is where ARGBLK 0-8 9-12 13 14-17 18-35 -4 —»! 0 Reserved Reserved type I X u 7 I X C 7 I X d type I X NAMELIST table address first The The NAMELIST table is generated from the FORTRAN NAMELIST. following that are a number the table is the NAMELIST name; of word of 2-word entries for scalar variables, and a number of (N+3)-word N is the dimensionality of the where variables, array for entries array. The names you specify in the NAMELIST statement are stored, Each table. the 1in first form, arguments associated with the name; 1is name any - Address calculations used 1involve factors and offsets. to For The name argument list may (refer to the following . diagrams) Factoring element SIXBIT this argument list may be of length and is terminated by a zero entry. be in either a scalar or an array form D.6.3.3 Array Offsets and reference a gilven array in by a list of followed example: Array A DIMENSION A The size of each S1 = Ul-L1+1 S2 = U2-L2+1 is dimensioned (Ll1/U1,L2/02,L3/0U3,...Ln/Un) dimension is represented by etc. In order A the to calculate the address of an element referenced by (I1,12,1I3,...1In) following formula is used: A+(I1-L1)+(I2-L2)*S1+(I3-L3)*S2*S1l+...+(In-Ln)*S[n-1]*...*%S52*51 The terms and not on the element referenced are factored out depending on the dimensions to arrive at the of the array a single formula A+ (-L-L2*S1-L3*S2*S1...)+I1+I2*S1+I3*S2*S]l... The parenthesized part of precision array and it is this formula is the offset for referred to as the Array Offset. FOROTS For each dimension of a given array, there is a corresponding factor by which a subscript in that position will be multiplied. From the last expression, one can determine the factor for dimension n to be S[n-1]1*S[n-2]*...*S52*S1 For double-precision and complex arrays, the expression becomes A+2* (I1-L1)+42* (I2-L2)*S1+2*(I3-L3)*S2+S1+... Therefore, the array offset for a double-precision array 1is 2% (=L1-L2*S1-L3*S2*S1...) and the factor the nth dimension 1is for 2*S[n-1]1*S[n=-2]*...*S2*S1 The factor always array 1is for the always 1. 2. The SCALAR ENTRY 0. . in .8 a 9. first dimension factor for of a double-precision NAMELIST Table . .11 12. . .14|15. . .17 18. . .35 SIXBIT/SCALAR NAME/ 0 ARRAY ENTRY 0 in 0-8 a I X Scalar addr NAMELIST Table 9-11 12-14 15-17 18-35 SIXBIT/ARRAY NAME/ #DIMS ARRAY type array 1is the first dimension of a single-precision I X SIZE OFFSET I X Factor 1 I X Factor 2 I X Factor 3 I X Factor n FOROTS READ I/O Statements, Random Access Calling Sequences - The D.6.3.4 and operations transfer data access random for and WRITE statements their calling sequences are: (u#R,f,END=c, ERR=d) list (u#R,END=c, ERR=d) list READ READ MOVEI 16, ARGBLK PUSHJ 17, RTB. WRITE WRITE (u#R,f,END=c, ERR=d) list (u#R,END=c, ERR=d) list MOVEI 16, ARGBLK PUSHJ 17, WTB. and where ARGBLK 1is 9-12 0-8 13 18-35 14-17 -6 —»| 0 Reserved type I X u 7 I X C 7 I X d type I X f type I X format size 2 I X address of \ Reserved Record (in words) Number f and the format size in words are 0 if the I/0 statement 1is unformatted. D.6.3.5 Calling Sequences for Statements That Use Default Devices a reserved system The FORTRAN-10 statements that require the use of default device and their calling sequences are: Default ACCEPT f, list READ f, list REREAD f, list MOVEI 16, ARGBLK PUSHJ 17, IN. UNIT=-4 UNIT=-5 UNIT=-6 Device (TTY) (CDR) (REREAD) FOROTS where ARGBLK 1is 0-8 9-12 13 14-17 18-35 -5 —»| 0 Reserved Res;Lved 2 I X u 7 I X C 7 I X d type I X f type I X Default PRINT f, list PUNCH f, list TYPE f, list MOVEI 16, PUSHJ 17, where ARGBLK 0-8 Reserved Res;Lved (in words) Device UNIT=-3 (LPT) (PTP) (TTY) UNIT=-2 UNIT=-1 ARGBLK is 9-12 13 14-17 -5 —»| Format Size 18-35 0 2 I X u 7 I X C 7 I X d type I X f type I X format size (in words) FOROTS D.6.3.6 Statements to Position Magnetic Tape Units - The formatted unformatted FORTRAN-10 statements that may be used to control the and positioning of a magnetic tape device and their calling sequences are: Function FOROTS Code Statement) SKIPFILE (u) BACKFILE (u) BACKSPACE ENDFILE REWIND OO & N W (FORTRAN (u) (u) (u) SKIPRECORD UNLOAD (u) (u) CALL: MOVEI 16, ARGBLK PUSHJ 17, MTOP. where ARGBLK 1is 0-8 9-12 13 14-17 18-35 —-4 — 0 Reserved type I X u Y Reserved type I X FOROTS D.6.3.7 List Directed Input/Output Statements code - You may write READ and any form of a sequential Input/Output statement as a list-directed statement by replacing the referenced FORMAT statement number with an asterisk statements READ (*) . The 1list-directed forms and their calling sequences are: (u, *, END=c, MOVEI 16, ARGBLK PUSHJ 17, IN. WRITE (u, *, MOVEI 16, ARGBLK PUSHJ 17, OUT. ERR=d) list and END=c, ERR=4d) list of the | WRITE FOROTS where ARGBLK 1is 0-8 9-12 13 14-17 18-35 -5 — 0 Reserved 2 I X u 7 I X C 7 I X d 0 0 0 0 0 0 0 0 Y Reserved D.6.3.8 Input/Output Data Lists - The compiler generates a calling to the runtime system if an I/O list is defined for the READ sequence the <calling with The argument block associated or WRITE statement. the variables and arrays to be of addresses the contains sequence The general form of an I/O list transferred to or from an I/O buffer. calling sequence 1is: MOVEI 16, ARGBLK PUSHJ 17, IOLST. Any number of elements may be included in the ARGBLK. The end of the a zero entry or a call to the FIN. by specified 1is block argument entry. Mnemonic Name FOROTS DATA SLIST ELIST FIN The elements of an 1. Value 1 2 3 4 I/O list are: DATA The DATA element converts one single- or double-precision or for a READ form internal to external from item complex WRITE a for form external statement and from internal to statement. Each DATA element has the following format. 0-8 DATA | 9-12 13 14-17 18-35 type I X SCALAR ADDR FOROTS 2. SLIST The SLIST argument the following converts an entire array from internal to external form or vice versa, depending on the type of statement, i.e., READ or WRITE, involved. An SLIST table has form: 0-8 9-12 SLIST 0 For type | example, the 13 14-17 18-35 I X #ELEMENTS I X INCREMENT I X BASE ADDRI. sequence: DIMENSION A(100),B(100) READ (-, -)A or READ(-,-) (A(I),I=1,100) develops an !only when SLIST argument 0-8 of 9-12 the the /OPT switch is used form: 13 14-17 0 0 0 0 0 18-35 0 2 0 0 4 More the than 0 0 2 0 one increment DIMENSION WRITE develops base is a same. The 1 A 0 in a SLIST as B(100) of the ! only when the switch used 1s /OPT form: 9-12 13 14-17 18-35 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 144 1 A B 0 0 2 0 0 0 4 1long sequence (A(I),B(I),I=100) SLIST argument 0-8 144 address may appear the A(100), (-,-) 0 0 0 as FOROTS ELIST The SLIST format permits only a single increment for of arrays increments to be specified while the ELIST permits to be specified for different arrays. The of format the ELIST 0-8 a number different 1is 9-12 134 14-17 18-35 ELIST No. Elements to transfer Base 1 N increment ADDR increment Base For example, the DIMENSION FORTRAN sequence IC(6,100), IB(100) WRITE(-,-) produces the 2 N Base N ADDR (IB(I),IC(1,I),I=1,100) ELIST 0-8 9-12 13 14-17 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 4 The ADDR increment increment may be zero. This 18-35 144 1 1B 12 IC 0 could be produced by the sequence DIMENSION A(100) WRITE(-,-) (K,I=100) The zero may not argument block. 0-8 appear The lonly when as an ELIST for 9-12 the /OPT switch 1immediate is constant used 1in the previous example would 13 14-17 3 0 0 0 0 2 0 0 the be 18-35 144 Pointgr.to a word contailning a zero 0 type 0 0 K 4 0 0 0 0 FOROTS 4. FIN The end of an I/0 list is indicated by a <call to the FIN routine in the object time system. This call must be made a with after each I/0 initialization call, including cal l1s The FIN routine may be entered by an explicit I/0 list. null block. argument call or by an argument in the I/O list both calls are used, the explicit call has no meaning. FIN element has EXPLICIT PUSHJ the following format: If The CALL: 17, FIN. form and D.6.3.9 OPEN and CLOSE Statements, Calling Sequences - The calling sequences for the OPEN and CLOSE FORTRAN-10 statements are: OPEN STATEMENT CALL MOVEI 16, ARGBLK PUSHJ 17, OPEN. CLOSE STATEMENT CALL where MOVEI 16, ARGBLK PUSHJ 17, CLOSE. ARGBLK 1is 0-8 Negative the 9-12 13 14-17 18-35 of number of words 1in block not including this one. 0 0 2 I X u 0 7 I X C d 0 7 I X G type I X H G type I X H G type I X H G type I X H The G field (bits 0 through the argument name; the address which points to the 8) contains a 2-digit numeric that defines H field (bits 18 through 35) contains an value of the argument. FOROTS The numeric codes that may appear each identifies are: G Field Open 01 02 03 04 05 06 07 10 DIALOG ACCESS DEVICE BUFFER COUNT BLOCK SIZE FILENAME PROTECTION DIRECTORY D.6.3.10 Argument in G field G Field 12 13 14 15 16 22 23 24 Memory Allocation Routines called to allocate points, ALCOR. and de-allocation. the or de-allocate DECOR., that Open and the argument that Argument MODE FILE SIZE RECORD SIZE DISPOSE VERSION ASSOCIATE VARIABLE PARITY DENSITY - The memory management module 1is core blocks. There are two entry control memory allocation and Use the ALCOR. entry to allocate the number of words specified in the argument block wvariable. Upon return, AC 0 will contain either the address of the allocated core block or a -1 wvalue, which 1indicates that core 1is not available. The calling sequence for ALCOR. call is: where MOVEI 16, ARGBLK PUSHJ 17, ALCOR. ARGBLK 1s 0-8 9-12 13 14-17 18-35 -1 —»| 0 Reserved type I X Address of Number of Words Use the DECOR. entry to de-allocate a previously alliocated block memory; the argument variable must be loaded with the address of core block to be returned. Upon return AC 0 is set to 0. of the If the number of desired words is N, ALCOR. actually removes N+l words from free storage. The pointer returned points to the second word (word 1 as opposed to word 0) removed from free storage. The 0 word contains the negative value of N in its left half. This word is used by FOROTS to maintain linked lists of allocated (using ALCOR.) and free storage. The calling segquence MOVEI 16, ARGBLK PUSHJ 17, DECOR. for a DECOR. call is: FOROTS where ARGBLK 1is 0-8 9-12 13 14-17 18-35 -1 0 Pointer —»| Reserved type I X to word containing address of block to be returned Software Channel Allocation And De-allocation Routines - You D.6.3.11 in MACRO programs via calls to the may allocate software channels routine. routine and de-allocate them by calls to the DECHN. ALCHN. values are returned in AC O. next the or channel entry to allocate a particular Use the ALCHN. The channel to be allocated is passed to ALCHN. available channel. Zero is passed in the argument Dblock in the argument block variable. Allowed channels are variable to allocate the next available channel. or available, not is requested channel the 1If 1 through 17 (octal). all channels are in use, ALCHN. returns with a -1 in AC 0. returns, AC 0 contains the assigned number. The calling sequence of an ALCHN. MOVEI 16, ARGBLK PUSHJ 17, ALCHN. where ARGBLK routine 1is: 1is 9-12 0-8 13 18-35 14-17 -1 0 Pointer —»| In normal Reserved type I X to containing the or channel a word # zero channel. assigned previously entry to de-allocate a Use the DECHN. 1in the argument block channel to be released is passed to DECHN. The by assigned not was de-allocated be If the channel to variable. and thus cannot be de-assigned, AC 0 is set to -1 on return. ALCHN. The calling sequence MOVEI 16, ARGBLK PUSHJ 17, DECHN. for a DECHN. routine is: FOROTS where ARGBLK 1is 14-17 13 9-12 0-8 -1 18-35 0 X I type —»| Reserved D.7 FUNCTIONS TO FACILITATE OVERLAYS Pointer to containing word a the channel # to be released FOROTS provides a subroutine (FUNCT.) to serve as an interface with the LINK-10 overlay handler. This subroutine consists of a group of functions that allow the overlay handler to perform 1I/0, core management, and error message handling. These functions have only one entry point, FUNCT., and they are called by the sequence MOVEI PUSHJ 16, 17, ARGBLK FUNCT. The general form of the ARGBLK 1is 18-35 0-17 0 Negative of the ARGBLK —» number of words in block type function number error code type status type type type type argument 1 argument 2 argument 3 type argument n where type function number error code the FORTRAN argument type (see Appendix C) the number of one of the required functions the 3-letter mnemonic output by the object (See Table or [. %, ?, time system after D-1.) status undefined on the call and set with one of the values below. -1 0 l....n on the Function not implemented Successful return Specific error message return FOROTS Table Function Function Function Number Mnemonic 0 1 2 3 4 5 6 7 8 Numbers Function ILL GAD COR RAD GCH RCH GOT ROT RNT 9 D-1 and Function Codes Description Illegal function Allocates core from a specific address Allocates core from available core De-allocates core Gets or assigns an I/0 channel Releases an I1/0 channel Allocates core from FOROTS De-allocates core from FOROTS Returns the initial runtime from FOROTS IFS Returns initial runtime file spec. from FOROTS 10 CBC FUNCTION 0 (ILL) ignored, and the FUNCTION 1 address. The - This function function always (GAD) - This arguments The arg 1 address arg 2 number return 0 1 2 Cuts back core statuses is illegal. The argument returns a status of -1. function allocates are: at of which words if possible to of begin core core to core a 1is specific allocation allocate are: core allocated (arg 1 and not enough core available cannot from block allocate core at 2 unchanged) in system (arg 1 specified address and arg (arg 1 2 unchanged) and arg 2 unchanged) 3 illegal (arg FUNCTION 2 arguments The 1 arguments and (COR) - 2 This function 1 undefined 2 size returned core of core statuses are: allocated (arg allocated 3 address size allocates to 1s greater than 256K) core from any address. The 2 allocate unchanged, enough core available in illegal argument (i.e., size 3 address. (RAD) The - This function arguments arg 1 address arg 2 number returned arg 1 beginning address of the core) not FUNCTION + are: arg 1 (i.e., unchanged) arg 0 The arg statuses 1s (arg 2 unchanged) greater than 256K) de-allocates core at the specified and the size are: of of core to be de-allocated words to be de-allocated are: 0 core de-allocated 1l core cannot 3 illegal argument greater than be system de-allocated (i.e., both 256K) D-30 the address are FOROTS - This function assigns an I/O channel. (GCH) FUNCTION 4 The argument is: arg The undefined 1 statuses returned are: 0 I/0 channel assigned (arg 1 channel number) 1 no I/0 channels available FUNCTION argument (RCH) 5 1is: function releases I/0 an channel. The I1/0 channel number to be released arg 1 The - This statuses returned 0 channel 1 invalid are: released channel number FUNCTION 6 (GOT) - This function gets core from the object time system The list. arg arg The arguments are: address at which to allocate core number of words of core to allocate 1 2 statuses are: 0 core allocated (arg returned 1 and arg 2 unchanged) 1 not enough core available in system (arg 1 and arg 2 unchanged) 2 arg and 1 (arg 2 cannot allocate core at specified address unchanged) 3 illegal t (s) argumen if the object time in that This function differs from function 1 free core lists, then function 1 is used to allocate two system has 1I/O space for links, and this function is used to allocate space for Function 1 uses the free core list for LINK-10, and function buffers. 6 uses the list for the object time system. FUNCTION 7 (ROT) - This function The system. returns core to the object time address of core to be de-allocated and returned size of core to be de-allocated and returned arg 1 arqg 2 The are: arguments returned statuses are: 0 core de-allocated 1 core cannot be de-allocated 3 illegal FUNCTION 8 argument (RNT) - This function returns the initial runtime from object time system. arg 1 The returned 0 always The argument 1is: undefined status 1is: (arg 1 - runtime from the object time system) This function is used only if the user desires a log file. the FOROTS FUNCTION 9(IFS) - This function returns the initial runtime file specification from the object time system. The specification 1is obtained from accumulators 0, 7, and 11 after the initial RUN command. The arguments arg arg arg The 1 2 3 are: undefined undefined undefined returned status is: 0 always (arg 1 - device from from accumulator 0, and arg 3 This function tells the initial RUN command. accumulator - directory overlay handler which 11, arg 2 - filename from accumulator 7) file to read after FUNCTION 10 (CBC) - This function cuts back core if possible and used to reduce the size of the user job. There are no arguments. The returned 0 D.8 status the 1is 1is: always LOGICAL/PHYSICAL DEVICE ASSIGNMENTS You make FORTRAN logical and physical device assignments at run time, or standard system assignments are made according to a FOROTS Device Table, 1.e., DEVTB. Table D-2 shows the standard assignments contained by the Device Table. FOROTS Table Device/Function D-2 FORTRAN Device FORTRAN Logical Table Use Unit Number REREAD CDR TTY LPT PTP TTY 0 DSK CDR -6 -5 -4 -3 -2 -1 00 01 REREAD statement READ statement ACCEPT statement PRINT statement PUNCH statement TYPE statement ILLEGAL DISK 02 Card CTY TTY PTR PTP DIS DTA1 04 05 06 07 08 09 Console Teletype User's Teletype Paper Tape Reader Paper Tape Punch Display DECtape DTA2 DTA3 DTA4 DTAS DTA6 DTA7 10 11 12 13 14 15 DECtape DECtape DECtape DECtape DECtape DECtape DSK DSK 23 24 DISK DISK DEV2 DEV3 DEV4 DEVS5 26 27 28 29 DEV39 63 LPT MTAOQ MTA] MTA2 FORTR DSK DSK DSK DEV1 03 16 17 18 19 20 21 22 25 Line Reader Printer Magnetic Tape Magnetic Tape Magnetic Tape Assignable Device DISK DISK DISK Assignable Devices APPENDIX E FORDDT FORDDT is an interactive program used to debug FORTRAN programs and control their execution. By using the symbols created by the FORTRAN compiler, FORDDT allows you to examine and modify the data and FORMAT statements in your program, set breakpoints at any executable statement or routine, trace your program statement-by-statement, and make use of many other debugging techniques described in this appendix. Table E-1 lists all the commands available Table Table of Access the FORDDT. Purpose Commands Modifies data locations. TYPE Displays data locations. Commands GROUP Defines MODE Specifies format OPEN Accesses program PAUSE Places REMOVE Removes pause DIMENSION Defines indirect dimensions pause lists of arrays if /DEBUG: B-2.) symbol statements. table. requests. of arrays for (Unnecessary was dimensions for TYPE requests. /DEBUG:DIMENSIONS Defines for typeout. unit references. DOUBLE of E-1 ACCEPT Declarative user Commands Command Data to FORDDT used. of was if See Table double-precision references. DIMENSIONS FORDDT (Unnecessary used. See Table FORDDT Table E-1 (Cont.) Table of Commands Command Control Purpose Commands START Begins execution of FORTRAN program. CONTINUE Continues execution after a pause. GOTO Transfers control within the Traces execution of the program. NEXT Terminates program and returns STOP monitor to mode. DDT Enters DDT (if DDT 1is loaded). Commands Other LOCATE Lists program unit names in which symbol STRACE is Displays program WHAT E.1 to some program statement open program unit. routine INPUT a given Dbacktrace of current DIMENSION, GROUP, status. Displays PAUSE defined. current information. and FORMAT FORDDT commands are made up of alphabetic FORTRAN-like identifiers and need consist of only those characters required to make the command unique. If you wish to specify parameters, a space or tab is required following the command name. FORDDT expects a parameter if a delimiter (i.e., space or tab) is found. Comments may be appended to command lines by preceding E.1l.1 Variables the comment with and an !. Arrays FORDDT allows you to access and modify the data 1locations in your program by using standard FORTRAN-10 symbolic names. Variables are specified simply by name. Array elements are specified 1in the following name format: (Sl1,...,5Sn) where name (Sl,...,5n) a FORTRAN variable or array name the subscripts of the particular array. You may reference an entire array simply by 1its unsubscripted name; you may specify a range of array elements by inputting the first and last array elements of the desired range, separated by a dash(-). E-2 FORDDT Examples ALPHA ALPHA (7) ALPHA (PI) ALPHA (2) -ALPHA (5) E.1.2 Numeric FORDDT Conventions accepts FORTRAN-10 optionally input signed numeric 1. INTEGER - A string of decimal digits. 2. FLOATING-POINT of 1n the standard - A string decimal digits optionally including a decimal point. Standard engineering double-precision exponent formats are also accepted. 3. OCTAL - A string of octal digits double 4. E.1.3 data formats: quote optionally preceded by a ("). COMPLEX - An ordered pair of 1integer or real separated by a comma and enclosed in parentheses. Statement and Labels and Source constants Line Numbers FORTRAN statement labels are input and output by straightforward However, source line numbers must be 1i.e., 1234. reference, numeric This mandatory input to FORDDT with a number sign (#) preceding them. sign distinguishes statement labels from source line numbers. E.2 NEW USER TUTORIAL a as below described commands The new FORDDT user can rely on the These commands are easy to programs. FORTRAN debugging for basis understand E.2.1 and Basic apply. Commands The easiest method of loading and starting FORDDT is: .DEBUG filename.ext FORDDT will respond ENTERING (DEBUG)/F10 with FORDDT >> Just as an asterisk angle brackets (*) signify signifies FORTRAN-10's readiness, the two that FORDDT is awaiting one of the following commands: OPEN Makes available to FORDDT the symbol names 1in a When a particular program unit of the FORTRAN program. program unit symbol table E-3 1is opened, the previously FORDDT open program unit is automatically closed. When FORDDT is entered, the MAIN program is automatically opened. The command format is: OPEN name This will open the particular program unit named allow all wvariables within that subprogram to accessible to FORDDT. and be OPEN START with no arguments will main program unit. reopen Starts your The command the main program at format is: the symbol program table of the entry point. files command to be format START STOP Terminates program execution, causes closed, and exits to the monitor. all The is: STOP MODE Defines the display format for succeeding FORDDT TYPE commands. You need type only the first character of the mode to identify it to FORDDT. The modes are: Mode Meaning o OH+HMT OO Y ASCII (left-justified) COMPLEX DOUBLE-PRECISION FLOATING-POINT INTEGER OCTAL RASCII (right-justified) Unless the MODE command is mode is the floating-point The command MODE format given, the format. default typeout is: 1list where list contains one or more of the mode identifiers separated by commas. The current setting can be changed by issuing another MODE command. If more than one mode 1s given, the wvalues are typed out in the order: F,D,C,I1,0,A,R MODE with no setting TYPE Allows arguments will reset FORDDT of floating-point format. you to display locations. They formatted according The command TYPE format list the contents of to one are displayed on to the last MODE is: the or original more data your terminal specification. F'ORDDT where list may contain one or more array elements, or array element For example: commas. TYPE I, ALPHA, BETA(2),J(3)-J(5) Each item will be displayed active typeout modes as set ACCEPT arrays, variables, ranges separated by in by each o0of the last the MODE currently command. Allows vyou to change the contents of a FORTRAN variable, array, array element, or array element range. The command format is: ACCEPT name/mode value where name the name of element, modified. or the If unsubscripted wvariable, array array, element the field array name array range to an element contailns or be an range, 1t causes all the elements to be set to the given value (see special case for ASCII in Section F.6). mode the format of the data wvalue to be entered. If given, it must be preceded by a slash (/) and 1immediately follow the name. (Note that /mode does not apply to FORMAT modification.) value the new value correspond in Data to be format assigned. It must to the given mode. Modes You need type only the first character of a data mode to 1identify 1t to FORDDT. If not specified, the default mode is REAL. The following 1input modes are available: Mode Meaning A C D ASCII(left-justified) COMPLEX DOUBLE-PRECISION /F0O0O/ (l.25,-78.E+9) 123.4567890 F REAL 123.45678 I O R S INTEGER OCTAL RASCII(right-justified) SYMBOLIC 1234567890 76543210 \BAR\ PSI(2,4) An example ACCEPT This with of the ALPHA changes the the default Example ACCEPT command format is: 100.6 value input of the variable ALPHA to 100.6 mode of REAL, since mode was not specified. PAUSE Allows you to set a breakpoint at any 1label, 1line number, or subroutine entry in your program. You may set up to ten pauses at one time. When one of these pauses is encountered, execution of the FORTRAN program E-5 FORDDT is suspended and control is transferred to Also, when a pause 1is encountered, the symbol that subprogram is automatically opened. The format FORDDT. table of command is: PAUSE P where P is a statement label number, 1line for example, routine entry voint name; PAUSE number, or 100 will cause a breakpoint at statement label currently open program unit. 100 Note that subprogram parameter be displayed when a pause 1is values will encountered at a of the subprogram entry point. CONTINUE Allows the program to resume execution after a FORDDT pause. After a CONTINUE 1is executed, the program either runs to completion, or it runs until another pause is encountered. If you include a value with this occurrence command, the program will run until the nth different pause is a until or pause given the of The command encountered. formats are: CONTINUE or CONTINUE n Example will of REMOVE CONTINUE 15 continue execution the until the fifteenth occurrence pause. Used to remove those pauses from the program previously set up by the PAUSE command. The command format is REMOVE where P pause was is P the number set, 1.e., REMOVE 100 will remove the pause Note that pauses; REMOVE with therefore, of the at statement no statement label label arguments where the remove all 100. will no abbreviation of the command allowed in this instance. This precaution prevents accidental removal of all pauses. WHAT Displays on your terminal the open program unit and any settings. The command format WHAT name of currently 1is: the is the currently active pause FORDDT E.3 FORDDT AND THE Most facilities FORDDT however, 1if program, the features; a of FORTRAN-10/DEBUG FORTRAN available, and several are available without of other the commands 1if you which wish will be /DEBUG when compiling will not be restricted. FORTRAN-10 to compile extra information B, Using the Comoiler, for a complete The additional features include: will generate to the REL file for all arrays The dimension information will FORDDT FORTRAN-10 not use the /DEBUG switch features (NEXT command) /DEBUG:DIMENSIONS, command. dimension the you do trace Using the /DEBUG switch tells for FORDDT. (See Appendix description of each feature.) 1. SWITCH to dimension information dimensioned in the subprogram. automatically be available to reference an array This feature eliminates 1information for FORDDT in a TYPE the need by using or to the ACCEPT specify DIMENSION command. /DEBUG:LABELS, which executable source line labels are FORDDT commands This generated, switch allocated the end will for of and also a generate labels form "line-number they may and GOTO. generate FORMAT the "format-label display PAUSE will in the If modify used labels statement statement. F". be they FORMAT arguments at so These are as the that via you the TYPE the 1location can have will every these with last FORDDT 1labels generated, statements for L". If detect the be form able to and ACCEPT commands. Note the that the :LABELS switch i1s automatically activated with :TRACE switch, since labels are needed to accomplish the trace features. /DEBUG:TRACE, which before for the executable statement. This command NEXT to function. Note on that a if single FORDDT This each trace more also than input reference applies will one line, and to generate FORTRAN only the a label the switch. /DEBUG:INDEX, which will force respective data location as to switch statement first line-number :LABELS reference has 1is FOKDDT required been statement placed will associated have with a 1it. the compiler to store 1in 1its well as a register the index variable of all DO loops at the beginning of each 1loop iteration. You will then be able to examine DO loops by using FORDDT. If you modify a DO loop index using FORDDT, it will not affect the number of 1loop iterations because a separate loop count is used. (See Section D.1l.5.) Note that commands E.4 LOADING 1. The the AND this in switch has no direct STARTING on any of the FORDDT simplest method of loading following command string: .DEBUG affect FORDDT. and filename.ext (DEBUG) /F10 E-7 starting FORDDT 1is with FORDDT FORDDT responds ENTERING with FORDDT > > The angle command, readiness. brackets Jjust as indicate that an asterisk FORDDT is ready (*) signifies ~ to receive a FORTRAN-10's The DEBUG command to the monitor will also load DDT (standard system debugging program). DDT can be used or ignored, but it does require an extra 2K (octal) of core. 2. You may wish to 1load vyour compiled program and FORDDT directly with the LINK-10 loader. (Loading with LINK-10 was accomplished implicitly in the previous command string.) The command sequence 1s as follows: .R LINK *filename.ext *filename.ext /DEB/G /DEB: FORDDT (loads (loads /G DDT) FORDDT) FORTRA *filename.ext /DEB: (DDT, FORDDT )/G loads both and FORDDT FORTRA DDT If the total FORTRAN program consists of many subroutines and insufficient core 1is available to complete 1loading with symbols, it is possible to 1load with symbols just those sections expected to give trouble. The remaining routines need E.5 SCOPE OF Each program FORDDT, vyou not be NAME loaded. AND LABEL REFERENCES unit has its own symbol automatically open the table. symbol When table you initially enter of the main program. All references to names or labels via FORDDT must be made with respect to the currently open symbol table. If vyou have given the main program a name other than MAIN by using the PROGRAM statement (see Chapter 5, Section 5.2), FORDDT will ask for the defined program name. After you enter the program name, FORDDT will open the appropriate symbol table. At this point, symbol tables in programs other than the main program can be opened by using the OPEN command. (See Section F.5.) References to statement labels, 1line numbers, FORMAT statements, variables, and arrays must have 1labels that are defined in the currently open symbol table. However, FORDDT will accept variable and array references outside the currently open symool table, providing the name 1is unique with respect to all program units in the given load module. E.6 FORDDT COMMANDS This section gives The commands are a detailed given in description alphabetical of order. all commands 1in FORDDT. FORDDT ACCEPT Allows yocu array, to change array statement. contents array command format The ACCEPT the element, name/mode of a FORTRAN element variable, range, or FORMAT is: value where name = the wvariable element array, range, or array FORMAT element, array statement to be modified. mode = The the format mode (/) and of the data value to be entered. keyword must be preceded by a slash immediately Intervening that follow blanks are does not /mode not the name. allowed. apply (Note to FORMAT modification.) value = the new value to be assigned. the input value specified mode. DATA LOCATION Data The following data Mode must The format correspond Modes modes are accepted: Meaning Example ASCII C COMPLEX (1.25,-78.E+9) D DOUBLE-PRECISION 123.4567890 F REAL 123.45678 I INTEGER 1234567890 0 OCTAL R RASCII S SYMBOLIC not (left-justified) the 76543210 \BAR\ PSI(2,4) specified, data /FO0/ (right-justified) the Two-Word For default mode is REAL. Values modes ASCII, RASCII, OCTAL, FORDDT will accept a "/LONG" modifier on This modifier indicates that the variable are to be of the MODIFICATION A If to interpreted as two words and SYMBOLIC, the mode switch. and the value long. Example ACCEPT VAR/RASCII/LONG will assume that VAR l0-character literal 1s two words into it. Initialization If the array the name field name or array value. or the a of '1234567890" an range of long and store the given Arrays ACCEPT contains an of array elements, specified range will be unsubscripted all set to elements the of given FORDDT Example ACCEPT ARRAY/F 1.0 or ACCEPT ARRAY (5)-ARRAY(10)/F Note that this applies only Long Literals 1.0 to modes other than ASCII and RASCITI. When the wvalue field of an ACCEPT contains an unsubscripted array name or range of array elements, and the specified data mode is ASCII or RASCII, the wvalue field 1s expvpected to <contain a long 1literal string. ACCEPT will store the string linearly into the array or array range. If the array is not filled, the remainder of the array or range will be set to zero. If the literal is too long the remaining characters will be ignored. Example ACCEPT ARRAY/RASCII FORMAT 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' STATEMENT MODIFICATION When the name field of an ACCEPT contains a label, FORDDT expects this label to be a FORMAT statement label and that the value field contains a new FORMAT specification. Example ACCEPT The new 10 (1HO,F10.2,3(I2)) specification originally allocated remainder of the area is cannot be longer than the space to the FORMAT by the compiler. The is cleared if the new specification shorter. Note that FOROTS performs some encoding of FORMAT statements when it processes them for the first time. If any 1/0 statement referencing the given FORMAT has been executed, the FORTRAN program has to be restarted (re-initializing FOROTS). CONTINUE Allows the program to resume execution after a FORDDT pause. After a CONTINUE is executed, the program either runs to completion or until another pause 1is encountered. The command format is: CONTINUE n where the n is optional and, if omitted, will be assumed to be one. If a value is provided, it may be a numeric constant or program variable, but it will be treated as an integer. When the value n is specified, the program will continue execution until the nth occurrence of this pause. For will example, CONTINUE 20 continue execution pause. after the 20th occurrence of the FORDDT DDT Transfers control system debugging opened by possible .F10 1s FOROTS so The the are that the FORCDT. of program ©program (if unaffected program to and execution global symbol command format DDT, loaded). wused Any the standard files currently return to may be to return T[FORDDT is resumed. control to is: .F10$G where be §$ 1in represents altmode the condition as image DDT. modified DIMENSION Sets your the access same core user-defined purposes. those declared will allow scope than warning you that is where For S is the of an dimensions compiler to redimension of Your before dimensions the given. DIMENSION escape. with These to or in array need the an program unless source array the source program. The command format have this have FORDDT agree code. to If for not will you with FORDDT a is larger done, a is: S name of the array specified. example: DIMENSION FORDDT will is redefined The command ALPHA(7,5/6,10) remember or the dimensions of the array until removed. it DIMENSION will give a full for all arrays. DIMENSION will display list of all the user-defined ALPHA the current information for only. DIMENSION will remove array the array any user defined array information ALPHA. elements name ALPHA ALPHA/REMOVE Arrays, Array dimensions Array are Elements, specified in and the for the Ranges following format: ([dl1/d2,...](S1l,...) where name the [eeo] optional, This name of form DIMENSION the and 1is array contains dimension equivalent statement. 1in information. effect to the FORDDT («..) = the subscripts of the specific element desired. The entire array 1is referenced simply by its unsubscripted name. A range of array elements is specified by inputting the first and last array elements of the desired range separated by a dash (-) (A(5)-A(10)). DOUBLE Defines the dimensions of a double-precision array. The result of this command 1is the same as for the DIMENSION command except that the array so dimensioned 1is understood by FORDDT to be an array with word entries and, therefore, reserves twice the space. The command format is: DOUBLE GOTO arrayname Allows you to continue your program from a point other than the one at which it last paused. The GOTO allows you to continue at a statement label or code-generating source line number provided that the /DEBUG:LABELS switch has been used or the contents of a symbol previously ASSIGNed during the program execution. Note that the program must be STARTed before this command can be used, and also note that a GOTO is not allowed after the "C"C REENTER sequence. (See F.6.) The command GOTO GROUP format is: n Sets up a string of text for input to a TYPE command. You can store TYPE statements as a 1list of wvariables identified by the numbers 1 through 8. This feature eliminates the need to retype the same list of variables each time you wish to examine the same group. Refer to the TYPE command for the proper format of the 1list. The command GROUP format n is: list where n = the group number list = a string of TYPE future accessing 1-8 statements to of the current be <called 1in group number. GROUP with no current arguments contents GROUP will type will of all cause the FORDDT that type out the n out the contents of the requested. Note to groups one group may call another. particular group FORDDT LOCATE Lists the program unit names in which a given symbol 1is defined. This 1s useful when the variable you wish to locate is not in the currently open program unit and 1is defined in more than one program unit. The command format is: LOCATE where MODE n may number, or Defines the n be any FORMAT FORTRAN variable, statement number. default formats of array, typeout from initial default mode, variables floating-point format. 1If you wish to modes, the command format is: MODE 1label, FORDDT. 1list Mode the mode Meaning P> OHMOO TM FLOATING-POINT DOUBLE-PRECISION COMPLEX INTEGER OCTAL ASCII (left-justified) RASCII (right-justified) typical command MODE NEXT In will be typed 1in change the typeout where list contains one or more of the modes 1in following table. (Only the first character of each need be typed to identifyv it to FORDDT.) A 1line string might be: A,I,OCTAL Allows you to cause FORDDT ¢to trace source lines, statement 1labels, and entry point names during execution of your program. This command will only provide trace facilities if the program was compiled with the /DEBUG switch. If this switch was not used, command format will act as a CONTINUE command. FORTRAN-10 the NEXT The command is: NEXT n/sw where a program variable n or integer numeric value and SwW one of the /S= /L= /E= The default trace. The The 20/L switches statement label source line entry point starting value default switch command NEXT following of is n is /L. 1, a single statement FORDDT will trace numbers or the execution of until another pause Note that if no argument given will be used. For NEXT the next 20 source is encountered. 1s specified, example, the 1last 1line argument /E will change the tracing mode to trace only subprogram entries using the numeric argument previously supplied. OPEN Allows you to open a particular program unit of the loaded program so that the wvariables will be accessible to FORDDT. Any previously opened program unit 1s closed automatically when a new one 1s opened. Only global symbols, symbols in the currently open unit, and unique locals are available at any one time. Note that starting FORDDT automatically opens the MAIN program. The command format 1is: OPEN name where name is the subprogram name. will reopen the MAIN program. OPEN with no arguments If the PROGRAM statement was used in the FORTRAN program, the name supplied by you will be requested upon entering FORDDT. PAUSE Allows you to place a pause request at a statement number, source line number, or subroutine entry point. Up to ten pauses may be set at any one time. When a pause 1is encountered, execution 1is suspended at that point and control is returned to FORDDT. Also, when a pause 1is encountered, the symbol table of that subprogram 1is automatically opened. The command formats include: PAUSE P PAUSE P PAUSE PAUSE PAUSE PAUSE P IF condition P TYPING /g P AFTER n TYPING /g P IF condition TYPING AFTER n /g where P n = = the an point where the pause integer constant or is requested, wvariable or array element g will to = 100 set pause be after group PAUSE reaching will a a number at statement suspended, 100 in PAUSE #245 cause a and the cause to be execution entered on MAX(5) to occur encountering specified by abbreviated. 100, FORDDT program. AFTER pause label <cause this MAX(5). E-14 Note at source point that the line number AFTER may number of not 245 times be FORDDT PAUSE If the IF variable 2.5E-3, be DELTA the LIMIT(3,1) pause request abbreviated, connectives PAUSE will the are 505 request 1label LIMIT(3,1).GT.2.5E-3 but all the PAUSE than granted. usual the The IF FORTRAN pause to be and the made at the wvariables be When The TYPING LINE#24 AFTER displayed the TYPING control by can typing Note that sequence, specification 16 TYPING may not REMOVE Removes format the is: used on requests be 3 with to the or the FORDDT after 16 of group 3 at PAUSE the command, next typeout terminal. remain command, previously REMOVE For is transferred START of be time. character pause a every option be any not logical first occurrence in group 5 will will place a request at source line number 24 (octal) times through; however, the contents will value may /5 505, displayed. abbreviated. greater be allowed. TYPING a is will after a a control requested control C C seguence. START ©pauses. REENTER The command P example, will will REMOVE L#123 remove a REMOVE ALPHA remove a REMOVE with requests, allowed. pause pause no at program at the arguments and, This source subroutine will line number entry remove to ALPHA. all in this case, no abbreviation prevents the unintentional 123. vyour pause of REMOVE removal is of pauses. START Starts your program entry point. The at the command normal format FORTRAN main program is: START STOP Terminates the files, and command format program, causes an requests exit FOROTS to the to close monitor. all open The usual is: STOP STOP/RETURN will allow a return to devices or closing files monitor so that a mode without CONTINUE can releasing be issued. FORDDT STRACE Displays a subprogram level backtrace of of the program. The command format is: the current state STRACE TYPE Causes one or more FORTRAN defined array elements to be displayed command format is: TYPE by be one or numbers. commas, more variable or array references These specifications must bDe and group numbers must be a slash (/). The command with no arguments last argument list submitted to FORDDT. An or The list where list may and/or group separated variables, arrays, on your terminal. array element range <can also be preceded will use specified. by the For example: TYPE PI(5)-PI(13) will display the values from If an unsubscripted array array will be typed. PI(5) to PI(13) name is specified, There of choosing MODE command. in are several conjunction l. If methods with you do the not floating-point 2. 3. specify form. You can specify a described in this You by in a the form format, format wvia appendix. the 1inclusive. the entire of the typeout defaultis MODE command can change the format previously designated the MODE command by including print modifiers the TYPE or GROUP string. The print modifiers are: /BA./C,/D,/F,/1,/0,/R The first print modifier specified in a string of variables determines the mode for the entire string unless another mode is placed directly to the right of a particular variable. For example, in TYPE the /IK,L/O,M,N/A,/2 typeout specified. mode is integer until another mode 1is Therefore, 'M,and/2 = Integer OCTAL = WHAT Displays the format 1is: WHAT ASCII information saved by FORDDT. The command FORDDT E.7 If ENVIRONMENT a program CONTROL enters "C"C REENTER pause at the an indefinite sequence. point of This reentry loop, and will allow program. Most commands can GOTO, routines any of state you can recover cause to control be used STRACE, once TYPE, and the program ACCEPT cause has been typing a simulate a run-away reentered; of control to external to FORDDT. No guarantee can be made to ensure that these commands following a “C"C REENTER sequence will not the user before profile. any of The these program four must commands be returned can be 1 restore command can be issued to FORTRAN-10/0PTIMIZE should compiled never with the was a 1In stable order next used, to 1label a NEXT integrity. SWITCH attempt the program to issued. you should set a pause at If the /DEBUG:TRACE switch You your transfer restore program integrity, and then CONTINUE to it. E.8 by FORDDT to | however, destroy you action to use FORDDT /OPTIMIZE with switch. a program The global that has optimizer been causes variables to be kept in ACs. For this reason, attempts to examine or modify variables in optimized programs will not work. Also, since the optimizer moves statements around in your program, attempts to trace program .9 flow FORDDT will FORDDT responds error been The format to great confusion. MESSAGES Fatal has lead with two messages terminated. of ?FDTXXX these levels of indicate Warning messages messages that the messages - fatal processing provide error of a helpful and warning. given command information. is: text or 3FDTXXX text where ? = % = warning fatal FDT = FORDDT XXX = 3-letter text = mnemonic for explanation of error Square brackets output on Fatal The mnemonic the ([ ]) in this error section message signify variables and terminal. are not Errors fatal the wuser order. errors BDF [symbol] BOI BAD OCTAL An illegal in terminal the and IS following on list listings. UNDEFINED OR IS are each They are MULTIPLY preceded listed in by ?FDT on alphabetical DEFINED OUTPUT character was detected in an octal input value. FORDDT CCN CANNOT CONTINUE Pause has been placed on causing FORDDT to 1loop; FORTRAN-10 CFO CORE FILE compiled programs. OVERFLOW The storage area for CNU [name] COMMAND THE some form of skip instruction should never be encountered in GROUP text has been exhausted. IS NOT UNIQUE More letters of the command are required to CSH CANNOT START DIMENSION TABLE is not an FORMAT acceptable FORTRAN-10 OVERFLOW FORDDT does not have the space to dimensions until some are removed. FCX it HERE The specified entry point main program entry point. DTO distinguish commands. other the from CAPACITY record any more array EXCEEDED An attempt was made to specify a FORMAT statement requiring more space than was originally allocated by FORTRAN-10. FNI FORMAL INITIALIZED NOT Reference to a FORMAL parameter never FNR was IS A FORMAL AND MAY NOT BE RE-DEFINED [array name] FORMAL parameters may IAF of some subprogram that executed. ILLEGAL ARGUMENT not be DIMENSIONed. FORMAT The parameters to the given command were not specified Refer to the documentation for correct format. properly. IAT ILLEGAL ARGUMENT TYPE An unrecognized SPR if Submit an ICC COMPARE IER E subprogram argument type was IS involves report via an SPR. detected. NOT ALLOWED two constants. (number) Internal IGN test [number] this message occurs. TWO CONSTANTS Conditional = INVALID FORDDT error GROUP - please NUMBER Group numbers must be integral and in the range 1 through 8. INV INVALID VALUE A syntax error was detected E-18 in the numeric parameter. FORDDT ITM ILLEGAL The LGU TYPE mode [array S MODIFIER is name] only [label] IS LOWER MLD [array name] NOT A S valid for ACCEPT statements. SUBSCRIPT.GE.UPPER The lower bound of equal to the upper LNF - any given bound. FORMAT dimension must be less MULTI-LEVEL ARRAY DEFINITION NOT ALLOWED same array cannot be dimensioned more than [dimensions] construct) in a single command. MORE SUBSCRIPTS The array specified NAL NAR NOT 1s in An attempt or a defined to have more the given reference. dimensions has been AFTER A The given command made to modify something restored NOT via is a not allowed CONTINUE or until NEXT CANNOT FIND FORTRAN START ADDRESS FOR Main program Names IS must a symbols NOT than data program integrity has be A are not FORTRAN [program name] loaded. VARIABLE 6-character alphanumeric strings beginning letter. NGF CANNOT GOTO NPH CANNOT INSERT attempt executable PAR other LOADED [symbol] with NUD were command. NFS [symbol] set than RE-ENTER DDT An the FORMAT. NDT NSP (via NEEDED NOT An once ALLOWED been NFV or STATEMENT The MSN than A A has been SUCH has STATEMENT PAUSE statement NO attempt FORMAT HERE made or to place subprogram a pause entry at other than an point. PAUSE been made to REMOVE USER DEFINED ARRAY been made remove a pause that was never up. [symbol] NOT An attempt an array A has that PARENTHESES Parentheses statements was never REQUIRED are and to dimension information for defined. (..) required complex for the constants. specification of FORMAT FORDDT PRO REQUESTS PAUSE TOO MANY The The PAUSE table has been exhausted. 1limit maximum 1is 10. SER ERROR SUBSCRIPT The subscript specified is outside the range of its defined dimensions. STL [array name] SIZE TOO LARGE An attempt has been made to define an array larger than 256K. TMS TOO MANY SUBSCRIPTS The array is defined to have fewer dimensions specified in the given element reference. URC Warning than are COMMAND UNRECOGNIZED Messages Each warning message in this list is preceded by %FTN on your terminal They are given here in alphabetical order. and on listings. ABX COMPILED ARRAY BOUNDS EXCEEDED [array name] FORDDT has detected another symbol defined in the specified range of the array. Note that this will occur in certain EQUIVALENCE cases and can be ignored at that time. CHI CHARACTERS IGNORED: " [text]" The portion of the command string included thought to be extraneous and was ignored. NAR [symbol] NSL NO IS SYMBOLS NOT was LOADED FORDDT cannot NST "text" ARRAY AN NOT 1in find the symbol table. STARTED The specified command requires that a START be previously issued to ensure that the program is properly initialized. POV PROGRAM The OVERLAYED symbol table is different from the last 1is being time FORDDT had superseded for control. SFA SUPERSEDES The the F10 ARRAY FORTRAN-10 generated array. dimension given SPO VARIABLE IS SINGLE-PRECISION XPA ATTEMPT TO EXCEED An attempt has PROGRAM AREA WITH been currently defined ONLY made program to space. E-20 [symbol access name] memory outside the APPENDIX CCMPILER FORTRAN-10 warning. continue, The responds If but format of ?FTNXXX a a with two F MESSAGES levels of messages - warning message 1is received, fatal error will stop the program messages fatal error and the compilation will from being compiled. 1is: LINE:n text LINE:n text or FFTNXXX where ? = fatal 3 = warning FTN = FORTRAN XXX LINE:n text = = = 3-letter mnemonic for the error message line number where error occurred explanation of error Square brackets output on Fatal the ([ mnemonic ]) in this appendix signify variables and are not terminal. Errors Each fatal error in the following list is preceded by ?FTN on the user terminal and on 1listings. They are presented here in alphabetical order. ABD ' [symbolname] The ATL AWN BOV usage HAS given For statement cannot [name] example, TOCO be total amount of greater than 512P. array was the given reference. To TOO determine core [name] The STATEMENT with a [definition] current symbol as information defined a defined LARGE necessary HAS to TO statement portion an subprogram WRONG have to about the EQUIVALENCE name. accommodate NUMBER more or of the OF this array SUBSCRIPTS fewer dimensions than CLASSIFY type, some portion must be examined by the compiler before syntactic analysis begins. During this entire in LARGE is REFERENCE DEFINED referenced The ARRAY BEEN conflicts symbol. ARRAY ALREADY required F-1 of the statement actual semantic <classification statement must fit into and the the COMPILER MESSAGES internal statement buffer (large enough for a normal 20-line statement). This error message 1s issued when the portion of a given statement required for <classification 1is too large to fit in the buffer. Once FORTRAN-10 has classified a CER CFF statement, COMPILER CPE ERROR Submit an CANNOT FIND The there file IN is no explicit ROUTINE SPR for restriction on its length. [name] any occurrence of this message. FILE referenced in CHECKSUM OR PARITY an INCLUDE ERROR 1IN statment was not found. [source/listing/object] FILE [name] CQL NO CLOSING QUOTE IN LITERAL ILLEGAL STATEMENT FUNCTION REFERENCE [symbolname] VARIABLE OR DFD DIA IN DUPLICATE DIMENSION DUMMY ARGUMENT [name] MUST BE SCALAR, DEFINED AS FORMAL COMMON DOUBLE [type] NAME ILLEGAL Duplicate fields specification. were encountered DO [name] IS INDEX VARIABLE In any nest defined for DID CANNOT DLN CPTIONAL DATA The extended to be by DO A DUMMY VALUE LIST FORTRAN defined IMPLIED ALREADY of DO loops, a given more than one loop. INITIALIZE supported DNL IS IN CALL STATEMENT 1in INCLUDE file variable may IN not DATA form that specification allows data statements wvalues 1is SPECIFICATION WITHOUT DPR DUMMY PARAMETER DSF ARGUMENT [name] DTI THE DVE CANNOT DWL [source/listing/object] ECT ATTEMPT EDN EXPRESSION EID ENTRY STATEMENT ILLEGAL INSIDE EIM ENTRY STATEMENT ILLEGAL IN [name] DIMENSIONS TO not FORTRAN-10. ASSOCIATED LIST VARIABLES USE be SUPPORTED statement type an ACTIVE index PARAMETER NOT 1in IS OF DUMMY ENTER TOO REFERENCED SAME AS FUNCTION [arrayname] VARIABLE IN MUST DEVICE NESTED F-2 DEFINITION NAME BE OF THE TYPE INTEGER EQUIVALENCE [symbolname] DEEPLY BEFORE [[device]] INTO TO MAIN COMMON COMPILE A DO LOOP PROGRAM WRITE TWICE LOCKED OF COMPILER MESSAGES ENF LABEL [number] MUST REFER TO AN EXECUTABLE STATEMENT, FORMAT ETF ENTER EXB EQUIVALENCE FEE FOUND FAILURE FNE LABEL EXTENDS syntax [number] COMMON BLOCK WHEN EXPECTING error message. MUST REFER WHEN EXPECTING TO [name] EITHER A BACKWARD [symbol] FORMAT, OR NOT FOUND HDE HARDWARE [symbol] DEVICE ERROR ON A AN STATEMENT FWE [symbol] EXECUTABLE [symbol] [source/listing/object] DEVICE [ [device]] IAC ILLEGAL IAL INCORRECT IBK ILLEGAL STATEMENT IN ICL ILLEGAL CHARACTER [character] IN IDN DO AT [number] ILLEGALLY ASCII LOOP You are one or CHARACTER ARGUMENT LINE: attemping more TYPE IDT ILLEGAL OR MISSPELLED IDV IMPLIED DO INDEX IED INCONSISTENT INDICES IS MAY given EQUIVALENCE to to refer IIP ILLEGAL IIS INCORRECT ILF ILLEGAL Refer FILES IMPLIED IMPLICIT INCLUDE Section a BE FIELD NESTED DO loop before the given one. terminating TYPE VARIABLE DECLARATION than RESIDE DO [name] SUBSCRIPTED one ON would physical cause some symbolic location. DISK INDEX SPECIFICATION PARAMETER SWITCH STATEMENT to A LABEL declaration more MUST IS SOURCE SUBPROGRAM after DATA EQUIVALENCE name NON-INTEGER FUNCTION LIBRARY NOT NOT The IID FOR terminate IMPLICIT INCLUDED IN defined IDS IFD [character] BLOCKDATA to loops DO A [filename] [symbol] General NOT AFTER 9.3.2 LOGICAL IF for restrictions BE on logical IF object statements. INN INCLUDE STATEMENTS MAY NOT I0D ILLEGAL STATEMENT USED AS ISD ILLEGAL SUBSCRIPT EXPRESSION Subscript indices expressions and constants NESTED OBJECT IN OF DATA may be formed combined with F-3 DO STATEMENT only +, -, with *, or implicit /. DO COMPILER MESSAGES ISN [symbolname] The the in used be cannot symbol [symboltype] IS NOT attempted manner. IUT PROGRAM UNITS MAY NOT BE TERMINATED WITHIN IVP INVALID IXM ILLEGAL MIXED MODE ARITHMETIC INCLUDED FILES PPN Complex and double-precision cannot appear 1in the same expression. ILLEGAL [datatype] Refer to Section LAD LABEL [number] LED ILLEGAL LIST DIRECTED LFA LABEL ARGUMENTS LGB LOWER BOUND GREATER THAN UPPER BOUND FOR ARRAY LLS LABEL IZM TOO Labels 6.3. LTL TOO MANY In rare [statement ILLEGAL OR cannot be LIST DIRECTED TOO 0 or IN greater THAN MSP STATEMENT MWL ATTEMPT TO 1 - [name] 5 digits. I/O LIST REDUCE NUMBER OF the syntax COMMON VARIABLE NAME than ITEMS a combination of long lists statement can exhaust MORE typel SMALL LIST instances, [number] IN FUNCTION OR ARRAY REFERENCE I/0 WITH NO ITEMS MCE [number] ALREADY DEFINED AT LINE: LARGE LNI SIZE MODIFIER IN stack. EQUIVALENCE in a single GROUP MISSPELLED DEFINE MULTIPLE RETURN WITHOUT FORMAL LABEL ARGUMENTS NCF NOT ENOUGH CORE FOR FILE SPECS. NEX NO EXPONENT AFTER NFS NO FILENAME SPECIFIED The INCLUDE statement NIO NAMELIST DIRECTED NGS CANNOT Refer GET D to Appendix COUNT of E reqguires [name] E of [number] CONSTANT I/0 WITH SEGMENT description OR TOTAL K NEEDED= the a filename. I/0 LIST - ERROR CODE: Monitor Calls [number ] Manual for codes. NIR REPEAT MUST NIU NON-INTEGER NLF WRONG NUMBER OF ARGUMENTS UNIT BE IN AN UNSIGNED I/O STATEMENT INTEGER FOR LIBRARY FUNCTION [name] full COMPILER NNF NO STATEMENT NRC STATEMENT NOT NUO .NOT. A NWD INCORRECT OPW CPEN PD6 FORTRAN PIC THE PRF PROTECTION PTL PROGRAM The IS NUMBER USE OF PARAMETER DO FOKMAT RECOGNIZED UNARY WILL CN MESSAGES OPERATOR * OR [name] NOT RUN PARAMETERS TOO LARGE program takes QEF QUOTA EXCEEDED QEX BLOCK TOO [filename] IS OF WRONG A name] more DISK than FULL LARGE OR QUOTA KIB [filename] RFC [function RIC COMFLEX SAD ERROR IS CONSTANT IMAGINARY PART ARRAY [name] RANGE LIMITS SNL [statement SOR SUBSCRIPT TFL TOO TOF MORE MANY - OF FORMAT THAN 2 A EE USED COMPLEX USER UMP UNMATCHED USI [symbol The CORE TG CALL REPRESENT THE DIMENSIONS MAY MAY NOT APPEAR BE ONLY AS REAL OR CONSTANT LABELED RANGE LABELS SPECIFIED FILES ARE NOT ALLOWED binary file EXCEEDED PARENTHESES [symbol symbol FOR CONSTANT STATEMENTS OUTPUT type] given EXCEEDED FUNCTION Only a 1listing and a relocatable specified as output files. UCE CONSTANTS [name] RECURSIVE SIGNED name] OUT A CANNOT OF INTEGER [filename] RDE name] BE 512P FILE DIRECTORY MUST [filename] [source/listing/cbject] OR TYPE FDP-6 [index uo OR 1IN ON OF FAILURE ? name] cannot VARIABLE used INCORRECTLY in EQUIVALENCE this way. BUT NOT VNA SUBSCRIPTED VSE EQUIVALENCE SUBSCRIPTS MUST BE INTEGER CONSTANTS VSO VARIABLE DIMENSION IN be USED ALLOWED IN SUBPROGRAMS AN ONLY ARRAY may be COMPILER Warning MESSAGES Messages Each warning message in the user terminal and on alphabetical order. following 1listings. AGA OPT LIST, CAI COMPLEX EXPRESSION USED IN CTR COMPLEX TERMS IN A RELATIONAL The result of the other operands is undefined. relational CuoO OBJECT VARIABLE, OF WAS NEVER ASSIGNED list is preceded by %FTN on They are presented here CONSTANT USED UNDERFLOW ASSIGNED GOTO ARITHMETIC WITHOUT the 1in OPTIONAL IF OTHER THAN EQ OR NE operators with complex OR OVERFLOW This message 1is 1issued when overflow or underflow 1is detected as the result of building constants or evaluating constant expessions at compile time. DIM POSSIBLE DO INDEX MODIFIED INSIDE LOOP A program that does this may be incorrectly compiled by the optimizer, since it assumes that indices are never modified. Note that the number of iterations 1is calculated at the beginning of the loop and is never affected by modification of the index within the loop. DIS OPT - PROGRAM Submit an DXB DATA FMR MULTIPLE ENA A ICC ILLEGAL ICD SPR IS if STATEMENT this message EXCEEDS BOUNDS RETURNS FUNCTION DISCONNECTED DEFINED WITHOUT AN CHARACTER, Continuation lines INACCESSIBLE COOE. ILLEGAL IDN OPT A GO - TO CHARACTER ILLEGAL DO within a A delete IN LINE NESTING DO loop DISCONTINUED ARRAY [name] FUNCTION LIST follow STATEMENT inner, nested DO loop. warning message is that DO OF ARGUMENT cannot OPTIMIZATION occurs. CONTINUATION The optimizer will during execution. ICS IN - FIELD OF comment INITIAL LINE lines. DELETED statements that cannot be reached SEQ# - goes OPTIMIZATION to the DISCONTINUED ending statement The line number printed of the OUTER DO. out of an with the COMPILER MESSAGES DO CONTINUE éONTINUE IFL OPT - LID IDENTIFIER The MVC INFINITE [name] remaining NUMBER OF LOOP. OPTIMIZATION MORE THAN characters VARIABLES DOES SIX DISCONTINUED CHARACTERS are ignored. NOT EQUAL THE IN DATA NED NO END NOD GLOBAL NOF NO PPS PROGRAM STATEMENT PARAMETERS IGNORED STATEMENT IN FILES NOT SUPPORTED WITH CONSTANTS compatibility SOD [name] STATEMENT VAI [name] ALREADY VND FUNCTION VNI OPT - The was optimizer analysis determined that never initialized prior to its use OPT - REDECLARE /OPT IGNORED IMPLICIT OUT OF TYPE ORDER INITIALIZED RETURN VARIABLE WARNING - purposes. ATTEMPT TO /DEBUG GIVEN RDI WOP OF PROGRAM OPTIMIZATION OUTPUT For NUMBERS STATEMENT VALUE IS NEVER [name] IS NOT GIVEN IN DEFINED INITIALIZED PHASE 1. the in a OPTIMIZED given wvariable calculation. CODE MAY NOT BE CORRECT One or more of the messages issued resulted from situations that the optimizer and thus may cause does not execute as desired. XCR EXTRANEOUS Carriage a ZMT line SIZE CARRIAGE return MODIFIER Message is used was termination prior to this message violate assumptions made by it to generate code that RETURN not immediately preceded or followed by character. [number] TREATED is issued when one of that is accepted only AS the for [data type] data type size compatibility. modifiers COMPILER MESSAGES Internal Compiler errors An internal compiler error is either an attempt by the compiler or the monitor to document an error inside the FORTRAN compiler. An 1is something occurrence of an internal compiler error signifies that wrong with the FORTRAN-10 compiler. internal errors are of the form Monitor-detected [message] WHILE where AT LOCATION [address] PROCESSING STATEMENT [message] ILLEGAL STACK IN PHASE [segment] [line-number] can be one of MEMORY REFERENCE EXHAUSTED MEMORY PROTECTION Compiler-detected VIOLATION errors are of the form ? INTERNAL COMPILER ERROR PROCESSING STATEMENT NUMBER ? CALL TO [routine-name] FROM [line-number] [address] Submit an SPR if you received an internal conpiler error. APPENDIX FORTRAN-10 This appendix G.1 INTRODUCTION ‘the FORRTF RTREAD, explains library RTWRIT, how to REALTIME use subroutines ©STATO, G the FORTRAN-10 (LOCK, STATI, SOFTWARE RTINIT, RTSLP, realtime CONECT, RTWAKE, DISMIS, software. RTSTRT, BLKRW, DISCON, UNLOCK, and temporary subroutine GETCOR (refer to Section G.3)) are designed to allow the timesharing FORTRAN user to do realtime programming. With these subroutines, the timesharing job can dynamically connect realtime devices to the priority interrupt (PI) system, respond to these devices at interrupt level, remove the devices from the PI system, and change that have realtime you core. The bits JPORTT (BIT 13) - realtime JPOLCK (BIT 14) - locking number of realtime reassembling. The error format format messages reassembly the of multiprocessor processor for by to core the to routines 1lock your requires job in privileges privileges that can be in handled the at one FORRTF time 1is source. an The the 0 be in either Table G-1.) core. If assembly-time (full format) Use of core constant to -1 full message the 1is code and 1limited, SHORT changed (coded format) saving. indicates the realtime by the job's more than one CPUO. indicated can (Refer to run-time with systems, indicate these are: FORRTF format. words of specified specification of able software has RTDEVN equal to 2 but it can be by editing the statement "RTDEVN==2" in FORRTF.MAC FORRTF.MAC the Use are RTDEVN, DIGITAL~-distributed accomplishes changed devices output or coded saves 165 and required constant, and only level. privilege DIGITAL-distributed changed (up to 6) On PI privileges The assembly-time from their CPU. Note that apply only specification. processor, the | traps CPU priority the to the If the specification interrupt channel 1is is FORTRAN-10 USING G.2 Users of SOFTWARE FORRTF FORTRAN-10 realtime software must consider l. Use 2. Device control 3. Priority 4. Masks G.2.1 REALTIME of the following: core in block or interrupt single mode levels Core The job being executed must be 1locked 1in core with ‘the LOCK subroutine. Any data being read into core can only be read into the low segment and above the protected Jjob data area (the first 140 locations). The subroutine BLKRW tests the validity of the locations specified to receive data in block-reading to ensure that no overwritings occur. However, when in block mode, the block pointer must dismissing the end-of-block interrupt; overwritten. G.2.2 otherwise, be reset Dbefore two ways: block all memory could be Modes Realtime jobs can control their devices in one of mode or single mode. In block mode, an entire block of data is read or written before the user interrupt routine is run, whereas in single mode, the user interrupt program 1is run every time the device interrupts. There are two types of block mode; fast block mode and normal block mode. The response time to read a word of data is 6.5 microseconds for fast mode and 14.6 microseconds for normal mode. (These are the times necessary to completely service the interrupts on a KI10 processor). In single mode, the response time measured from the receipt of a realtime device interrupt until the start of the user control program is 100 microseconds on a KI1l0 processor. A device 1in fast block mode requires that a PI channel be dedicated entirely to itself. G.2.3 Priority Interrupt Levels Priority interrupt levels 1 through 6 are 1legal depending on the system configuration. The lower the number of the level, the higher the priority of that level. Programs that execute for a 1long time should not be put on high-priority interrupt levels, since they could cause other realtime programs on 1lower levels to lose data. Specification of the PI level as zero for a particular device causes the device to be removed from the PI system. FORTRAN-10 G.2.4 For SOFTWARE Masks a description parameters Chapters 3 Appendix G.3 REALTIME of the of RTSTRT through 8 of C, IN-OUT bits and the DEVICE included in the status DECsystem-10 BIT the startmsk and intmsk word in STATO and STATI, System Reference Manual ASSIGNMENTS of that see and manual. SUBROUTINES Each of the 15 subroutines associated with FORTRAN-10 realtime software 1s described briefly in this section. These subroutines have been programmed to be compatible with programs written according to the RTTRP: REAL TIME TRAPPING UUO specifications, edition 4 of 12-Feb-73. LOCK G.3.1 LOCK locks the job in controlling tables before any other of Section G.3.15), CALL G.3.2 core and allocates and initializes for all realtime devices. the realtime routines, except and must be called exactly the 1internal LOCK must be called GETCOR (refer to once. LOCK RTINIT RTINIT initializes RTINIT must CALL be RTINIT unit the called internal for (unit, - each dev, realtime tables controlling individual pi, trpadr, device device a realtime being device. used. intmsk) unit number (any number from 1 to RTDEVN) dev - This number is not connected FORTRAN logical unit number. in device device A, code Reference pi - for DEVICE the realtime MNEMONICS Manual 1in the any way with (see the Appendix DECsystem-10 System DEC-10-XSRMA-A-D). priority interrupt level device 1is to be run. on Each have fast block mode must itself. 1If the level is individual device a level dedicated in to which the realtime equal to priority zero, the device will be removed from the interrupt system altogether. If it is necessary to connect one device to several levels simultaneously, system not to device from (Note that device.) a negative remove any this value any other other counts (or as for pi tells occurrences the same) another of the the PI level. realtime FORTRAN-10 trpadr - address of interrupts SUBROUTINE REALTIME SOFTWARE a FORTRAN are to trap. subprogram. entry to which realtime This can be a FUNCTION or Any variables that must be shared between the user interrupt level routine must COMMON. disastrous intmsk G.3.3 them as parameters causes mask of all interrupting flags for the realtime device. This 1s actually set up by RTSTKRT and should be zero whenever the realtime device 1is inactive, i.e., in a call to RTINIT, except in the case of fast block mode. In fast Dblock mode, intmsk must be set to -1. CONECT CONECT tells the level and sets Every - Passing results. level code and the be vassed by means of device CALL system to connect a up several elements must CONECT be realtime device to the proper PI of the device controlling tables. CONECTed. (unit, mode) unit - realtime device unit number (see RTINIT) mode - =2, write a block of data, fast interrupt. -1, write a block of data, normal mode; then mode; then normal mode; then fast mode; then interrupt. 0, interrupt +1, read a every block word of data, interrupt. +2, read a block of data, interrupt. G.3.4 RTSTRT RTSTRT can be used to start a realtime device as well as to and zero its interrupt mask. A device must be started to be should be stopped before it is disconnected. CALL RTSTRT (unit, startmsk, - realtime device startmsk - flags necessary to start System Reference Manual, 1is it and the device (see Appendix C). If the the intmsk) unit device stop used being unit number (see RTINIT) stopped, this parameter should be interrupting bits for particular Zero. intmsk - mask of device C). If all (see the System the device 1s 1n the Reference Manual Appendix fast block mode and being started, intmsk should equal -1; 1if, however, the device in any mode 1is being stopped, the parameter must be 0. FORTRAN-10 REALTIME SOFTWARE BLKRW G.3.5 It sets up the size and BLKRW is used with either of the block modes. A new count and handled. being block data the starting address of starting address must be set up each time the current one runs out. (unit, CALL BLKRW count, blkadr) unit - realtime device unit number count - number of words to be read or written blkadr - array into which the data is to be written or from which it is to be read. RTREAD G.3.6 from RTREAD, used with a device in single mode, reads single word of device the a data. (unit, CALL RTREAD datadr) (see RTINIT) unit -~ realtime device unit number datadr ~ address of where to store the data read RTWRIT G.3.7 RTWRIT sends a single word of data to a realtime device 1in single mode. (unit, CALL RTWRIT G.3.8 datadr) (see RTINIT) unit - realtime device unit number datadr -~ 1location of the data word to be sent to the device STATO STATO sends the specified status word to realtime the status register of a to (See Appendix C, In-Out Device Bit Assignments, in device. the DECsystem-10 System Reference Manual, DEC-10-XSRMA-A-D.) CALL STATO G.3.9 (unit, statadr) (see RTINIT) unit - realtime device unit number statadr - 1location of the word of status bits to be sent the realtime device STATI STATI reads the current device status bits into the location specified (See Appendix C, "In-Out Device fr inspection by the FORTRAN program. Bit Assignments", DEC-10-XSRMA-A-D.) in the DECsystem-10 System Reference Manual, FORTRAN-10 CALL STATI (unit, unit - adr ~ RTSLP SOFTWARE adr) realtime device location into be G.3.10 REALTIME unit which number the (see device RTINIT) status bits are to read. RTSLP 1s called from the timesharing level and causes the FORTRAN job to sleep until RTWAKE 1is called from interrupt level. The program goes to sleep for the specified number of seconds (up to 60). When it wakes up, 1t checks to see i1f RTWAKE has been called from interrupt level. If RTWAKE has program, otherwise the CALL RTSLP RTWAKE called CALL RTWAKE G.3.12 DISMIS DISMIS dismisses interrupt execution CALL DISCON should to the calling - length of sleep time at interrupt level to 1in seconds RTWAKE 1is G.3.13 RTSLP returns to sleep again. (time) tine G.3.11 been called, job goes back must to wake the interrupt currently be sure dismiss to up the being the FORTRAN program. processed. interrupt that The user causes its begin. DISMIS DISCON disconnects be a realtime disconnected device through from <calls its PI to DISCON 1level. All before devices the job is terminated. CALL DISCON unit G.3.14 UNLOCK UNLOCK unlocks complete, monitor. before must be (unit) - the realtime job device from number When (see RTINIT) execution of a the job is automatically unlocked before the return The UNLOCK subroutine provides a method to unlock execution is complete. finished before the job CALL core. unit UNLOCK Note that all is unlocked. realtime device job is to a the job handling FORTRAN-10 G.3.15 GETCOR, A Temporary GETCOR FOROTS 1s a routine use. The locked in that REALTIME SOFTWARE Subroutine allocates a of FOROTS specified amount of not allow FORTRAN design does core jobs to for be core due to 1ts run-time core needs. Thus, you must an amount of core sufficient to satisfy FOROTS for running the particular program being executed through a GETCOR <call. The GETCOR call must precede the LOCK call (see G.3.2). Unfortunately, the only way to determine the core required for each program 1is by allocate running argument the job with ever- increasing arguments to GETCOR. is too small, the following error message appears: ?FRSSYS CALL USER GETCOR wds PROGRAM REQUESTED MORE CORE THAN storage to IS AVAILABLE (wds) - number of words of Table G-1 Error Code Format and be allocated Messages Full Message Format Subroutine | Code Format 1l Full - If which Message ?ILLEGAL UNIT Format in message occurs NUIMBER. TO HANDLE MORE DEVICES, REASSEMBLE FORKTF WITH A LARGER A "RTDEVN" ?ERROR COMES SUBROUTINE 2 ?RTINIT CONECT 3 ?CONECT RTSTRT 4 A B "subroutine name" MUST BE CALLED BEFORE CONECT MUST BE CALLED BEFORE RTSTRT ,BLKRw OR BLKRW BOUNDS [i.e., overwrites some or in high segment] program ?END OF BLOCK start than 140 2JOB CORE CANNOT A ?2JOB NOT B ?NOT ENOUGH FOR LOCKING 6 THE ?REAL TIME BLOCK OUT OF ?END OF BLOCK TOO HIGH i.e., 5 FROM ?APR BE ?PDL ?ILLEGAL REFERENCE LOCKED CORE OVERFLOW MEMORY less IN PRIVILEGED ERROR AT A LOW, address LEVEL B TOO BLKRW AVAILABLE INTERRUPT LOCK the FORTRAN-10 REALTIME Table G-1 Error Code Format and SOFTWARE (Cont.) Messages Full Message Format Subroutine in which message Code Full Format Message Format occurs ERROR ?RTTRP realtime trap error following sort ?ILLEGAL PI ?TRAP 0 PI channel of NUMBER not ADDRESS available OUT OF FOR REALTIME ?2SYSTEM LIMIT DEVICES EXCEEDED EOUNDS ?2JOB NOT LOCKED PRIVILEGED IN CORE ?DEVICE ALREADY IN USE ANOTHER JOB ?O0OCCURRED the OR NOT BY IN THE DISCON DISCON IN THE CONECT CONECT ROUTINE 1l ?O0CCURRED ROUTINE ?NOT FOR ?NOT FOR ENOUGH CORE AVAILABLE CONTROL BLOCKS THE ENOUGH THE ?FRSSYS MORE CORE GETCOR LOCK AVAILABLE ROUTINE GETCOR USER PROGRAM REQUESTED GETCOR CORE THAN IS AVAILABLE APPENDIX FOROTS Errors detected at run-time errors (SYS) ERROR by d MESSAGES FOROTS fall 1into the following categories: l. system 2. open erros (OPN) - - errors I/O internal errors that to FOROTS occur during file OPEN and CLOSE 3. arithmetic calculations 4. library fault errors (LIB) errors (APR) - generated errors =~ errors | by in numeric FORLIB 1library routines APR 5. data 6. device and LIB errors (DAT) errors errors - errors (DEV) are - in data conversion I/0 hardware usually reported as warnings The number of APR and be changed by the FORTRAN Table either by an for details. The I/0 errors (SYS, messages to be printed on the terminal exit argument (ERR=statement label) on and I/0 errors continues. terminal can 15-3 cause error on and the. program LIB errors listed on the user's Library Subroutine ERRSET. See OPN, DAT, and DEV) or can be trapped OPEN, READ, WRITE, CLOSE. Table H-1 OPN, DAT, gives the and text DEV of the The information. Table printed for APR and H-2 LIB The Subroutine FORTRAN error that describe FOROTS. (The CALL calls Library occurred. this the When ERRSNS called, of integer ERRSNS ERRSNS the of is the can be printed footnotes give messages allows you to find returns one or two 1last value which included gives the text errors. status second messages errors. 1I/0 for which out «can be which I/O integer operation J is the second, optional integer values performed optional.) (I,J) subroutine. SYS, additional value. by FOROTS ERROR Table FOROTS I/0 Error First Second Value Value 0 Messages 243 246 23 error Values detected) error BACKSPACE illegal for device (9) End-of-file during READ Attempt to READ beyond valid input (8) Invalid record number LSCW illegal in binary record or —ceading ASCII; or attempt to read unwritten ASCII RANDOM ACCESS record or unwritten or destroyed record number Direct access not specified Cannot RANDOM ACCESS a SEQUENIAL file 308 302 26 Returned detected Backspace 312 25 ERRSNS Satisfactory completion (no error Normal end of job (1) Invalid error call Unidentified entry in FORERR (3) Unidentified entry in FORERR (3) 1 24 H-1 and Explanation No 0 101 MESSAGES 311 28 CLOSE 252 error DTA directory is full (2) or protection error 254 Rename file already exists (2) No room or quota exceeded (2) 262 268 Cannot delete directory (2) 29 250 No such file File was not OPEN failure 237 DUMP 30 mode numoer 253 currently a non-empty found RANDOM or APPEND access (2) File was being modified (2) implemented. 2. OPEN errors 251 through 276 map directly onto error returned by the OPEN UUO; see Appendix E, "Error Codes", in Notebook 4, 3. cannot Error not (3) Record length missing for RANDOM ACCESS Too many devices open: fifteen maximum Device not available (2) Illegal ACCESS for device (2) Illegal MODE or MODE switch (2) No directory for project, programmer 248 249 251 Not rename implemented; try IMAGE MODE DIALOG file cannot be opened 238 240 242 245 1. or "DEC-10 Monitor currently numbers Software Calls". occur. 8. Occurs when simulating mag tape output; SKIP RECORD and SKIP FILE are illegal. Also occurs when a non-existent file is opened in MODE= SEQINOUT and the first operation on that file is a READ. 9. Occurs if OPEN output with BACKSPACE is not a mag tape or disk. FOROTS FOROTS First vValue I/0 Error Second Value Table H-1 (Cont.) Messages and ERRSNS Illegal sequence 256 3ad or 259 Device 265 Partial 266 267 Block not free on allocation Cannot supersede an existing 269 SFD 270 Search 271 SFD 272 No 274 File 315 UFD not of RIB Values available allocation found list nested CREATE empty LOOKUP ENTER access 310 42 244 260 45 for be (2) 47 (2) directory (2) (2) specified updated or UFD (2) (2) RENAME error (2) SEQUENTIAL ACCESS on keyword dur ing (2) a 59 (2) illegal error DIALOG 62 301 306 314 63 305 FORERR or In implemented. 7. * ll1. "DEC~-10 runtime £i11 Can Monitor numbers Software Calls". FORMAT. controlled occur on [1,4] list. OPEN (7) 2. OPEN errors 251 through 276 map directly onto error returned by the OPEN UUO; see Appendix E, "Error Codes", in 4. (1) List-directed I/0 syntax error Illegal delimiter in LIST DIRECTED input Syntax error in FORMAT Illegal character in FORMAT statement (4) I/0 list without data conversion in FORMAT Missing width field for A or R on input Output conversion error Optional * fill: unidentified entry 1in 313 4, RANDOM Write on read-only file Write~-lock error (2) 263 Notebook (2) modes OPEN statement Switch error statement scan 241 (11) {2) only deeply flag Mixed Calls (2) too cannot do Monitor (2) Invalid logical unit number Illegal FORTRAN unit number Error during READ REREAD before first READ is Device handler not resident No such device (2) No such device (2) 239 currently bad not Cannot file 32 Not Returned 255 277 1. MESSAGES Explanation 31 39 ERROR on when by compile-time OPEN device (MODE= variable 'APPEND') specified was when SYS: ASTFIL. file and is found /NEW was in in LIB: your or search FOROTS ERROR MESSAGES Table H-1 (Cont.) FOROTS I/0O Error Messages and Explanation Second First ERRSNS Returned Values Value Value 64 303 307 67 304 81 102 261 699 247 257 258 264 273 275 276 799 309 899 | Input conversion error Checksum error reading binary records Illegal character in data Record too small for (5) I/0 list I/0 list greater than record size (6) Invalid argument Argument block not in correct format Argument block not in correct format (2) Unclassifiable error on OPEN FOROTS system error (2,3) FOROTS system error (2) FOROTS system error (2) Not enough monitor table space FOROTS system error (2) FOROTS system error (2) FOROTS system error (2) (2) Unclassifiable data error Variable cannot be found in NAMELIST block Unclassifiable device errors 400 401 402 Write protected Device error Parity error 404 407 CDR reader. Nonexistent full. structure Spooled CDR file does not exist. End-of-file (10) End-of-tape 100 FOROTS 403 Block too large, Unclassified 999 103 Monitor 104 Fatal system quota file code than system error error not build to support FOROTS error 105 User program has requested more 106 Run is or exceeded, available time memory management error numbers error onto directly map 276 through 251 2. OPEN errors see Appendix E, "Error Codes", 1in Software by the OPEN UUO; returned Notebook 4, "DEC-10 Monitor cannot Calls". currently occur. 3. Error 5. Checksumming controlled by compile-time variable CHKSUM. 6. Occurs when a type 10. Trappable if there 2 LSCW is found is no in a FORSE binary record. END= clause. FOROTS ERROR Table FOROTS Arithwmetic and MESSAGES H- 2 Library Error APR Messages LIB Integer Overflow Attempt to take DLOG Integer Divide Attempt to take DSQRT Illegal APR ACOS of Arg. > 1.0 in Magnitude ASIN of Arg. > 1.0 1n Magnitude Check Trapo Floating Divide Floating Underflow Check Attempt to take SQRT Attempt to take LOG of Negative of of of Arg. Negative Negative Negative Arg. Arg. Arg. INDEX A format descriptor, 13-12 ACCEPT, INTRO-5-2 BACKFILE statement, 14-3 BACKSPACE statement, 14-2 ACCEPT transfer, formatted, 10-18 into FORMAT statement, 10-19 Account number, INTRO-5-2 ACCESS in file control statement, 12-3 Accumulator usage, C-10 input from, 2-6 Basic external function subprogram, 15-8 Beginning a job, INTRO-1-1 BINARY with MODE, 12-4 Blank line, 2-6 BLOCK DATA statement, 16-1 ACCEPT statement, Accuracy of 10-18 double- precision numbers, ACOS function, 15-11 Addition, 4-1 Adjustable dimensions, ALL with DEBUG, B-3 BASIC, BLOCK C-1 6-2 Allocation, register, C-7 ALOG function, 15-10 ALOGl0 function, 15-10 Alphanumeric data transfer, SIZE in file statement, control 12-8 Block data subprogram, 16-1 BOUNDS with DEBUG, B-3 BUFFER COUNT in file control statement, 12-8 +C, INTRO-1-1 4C monitor call, INTRO-3-3 13-12 Alphanumeric FORMAT field descriptor, 13-11 .AND., 4-5 ANSI standard, 1-1 APPEND with ACCESS, 12-4 Argument, Call, FUNCTION, 15-16 subroutine, 15-13 CALL statement, 15-13 Carriage control character, 13-16 Carriage return key, INTRO-1-2 subprogram, 15-1 Argument type, Category, COBOL/FORTRAN, C-12 Arithmetic, mixed-mode, 4-2 Arithmetic assignment statement, 8-1 Arithmetic expression, 4-1 Arithmetic IF statement, 9-3 Arithmetic operator, 4-1 Array, 3-7 dimensioning, 3-9, C-4 Array elements, storage of, 3-10 Array subscript, 3-8 ASCII with MODE, 12-4 CCOS function, 15-11 CEXP function, 15-10 Changing a line, INTRO-3-4 Changing a program, INTRO-4-1 Changing line numbers, INTRO-4-5 Character code, A-1 Character set, 2-1 Character set with MODE, 12-4 Characters, line formatting, 2-2 line termination, 2-2 CLOG function, 15-10 CLOSE, INTRO-5-4 CLOSE statement, 12-1 ASIN function, 15-11 ASSIGN statement, 8-4 CONFIRM, INTRO-7-1 COBOL-10, ASCIZ string, statement, C-14 Assigned GOTO statement, Assignment statement, 9-2 arithmetic, 8-1 label, 8-4 logical, 8-4 mixed-mode, function, 15-11 ATAN2 function, 15-11 AXIS subroutine, 15-19 12-8 12-10 interaction with, C-18 COBOL/FORTRAN argument type, in file control statement, ATTACH, INTRO-~7-3 ATAN CLOSE statement summary, C-12 Command, COMPILE, B-4 DEBUG, B-4 8-1 ASSOCIATE VARIABLE 1l-1 EXECUTE, LOAD, Comment B-4 B-4 line, 2-5 Common block COMMON COMPIL statement, in FOROTS, Index-1 name, 6-5 6-5 D-2 INDEX Compilation 5-1 control COMPILE command, statement, DATA statement, 7-1 Data transfer operations, 10-1 B-4 Compiler commands, B-4 Compiler generated variable, B-6 Compiler switches, B-1 Compiler version, B-8 Complex constant, 3-3 Complex format, 13-4 COMPLEX statement, 6-3 Computation, redundant, C-=5 reordering, C-3 Computation in DO-loop, constant, integer, | ~ C-6 9-2 3-2 B-15 INTRO-4-3 DENSITY in file control 3-5 logical, 3-5 octal, 3-4 real, 3-2 Constant computation in DO-loop, C-6 Constant folding, C-7 Constant propagation, C-7 Continuation field, line, 2-3 Continuation line, 2-4 Continue (G) option after PAUSE, 9-11 statement, statement, compilation, 15-11 DATAN2 function, 15-12 DATE subroutine, 15-19 DCOS function, 15-11 DEBUG command, B-4 Debug line, 2-6 DEBUG switch, B-2, B-3 Debugger, FORDDT, E-1 Debugger code size, B-4 DECODE statement, 10-22 Deleting a line, literal, Control 3-1 DATAN function, DEFINE FILE subroutine, 15-17 DELETE, INTRO-4-3, INTRO-6-2 DELETE with DISPOSE, 12-5 Deleting a file, INTRO-6-2 3-6 CONTINUE Data type, DEFAULT, Computed GOTO statement, CONJG function, 15-12 Constant, 3-1 complex, 3-3 double-precision, 3-3 label, (CONT.) statement, 12-9 Descriptor, G format, 13-7 Device control statement, 14-1 Device control statement summary, 14-3 DEVICE in file control statement, 12-2 Device number, logical, 10-3 DEXP function, 15-10 DIALOG in file control 9-10 9-1 statement, | DIMENSION 5-1 12-9 statement, 6-1 Dimensioning, Control 7z, 2-1 COS function, 15-11 COSD function, 15-11 COSH function, 15-11 <CR>, INTRO-1-2 array in COMMON, 6-7 Dimensioning array, 3-9, C-4 Dimensions, adjustable, 6-2 DIMENSIONS with DEBUG, B-3 CROSSREF DIR, INTRO-6-1 Directory, sub-file, 12-6 switch, B-2 CSIN function, 15-11 CSQRT function, 15-10 user file, 12-6 DIRECTORY, | D, INTRO-4-3 D (double-precision notation), 3-3 D format descriptor, 13-4 .DAT extension, 12-5 Data, input/output, Data Data INTRO-5-1 file, INTRO-5-3 files, FOROTS, in file control statement, 12-6 Directory file, INTRO-6-1 DISPOSE in file control statement, 12-5 Division, 4-1 DLOG function, 15-10 DLOG10 function, DO statement, DO-1loop, D-4 constant Index-2 15-10 9-5 computation in, C-6 INDEX DO-loop (Cont.), execution, 9-6 extended range, floating-point, implied in nested, I/O Evaluation of 9-8 C-2 list, EVEN with PARITY, EX, 10-5 SOS, statement, 6-3 Double-precision constant, 3-3 Double~-precision format, 13-4 Double-precision numbers, range of, of, C-1 C-1 DSIN function, 15-11 DSQRT function, 15-10 Dummy argument, subprogram, EXECUTE, EXECUTE DO-loop iteration, C-2 DO-loop replacement, C-8 accuracy INTRO-8-1 Executable 9-9 15-1 DUMP subroutine, 15-20 DUMP with MODE, 12-4 12-9 INTRO-3-1 Examples, 9-6 PRECISION expression, 4-9 parameters, 9-6 permitted transfers, range, 9-5 DOUBLE (CONT.) statement, 1-1 INTRO-3-1 command, B-4 Execution, | interrupting, INTRO-3-3 Execution on non-DEC machines, C-1 Exit (X) option after PAUSE, 9-11 EXIT subroutine, 15-21 EXP function, 15-10 EXPAND switch, B-2 Exponential notation, 3-2 Exponentiation, 4-1 permitted, 4-4 Expression, arithmetic, 4-1 evaluation of, 4-9 logical, 4-4 mixed-mode, 4-10, 4-11 nested, 4-9 relational, E, INTRO-2-2, INTRO-4-5 E (exponential notation), 3-2 E format descriptor, 13-4 EDIT, INTRO-4-1 Editing source files, INTRO-4-1 ENCODE statement, END, INTRO-4-5 END argument in FILE I/O statement, 14-2 ENTER in FOROTS, C-18 Entering a program, INTRO-2-1 EQ, statement, .EQ., F descriptor, Fatal error, label, file 2-3 Field 2-3 descriptor, . alphanumeric FORMAT, statement, FORMAT, 13-2 statement, logical numeric FORMAT, control FILE, 2-3 2-4 I/O 12-10 C-18 B-17 continuation, statement, 6-7 13-4 programs, 3-5 remarks, in 6-8 Field, line FORMAT, 13-11 13-10 13-4 INTRO-2-1 File, Error, fatal, B-17 processing, FOROTS, Error compiled .FALSE., 15-17 statement, .EQV., 4-5 ERR argument 10-10 Error format F40 4-7 in 15-8 statement, INTRO-4-5 EQUIVALENCE ERR basic, EXTERNAL statement, END statement, 5-2, 15-7 Ending source input, INTRO-2-2 ENTRY subprogram, 15-7 10-22 10-10 END 4-7 Extension, .SHR, B-18 External function D-3 reporting, ERRSET subroutine, 15-21 subroutine, 15-21 ESCAPE, INTRO-2-2 INTRO-2-1 INTRO-7-1 data, INTRO-5-3 deleting a, INTRO-6-2 directory, INTRO-6-1 directory subfile, 12-6 B-17 ERRSNS .FOR, .REL, editing, Index-3 INTRO-4-1 INDEX (CONT.) Function subprogram, basic external, 15-8 external, 15-7 intrinsic, 15-3 File (Cont.), FOROTS data, D-4 non-FORTRAN-10, C-9 renaming a, INTRO-6-2 source, INTRO-2-1 statement, 15-3 File control statement, 12-1 File directory, Function subprogram structure, user, 12-6 FILE in file control statement, 12-5 FUNCTION FILE FIND SIZE in file control statement, 12-8 statement, 10-21 Floating--point DO-loop, C-2 Folding, constant, C-7 .FOR extension, INTRO-2-1 FORDDT debugger, E-1 FORDDT messages, E-17 FORMAT field descriptor, alphanumeric, 13-11 logical, 13-10 numeric, 13-4 record formatting, 13-15 FORMAT statement, 13-1 ACCEPT transfer into, 10-19 transfer into, 10-3 FORMAT statement descriptor, 13-2 Formatted ACCEPT 10-18 transfer, Formatted READ transfer, random access, 10-13 sequential, 10-11 Formatted WRITE random access, sequential, 15-7 G G type, 15-7 (option after PAUSE), 9-11 format descriptor, 13-4, 13-7 .GE., 4-7 General (G) numeric format, 13-7 GETOVL in LINK, C-20 Global optimization, GOTO statement, assigned, computed, 9-2 9-2 unconditional, GRIPE, .GT., 9-1 INTRO-6-3 4-7 H (literal notation), 3-5 H format descriptor, 13-12 Hardware requirements, FOROTS, D-1 Hierarchy of operators, Hollerith literal, 3-5 10-17 10-16 I, using, D-13 FOROTS data files, D-4 FOROTS error processing, D-3 I format descriptor, I/0 1list, 10-5 FOROTS features, FOROTS hardware requirements, INTRO-4-1 D-3 messages, H-1 software requirements, D-1 FOROTS/FORSE compatibility, C-21 FOROTS/LINK interface, D-28 FORSE/FOROTS compatibility, C-21 FORTRAN-10 compiler, B-1 FORTRAN-10 messages, F-1 FUNCTION call, 15-16 Function references, order, C-8 FUNCTION statement, 15-7 13-4 statement, 9-3 arithmetic, 9-3 logical, 9-4 ILL input/output facility, FOROTS IF D-2 D-1 FOROTS 4-9 transfer, FOROTS, FOROTS C-4 9-1 subroutine, 15-21 IMAGE with MODE, 12-4 IMPLICIT statement, 6-5 In I/0 list DO-loop, implied, 10-6 Inaccessible code, C-7 INCLUDE statement, 5-1 INCLUDE switch, B-2 INDEX with DEBUG, B-3 INIOVL in LINK, C-20 Initial line, 2-4 INPUT, INTRO-2-1 Input, line-sequence, 2-6 Input from BASIC, 2-6 Input from LINED, Input/output data, Index-4 2-6 INTRO-5-1 INDEX Line (Cont.), initial, 2-4 facility, Input/output D-3 FOROTS, Input/output list, 10-2 NAMELIST, 10-10 Input/output optimization, C-8 Input/ocutput statement, list-directed, 10-8 Input/output statement multi-statement, Line summary, continuation 2-5 field, 2-3 Line 10-1 formatting characters, 2=-2 Line LINE LINE 10-2 format, Input/output (CONT.) sequence number, B-5 subroutine, 15-21 terminal setting, INTRO-1-1 statement Line 10-24 termination characters, 2-2 INSERT, INTRO-4-1 Inserting a line, INTRO-4-1 Integer constant, 3-2 Integer format, 13-4 Line types, 2-4 Line~-sequence input, Intrinsic LINK-10 6-3 INTEGER statement, function program, input sub- Interrupting execution, INTRO -3-3 beginning a, disconnected from, 2-6 overlay facility, C-20 15-3 Iteration 4 DO-1loop Job, 2-6 LINED, INTRO-1-1 (attach), INTRO-7-3 killing a, INTRO-7-1 number forgotton, INTRO-7-4 JOB number, INTRO-1-2 LINK/FOROTS interface, D-28 List, input/cutput, 10-2 NAMELIST input/output, 10-10 LIST with DISPOSE, 12-5 List-directed input/output statement, 10-8 List-directed transfer, sequential READ, 10-12 sequential WRITE, 10-17 Listing, program, B-5 Literal constant, Literal format conversion, 3-5 13-13 LNMAP switch, B-2 LOAD command, B-4 Location in object program, K (kill file), INTRO-7-1 KAl1l0 switch, B-2 Keyword, K/F fast B-5 1-1 Logging in, INTRO-1-1 LOGIN, INTRO-1-2 Logical assignment statement, 8-4 logout, INTRO-7-2 KI10 switch, B-=2 Killing a job, INTRO-7-1 KJOB, INTRO-7-1 L format descriptor, 13-10 Label assignment statement, Label constant, 3-6 Label field, 2 -3 LABELS with DEBUG, .LE., 4-7 LEGAL Line, subroutine, blank, LOGICAL B-3 15-21 statement, 6-3 Logical unit number, LOGOVL in LINK, C-20 LT., 4-7 10-3 2-6 comment, 2-5 continuation, debug, 8-4 Logical constant, 3-5 Logical expression, 4- 4 Logical FORMAT field descriptor, 13-10 Logical IF statement, 9-4 Logical operator, 4-5 2-4 2-6 definition, fields, 2-2 2-2 MACRO in listing, B-5 MACRO-10 libraries, C-14 MACROCODE switch, B-2 Tndex-5 INDEX Object program, location in, B-5 Messages, FORDDT, E-17 FOROTS, H-1 FORTRAN-10, realtime, Octal constant, 3-4 ODD with PARITY, 12-9 F -1 G-7 4-2 Mixed-mode arithmetic, Mixed-mode assignment 8-1 statement, Mixed-mode (CONT.) OPEN, INTRO-5-3 OPEN statement, 12-1 OPEN statement summary, 12-10 Operator, expression, arithmetic, 4-10, subroutine, MKTBL MODE in 15-22 Operator strength, Optimization, global, C-4 file control 12-4 statement, MONITOR, INTRO- 1-2 program, Monitor, calling the, 4-1 hierarchy, 4-9 logical, 4-5 4-11 OPTIMIZE INTRO-3-3 Multi-statement line, 2-5 Multiple record 13-14 Multiplication, transfer, C-9 switch, B-2 4-5 .OR., 4-1 C-5 Order of OoTS, B-18 statements, 2-7 Output, suppressing printed, INTRO-6-2 Overflow, N, Overlay INTRO-4-5 C-3 facility, LINK-10, Name, symbolic, NAMELIST C-20 3-6 input/output list, 10-10 NAMELIST statement, NAMELIST-controlled input, 11-2 11-1 P, INTRO-4-4 transfer, P (preserve output, 11-3 sequential READ, 10-13 sequential WRITE, 10-17 NE., DO-loop, statement, 1-1 Non-FORTRAN-10 files, Non-FORTRAN-10 programs, NONSHAR, .NOT., C~9 C-9 B-18 4-5 NOWARNINGS switch, INTRO-4 -5 NUMBER subroutine, B-2 NUMBER, 15-22 Numeric, field width variable, 13-10 Numeric format, general (G), 13-7 Numeric FORMAT field descriptor, file control in 12-9 PASSWORD, INTRO-1-2 PATH with DIRECTORY, statement, PPN, 12-7 9-11 INTRO-7-3 Precision for real constant, PRINT, INTRO-4-4 PRINT statement, 10-19 PRINT with DISPOSE, 12-5 Printed output, suppressing, INTRO-6-2 printing lines of source, INTRO-4-4 Program listing, PROGRAM B-5 statement, 5-1 Program, changing, entering, 13-4 running, storing, INTRO-4-1 INTRO-2-1 INTRO-3-1 INTRO-2-2 Programs, 40, 6-9 PDUMP subroutine, 15-22 PLOT subroutine, 15-22 PLOTS subroutine, 15-22 Nested expression, 4-9 NOERRS switch, B-2 NONE with DEBUG, B-3 Nonexecutable PARITY PAUSE 9-6 INTRO-7-1 statement, statement, 4-7 Nested file), PARAMETER non-FORTRAN-10, INTRO-6-2 optimizing, C-9 writing, C-1 O format descriptor, 13-4 Object program, INTRO-3-1 Index-6 C-9 3-2 INDEX Propagation, constant, C-7 PROTECTION in file statement, PUNCH PUNCH with Repeat for format descriptor, control 12-6 statement, (CONT.) REPLACE, 13-3 INTRO-4-3 Replacement, 10-20 DISPOSE, DO-loop, 12-5 Replacing C-8 a line, INTRO-4-3 Reporting, error, REREAD INTRO-4-5 QUIT, RESET B-17 statement, in Return FOROTS, 10-14 C-10 key, carriage, INTRO-1-2 RETURN statement, 15-8, R, R INTRO-4-3 format .RS0S, REWIND descriptor, 13-12 INTRO-2-1 RAN function, 15-12 RANDIN with ACCESS, Random access data statement, 15-14 14-1 RUBOUT key, INTRO-2-3 Running a program, INTRO-3-1 RUNOVL in LINK, C-20 12-3 transfer, 10-1 Random access record S (save file), INTRO-7-1 SAVE with DISPOSE, 12-5 specification, 10-7 Random access transfer, formatted READ, formatted WRITE, SAVRAN 10-13 Scale 10-17 10-13 unformatted READ, unformatted WRITE, RANDOM with ACCESS, 12-3 of double-precision Range numbers, READ statement, 10-11 statement summary, READ Sequence Sequential access, READ, 10-13 10-11, 10-12, 10-13 constant, Real format, REAL statement, 3-2 13-4 messages, G-7 Realtime software, G-1 Record formatting (T and SIZE in file 12-8 X), control specification, access, Reentrant SETRAN subroutine, 15-23 allocation, C-7 INTRO-7-1 Relational expression, 4-7 RELEAS subroutine, REMOVL field, in RENAME, RENAME 15-23 2-4 LINK, C-20 program, B-18 .SHR extension, B-18 SIN function, 15-10 SIND function, 15-11 SINH function, SKIP FILE with a DISPOSE, file, subroutine, FOROTS, 15-23 requirements, D-1 SORT subroutine, SOS, INTRO-2-1 SOS examples, 15-24 INTRO-8-1 Source file, Source program, INTRO-2-1 INTRO-2-1 statement, 6-1 SQORT Index-=7 14-3 15-23 subroutine, Software 12-5 INTRO-6-2 15-11 statement, Specification INTRO-6-2 Renaming 12-6 SLITET B-18 extension, Remarks 14-3 15-23 Register .REL statement, subroutine, SLITE 10-7 program, RECORD 10-13 10-17 Sharable 13-15 statement, 10-12, 10-16, SETABL SFD, 6-3 Realtime random transfer, transfer, 10-11, WRITE, SET Real Record 12-3 10-1 sequential, RECORD 15-23 number, line, B-5 Sequential data transfer, random 13-7 subroutine, SEG, B-18 SEQIN with ACCESS, 10-14 READ 15-23 FORMAT SEQINOUT with ACCESS, 12-3 SEQOUT with ACCESS, 12-3 C-1 INTRO-5-1 in statement, SCALE 10-17 READ, subroutine, factor function, 15-10 INDEX SSAVE switch, B-18 15-23 SSWTCH subroutine, Statement, (CONT.) Statement (Cont.), REAL, 6-3 REREAD, 10-14 RETURN, 15-7, 15-14 REWIND, 14-1 SET RECORD, 14-3 SKIP FILE, 14-3 sTOoP, 9-10 SUBROUTINE, 15-9 ACCEPT, 10-18 Arithmetic assignment, 8-1 arithmetic IF, 9-3 ASSIGN, 8-4 assigned GOTO, 9-2 BACKFILE, 14-3 BACKSPACE, 14-2 BLOCK DATA, 16-1 CALL, subprogram, Statement label 14-1 6-3 Statement numbers, Statement 10-22 5-2, 15-3 constant, 3-6 9-5 DOUBLE PRECISION, ENCODE, 13-2 Statement field, 2-3 Statement format, input/output, 10-2 Statement function 7-1 DATA, DECODE, 10-22 device control, DIMENSION, 6-1 END, FORMAT, 9-2 computed GOTO, CONTINUE, 9-10 control, 9-1 10-21 type specification, 6-3 unconditional GOTO, 9-1 UNLOAD, 14-2 WRITE, 10-16 Statement category, 1l-1 Statement descriptor, 15-13 CLOSE, 12-1 COMMON, 6-5 COMPLEX, 6-3 DO, TYPE, 2-3 summary, CLOSE, 12-10 device control, 14-3 input/output, 10-24 OPEN, 12-10 15-7 END FILE, 14-2 ENTRY, 15-17 EQUIVALENCE, 6-7 executable, 1-1 EXTERNAL, 6-8 file control, 12-1 FIND, 10-21 FORMAT, 13-1 READ, 10-14 WRITE, 10-18 Statements, FUNCTION, 15-7 order of, 2-7 STOP statement, 9-10 Storage of array elements, IF, 9-3 IMPLICIT, 6-5 Sub-file directory, GOTO, 9-1 INCLUDE, 3-10 Storing a Subprogram, 5-1 input/output, INTEGER, 6-3 LOGICAL, 6-3 basic external 10-1 logical assignment, 8-4 logical IF, 9-4 mixed-mode assignment, PUNCH, READ, INTRO-2-2 12-6 function, 15-8 label assignment, 8-4 list-directed, input/output, 10-8 8-1 NAMELIST, 1l1-1 nonexecutable, OPEN, 12-1 PARAMETER, 6-9 PAUSE, 9-11 PRINT, 10-19 PROGRAM, 5-1 program, 1-1 data, 16-1 external function, 15-7 intrinsic function, 15-3 multiple entries to, 15-17 multiple returns from, 15-14 statement function, 15-3 subroutine, 15-9 Subprogram argument, 15-1 Subprogram dummy argument, block 15-1 Subprograms, 15-1 Subroutine, DATE, 15-19 ERRSET, 15-21 ERRSNS, 15-21 EXIT, 10-20 15-21 FORTRAN 10-11 Index-8 supplied, 15-14 INDEX Unconditional GOTO statement, (Cont.), Subroutine 9-1 15-21 ILL, Uninitialized variable, C-8 LEGAL, 15-21 LINE, 15-21 programming consideration, C-2 Subroutine call, 15-13 SUBROUTINE statement, 15-9 Subroutine structure, 15-13 Subroutine subprogram, 15-9 Subscript, array, 3-8 Subtraction, 4-1 Ssuppressing printed output, INTRO-6-2 Switches, compiler, T (trace after PAUSE), 9-12 T format descriptor, 13-15 TAB. INTRO-4-6 TANH function, 15-11 TIM2GO function, 15-12 TIME subroutine, 9-12 15-24 option after PAUSE, TRACE function, 9-13 TRACE subroutine, 9-13 TRACE with DEBUG, B-3 Transfer operations, data, 10-1 .TRUE., TYPE, Unformatted transfer, random access, READ, 10-13 WRITE, 10-17 sequential binary, READ, 10-12 WRITE, 10-16 UNLOAD statement, 14-2 User file directory, 12-6 Variable, 3-7 compiler generated, Warning message, B-17 WHERE subroutine, 15-25 WRITE, INTRO-5-1 WRITE statement, 10-16 WRITE 6-3 statement, X (option after PAUSE), 9-11 X format descriptor, 13-15 .XOR., 10-21 42, UFD, statement summary, 10-18 WRITE transfer, random access, 10-16, 10-17 sequential, 10-16, 10-17 Writing programs, C-1 INTRO-6-1 FUNCTION, 15-7 Type specification statement, +U, B-6 uninitialized, C-8 VERSION in file control statement, 12-8 3-5 INTRO-5-2, Type, TYPE statement, 12-2 Unit number, logical, 10-3 15-24 SYNTAX switch, B-2 SYS, INTRO-7-4 (T) UNIT in file control B-1 SYMBOL subroutine, Symbolic name, 3-6 Trace (CONT.) INTRO-3-4 12-6 Index-9 2-1 4-5 DECsystem-10 FORTRAN Programmer's Reference Manual AA-0944E-TB READER'S COMMENTS : NOTE This form is for document comments only. DIGITAL will use comments submitted on this form at the company's discretion. Problems with software should be reported on a Software Performance Report (SPR) form. If you require a written reply and are eligible to receive one under SPR service, submit your comments on an SPR form. Did you find errors in this manual? If so, specify by page. Did you find this manual understandable, usable, and well-organized? Please make suggestions for improvement. Is there sufficient documentation on associated system programs required for use of the software described in this manual? what material is missing and where should it be placed? If not, Please indicate the type of user/reader that you most nearly represent. [] Assembly language programmer [} Higher-level language programmer 004dg Please cut alon o Occasional programmer (experienced) User with little programming experience Student programmer Non-programmer interested in computer concepts and capabilities Date Name Organization Street City State Zip Code or Country dlilelit}a]1 Il No Postage Necessary it Mailed in the United States BUSINESS REPLY MAIL FIRST CLASS PERMIT NO.33 MAYNARD MASS. POSTAGE WILL BE PAID BY ADDRESSEE SOFTWARE PUBLICATIONS 200 FOREST STREET MR1-2/E37 o— o—— o o— o —— — —— e — — ——— " —— — — — — — — — G—— . — S Cut Along Dotted Line E— — — — — o —— e e e e e et e e e - - - - - — - — — - — — — — — — — — e Do Not Tear - Fold Hereand Tape - - - -\ - -\ - - - _— ———— o MARLBOROUGH, MASSACHUSETTS 01752
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies