1970_PDP 10_Timesharing_Handbook 1970 PDP 10 Timesharing Handbook
User Manual: Pdf 1970_PDP-10_Timesharing_Handbook
Open the PDF directly: View PDF .
Page Count: 534
Download | |
Open PDF In Browser | View PDF |
..;.~ · , .. " ~ ~BmBDmD ~ handbook series '. MONI'foit COMMANDS ARGUMENTS ABB:&EVIATION NAME ASSIGN ASSIGNt ATTACH ATTACHt CCONT COMPILE CaNT CORE CREATE CREF CSTART CTEST D(deposit) DAYTIME DDT DEASSIGN DEBUG DELETE DETACH DETACHt DIRECT E(examine) EDIT EXECUTE FILE FINISH GET HALT KJOB LIST LOAD LOGIN MAKE PJOB R REASSIGN REENTER RENAME RESOURCES RUN SAVE SCHEDULEt SSAVE START SYSTAT TALK TECO TIME TYPE AS AS AT AT CC COM CON COR CREA CREF CS 1 2 ~ SYS Idey dey .i2£ [proj, progj D DA DD DEA DEB DEL DET DET DI E ED EX FIL FIN G tC K LI LOA LOG M PI R REA REE REN RES RU SA SC SS ST SYS TA TE TI TY 3 4 5 [proj, progj core core dey list core .ext .ftk. adr rh Ih adr dey list list dey dey adr file .ext .fu1 arg dey dey .&k .ext list list file .ext file dey .ext job core file file .ext .ext [proj, progj core file .ext core arg dey dey n dey adr dey file job list .ext - Key: adr core dev ldev .ext file job octal address decimal number of lK blocks physical device name logical device name filename extension filename job number assigned by Monitor privileged command octal value of left and right half words Ih rh [proj, progj project·programmer numbers a single file specification or a string of list file specifications a pair of file specifications or a string arg of pairs of file specifications scheduled use of the system. n underline means always required See Book 2 and Book 7 for further explanation of commands. abbreviations are accurate and unique as of now, but their accuracy' 'and uniqueness may be changed in the future by the addition of new com'inltlld~ ~se PDP-tO TIMES NG HANDBOOK Prepared by The PDP-tO Software Writing Group .. Programming Department Digital Equipment Corporation Additional copies of this handbook may be ordered from the Program Library, Digital Equipment Corporation, Maynard, Mass. 01754. Order code AKW. $5.00 each. Discounts are available on five or more copies. PDP-tO HANDBOOK SERIES All rights reserved. Permission to reproduce this handbook or any parts thereof may be obtained from the PDP-I0 Product Line Manager, Digital Equipment Corporation, Maynard, Mass. The material in this handbook is for information purposes and is subject to change without notice. Copyright o@ 1968, 1969, 1970 by Digital Equipment Corporation The following are trademarks of Digital Equipment Corporation, Maynard, Massachusetts: DEC .• Digital PDP " INTRODUCTION TO TIMESHARING (pages 1-1 thru 1-,12) GETTING STARTED WITH THE MONITOR (pages 2-1 thru 2-20) BASIC (pages 3-1 thru 3-78) AID (pages 4-1 thru 4-99) FORTRAN (pages 5-1 thru 5-133) DEMONSTRATION PROGRAMS (pages 6-1 thru 6-49) ADVANCED MONITOR COMMANDS (pages 7-1 thru 7-21) UTILITY PROGRAMS (pages 8-1 thru 8-89) APPENDICES (pages A-I thru B-4) INDEX (pages Index-l thru Index·-lO) III IV FOREWORD We have written this handbook for the individual with little or no programming skill in an attempt to bring timesharing programming competence- to an ever-expanding circle of new computer users. With this volume as his guide, we hope he can soon acquire the necessary programming knowledge to improve his business or professional activity by the application of computer technology. I'm pleased to acknowledge here the work of the many DEC programmers, designers, and engineers who continue to advance the state of the timesharing art in both hardware and software, and the DEC software writers and technical artists who prepared this volume. President, Digital Equipment Corporation v PREFACE In devel~ping its timesharing capability, Digital has built a history of sm:cess very similar to the company's record in realtime. applications. That history started in 1960 when Digital's customers began building timesharing systems around PDP computers. Three years later Digital itself started dev~lopment of its own timesharing system, the PDP-6; and 4t 1964 the PDP-6 became the first timesharing computer to be delivered with manufacturer-supplied hardware and software. Th~ PDP-I0, which emerged in 1967,.is the successful culmination of many years of computer research. Its power, versatility, and low cost make ~t a leader in the general-purpose timesharing field. For its timesharing users" the' PDP-lO perfOmis scientific data analyses, helps make better management decisions, ~ids in engineering and architectural design, ,makes investment analyses, and provide!! management information services. With this handbook, Digital attempts' to bring its doctimentation on timesharing to a par with its hardware and software accomplishments. The handbook is intended primarily for students, scientists, engineers, and financial analysts who have little or no experience in programming. From it they can learn timesharing programming from a remote Tel,etype using disk input' output. This is not to say that an experienced programmer is automatically debarred from using this document. If the reader happens to be a' program~er, he should skip the preliminary books, go straight to the computer 'language in Book 5, and commence programming. In Book 6 he will find that Demonstration Programs..~3 and 4 are geared to his level of programming knowledge and competence. A synoptic view of the contents of the handbook is as follows. Book 1 describes the evolutionary hist9ry of timesharing and gives the reader an insight into the way it operates. Book 2, in explaining the elementary monitor commands, shows the reader how 'to get on the system. In Books, 3 and 4 the reader will find conversational programming with BASIC and AID, respectively. Book 5, 'as already indicated, contains FdRTRAN. Four demonstration ,programs constitute Book 6; advance~ monitor commands are found in Book 7; and the four utility' programs Batch,CHAIN, LINED, and TECO appear in Book 8. Since the handl"ook will be revised periodically in order to improve it and keep it up to date, we solicit the reader's constructive evaluations in the questionnaire at the back of the book. Please fill out the questionnaire and return it to PDP-I0 Software Writing Group Programming Department Digital Equipment Corporation Maynard, Massachusetts 01754 A companion volume, the PDP-! 0 Reference Handbook; is likewise iIi, print. It is oriented toward experienced programmers who are interested in writing and -operating assembly;-language programs. VI CONTENTS v Foreword Preface Book 1 VI Introduction to Timesharing ................................................'............................... . 1-1 A general description of the operation of a variety of factors in the evolution of timesharing.' Book 2 Getting Started with the Monitor ........................................................................ 2-1 Logging in, description of files, elementary commands to create, edit, manipulate, translate, load, and execute files, getting information from the system, .. and logging off the system. Book 3 Conversational Pr9gramming with BASIC 3-1 A complete book, explaining the procedures for logging in, logging off, and writing, editing, and running programs in BASIC-a problem-solving conversational language that can be used to solve both simple and complex mathematical problems. '-. Book 4 Conversational Programming with AID A complete book explaining how to program in AID, an algebraic conversational language designed to solve both simple and complex numerical problems. 4-1 Book 5 Programming in FORTRAN .................... :, .......................................... .-............ 5-1 A reference ~ook describing the specific statements and features of the FORTRAN IV language, designed primarily for the experienced FORTRAN programmer. Book 6 6-1 Demonstration Programs Four programs designed to utilize concepts and commands discussed in this manual. Demonstrations three and four also make use of advanced commands in TECO and DDT. Book 7 Advanced Monitor Commands ............................................................................ 7-] Explanation of monitor commands not covered in Book 2-commands to allocate system resources, produce line printer listings, manipulate core images, start a program, and get information from the system. Book 8 Utility Programs .................................................................................................... Includes BATCH-sequential execution of a series of jobs, CHAIN-allows users to deal with FORTRAN programs too large to fit or load into the amount of core available, LINED-a line-oriented editor designed for use on the disk, and TECO--description and explanation of the most frequently used commands of this powerful text editing program. 8-1 Appendices ............................................................................................................................. A-] .. Master Index ....................... ,........................................................................................... Index-l VII , • . VIn Bookt Introduction to·.· Timesharing _, 1 .- ,;.t. j • INTRODUCTION TO TIMESHARING Why Timesharing? Early computers were the province of the mathematician. Used mainly to solve differential equations, the systems were narrow in scope and poorly utilized. Since few persons were knowledgeable enough to employ the enormous processors, one individual could monopolize computer time-sit at the console and solve problems in step-by-step fashion. As more people discovered computin~ techniques, it was no longer practical to let a few persons monopolize computer time. To increase machine efficiency, batch processing was introduced. In this mode of operation; no time was wasted between jobs. Programs were punched on cards and the,cards stacked and fed to the computer jn batches. Operation of each program was gov/ erned by control cards that took the place of the human operator. batch processing Since card reading is a relatively slow process, some early systems employed a small computer to read the cards and transfer program information to magnetic tape that was then input to the large computer. As a further refinement, programs were assigned priorities, with short jobs being executed first to minimize job turnaround. But what about the computer user? As computer utilization improved, program development took more time. To develop a new program, a user performed the following procedure. After writing the program on paper, he carried it to a keypunch operator to have the cards punched and verified. A day or so later, when the program was returned, the user checked for punching errors, then returned to the keypunch for corrections. Next, he sent the cards to the computer center for compilation. The compilation, which might not be returned for a half day' or more, could ,reveal spelling or syntactical errors. The cards then had to be changed and resubmitted-another half day's wait. If the next compilation was successful and the program was run, program logic errors -might be discovered-new cards, new compilation, etc., etc. In addition, the user often studied reams of computer listings to find the errors. Using these inefficient methods, even simple programs might take weeks to develop. Batch processing maximizes machine efficiency in routine data processing operations where turnaround is not critical. But .for program development and modification, the user requires another mode of operation. The user needs a way to "interact" with the computer-to feed-his program to the system, line by line, and continuously check the results. 1-3 interaction • In .fact, the user may want to develop interactive programs. These programs, which are extremely productive toofs, ask the user questions and perform an analysis based on his answers. Electronic circuit design programs are a'prime example. The computer actually designs the circuit by asking the engineer questions and manipulating his answers. In addition, interaction provides a 'new dimension in management information reporting. Via an interactive terminal, a manager can request summaries, plot trends in plant operation and sales, and select special data for use in decision making. dedicated system , timesharing If the user had unlimited funds, he might be teQIpted to buy or lease a large computer~a system he could dedicate to his work that would provide sufficient power, many peripherals, and a large variety of software. With such a syst~m, the user could develop programs interactively or utilize batch processing for routine tasks. However, costs in excess of $20,000 per month normally preclude the dedication of a large system to a single user,. By using timesharing, the user has most of the benefits of a dedicated system at a small fraction of the cost. Timesharing with today's technology allows a large powerful computer to handle 20, 50, 100 or more users simultaneously. Through a choice of terminals, the user can interact with the system or initiate batch proc~ssing which runs .c9ncurrently. The user also has access to a choice of mass storage and pedpherals and a, selection of languages and application programs. Since response is fast, the user appears to have a 'dedicated system. Yet costs are shared. He pays only for the time and facilities that he requires and doesn't pay for the time the machine is idle. The Operation of a Timesharing System - A timesharing system isn't just any computer with some, additional hardware and software. It's a system designed specifically for timesharing. Otherwise, facilities are limited, fewer us'ers can be handled efficiently, and economics are unattractive. At 'a, minimum, a timesharing system requires a central processor with sufficient speed and power, input/output terminals, and an amount of core memory 'adequate to hold several users. ' time slice time quantum round robin operation In a simple timesharing system, each program is assigned a fixed time slice or time quantum and operation is switched from one program to an.other in round robin fashion until each program is completed. Essentially, if-.each user receives 1/60 of a second and 12 users are "on" the system, each , user will receive service every 1/5 of a second. ' 1-4 The timesharing system performs multiprogramming; that is, it allows several programs to reside in core simultaneously and to operate sequentially. The switching between programs, called context switching, is initiated by a clock which interrupts the central processor to signal that a certain time period has elapsed. The interrupt function is provided by a priority interrupt system. A monitor, also called an operating system or executive program, directs the execution of these tasks and performs other housekeeping duties. The monitor is also involved in keeping the actions of a user within his assigned memory space. A hardware device, a memory protection register, which is set by the monitor, limits the core area that a particular user can access. Any attempt by the program to read or change information outside that limit will automatically stop the program and notify the monitor. The system discussed so ·far services a number of users sequentially in round robin fashion. To increase the number of users serviced, more main memory or core is required. However, since core is expensive, a secondary memory is employed. This memory -usually magnetic disk or drum-is slower than core or main memory but provides greatly increased capacity at reasonable cost. User programs can be located in secondary memory and moved into main memory for execution. Programs entering main memory exchange places with a program (or programs) that has just been serviced by the central processor. This operation is called swapping (see diagram). MONITOR USER 1 USER 5 USER 2 SWAPPING DEVICE USER 3 USER 4 SWAPPING - 1-5 multiprogramming context switching , clock priority interrupt system monitor, operating system executive program memory protection register main memory secondary memory swapping . memory blocks input/ output processor asynchronous design In· operation, main memory is divided into separate memory blocks. Secondary memory is connected to these blocks thrQugh a high speed input/output processol'-a hardware device that allows the disk or drum to· swap a program into anyone of th~ main memory blocks without any aid from the central processor. This structure allows the central processor to be operating a user program in one block of memory while .programs are being swapped to ~d from another block. This independent overlapped operation, which greatly improves efficiency and processing power, is characteristic of an asynchronous system design philosophy. See diagram. MEMORY STRUCTURE TO INPUTIOUTPUT DEVICE Dynamic Scheduling compute bound I/O bound sc~eduling algorithm queue Round robin scheduling, in which each program operates in sequence and receives a fixed amount of time, is effective only if· all programs have similar requirements. Such is not the case, however. At any particular time, a timesharing system will be handling some programs which require extensive amounts of computing time (and are said to be compute bound) arid other programs that must stop frequently for input or output (I/O bound). . To serve programs at and between these two extremes, the scheduling algorithm must provide frequent service to I/O bound programs and must give compute bound jobs longer time quantums to prevent wasteful swapping.. A simple dynamic scheme could provide two queues-one for each type of job. When a user first logs on to the system, he is placed in ap I/O bound queue (waiting line) where he receives frequent service and small time quantums. If the program isn't completed or does not request input or output during the time allotted to him, the job needs more computing time and is placed in the compute bound queue. Thus the scheduling algorithm optimizes system efficiency by automatically adjusting to program requirements . . 1-6 In the present state of, scheduling art, algorithms are constantly being changed and improved. Current algorithms are extremely sophisticated, providing excellent service for most timesharing job mixes. They also allow fine tuning, if such modifications are necessary. The ability of the algorithm to match processing to program requirements .insures the best service possible for all user programs. In an efficient timesharing system, monitor functions (referred to as monitor overhead) take 5 to 10 percent of central processor time, making 90 to 95 percent of the time available to users. monitor overhead Sharing Software Since users of large timesharing systems have varying requirements, a good system provides a wide variety of software-interactive languages such as BASIC and AID for the computations of the engineer and scientist, FORTRAN for more complex calculations, COBOL for data processing functions. Therefore many users can have compilers and other common programs in core at the same time. MONITOR MONITOR FORrRAN COMPILER 1 FORTRAN PURE CODE FORTRAN COMPILER 2 FORTRAN COMPILER 3 NON-REENTRANT REENTRANT To prevent excessive core usage which results when a program is duplicated for several users, reentrant software is employed. That is, the program is written in two parts. One part contains pure code that is not modified during execution and can be used to simultaneously service any number of users. For example, the pure code portion of FORTRAN can service multiple FORTRAN users. A separate second part of the program belongs strictly to each user and consists of the code and data that is developed during the compiling process (impure code). This section is stored in a separate area of core. A comparison of memory usage in the non-reentrant and reentrant systems is shown in the diagram above. '1-7 • reentrant software pore 'code impure code -,- overlay dual me!mory protection and relocation What are. the benefits of reentrant software? First, less core is required. For. example, a reentrant system can service three FORTRAN users with 'one 8K compiler and three2K user areas, a total of 14K. A non..reentrant system would require 30K for the three 8K compilers and three 2K user areas. Total saviJlgs in this case is 16K of core. Using less core means that more programs c~ fit into a given amount of spaCe. The monitor then swaps less often and spends less time swapping the smaller impure sections. There are other savin~ too. Since the pure code never changes, it doesn't have to be returned to disk storage (swapped out). As long as a single copy is maintained on the disk, it can be called into core at any time. Programs can be swapped in or "overlayed" on top of the compiler to take its place in core whenever compiler is not needed. To protect the pure code from being modified, a. hardware feature is provided-dual memory protection and relocation. This feature allows a program to execute as two separate segments, one of which is protected. User programs, can also be written to· make use of this protection. For example, a user might develop a reentrant information retrieval system ~tten in COBOL. the Communications ~set modem data line muitiplexOl' data Hoe scanner Co~unication between the remote user and the computer passes over the conventional dial-up telephone network. User terminals can therefore be located anywhere that phone service is available and connected to any computer system, feasibility limited only by long distance phone rates. Each user tenirinal is connected to a data set or modem (modulator-demodulator) which converts us,er terminal output into a signal suitable for the telephone network. At the computer end of the phone lines, there is another data set which reconverts the signal and feeds it to a device called a data line multiplexor or data line scanner. This 'deviCe, in turn, feeds the information from a number of. terminals to the central processor (see diagram). COMMUNICATIONS 1-8 The number of data sets employed at the user end of the system is unlimited. At the computer end of the communications network, however, the number of data sets is limited by the number of users that can be serviced simultaneously by the system. In order to gain access to the system, the user dials the system phone number from his data set. The telephone network handles the call, scanning the data sets at the computer system. If all of the sets are busy, the user receives a busy signal, jllSt as he would with normal phone service. If a set is available, the telephone net- work rings it, causing the data line scanner to interrupt the 'monitor. The computer answers the call, placing the user in communication with the monitor. The terminal is then on-line and ready for operation. on-line Control of Inpnt/ Output A timesharing system has performed its basic function if it allows a number of users simultaneous access to a central computer. However, to be fully useful, the system should also allow the users access to other system resources-storage devices for his programs and data, line printers, card readers, etc. For example, the user should be able to choose between magnetic tape and disk for program storage. And it" he has a 50-page report to produce, he should be able to employ a line printer instead of his Teletype@. 'If users controlled these devices, however, much confusion might result. For example, two users might select the line printer at the same time. If one user was processing Abraham Lincoln's Gettysburgh Address and another, Mark Anthony's funeral oration, the report might look like ,the ~ollowing: I COME TO BURY CAESAR, NOT TO PRAISE HIM FOUR SCORE AND SEVEN YEARS AGO THE EVIL THAT MEN DO LIVE AFTER THEM OUR FATHERS BROUGHT FORTH ON THIS CONTINENT To prevent users from interfering with each other, the monitor coordinates input and output (I/O). The processor has an operating mode switch which the ,monitor sets, before a user program is run. If the program attempts to perform input or output, the user program is stopped and the monitor takes over. Control thus diverted to the monitor is called' trapping. When input/output is , prevented or trapped, the computer is said to be in user mode; when I/O can be performed, the system is in executive or mQllitor "~, _....I... ....,..,. j ·.of ®-registered trademark. of Teletype Corporation, Skokie, Illinois 1-9 , input/ _tput control ' trapping DSel'mode execudve mode • ill. . . . When the system is in user mode, _the memory protection feature is -in operation. In monitor -mode, this feature isoisabled and the monit()r has access to. all of core. User mode also prevents the usecfrom issuing a HALT command, which could stop op<. eration of the entire -system. - monitor calls programmed operators overlapped 1/0 access time latency optimization User-to-monitor-mode switching occurs when the user .reRemember that the CONFIRM message is typed only if there are files on your disk area. If there are no files on your disk area, the typeout would look like the following: .:. KJOB ) . . JOB 17, USER [27,32011 LOGGED OFFTTY17 131720-FEB-70 RUNTIME 0 MIN, 00.29 SEC 2.10 HOW TO LIVE WITH THE TELETYPE On the Teletype, there is a special key marked CTRL called the Control Key. If ,this key is held down and a character key.is depressed, the Teletype types what is known as a controf character rather than the character printed on the key. In this way, more characters can be used than there are keys on the keyboard. Most of the control characters do not print on the Teletype, but cause special functions to occur, os described in the following sections. There are several other special keys that qre recognized by the system. The system constantly monitors the typed characters and, most of the time, .sends the C?haracters to the program being executed. The important characters not passed to the program are also explained in the following sections. (See also the PDP-10 Reference Handbook, Communicating With the Monitor .) 2. 10.1 Control - C Control - C (t'e) interrupts the program that is currently running and takes you back to the monitor. The monitor responds to a control - C by typing a period on your Teletype, and you 2-18, may then type another monitor command. For example, suppose you are running a program in BASIC, and you now decide you wanHo leave BASIC and run a program in AID. When BASIC requests input from your Teletype by typing an asterisk, type control - C to terminate BASIC and return to the monitor You may now issue a command to the monitor to initialize AID (. R AID). If the program is not requesting input from your Teletype (i.e., the program is in the midd Ie of execution) when you type control - C, the program is not stopped immediately. In this case, type control - C twice in a row to stop the execution of the program and return control to the monitor. If you w ish to continue at the same place that the program was interrupted, type the monitor command CONTINUE. As an example, suppose you want the computer to add a million numbers and to print the square root of the sum. Since you are charged by the amount of processing time your program uses, you want to make sure your program does not take an unreasonable amount of processing time to run. Therefore, after the computer has begun execution of your program, type control - C twice to interrupt your program. You are now communicating with the monitor and may issue the monitor command TIME to find out how long your program has been running. If you wish to continue your program, type CONTINUE and the computer begins where it was interrupted. 2.10.2 The RETURN Key This key causes two operations to be perfo~med: (1) a carriage-return and ( 2 ) an automatic line-feed. This means that the typing element returns to the beginning of the line (carriagereturn) and that the paper is advanced one line (line-feed). Commands to the monitor "are terminated by depressing this key. 2.10.3 The RUBOUT Key The RUBOUT key permits correction of typing errors. Depressing this key once causes the last character typed to be deleted. Depressing the key n times causes the last n characters typed to be deleted. RUBOUT does not delete characters beyond the previous carriage-return, line-feed, or altmode. Nor does RUBOUT function if the program has already processed the characters you wish to delete. The monitor types the deleted characters, delimited by backslashes. For example, if you were typing CREATE and go as far as CRAT, you can correct the error by typing two RUBOUTS and then the correct letters. The typeout wou ~d be CRAT\TA\EATE 2-19 Notice that you typed only two RUBOUTS, but \TA\ was printed. This shows the deleted . characters, but in reverse order. 2~ 10.4 Control - U Contr-ol - U (t U ) is used if you have completely mistyped the current line and wish to start over aga in. Once you type a carriage-return, the command is read by the computer, and line-editing features can no longer be used on that line. Control - U causes the deletion of the entire Une, back to the last carriage-return, line-feed, or altmode. The system responds with a carriage-return, line-feed so you may start again •. 2.10.5 The ALTMODE Key The ALTMODE key, which is labeled ALTMODE, ESC, or PREFIX, is used as a command terminator for ~veral programs, including TECO and LINED. Since the ALTMODE is a non- printing character,. the Teletype prints an ALTMODE. as a dollar sign ( $ ). 2.10.6 Control - 0 Control - 0 (t 0) tells the computer to suppress Teletype output. For example, if you issue a command to type out a 100 lines of text and then decide that you dcr not want the typeout, type control - 0 to stop the output. Anothe.r command may then be typed as if the typeout had terminated normally. 2.10.7 Control - 8 Control - 8 (t 8) affects the printing of Teletype output in one of two ways depending on your Teletype; it either· restores printing of the characters or suppresses double printing of the characters. Suppose that when you begin typing on the Teletype, you notice that the characters you are typing are not printing on the Teletype paper. Type control - 8 to restore the printing of the characters. On the other hand, su·ppose you r~ceive double printing of your typeiilS. To suppress this double printing, type control - ·8. 2.10.8 Control - F This control character is needed only for the KSR37 Teletype. This key changes the way lower case characters are handled by the system; Normally, the system converts all lower case letters to upper case. Since the KSR37 Teletype is capable of transmitting both lower and upper case letters, control - F is used to permit the entry of lower case letters. 2-20 .~ Book 3 ,Conversational Programming With BASIC • CONTENTS CHAPTER INTRODUCTION Page 1.1 Example of Basic Program 3-9 1.2 Discussion of the Program 3-10 1.3 Fundamental Concepts of Basic 3-13 1.3.1 Arithmetic Operations 3-13 1.3.2 Mathematical Functions 3-14 1.3.3 Numbers 3-15 1.3.4 Variables 3-15 1.3.5 Relational Symbols 3-15 1.4 Summary 3-16 1.4.1 LET Statement 3-16 1.4.2. READ and DATA Statements 3-16 1.4.3 PRINT Statement 3-17 1.4.4 GO TO Statement 3-18' 1.4.5 IF - THEN Statement 3-18 1.4.6 ON - GO TO Statement· 3-19 1.4.7 END Statement 3-19 ,CHAPTER 2 LOOPS . 2.1 FOR and NEXT Statements· 3-22 2.2 Nested Loops 3-23 2.3 Summary 3-23 2.3.1 FOR and N EXT Statements 3-23 CHAPTER 3 LISTS AND TABLES 3.1 The Dimension Statement (DIM) 3-26 3.2 Example 3-27 3.3 Summary 3-28 3.3.1 The DIM Statement 3-28 CHAPTER 4 HOW TO RUN BASIC 4.1 Gaining Access to Basic 3-29 4.2 Entering the Program 3-30 3-3 • - - - - --.- • CONTE~TS (Coot) Page 4.3 Executing the Program 3-31 4.4 Correcting the Program 3-31 4.5 Interrupting the Execution of the Program 3-31 4.6 Leaving the Computer 3-32 4.7 Example of Basic Run 3-32 4.8 Errors and Debugg ing 4.8.1 Example of Finding atic! Correcting Errors 3-34 3-34 CHAPTER 5 FUNCTIONS AND SUBROUTINES 5.1 Functions 3-31 5.1.1 The Integer Function (lNT) 3-37 5.1.2 The Random Number Generating Function (RND) 5.1.3 The RANDOMIZE Statement 3-38 ,3-39 5.1.4 The Sign Function (SGN) 3-40 5.1.5 5.2 . The Define User Function (DEF) and Function End Statement (FNEND) 3-40 Subroutines 3-41 5.2.1 GOSUB and RETURN Statements 3-41 5.2.2 Example 3-42 CHAPTER '6 MORE SOPHISTICATED TECHNIQUES 6.1 More About the Print Statement 3-45 6.2 Input Statement 3-48 6.3 Stop Statement 3-49 6.4 Remarks Statement (REM) 3-49 6.5 Restore Statement 3-49· CHAPTER 7 VECTORS AND MATRICES 7.1 MAT Instruction Conventions 3-52 7.2 MAT C"= ZER, MAT C = CON, MAT C = ION 3-52 7.3 MAT Pril)t A, B, C 3-53 7.4 MAT Input V and the NUM Function 3-54 7.5 MAT B=A 7.6 MAT C = A + Band MAT C = A - B ·3-55 3-4 3-55 CONTENTS (Cont) Page =A * B 7.7 MAT C 7.8 MAT C :;: TRN(A) 3-55 7.9 MAT C :;: (K) * A 3-55 7.10 MAT C = INY(A) and the DET Function 3-55 7.11 Examples of Matrix Programs 3-56 7.12 Simulation of N-Dimensional Arrays 3-57 3-55 CHAPTER 8 ALPHANUMERIC INFORMATION (STRINGS) 8.1 Reading and Printing Strings 3-59 8.2 String Conventions 3-60 8.3 Numeric and String Data Blocks 3-61 8.4 Accessing Individua I Characters 3-61 CHAPTER 9 EDIT AND CONTROL 3-65 CHAPTER 10 DATA FILE CAPABILITY 10.1 FI LES Command 3-67 10.2 SCRATCH Command 3-68 10.3 WRITE Command 3-68 10.4 RESTORE Command 3-69 10.5 IN PUT Command 3-69 10.6 I F END Command 3-70 ' 3-5 PREFACE WHY BASIC? BASIC is a problem-solving language that is easy to learn and conversational, and has wide application in the scientific, business, and educational communities. It can be used to solve both simple and complex mathematical problems from the user's Teletype@ and is particularly suited for time-sharing. In writing a computer program, it is necessary to use a language ~r vocabulary that the computer recognizes. Many computer languages are currently in use, but BASIC is one of t~e simplest of these because of the small number of clearly understandable and readily learned commands that are required, its easy application in solving problems, and its practicality in an evolving educational environment. BASIC is similar to other programming languages in many respects; and is aimed at facilitating communication between the user and the computer in a time-sharing system. As with most programming languages, BASIC is divided into two sections: a. Elementary statements that the user must know to write simple programs, and b. Advanced techniques needed to efficiently organize complicated problems. As a BASIC user, you type in a computational procedure as a series of numbered statements by u~ing comman English syntax and familiar mathematical notation. You can solve almost any problem by spending an hour or so learning the necessary elementary commands. After becoming more experienced, you can add the advanced techniques needed to perform more intricate manipulations and to express your problem more efficiently and concisely. Once you have entered your statements via the Teletype, simply type in RUN or RUNNH. These commands initiate the execution of your program and return your results almost instantaneously. SPECIAL FEATURES OF BASIC - BASIC incorporates the following special features: a. Matrix Computations - A special set of 13 commands designed exclusively for performing matrix computations. h. .A~z::: Inlfm'lll'fatiori Handling - Single alphabetic or alphanumeric strings or vect.on ~n be ' read, printe-d, and defined in LET and If ••• THEN statements. Individual characters within these strings can be easily accessed by the user. Conversion can be performed between characters and their ASCII equivalents. Tests can be made for alphabetic order. @Teletype is the registered trademark of Teletype Corporation. 3-7 c. Program Control and Storage Facilities - Facilities are inc1uded that store programs or data on a mc,ss storage devic.e (e.g., disk or DECtape) and later retrieve them for execution. You,· as the user, . can also i'1'ut programs from the standard fow-speed Teletype paper tape reader as well as fromthe highspeed paper tape reader at the PDP-l0 site. d. Program Editing Facilities - An existing,program can be edited by adding or deleting lines, by renaming the program, or by resequencing the line numbers. The user can combine two programs into a single program and request a listing of his program, either in whole or in part, on his Teletype or on a high-speed line printer. e. Formatting of Output - Controlled formatting of Teletype output includes tabbing, spacing, and . printing columnar headings. f •. Documentation and Debugging Aids - Documenting programs by the insertion of remarks within proc~ures enables recglJ of.needed information at some later date and is invaluable in situations in which the program is shared by other users. Debugging of programs is aided by the typeout of meaningful ~iagnostic messages which pinpoint syntactical and logical errors detected during execution. 3-8 CHAPTER 1 INTRODUCTION This chapter intraduces the user to PDP-l0 BASIC and to its restrictions and characteristics. The best , introduction lies in beginning with a BASIC program and discussing each step coftl)letely. 1. 1 EXAMPLE OF A BASIC PROGRAM The following example is a complete BASIC program, named LINEAR, that can be used to solve a system of two simultaneous linear equations in two variables ax+by=c dx+ey=f and then used to solve two different systems, each differing from the above system only in the constants c and f. Ifae - bd is not equal to'O, this system can be solved to find that ce - bf x = ae - bd and af - cd y=ae-bd If ae - bd = 0 j there is either no solution or there are many, but there is no unique solution. Study this example carefully and then read the commentary and explanation.' (In most cases the purpose of each line in the pragram is ~If-evident.) 1121 15 2121 30 37 42 55 60 65 70 80 85 90 READ A,B,D,E LET G=A*E-B*D IF G=eJ THEN 65 READ C,F LET X=(C*E-B*F)/G LET Y=CA*F-C*D)/G PRINT X,Y GO TO 3121 PRINT "NO UNIQUE SOLUTION" DATA 1,2,4 DATA 2,-7,5 DATA 1,3,4,-7 END 3-9 " NOTE All statements are terminated 'by pressing t~' RETURN' key (represented in this text by the symbol,,) ).•. The RETURN ~ey echoes as' a carriage return, line feed. " 1.2 DISCUSSION OF THE PROGRAM Each line of the program begins with a line number of 1 to 5 digits that serves to identify the line as a statement. A program is made up of statements, most of which are instructions to the computer. line numbers serve to specify the order in which these statements are to be performed. 'Before the program is run, BASIC sorts out and edits the program, putting the statements into the order specified by their line numbers; thus, the program statements can be typed in any order I as long as each statement is prefixed with a line number indicating its proper sequence in the order of execution. Each statement starts after its line number Mth an English word which denotes the type of statement. Spaces have no significance in BASIC, except in messages which are printed out, as in line number 65 above. Thus, spaces mayor may not be used to modify a program and make it more readable. With this preface, the above example can be followed through step-by-step. The first statement, 10, is a READ statement and must be accompanied by one or more DATA statements. When the computer encounters a READ statement wh ile executing a program, it causes the variables I isted after the READ to be given values according to the next available numbers in the DATA statements. In this example, we read A in statement 10 and assign the value 1 to it from statement 70 and, similarly, with Band 2, and with o and 4. At this point, the available data in statement 70 has been exhausted, but there is more in statement 80, and we pick up from it the value 2 to be assigned to E. 15 LET G=A*E-B*D Next, in statement 15, which is a LET statement, a formula ls to be evaluated. [The asterisk (*) is used to de- note multip~ication.] In 'this statement, we compute the value of AE - BO, and call the result G. In general, a LET statement directs the computer to set a variable equal to the formula on the right side of the equal sign. 20 . IF G=0 THEN 65 If G is equal to zero, the system has no unique solution. Therefore, Wf!J next ask, in line 20, If G is equal to , zero. , 3-10 65 70 80 85 90 PRINT "NO UMIQUE SOLUTION." DATA 1.2.4 DATA 2.-1.5 DATA 1 • 3, Lj, -7 END If the computer discovers a ''yes'' answer to the question, it is directed to go to line 65, where it prints NO UNIQUE SOLUTION. Since DATA statements are not executable statements, the computer then goes to line 90 which tells it to END the program. 30 READ C.F If the answer is "no" to the question "Is G equal to zero?", the computer goes to line 30. The computer is now directed to read the next two entries, -7 and 5, from the DATA statements (both are in statement 80) and to assign them to C and F, respectively. The computer is now ready to solve the system x +2y =-7 4x+2y=5 37 42 LET X=(C*E-B*F)/G LET Y=(A*F-C*D)/G In statements 37 and 42, we instruct the computer to compute the value of X and Y according to the formulas , provided, using parentheses to indicate that C*E - B*F is calculated before the result is divided by G. 55 60 PRINT X.Y GO TO 30 The computer prints the two values X and Y in line 55. Having done this, it moves on to line 60 where it is reverted to line 30. With additional numbers in the DATA statements, the computer is told in line 30 to take the next one and assign it to C, and the one after that to F. Thus, x + 2y =1 4x + 2y =3 As before, it finds the solutions in 37 and 42, prints them out in 55, and then is directed in 60 to revert to 30. In line 30, the computer reads two more values, 4 and -7, which it finds'in line 85. It then proceeds to solve the system x +2y =4 4x + 2y =-7 3-11 and print out the solutions. Since there are no mOre pairs of numbers in the DATA statement a~ilable for C and 'F, the computer prints OUT OF DATA IN 30 and stops. If line number 55 (PRINT X, Y) had been omitted, the computer would have solved the three systems and then told us when it was out of data. If we had omitted line 20, and G were equal to zero, the computer would print DIVISION BY ZERO IN 37 and DIVISION BY ZERO IN 42. Had we omitted statement 60 (GO TO 30), the computer would have solved the first system, printed out the values of X and Y, and then gone to line 65 , where it would be directed to print NO UNIQUE SOLUTION. The particular choice of line numbers is arbitrary as long as the statements are numbered in the order the ' machine is to follow. We would normally number the statements 10, 20, 30, ••• , 130, so that later we can find that we have omitted two statements between those numbered 40 insert additional statements. Thus, if we . . and 50, we can give them any two numbers between 40 and 50 -- say 44 and 46. Regarding DATA statements, ' . . we need only put the numbers in the Order that we want them read (the first for A, the second for B, the third for D, the fourth for E, the fifth for C, the sixth for F, the seventh for the next C, etc.). In place of the three statements numbered 70, 80 , and 85 I we could have written the statement: or, more naturally I 70 75 80 85 DATA DATA DATA DATA . 1 .. 2 .. 4 .. 2 -7 .. 5 1 .. 3 4 .. -7 to indicate that the coefficients appear in the firSt data statement and the various pairs of right-hand constants appear in the subsequent statements. The program and the resulting run is shown below as it appears on the Teletype. 10 15 20 30 37 42 55 60 65 70 80 85 90 RUN READ A .. B .. D.. E LET G=A*E-B*D IF G=0 THEN 65 READ C .. F LET X=(C*E-B*F)/G LET Y=(A~F-C*D)/G PRINT X.. Y .GO TO 30 PRINT "NO UNIQUE SOLUTION" DATA 1 .. 2 .. 4· DATt) 2 .. -7 .. 5 .DATA 1-..3 .. 4 .. -7 END (continued on ,next page) " 3-12 11 : 0 3 LINEAR 10/19/69 -5.50000 0.166667 3.83333 OUT OF DATA IN 30 4 0.666667 -3.66667 NOTE Remember to terminate all statements by pressing the RETURN key. After typing the program, we type the word RUN, followed by a carriage return to direct the computer to execute the program. Note that the computer, before printing out the answers, printed the name LINEAR which we gave to the problem (refer to paragraph 4.1) and the time and date of the computation. fhe message OUT OF DATA IN 30, may be ignored here. However, in some instances, it indicates an error in the program. 1.3,\ FUNDAMENTAL CONCEPTS OF BASIC BASIC can perform many operations such as adding, subtracting, multiplying, dividing, extracting square roots, raising a number to a power, ,and finding the sine of an angle measured in radians. 1.3.1 Arithmetic Operations The computer performs its primary function (that of computation) by evaluating formulas similar to those used in standard mather:natical calculation, with the exception that all BASIC formulas !Oust be written on a single line. Five arithmetic operations can be used to write a formula. If we type A + B * C to, Meaning Symbol Example + A+B add B to A A-B subtract B from A * A*B multiply B by A / A/B divide A by B X t 2 find X2 the computer first raises C to the power 0, multiplies this result by B, and then adds the resulting product to A. We must use parentheses to indicate any other order. For example, if it is the product of Band C that we want raised to the power 0, we must write A + (B * C) t 0; or if we want to multiply A + B by C to the power 0, we write (A + B) * C t D. We could add A to B, multiply their sum by C, and raise the product to the power 0 by writing «A + B) * C) to. The order of precedence is summarized in the following rules. 3-13 a. The formula inside parentheses is evaluated before'the parenthesized quantity is used in computations • : b. In the absence or parentheses in a formula, BASIC performs exponentiations first, multiplications ; and divisions second, and additiOns and subtractions third. ~. In the absence of parentheses in a formula involving only multiplications a'nd divisions, BASIC performs the operations from left,to right, in the ordertliat 'they_are read. d. In the ,absence of parentheses in a tormula involving only additions and subtractions, BASIC performs the operations from left to right, in the order that they are read. The rules te II us that the computer, faced with A - B - C, (as usua I) subtracts B from A, and then C from their difference; faced with A/B/C, it divides Aby B, and that quotient by C. Given A t B t C, the computer raises the number A to the power B and takes the resulting number and raises it to the power C. If there is any question about the precedence, put in more parentheses to eliminate possible ambiguities. 1.3.2 Mathematical Functions In addition to these five arithmetic operations, BASIC can evaluate certain mathematical functions. These functions are given special three-letter English names. • Interpretat ion Function SIN (X) Find the sine of X {X COS (X) Find the cosine of X TAN (X) Find the tangent of X ;nte B >= A>= B A is greater than or equal to B <> A<>B A is not equal to B = < <= A A A is less than or equal to B A is greater than B 3-15 1.4 SUMMARY .,... , -' ~r - ;::~.; .' , - : ,. , Several elementary BASIC commands have been introduced in our discussions. In describinr, dClch of these commands,. a line number is assumed, and brackets are used to denote a general type~ For example, {variablel ; refers to any variable. 1.4. 1 LET Statement The LET statement is used when computations must be performed. This command is not of algebraic equality, but a command to the computer to perform the indicated computations and assign the answer to a certain variable. Each LET statement is of the form: LET [variab Ie 1 = [formula] Generally, several variables may be assigned the same value by a single LET statement. Examples of assigning a value to a single variable are given in. the following two statements: 100 259 LET X=X+1 LET W7=(W-X4t3)*(Z-A/(A-B)-17) Examples of assigning a value to more than one variable are given in the following statements: ( LET X=Y3=A(3,1 )=1 The variables X, Y3, and A(3, 1) are assigned the value 1. The variables W and Z are assigned the value 3,*X-4X f 2 1.4.2 READ and DATA Statements READ and DATA statements are u"sed to enter information into the computer. We use a READ statement to assign to the listed variables th~ values which are obtained from a DATA statement. Neither statement is used without the other. A READ statement causes the variables listed in it to be given in order, the next available num, - bers in the collection of DATA statements. Before the program is run, the computer takes all of the DATA statements in the order they appear and creates a large ~ta block. Each time a READ statement is encountered anywhere in the program, the data block supplies the next available number or numbers. If the data block runs out of data, the program is assumed to be finished and we get an OUT OF DATA message. Since we have to read in data before we can work with it,. READ .statements normafly occur near the beginning .... of a program. The location of DATA statements is arbitrary, as lorig as they occur in the correct order. A common practice is to collect all DATA statements and place them just before the END statement. 3-16 Each READ statement is of the form: READ [sequence of variables] Each DATA statement is of the form: DATA [sequence of numbers] 150 330 340 READ X,Y,Z,X1 .. Y2,Q9 DATA 4,2,1.7 DATA 6.734E-3 .. -174.321,3.1415927 234 263 READ BCK) DATA 2,3,5,7,9,11,10,8,6,4 10 440 450 READ RCI, J) DATA -3,5,-9,2.37,2.9876.-437.234E-5 DATA 2.765, 5.5576. 2.3789E2 Remember that only numbers are put in a DATA statement, and that 15/7 and. SQRT(3) are formulas, not numbers. Refer to Chapter 3 for a discussion of the subscripted variables. 1 .4.3 PRINT Statement . The common uses of the PRINT statement are: a. to print out the result of some computations b. to print out verbatim a message included in the program c. a combination of the two d. to skip a line. The following are examples of 100 135 a type a .: PRINT X,SQR(X) PRINT X,Y,Z .. B*B-4*A*C .. EXPCA-B) The first example prints X, and a few spaces to the right, the square root of X. The second prints five different numbers: 2 X, Y, Z, 8 -4AC, and e A-8 The computer computes the two formulas and prints up to five numbers per line in this format. Thefollowi~ are examples of type b.: 100 430 500 PRINT. "NO UNIQUE SOLUTION~' PRINT "X VALUE", nSINE", "RESOLUTION" PRINT X,M, D 3-17 Line tOO prints the sample statement, and line 430 prints the three labels with spaces between them. The labels in 430,automatically line up with the' thr~e numberS called for in ~RINT stafement 500 ~. " The following is an example of type c.: 150 3!2J PRINT -'THE VALUE OF X IS" X PRiNT "THE SQUARE ROOT OF" X .. "IS" SQR(X) If the first has computed the value of X to be 3, it prints out: THE VALUE OF X IS 3. If the second has computed the value of X to be 625, it prints out: THE SQUARE ROOT OF 625 IS 25,. The following is an example of type d.: 250 PRINT The computer advances the paper one line when it encounters this command. t .4.4 GO TO Statement The GO TO statement is used when we want the computer to unconditionally transfer to some command other than th~ next sequential command., In the LINEAR pro~lem, we direct the computer to go through the same process for different values of C and F with a GO TO statement. This statement is in the form of GO TO [ line number] • 150 1.4.5 GO TO 75 IF - THEN Statement The IF - THEN statement is used to transfer 'conditionally from the seq\Jential order of commands according to the truth of some relation. It is sometimes called a conditional GO TO statement. Each IF - THEN statement is of the form: IF [formula] [relation} [formula] THEN [line number] The following are two examp!es of this statement: 40 20. IF SIN(X)<=M THEN 80 IF G=f2l THEN ,65 If the first <;Isks if the sine of X is less than or equal to M, and skips to line 80 if so. The second asks if G is equal to 0, and skips to line 65 if so. In each case, if the answer to the question is no, the computer goes the next line. 3-18 to 1.4.6 ON - GO TO Statement The IF - THEN statement allows a two-way fork in a program; the ON - GO TO statement allows a many-way switch. For example: This condition causes the following to occur: If X = 1, the program goes to line 100, If X = 2, the program goes to line 200, IfX=3, the program goes to line 150 In other words, any formula may occur in plac.e of X, and the instruction may contain any number of line numbers, as long as it fits on a _single line. The val ue of the formula is computed and its integer part is taken. If this is 1, the program transfers to the line whose number is first on the list; if its integer part is 2, the program transfers to the line whose number is the second one, etc. If the integer part of the formula is below 1, a- larger than the number of line numbers listed, an erra- message is printed. To increase the similarity between the ON - GO TO and IF - THEN instructions, the instruction 75 IF X>5 THEN 200 may also be written as: 75 IF X>5 GO TO 200 Conversely, THEN may be used in an ON - GO TO statement. 1.4.7 END Statement Every p~ogram must have an END statement, and it must be the statement with the highest line number in the program. 999 END 3-19 I I I I I I I I I I I I I I I I I / I I I I I I I I I I I I I I I I I .. CHAPTER 2 LOOPS We are frequently interested in writing a program in which one or more portions are executed a number of times, usually with slight variations each time. To write the simplest prOgram in which the portion of the program to be repeated is written just once, we use a loop. A loop is a block of instructions that the computer executes repeatedly until a specified terminal condition is met •. The programs which use loops can be best illustrated and explained by using two versions of a program for the simple task of printing out a table of the positive integers 1 through 100 together with the square root of each. Without a loop, the first program is 101 lines long and reads 113 20 313 PRINT 1, SQR ( 1 ) PRINT 2,SQP..(2) PRINT 3,SQR(3) 9913 1131313 113 10 PRINT 99,SQR(99) PRINT 1130;SQR( 1013) END .... ' With the following program example, using one type of loop, we can obtain the same table with far fewer lines of instructions (5 instead of 101): 10 20 313 ~ 50 LET X=1 PRINT X,SQR(X) LET X=X+1 IF X<=100 THEN 20 END Statement 10 gives the value of 1 to X and initializes the loop. In line 20, both 1 and its square root are printed. Then, in line 30, X is increased by 1, to,a value of 2. line 40 asks whether X is less than or equal' to 100; an affirmative answer directs the computer back to line 20, where it prints 2 and/2 and goes to 30. Again, X is increased by 1, this time to 3, and at 40 it goes back to 20. This process is repeated -- line 20 (print 3 and ./3), 'Iine 30 (X = 4), line 40 (since 4 < 100, go back to line 20), etc. -- until the loop has been traversed 100 times. Then, after it has printed 100 and its square root, X becomes 101. The computer now receives a negative answer to the question in line 40 (X is greater than 100, not less than or equal to it), does not return to 20 but moves on. to line 50, and ends the program. A" loops contain four characteristics: . 3-21 a. initianzcitiori (line 10) b., the body (line 20) 2.1 c. modification (line 30) d. an exit test (line 40) FOR AND NEXT STATEMENTS BASIC provides two statements to specify a loop: the FOR statement and the NEXT statement. 113 213 313 50 FOR X=l TO 11313 PRINT X,SQR(X) NEXT X END In line 10, X is'set equal to 1, and a test is set up, like that of line 40 above. Line 30 carries out two tasks: \ X is increased by 1, and the test is carried out to determine whether to go back to 20 or to go on. Thus, lines • 10 and 30 take the place of lines 10,30, and 4O·in the previous prograrri. Note that the value of X is increa~d by 1 each time BASIC goes through the loop. If we want a different increase, we could specify it by writing the following: 113 FOR X= 1 -TO 11313 STEP 5 and the computer would assign 1 to X on the first time through the loop, 6 to third I X on the second time, 11 on the and 96 on the last time. Another step of 5 would take X beyond 100, allowing thC!' program to proceed to the end after printing 96 and its square root. The STEP may be positive or negative, and we could have obtained the first table, printed in reverse order, by writing line 10 as follows: 113 FOR X=100 TO 1 STEP-1 In the absence of a STEP instruction,' a step-size of +1 is assumed. More complicated FOR statements are allowed. The initial value, the final value, and the step-size may all be formulas of any complexity. For example, if Nand Z have been specified earlier in the program, we could write the following: FOR X=N+7*Z TO (Z-N)/3 STEP te.. r.~, ~-befere. ShHthtt ~iCKt nms, you ~rt ~ 10"0."",: RANDOM 5.1.4, The Sign ~uACtiCln (SGN) The SGN function is one which assigns .the value , to a~ positiVe number, 0 toze~, and -1 to any negative number. Thus, SGN (7.23) = 1, SGN (0) =0, and SGN (-.2387) =-Y. For exampte, the fotlowing statement: , ~ O~ SGN(X)+2 GO TO 1@0,200,300 trol1$fen to 100 if X < 0, to 200 if X =0, and to 300 if X> O. 'c 5.1.5 The Define User Function (DEF) and Function End Statement (FNEND) In addition to the 14 functions BASIC provides, you may define up to 26 functions of your own with the.DEF The'name of the defined function must be three letters, the first two of which are FN, e.g., FNA, FNB,'•• _, FNZ. Each DEF statement introduces a single function. For example I if you repeatedly use the function e ~X2 + 5, introduce the 30 f~nction by the following: DEF FNECX)=EXPC-Xt2)+5 _ and call for various values of. the function by'FNE (.1), FNE (3.45), FNE ~A+2), etc. This statement saves a great deal of time when you need values of the function for a nuR,ber of different values of the variable. The DEF statement may occur anywhere in the program, and the expression to the right of the equal sign may' be any formula that fits on one lin~. It may include any combination of other functions, such as those defined b)r different DEF statements; it also can involve other variables besides those denoting the argument of the functi~. , I - - Each defined function may have zero, one, two, or more Variables as in the 10 105 530 DEF FNB(X,Y)=3*X*Y-Yf3 DEF FNC(X,Y,Z,W)=FNB(X,Y)/FNB(Z,WJ DEF FNA=3.1416*Rf2 3-40 fo"~ing example: . In-the definition of FNA"; the current value of R is ~sed when FNA occurs. Similarly, iffNR the following: W DEF is defined by • FNR(X>=SQRC2+LOGCX)-EXP{Y*~>*CX+SIN(2*Z») you ~an ask for FNR(2.7), and give new values to Y and Z before the next" use of FNR. The methcxf of having multiple line PEFs is illustrated by the "max" function shown below. Using this method, the possibility of using IF ••• THEN as 10 20 30 40 50 part of the definition is a great help as shown in the following example:; DEF FNMCX,Y) LET FNM=X IF Y<= X THEN 50 LET FNM=Y FNEND The absence of the equals sign (=) in line 10 indicates that this is a multiple line DEF. In line SO, FNEND terminates the definition. The expression FNM, without an argument, serves as a temporary variable for the computation of the function value. The following example defines N-factorial: 10 20 30 40 50 60 DEF FNFCN> LET FNF=1 FOR K=l TO N LET FNF=K*FNF NEXT K FNEND Any variable which is not an argument of FN in a DEF loop has its current value in the program. Multiple line DEFs may not be nested and there must not be a transfer fram inside the DEF to outside its range, or yice versa. 5.2 SUBROUTINES " When you have a procedure that is to be followed in several places in your program, the procedure may be written as a subroutine. A subroutine is a self-contained program which is incorporated into the main program at specified points. A subroutine differs from other c . LET R=X-Q*Y IF R=0 THEN 300 LET X=Y LET Y=R " GO TO 200 3-42 30f2) 310 320 RUN LET G=Y RETURN END GCD3NO 13:38 10/20/69 A 8 C GCD 6(21 90 64872 384 120 98765 72 30 39456 32 1 8 OUT OF DATA IN 20 3-43 ., CHAPTER 6 MORE SOPHISTICATED TECHNIQUES The preceding chapters have covered the essential elements of BASIC. At this point, you are in a position to write BASIC programs and to input these programs to the computer via your Teletype. The commands and techniques discussed so far are sufficient for most programs. This chapter and remaining ones are for a programmer who wishes to perform more intricate manipulations and to express programs in a more sophisticated manner. 6.1 MORE ABOUT THE PRINT STATEMENT The PRINT statement permits a greater flexibil,ity for the more advanced programmer who wishes to have a different format for his output. The Teletype line is divided into 5 zones of 14 spaces each. A comma is a signal to move to the next print zone or, if the fifth print zone has just been filled, to move to the first print zone of the next line. If a label (expression in quotes) is followed by a semicolon, the label is printed with no space after it. If a variable is followed by a semicolon, its value is printed in the following format: snnn •• n l ~ one space numeric value sign: space if positive; - if negative When you type in the following program: 10 FOR 1=1 20 30 40 PRINT I NEXT I END. TO 15 the TeletyPe prints 1 at 'the beginning of a line, 2 at the beginning of the next line, .and, finaUy, 15 on the fifteenth line. But, by changing line 20 to read as follows: 20 PRINT I! 3-45 1 6 11 2 3 8 1 12 .4 9 14 13 5 10 15 If you want the numben printed in this fashion, but compressed, change line 20 by replacing the comma 'with a example: ~ semicolon as in the following . ( 20 PRINT I; The following results are printed: 2 3 4 5 6 1 8 9 10 11 12 13 14 15 A label inside quotation marks is printed as it appears, and the end of a PRINT statement signals a new line, unless a comma or semicolon is the last symbol. Thus, the follOYiing instruction: 50 PRINT X, Y prints two numbers and then returns to the next line, while the instruction: 50 PRINT X, Y, prints these two values and does not return •. The next number to be printed appears in the third zone, after the values of X and Y in the first two zones. Since the end of a PRINT statement sigflC!ls a new 250 line, PRINT causes the Teletype to advance the paper one line, to put a blank line for vertical spacing of your res':llts, or to complete a partially filled line. 50 110 120 130 140 150 FOR M=1 TO N FOR J=0 TO M PRINT BCM,J); NEXT J PRINT NEXT M This program prints B(1,O) and next to it B(1, 1). Without line 140, the Teietype would go on printing 8(2,0), 8(2',1), and B(2,2) on the same line, and. then J(3,.G},. B(3,.1'),. etc. After~. Tef.etype·pr.tftftt'" 1(1 "l) value corresponding to M = 1, line 1-40 directs it to start a new line; after printing the value'of B(2,2) corresponding to M =2, line 140 directs it to start anOther new line, §tc. 3-46 The following instructions: 50 51 PRINT "TIME-"; "SHAR"; "ING"; PRINT "ON"; "THE"; "PDP-leI" cause the printing of the following: TIME-SHARING ON THE PDP-10 Formatting of output can be controlled even further by use of the function TAB, in the form TAB(n), where n is the desired print position (0 through 74). Insertion of TAB(l7) causes the Teletype to move to column 17, as if a 'tab had been set there. For this purpose, the positions on a ,line are numbered from 0 through 71, and 72 is assumed to be the 0 position on the next line. More precisely, TAB may contain any formula as its argument. The value of the formula is computed, and its integer part is taken. This, in tum, is treated modulo 75, to obtain a value from 0 through 74, as indicated above. The Teletype is then moved forward to this position (unless it has already passed this position, in which case the TAB is ignored). For example, inserting the following line in a loop 55 PRINT X; TAB(12); Y; TAB(27); Z causes the X values to start in column 0, the Y vCllues in column 12, and the Z values in column 27. The following rules are used to interpret the printed results: a. If a number is an integer, the decimal point is not printed. If the integer contains more than eight digits, it is printed in the format as fotlows. L nl'~i- E (Exponent) followed by p (power of 10) next five digits first digit For example, 32,437,580,259 is written as 3.24376E+10 b. For any dpcimal number, no more than six significant digits are printed. c. For a number less than 0.1, the E notation is used, unless the entire significant part of the number can be' printed as a 6-digit decimal number. Thus, 0.03456 indicates that the number is exactly .0345600000, while 3.45600E-2 indicates that the number has been rounded to .0345600. d. Trailing zeros after the decimal point are not printed. 3-47 Ie 20 30 FOR N=-5 TO,3121 PRINT 2fN; NEXT N 4?l END RUN PO WERS 11 : 54 1121/2121/69 3. 125121I21E-2 6.25121121121~-2 121.125 121.25 121.5 1 2 4 8 16 32 64 128 256·512 112124 212148 412196 8192 16384 32768 65536 13112172 262144 ~4288 112148576 212197152 419431214 838861218 16777216 33553332 6711218864 1.34218 E+8 2.68435 E+8 5.36871 E+8 1.1217374 E+9 6.2 INPUT STATEMENT At times, during the running of a program, it is desirable to have data entered. This i~ particularly true when one person writes the program and saves it on the storage device as a Iibrary program (refer to SAVE command, Chapter. 9), and other persOns use the program and suppy their own data. - Data may be entered by an INPUT statement, which acts as a READ but accepts numbe~ of alphanumeric data from the Teletype keyboard. For example, to supply values for X and Y into a program, type the follCNiing: 40 INPUT X, Y prior to the first statement which.uses either of these numbers. When BASIC encounters this statement, it types ,a question mark. The user types two numbers, separated by a comma, and presses the RETURN key, and BASIC continues the program. No number can be I~nger than 8 digits. " Frequently, an INPUT statement is combined with a PRINT statement to make sure that the user knCNis what the question mark'is asking for. You might type in the follCNii~ statement: 2121 30 PRINT "YOUR VALUES OF X,Y, AND Z ARE"; INPUT X,Y,Z and BASIC types out'the following: YOUR VALUES OF X,Y, AND Z ARE? Without the semicolon cit the end of line 20, the question mark would have been printed on the !"8xt line. Data entered via an INPUT statement is not saved with the program. Therefore, INPUT should be used only ~hen small amounts of data are'to be entered, or when necessary during the running of the program. 3-48 6.3 STOP STATEMENT STOP is equivalent to GOTO xxxxx, where xxxxx is the line number of the END statement in the program. For example, the following two program portions are exactly equivalent: 6.4 250 GO TO 999 250 STOP 340 GO TO 999. 340 STOP 999 END 999 END REMARKS STATEMENT (REM) REM provides a means for inserting explanatory remarks in the program. BASIC completely ignores the remainder of that line, allowing you to follow the REM with directions for using the program, with identifications of !he parts of a long program, or with any other information. Although what follows REM is ignored, its line number may be used in a GOTO or IF-THEN statement as in the following: 200 REM REM REM REM 300 RETURN 520 GOSUB 200 100 110 120 INSERT IN LINES 900-998. THE FIRST NUMBER IS N, THE NUMBER OF POINTS. THEN THE DATA POINTS THEMSELVES ARE ENTERED, BY THIS IS A SUBROUTINE FOR SOLVING EQUATIONS A second method for adding comments to a prpgram consists of placing an apostrophe ( I) at the end of the line; and following it by a remark. Everything following the I is ignored except when the line ends in a string (refer to Chapter 8). 6.5 RESTORE STATEMENT The RESTORE statement permits READing the data in the DATA statements of a program more than once. When. . ever RESTORE is encountered in a program, BASIC restores the data block pointer to the first number. A subsequent READ statement then starts reading the data all over again. However, if the desired data is preceded by code numbers or parameters, superfluous READ statements should be used to pass over these numbers. As an example, the following program p~ion reads the data, restores the data block to its original state, and reads the data again. Note the use of line 570 (READ X) to pass over the value of N, which is already known. 100 110 120 READ N FOR I =1 TO N READ X ....... . 3-49 .. 200 NEXT1 560 570 580 590 RESTORE READ X FOR 1=1 TO N READ X 700 710 DATA ••••• DATA ••••• ...... ...... 3-50 CHAPTER 7 VECTORS AND MATRICES Operations on lists and tables occur frequently; therefore, a special set of 13 instructions for matrix computations, all of which are identified by the starting word MAT, is used. These instructions are not necessary and can be replaced by combinations of other BASIC instructions, but use of the MAT instructions results in shorter programs that run much faster. The MAT instructions are as follows: MAT READ a, b, c Read the three matrices, their dimensions having been previously specified. MAT c '" ZER Fill out c with zeros. MATc =CON Fill out c with ones. MATc=IDN Set up c as an identity matrix. MAT PRINT a, b, c Print the three matrices. (Semicolons can be used immediately following any matrix which you wish to have printed in a closely packed format.) MAT INPUT v Call for the input of a vector. MAT b =a Set the matrix b equal to the matrix a. MATc=a+b Add the two matrices a and b. MAT c = a - b Subtract the matrix b from the matrix a. MAT c = a *b MA T c = TRN(a) MAT c = (k) *a MAT c = INV (a) Multiply the matrix a by the matrix b. Transpose the matrix a. Multiply the matrix a by the number k. The number, which must be in a parentheses, may also be given by a formula. Invert the matrix a. 3-51 7.1 MAT INSTRUCTION CONVENITONS The following convention has been odopted for MAT instru~ions: while every vector has ~ cOmponent 0, and every matrix has a rON 0 and a column 0,- the MAT instNctions ignore these. Thus, if we have a matrix of dimension M-by-N in a MAT instNction, the rows are numbered 1,2, '••• , M, and the columns I, 2, ••• , N. The DIM statement may simply indicate what the maximum dimension is to be. Thus, if we write the foliONing: DIM M(20 .. 35) Mmay have up to 20 rows and up to 35 columns. This statement is written to reserve enough space for the matrix; consequently, the only concern at this point is that the dimensions declared are large enough to accommodate the matrix. HONever, in the absence of DIM sTarements, all vectors may have up to 10 components and matrices uP.to 10 rows and 10 columns. This is to say that in the absence of DIM "statements, this much space is automatically reserved for vectors and matrices on their appearance in the program. The actual dimension I of a matrix may be determined either when it is first set up (by a DIM statement) or when it is computed. the following reads 10 DIM M(20 .. 7) 50 MAT READ M a 20-by-7 matrix for M, while the following: 50 MAT READ M( 17 .. 30) reads a 17-by-30 matrix for M, provided sufficient space has been saved for it by writing 10 7.2 DIM M(2eJ .. 35) MAT C = ZER, MAT C = CON, MAT C = ION The following three instNctions: MAT M= ZER MAT M= CON MAT M= ION (sets up matrix M with all components equal to zero) (sets up matrix M with all components equal to one) ? @ 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 A B C D E F G H I J K L M N 0 P Q R S T U V W ,X Y Z [ \ ] t ... Additional symbols useful on output..are as follows: LF (I i ne feed) CR (carriage return) 10 13 The above list is not complete; there are 128 characters numbered 0 through 127. 3-62 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91' 92 93 94 95 The other use of CHANGE is. illustrated by the following: 1121 15 2121 25 3I2J 35 LtlJ FOR 1=121 TO 5 READ ACI) NEXT I DATA 5,65,66,67,68,69 CHANGE A TO A$ PRINT A$ END This program prints ABCDE because the numbers 65 through 69 are the code numbers for A through E. Before CHANGE is used in the vector-to-string direction, we must give the number of characters which are to be in the string as the zero component of the vector. In line 15,A(O) is read as 5. The following is a final example: 5 1121 2121 3I2J ~ 5I2J 6I2J 7I2J RUN EXAMPLE DIM V(128) PRINT "WHAT DO YOU WANT THE VECTOR V TO BE".; MAT INPUT V LET V(I2I)=NUM CHANGE V TO A$ PRINT A$ GO TO 1121 END 13: 59 1121/2121/69 WHAT DO YOU WANT THE VECTOR V TO BE? 4121.32,45,6121,45,89,9121 (-<-YZ WHAT DO YOU WANT THE VECTOR V TO BE? 32,33,34,35,36,37,38,39,4121,41,42,& ? 43,44,45,46,47,48,49,5121 !"#$%&' ()*+, -./12112 ~HAT DO YOU WANT THE VECTOR V TO BE? 4 Note that in this example we have used the availability of the function NUM after a MAT INPUT to find the number of characters in the string which is to result from line 40. Giving the input "4" on the last request obtains the response EOT (end of transmission), which turns off the Teletype. 3-63 ~ CHAPTER 9 EDIT AND, CONTROL Several commands for editing BASIC programs and for controlling their execution enable you, for example, to: a. delete lines b. list the program c. change or resequence I ine numbers with set increments d. save programs on a file-structured storage device (disk or DECtape) e. replace old programs on the storage device wi th new programs f. call in programs from the storage device. These commands are summarized as follows: Command Action DELETE n Delete line number n and the contents of the line from user core. DELETE n,m De lete line numbers n through m from user core. LENGTH Print length of source program {expressed as the number of characters}. LIST List program with heading. LIST n List program with heading, beginning at line number n. LIST n,m List program with heading, from line number n through m. LISTNH } LISTNH n LISTNH n,m Same as LIST, but with heading suppressed. NEW BASIC asks for new program name and checks to make certain that it does not already exist. OLD BASIC asks for program name and replaces current contents of user core with existing program of that name from the storage device. RENAME filename Change name of program currently in user core. REPLACE Replace old fi Ie of current name with contents of user core. ' RUN Compile and run program currently in core. RUNNH Same as RUN, but with heading suppressed. 3-65 Action Command SAVE Save the contents of user core as file whose filename is current program, name and whose extension is • BAst. SAVE filename Save user cor~ as filename • BAst • SCRATCH Delete all program statements from user core. RESEQUENCE n Change line numbers to n, n +-10, •••• RESEQUENCE nllk Change line l1u",bers to n, n + k, •••• Commas are necessary as argument delimiters. RESEQUENCE n, f, k Change line numbers from line f upward to n, n + k, •••• f must not be greater than n. . SYSTEM Exit to Monitor. WEAVE filename Read program statements from the file named filename. BAS (existing statements in user core are replaced by new statements having same Ii.,e numbers). fC To stop a running program and enter Monitor level, type tC twice. to To suppress output (typeout), type t SAVE commands do not overwrite an existing file of the same 3-66 to. name (use REPLACE instead). CHAPTER 10 DATA FILE CAPABILITY The data file capability allows information to be written onto the disk for immediate or semipermanent storage. The user can save this information until the disk is refreshed, or he can utilize PIP (Peripheral Interchange Program) to save it permanently on DECtape or paper tape. With each BASIC program, a user can save up to nine files, each with a different filename. The filename is assigned by the user and must follow the filename rules described in Chapter 4. The extension is assigned by the BASIC compiler and is set to .BAS. (All BASIC files~have this extension.) The current date and time are placed into the file directory along with the project-p.rogrammer numbers. The file protection key is set to the standard protection when the file is !=reated, indicating protection-protection and write-protection against all users except the owner of the file. 10.1 FILES COMMAND The FILES command specifies what files are to be read or written. The command format appears as follows: FilES name 1 , name2, .. :, name9 where name 1, name2, •.. , name9 are filenames. The filenames may be separated by commas or semicolons. This command may come after any executable command, but must precede any command that is associated with creating a new file or referencing an old file. I/O channels ~re assign~d consecutively, starting with channell, to the files. The names are positional, where name 1 corresponds to software channell, name2 to software channe I 2, and so forth, up to name9 to software channel 9. Since the filenames are positional, commas must precede filenames that are not sequentially ordered, for example: indicates that input or output is desired on channel 3 (filename S), channel 5 (fi lename R), and channel 6 (fi lename T). 3-67 Files are in either read or write mode ahd are assumed fo be initially in ~ad1Ylode_ -An error message is given , if an attempr is made to read a file which does not exist or to read a file which is being written _ Examples of . the FILES command are as follows: FILES FILES FILES AAA X, V,Z .D,F 10.2 SCRATCH COMMAND The SCRATCH command opens a file for writing_ More than one channel may be referenced. The command format is as follows: , ( SCRATCH 1M I IN I Ipor SCRATCH 1M, N,P where M, N, and P are channel specifiers. The I must precede the first channel specifier, but need not be duplicated for subsequent channel specifiers in the same command. This command must be used prior to. the writing of afile. Examples of the SCRATCH command are-as follows: SCRATCH SCRATCH SCRATCH 10.3 WRITE COMMAND The WRITE cOrRmand causes data to be output to the disk on the specified channel. The data may be an area of storage previously dimensioned, or any information appearing in a PRINT statement _ The format of I/O to the disk is the same as the format to the Teletype. The command format is as follows: WRITE IN, (sequence of variables) where N is a channel specifier. When writing a file, BASIC inserts line numbers, startfng with 10 and incrementing by 10. After each line number, BASIC inserts the letter 0 to separate the line nvmber from the data. When reading a file, BASIC recognizes the-nondigit character (D) following the line numbers, and ignores it~ Examples of the WRITE command are as follows: WRITE WRITE 3-68 The following is an example of the storage of the sines of 1-10 radians in file RRR: 10 20 30 40 50 60 70 80 10.4 DIM ACl0) F1j-ES RRR SCRATCH # 1 FOR 1=1 TO 10 A(!)=SIN(1) WR I T E # 1 , A ( 1 ) NEXT I END RESTORE COMMAND The RESTORE command opens a file for reading. More than one channel may be referenced. The command format is as follows: RESTORE #M, #N, #p or RESTORE #M,N,P where M, N, and P are channel specifiers. The main use of the RESTORE command is to reread a file or read a file that has just been written. If the first function in the program is to read an already existing file, the command is not necessary. In other words, if a different program created the files, then a new program does not need the RESTORE command in order to read the files; this is because files are initially in read mode.· Examples of the RESTORE command are as follows: RESTORE RESTORE 10.5 INPUT COMMAND The INPUT command causes data to be input from the disk on the specified channel into the specified area. Each command can reference only one channel and, therefore, only one file. The command format is as follows: INPUT # N, (sequence of variables) where N is a channel specifier. The READ and INPUT commands are equivalent when data files are read from the disk, and the PRINT and WRITE commands are equivalent when data files are written on the disk. of the I NPUT command are as follows: INPUT INPUT INPUT #2, A(i) #6, Z$ #3, B(K) 3-69 Examples The foHoWing example demonstrates-access to previously stored~atues in the file RRR: 10 DIM 1:1.(10) 2QJ 30 FILES RRR FOR 1=1 TO 1 Ql I NPUT If 1 , A CI ) PRINT ACI) NEXT I END' 4121 50 6I2l 70 RUNN H 121-841411 0.909297 0.14112 -0.756802 -0.958924 -0 .21941 6 0.656981 0.989358 0.412119 -0.544021 10.6' IF END COMMAND This command provides control in a program when an End-of-File is detected during input from the disk. The command fonnat is as follows: l , {THEN} • IF END N GO TO (lme number) where N is a channel specifier. The line number must follow the rules discussed in Chapter 1. Either THEN or GO TO is acceptable. Examples of the IF END command are as follows: IF END '1 GO TO 160 IF END '4 THEN 435 3-70 APPENDIX A SUMMARY OF BASIC STATEMENTS A.l ELEMENTARY BASIC STATEMENTS The following subset of the BASIC command repertoire includes the most commonly used commands and is sufficient for solving most problems. DATA [data list] READ [sequence of variables] DATA statements are used to supply one or more numbers or alphanumeric strings to be accessed by READ statements. READ statements, in tum, assign the next available data in the DATA string to the variables listed. Numeric and alphanumeric data are kept in separate tables and must be accessed by separate READ statements; however, they both may be entered in the same DATA statement. PRINT [arguments] Types the values of the specified arguments which may be variables, text, or format control characters. LET [variable] = [formula] Assigns the value of the formula to the specified variable. . GO TO [line number] Transfers control to the line number specified and continues execution from that point. IF [formula] [relation] [formula] If the stated relationship is true, then transfers control to the line number specified; if not, continues in sequence. 1 [lirie number] { THEN GOTOj FOR [variable] = [formula] ] TO [formula 2] STEP [formura3] NEXT [variable] Used for looping repetitively through a series of steps. The FOR statement initializes the variable to the value of formulal and then performs the following steps until the NEXT statement is encountered. The NEXT statement increments the variable ny the va.lua of fo,mul~. (If omitted, the increment YUlue it.ossumed,to·be + 1 :) The resultant value is then compared to the value of formula2. If variable OR . The line is ignored. OUT OF ROOM Can't get more core to make room for: a. More compilation space. b. Maximum space for all the vectors and arrays. c. Space to store another string during execution. TOO MANY FILES A maximum of nine files may be read or written in a progrom. ILLEGAL DSK READ IN LINE N File was never accessed for reading. FILE NEVER ESTABLISHED-REFERENCED IN LINE N File was not referenced in a FILES command. FILE NOT FOUND BY RESTORE COMMAND IN LINE N File was never written. ILLEGAL DSK WRITE IN LINE N File was not opened for writing. FAILURE ON ENTRY IN LINE N Channel is not available for SCRATCH command. EOF IN LINE N An attempt was made to read data from a file after all data had been read. BAD DATA INTO LINE N Input data is not in correct form. Execution mors Message bcplanation SUBROUTINE OR FUNCTION CALLS ITSELF IN NN FNA is defined in terms of FNB which is defined in terms of FNA, or a similar situation with FUNCTIONS or GOSUBS. ON EVALUATED OUT OF RANGE IN NN The value of the ON index was the number of branches. J OVERFLOW IN NN UNDERFLOW IN NN DIVISION BY ZERO IN NN These all work according to specifications whenever the APRENB UUO is implemented. RETURN BEFORE GOSUB IN NN NOT ENOUGH INPUT--ADD MORE INPUT DATA NOT IN CORRECT FORM-RETYPE LINE OUT OF DATA IN NN TOO MANY ELEMENTS--RETYPE LINE 3-77 Execution Errors (Cont) Explanation Message IMPOSSIBLE VECTOR LENGTH IN NN In a CHANGE (to string) statement, the zeroth element of the number vector was negative or exceeded its maximum dimension. NON-ASCII CHAR SEEN IN NN In a change operation of the same kind, one of the other elements of the number vector was negative or exceeded octal 177. NO ROOM FOR STRING IN NN In a CHANGE A$ TO A I the number of characters in A$ exceeds the maximum size of A. LOG OF NEGATIVE NUMBER IN NN SQRT OF NEGATIVE NUMBER IN NN TAN OF Pl/2 OR COTAN OF ZERO IN NN EXP TOO LARGE IN NN ZERO TO A NEGATIVE POWER IN NN ABSOLUTE VALUE RAISED TO POWER IN NN DIMENSION ERROR IN NN LOG OF ZERO IN NN • 3-78 Book 4 Conversational Programming With AID . .. CONTENTS CHAPTER 1 INTRODUCTION 1.1 Gaining Access to the AI D System 4-9 1.2 Terminating AID 4-9 1.3 AI D La "guage 4-10 1.3.1 Rules of Form 4-11 1.3.2 Arithmetic Accuracy and Notations 4-11 1.4 Teletype Consoles 4-12 1.5 Correction of Typing Errors 4-13 CHAPTER 2 STEPS AND PARTS 2.1 Direct Steps 4-15 2.2 Indirect Steps 4-15 2.3 Parts 4-15 CHAPTER 3 IDENTIFIERS ARIABLES} rv 3.1 Defining an Identifier by a Value (SET and DEMAND Commands) 4-17 3.2 Defining Identifiers by Formulas (LET Command) 4-19 3.2.1 Arithmetic Formulas 4-19 3.2.2 Boolean Expressions (Propositions) Defined by the LET Command 4-20 3.2.3 User Functions Defined by the LET Command 4-20 3.3 Identifier References 4-20 3.4 Indexed Identifiers (Arrays) 4-21 CHAPTER 4 ARITHMETIC OPERATORS, FUNCTIONS, PROPOSITIONS and ITERATIONS 4.1 Arithmetic Operators 4-23 4.2 AID Functions 4-25 4.3 User-Defined Functions 4-29 4.3.1 Examples of User-Defined Functions 4-30 4.4 Propositions 4-31 4.4.1 Conditional Expressions 4-32 4-3 CONTENTS (continued) 4.5 Iterative S:;lauses (Ranges) 4-34 4.5.1 Series of Values 4-34 4.5.2 Incrementation 4-34 4.5.3 Combinations 4-34 CHAPTER 5 AID VERBS 5.1 4-37 CANCEL Parenthetical CANCEL (CANCEL) 4-37 4-37 . Diagnostic Messages 4-38 Description 5.2 DELETE 4-39 4-39 Description 5.3 5.4 5.5 " 4-41 DEMAND Description 4-41 DEMAND ••••. AS "Any Text" Option 4-41 4-45 DISCARD Description 4-45 Diagnostic Messages 4-45 4-46 DO Description 4-46 TIMES Option 4-46 Range Option (FOR Clause) 4-46 IF Clause 4-48 Parenthetical DO (DO .•.••. ) 4-48 Diagnostic Messages 4-50 4-51 DONE 5.7 5.8 Description 4-51 Diagnostic Messages 4-52 FILE 4-53 Description 4-53 Diagnostic Messages 4-53 FORM 4-54 4-54 Description 4-4 CONTENTS (continued) 5.8 (cont) SPfJ!cific Notations 4-54 Multiple Results on a Single Line / 5.9 5.10 4-55 Report-Type Headings 4-56 Diagnostic Messages 4-56 GO 4-57 Description 4-57 Diagnostic Messages 4-58 IF Clause 4-59 4-59 Description 5.11 5.12 LET 4-60 Description 4-60 Arithmetic Formulas 4-60 Boolean Expressions (Propositions) 4-60 User Functions 4-.60 LINE 4-62 4-62 Description 5.13 4-63 PAGE 4-63 Description 5.14 4-64 QUIT Description 5:15 5.16 4-64 RECALL 4-65 Description 4-65 Diagnostic Messages 4-65 RESET TIMER 4-66 Description 5.17 4-66 SET 4-67 Description 5.18 4-67 4-68 STOP Description 5.19 4-55 Interspersing Text with Results 4-68 4-69 TO , Description 4-69 4-70 Diagnostic Messages 4-5 CONTENTS (continued) 5.20 5.21 TYPE 4-71 Description 4-71 Combined TYPE Commands 4-71 I N FORM Option 4-71 4-75 USE Description 4-75 Diagnostic Messages 4-75 APPENDIX A TABLES A-1 A Glossary of AID Terms 4-78 A-2A AID Command Summary 4-80 A-2B Fi Ie Command Subset 4-84 A-3 AID Character Set 4-85 A-4 AID Diagnostic Messages 4-87 TABLES 4-1 AID Arithmetic Operators 4-23 4-2 AID Functions 4-26 4-6 PREFACE AID (for Algebraic Interpretive Dialogue) is a PDP-10 adaptation of language elements of JOSS 1 , the well -known computing service program developed by The RAND Corporation under contract to the Uni ted States Ai r Force. The system is designed to assist scientists and engineers in solving complex numerical problems. The language is direct and relatively easy to learn. No previous programming experience is needed, either to understand this manual or to use AID at a Teletype console. Commands are typed in the form of imperative English sentences and mathematical expressions are typed, for the most part, in standard notation. Digital Equipment Corporation is grateful to The RAND Corporation for permission to adapt the language processors of JOSS for the PDP-l o. We also wish to express our appreciation to the programmers and computer scientists who developed the system, and to The RAND Corporation and E. P. Gimble of the Air Force's Sacramento Air Materiel Area for the use of RAND publications in the preparation of this AID manual. 1 JOSS is the trademark and service mark of The RAND Corporation for its computer program and servi ces usi ng that program. 4-7 • CHAPTER 1 INTRODUCTION AID is available on all PDP-10 systems and provides each user with a personal computing service, interacting with the user and responding to commands expressed in a simple language via the user's Teletype. AID has proven to be easy and convenient to use in solving both simple and complex numerical problems. AID is device independent. It provides the user with a facility to create external files for storage of subroutines and data for subsequent recall and use. For ac~essibi lity and speed, such fi les are normally stored on directory devices such as disk or DECtape; however, files may be stored on any retrievable medium such as magnetic tape. AID runs in approximately 11 K of core memory (with 1K of user data area) and expands to 14K of core (with 4K of user data area) as required. Note that AID will not run on a 16K machine if Iv\onitor occupies more than 5K of core. 1.1 GAINING ACCESS TO THE AID SYSTEM To gain access to AID, the user must first gain access to the Monitor. In the case of all but the disk monitors, this is accomplished simply by typing l' C (hold down the CTRl key while striking C). In the case of the PDP-I0/50 Monitor, the user must log in (see either the Time-Sharing Monitors: 10/40, 10/50 manual or the PDP-I0 System Users Guide, found in the PDP-I0 Reference Handbook, order code AIW. When access to the Monitor is gained, and the Monitor has responded with a period (.), the user types .R AIDJ When AID is loaded into core, it responds with the message AID (revision date) AT YOUR SERVICE. •• * The asterisk (*) indicates that AID is ready to accept a command from the user. 1 .2 TERMINATING AID AID is terminated and control is returned to Monitor level by typing l' C J (hold down the CTRl key and strike C) 4-q AID can then be re-entered by typing .CONTJ 1 or killed by either typing ,.KJOBJ or running another program. 1.3 AID LANGUAGE Table A-2 contains all AID commands and fUllctions. Each command occupies a single line and is terminated by a carriage return. A period at the end of a command is optional. A command can be entered as a direct command (to be executed immediately) or as an indirect command (to be stored for later execution). Variables in commands are represented by single alpltlabetic letters, A through Z and a through z, called identifiers. Entire routines can be stored as a series of indirect commands to be executed in a"specific order. An expression is defined as one number or identifier (or a combination of numbers and/or identifiers and/or AID functions) which is reducible to a number when AID is called upon to use it. The standard mathematical Qp-erators can be expressed in AID as follows: r ! [ 1 ( ) + absolute value (equivalent·to.the mathematical symbol 2 brackets 2 parentheses II ) _ addition subtraction * · I'Icahon . 3 mu ItiP / division' t exponentiation4 (x 3 =x~3) The order of precedence for these operations is conventional: !, [ a) ] , and ( ) from the innermost pair to the outermost pair b) t c) * (multiplication) and / (division) from left to right within each term d) + (addition) and - (subtraction). (exp~nentiation) 1If AID was performing an iterative process when interrupted by the proceeds .automatically following the CONT command to Monitor. ~reviously typed tc, execution If it is desired to have AID halt before continuing, type, RE-ENTER instead of CONT. In this case, AID wil,l execute the next step of the interrupted process, type the message "I'M AT STEP m.n" and halt. To continue, type GO. 2~rackets and parentheses can be used interchangeably in pairs. 3The ampersand (&) will perform multiplication also, ho'wever when returning the result, AID will type an asterisk (*) in place of the ampersand. . t, N key with SHIFT on Teletype Models 33 4The tip arrow for exponentiation is typed by striking the and 35. On Teletype Model 37 strike the """, 1\ without SHIFT. In either case do not use the CTRL key for exponentiation. 4-10 Examples: a/3*c (~)c not x/y,3 -x y 3 a 3c not (Ieft-to-right rule) (order of precedence) ( ;)3 Boolean expressions composed of arithmetic statements using the operators = (equal to), # (f not equal to), >= (2:greater than or equal to), <= (~ less than or equal to), < (I~ss than), > (greater than). and the negation not and connected in turn by logical operators and, or (inclusive) are handled by AID. 1 .3.1 Rules of Form a. Only one step (command) can be typed per line and only one line can be used for each b. Each step begins with a verb and terminates with a carriage return. A period at the end step. of a step is optional. c. Words, variables (identifiers), and numerals can neither abut each other nor contain em- bedded spaces; spaces cannot appear between an identifier (when it appears in an array, a formula, or . a function) and its associated grouped operators and arguments. Otherwise, spaces can be used freely. d. typing ~F When operating via the Teletype Model 37 in upper and lower case mode (entered by - CTRL F), the initial letter of the first word of each command may be typed in upper case. All other letters within the command must be in lower case (with the exception of letters in a character string enclosed by quotation marks, or in the case of identifiers of the range A through Z). Examples: 1.3.2 , Step Number (indirect) Verb Arguments Modifiers 1) *1.23 Type a, a+2, at3 in form 1 if a>O.J 2) *1.4 Do part 2 for c = 5(lO)100.~ Arithmetic Accuracy and Notations All results are rounded to the nine most significant digits. 6 ' All results with a value of less than 10 and equal to or greater, than .001 are typed by AID in fixed point notation. 4-11 . Examples: a) ~Type 1/3+2 J 1/3+2 b) • *Type 100**3 J 100**3 c) d) *Type 1/4*1 J 1/4*1 ' = = = '«Type cos (2 .5)J cos (2 .5) = " 2.33333333 1 *10t6 .25 -.801143616 All other results are typed in scientific notation. Examples: a) b) 1.4 *Type 365*24*60*60J • 365*24*60*60 = *Type (.0005)* (17)*(.01)J (.0005)* (17)*(.01) = 3.1536*10t7 (Read as 3.1536 times 10 raised to the 7th power) 8.5*10t(-5) (Read as 8.5 times 10 raised to the minus 5th power) TELETYPE CONSOLES A Teletype console is the link between the user and AID. A PDP-10 system may be equipped with anyone of three Teletype models, /IAodel 33, Model 35, or /IAodel 37. The essential difference between /IAodel 37 and Models 33 and 35 is that Model 37 has both upper and lower case letters 1 (with special characters occupying other keys), while Models 33 and 35 have upper case letters only (typed . without use of the SHIFT key - some of the special characters occupy what are normally the upper case positions on the letter keys)2 • 1l!'" Command examples shown in this publication use both upper and lower case letters (rules governing capitalization are similar to those of the English language, the initial letter of the first word of a command is capitalized). Thus, commands can be typed on the ,/IAodel 37 exactty as shown on the following pages, while only upper case characters can be typed on Models 33 and 35. Table A-3lists the Alp character set, corresponding,standard mathematical symbols, c~rre sponding JOSS symbols, and the method used to obtain each character on the various Teletype models. 1The system accepts only upper case letters (typed without use of the SHIFT key) from Teletype Model 37 unless , F (CTRl F) is first typed, in which case both upper case and lower case letters are recognized. 2The difference between /IAodel 33 and Model 35 is that fv40del 33 does not have TAB, FORM, or VT ~ertical lab) mechanisms. 4-12 1 .5 CORRECTION OF TYPING ERRORS If the user should make an error while typing a command to AID, he can correct it by one of two methods; (1) he can strike the RUBOUT key once for each character to be erased and then type the correct data, or (2) he can type an asterisk followed, by a carriage retur~ to delete the entire line, and type the line over. 1) *Type VEC\CEV\ VECTOR CALCULATION"J User omitted the quotation mark before the V; he erases C, E, and V by striking the RUBOUT key three times (deleted characters are pri nted between \), types the missing quotation mark, and continues • 2) *Type "VECTOR CALCULATION*d *Type "VECTOR CALCULATION'~ User realizes that he has omitted a space between the e and the quotation mark; he decides to delete the line and retype it. Should the user type an incorrect command, AID, when it attempts to interpre! it, will respond with the message EH? * NOTE When indirect commands are entered, AID merely checks the validity of the step number; the validity of the command is not checked until it is called upon for execution. ," 4-13 CHAPTER 2 STEPS AND PARTS A user requests AID functions by typing single-line commands called steps. The user can enter a step whenever AID responds with an asterisk (*) typeout. Each step is terminated by a carriage return (~). Steps can be entered in two ways: (1) as direct steps, or (2) as indirect steps. 2.1 DIRECT STEPS A direct step is interpreted and executed by AID immediately (following the terminating carri age return typed by the user). *Type 2+2 ~ User types dJ rec t step. 2+2 4 AID responds immediately by interpreting and executing the step. * Direct steps are performed only once each time they are typed, and must be retyped each time th'e user desires to execute them. 2.2 INDIRECT STEPS An indirect step is entered by preceding the' step with a nume'ric label containing both an i'lteger and a decimal portion (1.1, 2.53). By preceding a step with a numeric label, the user signals to AID that the step is not to be executed immediately, but is to be stored for later execution as part of a routine. AID files away labeled steps in sequelJce according to the numeric value of the IQbel or step number. Thus, a step number can be used to indicate that a step is to be inserted into, deleted from, or substituted in a series of previously entered indirect steps. Step numbers can contain a maximum of nine significant digits. *1.1 *1.2 *1.3 *1 • 15 Set x=3 *1.3 ... J J Type "X VALUES" Type x d Type x*2, x/2, x~ J User inserts a step between steps 1.1 and 1.2 by assigning it a number which falls between these two step numbers. Type x*2; x/2, x~, xt3 ~ *Delete step 1.2 User types i,n a 3-step routine for later execution. J 'User changes step 1.3 by substituting a new step having the same step number. . User del etes step 1 .2. * 2.3 PARTS Steps are organized into parts according to the integer portion of their step numbers. All steps with step numbers containing the same value in their integer portion belong to the same part. 4-15 Thus, all of the steps in the previous example can be referred to as part 1. *Type part 1 1.1 . 1.15 1.3 J User ~equests AID to type a II steps in part 1 . Type fiX VALUES" Set x=3 . Type x*2, x/2,x ~2, x ~3 *00 part 1 J , User requests AIO to interpret and execute (i .e. I 00) all steps in part 1. , X VALUES x*2 = x/2 xt2 = ~3 = 6 1.5 9 27 I * Steps and parts are units which may be entered, changed I deleted, typed out, executed, or filed in (and later recalled from) a file stored on some retrievable I/o medium (e.g., disk or OECtape). In addition, they are available in core storage as stored routines for repetitive execution. Examples: a) *1ype step 1 .1 b) *Type part 1 J d) J *00 step 2.3 J *00 part 4 J e) *File step 3.65 as item 4 f) *'File part 3 as item 2 c) J J All steps or parts can be referred to collectively (except by 0(3). Examples: a) *Type all steps b) *1ype a II ,parts c) d) J J J *File all parts as item 9 J *File all steps as item 8 4-16 CHAPTER 3 IDE NT I FIE RS (VA RI A Bl E S) An identifier (variable) is used in expressions to represent a variable quantity. In AID, identifiers are repres~nted ~y single alphabetic characters to which arithmetic or logical values have been assigned. On Tel~type Models 33 and 35 (and Model 'Jl in the upper case mode), 26 unique identifiers are available. However, when the Model 37 Teletype is operated in the upper/lower case mode, 52 unique identifiers (A through Z, and a through z) can be used. 3.1 DEFINING AN IDENTIFIER BY A VALUE (SET AND DEMAND COMMANDS) A fixed value can be assigned to an identifier by typing *Set x = value NOTE When this command is typed as a direct command, the verb (SED may be omitted, e.g., -*x = 95 In a SET command, the single -character identifier on the left of the equals sign (~) is not a number, but an identifier being defined (or redefined). The value or expression on the right of the equals sign is a numeric value (or truth value) and must always, if a numeric expression, be immediately reducible to a number. Examples: ~ a) *x = 10 b) *Set x =3.5 ~ c) *y = cos (25)+2 d) *Set a = sqrt(20)+5 e) *m = false ~ 6 cos is a standard function provided by AID (see Chapter 4). ~ ~ is also a standard AID function. !!! is set equa I to the value false. The SET command is a convenient way to shorten a lengthy expression by using identifiers to represent its parts. Example: 34 2 (5 + 73) + 4-17 42 - .[50 19 This expression can be simplified and solved as follows. *0 = 5+34/73.} *b = [42-sqrt(50)l!19 ~ *Type (at2+b)/a ~ (at2+b)ja = 5.80209589 Common algebraic funi::tions{e.g., sqrt, cos, sin, log)are provided in AI Dforuse inexpressions (see Chapter 4). Example: Define the value of pi ('If) *p = arg(-l, 0) ~ *Type p 6 arg is the AID function of a rectangular coordinate point (see Table 4-2). f p = 3.14159265 *Type p*36t2 .} Calculate the area of a circle having a radius of 3p. 4071.50407 An identifier can also be set to a value, to be typed in by the user prior to execution of the associated routine. This is acco~plished by using the, DEMAND command, which can be used indirectly only. Execution of a DEMAND command causes a typeout of the specified variable, which is followed by the val ue to be used, typed by the user. 'Example: J *1.1 Demand x *1.2 Demand y ~ *1.3 Type x*y, (x¢2)*(y¢2) ~ *Do part 1 ~ x= y = * (xt2)* (yt2) : AID requests value ,for x. User responds by typing in 4. AID requests value for y. User responds by typing in 6. 24 576 An identifier can be set to a ran~e of values by the "DO ••• FORx=lst-value (increment) last-value" command (see"DO", Chapter 5). When this form of the DO command is used, the series of staps is executed repetitively for each requested value,' beginning with 1st-value and incrementing it by "increment" following each repetition until "last-value" is reached. 1 1 As described in Section 4.5, the range given for a variable can be greatly expanded beyond this simple format. For example, Do part 1 for x = 1 ,2,3(2)25(i)2tt(k)200,500 • . In this example, part 1 is performed for x = 1, 2, 3, tlien in increments of 2 up through 25, then in increments of i up through the value of 2t, then in increments of k up through 200, and 500. Example: Type x,x'?2, x~3 ~ *1.1 *Do part 1 for x == 2(2~1 0 ~ x 2 4 x 4 16 64 6 36 216 8 64 512 10 100 1000 x~2 == x~3 == Directs AID to perform step 1.1 for values of x, beginning with a value of 2 and incrementing this value by 2 until lOis reached in a series of repetitive exec uti ons . AID types out results. 8 x~2 == x~3 == x x~2 == x~3 == x xt2 == x~3 == x x~2 == xt3 == * 3.2 DEFINING IDENTIFIERS BY FORMULAS (LET COMMAND) 3.2.1 Arithmetic Formulas AID can be told how to calculate the value of an identifier rather than associating the identi- fier with a fixed value. This is done with the LET command. The use of LET causes the identifier on the left of the equals sign to be set to the formula (not necessari Iy a numeric val ue) on the ri ght of the equals sign (==). *Let d == sqrt(a) + b + c *Type formula d J d: J sqrt(a) + b + c * Note that AID associates a formula, not a numeric value, with the identifier d. In the above example, the formula for d is an expression reducible to a number, but this value is not calculated until d is called for. However, before d can be calculated, the user must supply values for all variables in the formula associated with d. *Type d ~ Error in formula d: a == ?? User has assigned no value to a. 96 *a == *b == 5~ *c == 8~ *Type d ~ d == 16 * 4-19 3.2.2 Boolean Expressions (Propositions) Defined by the LET Command A second use of the LET command is to define an identifier as being equivalent to the value (true or false) of a proposition/ i.e./a Boolean expression compose~ of arithmetic and logical statemen!;, using common relational operators (e.g./ =/>/<)/ the logical negation (not)/ and logical operators (and/ ~). Example: J, J *Set a = true *b = false~ * Let c = a and b *Type c ~ c = false Proposit,ions are discussed in detail in Chapter 4. 3.2.3 User Functions Defined by the LET Command AID provides many of the common algebraic and geometric functions (sqrt - square root/ cos - cosine/ log - logarithm, etc.). AID functionsare specified in expressions by using the appropriate function mnemonic (sqrt = square root). A third use of the LET command is to equate an identifi~r to a user-defined function. Once defined/ a user function can be used the same as an AID function. Example: Defines the user function, a. l *Let a(b,c) = (b~2)-t{2*b*c)+(c~2) ~ *Type a(4, 10) cJ a(4,10) = 196 Both AID functions and user-defined functions are discussed further in Chapter 4. 3.3 IDENTIFIER REFERENCES In addition to an identifier in a formula referring to its associated value or formula, it can also be used to delete, type, or file that value or formula. Examples: J Delete a and its associated value. a) *Delete a b) *Delete formula b c) *Type c d) *Type formula d e) *File e as item 1 ~ J J Delete b and its associated formula. Type the value of c. J Type the formula associated with d. Store e and its associated val ue on the currently open file (see "FILE") as item 1. All current identifiers and their associated values or formulas can be referred to collectively. lin the function a(b/c)/ band care dummy 'arguments and do not conflict with variables-of the same letter outside of the formula (b and c-can be used as identifiers elsewhere). Examples: *Type all values a) d) J *Delete all values J *Delete all formulas J e) *File all values as item 3 f) *File all formulas as item 4 b) c) 3.4 J *Type all formulas J J INDEXED IDENTIFIERS (ARRAYS) Values may be organized into vectors and arrays by using indexed letters for identifiers. The letters may then be used to refer to the arrays. Identifiers defined by formulas may not be indexed. The index or subscript is, enclosed in parentheses immediately following the identifier. Example: *x(1) *x(2) *x(3) = 12 ~ 4~ 6tJ *Type x(1), x(2), x(3), x(1)*x(2)*x(3)J x(1) = 12 x(2) 4 x(3) = 6 x(1) *x (2) *x(3)= 288 *Type x ~ x (1) 12 x (2) = 4 x(3) = 6 x refers to all indexed x's; thus, a nonindexed identifier cannot coexist with the same identifier indexed. Multiple subscripts can be specified for an identifier to create a multidimensional array. An identifier can be indexed by one to ten subscripts, and each subscript may have an integer value in the range -250 through +250. Examples: J a) *x(l) = 6 b) *a(1,2) = 10 c) *c(100,50,67) = 130J J An individual identifier can be used in only one way at anyone time and redefinition deletes any previous definitions. "Thus, the definition of an identifier with n dimensions deletes all definitions of the same identifier having other than n dimensions. Example: The identifier x (unindexed - 0 dimension) is defined as equal to 5. *x =5J *Type xJ x ::: 5 4-21 *x(1) = 10 ~ *x(2) = 20 ~ *Type x ~ x(1) = 10 x(2) = 20 *x(1 , 1) The identifier x is now redefined with one dimension " '(subscript); the unindexed x is deleted. ~ "~', ~ ! ~ = 33 ~ .~ . "r, The identifier xis now redefined QS describing a two-dimensional array; XIS' having other dimensions are deleted. *Type!< ~ x(1,1) = 33 *x(1,2) = 44 ~ *x(2, 1) = 55 ~ *Type x ~ "x(1, 1) , x(l ,2) X{2i 1} = = Additional x values having the same number of subscripts as the previously defined x are entered; no deletions occur. 33 44 '- " 55 NOTE Undefined elements of the x array in thi-s example can-be set to a ,value of '0 by the use of the command Let x be sparse. *Typ'e x(2,2) rl x{2,2) = ?'?? *Let x be sparse ~ *Type x (2,2) ~ x(2,2) = 0 *Type x ~ x(1,1) = 33 x(1,2) 44 x(2,1) x is sparse. 55 * • / 4-22 CHAPTER 4 ARITHMETIC OPERATORS, FUNCTIONS, PROPOSITIONS, AND ITERATIONS 4.1 ARITHMETIC OPERA TORS As discussed in Chapter 1, paragraph 1.3" "AI D Language", all standard arithmetic operators can be expressed in AID. These are presented'in Table 4-1, in their order of precedence. Table 4-1 AID Arithmetic Operators Standard Designation AlP Symbology Ix I [ 1 ! x ! [ 1 ( ) ( e x a . b, (a)(b), or a X b a alb or Ii 0 Meaning Absol ute val ue of x Second level grouping 1 1st Ievel grouping 1 ) The value "x II raised to the power of. "e". x*e a*b Multiply a times b. alb Divide a by b. a + b a+b Add a to b. a- b a-b Subtract b from a. l. Within nested pairs of brackets (or parentheses), the order of evaluation is from the innermost pair outward. Examples: a) -5J *x = *y = +2~ *Type x+y x+y = *Type !x-ty! ~ !x+X! = *Type x+yi'2-15 x+yt2-15 = *Type (x+y)~2-15 ~ (x-ty )t2- 15 = *Type (x+y )t(2- 15) (x+y)t(2-15) = J -3 3 J -16 J -6 -6. 27225472*1 Ot(-7) 4-23 b} *x == sqrt (16}-+sqrt (9) J *y == sqrt [16-+sqrt (9)] J *z = sqrt [sqrt (16+9)] d *Type xrJ x *Type y J = y *Type zJ Z c} 7 . .,' 4.35889894, 2.23606798 == Computing simple interest r =rate of interest per year t =, time (in years) = principal P (in %) (p)(r}(t) == 100 *Let i = (p*r*t}/lOOJ *p = 1000£1:' . ,. *r == 6rl *t = 3rJ *Type iJ 180 d} Computing total accumulated principal and compound interest a =accumulated principal and interest, compounded annually. r I t', and p are the same as above. a = p(Hr/l00}t *Leta =p*(1+r/l00} ~ *p = 1000rl *r =6rl *t =3£1 *Type arJ a = e} trl . 1191.016 Formula for a catenary curve y x x a(a +ea) =2' e where a is a constant, and e is Euler's number *Let m = x/a tJ *Let n = O-m d (optional) *Lete =2.71828183rl *Let y .= (a/2) *[ (6 m) +(e t t (O-m}}J £I or *Let y = (a/2)*[(e t m)+(e *1.1 TypeYJ *a =-3£1 *Do part 1 for x = 1(1)5J y y y y y = = == == t n)] £I -3.1682156 -3.69172674 -4.62924191 -6.08589753 -8.22504851 4-24 Execute part 1 for y with val ues of x beginning with 1 and incremented by 1 until 5 is reached. 4.2 AID FUNCTIONS Many common algebraic and geometric functions are provided by AID for use in expressions. Two of the most commonly used functions ore sqrt SQUARE ROOT log NATURAL LOGARITHM Examples: sqrt(10) log(x*y) Note that the argument for a function is enclosed in parentheses a-nd immediately follows the function mnemonic. Table 4-2 lists AID functions in alphabetic order. The symbols x and y represent any expression reducible to a number and are the arguments of the function. The variable i is a dummy variable and does not affect any real identifier denoted by the same alphabetic character. -' ~ , 4-25 " -' Table 4-2 AID Functions Description Function The ARGUMENT function takes two arguments (x, y) and computes the angle between the +x axis of the x,y plane and the line joining point 0,0 and point x,y, The result is in radians arg(x,y) +Y arg(x,y) • ° The value of arg (0,0) is 0. The range of arg is through 21f or -1f through 1f. X,Y Y~---------- I I I 'i': Jr6;9~ , 0,0 ---..t.--~x:-----L-- +x 'The COSINE f~nction requires one argument, assumed to be in radians. cos(x) I'x I must be < 100. dp(x) The DIGIT PART function, dp(13456.5432)= 1.~4565432 exp(x) The EXPONENTIAL function: eX , where e is Euler's number (2.718281828). The argument (x) must fulfill the requirement that e X - prod(i=range ••• : ••• i expression •• ) The PRODUCT function requires the same two types of arguments as the MAXIMUM, MINIMUM and SUM functions. The expression is computed iteratively for each value of i, and the result (product of all the iterations) is typed out.1 sgn(x) sin(x) The SIGNUM function. The val ue of a signum function of an argument greater than zero is +1, of an argument equal to zero is 0, of an argument less than zero is -1. . The SINE function requires one argument, assumed to be in radians • I x I must be ,sqrt(x) . < 100. The SQUARE ROOT function. The argument (x) must be equal to or greater than zero. sum(i=range ••• : •• i expression •• ) , The SUM function requires the same two types of arguments as the MAXIMUM, MINIMUM, and PRODUCT functions. , The expression is computed iteratively for each value of i, and the result (sum of al I iterations) is typed out.1 1The iterative clause and i funcHon can, in all of these cases, be replaced by a simple series of value: for i. Example: max(S, -4.3, y,x,2) . .see Section 4.S. 4-27 .. Table 4-2 (Cont) AID Functions < Function tv (proposition) " Description - , The TRUTH VALUE function requires one argument, a proposition, and converts this argument into a numeric. value: 1, if the proposition is true; 0, if the proposition is false . . xp(x) The EXPONENT PART function. xp(13456.5432) = 4 i.e., 13456.5432 = 1 .34565432*10 ~ 4 Examples: *a *b *c *d *e *f *i a) b) c) = 12ll = -2.5J = 100£1 = 1.325ll = 10.435J =25J *Let z = sum(i=0(10)100:i*2) J *Type zrl . z = 1100 *Type sum (a,b,c ,d,e,f, i ,z) rl sum (a,b,c,d,e,f,i,z) = 1256.26 *Let z = prod (i =1 (1)5:i *Type zll z =. t 2) rl *Let z = max(i=-15(l)15:{i.~ 2)-(-5*i))J *Type ztJ. z = 300 e) *Let z = min (i=-15(1)15:(i ~ 2)-(-5*i»tl "'Type ztJ z = -6 f) *Type min(a,b,c,d,e,f,i)J min(a,b,c,d,e,f,i) = h) . i) j) k) NOTE The i in .,(a) is a dum~y variable and in no way relates to the i in (b). The latter is an identifier and refers to the variable and defined above. 14400 d) g) • = lOll -2.5 *Type arg{-l,O)J arg(-l,O) = 3.14159265 *Type arg{c ,a) J arg{c,a) = 1.81577499 *Type sin(10) J sin(10) = -'.544021111 *Type cos (a) J cos{a) = , ':'.839071529 *Type sin«a*eH)J sin«a*e)-i) = 't.. .728664976 4-28 ". I} m} n) "Type exp(. 346} ~ exp(.346} = 1.41340262 J *Type fp(e+F) J *Type dp(etf) dp(e+F) = 1.176 fp(e+F) = 0) p) q) r) s) t) u) .76 *Type ip(e+F) ~ ip(e+f) = 11 *Type log(650) ~ log(650) = 6.47697236 *Type log(e+f) ~ 10g(e+F) = 2.46470394 . *Type sgn(d-~bt2}+i) ~ sgn(d-(bt2}+1) = -1 ";m = -5~ *n = *Tr.pe tv«m>=n) or (m=O) or (m -4» tv(m>=n) or (m=O) or (m<0) and (m>-4» = 0 3" /J *Type sqrt(a-+b+C'+cHe) sqrt(a-+b+C+d-le) = *1.1 Let a(x) = xt2-20 *00 step 1.1 for x=1(1 )30 P 10.9920426 ~ *Type a (25) ~ a(25) = *Type first(I=1 (1)30:a (I) =0) first(I=1(1)30:a(I)=O) = ??? *Type first{I=1 (1)30:a (I) >700) first (I=l (1)30:a(I»700) = *Type a (27) a(27) = Set up a table (or array) of 30 items calculated according to the formula given in step 1 .1. 605 J J 4.3 rJ No such value found in table. J 27 709 USER-DEFINED FUNCTIONS Functions not included in AI D can easi Iy be defined for repetitive use. As discussed in Chapter 3, the LET command is used to equate an identifier to some user- defined function. Following this function identifi,er, up to ten dummy arguments (enclosed as a group in parentheses) can be specified; these are replaced by actual arguments when the function is to be used. Dummy arguments are also represented by single alphabetic characters, but the use of a letter as a dummy in no way affects the use of that same letter as an identifier. Following the dummy arguments, an equals sign and the expression representing the user function are typed. f(a,b,c, •••• ) = expression f = function identifier (any single alphabetic character) (a,b/c, •••• ) = dummy arguments (also single alphabetic characters) expression = the arithmetic 'e~pression representing the user fl,lnction Arguments supplied for functions can themselves be functional. 4-29 4.3.1 Examp/es-of User-Defined Functions *let a(b,c) = sqrt(b*c) + b~2 + c~2 ~ Define the user.function a, with two dummy -arguments band c, as being equivalent to the formula sqrt(b *c )+b~2+c ~2 *Type a(120.555,32.076) a(120.555,32.076)= b 15624.5624 *Type a ~ a(b,c): sqrt(b*c) + b~2 + c~2 *Type formula a ~ a(b,c): sqrt(b*c) + b~2 + c~2 *Type a(b,c} ~ b = ??? Use the newly-defined function by specifying two actual arguments in place of the dummy arguments, b and c. Note that a is equated to the formula, not'a value, since a alone is not an expression. Same typeout. No values -have been specified for the identifiers (not dummy arguments), band c. *b = (4~6)/9~ *c = 5.23P *Type a(b,c) ~ a(b,c) = 207202.264 Many common functions can be defined as user functions, as shown below. Tangent *Let T(a) = sin(a)/cos(a) *Type T(10) P T(10) = b .648360828 Arc cos *Let F(a) =arg(a, sqrt(1-a~2» *Type F(.10) t:J F(.10) = 'b 1.47062891 Arc cot *Let C(a) = arg(a, 1) *Type C(10) ti C(10) = tJ. .0996686522 Arc csc *Let 5(0) = arg(sqrt(1-1/a~2), 1/a) tJ. *Type 5(10) .d 5(10) =; .100167421 Arc sec *Let K(a) = arg(1/a,sqrt(1-1/a~2» ~ *Type K(10) t3 K(10) = 1.47062891 4-30 Arc sin *Let N (a) = arg (sqrt (1-0 ~ 2),a) rl *Type ~(.10)rl N(.10) = .100167421 Arc tan *Let T(a) = arg(1 ,a) J *Type T(10) rl 1(10) = 1.47112767 Log to base 10 *Let L(a) = log (a}/Iog (10)J *Type L(25.38)~ L(25.38) = 1.40449162 Derivative of a function of a variable *Let D(a) = (F(a+.005)-F(a- .005»/ .01 rl *let F(a) =3*a ~3-4*a ~2+2*a+5tl *Type D(4) ~ D(4) = 114 4.4 PROPOSITIONS As discussed in Chapter 3, propositions are Boolean expressions composed of arithmetic or logical statements using the relational operators. = (equal), # (not equal), >(greater than), > = (greater than or equal to), < = (less <(less than), than or equal to) the negation not and the logical operators and or A proposition has either of two possible values: true or false. Example: *x = trueJ *y = falseJ *Let z = (x) and (y) or (x) and (100 >Sqrt(959» tl *Type z rJ z= true The order of execution within a proposition is: a) evaluation of expressions b) ( ) Within nested pairs of parentheses, the order of evaluation is from the innermost pair outward. c) relational operations 4-31 • d) e) !!Q!. and f) Q!. .- " ~ :: " ,# A series of relational operations is assumed to be an ~ chain if no logical operator intervenes. a=b>c c and c Sqrt(30*5-20» *Type tv (y) tJ. tJ. o *Type 'J.4+tv(x(J 24+tv(x) = 4.4.1 25 Conditional Expressions A conditional expression allows an expression (e.g., a variable) to have different values de- . pendin~ upon which of a numbe'r of conditions is true •. It is composed of a series of clauses separated by semicolons, ~ith each clause ~ade up of a proposition followed by a colon follow'ed by an expression. The entire conditional expression must be enclosed by parentheses or brackets. (proposition:expression; proposition:expression; •••• ) Example: Express the function: If x> 0, C(x) = x~2; if x=O, C(x) =0; . if x 0:x~2;x=0:0;x<0:x) *Type C(5)', C(-10), C(O), C(10) iJ C(5) = 25 -10 C(-10) = C(O) = 0 C(10) = 100 tJ If the last expression is to be true for all cases which do not satisfy any o(the stated condi - ' tions, the expression can be typed without a preceding proposition. For example, in the case above r the user could have typed: *let C(x) = (X>0:x~2;x=0:0;x) tJ NOTE, Every possible combination of the variable must be provided for, either by explicitly stating a conditional expression arid a proposition for it, or by simply specifying 0 terminating expression to be executed for all cases which do not satisfy any of the explicitly stated propositions. '1f this provision is not mode, and an unprovided -for condition'occurs, AID responds with the message ERROR IN FORMULA X . 4-32 A conditional expression can be used to perform a fable lookup for all items whose values satisfy one or more conditions. Example: *1.1 SetA(x)=xi2 +x*.5-5*x tJ Generates a 35 - item tabl e. *00 step 1. 1 for x = 1(1)35 ~ *Type A(20) tJ A(20) = 310 *Type A(3) ~ A(3) = -4.5 *Let F(x) = (x<0:xix>700:Xifp(X»0 and x>300:x; *00 step 1 .1 for i = 1(5)35 F(A(i)) = tJ Test every fifth item in the table. -3.5 F(A(i)) = 346.5 = Values, in tested items which do not satisfy any of the three propositions result in line feed/carriage return (because of the terminating + symbol in the conditional expression). . 821.5 = *Let E(x) = (fp(x/2)=0:x; tJ Find all values which are (1) less than zero; (2) greater than 700; or (3) greater than 300 and have a fractional part which is nonzero. If x is none of these, perform a line feed, carriaQe return (indicated by the + symbol). *1.1 Type .F(A(i)) ~ F(A(i)) F(A(i» + ) 1067.5 + ) " . Find all even-numbered values in the table. *1.1 Type E(A(i» ~ Test every item in the tabl e • *Do step 1 • 1 for i = 1(l)35 " E(A(i» = -2 E(A(i» = 28 E(A(i» = 90 E(A(i» = 184 E(A(i)) = 310 E(A(i» = 468 E(A(i» = 658 E(A(i» = 880 4-33 4.5' ITERATIVE CLAUSES"(RANGES) Iterative clauses are 'used with the DO command and with the functions FIRST, NtA.X, MIN, PROD, and SUM. In bO.th cases, the iterative clause specifies a range of values to be acted upon by the command or function. 4.5.1 Series of Values One format of an iterative clause lists the individual values which make up the range: n, n I' n2.' n3 ,······· For exampl,e, Do part m for x',= range Do part 1 forA:::; 1, M, 100,50, -25, xt3 Type sum(x=range) Type sum(A = -4.6, M*N, 240.5,C) 4.5.2 Part 1 wi II be executed for each of the individual values of A. The SUM function is performed on 'all values listed and the result (the , SUM of all values) typed out., Incrementation The range of values for a variable can also be expressed as a first value, an incremental value, and an ending value. As a result, the variable values range from the'first value ,upward in steps of the specified increment until the e~ing value is reached. The ending value is always taken as the last value in the range, even though the incremental steps may not hit it exactly. The general form of an incremental iterative clause is: x = first-value{increment)ending-value ,For example: Do step m. n for x = range Dostep2.3forA= 1(2)12 Step 2.3 will be executed for each individual value of A: 1,3,5,7,9,11,12 Type sum (x =range )' Type sum(A = -50(B)C) 4.5.3 The SUM of all values of ,A, as indicated by the range, is calculated. This range begins with -50 and contin!J~s in increments of B until C is reached. Combinations A range can be expressed as a combination of value series and increments. 4-34 x = a(b)c,d,e(f)g(h)i,j,k The-range pf x values begins with a,' continues in increments of b through c, then d, e, then in increments of f until g is r.eached, then in increments of h until; is reached, then j and k. ' For example, Do part 3 for W = 20(Y)50(50)500, 1000(100)Z Part 3 will be performed for all value$ of W, beginning with 20, continuing in increments of Y through 50, then continuing in increments of 50 through 500, and from 1000 in increments of 100 through Z. Type sum(W = A(30)B, C, 800(0) 1500) The SUM function will be applied to all valves of W, beginning with A and continuing in increments of 30 through B, then C, followed by 800 through 1500 in increments of O. '4-35 CHAPTER 5 AID VERBS This chapter contains a summary of AID verbs, their command formats, optional features, and examples of usage. Some of these verbs (e.g., TYPE, DO) hove appeared frequently in examples in previous chaptersiothers(e.g., LET, SET) have already been describedextensivelyandare included here only as a review. Some verb descriptions include diagnostic messages which are associated with a specific command or group of commands. A complete list of diagnostic messages can be found in Table A-4. II 5.1 CANCEL DESCRIPTION The CANCEL command cancels a currently stopped (interrupted) process, if the user does not desire to resume execution. 1 CANCEL is the antithesis of the GO command. CANCEL also releases any immediate memory currently assigned to the interrupted execution. NOTE The CANCEL command does not, however, delete any commands, formulas, variables, etc., associated with the interrupted process. The CANCEL command can be given directly only. Parenthetical CANCE L (CANCE L) Typing (CANCEL) cancels any currently stopped process that was initiated by a parenthetical DO. 1 An interrupted process is automatically cancelled whenever the user types a direct DO command to initiate another part or step. 4-37 EXAMPLE *1.1 Let x = ..... ~ *2.10 Type .... ~ '*00 part 1 P •• Error 'at step 2.5: i"egal set of values for iteration. *Cancel. ~ User does not desire to correct step and resume execution. * DIAGNOSTIC MESSAGES DON'T GIVE THIS COMMAND INDIRECTlY 4-38 The CANCEl command can 'be given directly only (with no step number precedi ng it). 5.2 DELETE DEseRI PTION The DELETE command erases a step, port, form, value, or formula from immedio.te storage and frees that storage for some other use. This command should be used frequently to delete.routines, tables, and other items which are no longer needed. By doing this, unnecessary waste of storage and possible storage overflow can be avoided. Delete a Delete identifier a and its associated value{s) from immediate storage. If identifier a is a subscripted variable, the entire a array is deleted. Delete a(b, ••J Delete the particular array item, a{b, •• ), and its associate value from immediate storage. Delete step m.n Delete the step numbered m.n. Delete port m Delete port m (all steps having numbers whose integer portion is m). Delete formula a Delete the formula associated with a. Delete form m (See "FORM" and "TYPE" for on explanation of forms.) Delete form m. values steps Delete all ports Delete all entries of the named type. Delete all Delete all entries. Several individual DELETE commands can be combined into one. For example, Delete x, form 3, formula b, all ports. 4-39 EXAMPLES t> *1.1 TyPe '''STEP A" *1.2 Type a+b in fann 1 ~ *1.3 To step 2.1 ~ l *2.1 Type a~2+b~2 p *2.2 Type "END" /J *Leta= 10+b t> *b = 25A *Form 1:~ Type entries into immediqte storage. *"""""0"" ~ *00 part 1 ~ Test routine. STEP A 60.00 1850 at2-1bt2 = END t\ Delete identifier b and its associated value. Attempt to use b. *Delete b *00 part 1 p STEP A Error at step 1.2 (in fonnula A): b ~ ??? *Delete step 2. 1 ~ Delete step 2.1. *00 step 2.1 ~ I can't find the required step. *Delete a ~ Attempt to execute it. *Type a ~ 0= ??? *Del~;e' 01 I ~ Attempt to type it. *Type all ~ Test that all have been deleted. Delete formula a. Delete remaining entries. * • 4-40 I 5.3 DEMAND DESCRIPTION DEMAND causes AID to type out a request for a user-supplied value during execution of a routine. The DEMAND command can be given indirectly only. Demanda. AID types out a request for the value of a. tJ. *1 • 1 Demand a *1.2 Type .•••• ~ *Do part 1 t> a = *(user types value here)~ Demand a(b, •• ). AID types out request for the value of the subscripted variable a(b, •• ). *1.1 Demand M(3,5,7) !> *1.2 Type ••••• 1> *Do part 1 P M(3,5,7) *(user types value here)!> DEMAND ..... AS "ANY TEXT" OPTION Demand a as "any text" . AID types "any text" to request a value for a. *1.1 Demand p as "NUMBER OF SAMPLES WANTED" r:l *1.2 Type •••• ~ *Do part 1 tJ NUMBER OF SAMPLES WANTED = *(user types value here)!> Demand a(b, .. ) as "any text" . AID types "any text" to request a value for the subscripted variable a(b, .. ). 4-41 ~~ .... " t\ ,J. ~"'! .... "':.-d ~; *1.1 Demand y(3) as "MAXIMUM SPEED" *1.2 Type ..... ts *00 part 1 tl MAXIMUM SPEED = *(user types ~alue hEm9)~ ~ Depending upon the use of the variable specified, values r~quested b)la 'D~MAND command can be entered in the form of a) a numeric expression (e.g., a numberin fixed or floating point notqtion, or an identifier representing a numeric value), b) a formula, or c) a Boolean value (true or false). NOTE Only one variable can be specified in each DEMAND command. EXAMPLES a) *x=25 ~ *y=50.25~ __ *z=16.4~ *1.1 Type "CONVERSION OF POUNDS TO KI LOGRAMS" *1.2 Demand a ~ *1.3 Type a,b in form 1 ~ *1.4 To step 1.2 ~ * Let b =. 45359*a P *Form 1:1> * .................... • ................ POUNDS *Do part 1 t> = . . . . . . . . . . •. . . . . . . . KILOGRAMStl CONVERSION OF POUNDS TO KILOGRAMS a = *25.8" 25.8000 POUNDS = .\ 11.7026 KILOGRAMS a = *100.543p 100.5430 POUNDS = .1 45.6053 KI L9 GRAMS a = *5567.98p 5567.9800 POUNDS = 2525.5801 KILOGRAMS a = *1> I'm at step 1.2. ~a'rriage return by user terminates iterations. *1.2 Demand a as "POUNDS" *Do part 1 ~ CONVERSION OF POUNDS TO KI LOGRAMS POUNDS ~ *25.8" 25.8000 POUNDS = POUNDS = *~ I'm at step 1.2. 11.7026 KI LOGRAMS * , 4-42 ~, ., - b) *Let a = m and' n f) *Let b = m or n ~ *1 • 1 Demand m *1 .2 Demand n *1.3 Type tv(a) in. form 1 ~ *1.4 Type tv(b) in form 2 V *1 • 5 To step 1. 1 *Form 1: t> * Logical AND: + *Form 2: ~ * Logical OR: ... *00 part 1 t> .\ m = *true V:. n = *falset> Logical AND: 0 Logical OR: 1 t> t> t> m = *false ~ n = *false V Logical AND: 0 0 .\ Logical OR: m = *not true V n = *not false t> Logical AND: 0 Logical ~R~.\ 1 m - V 11m at step 1 • 1 • * Carriage return terminates iterations. c) *1. 1 Do part 2 for B = 1(1)3 t> *1.2 Type A I> *2.1 Do part 3 for C = 1 (1)5 t> *3.1 Demand A(B,C) t> *3.2 Set A(B,C) = sqrt(A(B,C» t> *00 part 1 ~ A(1,1) A(1,2) A(1,3) A(1,4) A(1,5) A(2, 1) A(2,2) A(2,3) A(2,4) A(2,5} A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) A(1, 1) A(f,2) A(1,3) A(1,4) = *30 = *65 = = = = *4 *50 *43.55677 *32· = *1 = *45.99 = *29 = *22.3333 = *56.77 = '*66,.7777 = *99 = *100 *1234.33 = = = . = 5.47722558 8.06225775 2 7.07106781 4-43 A(1,5) 'A(2,1) A(2,2) A(2,3) A(2,4) A(2,5) A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) =' = = = = = = = = = = 6.5997553 5.65685425 1 6.78159273 5~ 38516481 4.7258121 7.53458692 8.17176236 9.94987437 10 35.1330329 4'"744 II 5.4 DISCARD DESCRIPTION DISCARDdeletesanitemfromtheexternal storage file currently in use. Discard item m (code). Erase item #m (where m can be in the range 1 through 25) from the currently open external storage file and make the item available for some other use. Immediate storage is not affected in any wdy. Code is optional for documentation purposes only and is ignored by AID; however, code, if used, cannot exceed five characters in length. EXAMPLE *Discard item 20 Done. P Item 20 of the external storage fi Ie currently in use has been cleared successfully, as evidenced by the AID message, DONE •• Item 20 can now be used for storing some other data, via the FI LE command. DIAGNOSTIC MESSAGES I CAN'T FIND THE REQUIRED ITEM. The specified item cannot be found in the currently open file. Ei ther the wrong file is open, or the item number is incorrect. ITEM NUMBER MUST BE POSITIVE <=25. INTEGER An invalid item number was given. YOU HAVEN'T TOLD ME WHAT FILE TO USE A DI SCARD command was attempted before an external storage file was opened via a USE command. 4 .... 45 c, ' \:1 ' 5.5 DE'SCRIPTION The DO command executes an indirect step or part. DO is completed when either (1) in a noniterative operation, the last step in the sequen~e has been completed, or (2) in an iterative operation, the last iteration has been completed. 1 If the DO command is a direct step,' control returns to the user at the compretion of the DOi if the DO command is indirect, control returns to the step following the DO. 'If the step or part being executed contains imbedded DO or TO commands, they are executed normally. Do step m.n Execute step Hm•n and return control as descri bed above. TIMES Option Do step m.n, p times Execute step Hm•n the nu~ber of times specified by integer p and return control as described above. Note that a comma must immediately follow th!Sl step number. RANGE Option (FOR Clause) Do step m. n for x = range Execute step m.n iteratively for each specified value of x as indicated by range (see Section 4.~~,. When the range is sat1sfied, control ,is returned as described above. Do step 1 ~ 2 for x = 1(1 )5 Execute step 1:2 iteratively, beginning with an initial x value of 1 and incrementing x by 1 prior to each iteration until the maximum value of 5 is reached. Do step 5.25 for a = -10.25(.25)4.50 Execute step 5.25 iteratively, beginning with an initial a value of -10.25 and incrementing a by the value .25 each time until the maximum value of 4.50 is reached. Do step 1.3 for m = 1,-2.5,100"':'43.666 Execute step 1.3 for each of the four specified m values. 1Remember that steps are always executed according to the n~merical regardless of the order in which the steps were originally entered. 4 ... 46 s~quence of their step numbers, Do step 10.6 for p = 200, -30.667, -2.3(.1)1.9, 5.75 Execute step 10.6 for three val~s of p (200, -30.667, anclS.7~ and 'for a range of values of p (4.3 through 1 .9, in increments of .1). Do step 1.3 for m = 1(4)26(5)50{25)155 Perform step 1.3 iteratively for m = 1 to 26 in increments of 4 26 to 50 in increments of 5 50 to 150 in inc(ements of 25. Thus, the values ofm will be 1,5,9, 13,17,21,25,26,31,36,41,46, 50,75, 100, 125, 150, and 155 for the 18 iterations of step 1.3. Do part m Execute part m {all steps having the value m as the integer portion of their step number}. All steps are executed in numeric sequence; any jump (via a DO or TO) to a step which is outside part m is handled correctly. Control is returned as described above. Do part m, p times Execute part m the number of times specified by integer p and return control as described above. Do part m for x = range Execute part m iteratively·for each specified value of x in the same manner as described under" Do step m.n for x = range". The FOR clause of a DO command is interpr~ted only once, at the point where the DO com- mand is encountered; therefore, if a variable specified within the FOR clause is changed during execution of the DO-initiated routine, the change has no effect on the performance of the FOR clause. The number of iterations performed and the setting of the variable at the beginning of each iteration is the same as if no modification of the variable were performed by the routine. *1.1 Do part 2 for x=1(1)5 }, *2.1 Type x C> '*2.2 Set x = x+l00 ~ *2.3 Type x tJ *00 part 1 {) x = x = x = -x = x = x == 1 101 2 102 .3 103 x = 4 x = 104 5 105 x = x = 4-47 Note that, when the FOR clause is used, the end-range v~1u~'i~ hif~~~tjy. For example, given the DO command . :. '~: . ,~. :_: Do part 1 for x = 1(3)14.5 iterations will be performed for x = 1, 4, 7, 10, 13, and 14.5. IF Clause The IF clause (q.v.) when appended to a DO command is also interpreted only once (when the DO command is encountered) and has no effect once execution of the DO has begun. Thus, even though the DO-initiated routine might perform some action which would make the IFcondition no longer satisfied, once execution has begun it continues to its normal termination. P *x = 20 *1.1 Do part'2, 3 times if X>O ~ *2.1 Set x = x-50 ~ *2.2 Type x ~ *00 part 1 b x x -30 = At the start, x = 20. x is now <0, but iteration continues. -80 x = -130 Parenthetical DO (DO •••••• ) The parenthetical DO command is used to initiate execution of a step or part, while another process is waiting to continue after a STOP or "other type of interrupt, without cancelling that other process. NOTE A normal DO command automatically cancels any currently stopped process. The parenthetical DO command inc ludes all the options of the normal DO command. Its general format is: (Do ••••••••••• a) (Do part 3 ) b) (Do step 1.4 for x = 5(5)25 ) The parenthetical DO command is commo;nly used to execute a step or part to test its validity; thus, this commanc/ is primari Iy a debugging aid. Any stopped process which was originally initiated by a parenthetical DO can be cancelled by a parenthe.tical CANCEL command. Examples of parenthetical DOs can be found under" GO" in this chapter. EXAMPLES a) * 1 . 1 Type *1.2Type *1.3 Type *1.4 Type "A" ~ "0" rJ, "F" ~ "J" cl *1.25 Type "E" ~ *2.1 Type "8" ~ ~2~2 Type "e" cs *3. 1 Type "G" r:J *3.2 Type "H" r:J *3 .3 Type "I" ~ *Do part 1 ~ A D E F J *1.15 Do part 2 *Do part 1 ~ A 8 e D E F J *1.35 To part 3 t:l *Do part 1 A 8 e D E F G H I , , * b) *let I = sqrt (a ~ 2+b ~ 2) J * 1 . 1 Do part 2 for b = 1 (3)9 ~ *2.1 Type a I b I lin form 1 t:l *Form 1: t:l * a= ............ b=+-"'''' c=_ ............. · .............. tl *Do part 1 for a = 1 (2)12 t:l a= 1 b= 1 c= 1.4142 a = 1 b = 4 c = 4. 1231 a = 1 b = 7 c = 7.0711 9.0554 a = 1 b = 9 c = a = 3 b = 1 c = 3.1623 a = 3 b = 4 c = 5.0000 a= 3 b= 7 c= 7.6158 a= 3 b= 9 c= 9.4868 a = 5 b = 1 c = 5.0990 a = 5 b = 4 c = 6.4031 8.6023 a = 5 b = 7 c = a = 5 b = 9 c = 10.2956 a = 7 b = 1 c = 7.0711 a = 7 b = 4 c = 8.0623 4-49 Note that no return is made to step 1.4. (the TO command does not return control). I ~, JVlOO 0= 0= . '0= a'" ' 0= 0= 0= 0= a'" a':" 0= 0= " 7 7 9 9 9, 9 II 11 11 11 12, 12 12 12 b= b= b= b= b= b;'" b= b= b= b= b= b= b= b= 7 c= c= 9 1 c= c= 4 7 '. c= 9 c= 1 c= c= 4 7 c= 9 c= 1 c= 4 c= c= 7 9 c= o. . \: 9.8995 11.4018 9.0554 9.8489 11..4018 12.7279 11.0454 11.7047 13.0384 14.2127 12.0416 12.6491 . '13.8924 15.0000 .If~'!~"'jt" ~~j<~( * c) t> , *Delete all, *Let A = (B~2)/4*sqrt(3) t> *1.1 Type A, 2*A, +- I> *1.2 Stop if A> 100 t> *2.1 Type B tJ *Do part 1 for B=10(25)100 ~ A= 43.3012703 2*A = 86.6025406 .A = 530.440561 2*A = 1060.88112 Stopped b,3 step 1.2. *Type A . A= *1.0 Stop if A>100 ~ *Do part 1 for B=10(25)100 " A= 2*A = " 530.440561 43.3012703 86.6025406 Stopped by step 1. * DIAGNOSTIC MESSAGES I CAN'T FIND THE REQUIRED STEP. An incorrect step number has been specified; no such step number exists • . '.i I CAN'T FIND THE REQUIRED PART. An incorrect part number has been specified; no ,such part number exists. " .J ". c'. .... '~ . 4-50 . -", - ' . ", ""' /.), ,- ... ,- 5.6 DONE DESCRIPTION The DONE command skips execution of the remaining steps of a part during the current iteration. This command can-be given indirectly only. It is usually given conditionally. Done (unconditional) Normally used only as a temporary step (during the testing of a routine) when performing a partial execution., Done if ••..•. (conditional) Used to skip execution of the remaining steps of a part when certain conditions (specified in the IF clause) are met. EXAMPLE *LetA = 8~2+2*8+10 t> *Let C =,At2+2*A*8+8t2 t> *1.1 Type A / 8 / C in form 1 C. *1.2 Type A*8 ~ *1. 3 Type A*C , <4*Form 1: t> t> *+++++-++++ + .... +++.++++ +++++.++++ " *Do part 1 for 8 = 1(1)4 ~ 13.0000 1.0000 A*8 = 13 A*C = 2548 25.0000 A*8 = A*C = 2.0000 36 7200 3.0000 75 19600 34.0000 A*8 = A*C = 4.0000 136 49096 18.0000 A*8 = A*C= *1.15 Done 196.0000 400.0000 784.0000 1444.0000 t> *Do part 1 for 8=1 (1)4 P 13.0000 1.0000 18.0000 2.0000 25.0000 3.0000 34.0000 4.0000 *1.15 Done if 8>2 *Do part 1 for 8=1 (1)4 13.0000 1.0000 A *8 = 13 A*C = 2548 t> 18.0000 A*8 = A*C = t> 2.0000 36 7200 Insert temporary premature termination step following 1.1. 196.0000 400.0000 784.0000 1444.0000 Change unconditional DONE to conditional. 196.0000 400.0000 4-51 3.0000 4.0000 784.0000 1444.0000 * DIAGNOSTIC MESSAGES DON'T GIVE THIS COMMAND DIRECTLY 4-52. The DONE command must only be given indirectly {preceded by a step number}. 5.7 I DESCRIPTION FILE FILE stores an item in the external storage file currently in use. Immediate storage is not affected in any wr:;Jy. E. a(b, ... ) form m step m part m formula f all steps File all parts as item n (code) all formulas all forms Store the specified information as item n (where n can be in the range 1 .through 25) in the currently open externa I storage fi Ie. Code is optional for documentation only and has no meaning to AID; however, code, if used, must not exceed five characters in length. all values all EXAMPLE *File all parts as item 5 Done. J * All parts'" existing in immediate storage are stored on the currently open external storage file as item 5. Successful execution of the command is evidenced by the AID response, DONE .. Item contents can be retrieved by the RECALL command. DIAGNOSTIC MESSAGES ITEM NUMBER MUST BE POSITIVE INTEGER <=25. An invalid item number was given. PLEASE DISCARD THE ITEM OR USE A NEW ITEM NUMBER. The specified item is already occupied; no change in either immediate or external storage occurs. PLEASE LIMIT ID'S TO 5 LETTERS AND/OR DIGITS Code exceeds five characters in length. YOU HAVEN'T TOLD ME WHAT FILE TO USE. A FILE command was attempted before an external storage file was opened via a USE command. NOTE Only 22 items are allowed, if DECtape is used for external storage. 4-53 I FORM . 5.8 DESCRIPTION FORM is used to edit typeouts of results ,for purposes of readibi lity, e.g., to (l)specify that results be typed in a specific notathn, (either scientific or fixed point), (2) specify that multiple results are to be printed on a single line, usually to conserve space, (3) intersperse text .with results, and (5) produce report-type headi ngs. The elements which can be typed in a form are: a) Numeric values, including variables, $ (line counter), TIME, TIMER, and SIZE. 1. Type -23.466 in form 1 2. Type 0, b, c in form 2 3. Type $ in form 3 4. b) Type TIMER in form 4 Propositional values (TRUE and FALSE). Both of these values must be provided with on integral form field containing at least five character positions. Type F in form 5 c) ... (where F is a proposition). {indicating a blank field}. Type a, b, ... , f in form 6. Forms are entered as two lines: *Form n:~ * n identifies the specific form and must be on integer. user types actual format here •. Once a form is defined, it can be used by sp'acifying itin ~ TYPE c~n;Jmand. Type ......... in fqrm .n Specific Notations Fixed-point notation is specified by a series of left arrows, one for each digit position and one for a si9':l (if any). If less integer places appear in the form than in the result, the error message I CAN'T EXPRESS THE VALUE IN YOUR FORM is typed; if less decimal places appear in the form than in the result, rounding occurs. A period is used to indicate the decimal point position. ++++.+++ -- -345.667 ++++a ++++++ - 345.666667 \ 4-54 At least seven periods must appear in a scientific notation form. ,.,.' -3.3-01 Reducing the number of periods in a scientific notatipn form reduces the number of fraction digits appearing in the result; these digits are dropped after rounding. Multiple Results on a Single Line More ,than one result can be typed on a single line through the use of the FORM command. Such a technique might be used to conserve space, increase output speed, and/or couse results to appear under previously typed col umn headings. *Form l:~ * + ... + +++++++ • + +++++++ • ++ +ofo:++++. +++ " * 1.1 Type Il, a~2, a~3, a~4 in form 1 p *00 step 1.1 for a = 10(.5)15 f) 10.0 100.0 1000.00 10000.000 10.5 110.3 1157.63 12155.063 11.0' 121.0 1331.00 14641.000 11.5 132.3 1520.88 17490.063 12.0 144.0 1728.00 20736.000 12.5 156.3 1953.13 24414.063 13.0 169.0 2197.00 28561.000 13.5 182.3 2460.38 33215.063 14.0 196.0 2744.00 38416.000 14.5 210.3 3048.63 44205.063 ~5.0 225.0 3375.00 50625.000 * Interspersing Text with Results A form can be used to intersperse explanatory text with typed results. *Form 2:~ * If a = +++. + then 0~2 = +++++. ++++ *2.1 Type 0, 0~2 in form 2 ~ *00 part 2 for a = 10(.5)12 J) '100.0000 Ifo=10.0 then oC12= 110.2500 If a = 10.5 then oC12 = 121.0000 If a = 11.0 then oC12 = 132.2500 If a = 11 .5 then oC12 = 144.0000 lfa=12.0 thenoc.2= * "4-55 Report-Type Headings A form containing only text can-be used to- generate columnar- headings~" *Form 3:tl a * *1 .1 Type form 3 *1.2 Do step 1.3 for a = 10(.5)12~ *1.3 Type a, a ~2, a ~3, a ~4 in form 1 cJ *Form 1: * ......... ................................ . . ................ Iof-o ..... *00 part ltJ a a~3 a~2 10.0 1000.0000 100.0000 10.5 110.2500 1157.6250 11.0 121.0000 1331.0000 11.5 132.2500 1520.8750 12.0 1728.0000 144.0000 1728.0000 12.0 144.0000 * 'c" . . ........................... t! a~4 10oo0.0pOO 12155.0625 14641.0000 17490.0625 20736.0000 20736.0000 . DIAGNOSTIC MESSAGES FORM NUMBER MUST BE INTEGER AND 1 <= FORM<1049. Form numbers must be integers in the range 1 through 109-1 . I CAN'T EXPRESS THE VALUE IN YOUR FORM. A value cannot be expressed in the format given (the value is to~ large). I CAN'T FIND THE REQUIRED FORM. The specified form does not exist; the form number is incorrect. I HAVE TOO MANY VALUES FOR THE FORM. The TYPE command specifies more elements to be typed than there are fields in the form. ' 5.9 f 'GO DESCRIPTION GO continues execution of a currently-stopped (interrupted) process. GO is the antithesis of the CANCEL command. The GO command is normally used to continue execution after control has been returned to the user via a STOP command. Go The GO command must be given directly only. EXAMPLE *let v=p*(rt2)hd *p=3 .1421l *1.1 Do part 2 for h=.5(.5)3 d *1.2 Stopd *2 • 1 Type r , h, v inform 1 J *3.1 Type r'2~ *3.2 Delete step 1 .2 ~ *Form 1: * ............................................. tl *Do part 1 for r=l (1)3 ~ Error at step 2.1 (in formula v): eh? . *Type formula v rJ v: p *(r t2)h *let v=p*(rt2)*h J *GocJ .5 1.0 1.5 2.0 2.5 3.0 Multiplication symbol was omitted. Correct formula. Execute GO to continue. ·1.5710 3.1420 4.7130 6.2840 7.8550 9.4260 STOP command at step 1 .2 is Stopped by step 1 .2 encountered. *(Do part 3) r:l rt2 = Done. I'm ready to go from step 1.2, although I can't find it. *Go~ 2 2 2 2 2 2 3 3 3 3 3 3 .5 1.0 1.5 2.0 2.5 3.0 .5 1.0 1.5 2.0 2.5 3.0 6.2840 12.5680 18.8520 25.1360 31.4200 37.7040 14.1390 28.2780 42.4170 56.5560 70.6950 84.8340 *Go I have noth i ng to do. * 4-57 Execute part 3 via a parenthetical DO; then GO to continue. The GO command can be given dionly (with no step number' ' preceding it). recty I HAVE NOTHING TO DO. When the GO command was given, no process was in a stopped or interrupted status. Control retl,lrns to the user and AID waits for a new command. 4-58 5.10 _ IF CLAUSE DESCRIPTION The IF clause can be appended to ~ command (except the short SET command) to make that command conditional; (the command is executed only if the proposition following the word IF is satisfied). Verb (arguments) IF proposition EXAMPLES a} *1.1 Setb=50ifa>100" Set b equal to 50 if, and only if, a is greater than 100; otherwise leave the value of b undisturbed. b} *3.3 To part 5 if fp(d)=O ~ Transfer control to part 5 if, and only if, d is an integer; otherwise, continue in sequence. c) *2.9 Do part 3 if tv(f)=l " Execute part 3 if the truth value (tv) of proposition f is equal to 1; otherwise, continue in sequence. 4-59 , LET 5.11 DESCRIPTION LET defines arithmetic formulas, Boolean expressions (propositions), and user functions. The· formula, expression, or function with which an identifier is associated is re-evaluated each time that identifier appears during execution of a routine. Arithmetic Formulas The LET command can be used to tell AID how to calculate the value of an identifier (versus" associating the identifier with a fixed value, as with the SET command). LET causes the identifier on / the left of the equal's sign to be set to the formula on the right of the equals sign. a) *Let v = p *(r ~ 2) *L *Set p =3.1416cl b) *Let L ::: w *h ~ J Boolean Expressions (Propositions) LET can also be used to equate an identifier to the value (true or false) of a proposition (a Boolean expression) composed of (e.g., =,<, », arit~metic the logical negation (not), and logical operators (and, or). a) *Let a ::: true J b) *Let c ::: a ane! b or c or d J . c) and logical statements using common relational operators *Let y ::: X and yor (sqrt(100) ~ *~5 ~ *c=12 r) *Do part 1 c) VOLUME CALCULATION AID advances paper form one line. ' a = b= c == a*b*c = 3 5 12 180 NOTE The steps above perform essentially the same process as the command: *1.1 Type "V.oLUME CALCULATION" *1.2 Type + ,a,b,c,a*b*c t> ,"":' " '. t> 5.13 DEseRI PTION PAGE advances the Teletype paper form to the top of the next page. Page. The PAGE command can be used in conjunction with the $ symbol, which represents the current line count, (the number of lines printed thus for on the current page). mum of 54 I ines per page. EXAMPLE *1.0 Page *1.1 Type"SQUARE ROOT VALUES FOR 1 - 100" *1 .2 Do part 2 for a = 1 (1)100 *2.1 Type a, sqrt(a) ~ .l *2.2 Do part 3 if $>45 V *3.1 Page *3.2 Do steR 1.1 *Do part 1 ~ tJ tJ tJ ( skip to new page) SQUARE ROOT VALUES FOR 1-100 .i (44 lines of typeout) ~ (skip to next page) SQUARE ROOT VALUES FOR 1-100 (44 u1 of typeout) ~ (skip to next page) SQUARE ROOT VALUES FOR 1-100 i (remaining 12 lines of typeout) + 4-63 P AID allows for a maxi- DESCRIPTION -QUIT skips execution of the remaining steps of a part and satisfies the DO command for that part by cancelling any further iterations. The QUIT command is uSl.!OlIy given conditionally. Quit. (unconditional) Normally used only as a temporary step (inserted for the purpose of testing a portion of a routine) when performing a partial execution. Quit if ....•. (conditional) Used to skip execution of the remaining steps of a part (and any further iterations of the part by the current DO command)' when certain conditions are present. EXAMPLE *let A = B~ 2+2*B+10 d *Let C =A ~ 2+2+A+B+B ~ 2 ~ *1.1 Type A,B,C ~ *1.2 Type A*B~ *1.3 Type A*ccl *Do part 1 for B = 5(5) 15J , A 45 B C A*B A*C = A B C = A*B -A*C = AB C = A*B = A*C *1.15 Quit if A >lOocl *Do part 1 for B = 5(5) 15 J A= 5 2102 225 94590 130 10 17142 1300 2 .22846*10 ~6 265 15 70732 3975 1 .874398*10~ 7 45 B 5 C A*B A*C A B C 2102 225 94590 130 10 17142 = = = = = * 4-64 5.15 " RECALL DESCRIPTION RECALL reads an item, previously stored by a FI LE command, from the currently open external storage file into immediate storage. The contents of the item then exist both on the external file and in immediate storage. All steps, identifiers, forms, etc., which were in immediate storage before the RECALL command was given remain unchanged, with the exception of those which are redefined by the recalled item. *Recall item m (code) Read in item #m (where m can be in the range 1 th rough 25) from the currently open external storage file. Code is optional for documentation purposes only and is ignored by AID; however, code, if used, cannot exceed five characters in length. EXAMPLE *Recall item 23 Done. * The contents of item 23 of the currently open file are read into immediate storage. Successful execution sf the RECALL command is evidenced by the AID response, DONE.. DIAGNOSTIC MESSAGES I CAN'T FIND THE REQUIRED ITEM. The specified item cannot be found in the currently open file. Either the wrong file is open, the item number is incorrect, or the item was never filed. ITEM NUMBER MUST BE POSITIVE INTEGER <=25. An invalid item number was given. PLEASE LIMIT ID'S TO 5 LETTERS AND/OR DIGITS. Code exceeds five characters in length. YOU HAVEN'T TOLD ME WHAT FILE TO USE. ARECA LL command was attempted before an external storage file was opened via a USE command. 4-65 5.16 DESCRIPTION 1 Resets TIMER to zero. Reset timer TIMER is a counter used by AID to keep track of the amount of central processor time spent by the user in running AID. This cumulative running time can be obtained ot any point by typing the request Type timer •• Each time the user wishes to reset the timer and to begin timing a new operation, he types Reset timer •• lThe least significant digit of TIMER is freguently used to supplypseudo-random decimal numbers. / 4-66 5.17 ~ET DESCRIPTION SET defines an identifier as equivalent to a fixed value. This value is calculated once and the result is then used whenever the identifier appears in a calculation. If an expression, the expression must be immediately reducible to a numeric val ue. *Set x = expression or value NOTE When the SET command is typed as a direct command, the verb (SET) may be omitted. This form is cafled a short SET command. a) *Set ci = 20 t> b) *a = 20~ c) *Set a = sqrt(20)+43.5~2 d) *Set d = true e) *f = false ,J EXAMPLES A more complete discussion of the use of SET commands, including additional examples, can be found in Chapter 3. 4-67 5.18 OESCRI PTION The STOP command temporari Iy halts the current process at the point where the STOP com. mand appears and returns control to the user. The stopped process can be resumed by typing GO. If the user does not desire to continue the process, he types CANCE L. The STOP command can be given indir~ctly only. Stop (unconditional) Normally used only as a temporary step (during the testing of a routine) when performing a partial execution. Stop if •••• (conditional) Used to temporarily halt execution and return control to the user when certain condi tions (specified in the IF clause) are met. EXAMPLE tJ. *Let B=16-C *Let A=3. 17568/B *1.1 Stop if 8=0 C> *1.2 Type A, B, C in form 1 *Form tJ. I:J STOP command prevents attempt to divide by 0 in formula A. t3 * ~~;t'1'f~~'C~~4(4)24 .jj.......... . *00 1.58784000..01 1.98480000..01 2.64640000-01 3.96960000-01 7.93920000-01 Stopped b¥ step 1. 1 *Type C t> C = *Type B ~ B= 2.00000000 I. 60000000 1.20000000 8.00000000 4.00000000 01 01 01 00 00 16 0 * '.I ............. -6 -4.00000000 00 o 4.00000000 00 8.00000000 00 1.2000000001 II 5.19 TO DESCRIPTION TO discontinues the sequential execution of the part currently being executed and transfers control to another step or part. When the new part is finished, the direct command which initiated the execution is satisfied. The TO command can be given indirectly only. {:t:; To :.n } EXAMPLE *1.1 Demand G ~ *1.2 Demand T ~ *1.3 To part 2 if T>=560 ~ *1.4 Let d = G*.046 ~ *1.5 To part 3 if (T+d»560 ~ *1.6 Type "DEDUCTIONS" p *1 • 7 Type d, d+ TI'" ,'" t> *2.1 Type "NO DEDUCTION REQUIRED" *2 • 2 Let d = 0 *2.3 To step 1.6 ~ .1 *3. 1 Let d = 560 - T p *3.2 To step 1.6 ~ *Do part I, 4 times. .l G = *125.00p. T = *340.00 DEDUCTIONS 5.75 d = d+T = 345.75 t> tl G T DEDUCTIONS d d+T G T DEDUCTIONS d d+T = *350.00 == *545.00 ~ ~ 15 560 = = = *103.45 ~ = *559.04 tl = = G = *300.00~ T = *565.00 ~ NO DEDUCTION REQUIRED DE DUCTI ONSd = d+T = .96 560 o 565 * 4-99 Demand gross pay for week. Demand total FICA year-to-date. $560 = maximum deduction/year. d = current deduction. tJ -. ~iAGN~Y~' MES"S~ES .;.,,.,,::'I··:'·;:;·<·'i·tfCfi:l~t-E THIS COMM.AND DIRECTlY. t :.. ? The TO command must (Ilnly be given indirectly (preceded by a step number), .,1 5.20 DESCRIPTION Types out the specified information on the user's console. -n s - where n is numeric value or expression f where p is a proposition where s is a subscripted var"iable s(a,b, •• ) .. "any text" form m Type ste~ .. represents a null item (a blank field when typing in form x, or a blank line) m.n part m formula f f(n, ... ) function of (n, ••• ) &> function (tv) of a proposition all ste~s all ~arts all formulas all forms all values all time current time of day in min~tes since midnight timer processor ti me used (see RESET TIME R) size amount of immediate storage being used item-list users Combi ned TYPE Commands item list of currently open external storage file always returns an answer of 0 .. Several individual TYPE commands (except for TYPE "any text" or TYPE ITEM-LIST) can be combined into one command. *Type all parts, 1243, formula 0, form 5 Each entry, however, is still typed on a separate line. IN FORM Option Output edi ting can be performed by appendi ng the IN FORM ••• opti on to a TYPE command. See "FORM". Note that only certain types of entries can be typed in forms. 4-71 EXAMPLE *b = 20~ *c = 30~ *d = 111. 333 Variables P *Let a(b,c) = (b~2)*(c~2) ,*Let f(b) = b/2 P p User functions Subscripted variables *e(l) = 16" *e(2) = 25~ *e(3) = 35~ *Let 9 = h.}or i and j *h = true Po *i = falseq *j = false p p Propos i ti ons P *Let k = b*c*d .*Let m = k/2*sqrt(k) ~ Formulas *Form I:P * *Form 2:P * POUNDS *1.1 *1.2 *1.3 *2.1 *2.2 Forms OUNCES~ POUNDS IS OUNCES Type b,c ~ Type d,e t:l To part 2 " Type form 2 f) Type d/e(1), d in form 1 ~ Parts and steps *3.1 Type k, m f) *3.2 Type a(e(l ),e(2» " *Do part 1 tJ b = 20 c = 30 d = 111. 333 e(l) = 16 e(2) = 25 '35 e(3) = POUNDS' OUNCES 6.95800 POUNDS IS 1.113 02 OUNCES A command to type the values of a *Type e " e(l) = subscripted letter results in typeouts 16 e(2) = of all values. 25 " e(3) = 35 *Type 0(3,6) p 324 0(3,6) = *Type a t> o(b,c): (b,2)*(c'2) *iype 9 " 9 = ~ue *Type tv(g) " . tv(g) = *Type form 1 J) ......... POUNDS IS ......... OUNCES *Type step 1.3 t3 1.3 To part 2. *Type formula k " ' k: b*c*d *Type all steps " 4-72 1.1 Type b,e. 1.2 Type d,e. 1.3 To port 2. 2.1 Type form 2. 2.2 Type d/e(1), d in form 1. 3.1 Type k,m. 3.2 Type a(e(1 ),e(2}). *Type all formulas C> a(b,e): (b'2)*(e~2) 9: h or i and i k: b*e*d m: k/2*sqrt(k) *Type all forms 6 Form 1: POUNDS IS .•••••••• OUNCES Form 2: POUNDS OUNCES *Type all values ~ b= 20 e = 30 d = 111.333 h= true i = false false : 16 e(2) = 25 e(3) = 35 *Type all 1.1 Type D,e. 1.2 Type d,e. 1.3 To part 2. 2.1 Type form 2. 2.2 Type d/e(1), d in form 1. 3.1 Type k,m. 3.2 Type a(e(1 ),e(2». Form 1: OUNCES POUNDS IS Form 2: POUNDS OUNCES a(b, e): (b~2)*(e ~2) 9: h or i and i k: b*e*d m: k/2*sqrt(k) b = 20 30 e = d = 111.333 true h = i = false false : 16 e(2) = 25 e(3) = 35 *Type time 24-hour time time: 1453 e(1~ t> e(1~ 4-73 / *Type timer ~ timer The total central processor time uti lized by the user thus for. . , = mm ss.ss mm = minutes = seconds to the nearest hundredth 55.55 *Type size rJ size: 64 *Use file 110 (DSK) ~ . Roger. . *File all formulas as item 1 (FMULA) }; Done. *File all forms as item 2 (FORM) ~ Done. 1 *File all values as item 3 (VALUE) I> Done. *File all steps as item 10 (STEP) ~ Done. *Type item-list }; ITEM-LIST ITEM DATE 1 mm/dd/yy 2 mm/dd/yy 3 mm/dd/yy 10 mm/dd/yy * • 4-74 The number of "cells" of immediate storage currently occupied by the user's work area. In a 13K environment, approximately 1900 such "cells" are avaitable for this purpose. \ DATE is the creation date. 5.21 USE DESCRIPTION USE makes an external storage file 1 available for use. The external file thus addressed remains open for use until another USE command is given or until the AID program is terminated. USE file filename (device) where filename is a positive integer-, greater than 0 and less than or equal to 2750, which identifies the particular file on the device. device is the device name (logical or physical) of the device containing the file. Device can be one of the following. DSK disk OTAn OECtape, where n is the drive number and can be in the range 0 through 7. or any logical device name assigned to either of the above device types. If device is omitted, DSK is assumed. Mag- netic tape may also be used, provided the user positions the the tape directly before the desired file before issuing a RECALL or FILE command; the TYPE ITEM-LIST and DISCARD commands have no meaning for magnetic tape. Once a file has been opened by a USE command, all DISCARD, FILE, RECALL, and TYPE ITEM- LI ST commands are assumed to refer to that file. EXAMPLE *Ose file 103 (OSK) ~ (or Use file 103) Roger.~ * Makes file 103, on disk, avai lable for use. Successful execution of the command is evidenced by the AID response ROGER. DIAGNOSTIC MESSAGES FI LE NUMBER MUST BE POSITIVE INTEGER <= 2750. Filename is less than 0 or greater than 2750. 1 External storage files created by AID are in a special AID (8-bit) character format, Dot ASCII. 4-75 APPENDIX A TABLES This appendix contains five tables: A-I A Glossary of AID Terms A-2A AID Command Summary A-2B File Command Subset A-3 AID Character Set A-4 AID Diagnostic Messages 4-77 Table A-I. A Glossary of AID Terms + Indicates a blank field, when typed in conjunction with a FORMi otherwise, \ a blank line. $ A spe~ial symbol which refers to the line counter kept by ~ID. This symbol can be used in TYPE commands, or it can be tested within a conditional command to cause a line feed (LINE) or advance to next head of form (PAGE) at appropriate points. Conditional expression A series of clauses separated by semicolons, with each clause made up of a proposition followed by a colon and then by an expression. The entire conditional expression must be enclosed in parentheses or brackets. External storage See "File". Expression An arithmetic formula, Boolean proposition, or function. File A peripheral storage medium (usually disk or DECtape) used for the preservation of user subroutines, values, etc. Files are manipulated by the DISCARD, FILE, and RECALL commands. Form A user-specified format for editing output via the TYPE command. Formula An arithmetic expression defined by the user via the LET command. Function An arithmetic or Boolean function providecl by AID (see Table 4-2) or defined by the user via the LET command. Identifier A single alphabetic character associated with a variable (via the LET or SET commands) and then used to access the current value of the variable. Immediate storage Core storage work area. In a 13K environment, approximately 4K of core is available to the user for his steps, values, tables, etc. Item-list The file directory associated with an external storage file. The user can obtain a listing of the directory of the currently open file by typing the command TYPE ITEM-LIST. Part A series of indirect steps, the step numbers of which have the same integral value. SIZE A noun which can be specified in a TYPE command to obtain a typeout of the amount of core "cells" used. (1 ce II .= approx. 2 core words) 4-78 Table A-l (Cont) A Glossary of AID Terms Step Anyone -line command typed by the user. A step can be direct (executed immediately), in which cose no step number precedes it, or indirect (to be executed later), in which case it is preceded by a step number. TIME A noun which can be specified in a TYPE command to obtain a typeout of the time of day (in 24-hour format). r TIMER A noun which can be specified in a TYPE command to obtain a typeout of the amount of central processor time spent thus for by the user during the current AID run. Variable An element defined by ei ther the LET or SET commands which is associated with some value. It is referred to by an associated tag called an identifier. 4-79 Table A-2A AID Command Summary Command Format Type Description CANCEL 0,0 Cancels a currently stopped process when the user does not desire to resume execution. (CANCEL) 0,0 Cancels a currently stopped process which was initiated by a parerithetical DO. • ° Erases the specified item from immediate storage and frees the space occupied by it for some other use. l S DE LETE S(m,n) form m stepm.n part m formula f a II steps all parts all formulas all forms all values all j SCm, n) l. DEMAND l as "any text" SCm, n) as "any text" l DISCARD ITEM m(code). DO step m.n step m .n, p times step m.n for l=range part m partm, p times port m for L=range Several DELETE commands can be combined into one. 1,0 Causes AID to type out a message requesting the user to supply a value for the specified item. Only one variable can be specified in each DEMAND command. F Deletes item 1m from the external storage fi I~ currently in use. (Code) is optional. o (DO .... same as above .• ) DONE Executes an indirect step or part. If the DO command is a direct step, control r~turns to the user at . the completion of the DO; if an indi rect step, control returns to the step following the DO. Initiates a new execution without cancelling the currently stopped process. 1,0 Skips execution of the remaining steps of ~ part during the current iteration. 4-80 Table A-2A (Cont) AI D Command Summary Command Format FILE l S S(m,n} form m step m.n part m formula f a II steps all parts a II formu las all forms all values all AS ITEM n (code) F 0 FORM m: •••••••• • ++++ Description Type Text Stores the specified item in the external storage fi Ie currently open. Immediate storage is not affected in any way. (code) is optional. Defines a format to be used in editing typeouts for purposes of readabi Ii ty . fixed point notation (up to nine digit positions plus the decimal point) +++++e++++ ........................ scientific notation (minimum of seven positions maximum of fourteen) text any text to be included in the line; not enc losed in quotation marks unless they are port of the text. . QQ.. D,O Continues execution of a currently stopped process; opposi te of the CANCE l command. -IF Clause M Can be appended to any command (except the abbreviated-5ET command) to make the command conditional; the command is executed only if the proposition is true. Verb .... IF proposition. -LET rm 1 l = formula F(l) = m F(l} = proposition LET S be sporse . 0 Defines arithmetic formulas, Boolean expressions (propositions), and user functions and associates them with identifiers. The formula, expression, or function with which an identifier is associated is re-evaluated each time the identifier appears during an execution. S Sets undefined array elements to zero. 4-81 Table A-2A (Cont) AI D Comman~ Summary Command Format Type Description LINE 0 Advances the Te letype paper form one line. PAGE --- 0 Advances the Teletype paper form to the top of the next page. QUIT 0 Skips execution of the remaining steps of !J part and satisfies the DO command for that part by cance IIi ng any further i terati ons. Usua IIy given conditionay. RECALL ITEM m (code) F RESET TIMER S Resets TIMER to zero. 0 Defines an identifier as equivalent to a fixed value, which is calculated once and thenused whenever the identifier appears. A short form of the SET command, where the word SET is omitted, can be used if the command is direct. 1,0 Temporari Iy halts the current process at the point where the STOP command appears and returns control to the user. The stopped process con be resumed by typing GO. 1,0 Discontinues the sequentia I execution of the part currently being executed and transfers control to another step or part; when the new part is finished, the direct command which initiated the execution is satisfied. ' SET r~ L=proposition s(m, n) =m S(m, n )=proposition STOP -- 1 - TO {"",.m stepm.n 1 - Reads 'an item, previously stored by a FI LE command, from the currently open external storage file into immediate storag'e. (Code) is optional and is for documentation on Iy. .~ , 4-82 . Table A-2A (Cont) AI D Command Summary Command Format m Description Type o S S(m,n} proposition "any text" Types out the specified information on the user's console. Several individual TYPE commands may be combined into one (except for TYPE "any text" or TYPE ITEM-LIST). + TYPE form m step m.n part m formula f F(x} F(proposition} a II steps all ports all formulas all forms all values all time timer size item-list USE FILE filename (device) The command Type in form n causes the listed items to be typed out in the format specified by form n. n can be a numeric value (for example, form 3) or it can be a numeric formula (for example, form (2*x-y». S I- S S F F Makes an external.storage fi Ie avai lable for use. The externa I fi Ie thus addressed remains open for use (by DISCARD, FI LE, RECALL, and TYPE ITEM-LIST commands) until another USE command is given or the AI D program is terminated. Command Format Symbology L = letter S = subscripted letter. m, n, p = numeric values. f = formula. F = function. range =an i nterati ve sequence or series of va lues. Type Symbology D = Can be given directly only I = Can be given indirectly only. 0= Operational command. F = Fi Ie command. S = Special command. 4-83 Command Format D1SCARD ITEM m ~code) ""L S S{m,n,} form m step m.n part m FILE< formula f all steps all parts all formulas all forms all values .....all Table A-2B Fil e Command Subset Section Reference ", Description 5.4 Deletes item 1m from the external storage file currently in use. (Code) is optional. 5.7 Stores the specified item in the external storage file currently open. Immediate storage is not affected in any way. (Code) is optional. .... AS ITEM n {code} RECALL ITEM m (code) ~ 5.15 , Reads item 11m, previously stored by a FI LE command' from the currently open external storage file into immediate storage. (Code) is optional and is for documentation only • . il! TYPE ITEM-LIST 5.20 Obtains a typeout of the directory of the currentlyopen external sJorage file. USE FILE filename (device) 5.21 Makes an external storage fi Ie available for use. lhe external storage file thus addressed remains open for use (by DISCARD, FILE, RECALL, and TYPE ITEM-LIST commands) until another USE command is given or the AID program is terminat.ed • , 4-84 Table A-3 AID Character Set Typing Method Standard Math Symbol AID Symbol JOSS Symbol Model 37 Models 33 and 35 A through Z Strike appropri ate key with SHIFT. Strike appropriate key; no SHIFT. A through Z a through z Strike appropriate key wi thout SHIFT. Not avai lable; use upper-case letters. a through z 0,1 through 9 Strike appropriate key; no SHIFT. Strike appropri ate key; no SHIFT. 0, 1 through 9 I I (absolute) I I Strike the I, 1 key with SHIFT. Strike the I, 1 key with SHIFT. I I [ ] (brackets) [ J Strike appropri ate keys. [ Strike K with SHIFT 1 Strike M with SHIFT [ J ( ) (parentheses) ( ) ( Strike the ca ( key wi th SHI FT. ) Strike the ),9 key with SHIFT. ) Operators: ( Strike the (,a key with SHIFT • ) Strike the), 9 key with SHIFT . x e (exponent) x~e Strike the "', /\ key; no SHIFT • Strike the ~ , N key with SH 1FT . I I Strike the.? ,I key; no SHIFT . Strike the?,/ key; no SHI FT. • (mul tipl ication) * Strike the *,: key with SHIFT . Strike the *,: key with SHIFT. + (addition) + Strike the +,; key with SHIFT . Stri ke the +,; key with SHIFT. + - Strike the =,key; no SHIFT. Strike the =,key; no SHI FT. - = (equal) = Strike the =,key with SHIFT . Strike the =,key with SHIFT. = /' (not equa I) # Strike the # ,3 key with SHIFt. Strike the #,3 key with SHIFT. /' (divide) • - (subtraction) Boolean Expressions: 4-85 - * I . Notes Table A-3 (Cont) AID Character Set Typing Method Standard Moth Symbol < (equal - than) to or less . > (equal to or - greater than) AID Symbol JOSS Symbol Model 37 Models 33 and 35 (2 characters) Strike the <, < key; then strike the=, -key with SHIFT. Strike the<, .key with SHIFT; then strike the =,-key with SHIFT. -< > = (2 characters) Strike the >, > key; then strike the =,-key with SHIFT. Strike the>,. key with SHIFT; then strike the =,- key with SHIFT. -> RUBOUT (types back as deleted characters between \. Strike DELETE key to erose each preceding character in error; then type correctly. Strike RUBOUT key to erase each preceding character in error; then type correctly. BACKSPACE and type over < => '" Example: TPE\EP\ YPE PART 1. null item -+- Strike the , key with orwithout SHIFT • Strike 0 key with SHIFT. - $ (current line number) Strike the $,4 key with SHIFT. Strike the $,4 key with SHIFT. $ * (cancel entire line) Strike the * ,: key with SHIFT. Strike the *,: key with SHIFT. * (underscore) " , ... 4-86 Notes Used to correct typing errors. Table A-4 AID Diagnostic Messages Meaning Message x = ??? A value has not been supplied by the user for variable x. DONE. Signals completion of a File command (DISCARD, FI LE, RECALL). / DONE. "M READY TO GO iJiOM} STEP m.n . •• • AT STEP m.n .•• Task was suspended by an interruption or error during the interpretation of an indirect step • •• • FROM STEP m.n ••• Task was suspended by a stopping command • •• • IN STEP m.n ••• Task was suspended during an indirectly initiated DO command. AID resumes execution whenever the user types Go. DONE. "M READY TO GO ~iOM} Same as above, except that the step at which AID is prepared to resume can no longer be found in i mmed i ate storage. Possibl y, a di rec t command (or a routine initiated by a parenthetical DO) has deleted the step in the interim. Upon receipt of a GO command from the user, AID will attempt to resume at the step following the missing step. STEP m.n, ALTHO I CAN'T FIND IT. DON'T GIVE THIS COMMAND { DIRECTLY} INDIRECTLY EH? This command can be given only indire~tly (TO, DONE, STOP, DEMAND) or only directly (CANCEL, GO). The previously entered line is incorrect. Indirect commands: The step number was incorrectly typed. Direct LET commands: LET x portion is incorrect. Other direct commands: A space was omitted. The terminating period was omitted. The command is not legitimate. An expression is incorrectly written. To continue, retype the command correctly. 4-87 Table A-4 (Cont) AID Diagnostic Messages Meaning Message ERROR AT STEP m.n: The step number is correct, but the command is incorrect. EH? a. Request a typeout of the step in error. b .• Check for the errors listed under "Eh ?". c. Retype the command correctly. d. Type GO. to continue. The step in error refers to a nonexistent step or part. ERROR AT STEP m.n: I CAN'T FIND THE REQUIRED {~[5:M Correct the error and type GO. to cOl')tinue •. }. PART FORMULA The variable z has not been assigned a value by the user. ERROR AT STEP m.n: (IN FORMULA x): z = ??? ERROR IN FORMULA x: Check for any other errors, define variable z correctly, and type GO. to continue. (Fo"owing a direct command in which x was used) The form of the expression for x is in error. EH? a. Request a typeout of formula x. b. Check for the errors listed under "Eh?". c. Formula x m~y be correctly written, but the definition of one or more identifiers is not consistent with their use in formcrla x. FILE NUMBER MUST BE POSITIVE INTEGER <=2750. The fi lename of a USE command must not be greater than the value 2750. FORM NUMBER MUST BE INTEGER AND 1 <= FO RM < lOt 9. Form numbers must be integers in the range 1 through 109- 1• I CAN'T EXPRESS THE VALUE IN YOUR FORM. A value cannot be expressed in the format specified by the FORM (e.g., the value is too large to specify in fixed point notation). To correct, follow the steps given under "I HAVE TOO MANY VALUES FOR THE FORM." I CAN'T FIND THE REQUIRED { FORM} ITEM • PART STEP Either the element has never been defined or has been deleted. 4-88 '. Table A-4 (Cont) AID Diagnostic Messages Message Meaning I CAN'T MAKE OUT YOUR FIELDS IN THE FORM. The fields in the form specified were typed in such a way that AID cannot distinguish their beginning or ending. Possibly, there are either no fields in the form or two or more are run together with no intervening space. I HAVE AN ARGUMENT <=0 FOR LOG. The argument for the LOG function must be greater than o. I HAVE A NEGATIVE ARGUMENT FOR SQRT. Square root arguments must be positive. I HAVE A NEGATIVE BASE TO A FRACTIONAL POWER. An attempt was made to raise a negative value to a fractional power. For example, Type (-y)t(1/2). I HAVE AN OVERFLOW. Some number has exceeded 9.99999999. 10t99 in magnitude. I HAVE A ZERO DIVISOR. An attempt was made to divide by O. I HAVE NOTHING TO DO. The user has typed GO., but there is no currently stopped process which can be continued. I HAVE TOO FEW VALUES. An insufficient number of arguments have been supplied for a function. I HAVE TOO MANY VALUES FOR THE FORM. There are not enough fields in the form to receive all the values to be typed. a. Type the form and the values. b. Check for errors. c. Change either the TYPE command or the FORM to make them compatible and then type GO. to continue. I HAVE ZERO TO A NEGATIVE POWER. An attempt was made to rai se 0 to a negative power. IlLEpAL SET OF VALUES FOR ITERATION. An error has been detected in a range clause of a function or a DO command, such that the ending value can never be reached (e.g., the increment is 0). I'M AT STEP m.n. When the user responds to a DEMAND-produced request (x=*)with a carriage return only, AID types back this message. 4-89 Table A-4 (Cont) AI D Diagnostic Messages Message Meaning INDEX VALUE MUST BE INTEGER AND ! INDEX! <250 All index value.s (subscripts) must be integral and must have an absolute value of <250. I NEED INDIVIDUAL VALUES FOR A FORM. A command was given to type a subscripted variable in a form (e.g., Type B in form 1, where B is a subscripted variable). Individual values only can be specified for TYPE .... IN FORM n. commands. I RAN OUT OF SPACE. User's immediate memory is filled due to one of the following errors .. a. Endless loops because of DO commands or because DO was typed instead of TO. b. Unlimited recursive definition. c. Variable x defined in terms of y, and variable y defined in terms of x via LET command. d. Program is too large for avai lable memory; use TYPE SIZE command to determine how much immediate storage has been used. File commands can be used to store parts of the routine and execute them one at a time. I RAN OUT OF FILE SPACE. DECtape directory is full (limit = 22 items). ITEM NUMBER MUST BE <= 25. The item number in fi Ie commands (DISCARD, FI LE, RECALL) must be less than or equal to 25. NUMBER-OF- TIMES MUST BE INTEGER AND >= O. The value specified in the TIMES clause of a DO command must be a positive integer. PART NUMBER MUST BE INTEGER AND 1 <=PART<10~9. Part numbers must be integers and in the range 1 through 109-1. PLEASE DELETE THE ITEM OR USE A NEW ITEM NUMBER. The user has attempted to FI LE information into an item which already exists on the currently open external storage file. The user must either DISCARD the item prior to filing the new information or use a di fferent item number in the FI LE command • .. PtEASEKEEP !X!<100 FOR SIN(X) AND COS(X). Arguments for the SINE and COSINE functions must be less than 100. PLEASE LIMIT ID'S TO 5 LETTERS AND/OR DIGITS. Filename in a USE file command or code in a DISCARD, FILE, or RECALL command exceeds five characters in length or contains special characters. 4-90 Table A-4 (Cont) AID Diagnostic Messages M.essage Meaning PLEASE LIMIT LINES TO 78 UNITS (CHECK MARGIN STOPS) SAY AGAIN: User typeins are limited to singleline, 78 -character strings. PLEASE LIMIT NUMBERS TO 9 SIGNIFICANT DIGITS. Numeric values are limited to nine significant digits. PLEASE LIMIT NUMBER OF INDICES TO 10. The number of subscripts following an identifier cannot exceed 10. PLEASE LIMIT NUMBER OF PARAMETERS TO TEN. The number of arguments for a function is limited to 10. PLEASE LIMIT STEP LABELS TO 9 SIGNIFICANT DIGITS. Step numbers can be up to nine di gits in length. REVOKED. I RAN OUT OF SPACE. See "I RAN OUT OF SPACE.II ROGER. Signals successful completion of a USE file command. SOMETHING'S WRONG. I CAN'T ACCESS THE FILES. A system I/O error (or other type of AID error) has occurred. Begin again. SOMETHING'S WRONG. TRY AGAIN. AID has found something unusual in its internal records or has received contradictory signals from its I/O routine. Begin again. SORRY. SAY AGAIN: A transmission error occurred on the previous typein. This message is preceded by the erroneous line with # symbols typed where the failure occurred. Retype the line. . STEP NUMBER MUST SATISFY 1<= STEP< 10t9. Step numbers must be in the range 1 through 109-1. STOPPED BY STEP m.n. Process has been temporarily halted by a STOP command at step m. n • YOU HAVEN'T TOLD ME WHAT FILE TO USE. The user has issued a DISCARD, FILE, RECALL, or TYPE ITEM-LIST command before he has given a USE file command. 4-91 Book 5 Programming In FORTRAN . • • CONTENTS Page CHAPTER 1 INTRODUCTION TO THE FORTRAN LANGUAGE 1.1 Line Format 5-15 1. 1.1 Statement Number Field 5-15 1.1.2 Line Continuation Field 5-15 1.1.3 Statement Reid 5-16 1.1.4 Comment Li ne 5-16 1.2 Character Set 5-17 CHAPTER 2 CONSTANTS, VARIABLES, AND EXPRESSIONS 2.1 Constants 5-19 2.1.1 Integer Constants 5-19 2.1.2 Real Constants 5-19 2.1.3 Double Precision Constants 5-20 2.1.4 Octal Constants 5-20 2.1.5 Complex Constants 5-20 2.1.6 Logical Constants 5-21 2.1.7 Literal Constants 5-21 2.2 Variables 5-22 2.2.1 Scalar Variables 5-22 2.2.2 Array Variables 5-22 2.3 Expressions 5-24 2.3.1 Numeric Expressions 5-24 2.3.2 Logical Expressions 5-26 CHAPTER 3 3.1 THE. ARITHMETIC STATEMENT General Description 5-29 . CHAPTER 4 CONTROL STATEMENTS .c1;.1 GO TO Statement 5-31 4.1.1 Unconditional GO TO Statements 5-31 4.1.2 Computer GO TO Statements 5--31 4.1.3 Assigned GO TO Statement 5-32 4.2 IF Statement 5·-32 5-3 CONTENTS (COnt) Page 4.2.1 Numerical IF Statements 5-33 4.2.2 logical IF Statements 5-33 4.3 DO Statement 5-34 4.4 5-36' ,CONTINUE Statement 4.5 PAUSE Statement 5-36 4.6 STOP Statement 5-37 4.7 END Statement 5-37 CHAPTER 5 DATA TRANSMISSION STATEMENTS 5.1 Nonexecutable Statements 5-39 5.1.1 FORMA T Statement 5-39 5.1.2 NAMELIST'Statement 5-49 5.2 Data Transmission Statements 5-51 5.2.1 Input/Output Lists 5-52 5.2.2 Input/Output Records 5-53 5.2.3 PRINT Statement 5-53 5.2.4 PUNCH Statement 5-54 5.2.5 TYPE Statement 5-54 5.2.6 WRITE Statement 5-54 5.2.7 READ Statement 5-56 5.2.8 REREAD Statement 5-57 5.2.9 ACCEPT Statement 5-58 5.3 Device Control Statements 5-58 5.4 Encode and Decode Statements 5-59 .:t' "., ... ';,"', -.', . CHAPTE,R 6 SPECIFICA TIO N STATEMENTS 6.1 Storage Specification Statements 5-62 6.1.1 DIMENSION Statement 5-62 6.1.2 COMMON Statement 5-64 6.1.3 EQUIVALENCE Statement 5-65 6.1.4 EQUIVALENCE and COMMON 5-66 6.2 Data Specification Statements 5-66 6.2.1 DATA Statement 5-66·, 6.2.2 BLOCK DATA Statement 5-68 5-4 CONTENTS (Cont) 6.3 Type Declaration Statements Page 5-68 6.3.1 IMPLICIT Statement 5-68 CHAPTER 7 SUBPROGRAM STATEMENTS 7.1 Dummy Identi fi ers 5-71 7.2 7.3 Li brary Subprograms 5-71 Arithmetic Function Definition Statement 5-71 7.4 FUNCTION Subprograms 5-72 7.4.1 FUNCTION Statement 5-72 7.5 SUBROUTINE Subprograms. 5-74 7.5.1 SUBROUTINE Statement 5-74 7.5~2 CALL Statement 5-75 7.5.3 RETURN Statement 5-75 7.6 BLOCK DATA Subprograms 5-76 7.6.1 BLOCK DATA Statement 5-76 7.7 EXTERNAL Statement 5-76 7.8 Summary of PDP-l0 FORTRAN IV Statements 5-77 CHAPTER 8 LIB40 8.1 The FORTRAN Operating System 5-83 8.1.1 FORSE. 5-83 8.1.2 I/O Conversion Routines 5-84 8.1.3 , FORTRAN UUOs 5-85 8.2 Science Library and FORTRAN Utility Subprograms 5-86 8.2.1 FORTRAN IV Library Functions 5-86 8.2.2 FORTRAN IV Library Subroutines 5-90 CHAPTER 9 SUBPROGRAM CALLING SEQUENCES 9.1 Macro Subprograms Called by FORTRAN Main Programs 5-95 9.1.1 Calling Sequences 5-95 9.1.2 Returning of Answers 5-96 9.1.3 Use of Accumulators 5-96 9.1.4 Examples of Subprogram Linkage 5-96 5-5 Page . ' 9.2 Macro Main Programs Which Reference FORTRAN SubprOgrams 9.• 2.1 C~lIing 9.2.2 Returning of Answers 5-103 9.2.3 Exampl e of Subprogram li nkage 5-104 Sequences 5-103 5-103, CHAPTER 10 ACCUMULATOR CONVENTIONS FOR MAIN PROGRAMS AND SUBPROGRAMS 10.1 Locations 5-111 10.2 Accumulators 5-111 10.2.1 Accumulators 0 and 1 5-111 10.2.2 Accumulators 2 Through 15 5-112 10.2.3 Accumulators 16 and 17 5-112 10.3 UUOS 5-112 10.4 Subprograms Ca II ed by JSA 16, Address 5-112 10.5 Subprograms Called by PUSHJ 17, Address 5-112 10.6 Subprograms Called by UUOS 5-113 CHAPTER 11 SWITCHES AND DIAGNOSTICS 11.1 FORTRAN Switches and Diagnostics 5-115 CHAPTER 12 RELATED FEATURES OF THE PDP-l0 12.1 ASCII Character Set 5-125 12.2 PDP-10 Word Formats 5-126 12.3 FORTRAN Input/Output 5-127 12.3.1 Logical and Physical Peripheral Device Assignments 5-128 12.3.2 DEC tape and Disk Usage 5-128 12.3.3 Magnetic Tape Usage 5-130 12.4 PDP-l0 Instruction Set 5-132 APPENDIX A THE SMALL FORTRAN IV COMPILER 5-6 'f" ILLUSTRATIONS Page 1-1 Typical FORTRAN Coding Form 5-16 2-1 Array Storage 5-23 4-1 Nested DO Loops 5-35 TABLES 2-1 Types of Resultant Subexpressions 5-25 3-1 Allowed Assignment Statements 5-30 5-1 Magnitude of Internal Data 5-41 5-2 Numeric Field Codes 5-42 5-3 Device Control Statements 5-59 8-1 I/o Conversion 5-84 8-2 FORTRAN UUOs 5-85 8-3 FORTRAN IV l-ibrary Functions 5-87 8-4 FORTRAN IV Library Subroutines 5-90 10-1 Accumulator Conventions for PDP-10 FORTRAN IV Compiler and Subprograms 5-1~ 11-1 FORTRAN Compiler Switch Options 5-115 11-2 FORTRAN Compiler Diagnostics (Command Errors) 5-116 11-3 FORTRAN Compiler Diagnostics (Compilation Errors) 5-117 11-4 FORTRAN Operating System Diagnostics (Execution Errors) 5-120 1~-1 ASCII Character Set 5-125 12-2 PDP-10 FORTRAN IV Standard Peripheral Devices 5-127 12-3 Device Table for FORTRAN IV 5-129 Routine 5-7 f • PREFACE This is a reference manual describing the specific statements and features of the FORTRAN IV language for the PDP-10. It is written for the experienced FORTRAN programmer who is interested in writing and running FORTRAN IV pro- grams alone or in conjunction with MACRO-10 programs in the single-user or time-sharing environment. Familiarity with the basic concepts of FORTRAN programming on the part of the user is assumed. PDP-10 FORTRAN IV conforms to the requirements of the USA Standard FORTRAN. 5-9 I I I I I I I - I I I I I I I I I I I I I I I I I I I I I I I I I . INTRODUCTION TO THE FORTRAN IV SYSTEM The FORTRAN compiler translates source programs written in the FORTRAN IV language into the machine language of the PDP-10. This translated version of the FORTRAN program exists as a retrievable, relocatable binary file on some storage device. All relocatable binary filenames have the extension .REL if they reside on a directory-oriented device (disk or DECtape). Binary files may also be created by the MACRO-10 assembler (see Chapter 9) 1 • In order for the FORTRAN program to be processed, the Linking Loader must load the relocatable binary file into core memory. Also loaded are any relocatable pinary files found in the FORTRAN library (LIB40) which are necessary for the program's execution. Within the FORTRAN source program, the library files may ~e called explicitly, such as SIN, in the statement. x = SIN(Y) or implicitly, such as FLOUT. '- the floating-point to ASCII conversion routine, which is implied in the followi ng statements. 3 PRINT 3,X FORMAT(1X,F4.2) A FORTRAN main program and its FORTRAN and/or MACRO-10 subprograms may be compiled or assembled separatelyand then linked together by the Linking Loader at load time. The core image may then be saved on a storage device. When saved on a directory storage device, these files have the extension .SAV in a multiprogral'!lming Monitor system and • SVE in a single-user Monitor system. The Time-Sharing Monitors act as the interface between the user and the computer so that all users are protected from one another and appear to have system resources available to themselves. Several user programs are loaded into core at once and the Time-Sharing Monitors schedule each program to run for a certain length of time. All Monitors direct data flow between I/O devices and user programs, making the programs device independent, and overlap I/O operations concurrently with computations. In a multiprogramming system, all jobs reside in core and the scheduler decides which of these jobs should run. In a swapping system, jobs can exist on an external storage device (usually disk) as well as in core. The scheduler lFor further information on the MACRO-10assembler, see the MACRO-10ASSEMBLER manual, DEC-10-AMZA-D. 5-11 decides not only which ,job is to run but al~ when a job is to be swapped out onto the disk or brought back into core. The number of users that can be handled by a given size time-sharing configuration is further increased by using the reentrant user-programming capability. This means that a sequence of instructions may be entered by more than one user job at a time. Therefore, a single copy of a reentrant program may be shared by a number of users at the same time to increase system economy. The FORTRAN compiler and operating system are both reentrant. SECTION I The PDP-10 FORTRAN IV Language The seven chapters of this section deal with the PDP-10 FORTRAN IV language. Included in these chapters are the language elements of FORTRAN IV and the five categories of FORTRAN IV statements {arithmetic, control, input/output, specification, and subprogram}. CHAPTER 1 INTRODUCTION TO THE FORTRAN LANGUAGE The term FORTRAN IV (FORmula TRANslation) is used interchangeably to designate both the FORTRAN IV language and the FORTRAN IV translator or compiler. The FORTRAN IV language is composed of mathematicalform statements constructed in accordance with precisely formulated rules. FORTRAN IV programs consist of meaningful sequences of FORTRAN statements intended to direct the computer to perform the specified operations and computations. The FORTRAN IV compi ler is itself a computer program that examines FORTRAN IV statements and tells the computer how to translate the statements into machine language. The compiler runs in a minimum of 9K of core. The program written in FORTRAN IV language is called the source program. The resultant machine language program is called the object program. Digital's small FORTRAN compiler, which runs in 5.5K of core, is virtually identical to the larger compiler, except for differences explained in Appendix 2. Operating procedures and diagnostic messages for both compi lers are explained in the PDP-10 System Users Guide (DEC-10-NGCC-D). 1. 1 LINE FORMAT Each line of a FORTRAN program consists of three fields: statement number field, line continuation field, and statement field. A typical FORTRAN program is shown in Figure 1-1. 1. 1. 1 Statement Number Field A statement number consists of from one to five digits in columns 1-5. Leading zeros and all blanks in this field are ignored. Statement numbers may be in any order and must be unique. Any statement referenced by another statement must have a statement number. For source programs prepared on a teletypewriter, a horizontal tab may be used to skip to the statement field. This is the only place a tab is not treated as a space. 1. 1.2 Line Continuation Field If a FORTRAN statement is so large that it cannot conveniently fit into one statement field, the statement fields of up to 19 additional lines may be used to specify the complete statement. Any line which is not continued,. or the first line of a sequence of continued lines, must have a blank or zero in column 6. Continuation lines must 5-15 CODER I. r .."'O:-c"-:-'M---------'---'-'--~--ir:~. DATE FORTRAN COOINGFOItM CCofl".. e.,t ~ S.::~e~~ PAGE ~ , FORTRAN STATEMENT ~~ '. = IDEN'lfICATION ,.~, 1 2 J • ,5 6 7 8 9 10 II 12131.1.51617181920" 222314252627282930 31 J231 34353637383UO.'42'3,U"5.6.7.84.9 SO.51,52,5J.s.,55S6,57S159606162bJU6566W6869707112 137.,5761718791 THI S PR OGRAM CA-lC UlA.T~ ,S, ,P,R,I,"'lE, ,!::lY"'lB,E,R,S, ,F,R,9!:!1,I.J..- TO 50 , D,O 10 1:'11 50 2 J =1 4 J=,J,~ . A=,J. -.I.l.A 1.0 . ,,, 11.,=,1 [,J, , , , , ,,,,I I ,,I I ,,, 'B=A-l 10 1 F ,( B.l. 5 5 , I I I , , , , , I 1 F ( J .. l T • SQRT .( Fl.QA,T ,LI,),),), .GO TO 4 YPE 10.5 1 :.ONTI NUE 1 05 FQRM~T 5 ,(.J 4 . , 1 S PR IM,E ~ ',) 'NO +1 I ,, I , I , , , I , , I , , 1 I , , , 11 , , I I I , I I I , 1-+-++11 I I I +++++++++-1 1 2 1 4 .5 6 7" I ,, I I I I , I I -r-+-+-+-+-+- +-+-+-+-+I 1 11.1 I I I' , ,,,,,,,,,, I 1 1-1 1 I , " I 1111+++ JO 11 1213 1.,,16171'''20212223 ~2526212'29JOll32'13 U 113617l11940.14Z .. l ... 4' ....7 •••95C).51525JSoI55S6"!I5960.162.1 •• 6,56601616fTOTI '1ll7J'1."76n 7I1'9IC. DIGITAL EQUIPMENT CORPORATION Figure 1-1 • MAYNARD. MASSACHUSETTS 100 - 12/64 Typical FORTRAN Coding Form have a character other than blank or zero in column 6. If a continuation line is desired when a TAB is used in the statement number field, a digit from 1 to 9 must immediately follow the TAB . • 1.1.3, Statement Field Any FORTRAN statement, as described in later sections, may appear in the statement field (columns 7-72). Except for alphanumeric data within a FORMAT statement, DATA statement, or literal constant, blanks (spaces) and TABS are ignored and may be used freely for appearance purposes. 1• 1.4 Comment li ne Any line which starts with the letter C in column 1 is interpreted as a line of comments. Comment lines are printed onto any listings requested but are otherwise ignored by the compiler. Columns 2-72 may be used in any format for comment purposes. A comment line must not immediately precede a continuation line. 5-16 1.2 CHARACTER SET The following characters are used in the FORTRAN IV language: Blank 0 @ P A Q II 2 B R I/> 3 C S $ 4 D T % 5 E U & 6 F V 7 G W 8 H X 9 Y * J + K < L M / > N ? 0 NOTE ASCII characters greater than Z (1328 ) are replaced by the error character lit". See Chapter 12 for the internal representati on -Qf these characters. 5-17 Z .\ CHAPTER 2 CONSTANTS, VARIABLES, AND EXPRESSIONS The rules for defining constants and variables and for forming expressions are described in this chapter. 2.1 CONSTANTS Seven types of constants are permitted in a FORTRAN IV source program: integer or fixed point, .real or singleprecision floating point, double-precision floating point, octal, complex, logical, and literal. .. 2. 1. 1 Integer Constants An integer constant consists of from one to eleven decimal digits written without a decimal point. A negative. constant must be preceded by a minus sign. A positive constant may be preceded by a plus sign •• Examples: 3 +10 -528 8085 An integer constant must fall within the range _235+1 to 235 -1. When used for the value of a subscript an index in a DO statement, the value of the integer is taken as modulo 2 18 . 2. 1:2 01" as Rea I Constants Real constants are written as a string of decimal digits including a decimal point. A real constant may consist of any number of digits but only the leftmost 9 digits appear in the compiled program. Real constants may be given a decimal scale factor by appending an E followed by a signed integer constant. The field following the letter E must not be blank, but may be zero. Examples: 15. 0.0 .579 -10.794 5. OE3(i.e., 5000.) 5.0E+3{i .e., 5000) 5.0E-3{i.e., 0.005) 5-19 A real constant has precision to eight digits. The magnitude must lie'approXimately within the range -38 38 O. 14 x 10 to 1.7 x 10 • Rea I constants occupy one word of PDP-lO storage. 2.1.3 Double Precision Constants A double precision constant is specified by a string of decimal digits, including a decimal point, which are followed by the letter D and a signed decimal scale factor. The,field following th~ letter D must not be blank, but may be zero. Examples: 24.67132598213400 3.6D2 (i.e., 360.) 3.60-2 (i .e., .036) 3.000 Double precision constants have precision to 16 digits. The magnitude of a double precision constant must lie . -38 38 approximately between O. 14x 10 and 1.7 x 10 Double-precision constants occupy two words of PDP-10 storage. 2.1.4 Octal Constants .- A number preceded by a double quote represents an octal constant. An octal, constant may appear in an arithmetic or logical expression or a DATA statement. Only the digits 0-7 may be used and only the last twelve digits are significant. A minus sign may precede the octal number, in which case the number is negated. A maximum of 12 octal digits are stored in each 36-bit Examples: 2.1.5 word~ "7777 "-31563 Complex Constants . FORTRAN IV provides for direct operations on complex numbers. Complex constants are written as an ordered pair of real constants separated by a comma and enclosed in parentheses. Examples: (.70712, -.70712) (8 •763E3 ,2.297) The first constant of the pair represents the real part of the complex number I and the second constant represents the imaginary part. The real and imaginary parts may ~ach be signed. The enclosing parentheses are part of the constant and always appear, regardless of context. Each part is internally represented by one singleprecision floating point word. They occupy consecutive locations of PDP-10 storage. 5-20 Fo,RTRAN IV arithmetic operations on complex numbers, unlike normal arithmetic operations, must be of the form: A±B = a 1ib 1+i(a2 ib2) A*B = (albl-a2b2)+i(a2bl+alb2) (a 1b 1+a 2b 2 ) +i (a 2b 1-Ql b2) A/B= 2 2 2 2 b 1 +b2 b 1 +b2 where A 2.1.6 =a 1 + ia2 , B =b 1 + ib 2 , and i =J-]: Logical Constants The two logical constants, .TRUE. and .FALSE., have the internal values -1 and 0, respectively. The enclosing periods are part of the constant and always appear. Logical constants may be entered in DATA or input statements as signed octal integers (-1 and 0). Logical quantities may be operated on in either arithmetic or logical statements. Only the sign is tested to determine the truth value of a logical variable. 2.1.7 Literal Constants A literal constant may be in either of two forms: a. A string of alphanumeric and/or special characters enclosed in single quotes; two adjacent single quotes within the constant are treated as one single quote. b. A string of characters in the form nHx 1x 2 •• .x n where x 1x 2 .•• x n is the literal constant, and n is the number of characters following the H. Literal constants may be entered in OAT A statements or input statements as a string of up to 57-bit ASCII characters per variable (10 characters if the variable is double-precision or complex). Literal c~nstants may be operated on in either arithmetic or logical statements • • NOTE Literal constants used as subprogram arguments will have a zero word as an end-of-string indicator. 5-21 Exampl~s: 2.2 CALL SUB·('LITERAL CONSTANT i ) 'DONT"T' 5HDON'T A == 'FIVE' + 42 B == (5HABCDE .AND. "376)/2 VARIABLES A variable is a quantity whose value may change during the execution of a program. Variables are specified b.y name alphal'lumeric characters, the first one of . and type. The name of a variable consists of one or more . which must be alphabetic. Only the first six characters are interpreted as defining the variable name. The type of ,variable (integer, real, logical, double preciSIon, or complex) may be specified explicitly by a type declaration statement o~ implicitly by the IMPLICIT statement. If the variable is not specified in this manner, then a first letter of I, J, K, L, M or N indicates a fixed point (integer) variable; any other first letter indicates a floating-point (real) variable. Variables of any type may be either scalar or array variables. 2.2.1 Scalar Variables A scalar variable represents a single quantity. Examples: A G2 POPULATION 2.2.2 Array Variables An array variable represents a single element of an n dimensional array of quantities. The variable is denoted by. the array name followed by a subscript list enclosed in parentheses. The subscript list is a sequence of integer expressions, separated by commas. The expre"ssions may be of any form or type providing they are explicitly changed to type integer when each is completely evaluated. Each expression represents a subscript, and the values of the expressions determine the array element referred to. For example, the row vector A. would be " I represented by the subscripted variable A(J), and the element, in the second colu'mn of the first row of the square matrix A, would be represented by A(1,2). Arrays may have any number of dimensions. Examples: Y(l) STATION (K) A (3* K+2, I, J-1) . The three arrays above (Y, STATION, and A) would have to be dimensioned by a DIMENSION, COMMON, or type. declaration statement prior to their first appearance in an executable statement or in a DATA or NAMELISI statement. (Array dimensioning is discussed in Chapter 6). 5-22 l-Dimensional Array A(10) lAC II I A( 21 1A( 31 1A(4) I A(5) I A(61 1A( 71 1A(8) IA(9) I AClO) I CONSECUTIVE STORAGE LOCATIONS - - - - - - - - 2-Dimensional Array 8(5,5) I B(I,I) 6 B(I,2) II B(I,3) 16 B(I,4) 21 B(I,5) 2 B(2,1) 7 B(2,21 12 B(2,3) 17 B(2,4) 22 B(2,5) 3 B(3,1) 8 B(3,21 13 B(3,3) 18 B(3,41 23 B(3,5) 4 B(4,11 9 5 8(5,1) 10 8(5,21 15 8(5,31 20 B(5,41 21 B(5,51 8(4,21 14 8(4,31 19 8(4,4) 24 B(4,5) 8(3,1) IS THE THIRD STORAGE WORD IN SEQUENCE B(3,4) IS THE EIGHTEENTH STORAGE WORD IN SEQUENCE 3-Dimensional Array C(5,5,5) III C(I,3,5) 116 112 C(23,5) 117 96 C(l54) 118 76 CII 14) 81 97 C(2,5,4) 119 77 C(2,I,4) 82 C(3,5,4 ) 120 CII,I,3) 56 CO,2,3) 61 C(I,3,3) 66 C(I,4,3) 71 CO,5,31 98 c(2,I,3) 57 C(2,2,3) 62 C(2,3,3) 67 C(2,431 72 C(2,5,3I 99 C(4,5,4) CO,2,2) 36 CO,3,2) 41 C(I,4,2) 46 C(I,5,2) 73 C(3,5,3) 100 c(5.5,4) C(22 2) 37 C(2.3.2 ) 42 C(242) 47 C(2,5,2) 74 C(4,5,3) CII 3,1 I 16 C(l4 I ) 21 C05 I I 48 C(3,5,21 75 C(5,5,31 C(2,3,11 17 C(2,4,11 22 C(2,5,1) 49 C(4,5,2) C(3311 18 C(3411 23 C(3511 50 C(5,5,21 C(43 II 19 C(44 I) 24 C(~~II C(5,3,11 20 C(5,4,1) 25 C(5,5,11 101 102 CII,2,4) 86 C(2,2,4) 87 I 2 3 4 5 CO I I ) C(2,I,I) C(3,I,I) C(41 II C(5,I,11 26 27 6 7 8 9 10 C(t,I,2) C(2J.2) C(l2 I) C(2,2,11 C(3,2,11 C(4211 C(5,2,1) 51 52 31 32 II 12 13 14 15 C(I,I,5) 106 C( I .2,5) C(2,I,5) 107 C(2,2,5) C(I 34) 91 C(144) C(2,3,4) 92 C(2,4,4) C(I,4,5) C(2,4,5) C(3,4,5) C(4,45) C(5,4,5) 121 122 123 124 125 CII,5,5 ) C(2,5,5) C(3,5,5) C{4,5,5) C(5,5,5) C(1 ,3,2) is the 36th storage word in sequence. C(l, 1,5) is the 101st storage word in sequence. Figure 2-1 Array Storage 5-23 Arrays are stored in increasing storage locations with the first subscript varying most r.apidly and the lost subscript . varying least rapidly. For example,-the 2-dimensional array B(I,J) is stored in the following order: B (1,1), B (2,1), •.. , B (I, l),B (1,2),B (2,2), ..• ,B (1,2), .•. ,8 (I,J). 2.3 EXPRESSIONS Expressions may be either numeric or logical. To evaluate an expression, the object program performs the calculations specified by the quantities and operators within the expression. 2.3. 1 Numeric Expressions A numeric expression is a sequence of constants, variables, and function references separated by nu~eric operators and parentheses in accordance with mathematical convention and the rules given below. The numeric operators are +, -, *, I, **, denoting, respectively, addition, subtraction, multiplication, division, and exponentiation. In·addition to the basic numeric operators, function references are also provided to facilitate the evaluation of functions such as sine, cosine, and square root. A function is a subprogram which acts upon one or more quantities, called arguments, to produce a single quantity called, the function' value. Function references are denoted by the identifier, which names the function (such as SIN, COS, etc.), followed by an argument list enclosed in parentheses: identifier(argument, argument, ... , argument) At least one argument must be present. An argument may be an expression, an array identifier, a subprogram identifier, or an alphanumeric string. Function type is given by the type of the ic!e"ntifier which names the function. The type of the function is independent of the types of its arguments. (See Chapter 7, Section 7.4.1.1.) A numeric expression may consist of a single element (constant, variable, or function reference): 2.71828 Z(N) TAN(THETA) Compound numeri~ expressions may be formed by using numeric operations to combine basic elements: X+3. TOTAL/A TAN(PI*M) (X+3.) -(TOTAL/A) * TAN (PI*M) 5-24 Compound numeric expressions m~st be constructed according to the following rules: a. With respect to the numeric operators +, -, *, /, any type of quantity (logical, octal, integer, real, double precision, complex or literal) may be combined with any other, with one exception: a complex quantity cannot be combined with a double precision quantity. The resultant type of the combination of any two types may be found in Table 2-1. The conversions between data types will occur as follows: (1) A literal constant will be combined with any integer constant as an integer and with a real or double word as a real or double word quantity. (Double word refers to both double precision and complex.) (2) An integer quantity (constant, variable, or function reference) combined with a real or double word quantity results in an expression of the type real or double word respectively; e.g., an integer variable plus a complex variable will result in a complex subexpression. The integer is converted to floating point and then added to the real part of the complex number. The imaginary part is unchanged. (3) A real quantity (constant, variable, or function referenee) combined with a double word quantity results in an expression that is of the same type as the double word quantity. A logical or octal quantity is combined with an integer I real, or double word quantity as if it were an integer quantity in the integer case, or a real quantity in the real or double word case (i .e., no conversion takes place). (4) b. Any numeric expression may be enclosed in parentheses and considered to be a basic element. (X+y)/2 (ZETA) (COS(SIN(PI*M)+X» Table 2-1 , Types of Resultant Subexpressions Type of Quantity +,-,*,/ Type of Quantity Real Integer Complex Double Precision Logical, Octal, or Literal Real Real Real Complex Double Precision Real Integer Real Integer Complex Double Precision Integer Complex Complex Complex Complex Not Allowed Complex Double Precision Double Precision Double Precision Not Allowed Double Precision Double Precision Logical, Octal, ,or' Literal Real Integer Complex Double Precision -: Logical, Octal, or Literal .' ' 5-25 ,c. Numeric expressions whicli are preceded by-a + or - sign are alS? numeric expressions~ +X -(ALPHA *BET A) -SQRT( -GAMMA) d. If the precedence of numeric operations is not given explicitly by parentheses, it is understood to be the following (in order of decreasing precedence): Explanation Operator ** numeric exponentiation *and/ numeric multiplication and division +and- numeric addition and subtraction In the case of operations of equal hierarchy, the calculation is performed from left to right. e. No two numeric operators may appear in sequence. For i.nstance: x*-y is improper. Use of parentheses yields the correct form: x*(-y) By use of the foregoing rules, all permissible numeric expressions may be formed .. As an example of a typical numeric expression using num~ric operators and a function reference, the expression for one of the roots of the general quadratic equati on: would be coded as: (-B+SQRT(B**2-4. *A*C»/(2. *A) 2.3.2 Logical Expressions A logical expression consists of logical constants, logical variables, logical function references, and arithmetic expressions, separated by logical operators or relational operators. Logical expressions are provi~ed in FORTRAN IV to permit the implementation of various forms of symbolic logic. Logical constants are defined by arithmetic statements, which are described in Chapter 3. Logical variables and functions are defined by the LOGICAL statement, described in Chapter 6. Binary variables may be represe-nted by the logical constants -. . • TRUE. and .FALSE. , which must always be written with enclosing periods. Logical masks may be represented by using octal constants. The result of a logical expression has a logical value (i .e., either true or false) and therefore, only uses one word. 5-26 2·.3.2.1 Logical Operators - The logical operators, which include the enclosing periods and their definitions, are as follows,' where P and Q ':Ire logical expressions: . NOT. P Has the value. TRUE. only if P is . FALSE. , and has the value .FALSE. only if Pis .TRUE. P.AND.Q Has the value. TRUE. only if P and Q are both. TRUE. , and has the value .FALSE. if either P or Q is .FALSE. P.OR.Q (Inclusive OR) Has the value. TRUE. if either P or Q is . TRUE. , and has the value .FALSE. only if both P and Q are .FALSE. P.XOR.Q (Exclusive OR) Has the value. TRUE. if either P or Q but not both are . TRUE., and has the va lue . FALSE. otherwise. P.EQV.Q (Equivalence) Has the value. TRUE. if P and Q are both • TRUE. or both . FALSE. , and has the value . FALSE. otherwise. Logical operators may be used to form new variables, for examp Ie, x = Y.AND.Z E = E.XOR. "400000000000 2.3.2.2 Relational Operators - The relational operators are as follows: Operator Relation .GT. greater than .GE. greater than or equal to · LT. less than • LE. less than or equal to .EQ. equal to · NE. not equal to The enclosing periods are port of the operator and must be present. Mixed expressions involving integer, real, and double precision types may be combined with relationals. The value of such an expression will be . TRUE. or .FALSE.. The relational operators .EQ. and. NE. may also be used with COMPLEX expressions. (Double word quantities are equal if the corresponding parts are equal.) 5-27 A logical expression may consist of a single elemenf (constant, variable, function rererence, or relation):' - , .TRUE. X.GE.3.141S9 Single elements may be combined through use of logical operators to form compo~nd logical expressions, such as: TVAL. AND. INDEX BOOL(M). OR. K.EQ.LIMIT Any logical expression may be enclosed in parentheses and regarded as an element: (T .XOR.S).AND.(R.EQV.Q) CALL PARITY ((2.GT.Y .OR.X.GE. Y).AND. NEVER) Any logical expression may be preceded by the unary operator. NOT. as in: .NOT.T . NOT.X+7.GT.Y+Z BOOL(K).AND •. NOT. (TVAL.OR. R) No two logical operators may appear in sequence, except in the case where. NOT. appears as the second of two logical operators, as in the example above. Two decimal points may appear in sequence, as in the example above, or when one belongs to an operator and the other to a constant. When the precedence of operators is not given explicitly by parentheses, it is understood to be as follaws (in order of decreasing precedence): ** *,/ +,.GT. ,.GE. ,.U. ,. LE. ,.EQ. ,. NE. • NOT. .AND • • OR • . EQV., .XOR. For example, the logical expression .,NOT.ZETA**2+Y*MASS.GT.K-2. OR. PARITY .AND.X.EQ.Y is interpreted as (. NOT. (((ZET A**2)+(y*MASS». GT. (K-2))). OR. (PARITY .AND.(X .EQ. V)) 5-28 CHAPTER 3 THE ARITHMETIC STATEMENT 3.1 GENERAL DESCRIPTION One of the key features of FORTRAN IV is the ease with which arithmetic computations can be coded. Computations to be performed by FORTRAN IV tire indicated by arithmetic statements, which have the general form: A=B where A is a variable, B is an expression, and = is a replacement operator. The arithmetic statement causes the FORTRAN IV object program to evaluate the expression B and assign the resultant value to the variable A. Note that the = sign signifies replacement, not equality. Thus, expressions of the form: A=A+B and A=A*B are quite meaningful and indicate that the value of the variable A is to be replaced by the result of the expression to the right of the = sign. Examples: Y=l*Y P=. TRUE. X (N)=N*ZETA(ALPHA*M/PI)+(l.', -1.) Table 3-1 indicates which type of expression may be equated to each type of variable in an arithmetic statement. D indicates that the assignment is performed directly (no conversion of any sort is done); R indicates that only the real part of the variable is set to the value of the expression (the imaginary part is set to zero); C means that the expression is converted to the type of the variable; and H mea~s that only the high-order portion of evaluated expression is assigned to the variable. The expression value is made to agree in type with the assignment variable before replacement occurs. For example, in the statement: THET A=W*(ABET A+E) if THETA is an integer and the expression is real, the expression value is truncated to an integer before assignment to THETA. 5-29 Table, 3-1 Allowed Assignment Statements Expression Logical, Octal, or Literal Constant Real Integer Complex Double Precision Real D C R,D H,D D Ioteger C D R,C H,C D Complex D,R,I C, R',I D H,D,R,I D,R,I Double Precision D,H,L C,H,L R~D,H,L D D,H,L D R,D H,D Variable Logical D D - Direct Replacement C - Conversion between integer and floating point R - Real only - Set imaginary part to 0, H - ,High order only l - Set low order part to 0 • 5-30 D CHAPTER 4 CONTROL STATEMENTS FORTRAN compiled programs normally execute statements sequentially in the order in which they were presented to the compiler. However, the following control statements are avai lable to alter the normal sequence of statement execution: GO TO, IF, DO, PAUSE, STOP, END, CALL, RETURN. CALL and RETURN are used to enter and return from subroutines. 4. 1 GO TO STATEMENT The GO TO statement has three forms: unconditional, computed, and assigned. 4. 1. 1 Unconditional GO TO Statements Unconditional GO TO statements are of the form: GO TO n where n is the number of an executable statement. Control is transferred to the statement numbered n. An unconditional GO TO statement may appear anywhere in the source program, except as the terminal statement of a DO loop. 4. 1.2 Computed GO TO Statements Computed GO TO statements have the form: GO TO (n 1 ,n 2 , ... ,nk ),i where n 1,n 2 , ... ,n k are statement numbers, and i is an integer ~xpression. This statement transfers control to the statement numbered n l' n2 , .•. , nk if i has the value 1, 2, .•. , k, respectively. If i exceeds the size of the I ist of statement numbers or is less than one, execution wi II proceed to the next ~xecutable statement. Any number of statement numbers may appear in the list. There is no restriction on other uses for the integer variable i in the program. 5-31 In the example GO TO (20,10,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. A computed GO TO statement may appear anywhere in the source program, except as the terminal statement of a DO loop. 4. 1.3 Assigned GO TO Statement , Assigned GO TO statements have two equivalent forms: GOTO k and where k is a nonsubscripted integer variable a'nd n 1, n 2 , ... nk are statement numbers. Any number of statement numbers may appear in the list. Both forms of the assigned GO TO have the effect of transferring control to the statement whose number is currently associated with the vqriable k. This association is established th'rough the use of the ASSIGN statement, the general form of which is: ASSIGN i TO k If more than one ASSIGN statement refers to the same integer variable name, the value assigned by the last ex- ecuted statement is the current va lue. Examples: ASSIGN 21 TO INT ASSIGN 1000 TO INT GO TO INT GO TO INT, (2,21,1000,310) An assigned GO TO statement may appear anywhere in the source program, except as the terminal statement of a DO loop., 4,2 IF STATEMENT IF statements have two forms in FORTRAN IV: numerical and logical. 5-32 4.2.1 Numerical IF Statements Numerical IF statements are of the form: IF (expression) n 1,n 2 , n3 where n l' n2 , n3 are statement numbers. This statement transfers control to the statement numbered n l' n 2 , n3 if the value of the numeric expression is less than, equal to, or greater than zero, respectively. All three state .... ment numbers must be present. The expression may not be complex. Examples: 4.2.2 IF (ETA) 4,7,12. IF (KAPPA-L (10)) 20,14,14 Logical IF Statements Logical IF statements have the form: IF (expression)S where S is a complete statement. The expression must be logical. S may be any executable statement other than a DO statement or another logical IF statement (see Chapter 2, Section 2.3.2). If the value of the expression is .FALSE., control passes to the next sequential statement. If value of the expression is . TRUE., statement S is executed. After execution of 5, control passes to the next sequential statement unless S is a numerical IF statement or a GO TO statement; in these cases, control is transferred as indicated. If the expression is . TRUE. and S is a CALL statement, control is transferred to the next sequential statement upon return from the subroutine. Numbers are present in the logical expression: IF (B)Y=X*SIN(Z) W=Y**2 If the value of B is •TRUE., the statements Y=X*SIN(Z) and W=Y**2 are executed in that order. If the value of B is .FALSE." the statement Y=X*5IN(Z) is not executed. Examples: IF (T .OR.S)X=Y+1 IF (Z.GT.X(K)) CALL SWITCH (S,Y) IF (K .EQ.INDEX) GO TO 15 NOTE Care should be taken in testing floating point numbers for equality in IF statements as rounding may cause unexpected results. 5-33 4.3 Th~ DOSTATEMENT DO statement simplifies the cocltng of iterative procedures. DO statements are of the-form: . , where n is a statement number, i is a nonsubscripted integer variable, and m1,m 2,m 3 are any integer expressions. If m3 is not specified, it is understood to be 1. The DO statement causes the statements which follow, up to and including the statement numbered n, to be executed repeatedly. This group of statements is called the range of the DO statement. The integer variable i of the DO statement is called the index. The values of m1,m2 , and m3 are called, respectively, the initial, limit, and increment values of the index. A zero incremen! (m 3 ) is not allowed. The increment m3 may be negative if m1~m2'.. If m1~m2' the increment, m3 must be positive. The index variable can assume legal values only if (m2-mi)*m~O. (m i is the current valu~ , , of the index variable m1.) Examples: Form Restri cti on DO 101=1,5,2 DO 10 1=5, 1,-1 DO 10 I=J,K,5 J K DO 10L=I,J,-K I~J,K O DO 10 L=I,J,I< I~J,X>O or I~J,K>O Initially, the statements of the range are executed with the initial value assigned to the index. This initial execution is always performed, regardless of the values of the limit and increment. After each execution of the range, the increment value is added to the value of the index and the result is compared with the limit value. If the value of the index is not greater than the limit value, the range is executed again using the new value , of the index. When the increment value is ~egative, another execution will be performed if the new value of the index is not less than the limit value. After the last execution of the range, control passes to the statement immediately fol~owing the range. This exit from the range is called the normaJ"exit. Exit may also be accomplished by a transfer from within the range. The range of a DO statement may include other DO statements, provided that the range of each contained DO statement is entirely within the range of the containing DO statement'. That is, the r:anges of two DO statements must intersect completely or not at all. A transfer into the range of a DO statement from outside the range is not allowed. 5-34 Invalid Dq Loop Nest Valid DO Loop Nest IA _ __ B ........ B A C c Loop Cis not fu II y wi th in the range of loop B even though it is within the range of loop A. Control must not pass from within loop A or loop B into loop 0, or from loop 0 into loop A or loop B. Figure 4-1 Nested DO Loops Within the range of a DO statement, the index is available for use as an ordinary variable. After a transfer from within the range, the index retains its current value and is available for use as a variable. The value of the index variable becomes undefined when the DO loop it controls is satisfied. The values of the initial, limit, and increment variables for the index and the index of the DO loop, may not be altered within the range of the DO statement. The range of a DO statement must not end with a GO TO type statement or a numerical IF statement. If an assigned GO TO statement is in the range of a DO loop, all the statements to which it may transfer must be either in the range of the DO loop or all must be outside the range. A logical IF statement is allowed as the last statement of the range. In this case, control is transferred as follows. The range is considered ended when, and if, control would normally pass to the statement folloWing the entire logical IF statement. As an example, consider the sequences: DO 5 K = 1,4 5 IF(X(K).GT. Y(K»Y(K) = X(K) 6 ... Statement 5 is executed four times whether the statement Y(K) ecuted unti I statement 5 has been executed four times. 5-35 = X(K) is executed or not. Statement 6 is not ex- DO 22 L = 1,30 DO 45 K =2, LIMIT, -3 DO ZX ~'T,MAX,L Examples: 4.4 CONTINUE STATEMENT The CONTINUE statement has the form: CONTINUE This statement is a dummy statement, used 'primarily as a target for transfers, particularly as the last statement in , the range of a DO statement. For example, in the sequence: DO 7 K = START, END IF (X (1<»22, 13,7 7 CONTINUE a positive value of X (K) begins another execution of the range. The CONTINUE provides a target address for the IF statement and ends the range of the DO statement. 4.5 PAUSE STATEMENT The PAUSE statement enables the program to incorporate operator activity into the sequence of automatic events. The PAUSE statement assumes one of three forms: PAUSE PAUSE n PAUSE 'xxxxx' where n is an unsigned string of six or less octal digits, and 'xxxxx' is a literal message". Exec:ution of the PAUSE statement c:auses the message or the oc:tal digits, if any, to be typed on the user's teletypewriter. Program exec:ution may be resumed (at the next exec:utable FORTRAN statement) from the console by typing "G," followed by a carriage return. Program execution may be terminated by typing '~X," followed by 'c:arriage return. Example: PAUSE 167 PAUSE 'NOW IS THE TIME' 5-36. 4.6 STOP STATEMENT The STOP statement has the forms: STOP STOP n or where n is an unsigned string of one to six octal digits. The STOP statement termi.nates the program and returns control to the monitor system. (Termination of a program may also be accomplished by a CALL to the EXIT or DUMP subroutines.) 4.7 END STATEMENT The END statement has the form: END The END statement informs the compiler to terminate compilation and must be the physically last statement of the program. 5-37 1- CHAPTER 5 DATA TRANSMISSION STATEMENTS Data transmission statements are used to control the transfer of data between computer memory "and either peripheral devices or other locations in computer memory. These statements are also used to specify the format of the output data. Data transmission statements are divided into the following four categories. a. " Nonexecutable statements that enable conversions between internal form data within core memory and external form data (FORMAT), or specify lists of arrays and variables for input/output transfer (NAMELIST). "b. Statements that specify transmission of data between computer memory and WRITE, PRINT, PUNCH, TYPE, ACCEPT. I/o devices: READ, "c. Statements that control magnetic tape unit mechanisms: REWIND, BACKSPACE, END FILE, UNLOAD, SKIP RECORD. d. Statements that specify transmission of data between series of locations in memory: ENCODE", DECODE. 5.1 NONEXECUTABLE STATEMENTS The FOR.v\AT statement enables the user to specify the form and arrangement of data on the selected external medium. The NAME LIST statement provides for conversion and input/output transmission of data without reference to a FORMAT statement. 5.1.1 FORMAT Statement FORMAT statements may be used with any appropriate input/output medium or ENCODE/DECODE statement. FORMAT statements are of the form: where n is a statement number, and each 5 is a data field specification. FORMAT statements may be placed a~ywhere in the source program. Unless the FORMAT statement contains only alphanumeric data for direct input/output transmission, it will be used in conjunction with the list of a data transmission statement. 5-39 Slashes are used to specify unit records, which must be one of the following: m~imum length correspondirlg t~~a" line- buff~r a. A tape or disk record with a b. A punched card with a maximum Qf 80 characters. (ngAscII characters). c. A printed line with a maximum of 72 characters for a Teletype ®and either 120 or 132 characters for the line printer. During transmission of data, the object program scans the designated FORMAT statement. If a speciftcation for a numeric field is present (see Section 5.2.1 of this chapter) and the data transmission statement contains items remaining to be transmitted, transmission takes place according to the specifications. This process ceases and execution of the data transmission statement is terminated as soon asa~1 specified items have been transmitted. Thus, the FORMAT statement may contain specifications for more items than are specified by the data transmission statement. Conversely, 'the FORMAT statement may contain specifications for fewer items than are specified by the data transmission statement. The following types of field specifications may appear in a FORMAT statement: numeric, numeric with scale factors, logical, alphanumeric. The FORMAT statement also provides for handling multiple record formats, formats stored as data, carriage control, skipping characters, blank insertion, and repetition. If an input list requires more characters than the input device supplies for a given unit record, blanks are supplied. 5.1. 1.1 Numeric Fields - Numeric field specification codes designate the type of conversion to be performed. These codes and the corresponding internal and external forms of the numbers are listed in Table 5-2. The conversions are,specified by the forms: 1. 2. 3. 4. 5. 6. Dw.d Ew.d Fw.d Iw Ow Gw.d Gw Gw.d,Gw.d . (for real or double precision) (for integer or logical) (for complex) respectively. The letter 0, E, F, I, 0, or G designates the conversion type; w is an integer specifying the field width, which may be greater than required to provide for blank columns between numbe~s; d is an integer specifying the number of decimal places to the right of the decimal point or, for G conversion, the number of significant digits. (For 0, E, F, and G input I the position of the decimal point in the external field takes precedence over the value of d in the format.) ® Teletype is a registered trademark of Teletype Corporation. 5-40 For example, FORMAT (I5,F10.2,D18.10) could be used to output the line, bbb32bbbb-17.60bbb.5962547681D+03 on the output listing. The G format is the general format code that is used to transmit real, double precision, integer, logical, or complex data. The rules for input depend on the type specification of the corresponding variable in the data list. The form of the output conversion also depends on the individual variable except in the case of real and double-precision data. In these cases the form of the output conversion is a function of the magnitude of the data being converted. The following table shows the magnitude of the external data, M, and the resulting method of conversion. Table 5-1 Magnitude of Internal Data Magn itude of Data Resulting Conversion 0.15. M < 1 1 F(w-4). d, 4x -< M < 10 . F(w-4).(d-1),4x . 10d- 2 ~ M < lOd - 1 10d-1 5. M < lOd F(w-4). 1, 4x F(w-4). 0, 4x All others Ew.d The field width w should always be large enough to include spaces for the decimal point, sign, and exponent. In all numeric field conversions if w is not large enough to accommodate the converted number, the excess digits on the left will be lost; if the number is less than w spaces in length, the number is right-adjusted in the field. 5-41 Table 5-2 Numeric Field Codes . , ' Conversion Code , . Internal Form External Form 0 Binary floating point double-precision Decimal floating point with 0 exponent E Binary floating point Decimal floating point with E exponent F Binary floating point Decimal fixed point Binary integer Decimal integer Binary integer Octal integer One of the following: single precision binary floating point, binary integer, binary logical, or binary complex Single -'precision decimal floating point integer, logical (T or F), .or complex (two decimal floating point numbers), depending upon the internal form I 0 , G 5.1.1.2 '- " Numeric Fields with Scale Factors - Scale factors may be specified for O,.E, F, and G conversions. A scale factor is written nP where P is the identifying character and n is a signed or unsigned integer that specifies the scale factor. For F type conversions (or G type, if the external field is decimal fixed pointL the scale factor specifies a power of ten so that • (scale factor) externol number = (mternal number)* 10 For 0, E, and G (external field not decimal fixed point) conversions, the ,scale factor multiplies the number by a power of ten, but the exponent is changed accordingly leaving the' number unchanged except in form. For example, if the statement: FORMAT (F8.3,E16.5) corresponds to the line bb26.451bbbb-0.41321E-Ol then the statement FORMAT (-lPF8.3,2PE 16.5) , 5-42 might correspond to the line . , bbb2. 645bbb-41 . 32157E -03 In input operations, F type (and G type, if the external field is decimal fixed point) conversions are the only types affected by sca Ie factors. When no scale factor is specified, it is understood to be zero. However, once a scale factor is specified, it holds for all subsequent 0, E, F, and G type conversions within the same format unless another scale factor is encountered. The scale factor is reset to zero by specifying a scale factor of zero. Scale factors have no effect on I and 0 type conversions. 5. 1. 1.3 Logical Fields - Logical data can be transmitted in a manner simi lar to numeric data by use of the specification: Lw where L is the control character and w is an integer specifying the field width. The data is transmitted as the value of a logical variable in the input/output list. If or input, the first nonblank character in the data field is T or F, the value of the logical variable will be stored as true or false, respectively. If the entire data field is blank or empty, a value of false wi" be stored. On output, w minus 1 blanks followed by Tor F will be output if the value of the logical variable is true or false, respectively. 5.1.1.4 Variable Field Width - The 0, E, F, G, I, and "0 conversion types may appear in a FORMAT state- ment without the specification of the field width (w) or the number of places after the decimal point (d). In the case of input, omitting the w implies that the numeric field is delimited by any character which would otherwi~ be illegal in the field, in addition to the characters -, +, ., E, 0, and blank provided they follow the numeric field. For example, input according to the format 10 FORMAT(2I,F,E,0) might appear on the. input medium as -10,3/15.621-.0016E-10,777. 5-43 In thi,s case, commas delimit the numeric fields, blanks may also be used as field delimiters. On output, omitting the w has the following effect: Format 5. 1. 1.5 Becomes D D25.16 E E15.7 F F15.7 G G15.7 or G25. 16 I 115 O' 015 Alphanumeric Fields - Alphanumeric data can be transmitted in a manner simi lar to numeric data by use of the form Aw, where A is the control character and w is the number of characters in the field. The alphanumeric characters are transmitted as the value of a va!iabJe in an input/output list. The variable may be of any . type. For the sequence: READ 5, V 5 FORMAT (A4) causes four characters to be read and placed in memory as the value of the variable V. Although w may have any value, the number of characters transmitted is limited by the maximum number of characters which can be stored in the space allotted for the variable. This maximum depends upon the variable type. For a double precision variable the maximum is ten characters; for all other variables, the maximum is five characters. If w exceeds the max imum, the leftmost characters are lost on input and replaced with blanks on output. If, on input, w is less than the maximum, blanks are fj lied in to the right of the given characters unti I the maximum is reached. If, on output, w is less than the maximum, the leftmost w characters are transmitted to the extemal medium. Since for complex variables each word requires a separate field specificCJtion, the m~ imu~ value for w. is 5. For example, COMPLEX C ACCEPT 1 i C 1 FORMAT (2A5) could be used to transmit ten alphanumeric characters into complex variable C. 5.1.1.6 Alphanumeric Data Within Format Statements - Alphanumeric data may be transmitted directly into or from the fOmlat stateme~t by two different methods: H-conversion, or the use of single quotes. 5-44 . In H-conversion, the alphanumeric string is specified by the form nH. H is the control character and n is the number of characters in the string counting blanks. For example, the format in the statement below can be used to print PROGRAM COMPLETE on the output lis,ting. FORMAT (17H PROGRAM COMPLETE) The statement FORMAT (16HPROGRAM COMPLETE) causes ROGRAM COMPLETE to be printed. Referring to this format in a READ statement would cause the 17 characters to be replaced with a new string of characters. The same effect is achieved by merely enclosing the alphanumeric data in quotes. The result is the same as in H-conversion; on input, the characters between the quotes are replaced by input characters, and, on output, the characters between the quotes (including blanks) are written as part of the output data. A quote character within the data is represented by two successive quote marks. For example, referring to: FORMAT (' DON"T') with an output statement would cause DON'T to be printed. Referring to FORMAT ('DON"T') causes ON'T to be printed. The first character referenced by the FORMAT statement for output is interpreted as a carriage control character (see 5. 1 • 1. 13). 5.1.1:7 Mixed Fields - An alphanumeric format field may be placed among other fields of the format. For example, the statement: FORMAT (I5,7H FORCE=FlO.5) can be used to output the line: bbb22bF ORCE=bb 17. 68901 The separating comma may be- omitted after an alphanumeric format field, as shown above. 5-45 5.1.1.8 Complex Fields.- Complex q~antities are transmitted as two independent n::al quantities. The format specification consists of two successive .real specifications or one' repeated real specification. For instance, the statement: FORMAT (2E15.4,2(F8.3,F8.5» could be used in the transmission of three complex quantities. 5.1.1.9 Repetition of Field Specifications - Repetition of a field specification may be specified by preceding the control character 0, E, F, I, 0, G, L, or A by an unsigned integer giving the number of repetitions desired. For example: FORMAT (2E12.4,315) is equivalent to: FORMAT (E 12.4,E 12.4, IS ,15 ,15) 5.1.1. 10 Repetition of Groups - A group of field specifications may be repeated by enclosing the group in parentheses and preceding the whole with the repetition number. For example: FORMAT (218, 2(E 15.5 ,2F8 .3» is equivalent to: FORMAT (218,E 15.5 ,2F8.3,E 15.5 ,2F8 .3) 5.1.1.11 Multiple Record Formats - To handle a group of input/output records where different records have different field specifications, a slash is used to indicate a new record. For example, the statement: FORMAT (308/I5,2F8.4) is equivalent to FORMAT (308) for the first record and FORMAT (I5, 2F8 .4) for the second record. 5-46 The separating comma may be omitted when a slash is used. When n slashes appear at the end or beginning of .. a format, n blank records may be written an output or records skipped on input. When n slashes appear in the middle of a format, n-1 blank records are written or n-1 records skipped. Both the slash and the closing parenthesis at the end of the format indicate the termination of a record. If the list of an input/output statement dictates that transmission of elata is to continue after the closing parenthesis of the format is reached, the format is repeated starting with that group repeat specification terminated by the last right parenthesis of level one or level zero if no level one group exists. Thus, the statement • FO~MAT level (F7. 2,(2(E 15.5,E 15.4),17» O~ J level 1 level 1 jL level 0 causes the format F7 .2,2(E 15.5,E 15.4) ,17 to be used on the first record, and the format 2(E15.5,E15.4),I7 to be used on succeeding records. As a-further example, consider the statement' FORMAT (F7. 2/(2(E 15.5,E 15 .4) ,17» The first record has the format F7.2 and successive records have the format 2(E15.5,E 15.4),17 5. 1.1.12 Formats Stored as Data - The ASCII character string comprising a format specification may be stored as the values of an array. Input/output statements may refer to the format by giving the array name, rather than the statement number of a FORMAT statement. The stored format has the same form as a FORMAT statement excluding the word "FORMAT." The enclosing parentheses are included. 5-47 ' As an example, consider the sequence: , , DIMENSION SKELETON {2} READ 1, (SKELETON{I), 1=1,2) 1 FORMAT (2M) READ SKELETON,K,X The first READ statement enters the ASCII string into the array SKELETON. In the second READ statement, . SKELETON is referred to as the format governing conversion of K and X • 5.1. 1. 13 Carriage Control - The first character of each ASCII record controls the spacing of the line printer or Teletype. 'This character is usually set by beginning a FORMAT statement for an ASCII record with 1Ha, where a is the desired control character. The line spacing actions, listed be low, occur before printing: Effect Character space skip to next line with a FORM FEED after every 60 lines zero skip a line one form feed - go to top of next page + plus suppress skipping - will overprint line * asterisk skip to next I i.ne with no FORM FEE DS minus skip 2 lines 2 two sk i p to nex t 1/2 of page 3 three skip to next 1/3 of page / slash skip to next 1/6 of page period skip to next 1/20 of page comma skip to next 1/30 page o A $ (dollar sign) as a format field specification code suppresses the carriage retum at the end of the line. 5.1.1.14 Spacing - Input and output can be made to begin at any position within a FORTRAN record by use of the format code Tw where T is the control character and w is an unsigned integer constant specifying the character position in a FORTRAN record where the transfer of data is to begin. When the o~tput is printed, w corresponds to the {w-l)th print position. This is because the first character of the output buffer is a carriage control character and is not printed. It is recommended that the first field specification of the output format be lx', except where a carriage control character is used. 5-48 For example, 2 FORMAT (T50, 'BLACK'T30, 'WHITE') would cause the following line to be printed Print Position 29 +WHITE Print Position 49 + BLACK For input I the statement ] FORMAT(T35, 'MONTH') READ (3,1) cause the first 34 characters of the input data to be skipped, and the next 5 characters would replace the characters M, 0, N, T, and H in storage. If an input record containing ABCbbbXYZ is read with the format specification 10 FORMAT (T7 ,A3, T] ,A3) then the characters XYZ and ABC are read, in that order. 5. ]. ].15 Blank or Skip Fields - Blanks may be introduced into an output record or characters skipped on an input record by use of the specification nX. The control character is Xi n is the number of blanks or characters skipped and must be greater than zero. For example, the statement FORMAT (5H.STEPI5, lOX2HY=F7.3) . may be used to output the line bSTEPbbb28bbbbbbbbbbY=b-3.872 5.1.2 NAME LIST Statement The NAME LIST statement, when used in conjunction with special forms or the READ and WRITE statements, provides a method for transmitting and converting data without using a FORMAT statemen't or an NAME LIST statement has the form 5-49 I/o I.ist. The· where the X's are NAMELIST names,'\and the A's, B's, and C's are variable or array names. Each list or variable mentioned in the NAME LIST statement is given the NAMELIS! name immediately preceding the list. Thereafter, an I/o statement may refer to an entire list by mentioning its' NAMELIST name. For example: NAMELIST/FRED/A,B,C/MARTHA/D,E states that A, B, and C belong to the NAME LIST name FRED, and D and E belong to MARTHA. The use of NAMELIST ~tatements must .obey the following rules: a. A NAMELIST name may not be longer than six characters; it must start with an alphabetic character; it must be enclosed in slashes; it must precede the list of entries to which it refers; and it must be unique within the program. b. A NAME LIST name may be defined only once and must be defined by a NAMELIST statement. After a NAMELIST name has been defined, it may only appear in READ or WRITE stateme~ts. The NAMELIST name ,must be defined in advance of the READ or WRITE statement. c. A variable used in a NAME LIST statement cannot be used as a dummy argument in a subroutine definition. d. Any dimensioned variable contained in NAME LIST statement must have been defined in a DIMENSION statement preceding the NAMELIST statement. 5.1.2.1 Input Data For NAMELIST Statements - When a READ statement refers to a NAMELIST name, the first character of all input records is ignored. Records are searched until one is found with 6 $ or & as the second character immediately followed by the NAMELIST name specified. Data is then converted and placed in memory until the ~nd of a data group is signaled by a $ or'& eith~r in the same record as the NAMELIST name, or in any succeeding record as long as the $ or & is the second character of the record. Data items must be separated by commas and be of the following form: where V may be a variable name or an arra~ name, wi th or without subscripts. The K's are constants which may be integer, real, double precision, complex {written as (A, B) where A and B are rea!), or logical (written as T for true and'F for false). A series of J identical constants may be represented by J*K where J is an unsigned integer and K is the repeated constant. Logical and complex constants must be equated to logical and complex variables, respective ly. The other types of constants (real, double precisi9n, and integers) may be equated to 5-50 any other type of variable (except logical or complex), and will be converted to the variable typel For example, assume A is a two-dimensional real array, B is a one-dimensional integer array, C is an integer variable, and that the input data is as follows: $FRED A(7,2)=4, B=3,6*2.8, C=3.32$ t Column 2 A READ statement referring to the NAMELIST name FRED will result in the following: the integer 4 will be converted to floating point and placed in A(7,2). The integer 3 will be placed in B(l) and the floating point number 2.8 will be p'laced in B(2), B(3), •.. , B(7). The floating point number 3.32 will be converted to the integer 3 and placed in C. 5.1.2.2 Output Data For NAMELIST Statements - When a WRITE statement ref~rs TO a NAMELIST name, all variables and arrays and their values belonging to the NAMELIST name will be written out, each according to its type. The complete array is written out by columns. The output data wi" be written so that: a. The fields for the data will be large enough to contain all the significant digits. b. The output can be read by an input statement referencing the NAMELlST nome. For example, if JOE is a 2x3 array, the statement NAMELIST/NAM l/JOE, K I,ALPHA WRITE (u, NAM 1) generate the following form of output. Column 2 ~ $NAMJ JOE = -6.75, -17.8, Kl=73.1, 5.2 . 234E-04, 0.0, ALPHA=3,$ 68.0, -. J97E+07, DATA TRANSMISSION STATEMENTS The data transmission statements accomplish input/output transfer of data that may be listed in a NAMEL:ST statement or defined in a FORMAT statement. When a FORMAT statement is used to specify formats, the data transmission statement niust contain a list of the quantities to be transmitted. The data appears on the external media in the form of records. 5-51 I 5.2.1 Inpot/Output Lists The list of' an-input/output statement specifies the order of transmission of the variable values. During input, the new values of listed variables may be used in subscript or control expressions for variables appearing later in the list. For example: READ 13,L,A(L),B(L+1} reads a new value of L and uses this value in the subscripts of A and B: The transmission of array-variables may be controlled by indexing similar to that used in the DO statement. The list of controlled variables, followed by the index control, is enclosed in parentheses. For example, READ 7, (X(K),K=1,4),A is equivalent to: READ 7, X(1) ,X(2) ,X(3) ,X(4),A As in the DO statement, the initial, limit, and increment values may be given as integer expressions: READ 5, N, (GAIN(K), K=l ,M/2, N) The indexing may be compounded as in the following: READ 11, «MASS(K, L), K= 1,4), L= 1,5) The above statement reads in the elements of array MASS in the following order: MASS(l, 1), MASS(2, 1}, ... ,MASS(4, 1} ,MASS(l ,2), ... ,MASS(4,5) If on entire array is to be transmitted, the index ing may be omitted and only the array identifier written. The array is transmitted in order of increasing subscripts with the first subscript varying most rapidly. Thus, the example above could have been written: READ 11, MASS Entire arrays may also be designated for transmission by referring to a NAME LIST name (see description of NAMELIST statement). 5-52 5.2.2 Input/Output Recorc!s All information appearing on external media is grouped into records. The maximum amount of information in one record and the manner of Separation between records depends upon the medium. For punched cards, each card constitutes one record; on a teletypewriter a record is one line, and so forth. The amount of information contained in each ASCII record is spec ified by the FORMAT reference and the binary records, the amount of information is specified by the I/o I/o list. For magnetic tape list. Each execution of an input or output statement initiates the transmission of a new data record. Thus, the statement READ 2, FIRST ,SECOND, THIRD is not necessarily equivalentto the statements READ 2, FIRST READ 2, SECOND READ 2, THIRD since, in the second case, at least three separate records are required, whereas, the single statement READ 2, FIRST ,SECOND, THIRD may require one, tWo, three, or more records depending upon FORMAT statement 2. If an input/output statement requests less than a full record of information, the unrequested part of the record is los! and cannot be recovered by another input/output statement without repositioning the record. If an input/output list requires more than one ASCII record of information, successive records are read. 5.2.3 PRI NT Statement The PRI NT statement assumes one of two forms PRINT f, list PRINT f where f is a format reference. The data is converted from internal to external form according to the designated format. If the data to be transmitted is contained in the specified FORMAT statement, the second form of the statement is used. 5-53 Examples~ PRINT 16, T , (B(I<) ,K=1,M) PRINT F 106, seEE 0, MISS In the second example, the format.is stored in array F106. '5.2.4 PUNCH Statement The PUNCH statement assumes one of two forms PUNCH f, list PUNCH f :\It where f is a format reference. Conversion from internal to externa I data forms is specified by the formqt reference. If the data to be transmitted is contained in the designated FORMAT statement, the second form of the statement is used. Examples: 5 • 2.5 PUNCH 12,A,B(A),C(B(A» PUNCH 7 TY PE Statement The TYPE statement assumes one of two forms TYPE f, list TYPE f where f is a format reference. This statement causes the values of the variables in the list to be read from memory and listed on the user's teletypewriter. The data is converted from internal to external form according to the designated format. If the data to be transmitted is contained in the designated F ORMAT is used. Examples: 5.2.6 TYPE 14,K,(A(L) ,L=1,K) TYPE FMT WRITE· Statement The WRITE statement assumes one of the following forms 5-54 state~ent, the second form of the statement WRITE (u,f) list WRITE(u ,f) WRITE(u,N) WRITE(u) list WRITE(u#R,f) list where u is a unit designation, f is a format reference, N is a NAMELIST name, and R is a record number where I/o is to start. The first form of the WRITE statement causes the values of the variables in the list to be read from memory and written on the unit designated in ASCII form. The data is converted to external form as specified by the designated FORMAT statement. The second form of the WRITE statement causes information to be read directly from the specified format and written on the unit designated in ASCII form. The third form of the WRITE statement causes the names and values of all variables and arrays belonging to the NAMELIST name, N, to be read from memory and written on the unit designated. The data is converted to external form according to the type of each variable and array. The fourth form of the WRITE statement causes the values of the variables in the list to be read from memory and written on the unit designated in binary form. The fifth form of the WRITE statement -allows the FORTRAN programmer to access fixed-length records in a disk file directly. This eliminates sequential writing of data in order to access one or more records within a file. The file must be defined properly and the record from which the writing is desired must be specified. The file whose records are to be accessed is defined as follows. CALL DEFINE FILE (D, S, V, F, Pj, Pg) D = data set (device) S size of records in the file in characters (ASCII) or words (binary) V = associate~ variable which initially contains the length of the file that would be accessed next if the program were to continue I/o sequentially *F = file name .ext defined first in DATA statement *Pj = project number ' *Pg = programmer number Output begins when the random WRITE is specified in the correct format. The arguments designated by an asterisk (*) may be zero. This impl ies a defau It filename and/or user's project and programmer numbers; for example, CALL DEFI NE FILE (3,80, NX ,0,0,0) 5-55 • 5.2.7 READ Statement The READ statement assumes one of the following forms READ f, list READ f READ(u , f) list READ(u ,f) READ(u, N) READ(u)list READ(u# R, f) list READ(u,f,END=C, ERR=d) list READ(u,f,END=C) list READ(u,f, ERR=d) list ''\IIiiit:, ,,~-. where f is a format reference, u is a unit designation, N is a NAME LIST name, R is a record number where I/o is to start, C is a statement number to whi ch control is transfe~red upon encountering an end-of-fi Ie, and d is the statement number to which control is transferred upon encountering an error condition on the input data. The first form of the READ statement causes information to be ,read from cards and put in memory as values of the variables in the list. The data is converted from external to internal form as specified by the referenced FORMAT statement. Example: READ 28,Zl,Z2,Z3 The second form of the READ statement is used if the data read from-cards is to be transmitted directly into the s~cified format. Example: READ 10 The third form of the READ statement causes ASCII information to be read from the unit designated and stored in memory as values of the variables in the list. The data is converted to internal form as specified by the referenced FORMAT statement. Example: READ( I, 15)ET A, PI The fourth form of the READ statement causes ASCII information to be read from the unit desi.gnated ,and transmitted directly into the specified format. Example: READ(N,105) The fifth form of the READ statement causes data of the form described in the discussion of input data for NAMELIST statements to be read from the unit designated and stored in memory as values of the variables or arrays specified. READ(2,FRED) Example: The sixth form of the REAb statement causes binary information to be read from the unit designated and stored in memory as values of the variables in the list. READ(M)GAIN,Z ,AI Example: The seventh form of the READ statement allows random access of fixed-length records in a disk file. The file whose records are to be read is defined by the DEFINE FILE call where the arguments are the same as described in Section 5.2.5 of this chapter. Example: DOUBLE PRECISION FIL DIMENSION A(6) DATA FIL/'FILE. ONE'I CALL DEFINE FILE (4,30, NV,FIL,"l1,"23) READ (4#54,5)A This example reads the 54th record from FILE. ONE on the disk area belonging to programmer [11,23] into the list variables A(1) through A(6). The eighth form of the READ statement causes control to be transferred if an end-of-file or error condition is encountered on the input data. The argument$ END=c and ERR=d are optional and mayor may not be included. If an end-of-file is encountered, control transfers to the statement specified by END=c. If an END parameter is not specified, I/O on that device terminates and the program halts with an error message to the user's TTY. If an error on input is encountered, control transfers to the statement specified by' ERR=d. If an ERR=d parameter is not specified, the program halts with an error message to the user's TTY . Example: 5.2.8 READ (7,7,END=888, ERR=999)A 888 (control transfers here if an end-of-file is encountered) 999 (control transfers here if an error on input is encountered) . REREAD Statement The reread feature allows a FORTRAN program to reread information from the last used input file. The format used during the reread need not correspond to the original read format, and the informati on may be read as many times as desired. 5-57 a. To reread from an input device, the following coding would be u~d: READ (16, l(0)A REREAD 105,A The REREAD 105,A statement causes the last input device used to be reread according to format st~te ment 105. The original read format and a subsequent reread format need not be the same. b. The reread feature cannot be used until an input from a file has been accomplished. If the feature is used prematurely, an error message will be generated. c. Information may be reread as many times as desired using either the same or a new format statement each time. d. The reread feature must be used with some forethought and care since it file used, i.e.: re~ads from the last input The following example will reread from the file on Device No. 10, not Device No. 16: READ (16, l(0)A READ (10,200)B REREAD 110,A 5.2.9 ACCE PT Statement The ACCEPT statement aSSumes one of two forms ACCEPT f, list ACCEPT f where f is a format reference. This statement causes information to be input from the user's teletypewriter and put in memory as values of the variables in the list. The data is converted to internal form as specified by the format. If the transmission of data is directly into the designated format, the second form of the statement is used. Examples: 5.3 ACCEPT 12,ALPHA,BETA ACCEPT 27 DEVICE CONTROL STATEMENTS Device control statements and their corresponding effects are listed in Table 5-3. 5-58 Table 5-3 Device Control Statements '5.4 Statement Effect BACKSPACE u Backspaces designated tape one ASCII record or one logical binary record. END FILE u Writes an end-of-fi Ie . REWIND u Rewinds tape on designated unit. SKIP RECORD u Causes skipping of one ASCII record or one logical binary record. UNLOAD u Rewinds and unloads the designated tape. ENCODE AND DECODE STATEMENTS ENCODE and DECODE statements transfer data, according to format specifications, from one section of user's core to another. No peripheral equipment is involved. DECODE is used to change data in ASCII format to data in another format. ENCODE changes data of another format into data in ASCII format. The two statements are of the form ENCODE(c,f,v),l(1), ••. ,L(N) DECODE (c, f, v), L(1), .•• ,L(N) where c = the number of ASCII characters f = the format statement number v = the starting address of the ASCII record referenced L(1), ••. ,L(N) = the list of variables. Example: Assume the contents of the variables to be as follows: A(I) contains the floating-point binary number 300.45 A(2) contains the floating-point binary number 3.0 10 J contains the binary integer value 1. B is a four-word array of indeterminate contents C contains the ASCII string 12345 DO 2 J = 1,2 . ENCODE (16, 10,B) J, A(J) FORMAT (IX,2HA(,Il,4H) = ,F8.2) TYPE 11 ,B 11 2 FORMAT (4A5) CONTINUE DECODE (4, 12, C) B 5-59 12 13 FORMAT (3F1.0,IX,F1.0) TYPE 13,B FORMAT (4F5.2) END Array B can contain 20 ASCII·characters. The result of the EN~ODE statement after the first iteration of the . DO loop is: Typed as B( 1) 1--_.;...:.A(,l..;.;1):""'-_-I B(2) 1-----::=="......,....----1 B(3) t--_3_O-;::-0_.4_ _--i B(4) L -_ _5_ _---' A(1) = 300.45 The result after the second iteration is: B.(1) t - - _A . . . ;(.. .;.2)_ _--i B(2) 1--_,.....-_ _---I B(3) t--_ _ 3_.0_ _~ B(4) '--_ _ _ _--1 Typed as A(2) = 3.0 The result of the DECODE statement is to extract the digits 1, 2, and 3 from C and convert them to floatingpoint binary values and store them in B(1}, B(2), and 8(3). Then skip the next character (4) and extract the digit 5 from C, convert it to a floating-point binary value, and store it in 8(4). 5-60 CHAPTER 6 SPECIACATION STATEMENTS Specification statements allocate storage and furnish information about variables and constants to the compiler. Specification statements may be divided into three categories, as follows: a. Storage specification statements: DIMENSION, COMMON, and EQUIVALENCE. b. pata specification statements: DATA and BLOCK DATA. c. Type declaration statements: INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, SUBSCRIPT INTEGER, and IMPLICIT. By extending the USA Standard in regard to specification statements, PDP-lO FORTRAN IV allows the following statements to be used anywhere in the program, provided that the variables they specify appear in executable statements only after the particular specification statement. The specification statement must not appear in the range of a DO loop. DIMENSION statement EXTERNAL statement (described in Chapter 7) COMMON statement EQUIVALENCE statement Type declaration statements DATA statement A sample program that incorporates these statements follows. 10 DOUBLE PRECISION 0 DIMENSION Y(10), 0(5) Y{l) = -1.0 INTEGER XX(5) Y(2) = ABS(Y(l» DATA XX/l,2,3,4,5 DO 10 1= 3,7 Y(I) = XX(I-2) COMMON Z Z=Y(1)*Y{2)/(Y{3) + Y(5» END Only IMPLICIT statements and arithmetic function definition statements (described in Chapter 7) must appear in the program before any executable statement. 5-61 - In addition, arrays must be dimensional before being referenced in a NAMEUST, EQUIVALENCE, or DATA statement. ,DOUBLE PRECISION and COMPLEX arrays must be declared before they are dimensioned. 6.1 STORAGE SPECIACATION STATEMENTS 6. 1. 1 DIMENSION Statement The DIMENSION statement is used to declare identifiers to be array identifiers and to specify the number and bounds of the array subscripts. The information supplied in a DIMENSION statement is required for the allocation of memory for arrays. Any number of arrays may be declared in a single DIMENSION statement. The DIMENSION statement has the form where S is an array specification. Each array variable appearing in the program must represent an element of an array declared in a DIMENSION statement, unless the dimension information is given in a COMMON or TYPE statement. Dimension information may appear only once for a given variable. Each array specification gives the array identifier and the minimum and maximum values which each of its subscripts may assume in the following form: identifier(min/max, min/max, ••• ,min/max). The minima and maxima must be integers. The minimum must not exceed the maximum. For example, the statement DIMENSION EDGE(-1/1,4/8) specifies EDGE to be a two-dimensional array whose first subscript may vary from -1 to 1 inclusive, and the second from 4 to 8 inclusive. Minimum values of 1 may be omitted. For example, NET(5, 10) is interpreted as: NET(1/5,1/to) 5,..62 Examples: PIMENSION FORCE(-l/1, 0/3, 2,2, -7/3) DIMENSION PLACE(3,3,3), JI(2,2/4), K(256) Arrays may also be declared in the COMMON or type declaration statements in the same way: COMMON X(10,4), Y,Z INTEGER A(7, 32), B DOUBLE PRECISION K(-2/6, 10) 6.1.1.1 Adjustable Dimensions - Within either a FUNCTION or SUBROUTINE subprogram, DIMENSION and TYPE statements may use integer variables in an array specification, provided that the array name and variable dimensions are dummy arguments of the subprogram. The actual array name and values for the dummy variables are given by the call ing program when the subprogram is called. The variable dimensions may not be altered within the subprogram (i.e., typing the array DOUBLE PRECISION or COMPLEX after it has been dimensioned) and must be less than or equal to the explicit dimensions declared in the calling program. SUBROUTINE SBR(ARRAY,M1,M2,M3,M4) DIMENSION ARRAY (Ml/M2,M3/M4) Example: DO 27 L=M3, M4 DO 27 K=M1,M2 . 27 ARRAY(K,L)=VALUE END The calling program for SBR might be: DIMENSION Al(10,20),A2(l000,4) CALL SBR(Al,5, 10, 10,20) CALL SBR(A2, 100,250,2,4) END 5-63 6.1.2 COMMON Statement The COMMON statement causes specified variables or arrays to be stored in an area available to other programs. By means of COMMON statements,' the data of a main program and/or the ,data of its subprograms may share a common storage area. The common area may be divided into separate blocks which are identified by block names. A block is specified as follows: . ,/block identifier/identifier, identifier, ••• ,identifier The identifier enclosed in slashes is the block name. The identifiers which follow are the names of the variables or arrays assigned ,to the block and are placed in the block in the order in which they appear in the block specification. A common block may have the same name as a variable in the same program. The COMMON statement has the general form COMMONjBLOCK 1/A, B,C/BLOCK2/D, E, F/ ••• where BLOCK 1,BLOCK2, ••• are the block names, and A,B,C, ••• are the variables to be assigned to each block. For example, the statement COMMON/R/X, Y, T/C;\J, V, W,Z i ndi cates that the elements X, Y, and T are to be placed in block R in that order, and that U, V, W, and Z are to be placed in block C. Block entries are linked sequentially throughout the program, beginning with the first COMMON statement. For example" the statements COMMON/D/ALPHA/R/A,B/C/S COMMON/C/X, Y/R/U, V, W have the same effect as the statement COMMON/D/ALPHA/R/A,B,U, V, W/C/S,X, Y One block of common storage, referred to as blank ~ommon, may be left unlabeled. Blank common is indicated by two consecutive slashes. For example, COMMON/R/X, Y//B,C,D indicates that B, C, and D are placed in blank common. The slashes first block of the statement. 5-64 m~y be omitted when blank common is the COMMON B,C,D Storage allocation for blocks of the same name begins at the same location for all programs executed together. For example, if a program contains COMMON A, B/R;?<, ViZ as its first COMMON statement, and a subprogram has COMMON/R/U, V, W//D,E,F as its first COMMON statement, the quantities represented by X and U are stored in the same location. A similar correspondence holds for A and D in blank common. Common blocks may be any length provided that no program attempts to enlarge a given common block declared by a previously loaded program. Array names appearing in COMMON statements may have dimension information appended if the arrays are not declared in DIMENSION or type declaration statements. For example, COMMON ALPHA, T(15, 10,5),GAMMA specifies the dimensions of the array T while entering Tin bl(Jnk common. Variable dimension array identifiers may not appear in a COMMON statement, nor may other dummy identifiers. Each array name appearing in a COMMON statement must be dimensioned somewhere in the program containing the COMMON statement. 6.1.3 EQUIVALENCE Statement The EQUIVALENCE statement causes more than one variable within a given program to share the same storage location. The EQUIVALENCE statement has the form EQUIVALENCE(V l' V2' ... ), (Vk , Vk+ 1'· •• ), ..• where the V's are variable names. The inclusion of two or more references in a parenthetical list indicates that the quantities in the list are to share the same memory location. For example, EQUIVALENCE(RED, BLUE) specifies that the variables RED and BLUE are stored in the same location. 5-65 I The relation of equivalence is transitive; e.g., the two statements, EQUIVALENCE(A, B), (B,C) \ EQUIVALENCE(A,B,C) have the same effect. Tne subscripts of array variables must be integer" constants. EQUIVAlENCE(X,A{3), V{2, 1,4», (BETA{2(2),ALPHA) Example: 6.1.4 EQUIVALENCE and COMMON Identifiers may appear in both COMMON and EQUIVALENCE statements provided the following rules are observed. a. No two quantities in common may be set equivalent to one another. b. Quantities placed in a common block by means of EQUIVALENCE statements may cause the end of the common block to be extended. For example, the statements COMMON/Rft, V,Z DIMENSiON A(4) EQUIVALENCE{A, V) causes the common block R to extend from X to A(4), arranged as follows: X V A(1) Z A(2) A(3) A(4) (same location) (same location) c. EQUIVALENCE statements which cause extension of the start of a common block are not allowed. For example, the sequence COMMON/Rft, V,Z DIMENSION A(4) EQUIVALENCE(X ,A(3» is not permitted, since it would require A(1) and A(2) to extend the starting location of block R. 6.2 DATA SPECIFICATION STATEMENTS The DATA statement is used to specify initial or constant values for variables. The specified values are compiled into the object program, and become the values assumed by the variables when program execution begins. 6.2.1 DATA Statement The data to be compiled into ,the object program is specified in a DATA statement. The DATA statement has the form 5-66 DATA Iist/d 1,d 2 ,· • •1, list/dk,d k+1" . .I, ... where each list is in the same form as an input/output list, and the d's are data items for each list. Indexing may be used in a list provided the initial, limit, and increment (if any) are given as constants. Expressions used as subscripts must have the form where c 1 and c 2 are integer constants and i is the induction variable. If an entire array is to be defined, only the array identifier need be listed. Variables in COMMON may appear on the lists only if the DATA statement occurs in a BLOCK DATA subprogram. (See Chapter 7, Section 7.6) The data items following each list correspond one-to-one with the variables of the list. Each item of the data specifies the value given to its corresponding variable. Data items may be numeric constants, alphanumeric strings, octal constants, or logical constants. For example, DATA ALPHA, BETA/5, 16.E-2/ specifies the value 5 for ALPHA and the value. 16 for BETA. Alphanumeric data is packed into words according to the data word size in the manner of A conversion; how~ver, excess characters are not permitted. the specification is written as nH followed by n characters or is imbedded in single quotes. Octal data is specified by the letter 0 or the character ", followed by a signed or unsigned octal integer of one to twelve digits. Logical constants are written as • TRUE.,. FALSE., T, or F. Example: DATA NOTE,K/4HFOOT, 0-7712/ DATA QUOTE/,QUOTE'/ Any item of the data may be preceded by an integer followed by an asterisk. The integer indicates the number of times the item is to be repeated. For example, DATA(A(K},K=1, 20)/61 E2, 19*32E1/ specifies 20 values for the array A; the value 6100 for A(1); the value 320 for A(2) through A(20). 5-67 6.2.2 BLOCK OATA Statement The BLOCK DATA statement has the form: BLOCK DATA This statement declc:'res the program which follows to be a data specification subprogram. Data may be entered into labeled or blank common. The first statement of the subprogram must be the BLOCK OAT A statement. The subprogram may contain only the declarative statements associated with the data being defined. Example: BLOCK DATA COMMONft/S, Y/C/z', W, V DIMENSION Y(3) COMPLEX Z DATA Y/1E-1 ,2*3E2/,X, Z/ll. 87700,(-1.41421,1.41421)/ END Data may be entered into more than one block of common in one subprogram. 6.3 TYPE DECLARATION STATEMENTS The type declaration statements INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, IMPLICIT; and SUBSCRIPT INTEGER are used to specify the type of identifiers appearing in a prograJ!l. An identifier may appear in only one type statement. Type statements may be used to give dimension specifications for arrays. The explicit type declaration statements have the general form type identifier, identifier, identifier ••• where type is one of the following: IN TEGER, REAL, DOUBLE PRECISION,COMPLEX,LOGICAL, SUBSCRIPT INTEGER The listed identifiers are declared by the statement to be of the" stated type. Fixed-point variables in ci SUBSCRIPT INTEGER statement must fall between _2 27 and 227. 6.3. 1 IMPLICIT Statement The IMPUCIT statement has the form 5-68 where type represents INTEGER, REAL, LOGICAL, COMPLEX, or .DOUBLE PRECISION, and a 1a 2 , ... represent single alphabetic characters, each separated by commas, or a range of characters (in alphabetic sequence) denoted by the first and last characters of the range separated by a minus sign (e.g., (A-D». This statement causes any program variable which is not mentioned in a type statement, and whose first character is one of those listed in the IMPLICIT statement, to be classified according to the type appearing before the list in which the character appears. As an example, the statement IMPLICIT REAL(A-D, L, N-P) causes all variables starting with the letters A through D, L, and N through P to be typed as real, unless they are explicitly.declared otherwise. The initial state of the compiler is set as if the statement IMPLIOT REAL(A-H,O-Z), INTEGER(I-N) were at the beginning of the program. This state is in effect unless an IMPLICIT statement changes the above interpretation; i.e., identifiers, whose types are not explicitly declared, are typed as follows. a. Identifiers beginning with I, J, K, L, M, or N are assigned interger type. b. Identifiers not assigned integer type are assigned real type. If the program contains an IMPLICIT statement, this statement will override throughout the program the implicit state initially set by the compiler. No program may contain more than one IMPLICIT declaration for the same letter. 5- 69 / CHAPTER 7 SUBPROGRAM STATEMENTS FORTRAN subprograms may be either internal or external. Internal subprograms are defined and may be used only within the program containing the definition. The arithmetic function definition statement is used to define internal functions. External subprograms are defined separately from (i. e., external to) the programs that call them, and are complete programs which conform to all the rules of FORTRAN programs. They are compiled as closed subroutines; i.e., they appear only once in the object program regardless of the number of times they are used. External subprograms are defined by means of the statements FUNCTION and SUBROUTINE. 7.1 DUMMY IDENTIFIERS Subprogram definition statements contain dummy identifiers, representing the arguments of the subprogram. They are used as ordinary identifiers within the subprogram definition and indicate the sort of arguments that may appear and how the arguments are used. The dummy identifiers are replaced by the actual arguments when the subprogram is executed. 7.2 LtBRARY SU BPROGRAMS The standard FORTRAN IV library for the PDP-10 includes built-in functions, FUN~TION subprograms, and SUBROUTINE subprograms, listed and described in Chapter 8. Builf-in functions are open subroutines; that is, they are incorporated into the object program each time they are referred to by the source program. FUNCTION and SUBROUTINE subprograms are closed subroutines; their names derive from the types of subprogram statements used to define them. 7.3 ARITHMETIC FUNCTION DEFINITION STATEMENT The arithmetic function definition statement has the form: identifier(jdentifier, identifier, ••• }=expression 5-71 This statement defines an internal subprogram,. The entire definition is contained in the single statement. The first identifier is the name of the subprogram being defined. Arithmetic function subprograms are single-v~lued functions with at least one argument. The type of the function is determined by the type of the function identifier. The identifiers enclosed in parentheses represent the arguments of the function. These are dummy identifiers; they may appear only as scalar variables in the defining expression. Dummy identifiers have meaning and must be unique only within the defining statement. Dum'my identifiers must agree in order, number, and type with the actual arguments given at execution til1le. Identifiers, appearing in the defintng expression, which do not represent arguments are treated as ordinary variables. The defining expreSsion may include external functions or other previously defined arithmetic statement functions. All arithmetic function definition statements must precede the first executable statement of the program. Examples: SSQR(K)=K*(K+1)*(2*K+l )/6 ACOSH(X)=(EXP(X/A)+EXP(-X/A))/2 In the last example above, X is a dummy identifier and A is an ordinary identifier. At execution time, the function is evaluated using the current value of the quantity represented by A. 7.4 FUNCTION SUBPROGRAMS A FUN<;:TION subprogram is a single-valued function that may be called by using its name as a function name in an arithmetic expression, such as FUNC(N), where FUNC is the name of the subprogram that evaluates the corresponding function of the argument N. A FUNCTION subprogram begins with a FUNCTION statement and ends with an END statement. It returns control to the calling program by means of one or more RETURN statements. 7.4.1 FUNCTION Statement The FUNCTION statement has the form: FUNCTION identifier(argument ,argument, ••. ) This statement declares the program which follows to be a FUNCTION subprogram. The identifier is the name of the function being defined. This identifier must appear as a scalar variable and be assigned a value during execution of the subprogram which is the function value. 5-72 Arguments appearing in the list enclosed in parentheses are dummy arguments representing the function argument. The arguments must agree in number, order, and type with the actual arguments used in the calling program. FUNCTION subprogram arguments may be expressions, alphanumeric strings, array names, or subprogram names. Dummy arguments may appear in the subprogram as scalar identifiers, array identifiers, or subprogram identifiers. A function must have at least one dummy argument. Dummy arguments representing array names must appear within the subprogram in a DIMENSION statement, or one of the type sta.tements that provide dimension information. Dimensions given as constants must equal the dimensions of the corresponding arrays in the calling program. In a DIMENSION statement, dummy identifiers may be used to specify adjustable dimensions for array name arguments. For example, in the statement sequence: FUNCTION TABLof(A,M, N, B,X, Y} DIMENSION A(M,N}, B(10),C(50) The dimensions of array A are specified by the dummies M and N, while the dimension of a~ray B is given as a constant. The various yalues given for M and N by the calling program must be those of the actual arrays which the dummy A represents. The arrays may each be of different size but must have two dimensions. The arrays are dimensioned in the programs that use the function. Dummy dimensions may be given only for dummy arrays. In the example above the array C must be given absolute dimensions, since C is not a dummy identifier. A dummy identifier may not appear in an EQUIVALENCE statement i~ the FUNCTION subprogram. A function must not modify any arguments which appear in the FORTRAN arithmetic expression calling the function. Modification of implicit arguments from the calling program, such as variables in COMMON and DO loop indexes, is not allowed. The only FORTRAN statements not allowed in a FUNCTION subprogram are SUBROUTINE, BLOCK DATA, and another FUNCTION statement. 7.4. 1.1 Function Type - The type of the function is the type of identifier used to name the function •. This identifier may be typed, implicitly or explicitly, in the same way as any other identifier. Alternatively, the function may be explicitly typed in the FUNCTION statement itself by replacing the word FUNCTION with one of the following. INTEGER FUNCTION REAL FUNCTION COMPLEX FUNCTIO N LOGICAL FUNCTION DOUBLE PRECISION FUNCTION 5-73 For example, the statement COMPLEX FUNCTION HPRIME{S,N) is equivalent to the statements FUNCTION HPRIME(S, N) COMPLEX HPRIME Examples: 7.5 " FUNCTION MAY{RANGE,EP, YP,ZP) COMPLEX FUNCTION COT{ARG) DOUBLE PRECISION 'FUNCTION LIMIT{X, Y) SUBROUTINE SUBPROGRAMS A SUBROUTINE subprogram may be multivalued and can be referred to only by a CALL statement. A SUBROUTINE subprogram begins with a SUBROUTINE statement and returns control to the calling program by means of one or more RETURN statements. 7.5. 1 SUBROUTINE Statement The SUBROUTINE statement has the form: SUBROUTINE identifier(argument ,argument, ••• ) This statement declares the program which follows to be a SUBROUTINE subprogram. The first identifier is the subroutine name. The arguments in the list enclosed in parentheses are dummy arguments representing the arguments of the subprogram. The dummy arguments must agree in number, order, and type with the actual arguments used by the calling program. - - SUBROUTINE subprograms may ha'\i'e expressions, alphanumeric strings, array names, and subprogram names as arguments. The dummy arguments may appear as scalar, array, or subprogram identifiers. Dummy identifier:s which represent array names must be dimensioned within the subprogram by a DIMENSION 'or type declaration statement. As in the case of a FUNCTION subprogram, either constants or dummy identifiers may be used to specify dimensions in a DIMENSION statement. The dummy arguments must not appear in an EQUIVALENCE or COMMON statement in the SUBROUTINE subprogram. A SUBROUTINE subprogram may use one or 'more of its dummy identifiers to represent results. The subprogram name is not used for the J:'etum of results. A SUBROUTINE subprogram need not have any argument at all. 5-74 Examples: SUBROUTINE FACTOR(COEFF,N,ROOTS) SUBROUTINE RESIDU(NUM,N,DEN,M,RES) SUBROUTINE SERIES The only FORTRAN statements not allowed in a function subprogram are FUNCTION, BLOCK DATA, and another SU BRO UTI N E statement. 7.5.2 CALL Statement The CALL statement assumes one of two forms: CALL identifier CALL identifier (argument, argument, .•. ,argument) The CALL statement is used to transfer control to SUBROUTINE subprogram. The identifier is the subprogram name. The arguments may be expressions, array identifiers, alphanumeric strings or subprogram identifiers; arguments may be of any type, but must agree in number, order, type, and array size (except for adjustable arrays, as discussed under the DIMENSION statement) with the corresponding arguments in the SUBROUTINE statement of the called subroutine. Unlike a function, a subroutine may produce more than one value and cannot be referred to as a baiic element in an expression. A subroutine may use one or more of its arguments to return results to the calling program. If no arguments at all are required, the first form is used. Examples: CALL EXIT CALL SWITCH(SIN,2.LE. BETA,X**4, Y) CALL TEST(VALUE, 123,275) The identifier used to name the subroutine is not assigned a type and has no relation to the types of the arguments. Arguments which are constants or formed as expressions must not be modified by the subroutine. 7.5.3 RETURN Statement The RETURN statement has the form: RETURN This statement returns control from a subprogram to the calling program. Normally, the last statement executed in a subprogram is a RETURN statement. Any number of RETURN state'ments may appear in a subprogram. 5-75 7.6 ,BLOCK DATA SUBPRO~RAMS A BLOCK DATA subprogram is a data specific~tion subprogram and is used to enter initial values into variables in COMMON for use by FORTRAN subprograms and MACRO-lO main programs (see Chapter 9). No executab~e statements may appear in a BLOCK DATA subprogram. 7.6.1 BLOCK DATA Statement The BLOCK DATA statement has the form: BLOCK DATA This statement declares the program which follows to be a data specification subprogram and it must be the first statement of the subprogram (see Chapter 6, Section 6.2.2) . . 7.7 EXTERNAL STATEMENT FUNCTION and SUBROUTINE subprogram names may be used as the actual arguments of subprograms. Such subprogram names must be distinguished from ordinary variables by their appearance in an EX TERNAL statement. The EXTERNAL statement has the form: EXTERNAL identifier, identifier, .•. , identifier This statement declares the listed identifiers to be subprogram names. Any subprogram name given as an argument to anoJher subprogram mU,st have previously appeared in an external declaration in the calling program (i .e., as an identifier in an EXTERNAL or CALL statement or as a function name in an expression). Example: EXTERNAL SIN,COS CALL TRIGF(SIN, 1. 5, ANSWER) CALL TRIGF(COS, • 87, ANSWER) END .. SUBROUTINE TRIGF(FUNC,ARG,ANSWER) . ANSWER ' = FUNC(ARG) RETURN END 5-76 To reference external variables from a MACRO-lO program by name, place the variables in named COMMON. Use the name of the variable as the name of the COMMON block: COMMON /A/A /B/B (13) /C C(6,7) 7.8 SUMMARY OF PDP-10 FORTRAN IV STATEMENTS CONTROL STATEMENTS Section References General Form ASSIGN i to m 4.1.3 CALL name (a 1,a 2, ... ) 7.5.2 CONTINUE 4.4 DO i m=m 1,m 2 ,m 3 4.3 GO TO i 4.1.1 GO TO m 4.1.3 GO TO m, (i l' i2 , ... ) 4.1.3 GO TO (i 1,i 2, ... ),m IF (e 1)i 1,i 2,i 3 4.1.2 IF (e 2)s 4.2.2 PAUSE 4.5 4.5 4.5 7.5.3 4.6 4.7 PAUSE 4.2.1 i PAUSE 'h' RETURN STOP END DATA TRANSMISSION STATEMENTS General Form Section References ACCEPT f 5.2.9 ACCEPT f, list 5.2.9 BACKSPACE unit 5.3 DECODE (n,f,v)list ENCODE (n,f,v)list 5.4 5.3 5.4 FORMAT (g) 5.1.1 PRINT f 5.2.3 PRINT f, list 5.2.3 END FILE unit 5-77 Section References General Form PUNCH f 5.2.4 READ f 5.2.7 READ f, list 5.2.7 READ (unit, f) 5~2.7 READ (unit,f)list 5.2.7 READ (unit)list 5.2.7 READ (unit,name 1) READ (unit #R,f)list 5.2.7 READ (unit,f,END=c,ERR=d)list 5.2.7 READ (unit,f,END=c)list 5.2.7 READ (unit, f, ERR=d)1 ist 5.2.7 REREAD f,list 5.2.8 REWIND unit 5.3 SKIP RECORD unit 5.3 TYPE f 5.2.5 TYPE f,list 5.2.5 WRITE (unit,f) 5.2.6 WRITE (unit, f) list 5.2.6 WRITE (unit)list 5.2.6 WRITE (unit ,name 1) 5.2.6 WRITE (unit HR, f)list 5.2.6 UNLOAD unit 5.3 5.2.7 SPECIACATION STATEMENTS Section References General Form COMMON a(n , ,n 2,.· . ),b(n 3,n4 , .•• ), ••• 6.1.2 COMPLEX a(n 1, n2, .•. ),b(n 3 ,n4" •• ), ••• DATA t,u, ..• ;1 1.0 IN MAGNITUDE ASIN OF ARG > 1.0 IN MAGNITUDE 8 ACOS OF ARG NOTE nnnnnn = location at which the error occurred. After two typeouts of a particular error message, further typeout of that error message is suppressed. At the end of execution, a summary listing the actual number of times each error message occurred is typed out. If the user wishes to permit more than two type outs for each error message, he may do so by calling the routine ERRSET at the beginning of the executable.part of his main program. ERRSET accepts one argument in integer mode. This argument is the number of typeouts that are permitted for each error message before suppression occurs. This routine is used to obtain the PC information which would otherwise be lost, Alternatively, because of the slowness of the Teletype output, the user may wish to suppress typeout of the messages entirely. This can be done by' calling ERRSET wrth an argument of zero. Suppression of typeout can also be accomplished during execution by typing to on the Teletype. Error messages and the summary are output to the Teletype (or the output device when running BATCH), regardless of the device assignments that have been made. 5-122 The treatment of overflow, underflow, and divide check errors in MACRO programs (those that are loaded with OVTRAP) can, to a certain extent, be manipulated by the user. (See OVTRAP in the Science Library and FORTR~O\.N Utility Subprogram manual.) 5-123 CHAPTER 12 RELATED FEATURES OF THE PDP-l0 12.1 ASCII CHARACTER SET Table 12-1 ASCII Character Set SIX BIT Character 00 01 02 03 04 05 06 07 Space ! ASCII 7-Bitt SIX BIT Character @ II $ % 043 & 046 047 40 41 42 43 44 45 46 47 50 51 52 53 54 55 56 57 H I P Q R S T U V " I 040 041 042 044 045 10 11 12 13 14 15 16 17 / 050 051 052 . 053 054 055 056 057 20 . 21 22 23 24 25 26 27 0 1 2 3 4 5 6 7 060 061 062 063 064 065 066 067 60 61 62 63 64 65 66 67 30 31 32 33 34 35 36 37 8 9 070 071 072 073 074 075 076 077 70 71 72 73 74 75 76 77 tFORTRAN IV also ( ). * + , - : ; < = > ? A B C D E F G J K L M N 0 W X Y Z [ \ ] f - ASCII 7-Bitt Character 100 101 102 103 104 105 106 107 \ 110 111 112 113 114 115 116 117 h i a b c d e f g i k I m n 0 120 121 122 123 124 125 126 127 p q r 5 t u v w 130 131 132 ]33 134 135 136 137 x y z { I } ....., Delete ac~epts the following control codes in 7-bit ASCII: Horizontal Tab Line Feed 011 012 Carriage Return Form Feed 5-125 015 014 ASCII 7-Bitt 140 141 142 143 144 145 146 147 150 151 152 153 154 155 156 157 160 161 162 163 164 165 -166 167 170 171 172 173 174 175 176 177 12.2 PDP-lO WORD FORMATS BASIC INSTRUCTIONS r INSTRUCTION CODE (INCLUDING MODEl 35 IN-OUT INSTRUCTIONS 1111 111 0 I' NS~~~iTlON II I DEVICE CODE 9 10 2 3 12 13 14 r K I 17 18 35 PC WORD flAGS • 10 I 0 I 0 I 0 I 01 17 18 ----------------- I PC 12: 13 35 BLT POINTER [XWD} SOU RCE ADDRESS DESTINATION ADDRESS )5 17 18 BLK 1/ BLKO POINTER, PUSHDOWN POINTER, DATA CHANNEL CONTROL WORD [IOWD} I - WORD COUNT ADDRESS-l 17 18 35 BYTE POINTER POSITION P I r SIZE S -5 6 '1 12 13 14 17 1e 35 BYTE STORAGE I--s I P BITS BITS BYTE 35 P-$-1 NEXT BYTE 35-P 35-P" 35 FIXED POI NT OPERANDS SIGN BINARY NUMBER (TWOS COMPLEMENT) O. 1- o 1 35 FLOATING POINT OPERANDS SIGN EXCESS 128 EXPONENT ,O· FRACTION (TWOS COMPLEMENT) 10NES COMPLEMENT} o , 8 9 35 LOW ORDER WORD IN DOUBLE LENGTH FLOATING POINT OPERANDS o o EXCESS 128 EXPONENT-27 IN POSITIVE FORM 1 LOW ORDER HALf Of fRACTION (TWOS COMPLEMENT 1 8 9 35 5-126 12.3 FORTRAN INPUT/OUTPUT In addition to the arithmetic functions, the PDP-10 FORTRAN IV library (LIB40) contains several subprograms which control FORTRAN IV I/O operations at runtiml". The I/O subprograms are compC!tible with the PDP-10 Monitors. In general FORTRAN IV I/O is done with double buffering unless the user has either specified otherwise through calls to IBUFF and OBUFF or is doing random access I/O to the disk. In these cases, sin~le buffers are used. The standard buffer sizes for the devices normally available to the user are given in Table 12-2. Note that the devices and buffer sizes are determined by the Monitor and may be changed by a particular installation. Also a user may specify buffer sizes for magtape operations through the use of IBUFF and OBUFF. The logically first device in a FORTRAN program is initialized on software I/O channel one, the second on software I/O channel two, and so forth. Software I/O channel 0 is reserved for error message and summary output. The SIXBIT name of the device that is initialized on channel N can be found in a dynamic device table at location DYNDV. + N. A device may be initialized for input and output on the same I/O channel. Devices are initialized only once and are released through either the CALL [SIXBIT/EXIT/J executed at the end of every FORTRAN program or the LIB40 subroutine RELEAS. Table 12-2 PDP-10 FORTRAN IV Standard Peripheral Devices Name Mnemonic Input/Output Formatted Unformatted Buffer Size In Words Operation Card Punch CDP Yes Yes 26 WRITE Card Reader CDR Yes Yes 28 READ Disk (includes disk packs and drums) DSK Yes Yes 128 READ,lWRITE DECtapes DTA Yes Yes 127 READ,lWRITE line Printer LPT Yes No 26 WRITE Magtape MTA Yes Yes 128 READ,lWRITE Plotter PLT Yes Yes 36 WRITE Paper Tape Punch PTP Yes Yes 33 WRITE Paper Tape Reader PTR Yes Yes 33 READ Pseudo Teletype PTY Yes No 17 READ,lWRITE Teletype - User TTY Yes No 17 READ,lWRITE Teletype - Console CTY Yes No 17 READ,lWRITE 5-127 12.3.1 Logical and Physical Peripheral Device Assignments Logical and physical device assignments are controlled by either the user at runtime or a table called DEVTB. The first entry in DEVTB. is the length of the table. Each en~ry after the first is a sixbit ASCII device name. The position in the table of the devi ce name corresponds to the FORTRAN logical number for that device., For example, in Table 12-3, magnetic tape 0 is the 16th entry in DEVTB. Therefore, the statement WRITE (16, 13)A refers to magnetic tapeO. The last five entries in DEVTB. correspond to the special FORTRAN statements READ, ACCEPT, PRINT, PUNCH, and TYPE. Any device assighments may be changed by reassembling DEVTB. If the user gives the Monitor comma~d ASSIGN DSK 16 prior to the running of his program, a file named FOR16. DAT would be written on the disk. Similarly, the Monitor command ASSIGN LPT 16 causes output to go to the line printer. 12.3.2 DECtape dnd Disk Usage 12.3.2.1, Binary Mode - In binary mode, each block contains 127 data words, the first of which is a record control word of the form: w n where w is the word count specifying the number of FORTRAN data words in the block (126 for a full block) and n is 0 in all but the last block of a logical record, in which case n is the number of blocks in the logical record. (A logical record contains all the data corresponding to one READ or WRITE statement.) 12.3.2.2 ASCII Mode - In ASCII mode, blocks are packed with as many full lines (a line is a unit record as specified by a format statement) as possible. Lines always begin with a' new word. If a line terminates in the middle of a word, the word is filled out with null characters and the next line begins with the next word. Lines are not split across blocks. 5-128 Table 12-3 Device Table for FORTRAN IV TITLE SUBITL DEVTB V.Ol? l-APR-69 ENTRY ENTRY ENTRY P=1? DEVTB. ,DEVND. ,DEVLS. ,DVTOT. MTABF., MBFBG., TABPT., TABP1. MTACL. ,DATTB., NEG1. ,NEG2. ,NEG3., NEG5. DEVTB. : EXP DEVND. -. SIX BIT SIXBn SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIXBn SIX BIT SIX BIT SIX BIT SIX BIT SIXBn SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT .DSK. .CDR. .LPT. .CTY. .TTY. .PTR. .PTP. · DIS. · DTA l. .DTA2. .DTA3. .DTA4. .DTA5. .DTA6. .DTA7. .MTAO. .MTAl. .MTA2. ."FORTR. SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT SIX BIT .DSKO. · DSK l. .DSK2. .DSK3. .DSK4. .DEV1. .DEV2. .DEV3. .DEV4. .DEV5. .REREAD. .CDR. .TTY. · LPT. .PTP. .TTY. CORPOS: LPTPOS: TTYPOS: PTPPOS: DEVLS. : DEVND.: ;NO. OF ENTRIES ;LOGICAL# /FILENAME/DEVICE DISC ; 1 FOROL DAT CARD READER ; 2 FOR02. DAT LINE PRINTER ; 3 FOR03. DAT ; 4 FOR04. DAT CONSOLE TELETYPE ; 5 FOR05. DAT USER TELETYPE ; 6 FOR06. DAT PAPER TAPE READER PAPER TAPE PUNCH ; 7 FOR07. DAT ; 8 FOR08. DAT DISPLAY ; 9 FOR09. DAT DECTAPE ; 10 FOR10.DAT ; 11 FORll. DAT ; 12 FOR12.DAT ; 13 FOR13.DAT ; 14 FOR14. DAT ; 15 FOR15.DAT MAGNETIC TAPE ; 16 FOR16.DAT i 17 FOR17.DAT i 18 FOR18.DAT ; 19 FORTR.DAT ASSIGNABLE DEVICE, FQRTR ; ; ; ; ; ; ; ; ; ; 20 21 22 23 24 25 26 27 28 29 FOR20.DAT FOR21 . DAT FOR22.DAT FOR23.DAT FOR24. DAT FOR25. DAT FOR26. DAT FOR27.DAT FOR28.DAT FOR29.DAT -6 -5 -4 -3 -2 -1 DISK ASSIGNABLE DEVICES V.OO6 REREAD READ ACCEPT PRINT PUNCH TYPE 12.3.2.3 File Names - File names may be declared for DECtapes or the disk through the use of the library subprograms IFILE and OALE. In order to make an entry of the file name FILE1 on unit u, t~e following statement could be used: 5-129 CALL OALE (u,FILE1) Similarly, 'the following statements might be used to open the file, RALPH, for reading: RALPH=5HRALPH CALL IFILE(u,RALPH) After writing a file, the END FILE u statement must be given in order to close the current file and allow for reading or writing another file or for reading or rewriting the same file. If no call to IFILE or OFILE has been given before the execution of a READ or WRITE referencing DECtape or the disk the fi Ie name FORnn. DAT is assumed where nn is the FORTRAN logical number use.d in the I/O statement that references device nn. The FORTRAN programmer can make logical assignments such that each device has its own unique file as intended, but each can be on the DSK. In order to use the-devices available, the programmer can make assignments at run time and assign the DSK to those not available. For example, the FORTRAN logical device numbers, e.g., 1 = DSK, 2 = CDR, 3 = LPT, are used in the file name. The written file names are FOROl.DAT, FOR02.DAT, etc. The same is true for READ. For example, a WRITE (3, 1) A, S, C, in the FORTRAN program generates the file name FOR03.DAT on the DSK if the DSK has been assigned LPT or 3 prior to running the program. (Note: REREAD rereads from the file belonging to the device last referenced in a READ statement, not FOR-6. DAT, as usual.) The programmer must, of course, realize his own mistake in assigning the DSK as the TTY in the case that FORSE tries to type out error messages or PAUSE messages. More than one DSK File may be accessed, without making logical assignments at runtime, by using logical device numbers 1, and 20 through 24 in the FORTRAN program. Logical device number 19 refers to logical device FORTR which must be assigned at runtime and accesses file name FORTR.DAT to maintain compatibility with the past system of default file name FORTR. DAT. In all cases when the operating system fails to find a file specified, an attempt will be made to read from file FORTR.DAT as before. The magnetic tape operation REWIND is simulated on DECtape or the disk. Thus, a program which uses READ, WRITE, END FILE, and'REWIND for magnetic tape need only have the logical device number changed or assigned to a MTA at runtime in order to perform the proper input/output sequences on DECtape or the disk. 12.3.3 Magnetic Tape Usage Magnetic tape and disk/DECtape I/O are different in the following ways. When a READ is issued, a record is read,in for both magnetic tape and disk. If a WRITE is then issued, the next sequential record is written on magnetic tape but not on disk. When one or more READs have been executed on a disk file and a WRITE is issued, the file is closed prior to the WRITE and then reopened. The WRITE causes the writing over of the first logical record in that file. 5-l30 12.3.3.1 Binary Mode - The format of binary data on magnetic tape is similar to that for DECtape except that the physical record size depends on the magnetic tape buffer size assigned in the Time-Sharing Monitor or by IBUFF/OBUFF (see Section 8.2.2). Normally, the buffer size is set at either 129 or 257 words so that either 128 or 256 word records are written {containing a control word and 127 or 255 FORTRAN data words}. The first word, control. word, of each qlock in a binary record contains information used by the operating system. The left half o~ the first word contains the word count for that block. The right half of the first word con- tains a nuJI character except for the last block in a logical record. In this case, the right half of the first word contains the number of blocks in the logical record. 12.3.3.2 ASCII Mode - The format for ASCII data is the same as that used on DECtape. 12.3.3.3 Backspacing and Skipping Records - Both the BACKSPACE u and SKIP RECORD u statements are ex- ecuted on a logical basis for binary records and on a line basis for ASCII records. a. Binary Mode - Both BACKSPACE and SKIP RECORD space magnetic tape physically over one (1) logical record; i.e., the result of one WRITE (u) statement. b. ASCII Mode - ASCII records are packed, that is WRITE (u, f) statements do not cause physical writing on the tape until the output buffers are full or a BACKSPACE, END FILE, or REWIND command is executed by the program. BACKSPACE and SKIP RECORD on ASCII record space over one (1) line. c. BACKSPACE and SKIP RECORD following WRITE ASCII commands. (1) BACKSPACE closes the tape, writes 2 EOF's (tapemark) and backspaces over the last line. (2) SKIP RECORD cannot be use~ during a WRITE operation. This is an input function only. 5-131 12.4 PDP-10 INSTRUCTION SET MOVl ~ Negat.ive e Magnttude e Swapped 1--------, Right} {Right} Half word { Left to Left I 1 to AC f- no effect Ones Zeros ADD SUBtract • MULtiply 1 Immediate to AC to Memory to Self Extend sign BLock Transfer' EXCHange to Memory ~~~:~:~: ~~ract 1["'d Roood I~>:th Floating MultiPly Floating DiVide and memory AC ~I--Immediate Integer MULllply DiVide Integer DIVIde to Memory to Both use present pOinter} d I LoaD Byte mto AC . Increment pointer an i DePosit Byte in memory Floating SCale Increment Byte Pointer Unnormalized Floatmg Add PUSH down} POP up f -- 1and Jump Double Floating Negate - Ant~lmetic .SHift LogIcal SHIft ROTate I{C b' d om me Zeros Ones SETto Ac Memory Complement of Ac Complement of Memory 1 l AC I to AND } ;ith Complement of Ac inclusive OR with Complement of Memory .Complements of Both I AC Immediate Memory Both .. Inclusive OR eXclusive OR - - - - - - - - - - - - ' EQuiValence SKlPifmemoryl _______________~ JUMP if AC f Add One to \ {memory and SkiP} 'f Subtract One from AC and Jump . 11Immediate } . '. and skIp If ACCompare Ac \ . h M WIt emory never Less Equal Less or Eqwil Always Greater Greater or Equal Not equal .lest AC I I with Direct mask with Swapped mask Righ tWIt .hE Left with E eXeCuTe DATA} BLocK : { { I n I 5-132 • Out . 111 No modification set masked bits to Zeros d k' an s Ip set masked bits to Ones Complement masked bits I HALT (JRST 4,) CONditions . {POSitive . Add One to Both halves of AC and Jump If N egatJve T to SubRoutine and Save Pc and Save Ac and Restore Ac if Find First One on Flag and Clear it on OVerflow (JFCL 10,) Jump on CaRrY 0 (JFCL 4,) on CaRrY I (JFCL 2.) on CaRrY (JFCL 6,) on Floating OVerflow (JFCL I.) and ReSTore and ReSTore Flags (JRST 2,) and ENable PI channel (JRST 12.) . d Sk' 'f all masked bits Zero an Ip I \ some masked bit One Inever if all masked bits Equal 0 if Not all masked bits equal 0 Always , I APPENDIX A THE SMALL FORTRAN IV COMPILER This compiler runs in S. SK of core, and to the user, is identi cal to the large compi ler, with the exception of the following language differences. Operating procedures are given in the Systems User's Guide (DEC-l0-NGCC-D). Language Differences The IMPLICIT , DATA, and NAMELIST statements are not recognized; constant strings are not collapsed (for example, A=S*3 will not be treated as A=lS). 5-133 Book 6 Demonstration Programs • - \ rhe following demonstration programs illustrate the flexibility of the PDP-lO software system. Each demonstration is aimed at a specific class of user and should be studied with this in mind. Demonstration #1 is an elementary FORTRAN main program and subroutine. It is intended for a beginning programmer interested in creating and editing files with LINED. The subroutine calculates the sum of the square of twenty numbers and returns the answer to the main program. The main program prints this answer on the Teletype. A bug is found in the subroutine and cQrrected with elementary LINED commands. Demonstration #2 is a FORTRAN program which fits a curve to a set of points by the method of least squares. LINED is used to edit and debug the program. This demonstration was created for the applications programmer or th~ engine€r with some mathematical background. There are four sections within the program; each section can be examined separately without detracting from the reader's comprehension. Demonstration #3 is an advanced example of the procedure used for creating a FORTRAN main program and a MACRO-10 subprogram. It is. intended primarily for the experienced systems programmer. The two programs are inputted using TECO (Text Editor and- Corrector) and then translated and executed together. A listing file is created for each program in case a bug is encountered during execution. Since a bug is found, the listings, along with DDT (the Dynamic Debugging Techn ique program), are used to debug the program. The erroneous program is then corrected with TECO and saved on the disk for later use. For a complete description of DDT, see the PDP-10 Reference Hardbook. Demonstration #4 is an advanced demonstration of a FORTRAN subroutine that is used to return a random number, and a FORTRAN testing program that tests the accuracy of the subroutine. This demonstration is intended for the experienced programmer familiar with DDT and TECO. The two programs are inputted using TECO and then executed together. Errors are detected by the FORTRAN compiler and corrected with advanced TECO commands. Execution is again attempted, but now the program returns incorrect results. Cross-reference listings, along with advanced DDT commands, are used to debug the program. The program is then permanently corrected with TECO and saved on the disk for future use. 6-3 Demonstration , 1 tC .LOGIN 4SP74G JOB 10 #27,235 PASSWORD: 1525 05-MAR-70 TTY~5 PLEASE DELETE ANY FILES THAT ARE NOT NEEDED FROM YOUR DISK AREA ••• • CREATE MAIN.F4 *1 00010 00020 00030 00040 00050 00060 0121070 TYPE 69 FORMATe' THIS PROGRAM PRINTS THE SUM OF THE SQUARES') CALL SUB1CISUM) TYPE 70,ISUM FORMATe' THE SUM OF THE SQUARES IS',3X,I5) END 69 70 $ .CREATE SUB1.F4 *1 00010 00020 0012130 00040 12101215121 0121060 00070 11210 SUBROUTINE SUBRCJ) J=0 DO 100 1=1,20 J=J+I**2 CONTINUE RETURN $ .EXECUTE MAIN.F4,SUB1.F4 FORTRAN: MAIN.F4 SUB1.F4 FORTRAN: LOADING 000001 UNDEFINED ~LOBALS 6-4 Establish communication with the monitor by typing tC while depressing the CTRL key. Begin the login procedure by typing the monitor command LOGIN followed by a carriage-return. The monitor responds with your job number and the mon itor name and version number. The login program requests your identification by typing the number sign (#). Type in your project programmer numbers, followed by a carriage-return. The login program requests your password. Type it in; to maintain password security, it is not printed. If your identification matches the identification stored in the system, the monitor responds with the time, date, Teletype number, message of the day (if any), and a period. CREATE a new disk file with LINED. Call the new file MAIN.F4. Command to LINED to insert line numbers starting with 10 and incrementing by 10. Statements of the FORTRAN main program. The Altmode ends t.he insert. Command to LIN ED to end the creation of the file and to write the fi Ie on the disk. Return to monitor. CREATE a disk file for the subroutine. Call the file SUB1.F4. Command to LINED to insert line numbers starting with 10 and incrementing by 10. Statemenfs of the FORTRAN subroutine. Altmode ends the insert. LIN ED command to end the creation of the file and to write the file on the disk. Return to monitor. Request execution of the two progra·ms created. FORTRAN reports its progress. 6-5 SUB 1 000156 ? LOADER 4K CORE ?EXECUTION DELETED EXIT tC .EDIT SUB1.F4 *P10 11'00111' *110 11'011'111' , $ 11'11'11'211' SUBROUTINE SUBR(J) SUBROUTINE SUB! (J) .EXECUTE MAIN.F4,SUB1.F4 FORTRAN: SUB1.F4 LOADING LOADER 4K CORE EXECUTION THIS PROGRAM PRINTS THE SUM OF THE SQUARES THE SUM OF THE SQUARES IS 2870 EXIT tC .KJOB CONFIRM: K JOB 111', USER (27,235J LOGGED OFF TTY25 15411' 5-MAR-70 DELETED ALL 6 FILES (INCLUDING UFD, 7. DISK BLOCKS) RUNTIME ,0 MIN, 04.95 SEC 6-6 There is no subroutine named SUBl This includes the space for the Loader. No execution was done. Ask to edit SUB 1. F4 Type line 10 on the Teletype. Insert a new line 10. Request execution. Only the subroutine is recompiled since it has been edited. Both MAl Nand SU Blare loaded. Execution begins. Execution ends. Issue KJOB command to log off the system. Answer the CONFIRM: message with K and a carriage-return if you wish to delete all files you have created. See the following demonstrations for other options available with the KJOB command. 6-7 Demonstration 112 " tC .LOGIN DEC PDP-10 #40 4561H PR JOB 7 . #27 .. 20 PASSWORD: 0927 29-0CT-69 TTY3 .CREATE SAMPLE.F4 *110 6-8 Introduction Given a set of n sample points [(xl' Yl),(x 2'Y2) ••• (x n 'Yn») lates the coefficients of the quadratic equation, a 1+a minimizes the expression r this demonstration program calcu+a3x 2) such that the value of 01 a 2 ,a 3 This method of minimizing a 1,a 2 ,a 3 is called least squares. The program logically divides into four sections. Section 1 sets up a set of simultaneous equations (the normal equations); section 2 solves the equations for a I' a 2 , a 3 • The polynomial approximation (a l+a +a 3x 2) and the sample points are graphed in section 3. In section 4, a subroutine evaluates 3x3 determinates. r The programmer logs into the system by typing LOGIN (abbreviated LOG); the monitor responds by typing the ·job number assigned to the programmer and a version number of the monitor. Following the printout of a # symbol, the programmer types his project-programmer number. The monitor types PASSWORD: and awaits'an entry. The programmer then-types his password (echo typeout suppressed). If the password and project-programmer number match correctly with the password and project-programmer number stored in the system, the monitor types out the time, the date and the number of the Teletype. The monitor may also type out. some other information (the message of the day) before awaiting a command. the monitor command: CREATE SAMPLE.F4 ca lis in LI N ED and opens file SAMPLE for creation. The extension F4 marks the fi Ie as FORTRAN. The monitor responds to the CREATE command by typinS an * indicating that a LINED instruction is now to be typed. Th~ LINED command 110 will begin line numbering at 10, incrementing by 10 for each new line. An explanation of the mathematical ca Iculafions is given for each section. Note: not all variables which appear in the explanation appear in the program. When the same variables occur in both the explanation and program, they occur in lower case in the explanation and, by necessity, occur in upper case in the program. 6-9 00010 00020 00030 00040 00050 00060 00070 00080 00090 00100 , 00110 00120 00130 00140 00150 00160 00170 00180 00190 00200 00210 00220 00230 00240 00250 00260 0027121 00280 00290 00300 00310 00320 00330 00340 00350 00360 00370 00380 00390 c c c c c c c c c C C C C C C C C C 10 20 30 40 500 510 520 530 THIS PROGRAM FITS A QUADR4TIC POLYNOMIAL ('THE APPROXIMATION POLYNOMIAL') TO A SET OF SAMPLE POINTS BY THE METHOD.OF LEAST SQUARES. ***SECTION 1*** THE ELEMENTS'OF Z,X,IX,TEMP ARE INITIALIZED TO ZERO BY THE DIMENSION STATEMENT. DIMENSION Z(3,4),X(9,4),IX(9,4),A(4),TEMP(3) COMMON Z TYPE 500 N IS THE NUMBER OF SAMPLE POINTS. N CAN NOT BE GREATER THAN 9 CTHIS RESTRICTION IS IMPOSED BY FORMAT 510). FORMAT 500 WILL BE TYPED ON THE TELETYPE TO INDIC~TE WHEN THE USER IS TO ENTER THE DATA FOR N. ACCEPT 510,N FORMAT 520 WILL BE T-YPED ON THE TELETYPE TO INDICATE WHEN THE USER IS TO ENTER THE SAMPLE POINTS. TYPE 520 ACCEPT 530,(XCI,2),XCI,4),I=1,N) DO 10 1=1, N THE TWO STATEMENTS BELOW ROUND THE X AND Y COORDINATES OF THE SAMPLE POINTS TO THE NEAREST INTEGER. IXCI,1) AND IXeI,2) WILL BE USED F.OR GRAPHING. IXeI,1)=IFIXCXCI,2)+.5) IX(I,2)=IFIX(XCI,4)+.5) XCI,1)=l XCI,3)=XCI,2)**2 DO 40 1=1,3 DO 30 K=1 .. N DO 20 L=1,4 zeI,L)=Z(I,L)+XCK,L)*X(K,l) CONTINUE CONTINUE FORMATelX,'NUM. OF POINTSlFORMATCI1)l2 $ .EXECUTE SAMPLE.F4 FORTRAN: SAMPLE.F4 01170 121-2 SUBROUTINE IS NOT A SEPARATE PROGRAM COMMON Z 121118121 A-2 ATTEMPT TO ENTER A VARIABLE INTO COMMON TWICE DIMENSION Ze3,4),B(4) 01190 1211280 SUBROUTINE DETR(DEE> 2121121 1-2 ARRAY NAME ALREADY IN USE B(K)=Z(2,M) t 1211290 ~IN. S-1 SYNTAX B(K+2)=Z(3,M) S-1 SYNTAX ERRORS DETECTED: 5 ? TOTAL ERRORS DETECTED:5 LOADING 12100002 UNDEFINED GLOBALS B DETR 000556 00121276 ? LOADER 5K CORE?EXECUTION DELETED EXIT tC 6-18 Th is system of determ inants reduces further: + To return to LINED command mode, the programmer types an ALTMODE ($) and LINED returns a *. Upon reviewing the listing, the programmer discovers that a line has been omitted after 1140. A new line, line 1141, is inserted for the omitted coding. After line 1141 is typed, LINED responds with line number 1151. The double quote after the line number 1151 indicates a pre-existing line has been skipped (line 1150). file by typing an E. A control C The Monitor command: (t C) The programmer closes the returns the program to monitor level. EXECUTE SAMPLE. F4 initiates loading and execution of SAMPLE. F4. Five errors are detected in SAMPLE. F4, however, terminating the program before execution. The errors are generated by the omission of an END statement. This omission has led the FORTRAN compiler to consider the main program and the subroutine as one program; hence the messages: "ATTEMPT TO ENTER VARIABLE INTO "UNDEFINED GLOBALS", and "ARRAY ALREADY IN USE." COMMO~ Since the DIMENSION statement is in error, any use of array b generates additional errors. 6-19 TWICE", '.EDI T SAMPLE. F4 *11145 01145 END 01155" $ *E *tC .EXECUTE FORTRAN: SAMPLE.F4 LOADING LOADER 5K CORE EXECUTION NOM. OF POINTS;FORMAT( 11 );2 SAMPLE.REL 6. BLKS :P SAMPLE.BAK <055> 10. BLKS SAMPLE.F4 <055> 10. BLKS :P JOB 7, USER 27, 20 OFF TTY3 AT 29-0CT-69 DELETED 1 FILES SAVED 2 FILES (INCLUDING UFD, 28. DISK BLOCKS) RUNTIME 0 MIN, 20.29 SEC .. 6-.24 The programmer logs off the Teletype with the Monitor command: KJOB. The Monitor asks for confirmation, CON FIRM: The programmer types a carriage return causing the Monitor to type an explanation and then ask again for a confirmation. Since the programmer typed an I, the Monitor responds with SAMPlE.REl <055> 6. BlKS: SAMPlE.REl is the relocatabJe binary file of the source program SAMPlE.F4. SAMPlE.REl uses six disk blocks (6. BlKS:). The octal number in angular brackets is the protection code. Protection code 055 means the fi Ie is sharable (the file can be read from or written on by a programmer with any project-programmer number). Typing a P following the colon changes the protection to 455 meaning that only a programmer logged in under the present project programmer number can write on the file. After the programmer types the P and a carriage return, the Monitor prints: SAMPlE.BAK < 055 > 10. BlKS: SAMPlE.BAK is a backup file. The backup file is the next-to-Iast closed file. In this case, the backup file is the FORTRAN file without the addition of lines 445, 1142, 1143, 1144 and the change of line 450.! The programmer deletes file SAMPLE .BAK. The Mon itor types SAMPlE.F4 <055> 10. BlKS: By typing a P, the programmer saves and protects the current FORTRAN source file. The Monitor then types the terminating message which includes the total number of disk blocks saved (The User File Directory, UFO, uses two blocks). 6-25 Demonstration #3 (Advanced) • fC .LOGIN JOB 14 4SP74G 640PROD 627~ 560 PASSWORD: 121859 23-FEB-70 TTY11 .MAKE MO DULO *IC C ROUTINE TO TYPE IN TWO INTEGERS AND TO TYPE OUT NI MODULO N2. 1 5. TYPE 5 FORMA T C' TYPE Nl AND N2' II> ACCEPT 10~NI~N2 FORMATC2I) M=MODCNl ~N2) TYPE 20~N1 ~N2~M FORMATC1X~ I5~' MOD • I5~' IS • 151/) GO TO 1 END 1121 2121 NI~N2 $$ *EX$$ EXIT fC' .MAKE MACSUB.MAC *1 ;MOD SUBROUTINE WITH STANDARD FORTRAN CALLING SEQUENCE ;FORTRAN STATEMT M=MOD(Nl~N2) ;RESULTS IN CALL TO MOD IN THE FORM ; JSA I6~MOD ; ARG eJ~NI ; ARG 0~N2 ;THUS UPON ENTRY TO MOD~ ACI6 POINTS TO NI ;THE REMAINDER OR "MOD" FUNCTIO:\T IS RETUrtNED IN AC0 ;AS THE RESULT OF DIVIDING NI tIN ACI7) BY N2. ;ENTRY POINT FOR LOADER ENTRY MOD 121 MOVEM I 7 ~ SAVI 7 ; SAVE ACl7 MOVE 17~@(l6) ;PICK UP Nl IDIV 17~@ 000000 ;DIVIDE BY"N2 (R IDIV 17,@(l6) 000000 000006' 000002 000000 MOVE l7,SAVl7 JRA. 16,2(16) SAV17: ;RESTORE AC17 ;RETURN TO CALLI 0 END NO ERRORS DETECTED PROGRAM BRK4K IS 000007 .MAIN" MA.CRO.V40 09:14 23-FEB-70 PAGE 2 SYMBOL TABLE ~CSUB.MAC MOD -000000' ENT SA.V17 000006' The error seems to be here. In line 000003 a 1 has been om itted between the @ and the ( 16 ). A patch is inserted In the program with DDT to check its va lid ity. 6-33 • • DEBUG MODULO,MACSUB.MAC LOADING ., LOADER 4K CORE EXECUTION .MAIN$: MOD+3/ $G IDIV 17,@0(16) IDIV 17,@1(16) TYPE N1AND N2 10 3 10 MOD 3 IS TYPE N1 AND N2 12 8 12 MOD 8 IS 4 TYPE N1 AND· N2 43762 10822 43762 MOD 10822 IS 474 TYPE Nl AND N2 tC .TECO MA.CSUB.MAC *JSIDIV 17,@$ll$0LT$$ IDIV 17,@1(16) *EX$$ ;DIVIDE BY N2 (REMAINDER IN AC0) EXIT TC .KJOB CONFIRM: I MODULO MACSUB.BAK MODULO.LST MODULO.REL MACSUB.REL MACSUB.LST MACSUB.MAC J <055> <055> <055> <055> <055> <055> 1. BLKS 1. BLKS :S 2.·BLKS DELETED 1. BLKS :S 1. BLKS :S 2. BLKS DELETED ~05'5> 1. BLKS :S uUB.,J.~~·.tlSER,. [.27 ..:56~ ] LPQ"OE;D OFF 1;1"Y11, ~924 ,23-FEB-,70 DELETED 4 FILES (6. DISK BLOCKS)' SA.VED 4 FILES (INCLUDING UFD, 6. DISK BLOCKS> RUNTIME 0 MIN, 05.54 SEC 6-34 o· To load DDT with the programs, type DEBUG MODULO,MACSUB.MAC. Note that the two source files are not translated again since they have not been modified since the previous trans- • lation occurred • Before execution of the program is begun, the system transfers control to DDT. the symbol table for the MACRO-tO subprogram. MACRO since no name was specified.) .MAIN$: opens (.MAIN was automatically assigned by DDT acknowledges the command with a TAB. Then type MOD+3/ to examine the contents of location MOD+3. After DDT responds with the erroneous instruction, simply retype the instruction correctly. The $G then starts the program v.i th the correction included. The program now returns correct resultsl It is now necessary to return to TECO to permanently correct the program. The command TECO MACSUB.MAC opens the already existing file for editing. A command string is then given which inserts the t in the proper place, and the correction is typed out. It is now necessary to log off the system. Type KJOB to accomplish this. When the system types CONFIRM: , type I to individually save or delete your files. The MACSUB.BAK file is a backup file which was created when the TECO MACSUB.MAC command was given. This file contains the file as it was before the command was executed. Since this file is no longer needed, only a carriage return is typed to delete it. The listing files are automaticatly deleted by the system. An S is typed after the colon to save all the oth~r files on the disk for future use. The system then completes the logout procedure by typing out the number of files deleted and saved, their length in disk blocks, and the total runtime of your job. 6-35 Demonstration #4 (Advanced) .LOG 4SP74G JOB 7 ~: : #27,560 PASSWORD: TTY3 0902 25-FEB-70 SYS 40 WILL BE DOWN FROM 1800-2400 TUE FEB 24 •..... • .MAKE RANDOl"! * C C C· SUBROUTINE RANDOM (ARG) RANDOM NUMBER GENERATING SUBROUTINE RETURNS A SINGLE PRECISION FLOATING POINT (REAL) PSEUDO-RANDOM NUMBER UNIFORMLY DISTRIBUTED OVER <0,1>. C C C C C C C 2 C C C C THIS SUBROUTINE ATTEMPTS TO D~LICATE THE ASSEMBLY LANGUAGE PROGRAM RANDOM USED IN THE PDP-10 REFERENCE HANDBOOK DEMONSTRATION #2 EQUIVALENCE (T,I) INTEGER RNUMB,MAGIC,IT(3) DATA RNUMB/1/ MAGIC = 5**15 GET THE TIME IN ASCII HH:MM SS.T CALL TIME (I,ARG) USE TIME TO SELECT 1-4 ITERATIONS DECODE (5,1,ARG) (IT(K),K=1,3) FORMAT (1X,2I1,1X,I1) K=«( IT(1) + 15) I IT(2) ) + IT(3) ) .AND. "3 DO 2 I =K, 0, -1 MULTIPLICATIVE R4NDOM NUMBER GENERATOR R~UMB = RNUMB * MAGIC CONVERT TO FLOATING POINT FORMAT IN THE RANGE <0,1>, BY CL.EARING THE EXPONENT FIELD WITH A "Sl-IIFT" AND SETTING THE EXPONENT TO 0 (EXCESS 200). I = ( RNUMB /256 ) .OR. "20000000000 NORMALIZE AND STORE RESULT ARG = T + 0.0 RETURN END $$ *HT$$ C C C SUBROUTINE RA~DOM (ARG) RANDOM NUMBER GENERATING SUBROUTINE RETURNS A SINGLE PRECISION FLOATING POINT (REAL) PSEUDO-RANDOM.NUMBER UNIFORMLY DISTRIBUTED OVER <0,1>. C C C C C C C 2 THIS SUBROUTINE ATTEMPTS TO DUPLICATE THE ASSEMBLY LANGUAGE PROGRAM RANDOM USED IN THE PDP-10 REFERENCE HANDBOOK DEMONSTRATION #2. EQUIVALENCE (T,I) INTEGER RNUMB,MAGIC,IT(3) DATA RNUMB/l/ MAGIC = 5**15 GET THE TIME IN ASCII HH:MM SS.T CALL TIME (I,ARG) USE TIME TO SELECT 1-4 ITERATIONS DECODE.(5,l,ARG) (IT(K),K=l,3) FORMAT(lX,2Il,lX,Il) f{=«( IT(l) + 15) / IT(2) ) + IT(3) ) .A~D. "3 DO 2 I =K, 0, -1 MULTIPLICATIVE RANDOM NUMBER GENERATOR RNUMB = RNUMB * MAGIC 6-36 LOG (abbreviation for LOGIN) starts the process of logging in to the system. Type the appropriate "login" information for your particular system, and it w ill respond with the time, date, Teletype number, and the message of the day (if there is a message to be given). MAKE RANDOM creates the file RANDOM with TECO for the FORTRAN random number generating subroutine. The TECO insert command ( I ) is not needed since the first character to be input is a TAB. The TAB causes it, along with the rest of the text up to the two ALTMODEs ( $$ ), to be inserted into the buffer. HT$$ causes TECO to type the entire buffer on the Teletype. This is used to check the previously inserted text for errors. 6-37 C C C C CONVERT TO FLOATING POINT FORMAT IN THE RANGE <0,1> BY CLEARING THE EXPONENT FIELD WITH A "SHIFT" AND SETTING THE EXPONENT TO. 0 .( EXCESS 2(0). I = ( RNUMB /256 ) .OR. "202100000000 NORMALIZE AND STORE RESULT ~RG = T + 0.0 RETURN· END *EX$$ EXIT tC .MAKE TESTIT *110 1 2 3 4 5 $$ *HT$$ 10 1 2 3 4 5 TYPE 1 FORMAT(' COMPUTE THE AVERAGE OF ',5X, '. 9PSEUDO-RANDOM NUMBERS') TYPE 2 FORMAT(lH+,T25,$) ACCEPT 3,1 FORMAT(15) T=0.0 DO 4 K=l,1 CALC RANDOM (R) T=T+R T=T/l TYPE 5,T FORIYJAT <1 X, 'IS: ',F) GO TO 10 END TYPE 1 FORMAT(' COMPUTE THE AVERAGE OF ',5X, '. 9PSEUDO-RANDOM NUMBERS') TYPE 2 FORMAT(lH+,T25,$) ACCEPT 3,1 FORMAT< 15) T=0.0 DO 4 K=l,I CALL RANDOM (R) T=T+R T=T/I TYPE 5,T FO RMA T ( 1X, , IS: " F) GO TO 10 END *EX$$ ,. EXIT tC 6-38 The TECO command EX$$ causes the file to be ended and the contents of the buffer to be read onto your disk area. It then returns control to the monitor. MAKE TESTIT calls in TECO to open a file for the FORTRAN testing program. The program calls the subroutine to get random numbers. It then averages a specified number of random numbers and, since the random numbers are confined to the range (0,1), the average should be close to 0.5 if the numbers are truly random. The TECO insert command ( I ) causes TECO to insert the text of the program up to the two ALTMODEs into the buffer. The command HT$$ causes the whole buffer to be typed onto your Te Ie type • This is usefu I to check for typing mistakes. EX$$ causes the file to be closed and read onto your disk area. It then returns control to the monitor. 6-39 .EXECUTE TESTIT,RANDOM FORTRAN: TESTIT ******** 1 FORI"'IAT(' COMPuTE THE AVERAGE OF " 5X, , • ******** " t ******** M-7 UNTERMIN~TED HOLLERITH STRING ******** 9PSEUDO-RANDOM NUMBERS') ******** t ******** S-l SYNTAX. MAIN. ERRORS DETECTED: 2 ? TOT~L ERRORS DETECTED: 2 FORTAA'\T: RANDOM LOADING LOADER 5K CORE ?EXEGUTION DELETED EXIT tC .TECO TESTIT *S5X, , • $$ *2R8< 1 ~=$C>$$ 39 46 13 '. 10 9 32 57 80 *f2lLCD0L-TT$$ 1 FORMAT(' COMPU"tE THE AVERAGE OF ',5X, '. 9PSEUDO-RANDOM NUMBERS') *EG$$ FORTRAN: LOADING TEST!T LOADER 5K CORE EXECUTION COMPU'rE THE AVERAGE OF 00010.PSEUDO-RANDOM NUMBERS 6-40 Type EXEOJTE TESTIT ,RANDOM to call in the FORTRAN IV compiler to create binary machinelanguage files (these will be given the extension. REL). The EXECUTE command also causes the two relocatable binary files to be loaded and then executed, if there are no compiler detected errors: The FORTRAN compiler has detected errors in the main (testing) program. It types out the lines the errors occur in and an arrow at the particular point the error is detected. The total errors for the main program are then typed out. The compiler then translates the file RANDOM and does not detect any errors. The total core requirement for loading is then typed out. The execution is deleted since there were compiler detected errors. Control is then returned to the monitor. The error messages returned by the FORTRAN compiler seem to indicate that there may be an illegal character in one or both of the two lines which were typed out by the compiler. To check this assumption, type TECO TESTIT which opens the already existing file TESTIT for editing. This command has the added effect of renaming the file, as it was before editing, TESTIT.BAK .• The first command string to TECO searches for the characters 5X, I • • The second string causes the decimal equivalents of the ASCII code of eight consecutive characters, starting with the character I ,to be typed on the Teletype. In this way, it should be possible to see if there is a character among these eight (even a non-printing one) that should not be there. The 32 is a space, and for this Iine to be a continuation line it shou Id not be there. Type the TECO command string shown to delete the space and type the corrected lines. The command EG$$ causes TECO to perform the functions of an EX$$ and then to execute the last compile class command given to the monitor. In this case, it was EXECUTE TESTlT,RANDOM. Since RANDOM has not been changed, it is not recompiled. Execution of the program is begun and it types the line COMPUTE THE AVERAGE OF .. PSEUDO-RANDOM NUMBERS. The program will then space over to the blank spaces and wait for you to enter the number of random numbers it is to average. In this case 10 random numbers are averaged. Strike the return key after the number has been entered, and the program should give you the average and type the first Iine again. 6-41 INTEGER DIVIDE CHECK PC=000267 INTEGER DIVIDE CHECK PC=000267 INTEGER OVERFLOW PC=000276 INTEGER OVERFI.,.DW PC=000276 IS: 0.0000000 COMPUTE THE AVERAGE OF fC .DEBUG ICREF/COMPILE FORTRAN: FORTRAN: LOADING .PSEUDO-RANDOM NUMBERS TESTIT(~~M)~RANDOM(~~M) TESTIT RA.:\TDOM LOADER 7K CORE EXECUTION XXX f C .SAVE DSK TEST J>B SAVED fC .CREF 6-42 The INTEGER DIVIDE CHECK messages occur when the seconds portion of the time used in the program is an even multiple of 10. This causes IT(2) to be 0 and the divide check results when the program attempts to divide by IT(2). When this happens, the result is as if the divide never occurred, thus the results obtained are still accurate. The INTEGER OVERFLOW messages occur when RNUMB is multiplied by MAGIC (MAGIC = 5 15). The fact that these overflows occur does not affect the resu Its, since the purpose is just to obtain a random number. Both the INTEGER DIVIDE CHECK and INTEGER OVERFLOW messages are suppressed after they are outputted twice. The average is returned as 0 when it shou Id be close to 0.5. There must be another bug in the program. ConlTol-C When the program requests the number of random numbers to average, type (t C) to return to the monitor. The DEBUG/CREF/COMPILE TESTIT("M),RANDOM("M) command does several different operations. First it loads DDT along with the two programs to make it possible to debug with DDT. The /CREF causes a cross-referenced listing to be produced to help in finding the bug. /COMPILE must be used for forced compilation of the programs. Ordinarily the source files are compiled only if they have a creation time newer than the binary machine-language files. The /COMPI LE (called a switch) overrides this feature and ensures the creation of the listing files. If it was not used the CREF files would not be ,produced. Tlie (, ,M) causes the listings to contain the MACRO expansion code which is sometimes helpful in debugging • .. After the monitor types EXECUTION, it transfers control to DDT. This happens because DEBUG was used instead of EX ECUTE. Strike the RU BOUT (or DELETE) key to make certain that DDT was entered. In DDT, the RUBOUT key echoes (typ,es back) as XXX. Now type tc to return to the monitor to get the listings. So that DDT can be reentered with the greatest possible ease, it is necessary to save the core area on the disk. If this is not done, another DEBUG command must be given. The command SAVE DSK TEST writes a copy of the core area on the disk and gives it the filename TEST. SAV. The monitor types JOB SAVED and leaves the Teletype in monitor mode. Type CREF to print the cross-reference listings on the line printer. 6-43 -\ . • GET DSK TEST JOB SETUP tC .DDT T.... 4P+4$2B $$F $G COMPUTE THE AVERAGE OF 00010.PSEUDO-RANDOM NUMBERS $lB»4? R/ ~17105693E~33 INTEGER OVERFLOW PC=003552 $lB»4P R/ .26502884E-34 INTEGER $1 B»4P $1B»4? $1B»4P $1B»4P $1 B»4P $1B»4P $1 B»4P OVERFLOW PC=0213552 R/ .12697389E-33 R/ .18615497E-33 R/ .17992393E-33 R/ • ~ 7408278E-33 R/ .15958281E-33 R/ .37201131E-34 R/ .16486226E-33 INTEGER DIVIDE CHECK PC=f2l03543 $1B»4P R/ .14481467!J:-33 $2B»4P+4 T/ .13711563E-32 IS: f2l.f2l0f2l0f2l0f2l COMPUTE ;HE AVERAGE OF tC $P .PSEUDO-RANDOM NUMBERS .DDT $B RANDOM$: RNUMB .... 2P+4$$1B $$C $G 6-44 • GET DSK TEST loads the core image from the disk into core. The monitor types JOB SETUP and returns the Teletype to monitor mode. The command DDT is typed to' reenter the program in DDT. After this command is executed it is as if the monitor had just typed EXECUTION and transferred control to DDT. It is now possible to debug the program wi th the aid of DDT and the listings from the line printer. MAIN .$: opens the symbol table for the FORTRAN main program, in this case TESTIT. DDT responds to each command with a TAB. By examining the listings carefully, it is possible to find a place to stop the program to find out what some of the random numbers are it is getting from the subroutine. Location 4P (assigned by the compiler) is the correct point to examine the random numbers. The command R,,4P$$lB tells DDT to type the contents of R (address of the random number) at location 4P, assign this as the first breakpoint, and continue program execution without stopping. If only one ALTMODE ( $) were used, the program would stop after typing"the contents of R. At location 4P+4, the total of the random numbers can be examined by typing out the contents of T. The command T, ,4P+4$2B instructs DDT to type the contents of T at location 4P+4, assign this as the se-cond breakpoint, and stop the program after the typeout. $$F tells DDT to output the contents of the specified locations as floating point numbers. The $G then starts execution of the program. The ten random numbers are extremely small and not even close to the range of zero to one. This explains why an average of zero was r~turned. The calculated average was too small to print using an F format. The bug must be somewhere in the random number generating subroutine. After DDT types the total, type $P to proceed with the program. When it asks for the number of random numbers, type t C to return to the monitor. Reenter DDT by typing the command DDT. Open the symbol table for the random number generating routine by typing RANDOM$: . $B is typed to clear the previous breakpoints. To examine the random numbers produced by RANDOM, type RNUMB,,2P+4$$lB. This tells DDT to type the contents of RNUMB at location 2P+4, assign this as the first breakpoint, and continue the program execution without stopping. This should simply produce random digits in address RNUMB. Type $$C to cause DDT to type the numbers as octal constants. $G starts execution of the program. 6-45 COMPUTE THE AVERAGE OF f21f2lf211f21~PSEUDO-RANDOM NUMBERS INTEGER OVERFLOW ' $1B»2P+4' RNUMBI PC=f21f213552 11213231 ~ ~ 730141 PC=f21f213552 INTEGER OVERFLOW $1B»2P+4 RNUMBI 353364~~63f21365 $1B»2P+4 RNUMBI 2032n 151761 $1B»2P+4 RNUMBI 273526-~~272275 $lB»2P+4 RNUMBI 10 5623n 3341211 5 $1B»2P+4 RNUMBI '52227n 117021 $1B»2P+4 RNUMBI 136431,,262241 $1B»2P+4 RNUMBI 317344~ ~ 31212511 $1B»2P+4 RNUMBI 366123~~235f2165 $1B»2P+4 RNUMBI 254721~~447775 IS: 121.121121121121121121121 COMPUTE THE AVERAGE OF tC I .PSEUDO-RANDOM NUMBERS .DDT T" 2P+10$$1 B $G COMPUTE THE AVERAGE OF f21f2lf2l1f21.PSEUDO-RANDOM NUMBERS INTEGER OVERFLOW PC=f21f213552 INTEGER OVERFLOW $1B»2P+1121 TI $1B»2P+10 'FI $1B»2P+1121 TI $lB»2P+10 TI $1B»2P+lf21 TI $1B»2P,+10 TI $1B»2P+1121 TI $1B»2P+10 TI PC=f212!3552 204f213~ ~ 354047 INTEGER DIVIDE CHECK PC=01213543 $1B»2P+1121 $1B»2P+10 TI 2f21316~~622373 TI 20240~~644566 2eJ402~~262376 2eJ142~~231053 20755n 531405 , 2eJ300~, 643450 ' 20126" 233254 20254~~522723 20315~ ~ 121.0000000 IS: COMPUTE THE AVER~GE OF tC 115224 .PSEUDO-RANDOM NUMBERS .DDT CONST.I 2000f21,~0 .1 20012100,,0 20012100,,0 $B $G COMPUTE THE AVERAGE OF f210010.PSEUDO-RANDOM NUMBERS INTEGER OVERFLOW PC=003552 INTEGER OVERFLOW PC=003552 IS: 0.5106965 COMPUTE THE AVERAGE OF 0121100.PSEUDO-RANDOM NUMBERS IS: 121.5007578 COMPUTE THE AVERAGE OF tC .PSEUDO-RANDOM NUMBERS 6-46 The numbers appear to be random. The bug must be farther on in the program. Type t C to return to the monitor. Type DDT to return to DDT. It is unn~cessary to open the symbol table of RANDOM since it was opened the previous time DDT was used. The command T,,2P+10$$lB causes DDT to type the contents of T at location 2P+1O, assign this as breakpoint one, and continue execution without stopping. It is not necessary to clear the breakpoints since breakpoint one has been reassigned. T at location 2P+ 10 shou Id contain the unnormalized random number. Each number should begin with 200, as that is the exponent used. Type $G to start the program. The bug is here! Each number beg ins with 020 instead of 200; therefore, a zero ,must have been omitted in the exponent in the program. Type t C to return to the mon itor and reenter' DDT by typing DDT. Type CONST./ to examine the contents of that location. DDT types 20000,,0. There should be another zero in the left half of the word. Type 200000" ° to correct the error. DDT changes the contents of CONST. to the numbers just typed. Next type ./ to again examine the contents of CONST. DDT responds with the corrected value. $B clears the breakpoints and $G starts the program. The answer is close to 0.5 for 10 random numbers and closer for 100 random numbers. The program is correct. \ 6-47 .TECO R~NDOM *S"2$-T$$ C THE EXPONENT TO 0 (EXCESS 200). I = ( RN(JMB 1256 ) • (fR. "2*10 $0L TU I = ( RNUMB 1256 ) .OR. "200000000000 *EX$$ EXIT tC .DIR/F J DIRECTORY 27,560 1020 25-FEB-70 AANDOM.BAK TESTIT.B~K TESTIT.REL AANDOM.REL TEST IT TESTIT.CRF AANDOM. CRF TEST • S~V AA!'-1DOM .K CONFIRM: I AANDOM.BAK <055> 2. BLKS 1 • BLKS <055> 2. BLKS <055> TESTIT.REL 2. BLKS AANDOM.REL <055> 1 • BLKS TESTIT <055> :S <055> 4. BLKS TESTIT.CRF DELEITED <055> AANDOM.CRF 6. BLKS DELETED TEST .S~V <055> 45. ·BLKS <0'55> 2. BLKS RA.!'-1DOM :S JOB 7, USER [27,560] LOGGED OFF TTY3 1023 DELETED 7 FILES (62. DISK BLOCKS) ~VED 2 FILES (INCLUDING UFD, 5. DISK BLOCKS) RUNTIME 121 MIN .. 26.52 SEC TESTIT.B~K 25-FEB-70 The command TECO RANDOM opens the already existing file RANDOM for editing. The old file is renamed RANDOM.BAK. The command string 5"2$-T$$ causes TECO to search for the characters "2 which are unique in the program'and are located at the beginning of the octal constant used to insert the exponent. TECO then types the previous line and the current Iine up to the posit-ion following the characters searched for. TECO signals its readiness for another command string by typing an asterisk. The second command string inserts a zero and types the corrected line. The EX$$ causes the file to be closed and read onto your disk area with the corrections in eluded. Control is then returned to the monitor. Type DIR/F to obtain a directory of your disk area. The IF causes a shortened form of the directory to be printed. The length of each fi Ie and the creation date are omitted. The two files with extensions .BAK are back-up files'. They contain the files, specified by file names, as they were before ed iting was done with TECO. The . REL fi les are the binary machine-IQnguage files created by the FORTRAN compiler. The files with the extension .CRF are the CREF listing files. Type K (abbreviation for KJOB) to log off the system. When the monitor types CONFIRM: , respond with an I to individually save or delete your files. The two source files are saved by . ' typing an 5, the .CRF fi les are automatically deleted by the system, and the other files are deleted by typing only a carriag~ return. The system then responds with the rest of the logout information. 6-49 Book 7 Advanced Monitor Commands ADVANCED MONITOR COMMANDS The !.ystern controls many peripheral devices, such as Teletypes, magnetic tape drives, DECtape drives, card readers and punches, line printers, papertape readers and punches, and disks. The monitor is responsible both for allocating these peripheral devices, as well as other system resources (e.g., core memory), and for maintaining a pool of such available resources from which you can draw. Each device controlled by the system has a physical name associated with it. The physical name is unique. It consists of three letters and zero to three numerals specifying a unit number. The following table lists the physical names associated with various peripheral devices. Tobie 7-1 Peripheral Devices Device Physical Name Teletype TTYO, TTY 1, • • • , TTY77 Console Teletype CTY Paper Tape Reader PTR Paper Tape Punch PTP Plotter PLT Line Printer LPT Card Reader CDR Card Punch COP DECtape DTAO, DTAI, ••• , DTA7 Magnetic Tape MTAO, MTAI, ••• , MTA7 Disk DSK - . You may also give each device a logical device name. T.he logical device name is an alias, and the device can be referred to either by this alias or by the physical name. The logical • 7-3 name consists of one to six alphanumeric characters of your choice-. Tne reason for logical device names is thot in writing a program you may use arbitrarily selected device nomes (logical device names) that can be assigned to the most conven ient physical devices at runtime. However, care should be exercised in assigning logical device names because these names have priority over physical device names. For example, if a DECtape is a~gned the logical name DSK, then all of your programs attempting to use the disk via the physical name DSK end up using the DECtape instead. It is wise not to give .any device the logical name DSK because certain monitor commands (such as the COMPILE com~ands) make extensive use of special features that the disk has but other devices do not ha've. The following examples show the use of logical and physical device na~es • .!. ASSIGN DTA,ABC ) Assign a DECtape the logical name ABC. .!. ASSIGN MTAl,XYZ ) Assign !JICgnetic tape drive #1 the logical name XYZ • .!.ASSIGN PTR, FOO ) Assign the papertape reader the logical name FOO. In order to use most peripheral devices, you must assign the desired device to your ,job. You may assign a device either by a program or from the console. The first kind of assignment occurs when you write a program that uses a particular device. When the program begins using the device, it is assigned to you on a temporary basis and released from you when your program has finished with it. The second kind of assignment occurs when you explicitly assign the device by means of the ASSIGN monitor command. This is a permanent assignment that is ~n effect until the device is released by a DEASSIGN or FINISH monitor command or by your logging off the system. When you assign a device to your job, the monitor associates your job number with that device. This means that no other user may use the device while you are u,.sing it. The only exception is the dis~, which is accessible by all users. When you assign the disk, you are allocated a fraction of the disk, not the'entire unit. When you deassign a device or kill your job, the device is returned to the monitor's pool of qvailable resources. 7.1 7.1.1 COMMANDS TO ALLOCATE SYSTEM RESOURCES The ASSIGN Command The ASSIGN command is used to assign a peripheral device on a permanent basis for the duration, , , . ' , of your job or until you explicitly deassign it. This command must ha~e as an argument the legal physical device nome (see Table 7-1) of the device you wish to assign. For example, if • 7-4 \ you want to assign a 0 ECtape drive to your job, type .!. ASSIGN DTA) The monitor responds with the message DT An ASSI GN ED where n is the unit number of the DECtape drive assigned to your job. If all drives are in use, the monitor responds with NO SUCH DEVICE and you must wait until a drive becomes available. You may assign a specific DECtape drive as follows: • ASSI GN DTA3 ) The mOllitor responds with DTA3 ASSIGNED if the drive is available, or ALREADY ASSIGNED TO JOB n if job n is using DECtape drive #3. The ASSIGN command may also have, as an optional argument, a logical device name following the physical device name. The logical device name may be used in place of the physical device name in all references to the device. For example, if you want to use DECtape drive #1 and have it named SAMPLE, type the command .!. ASSI GN DT A I SAMPLE ) If DECtape driye #1 is free, the monitor responds with DTAI ASSIGNED 7-5 and stores the logical name you typed. You may then refer to ffifl the contents of the specified source files to be typed on the line printer. Headings at the top of each page tell the page number, the name of the file, and the date of printing. You may list fi les from disk or 0 ECtape • For example, the command .:.. LIST TEST .F4 ) causes your disk file TEST .F4 to be listed on the line printer. You may list multiple files by separating the fi lenames by commas. For example, if you want to list three fi les, S.t\MPLE.BAS, FILEX.F4,MAIN .F4, from DECtape drive #4, type the command .:.. LIST DTA4: SAMPLE. BAS, FI LEX. F4~MAIN .F4) The asterisk convention discussed in Book 2 may' be used with this command. For example, .:.. LIST *.F4 ) 7-9 causes all files with the filename extension. F4 to be listed. " 7.3.2 The CREF Command The CREF command is used "to list a certain type of file called a cross-reference file. This command is an invaluable aid in program debugging. If a COMPilE, lOAD, EXECUTE, or DEBUG command string (see Book 2) has a /CREF switch, the command string generates an expanded listing that includes ( 1,) the original code as it appears in the file, (2) the octal values the code represents, (3) the relative locations into which the octal values go, ( 4) a list of all the symbols your program uses, and (5) the numbers of the lines on which each symbol appeats. This is called a cross-reference "'Sting. To pri"nt this. listing file, you must call in a special cross-reference lister with the CREF command. All the cross-reference listing files you have generated since the last CREFcommand ar~ printed on the line printer. The file containing the names of the cross-reference listing files is then deleted so that subsequent CREF commands will not list them again. 7.3.3 The DIRECTORY Command When a DTAn: argument is specified with the DIRECTORY command, the directory of DECtape n is typed on the Teletype. (See Book 2 for a discussion of the DIRECTORY command when no argument is·specified.) For example, the command . .:. DIRECTORY DT A2 ) types the directory of DECtape drive 62 on the Teletype. Besides having optional device arguments, this command has two switch options. The first switch option is /F. Including /F in the command string causes the short form of the directory to be listed on the Teletype. The short form of the directory consists of the names of your files and the length of each file in PDP-10 disk blocks. (The long form of the directory also lists the creation dates of each file.) The second switch option is fl. Including /L in the command string causes the output of the directory to go to t~e line printer rather than to the Teletype. For example, the command • DIRECTORY /l ) lists your'directory of your d iskarea on the line printer. The line printer is assigned to you on a temporary basis and is released when the output is finished. 7-10 7.4 COMMANDS TO MANIPULATE CORE IMAGES By using one of the following commands, you can load core image files (see Book 2 for the definition of a core image file) from disk, DECtapes, and magnetic tapes into core and then later save the core images. These files can be retrieved and controlled from the user's console. Files on disk and DECtape are called by filename, and if you have any files on magnetic tape, you must position the tape to the beginning of the file. 7.4.1 The SAVE Command The SAVE command causes your current core image to be saved on the specified device with the specified filename. This command must be followed by severa I arguments. First, you must tell the monitor the device on which you want to save the core image. A colon may follow the device name. Second, you must give a name to the core image file. sion js not specified, the monitor designates one. If the filename exten- You may specify the amount, of core in which you want your file saved by specifying a decimal number to represent the number of 1K blocks. For example, if you want to save your core image on DECtape drive #2, give it the name SALES, and allow 12K of core for storage, type . SAVE DTA2: SALES 12 ) A file called SALES is created and your core image is stored in it. If you list your DECtape directory, the length of the file is slightly over 12,OOOworcls. ':Afteryou use this command, . you cannot continue executing the program. The program can be restarted only from the beginning. 7.4.2 The RUN Command The RUN command allows you to run programs you previously saved on the disk, DECtape, or magnetic tape. This command reads the core image file from a storage device and starts its execution. You must specify the device containing the core image file and the name of that file. The file must have been saved previously with a SAVE command. If the file is no,t a saved program, the monitor responds with an error message. If the core image file you want to execute is on another user's disk area, you must specify his project-programmer number, enclosed in square brackets. Again, you may specify the amount of core to be assigned to the program if different from the minimum core needed to load the program or from the core argument of the SAVE command. 7-11 7.4.3 The R Command The R,~l1lmand is a specia1 form of the RUN command. This command runs programs (or CUSPs)' that are part of the system, rather than programs that are your own. The R command is the usual way to run a OJ SP that does not have a direct mon itor command associated with it; For example, the only way to run BASIC and AID is by the commands • R BASIC) and • RAID) A device name or a project programmer number may not be specified for this command. 7.4.4 The GET Command The GET command is the same as the RUN command except that it does not stqrt the program; it merely generates a core image and exits. Thl\! monitor types JOB SETUP and is ready to accept another command. 7.5 7.5.1 COMMAI'JDS.TO START A PROGRAM The START Command The START command begins execution of the program at its starting address, the location sp'~cified within the file, and is valid only if you have a core image. This command allows you to specify another starting address by typing the octal address after the command. Normally, to start a program, type • START ) but to start a program at the specified octal location 347, type • START 347 ) A GET command followed by a START command is equivalent to a RUN command. t ,.:..,j "!: ": 7-12 7.5.2 The HALT ( t C) Command Typing tc stops your program and takes you back to the monitor. The program "remembers" at what pC)int it was interrupted so that it may subsequently be continued. After typing t C, you may type any commands that do not affect the status of your program (e.g., PJOB, DA YTIME, RESOURCES) and still be able to continue the execution of the program with a CONTINUE command. However, contin~ing is impossible if you issue any command that runs a new program, such as a RUN or R command. 7.5.3 The CONTINUE Command If you stop your program by a HALT (tC) command, you may resume execution from the point at which it was interrupted by typing the CONTINUE command. You may continue the program only if you exit by typing control - C. If the program exited on an error condition of some sort, the mon itor does not let you continue. It types CAN IT CONTINUE if you try. However, you may continue your program if it has halted and given the typeout HALT AT USER n 7.6 COMMANDS TO GET INFORMATION FROM THE SYSTEM. 7.6.1 - The RESOURCES Command The RESOURCES command types out a list of all the available devices (except Teletypes) and the number of free blocks on the disk. A disk block is 128 PDP-10 words in length. For example, • RESOURCES ) 22100. BLKS, PTYI,CDR,PTR,MTA 1,COP, PLT, At the time of this command, there were 22100 free disk blocks available in addition to six devices. 7.6.2 The SYSTAT Command The SYSTAT command produces a summary of the current status of the system and may be typed without logging in. I,:,cluded in the summary is a list of the jobs currently logged in, along 7-13 with their protect-programmer numbers, program names being 'run, and runtime. The following is a partial example of SYSTAT. ~re inform~'ti~~' is contained in this program and can be obtained by running SYSTAT. ~1:26:4~, UPTIME JOB WHO WHERE WHAT SIZE STATE RUNTIME 1 2 3 4 5 6 7 8 9 ** , ** PIP MACRO MACRO 13,575 TTY2~ lK 4K 12K lK 15K lK' 3K lK lK lK 2K lK lK 2K 2K 2K 2K lK lK 3K tc SW 4JO,633 DET TTY4 TTY3 TTY6 ~~:12:~1 ~~:~1:22 ~JO:J05:J05 JO~:~~:32 JO~:~JO:19 ~JO:~JO:52 ~~:~JO:2~ ~~:~~:24 ~~:~JO:58 ~~:ll:ll ~~:~~:39 2,5 11,554 j~~637 1~ TTY24 TTYI 1~2 TTY27 ** , ** 2~,521 TTX'13 2~,623 TTY23 1,2 TTY2 TTY33 ** , ** TTY14 ** , ** DET ** , ** lJ04,334 TTY43 7~,54 TTY15 . 11 12 13 14 15 16 17 18 19 20 21 22 23 24 7;J 38% NULL TIME = IDLE+LOST = 26% + 12% 4~,65 TTYl~ 4JO,64 TTY7 DET TTY21 DET TTY37 TTY5 DET ** , ** 11', 7~ ** , ** 11,131 13,12 ** , ** ~IP COBOL DEVCHK OPFILE LOGOUT SYSTAT PIP PRINTR LOGIN LOGOUT UFILE TECO STACK TECO PRINT SYSTAT MONGEN CHKPRT ~K 'HMAC 6K BATCH ·4K PLEASE lK tc SW RN TT TT SW TT SW IO MQ tc SW AU IO SL MQ tC SW tc SW TT SW RN MQ tc ~~:JO~:~JO ~JO:~2:25 ~~:~~:~9 ~~:JO~:~~ ~~:~1:33 ~~:~2:42 ~JO:~JO:12 SW ~~:~~:~~ ~~:~~:>n ~~:~~:JOI TT SW SL tc SW ~~:~~:42 ~~:~~:58 TT ~C ~~:~~:~1 ADDITIONAL·MONITOR COMMANDS In order to present the complete set of monitor commands, the following must be, included. . These commands are speciahun control and system administration commands and are discussed , , in the PDP-10 Reference Handbook, Communicating With the NIonitor, Chapter 2. Table 7-2 Additional Monitor Commands Command DDT , '- " Explanation " This comma~ !.sused in debug9ir:'9 programs and allows DDT ~ -to assume, control o(the execution of your program in ' various ways. See the PO P-lO Reference Handbook, Communicatina with the Monitor for further information. Table 7-2 (Cont.) Command Explanation REENTER Similar to the DDT command. This command causes the program to start at an alternate specified entry point. The alternate entry point must be set by you or your program. E This command allows you to examine locations in your core area. The argument adr is required the first time you use this command. By specifying an address, the contents of that location are typed. If an argument is not specified, the contents of the location following the previously spec i fied address are typed out. D This command allows you to deposit information in your core area. You must specify octal values to be deposited in the left half and right half of the location. The address of the location in which information is to be deposited may be specified. If the address is not specified, the information is deposited in the last location examined or the last location in which information was deposited. Th is command is the same as the SAVE command except that the program will be sharable when it is loaded with the . GET command. To indicate sharabiI ity , the high segment is written with the extension .SHR. A subsequent GET causes the high segment to be sharable. SSAVE CSTART CCONT These commands are identical to the START and CONT commands except that you are able to continue talking to the monitor. The START and CONT allow you to communicate only with the CUSP that is in execution. Monitor commands may now be executed while the job is running. SCHEDULE n Thi$ command is legal only from the operator's console. It changes the scheduled use of the system depending on n, where n is: . o =regular time-sharing 1 =no further logins allowed 2 =no further logins allowed from remote Teletypes ASSIGN SYS:dev II DETACH dev > This command changes the system device to device devil. The user must be logged in under [1, n or [1,2] • This command assigns the device "dey" to job 0, thus making it unavailable. The user must be logged in under [ 1, 1 ] • 7-15 Table 7-2 (Cor-t.) Explanation Command 7.8 ATTACH dev This command returns a detached device to the monitor's pool of available resources. The user must be logged in under [1, 1] • CTEST This command is used to test extensions made to the COMPIL CUSP. MONITOR ERROR MESSAGES The following table contains a summary of the error messages the system can issue. The convention used in the summary is that dev represents any legal device name. file.ext represents any legal filename and filename extension. adr represents a user address. n represents a job number or device unit number Table 7-3 Monitor Diagnostic Messages Message The type in is 'typed back followed by? ) Meaning The mon itor encountered an incorrect character, such as a letter in a numeric argument. The incorrect character appears immediately before' the? For example, • .:.. CORE ABC) CORE A? ) ADDRESS CHECK FOR DEVICE dev AT USER adr The monitor checked a user address and found it to be too large or too small; in other words, the address lies outside the bounds of your program. ALREADY ASSIGNED TO JOB n 1he device is already assigned to another user's job (job n). BAD DIRECTORY FOR DEVICE DTAn The system cannot read or write the DECtape directory without getting some kind of error. Many times this error occurs when you try to write on a write-locked tape or use a virgin tape. 7-16 Table 7-3 (Cent) Meaning Message BUSY The console addressed is not communicating with the monitor or is not positioned at the I eft margin. (The operatorls console is never busy.) CAN IT ATTACH TO JOB The project-programmer number specified is not that of the owner of the desired job. CANIT CONTINUE The job was terminated due to a monitor detected error and cannot be contlnued. COMMAND ERROR General catch-all error response for the COMPILE commands. The syntax of the command is in error and the command cannot be deciphered • dey: ASSIGNED The device has been successfully assigned to your job. DEVICE CAN IT BE REASSIGNED A userls Teletype cannot be reassigned or an attempt was made to reassign a device that your job is sti II using. DEVICE dev OK? The device is temporarily disobled. The line printer may be turned off or out of paper. For mag tapes, there may be no tape mounted or the switch is in LOCAL. You should correct the situation and then proceed (retry the operation) by typing CONTINUE. DEVICE dev WASNIT ASSIGNED The device isnlt currently assigned to your job and cannot be deassigned or reassigned by your job. DEVICE NOT AVAILABLE Specified d~vice could not be initialized because someone else is using it. DIRECTORY RJLL The directory of the device is full and no more fi les can be added. DISK NOT AVAILABLE The device DSK: could not be initialized. ERROR IN JOB n A fatal error occurred in your job or in the monitor while servicing your job. This typeout usually precedes a I-line description of the error. EXECUTION DELETED A program is prevented from being executed because of errors detected during assembI y,- compilation, or loading. Load ing is performed, but the Loader exits to the monitor without starting execution . ... ~ . 7-17 Table 7-3 (Cont.) Meaning Message file FILE IN USE OR PROTECTED could not be entered A temporary command in your UFO (user's file directory). HALT AT USER adr Your program executed a HALT instruction at adr. Typing CONTINUE resumes execution at the effective address of the HALT instruction. HUN G 0 EYIC E dev If a device does not respond within a certain period of time when it is referen ced, the system decides that the device is not functioning and outputs thi s message. ILLEGAL DATA MODE FOR 0 EYICE dev AT USER adr - The data mode specified for a device in your program is i"egal, such as dump mode for Teletype. ILLEGAL UUO AT USER adr An i"egal UUO was executed at user location adr. ILL INST. AT USER adr An illegal operation code was encountered in your program. ILL MEMREF AT USER adr An illegal memory reference was made by your program at adr or adr + 1. lNCORRECT RETRIEVAL IN FORMATION The retrieval poil1ters for a file are not in the correct format; the fi Ie is unreadable. INPUT DEVICE dev CANNOT DO OUTPUT Output was attempted on a device that can only do input, such as the card reader. INPUT ERROR I/O error occurred while reading a temporary command file from the disk. File should be rewritten. ?INVALID ENTRYTRY AGAIN An ill~gal project-programmer number or password was entered and did not match identification in system. I/O TO UNASSIGNED CHANNEL AT USER adr An attempt was made to do an OUTPUT, INPUT, OUT, or IN fo a device that your program has not initialized. JOB NEVER WAS INITIATED An attempt was made to attach to a job that has not been in itia lized • JOB SAVED The output is completed. LINKAGE ERROR I/O error occurred while reading a CUSP from device SYS: 7-18 Table 7-3 (Cont.) Meaning Message LOGICAL NAME ALREADY IN USE DEVICE dev ASSIGNED You previously assigned this logical name to another device. The device is assigned but the logical name is not. LOGIN PLEASE A command that requires you to be logged in has been typed to the monitor; it cannot be accepted until you log in. ? LOO KU P AND ENTER HAVE DIFFERENT NAMES An attempt was made to read and write a file on the disk. However, the LOOKUP and ENTER UUO's have specified different names on the same user channel. This message does not indicate a DECtape error. MASS STORAGE DEVICE FULL The storage disk is full. Users must delete unneeded files before the system can proceed • NESTING TOO DEEP The @ construction exceeds a depth of nine and may be due to a loop of @ command files. nK OF CORE NEEDED There is insuffic.ient free core to load the file. n 1K BLOCKS OF CORE NEEDED The user's current core allocation is less than the contents of JOBFF. NON-EX MEM AT USER adr Usually due to an error in the monitor. NON-RECOVERABLE DISC READ ERROR; The monitor encountered an error while reading or writing a critical block in the disk file structure (e.g., the MFD or the SAT table). If th is condition persists, the disk must be reloaded using FAILSAFE, after the standard location for the MFD and SAT table has been changed using the monitor once-only dialogue. N ON -RECOVERABLE DISC WRITE ERROR; NO CORE ASSIGNED No core was allocated when the GET command was given and no core argument was specified in the GET. NO START ADR Starting· address or reenter address is zero because you failed to specify the address. NO SUCH DEVICE The device name does not exist or all devices of this type are in use. 7-19 Table 7-3 (Cont.) Message Meaning NO SUCH FILEfile .ext Specified file could not be found. May be a source file or a file required for operation of the COMPILE commands. ' NOT A DUMP FI LE The file is not a core image file. NOT A JOB The job number is not assigned to any currently runn ing job. NOT ENOUGH CORE System cannot supply enough core to use as buffers or to read in 'a OJSP. NOT ENOUGH FREE CORE IN MONITOR The monitor has run out of free core for assigning disk'data blocks and monitor buffers. NOT FOUND The program file requested could not be found on the system device or the specified device. OUT OF BOUNDS The specified adr is not in your core area, or the high segment is write-protected and you do not have privileges to the file which initialized the high segment. OUTPUT DEVICE dey CANNOT DO INPUT An attempt was made to input from an output device, such as input from the line printer. OUTPUT ERROR I/O error occurred while writing a temporary command file on disk. PC EXCEED S MEMORY BOUND AT USER adr Your program made an illegal transfer outside its bounds. PROCESSOR CON FLICT Use of + construction has resulted in a mixture of source languages. PLEASE KJOB OR DETACH Attempt was made to attach a job when you already have a job initialized at that Teletype. SWAP READ ERROR A consistent checksum error has been encountered when checksumming locations JOBDAC through JOBDAC+74 of the Job Data Area during swapping. TOO FEW ARGUMENTS . A command has been typed, but necessary arguments are missing. ' TOO MANY NAMES or TOO MANY SWITCHES Command string complexity exceeds table space in the COMPIL CUSP. 7-20 Table 7-3 (Cont) Message TRANSMISSION ERROR . TTYn ALREADY ATTACHED Mean mg Duril'lg a SAVE, GET, or RUN command, the system received parity errors from the device, or was unable to read your file in some other way. This can be as simple as trying to write on a write-locked tape. Job number is erroneous and is attached to anot her conso Ie, or another user is attached to the job. UN RECOGN I ZABLE SWITCH An ambiguous or undefined word followed a slash (/). UUO AT USER adr This message accompanies many error messages and indicates the location of the UUO that was the last instruction your program executed before the error occurred . • 7-21 . Book 8 Utility Programs . ' BATCH CHAIN LINED TECD BATCH CONTENTS CHAPTER 1 CHAPTER 2 8-7 INTRODUCTION BATCH PROCESSING UNDER THE PDP-I0 MONITORS 2.1 Description 8-9 2.2 Batch Equipment Requirements 8-11 2.3 Object Job Status 8-12 2.4 User-Control Levels 8-13 CHAPTER 3 PROGRAMMER CONTROL OF THE PDP-lO BATCH PROCESSOR 3.1 Control Cards Acceptable as Batch Input 8-16 3.1.1 Control Card Notation 8-16 3.1.2 Control Card Descriptions 8-16 3.2 Loading User Programs 8-28 CHAPTER 4 DRIVER (A CORE DUMP PROGRAM) 4.1 General Description 8-29 4.2 Equipment Requirements 8-29 4.3 Implementation of Driver 8-30 4.4 Using Drivei' 8-30 APPENDIX A BATCH EXAMPLES 8-33 APPENDIX B TABLES 8-41 ILLUSTRATIONS 2-1 Batch Processing within the PDP-I0 Time-Sharing System 8-10 2-2 Lines of Control and Communication Between Batch and the Batch-Controlled Object Job 8-11 Sample Control Cards for Three Jobs Processed by Batch 8-38 A-I TABLES 3-1 Batch User Diagnostic Messages 8-28 B-1 Batch Control Cards 8-41 8-5 .! I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I CHAPTER 1 INTRODUCTION The PDP-10 Batch Processor (Batch), runlling under any of the PDP-10 Monitors, supervises the sequentia I execution of a, seri es of jobs. In a ti me-sharing environment, Batch performs this function as one of the users of the system, thus allowing normal access by other users. Batch maintains constant communication with the operator and allows him to interrupt, skip, repeat, or prematurely terminate one or more of the jobs in the series at any time. Chapter 2 contains a general description of Batch operation. Chapter 3 describes the Batch control cards that must be present in the input to Batch. The Appendicescontain supplementary information on Batch, including examples, and control card and Teletype command summaries. Two programs are used in conjunction with Batch-Stack and Driver. Stack is used to transfer job files to the Batch input device and stack them there for subsequent input to Batch, transfer output job files created by a Batch run from the Batch output device to some other device (usually the line printer), list job file directories, delete job files, and list directories with selective file deletion or transfer. As described in Chapter 4, the DRIVER provides a core dump of the user's core area. 8-7 CHAPTER 2 BATCH PROCESSING UNDER THE PDP-10 MONITORS 2.1 DESCRIPTIO N The PDP-10 Batch Processor" Batch, is a sl!bsystem which exists as one of many Commonly Used Systems Programs (cusps) in the PDP-lO System Library. Batch is called in by the operator from his console Teletype by the Monitor command "R BATCH" in the same manner as F40 (the FORTRAN Compiler), Macro-lO (the Macro Assembler), or PIP (the Peripheral Interchange Program), or any of the other cusps. The Batch Processor is not an integral part of the Monitor and therefore C?ccupies no core storage when it is not being run. There is only one version of Batch; this version runs under all Monitors. Batch is a command interpreter and job supervisor; it does not contain its own versions of assemblers, compilers or looders. Rather, the PDP-10 Batch Processor calls in and controls the execution of the same standard cusps that an on-lin~ user would utilize in unbatched execution of jobs from a console Teletype. The input/output handler of the Batch Processor uses Programmed Operators (UUOs) which trap to the Monitor; thus, the actual I/o is handled by routines that exist within the Monitor, thereby enabling Batch to be run as a time-shared job in only 3K of core. When Batch is being run from a user's console Teletype (TTY) as a time-shared job, with a job number n, it sequentially initializes and executes a series of time-shared jobs (with job numbers m1, m2 , etc.) in parallel with itself. Batch accomplishes this by utilizing a "simulated Teletype" (caded a pseudoTeletype (PlY». A PTY is a mechanism by which one job (a control job) can control another job (an object job). Batch uses a PTY to type its commands to the object job. Thus, the Batch control job runs concurrently with the time-shared, batch-processed object job. Since the Monitor "sees" the control job (which is running Batch) and the object job (which is being run by Batch) as two separate and distinct time-shared jobs, memory protection and relocation ensures the complete protection of the Batch Processor area of core as well as that of the Time-Sharing Monitor. 1 Consequently, there is no lThis holds tn:e only if the hardware configuration includes the memory protection and relocation package, i.e., a time-sharing system only. 8-9 way in which an error in a user program being run under Batch can inadvertently i~terfere with the Batch Processor itself. The fact that the two jobs are being run in perallel by the Time-Sharing Monitor makes it possible for the operator to communicate directly with Batch via his console Teletype without any interruption of the job being run by the Batch Processor; i.e., that portion of Batch which interprets console commands can operate independently from that portion which controls the execution of the object job (unless, of course, the console command specifically requests an interruption or termination of the current user's job being run). See Figure 2-2. MONItOR ~ CONSOLE COMMAND INTERPRETER 1 I I I I I I J ~I SYSTEM SUPERVISOR f ~ PROGRAM (USER JOB) EXECUTOR I· I I INPUT/OUTPUT HANDLER 1 I USER JOBS (CORE) USE A JOB 1 PIP2 CONSOLES • F4 SYSTEM DEVICE (CUSP'S) MACRO-lO LOADER BATCH DUMP JOB 2 BATCH ,. --.., I L ___ PIP EDITOR. ETC JOB 6 F4 I ~ Ffgure 2-1 Batch Processing within the PDP-10 Time-Sharing System 8-10 CONTROL JOB BATCH CONSOLE COMMAND INTERPRETER OPERATORS CONSOLE .---- INPUT STREAM INTERPRETER ( I-f--I 1 i OBJECT JOB EXECUTOR 8 ' l7J OUTPUT DEVICE THREE SllITES OF AN OBJECT • JOB BPTEMP r'- --. / 08JECT JOB WHILE UNDER BATCH CONTROL - r5 Figure 2-2 2.2 INPUTI OUTPUT HANOLER SYS) A'~r . f---+ BATCH INPUT DE\I1CE OBJECT JOB WHILE UNDER CUSP CONTROL OBJECT JOB WHI LE UNOER USER PROGRAM CONTROL Lines of Control and Communication Between Batch and the Batch-Controlled Object Job BATCH EQUIPMENT REQUIREMENTS The minimum utilities required for batch processing within a PDP-10 system are: one Batch input device (contair:ts the input 'stack of jobs to be run), one Batch output device (for any assembler or compiler listings), one scratch device (BPTEMP}l, the shared system device (SYS; contains the systems programs), 3K of core for the Batch program, and sufficient core available to Ba~ch to run the required cusps or i d~vice 1This scratch can be accessed by programs running under Batch by use of the device name BPTEMP:. Assume that it is file-structured. 8-11 specified user prog,rams. Th~ input device may be any device'capable of inptJf~itiiin;the insfdll~tlcin's sYstem (card reader, magnetic tape, DECtape, paper tape reader, or disk). The Batch output, or listing device, may be any output device within the PDP-lO system configuration (line printer, paper tape punch, magnetic tape, DECtape, or disk); in a time-sharing system, a console Teletype other than the operator's can be usedas the listing device. The scratch device can be any retrievable device (magnetic tape, DECtape, or disk) and is assigned to the control job with the logical name BPTEMP before Batch is started. The system device (logical name, SYS) is a directory device specified at system-build time, and shared by all system users; it is kept write protected and cannot be uniquely assigned to any one job, although any job can initialize and input from it. Because of the disk fi Ie structure in th~ PDP-10 systems, a disk may be initialized as "different" devices concurrently; therefore, in a system which includes a disk in its configuration, Batch may be run with that disk as its input, output, scratch and system device, all initialized at the same time. Other devices, including this disk, that a particulCl1" job may require must be assigned by control cards in the Batch input stream. The traditional approach to Batch processing is that all Batch control cards relating to a job to be run appear together with the job on the Batch input device, and the Batch output messages directly concerning the job appear with the job's output on the Batch output device. Other messages may go to the .. operator's console. In this mode of operation, the user's job should 'address the Batch input device and Batch output device; these devi~es may be assigned as any device and the user's job will still run with- out modification. Ho~ever, there is no restriction which states that the user must operate in this way. The Batch control cards and the user's job (e.g., program, data, etc.) may be placed on two or more separate devices. In most of the discussions in this manual, the first mode of operation is implied, but in actuality only the Batch control cards must appear on the Batch input device, and only the Batch messages concerning the user's job must appear on the Batch output device. 2.3 OBJECT JOB STATUS Each object job comprises a file in the input stack. Each such job is separately logged in by Batch, and at the endo~ each job, Batc;h performs a KJ6B. The job number assigned by the system to the object job is typed out fo,llowing the typeol,lt of that job's $JOB card. The object job , il1 which all job execution is done, is a Iway~,'in one of three possible, ~tates determi,ned by where control of the object -job resides (see Figure 2-2); uti lization of the above-mentioned devi-ces varies between each of'these stotes. The object job is under sole Botch control whenever job execution 8-12 is being controlled; i.e., whenever Batch is bringing a cusp into the object job's core area, whenever compilations, assemblies, or other proc~sses are initialized or terminated, or whenever a postmortem dump is performed. All control-card command execution is done while the object job is under Batch control. Batch can always bring the object job back to its own control, regardless of the object job's state. When a system program, such as the FORTRAN Compi ler, has been started as the time-shared object job by Batch, that program is in control of the job. The compiler may ask for input from the Batch input device, do output to the Batch output device, or perform I/O to devices specified on the control card that initialized its execution. Relocatable binary files produced by the assembler and compiler, or any other intermediate files, are placed on the scratch device, BPTEMP, for subsequent input for another process -- usually a loading process prior to running the now executable user program. When a user program is executed (execution automatically follows compilation or assembly unless the ~ control card includes a command to suppress execution or there has been an error whi Ie compiling or assembling), the object job is running under that program's control. The program can perform input and output on the Batch input and output devices or on any device previously assigned by a control card. When a user program e~its normally (with a CAll EXID, control reverts to Batch which then processes the next control card request; when the exit is,due to a monitor-detected error, Batch will execute a postmortem core dump, if requested, by calling most of the dump routine from the system device. If the previously specified maximum running time for the user program is exceeded, control also reverts to Batch. . Ultimate control of the object job always remains with Batch, since it can interrupt the execution of any program which is being run at any time. Batch does the timing of user programs being executed, and interprets commands that the operator may type on the console. These commands could interrupt, terminate, or atter the execution of a series of user jobs, or they could specify new parameters to Batch without interruption of the existing sequence, or even without slowing down object-job execution. 2.4 USER-CONTROL lEVELS There are two levels of control that a user exercises over Batch; these levels are determined by the form of the commands input'to Batch. Thl'lse commands are either in the form of "control cards" (see Chapter 3) which are prepared and arranged before Batch run time, or they are console commands typed to Batch at ruh time;' . The remainder of this section is primarily of interest to the programmer and discusses the fever of control that is exercised over the processor by various types of control-card commands. 8-13 -',; CHAPTER 3 PROGRAMMER CONTROL OF THE PDP-I0 BATCH PROCESSOR The programmer controls the execution of his job by Batch through control cards which he prepares prior to run time. A control card is hereby defined as any ASCII string of characters from any legal input device, where that string is terminated by the ASCII characters, RETURN and LINE-FEED, and initialized with an ASCII $ (dollar sign) as its first character. We shall refer to control cards as if they were cards, and refer to positions on these cards as columns. If the input device happens to be a card reader, the end of the card itself determines the termination of the ASCII character string; however, in every case (except the KEY card), column 1 must contain the dollar sign. The format of control cards requires that the control card type be identified by its first word, which must begin in column 2; this card type is usually an instruction or category of commands which mayor may not take a series of arguments. The fields of the various arguments are delimited by spaces (except for the name field on the $JOB card, which must be delimited by a comma, since it may contain space~) and they need not be delimited by.specific columns; leading spaces before arguments are ignored by Bat :h, so absolute positioning is flexible - the relative positioning of arguments, however, must be as specified below. If a directory device is used as the Batch input device, each user's job is assumed to be a separate file with a name, IJOBxy .abc, where xy represents the ASCII characters 01 through 99 and .abc represents any desired extension (omission of .abc implies a null extension). "xy" must run consecutively, with no missing numbers between the first job (IJOB01) and the last job (IJOBnn). Stack "stacks" files on a directory device, giving them consecutive names as just described (see Chapter 5). Batch runs jobs in the input stack as follows. First, Batch searches for the job IJOBOl and initializes it. At the end of IJOBOl ,. Batch searches for IJOB02, etc. B~tch continues operating in this sequential manner unti I after running· IJOBn I a LOOKUP on IJOBn+l fai Is; at this point, Batch assumes that it has reached the end of the input stack and types "END OF BATCH." 8-15 When Batch is executed with a directory device QS its output device, Batch. - creates filenames in the ,,1_, , "'. ., , • • ' ." , :. 1,' • ' ~ '. < ~ ~, • " (_~ form OJOBxy.abc, where the xy.abc string in the output files always corresponds to that of the IJO Bxy •abc fil es • 3.1 CONTROL CARDS ACCEPTABLE AS BATCH INPUT 3.1.1 Control Card Notation In the following control-card command descriptions, these notation conventions are used. Parameters in uppercase letters indicate the use of that particular ASCII string in the field indicated on the control card; e.g., NOGO suppresses program execution. Lowercase letters indicate an ASCII string to be substituted; e.g., "name" indicates a variable name. Lowercase terms with II as last character indicate a quantitative argument; e.g., "timell " indicates maximum execution time. Parentheses ( ) indicate that the enclosed argument is optional. Braces { 3.1.2 3.1.2.1 } indicate a choice of formats. Control Card Descriptions $JOB Card - The $JOB card must be the first card for a given user's application, or user job. The user job may consist of any number of specific tasks, compilations, assemblies or executions which are placed prior to the $EOJ (end of job) card, wnich terminates the job, causing Batch to look for the next $JOB card in the stack. The format of the $JOB card is as follows. 1 $JOB name, corell timell projll ,prog# (NOGO) (DUMP) I, name User's name or other information; must be delimited by a comma and cannot exceed 25 , . characters, inc Iudi ng blanks. " if' < " .' " , ' '.~ , ,;, I , If"" , !)I' " 8-16 • , , ,..;.., ;' ~ ,'" lo .. core II This quantity is the user's estimate of the maximum number of blocks (1024 10 , or 20008 words per block) of core memory required to process his job. This quantity is expressed in decimal. This estimate must include the 1K of locations reserved by the Monitor as the job-data area in every runable user program, and also the 1K locations required by the core dump DRIVER which is loaded by Batch starting at user location 140. All programs and/or cusps within a user job will be run in the amount of core requested on the $JOB card, whether that particular program or cusp requires it or not; this is necessary to prevent another time-shared user from acquiring core needed to complete a specific Batch user job. time ll This quantity is the user's estimate of the maximum amount of time (in seconds) that his job should require to run to completion. This figure should reflect use of processor I, time only, since input/output is handled by the Monitor; furthermore, if the environment is time-sharing, only the running time of the user is measured by Batch, not the real-time processor use of any other time-shared jobs. At program run time, if Batch finds that the specified time has been exceeded, a message is typed to the operator on the Batch console teletype, MAX TIME EXCEEDED; however, the user job continues uninterrupted for 8 seconds before skipping to the next user job. During this period, the operator may type TIMEOK to extend the program's execution until its normal exit (or until the operator terminates it with a console command, see Chapter 4). projll The projll, prog# ar~ applicabl,e only in systems that have a LOGIN feature; this includes all systems with a mass storage device (disk or drum) in their configuration. The 1 project number of a user is the first part of the number that he types when logging in for on-line utilization of the PDP-l0 system. The project-programmer number sequence identifies the user file directory (UFO) of that particular user on the disk. Once Batch has logged in the user under his number, all references to the disk with unspecified UFO by any part of the user's program or by $ASSIGN card will be a reference through that user's own file directory. The projll can be connected to the progll with a comma '(ASCII code =054) or a slash (ASCII code =057). prog ll This argument is the second part of the project-programmer number; every user of a system should have his own unique programmer number; the project number is usually common to several programmers. The significance of the project-programmer number in a disk system is treated in more detail in the PDP-l0 Time-Sharing Monitors manual. 8-17 . If the argument NOGOls included after thev~riable arg(,ments on t~e $JbB card I the NOGO object program produced by assembly and load or compi lation and load will not be executed; this feature might be used in conjunction with a $SAVE or $SSAVEcards in case the user wishes to run the program on-line at some later time. If the character string DUMP is included on the $JOB card, a postmortem dump is per- DUMP formed on the user core image following any object program termination other than a CALL EXIT. If the DUMP argument is not specified, however, the operator may still initialize" a core dump by typing the DUMP command on his console Teletype at any time (e.g., upon receiving a MAX TIME EXCEEDED message). 3.1.2.2 KEY Card - The KEY card must be the second card in the user job on systems that have a LOGIN feature. The key is a string of six or less ASCII characters and is associated with the previously mentioned project-progra·mmer number. To be logged in, the key must be correct; otherwise, the user's job will not be executed by BATCH. The formot of the KEY card is as follows: 1 key NOTE The ASCII dollar sign ($) is not used as the first character on this card. Examples of the $JOB card and KEY card combination: 1 $JOB EXAMPLE, 206099,99 NOGO PASWRD $JOB EXAMPLE2, 21 59 100,100 DUMP SECRET 3.1.2.3 $ASSIGN Card - The $ASSIGN card is required if the user wishes to reference any device other than the Batch input and outPlJt device. or SYS, the system devi<;e. If the user w~mts to perform I/O on the ~at~~ input/output devices, regardless Qf what these devices are assignec!to by the operator at run time, he does not use the $ASSIGN card; instead he performs I/o wi.th ACCEPT and TYPE state- ments in FORTRAN, or with "TTY" initialized as his input and output device if his source program is in 8-18 Macro. A user program may also use the Batch scratch device, BPTEMP, without an $ASSIGN card; in fact, the symbolic unit (or logical name) specified on an $ASSIGN card can be any logical name except BPTEMP and SYS. With the exception of DSK, the physical device specified cannot define a device already specified as the Batch input or Batch output device (see "NOTES," 4.1.3). The function of the $ASSIGN card is to set up a correspondence between a symbolic unit used in the user's program and a particular physical device designated at run time; if the device is a tape, it also associates the label appearing on the physical tape with the logical name and the tape drive. The format of the '$ASSIGN card is as follows. 1 $ASSIGN label symu (PROTECT) (NOREW) label This is the argument by which the user specifies the physical device he wants to reference in his program by the logical name, symu; it also specifies the physical device that subsequent control cards wi II reference as symu • If label is a nonsharable physical device (e.g., CDR, LPT) and is not avai lable at user run time, Batch will type a message, "USER NEEDS DEVICE label." to the operator and then wait for a response before proceeding. The operator should attempt to assign the required device to Batch, perhaps after waiting for the current user of the device to finish with it and release it. When the operator types "CONT", Batch will attempt to INIT the device. If this attempt succeeds, Batch will reassign the device to the object job and continue execution. If Batch cannot INIT the device, it will print an error message on the output device and skip to the next user's job. If the user assigns a sharable physical device (e.g., DTA, MTA), the label must begin with either D (for DECtape) 1 or M (for magtape) followed by some word or number that identifies the reel to be mounted. For example, the serial number might be used to indicate to the operator which of the tapes given him by the user should be mounted at this time. A label beginning with a D or M will cause Batch to type "MOUNT TAPE label WRITE PROTECTED" or "MOUNT TAPE label WRITE ENABLED" (the presence or absence of the PROTECT argument determines which of these two messages is typed); The operator then mounts the specified tape' on an available drive and types the device name and numl:>er on the console. (NOTE: The drive selected must not be that of either the Batch input or Batch output device.) 1 However, note that the label "DSK II assigns disk to the symu. 8-19 $ASSI~~ TAP~IN D1984 PROTECt This $ASSIGN c~~d cou~es'the typeouts at wn time. f~lIowir1g ; MOUNT TAPE D1984 WRITE PROTECTED (Operator mounts DECtape with serial number of 1984 on an avail(jJble DECtape drive, for example, drive 5) Operator types in device name and number, followed by'a colon. DTA5: ) OK Batch responds with message indicating that device was successfully initialized. If, for some reason, the drive on which the operator has just mounted the tape is not available (i .e., it is assigned to another time-shared job), the message "physdev NOT AVAILABLE" (where physdev is the physical device typed in) is typed to the operator followed immediately by the "MOUNT TAPE" message previously described. As soon as successful assignment is made, Batch types "OK" to the operator and waits for his "CONTINUE" command before resuming processing. If no drives are available or if the operator wishes to cease processing of the iob, "END" can be typed to abort the job. symu This argument can consist of six or fewer alphanumeric characters (no spaces or punctuation' can appear in this string). This is the symbolic unit which must be the name that the user's program employs to reference the device. PROTECT This argument is described under '~Iabel" above. NOREW This argument causes magtape to bypass rewind. The $ASSIGN control card $ASSIGN label symu is equivalent to the Monitor command .:.ASSIGN label symu if symu is equal to DSK or does not begin with an ASCII D or M. In the latter case (D or M), the operator must provide Batch with an actual DECtape drive or magtape drive. ~-20 3.1.2.4 $TAPE Card - The $TAPE card causes Batch to dynamically perform certain device-dependent operations on DECtapes or magnetic tapes that have previously been assigned a symbolic-unit name with an $ASSIGN card. The control card format is as follows. 1 $TAPE symu op 1 op2 op3 symu This logical symbolic unit must have been specified with an $ASSIGN card; if it was not, the message "UNIT symu NOT ASSIGNED, CARD IGNORED" is output on the Batch listing device, where symu is the unassigned logical nQme which was specified on the $TAPE card. If symu was assigned to a nontape device, the operations specified will be no-ops, but no message will be pri nted • opn This argument may be any of the following 2-character tape operation codes; the operations are executed in the order in which they appear on the card and their number may be variable. Operations that do not pertain to the device specified (e.g., zero directory command for magnetic tape) are considered to be no-ops. 3.1.2.5 DZ Zero directory of DECtape symu. MA Advance one file on 'magnetic tape symu. MW Rewind magneti c tape symu to load point, or rewind DECtape to end zone at front of tape. MB Backspace magnetic tape symu one file. MT Advance magnetic tape symu to logical end of tape (double end of file). $MAC, $F4, and $CBl Cards - The $MAC card executes a Macro-lO assembly; the $F4 card executes a FORTRAN compilation at the user's source program; similarly, the $CBl card executes a COBOL compilation of the user's source program. Then'(if execution is not suspended), the users program is loaded and executed with the timing control specified on the $JOB card. The action that Batch takes with the relocatable binary program produced by either assembly or compilation is independent of whether the compiler or assembler produced it. The format of.the cards is identical; and the conditions under which the relocatable binary program is to be handled by Batch may be specified on other control cards 'regardless of whether the source program was FORTRAN, Macro-lO, or COBOL. The format of the cards is as follows. {~MAC} prgname (B: symu2) (l: symu3) $F4 $CBl' (S: symu1) } { (S: symu I: prgname 1,prgname2, .. '. ..•• symux:pr~namey) 8-21 , • prgname • >' " • , " -" .... '.~' - ~.. ~ ~ ( ' -1 '" •- ", ' , 'This argument is ci program name of six or less charactEmi. If the 'control" card has speci'fied any directory output device, this will be the name of the file whi'ch will be ~ro duced by the compilation or assembly. If a directory output device has been specified and no name is given here, the name TEMP will be assigned. If NOGO was specified on the $JOB card, the file produced by assembly or compilation will not be passed to the Loader. B: L: $: These optional arguments specify that the user wishes to specify his own source, binary or listing device, ~espectively. The symu following the B, L, or S'must have been a~igned previously with a $ASSIGN card. The first of the "S" format above assumes the file prgname if symu1 is a directory device. The second of the two "S" formats above describes the case in which a file other ,than prgname or several source files are to be compiled or assembled into one bi·nary program. B:* or L:* indicates that binary output or I isting is to be suppressed. If no source device is specified, the Batch input device is assumed: if no listing device is specified, the Batch output device is assumed; and if no binary device has been specified, the intermediate relocatable binary file is output ~n the Batch scratch tape, BTEMP, from which it is loaded by tlie Loader prior to execution (note that BPTEMP is zeroed foltowing each job). Since the Macro-10 Assembler is two-pass, whenever the source is unspecified, the following file is copied from the Batch input devi ce onto BPTEMP prior to.assembly; in this case, if some binary device, has not been specified 1 , Batch will request that the operator mount additional scratch device(s). , Note. that "TTY" specified as source or listing device results in the source or listing being input or output on the Batch input or output device. 3.1 .2.6 $CREF Card - The $CREF card performs all the functions of the $MAC card and, in addition, produces a cross-reference assembly listing. It is provided for the user who wishes to obtai n a special cross-reference listing of hi~ Batch assembly. In the Macro listing produced, there is a decimal sequence number printed leftmost on each line of the output, regardless of whether thaf line is an, instruction, comment, or even blank. At the end of the listing",after the symbol table, every symbol referenced in the progra~ is listed alphabetically; each ~ymbo' heads a horiiontal list ~f sequence numbers which identify every line in which th~ given symbol is referenced. 1Specification could be by $BI N card prior to this card. I 8-22 " ,~, Note that, according to the following format description of the $CREF card, the I isting produced is printed on the Batch output device. 1 $CREF B: S: prgname (B:symu2) ( (S:symul) "\ (S:symu1 :prgnam 1, prgnam2, ••• ,symux:prgnam3~ Since the cross-reference procedure requires an intermediate "scratch" listing device, Batch utilizes BPTEMP for this purpose. Since the $MAC card already requires a binary device (in addition to BPTEMP) if no source device is specified, the $CREF card requires that if neither a binary nor a source device is specified, the operator will be requested to mount two additional scratch devices at assembly time. 3.1.2.7 $lDR Card - The $LDR card will cause the Loader to load relocatable binary files from a device previously assigned with an $ASSIGN card or from the system device SYS or from BPTEMP. The format for this card is as follows. Note that every program which has been asse~bled or complied (via $MAC,$F4, $CBL and $CREF cards) is automatically loaded. Thus, the $LDR card should be used only for programs which already exist in binary format and have not been assembled or compiled during this Batch run. 1 $LDR symu: prgnam 1, prgname2,. • • (LIB) symu Argument is described above. prgnam These must be the file names of relocatable binary files; they are specified only if symu is a directory device. LIB If this string appears, every program on the file is 10Qded in library search mode (see description of Loader, PDP-10 System User's Guide). 3.1.2.8 $EXLDR Card Card format: 1 $EXLDR (MAP) This card is optional, and is to be used only when no more source programs follow. When this card is read by Batch, the Loader is brought into core and is used to load alt programs previously compiled or assembled, or previously specified by $LDR cards. 8-23 MAP Any $LDR cards that follow the $EXLDR card do not bring the Loader in again, but continue to toad with the Loader that is already in the user's area. If the $EXLDR card is missing, the Loader is coiled and loading is triggered by the $EOJ or $EOF card. 3.1.2.9 $BIN Card Card format: 1 $BIN symu The logical name, symu (previously specified with an $ASSIGN card), specifies an symu assigned device which becomes the permanent output device for all relocatable binary files. Once this card has been read, all files normally written by Botch on BPTEMP are written on the specified device. NOTE I 3.1 .2.10 Make certain that the device is not write protected when the $ASSIGN card specifying it is read. $SAVE Card and $SSAVE Card Card format: 1 $SA VE symu:prgname (coreD) $SSAVE symu:prgname (coreD) These cards cause Batch to save the core image of the user's area on the,symu device specified in the argument field; if the device has a directory, the saved file is assigned the name "prgname. II The constraints on the symu device are the same as for the $BIN card above; i. e., it must not be write protected. The $SAVE card and the $SSAVE card serve the same function except tnat the $SSAVE cause the stored program to be sharable. -8-:24 coreN This argument specifies the number of 1K core-image locations which Batch is to save on the specified device; however, if the program in core requires more space than specified in the argument, it will be saved in the amount of space required. This argument takes precedence over the core argument specified on the $JOB card for the specific execution of the $SAVE (or $SSAVE card) card only, with all following operaations being executed in the amount of core specified on the $JOB card. If no coren argument is specified on the $SAVE(or $SSAVE card} card, the program is saved according to Monitor conventions. 3.1.2.11 $RUN Card Card format: $RUN symu:prgname This card causes Batch to read in and execute the program "prgname" from the previously assigned symu; this device may be write protected. The device can also be SYS or BPTEMP. Note that BTEMP is zero- ed at the end of each job. This must be a previously saved .SAV file or a system cusp. If the program "prgname" prgname expects input from TTY, these desired prgname inputs must be on the Batch input device, following the $RUN card; they should not have dollar signs in column 1. In this case, an $EOF card should be used to terminate the prgname input stream. NOTE Programs which run in DDT submode where communication between Batch and the program run by Batch is via Teletype (in DDT submode) cannot be specified (e.g., TECO, DDT). 3 .1 .2 • 12 $G ET Card Card format: $GET symu:prgname 8-25 " This card causes Batch to read in the program "prgname" from the previously a~}gn~ sYil'iu. The dr~u ments and functions of this car9 are similar to those of the $RUN card in all respects except that the program is not executed. 3.1.2.13 $START Card Card format: ' 1 $START The $START card causes Batch to initiate execution of a program that has been called in with the previous $GET card, or that has been I inked by the loader. 3.1.2.14 $EOF Card - This card has no argument field. The $EOF card creates an internal end-of-file to a preceding input stream on the Batch input device. If NOGO was not specified on the $JOB card, the $EOF card triggers the execution of programs that have been loaded in core, or before execution triggers the loading'of programs that have been assembled or compiled previously under control of $MAC, $F4, $CBL or $CREF cards. If the previously compiled or loaded programs require data from the Batch input device (ACCEPT statements or INPUT UUOs in Macro from TTY), the data must appear on the cards immediately following the $EOF card on the Batch input device. ' 3.1 .2.15 $EOJ Card - This card has no argument field. The $EOJ card specifies the end of a user's job. If no $EOF card has been issued previously, the $EOJ card triggers the same actions as for as loading and execution of programs by Batch as the $EOF card. The $EOJ card, however, specifies the end of the'inpllt stream for the current job." NOTE This card is mandatory for the end of the job; however, ifan end of file (EOF) on the "input device occurs (an EOF appears after each input job, exc;ept when the,'Batch input device is, card or paper tape), Batch simulates the $EOJ card. 8-26 ' 1 3.1.2.16 $DUMP Card Card format: 1 $DUMP The $DUMP card insert~ at any point in the user's data specifies that a dump is to be taken when the job reaches this point. 3.1.2.17 $* Card - Write to operator and wait for reply. Card format: 1 $* comment ... Columns 4 through 80 of this card are typed on the operator's console, and Batch waits for operator action, e.g., CONT or END. 3.1.2.18 $** Card - Write to operator without reply. Card format: $** comment Columns 4 through 80 of this card are typed on the operator's console, and Batch continues without operator intervention. 3.1.2.19 $PAUSECard Card format: 1 $PAUSE The $PAUSE card suspends Batch operation until operator intervention • 8-27 -3.2 LOADING USER PROG~MS Batch will run Loader whenever it encounters a $EXLDR, $EOF, $EOJ, $SSAVE or $SAVE control card. Batch loads programs in the order they were encountered on the $LDR, $F~, $CBL and $MAC cards, so that programs which previously existed in bInary form may be loaded prior to (that is, into numerically lower addresses than)"programs which have been translated during this Batch run. If loading was initiated by a $EXLDR card, Batch will then load any programs specified by $LDR cards and finish loading when it encounters a $EOF, $EOJ, $SAVE or $SSAVE card. Table 3-1 Batch User Diagnosti c Messages Message . Meaning BEGIN EXECUTION $EOJ card has been processed. CAN ONLY COpy 1 FILE ONTO DISK Cannot copy onto BPTEMP for MACRO assembly. CAN'T COMPILE OR ASSEMBLE AFTER A $EXLDR CARD The input deck is out of order. DRIVER NOT LOADED - CAN'T DUMP ******J08 ABORTED / The input job was terminated during -runtime by operation intervention. JOB CARD BAD A $J08 card field has been omitted or is in improper format. MAX TIME EXCEEDED - JOB KILLED Job has exceeded time on job cards. NO EX~CUTIO N An error or a NOGO has resulted in no execution of a previously loaded program. NO LOAD - PROGRAM NOT SAVED Trying to load a non-savJ!d program. ******NOJ AVAILABLE Batch has received a "1" from the monitor on a $ASSIGN card indicating the device is not available. SCRATCH DEVICE DIRECTORY FULL Could not el)ter a file name into the directory • UNIT UUU NOT ASSIGNED, CARD IGNORED The unit named on the card has not been specified on a $ASSIGN card. UNRECOGNIZABLE CARD, IGNORED An illegal control card has been introduced into the Batch stream. UNRECOGNIZABLE FIELD ON CARD, CARD IGNORED A field on the card is in improper format. 8-28 CHAPTER 4 DRIVER (A CORE DUMP PROGRAM) 4.1 GENERAL DESCRIPTION Driver is a PDP-l0 system program used in conjunction with the Batch Processor (BATCH). The major function of Driver is to provide a dump of the user's core area, when the Batch Processor encounters a $DUMP card in the Batch input deck, a DUMP option on the job card, or a DUMP command typed in by the Batch operator. Driver performs all of the following functions when it is invoked. These functions are performed sequentially as listed. (1) A dump of the ACs in both octal and decimal is performed. (2) A dump of selected monitor status information, obtained by utilization of the GETTAB UUO is performed. The standard Driver outpus the job status word (JBrs TS), job relocation and protection (JBTADR), high segment table (JBTSGN), and the user program name (JBTPRG). (3) A dump of specific job data locations is performed. The standard Driver outputs the following job information in this format. JOBUUO JOBBLT JOBUSY JOBCNI JOBVER . (4) JOB41 JOBHCU JOBSA JOBTPC JOB ERR JOBDDT JOBFF JOBOPC JOBENB JOBHRL JOBREN JOBCHN JOBREL JOBSYM JOBAPR JOBCOR A dump from the end of Driver up to JOBFF in octal, SIXBIT, and ASCII is performed • ... NOTE Because Driver is written as a series of MACRO calls, it is relatively simple for each installation to modify or extend the information output on the dump. For further information, consult the Driver source fiI e • . 8-29 4.2 EQUIPMENT REQUIREMENTS The Batch Processor operator's console is required for control of Driver. Driver requires one output device (usually the line printer) although intermediary output devices, such as MTA, can be used. 4.~ IMPLEMENTATION OF DRIVER The $EXLDR card automatically loods Driver into core before any user programs. 1 When a dump is requested (either by the $DUMP card or by operator intervention) the Batch Processor uses the E (EXAMINE) command to look at location 140. If location 140 contains "DRIVER" in SIXBIT, an ST (STARn 141 is used to invoke the dump. lf location 140 contains a value other than SIXBIT "DRIVER", the Batch Processor outputs a diagnostic to the user's output, and continues with the Batch note job stream. 4.4 USING DRIVER Once invoked by either the $DUMP card or by operator intervention, Driver performs a core dump of the Batch job drea without any operator intervention; no further operator actions are required for this Batch job. --... 1 If the $EXLDR card is omitted, Driver can be loaded with a $LDR card or a $RUN SYS LOADER card. 8-30 ••••••••• * ACS 00-07 ~0000000A00. 777~00004371 e00e11~02166 1~.17 ~00000~0~012 0~0~0~000042 04'0@~~00012 ~0"07 1~~17 *' *10 *2360438 +52344 9 1402 -16774919 .34 CORE OIJMP •••••••••• OCT'~ 000000006457 00~000007247 000000000000 777250001247 0~060~0~ 0 4 0332471016 0e~000~000~6 0~4555002367 777754004235 77775~000632 DECMAL +J375 *3751 .0 "90173785 .100663306 .4352274956 +6 +&32"4743 .524067' ~6291~46 MON I TOR ST AT,US 1N~O JBTSTS 44000'0~0~06 J8T,OR 007777104~02 ~BTSGN 000000000000 J8TPRG L~AnER ._-----_._----- . JOB DATA INF'O JOBUUO 000404007255 JOB41 26400e002107 J09ERR 000000000000 JOBENB 0~0000000000 JOBR£L 000000007777 JORBLT 3100000~0J01 JOA~CU 000~~~~0~~~0 JOBD~T 00000~000~~~ JOq~RL 0~0~0~0~0~0~ J09SVM 77725~0~7250 JOeU5Y 000~000?7250 J08SA ~04271eZ1?5' JOarr 00000~004371 JOPBEN 0~0~00000e00 JO~APR 0e000~070000 JOBeNI 0000000~0~00 J08TPC 000~~~00~~~t JOBOPC 31000e0e1e52 JOBC~N 0~1056000000 J08C~R 00427112100000 JOBVEB 00000~000~17 ------ ---------_. -~---~ AOOR 00 I W OCUL. ~-~- _ _ _ _ _ S! X8j..:.T_ __ ASCII 9101050 4406000003wa 449170000121000 25400000UJ52 26670011104033 .t"& 10' 5. (J6W -II'~ ~ ___ ~___ ~ ___ .1 ~01054 0150000~0~0~ 254e11l0~01052 3?144~0~106' 200000003260 .IH 5. fJI,' (W0 I~.' * 42 X' ~01060 2~20000~3262 607440000010 254f131110~106' 23314000327~ ~ IRP\. (5' (W~!' IX. •• YAR' JuL __ ~01064 202147000001 200140003272 202147000002 135140003340 .~1~ 101~ li01G "*1' ". , Fa J pa 4 p, 9101070 27U40003~40 205000350700 2~200r/10~3034 !>52J543001i!0~.Jt111.__ll.~Ji.....!...!_~ 8(~"C I', IS Il. • ......l.......__..t __ 11101074 5r554~0~0700 554~13000090 3~6~0~25400~ 254000~01110 .~~. 'M~* SP 5~ 5. 1( • • Q6 .r x l ' X. $, 1"011£'10 37000i1101!'09113 55'0030000010 336NH'00000:J 2?lU2l0i/!00373 *L- .M'" IP 0( jr •• ) ~ ..1_II__ --1.L __ "'011~4 270000000013 202540003033 20254~0"'3334 35'~00"'0000~.' .11'5' A105' 1(-' .', v V NI • 0'101110 5500200010"'13 542000~03!l134 20125400"3035 63~4400llHl_!.M ill .UII S(2!5. e,su IB_.i! XI! ___ '1 .. L ___ Q..L_ 0101114 4760e"'0"'3~3~ 5412'000"'0~e 4"'360~0~3017 62144!l110~00~ .r,p ~)L.~ _) A/R.,( * v. ,x 02 "'01120 54144"'000(11l1lfA 403040000006 5~52400C'100(/H" 2011'100"'00013 *1 ,. ~8'" &f!J. "', . . 'X2 *e Q. .....L __ _ 0"1124 20210(l'10~3~32 13 4100000013 311540003034 254000"'01177 .A1 I I . ' .9 •• 8<5, ,~ • • n M 26. 7' V, 0113 0 62010 IU! '" 010" 6 4 '" 1Ol0 '" 0 00 4" 2 0 014 ~ 00 0 0 !lI2 _231140",," !lI.aL!tHL_L.I.L __ ~_"_J..a.--'.Jt-...tD.. __ ..H______ . _ U _L _ ~011~4 1351440~147111 25'~23"'01511 663'4i11011'01!'0j 2540"'0001142 *'IM IX5'~ ~IV<' I~' 18 •• A * $LR • 1001140200200003332202200003333 2'510?0CH1"'2'" 2211;"""'''0012 .(?I" 1102 1171 02((11 .. , M H t'.L.I~l'_'__ f~ 001144 27004"'''002102 25'~~0~01123 671?4~000001 621440000001 .7 ~ "~. 13W.' IB,- I. '. • IN. 02 • L'l011~0 2V1!IJ4001'llIr1100 25'0"'0001123 2 6 174V'0(IJi!0(U i!61740000013~ ___ -'-l. )36" 16" ... _Ltt_. _:'Ln. 112 _ ....t2. __ .t__ _ 001154 607440000~02 ~0360000"'0~1 2540000~1166 627440000001 .~\~ "8) 15. IVR\. :_ .AR ~X + ,[R "'01160 254l"0A0r.1164 201112\40003333 202(-14<10,,333' 3"4(210f1lA000Z'0 .". IT21" 11~0. 1(8. • .+ __ ~.JL....Ji1 001164 20254(l'1003~34 202540"'03033 20104~e00001" 34460~"'01123 .~5. 1(05' 8,,,,( • . '1021;""0002 274740003343 *61~ 11M 8(6( "le' Ie. " Jil. _ _~~ I Q. 0012"4 6614'0100000 20054000333' 621.40000001 ~2l344"0100P0 .v,~( 0~- I(P,. 1'('1 • 'L2 ~D2 ~R t U1210 2540000"'1.63 20Ul1!I0003060 25100I1!!lIe'3077 2542lQl0002H'3 .", • 50 L sp" 8.-5, u. ,. __ ~___._--1.t __ r01214 373 91 17777777 25'~00"01220 2'4'43e03343 25400~001117 _'8/~.~5~ .07G' ,C5. II • • )~. HI O. I001220 200557000a00 344600001117 6614402"'''''00 6214'0000"~1 .~XQ (f I/V •• 0 ~" 1*' X Q t~2 D2 • 001224 254e0"0~1123 260140001346 2607400 0 1 7 21 254000001120 *5. '36 1 • • r6" 115. 10... II S. ~. (. V~123~ 2010401~02e4 6214400001r1 66144~0~101~ 62144ee00001 ,re, "SR,. IV •• e B" I •• " A02 L.2 02 • ~012~4 322e400?1120 55~1~000303~ 275113~00000 2211000000~' .,0' )0MI 8(71. 2) X• • 4~ (l ISX Ii , ~01240 325440m01252 13400m0m0013 36210~0011ZZ 60744000100~ II~~ .J.p .>1 ).P\, ( • '52 lJ (0 iAB ....JL ___ _ .0. NOTE SIXBn output is enclosed between asterisks (*) ASCII output is enclosed between up-arrows (t). APPENDIX A BATCH EXAMPLES This appendix contains a collection of examples showing the use of Batch control cards and operational procedures . Example 1 $JOB BATCH1, 10 20 100,101 DEMOI $1'4 TEMP (F"ORTRAN PROGRAM STATEMENTS) $EOF" CI NPUT DATA) $EOJ On running the above sequence of cards under control of Batch, the following actions occur. a. The contents of the $JOB card, followed by the job number assigned by the system to the object job, is printed on the operator IS Teletype. a file, TEMP.REL, on BPTEMP. b. The FORTRAN compiler produces c. The $EOF card triggers the loading of TEMP. REL and starts the job. d. The $EOJ card marks the end of the job and the end of the input data. Example 2 10 10 100,101 BATCH2, $JOB DEMOI DOUT $ASS IGN DTAI PROGRM $1'4 DIMENSION 11(1000) DTA 1 = LOGICAL DEVICE NO.9 C INTEGER G DATA G/9/ DO 1 J=I, 1000 II ( J ) = J F"ILE = 4HF"ILE CALL OF"ILE (G,F"ILE) 8-33 WR IrE (G) II END FILE G STOP END $EOJ o.n running the above job, the followi ng actions occur. a. The contents of the $Jo.B card, followed by the assigned job number, is printed on the operator's' Teletype. b. The message Mo.UNT TAPE Do.UT WRITE ENABLED is printed on the operator's Teletype. The operator can specify the actual DECtape (Do.UT) drive on which he'has mounted a DECtape reel by typing . - Batch replies with OJ< * and, when user types Co.NTINUE, proceeds with the running of the job. c. The Fo.RTRAN compiler p~duces a file, PRo.GRM.REL, on BPTEMP, and the $Eo.J card performs the functions of the $EQF card (triggers the loading of PRo.GRM. REL and starts the job). d. The execution of the program wi II create a fj Ie, FILE. DAT , on DECtape Do.UT. Example 3 In the preceding examples, the storage map produced by the Loader was written on the output device. This map can be suppressed by using the following sequence of control cards. $JOB DEMOl $ASS IGN $F'4 BATCH3 " 10 DREL MAIN DTA (FORTRAN PROGRAM STATEMENTS) $LDR DTA:SUBRl"SUBR2 $EXLDR NOMAP $EOI=" CINPUT DATA) $EOJ 8-34 The DECtape DREL containing the .REL files SUBR1 and SUBR2 will be requested by Batch. MOU~T TAPE DREL W~ITE ENABLED After the compilation, the Loader is brought in and executed by the $EXLDR card. Note that the file MAIN.REL is not specified, as doing so would result in multiply defined symbols. The option NOMAP on the $EXLDR card suppresses the writing out of the storage map. The $EOF card begins the execution of the loaded program. The $EOJ card terminates the input data and the job. Example 4 To save a program on a DECtape, the following sequence of control cards can be used. $JOB DEMOI $ASS I GN $1"4. BATCH .. 10 DSAV PROG DTA (rORTRAN PROGRAM STATEMENTS) $SAVE $EOJ DTA:rORSAV Ch!lnging DSAV on the $ASSIGN card to DSK would result in savtng the job on the disk in the user's (100,101) disk area. Example 5 To suppress the printing of the Macro code generated by the FORTRAN compiler, the following sequence of control cards can be used. $JOB BATCH 12 100 .. 101 DEMOI $RUN SYS:r40 BPTEMP:COMP .. TTY:/M~TTY: (FORTRAN PROGRAM STATEMENTS) $LDR. BPTEMP:COMP $EXLDR NOMAP $EOr (INPUT DATA) $EOJ 8-35 The following facts should be noted • . a. b. S.wit~h 1M suppresses the printing of the Macro code. BPTEMP may·be·used without assignin~ it. c. COMP must. be specified on. the $ LOR card, because the compi lation is not done under control of a $F4 card. d. The $EOF card begins execution of the loaded program. Example 6 The use of the Macro-10 assembler by means of the $MAC or $CREF card is completely-analogous to the use of the $F4 card. If one wants to run the assembler by means of a"$RUN card, it should be noted that the assembler makes two passes and, consequently I the source statements must be entered twice; this introduces a problem where card input is involved. However, by means of PIP (Peripheral Interchange Program), this problem can be alleviated. The control cards used are given below. $JOB DEMOI $RUN BATCH6.. 10 40 100 .. 101 SYS:PIP BPTEMP:SOURCE~TTY: (MACRO PROGRAM STATEMENTS) $EOF' $TAPE BPTEMP MW $RUN SYS:MACRO BPTEMP:MACBIN .. TTY:~BPTEMP:SOURCE $EOJ . Example 7, This example shows the combination of a FORTRAN program and a Macro-l0 program in one job. $JOB DEMOI BATCH7 .. 10 $1"4 DIMENSION KK(40) ACCEPT I .. KK DO 2 1=1 .. 40 K=KKCI> 2 1 3 CALL MACROCK .. L> TYPE 3 .. K.. L STOP F'ORMATC4012 ) F'ORMAT C1 X .. 2 17) END , 8-36 $EOF $MAC SUB ENTRY MACRO MACRO: Z MOVEM MOVE LSH MOVEM MOVE JRA SAVE: l~SAVE ;LOAD K 1~@(16) 1~ 1 ;STORE 2*K IN L 1~@1(16) l~SAVE 16~2Cl6) Z END ~p $EXLDR $EOF 0102 ••••••••••••••••••••••••••••••• ·.···········3940 $EOJ Example 8 This' example contains a diagram of sample control cards for three jobs to be executed under Batch (see Figure A-l) and a sample dialogue produced on the operator's console Teletype while these three jobs are being run. FolJowing this is the dialogue on the operator's console Teletype produced while the batch in Figure A-l is run. Underlined strings indicate computer typeouts. . 8-37 MACRO-l0 SOURCE PROGRAM $EOJ $ SAVE $ ELXDR DSK NAMDDT NOMAP 10-0477 Figure A-l Sample Control Cards for Three Jobs Processed by Batch 8-38 .ASS I GN MTA 1 BPTEMP :R BATCH ~ *IN CDR:~ iOUT LPT: ~ !SK 0 ~ $JOB JOHN DOE, RUNN I NG JOB 3 11 (Operator assigns scratch device) (Monitor command to run Batch) (Card reader input) (Line printer output) (Skip 0 jobs; start with first) ~ 40 33,44 (Compilation and Execution) RUN TIME - 32 SECS. $JOB JOE DOAKES, 8 30 DUMP ($JOB card always printed on TTY) 47,11 NOGO - RUNNING JOB 3 MOUNT TAPE 01984 WRITE PROTECTED DTA3~ DTA3 NOT AVAILABLE MOUNT TAPE 01984 WRITE PROTECTED DTA5~ OK (Operator mounts tape before typing CO NT command) !CONT ~ CONTINUING (Execution suppressed) RUN TIME - 0 SECS. $JOB fOGGY BOTTOM, ~ 70 50,50 DUMP RUNNING JOB 5 PLEASE MOUNT A SCRATCH TAPE DTA4~ (Operator mounts tape, write enabl ed, before typi ng CONT) !,CONn CONTINUING PLEASE MOUNT A SCRATCH TAPE (Batch needs 2 extra tapes) MTA0~ OK !CONT~ (Operator mounts magnetic tape number 0 write enabled) CONTINUING MAX. TIME E~CEEDED (Program execution exceeded time limit; e.g., infinite loop) DUMP ~ (Operator commands core dump on output device, LPT, and termination of user job) RUN TIME - 67 SECS. END Of BATCH * (At this point operator can run another batch or exit with a CTRL C command) 8-39 APPENDIX B TABLES Table B-1 Batch Control Cards Format Function $ASSIGN label symu (PROTECn (NOREW) To reference any devices other than the Batch input and output device or system (SYS) device (see 3.1.2.3). $BIN symu To specify the previously assigned device to be used to output all relocatable binary files (see 3.1.2.9). $CBL prgname (B:symu2) (L:symu3) (S:symul) Executes a COBOL compilation of user's source program and executes the resultant object program with timing control specified in the $JOB card (3. 1. 2 .9) • $CREF prgname (B:symu2) (S:symul) To cause the assembly of a Macro-10 symbolic program and the generation of a special crossreference listing (see 3.1.2.6). $DUMP Inserted at any point in the user's data to produce dump at this point (3.1.2. 16t. $EOF Creates an internal end of file to a preceding input stream on the Batch input device and triggers the running of programs loaded into core and the running of programs assembled (or complied) but not yet loaded (see 3.1.2. 14). $EOJ Signals the end of the user's job. If no $EOF card precedes the $EOJ card, the $EOJ card triggers the loading and running actions described above (see 3.1.2.15). $EXLDR (MAP) Used only when no more source programs follow; brings the loader into core and loads all programs previously assembled or compiled or specified by preceding $LDR cards (see 3.1.2.8). 8-41 , ~ Table, B-1 (Cont) Batch Control Cards Function Format $F4 prgname (B:symu2) (L:symu3) (S:symu1) Executes a FORTRAN compilation of the user's source program and executes the resultant object program with 'the timing control specified in the $JOB card (See 3.1.2.4). $GET symu: prgname Directs Batch to load the program "prgname" from the previously assigned sym~. Similar to -$RUN card except that the loaded program is not executed (see 3. 1 .2. 12). $JOB name, corel time# proj# , prog# (NOGO) (DUMP) The fitst card of a user job. All compilations, executions, and other tasks requested between this card and an $EOJ card are considered to be part of this job (see 3.1.2.1) • Key Must follow $JOB card (3.1.2.2) and password associated with Project Programmer number. $LDR symu:prgname 1 , prgnam2, ••• (LIB) Calls the loader: to load relocatable binary files from a device previously assigned by a $ASSIGN card or from the system device or from BPTEMP (see 3. 1 .2. 7) • $MAC prgname (B:symu2) (L:symu3) (S:symu1) Executes a Macro-l0 assembly of the user's source program and executes the resultant object program with the timing control specified'in the $JOB card (see 3.1.2.5). $PAUSE Suspends Batch until operator intervention (3 • 1. 2. 19). $RUN symu:prgname Directs Batch to load the program "prgname" from the previously assigned symu (or SYS or BPTEMP) and then execute it (see 3.1 .2.11) • $SAVE symu:prgname (corJi) $SSAVE symu: prgname (core#) Directs Batch to save the core image of the user's area on the symu device specified and, if symu is a directory device, assign the name "prgname" (see 3.1.2.10). SSAVE card marks the"prgname" as shareable. • $START Causes Batch to initiate execution of a program , which has been called in with previous $GET card, or which has been linked by loader, (3.1.2.13). 8-42 Table B":l (Cont) Batch Control Cards Function Format $ TAPE symu op f op2 op3 •.• DZ - Zero DECtape directory. MA - Advance mag tape on file •. MW - Rewind mag tape to load point. MB - Backspace mag tape one fiI e. MT - Advance mag tape to logical end of tape. Directs Batch to dynamically perform certain device-dependent operations on DECtapes or magnetic tapes which have previously been assigned a symbolic-unit name with an $ASSIGN card (see 3.1.2.3). $*comment Comment Card. Directs Batch to type out contents of columns 4 through 80 of this card and wait for operator to type CONTINUE or END (see 3.1.2.17). $**comment Comment Card. Directs Batch to type out contents of columns 4 through 80 of this card; Batch continues without operator intervention (3.1.2.18). 8-43 CHAIN CHAIN I. ABSTRACT The CHAIN Program is the prime component of a system that allows users to deal with FORTRAN IV programming applications which would produce programs too large to fit or to load into the amount of core avai lab Ie. Special switches in the LOAD ER allow the user to create CHAIN files, consisting of complete programs and subroutines, which can be read into core and executed as they are needed. CHAIN itself, a subroutine called by the user, provides a standard- ized method of reading the successive segments of coding (CHAIN files) into core and linking them to the programs already residing in core. 2. PDP-10 CHAIN JOB IMPLEMENTATION A COMMON area in lower core is set aside for the transmission of data between successive CHAIN files. This area in lower core is known as the Permanent Resident Area, and remains in core at all times. The Permanent Resident Area contains CHAIN and part of LIMO and may contain any number of Macro- 10 programs followed by the FORTRAN IV BLOCK OAT A program which defines COMMON. The BLOCK OAT A program defines the end of the Permanent Resident Area. There can be only one BLOCK DATA program in any CHAIN job. o CHAIN Any number or MACRO-lO programs by~ Defined FORTRAN IV BLOCK DATA program Permanent Resident Area COMMON MACRO-lO & FORTRAN IV programs Segment Read-In Area . For any CHAIN job the Permanent Resident Area assumes a fixed length. This are~ is unaffected by the process of reading in successive CHAIN files. The Macro-l0 programs 8-47 residing in the Pemianent Resident Area should be programs used by more than one CHAIN file (e.g., DDT or CHAIN). The remainder of core, above the Permanent Resident Area, is known as the Segment Read-in Area. It is in this area that various, CHAIN files are read into core and executed. The Segment Read-in Area may dontain a mixture of FORTRAN IV and Macro-lO programs. Within this area the user may define a Removable Resident Area. This area is directJy above the Permanent Resident Area. It may contain any number of Macro-lO programs fo "owed by one FORTRAN IV program. When the user makes a ca" to CHAIN, he may specify that the next CHAIN file be read'in either directly after the Permanent Resident Area or directly after the Removable Resident Area. Thus the user may leave his Removable Resident in core while several CHA IN files are being read in and executed, and'then he may read over it with another file. A CHAIN job beginning in this state: o • Permanent Resident Area . Removable Resident FORTRAN IV & Macro-10 programs Reads in a new CHAIN file and becomes o Permanent Resident Area Unchanged Removable Resident CHAIN 1 Then reads a CHAIN file that overlays the Removable Resident and becomes: 8-48 o Permanent Resident Area } Unchanged, ~4--4 CHAIN2 Then reads in a CHAIN file that restores the Removable Resident: o Permanent Resident Area Removable Resident ~- L Unchanged - -- FORTRAN IV & Macro-tO programs CHAIN file just read in (CHAIN3) Arrows point to that location in core which is the lower bound into which the file has just been read. By reading successive CHAIN files into the area above the Removabl,e Resident, the Removable Resident may be kept in core as long as desired. The Removable Resident may be removed at any time by reading a CHAIN file into core immediately above the Permanent Resident Area. The Removable Resident may be restored at any time by reading a new CHAIN file containing a copy of the-Removable Resident into core immediately above the Permanent Resident Area. 3. LOADING CHAIN CHAIN will be loaded from SYS by the Loader. This loading must be followed by a library search of lIB40 before the loading of block data so that', essential Macro programs are loaded in the PRA. 8-49 · 4. CALLING SEQUENCE The call to CHAIN is of the form: CALL CHAIN (TYPE, DEVICE, FILE) where: TYPE =0 reads the next CHAIN file, into core immediately above the' Permanent Resident Area (COMMON). TYPE == I reads the next CHAIN file into core immediately above the FORTRAN IV program which marks the end of the Removable Resident. w~ere: DEVICE = I, 2, ••• is an I/O device numbe~ corresponding 'to the device where'the CHAIN file may be found. For example, when reading a CHAIN file from the disk, DEVICE = I. NOTE: CHAIN files may be stored in DSK, MTA, or DTA only. FILE = I, 2, ••• is the number of the magnetic tape file where the CHAIN file is where: located. or: FILE =0 tells CHAIN to read the next file from the selected magnetic tape. or: FILE = 'ASCII NOTE: filename ' if the CHAIN file is to be read from DTA or DSK. File names are limited to five or fewer letters according to the FORTRAN IV convention. EXAMPLE: If a CHAIN, job wishes to read in a CHAIN file named SEG4 from the disk, and it wishes to read that file into the area above the Removable Resident, the,call to CHAIN would be: / CALL,CHAIN (l,l,'SEG41) 5. CREATION OF CHAIN FILES Using LOAD ER 1, the creation of CHAIN fi les is a two-step operation. First, one uses LOADER to create an image of core as it will look y.then the CHAIN file being created is r:ead in at run time. For instance, consider th~ CHAIN job illust rated below: Version 5 I or later of the LOAD ER is necessary. I ' 8-50 o MAC 1 - - - - CHAIN I- - Permanent Resident Area MAC2 ~ I- - - -- LlB40 ROUTINES ~-- -- COMMON Segment Reed-In Area Removable Resident RESID MAC6 ~- F41 - -- Stage I 1 Temporary Programs A call to CHAIN of the form CALL CHAIN(l, 1,'CHN1') would produce: o MAC1 - MAC2 - - -- I- - - - CHAIN -- ~------ LlB40 ROUTINES 1--.-._COMMON RESID F42 -- -- }cHNloCHN MAC3 Stage II A call to CHAIN of the form CALL CHAIN(O,I,'CHN2') wo~ld produce: o MAC 1 I-- - - --- MAC2 1------ CHAIN 1-----LlB40 ROUTINES I-- -- - -- COMMON F45 } CHN2.CHN Stage \1-1 8-51 The first step in the creation of the file CHN 1 would be to input to LOADER all the REL files . corresponding to the programs which will be in core at STAGE III; 'n this case, the command to LOADER would be: *DSK:MAC1,MAC2,CHAIN/FDSK:COMMON,RESID/FDSK:F42,MAC3 where F42 and MAC3 constitute the basis of the CHAIN file to be created. The /F switch is used to force .the loading of library programs so that they will be placed in lower core where they can be properly and permanently linked to the resident programs which call them. Commas must not follow a/Fswitch because the LOADER tries to load L1B40 twice. Second, a command is given that will cause the remaining library routines to be loaded and the completed CHAIN file, consisting of everything above the Removable Resident, to be written out onto the specified output device. In the case of the example above, the command might be: *DSK:CHN l-/R $ where "DSK:CHN 1-" instructs LOADER to write the CHAIN file named CHN 1.CHN 01) the disk. /R instructs LOADER that the CHAIN file consists of everything above the Removable I Resident, and $ (ALTMOD E key) instructs LOADER to first load the necessary Ilbrary . I routines, and then write out the CHAIN file. NOTE: LOADER puts all library ,routines referenced only by the programs in a CHAIN file into core above the last user program MAC3 in the example), and they Qre written out as part of the CHAIN file. Similarly, the CHAIN file CHN2 would have been created by giving to LOADER the command: *DSK:MACI,MAC2, CHAIN/FDSK:COMMON, F45 • where F45 (and the library routines it references) constitutes the body of the CHAIN file. subsequent command: . *DSK:CHN2-/C $ . would instruct LOADER to do the necessary library search- and write out the CHAIN file CHN2.CHN starting with the program after COMMON. 8-52 The The original core image in a CHAIN job (see Stage I above) is a LOADER"created SAV mode core image. In this case, it would be created by using the LOADER command string: *DS,K:MAC1,MAC2,CHAIN/FDSK:COMMON,RESID/FDSK:MAC6,F41 $ In summary, when one creates CHAIN files or the original core image used in a CHAIN job, the Permanent Resident Area must be constructed in exactly the same way each time LOADER is run. The same rule applies to the creation of Removable Residents, when they exist. To this end, the IF switch of the LOADER should be used to force the uniform loading of library routines referenced by programs in the Permanent Resident Area (PRA) or in the Removable IF switch should be given immediately after the last program in the PRA When an IF switch is set, LOADER loads the previously specified file, then Resident (RRj. The and the RR.t enters library search mode and scans the FORTRAN library loading the required programs only. The IF switch terminates a specification; therefore, it must not be followed by a comma as this also terminates a specification causing the LOADER to load the last file specified again. Also note, that the user must explicitly load CHAIN into his PRA. 6. PROGRAMMING CONSIDERATIONS a. When a call to CHAIN inuccessful, a new CHAIN file will be read in and execution begins af the 'starting address of the CHAIN 'file which has just been inputted. ~his starting address is governed by the usual LOADER rules and switches. This allows the user to specify different starting addresses for each link that he loads. As part of its binary output, the FORTRAN IV Compiler produces a starting address for each moin program that it compiles, and this information is used by LOADER to tell where to start a loaded program at run time. Similarly, the END statement in a Macro-lO program can be used to specify a starting address. When loading more than one program, LOADER accepts the starting address of the last program loaded which has a starting address as the starting address of the whole group of programs unless the II switch to LOADER is used. (See LOADER writeup for details .) b. CHAIN releases all I/O devices in use at the time the call to CHAIN is made. Thus I/o started by the programs of one CHAIN file cannot Be completed by the programs of another CHAIN file. In utilizing file-oriented devices, data must be organized into separate files for each CHAIN link. It is recommended that the user release all channels after the return from CHAIN. (This is done automatically by the first FORTRAN main program in each CHAIN file. ) 1 The library program loaded after the FORTRAN IV program which defines the end of the RR will be written out as part of the created CHAIN file. 8-53 c. When using the optiona I Removable Resident, ~the length of the Removable Resident may not be changed during a particular CHAIN job. If a Removable Resident is removed and then replaced, it must be replaced by a Removable Resident of the same length. f d. It is not necessary that all CHAIN files be the same size. However, the user must assign to his job enough core to accommodate the largest CHAIN file. While CHAIN is loading a new link, three errors may occur: I. The device specified in the call to CHAIN is not available. This causes the message: DEVICE xxx NOT AVAILABLE - CHAIN followed by a call to EXIT. 2. The filename specified with DECtape or disk input could not be found. This cal,lses the messag.e: FILE xxx NOT FOUND - CHAIN • followed bya call to EXIT. 3. An input error occurred while loading the actual dump file. Since CHAIN performs this input from the accumulators, its space is limited. If a read error has occurre~, CHAIN will execute a "Halt" instruction in 10catioA 14, and the Monitor will print a message on the Teletype . • 7. PROGRAM DESCRIPTION When CHAIN is called, it does a RELEASE on all I/O devices. If the specified input device is magnetic tape, the tape is positioned as specified in the call to CHAIN, otherwise a LOOKUP is done on the appropriate directory device. A CHAIN file contains an image of the appropriate portion of upper core. It also contains five preceding words which update information in the JOBDATA area (JOB4I, JOBSA, JOBSYM, JOBDDT, and length of CHAIN file). Thus five words at the end of the BLOCK DATA area (CO!",MON) or the Removable Resident are used while the new CHAIN file is being read into core. The actual input of the new CHAIN file is done by a portion of coding placed in the accumulators by CHAIN. This coding in the accumulator$ does the input of the CHAIN .file, updates J0B41, 8-54 JOBSA, JOBSYM, and JOBDDT and length of CHAIN file, and restores the five words to the area just below the CHAIN file that has been read in. Control is then transferred to the starting address for the CHAIN file just read in. However, the contents of all accumulators except 17 are altered by CHAIN. When CHAIN is called, it does not know the length of the incoming CHAIN file. This lack of information forces CHAIN to INPUT the file into the whole of available core. This lengthens the time required to complete the reading of a CHAIN ftle-which is stored on DECtape or disk and which is smaller than the amount of core available. This happens because input from these devices is not completed until sufficient data is transmitted to fill the amount of core specified with the INPUT commands1• It is to the user's advantage to load all CHAIN files into core images of approximately equal length so as to minimize the time required to input CHAIN files from DSK or DTA. With this version of CHAIN (V 50) and LOADER(V5.1), the removable resident area, when used, must remain a constant length. It is not possible to read in a link that destroys the original removable resident and then read in another link that replaces the removable resident with one of a different length. This will be fixed in further versions of CHAlN and LOADER by preserving one more word from the Job Data Area, JOBCHN. 1 However, after input is complete, CHAIN kn.ows how much data should have been read and checks for too little data transferred. 8-55 \ LINED LINED A LINE EDITOR FOR PDP-lO DISK FILES LINED is a line editor for disk files. It is used to create and edit source program files which are written on disk in ASCII code with line sequence numbers appended. LINED has the ability to reference any line at any time without the user having to close and reopen the file. LINED is a reentrant program and loads in 2K pure and 2K impure segments of core. NOTE In this document, computer typeouts are indicated by underscoring. The symbol) represents the RETURN key. The symbol represents the ALTMODE key. (!) I. MONITOR COMMANDS The MONITOR commands CREATE and EDIT may be used to select a file for editing with LINED. A temporary disk file, called DDDEDT .TMP, is created for passing the commands to , LINED. 1.1 The CREATE Command The CREATE command calls in LINED a'ld opens the specified new disk file for editing. The CREATE command is of the form: • CREATE filename.ext ) 1.2 The ED IT Command The EDIT command calls in LINED and opens the specified existing disk file for editing. The EDIT command is of the form: .!. EDIT filename.ext ) 2. LINED COMMANDS LINED indicates its readiness to receive commands by typing an asterisk. At this time LINED 8-59 is said to be in command mode. The user may then type in the followi~9 LINED commands. 2.1 .Inserting or Replacing a Line •. * Innmn nnnn nnnxx aaaa ••.••• a @ * Insert or replace the following typed Itne at line number nnnnn of the currently open file; nnnnn can be specified as a line sequence number or a. point (.), or it can be omitted entire Iy. A point refers to the last Iine which was typed, or the last I ine de leted, or the last Iine inserted. If nnnnn is omitted, it is assumed to be 10. When LI N ED has typed a Iine sequence number" the program enters text mode. In the text mode, characters typed by the user are understood to be text for the insertion. Following the user's typein of the line to be inserted, LINED types out the next sequential line number (nnnnn+l0) following which the user presses the ALTMODE key (sometimes labeled PREFIX or ESC) to terminate the insert process and retum to LINED command level. / . If there already exists a line at nnnnn, it will be replaced. A single quote following the line number indicates that insertion at this line number will cause the existing line to be replaced. 2.2 Inserting Multiple Lines *Innnnn, iiiii nnnnn aaaaa •••••• eI nnnxx bbbbb •••••• b nnnyy @ Insert the following typed lines, beg inn ing at line number nnmn (which can be specified as either a line number or a point) of the currently open file. Each time a line is entered, nnnnn is increased by the specified increment, iiiii: If iiiii is omitted, it is assumed to be 10 (if iiiii has never been specified previously), or the previous increment specified. * If nnnnn is omitted, it is assumed to be 10, and the result becomes the Iine number of the next insertion. Type ALTMODE on the line following the last insertion to return to LINED command mode. LIN ED then awaits another command. A double quote following a line number indicates that the increment specified for the current insert instruction has resulted in an existing line being skipped. 2.3 Deleting a Line * Dnnnnn Delete a line number nnnnn from the currently open filei nnnnn can be specified as either a line sequence number or a point ) 8-60 2.4 Deleting Multiple Lines * Dmmmmm, nnnnn 2.5 Printine a Line *Pnnnnn 2.6 Print lines mmmmm through nnnnn of the currently open file; mmmmm must be less than nnnnn. Either mmmmm or nnnnn may be specified as a point as long as mmmmm is less than nnnnn. Closing the Current Fi Ie E) 2.8 Print line nnnnn on the user's Teletype; nnnnn can be specified as either a line sequence number or a point. Typing ALTMODE following a typeout wi" cause the next sequential line to be printed. Printing Multiple Lines * Pmmmmm, nnnnn 2.7 Delete lines mmmmm through nnnnn from the currently open file; mmmmm must be less than nnnnn. Either mmmmm or nnnnn may be specified as a point as long as mmmmm is less than nnnnn. Closes the current file and returns to LINED command mode. At this point, the user may either open another file or type t C to return to Monitor level to assemble, list, and/or save his file on a permanent storage device (e.g., DECtape). Examples of Command Sequence Example 1 . CREATE FILEA RUN LINED AND OPEN FILE FILEA *I1,fJ "J,fJ,fJ1,fJ HE PROGRAM ,fJJj.fJ2,fJ IS INSERTED ~3,fJ HERE BEGIN INSERTING LINES AT LINE NUMBER 1,fJ INCREMENTING BY 1,fJ. " RETURN CONTROL TO LINED COMMAND MODE BY TYPING ($). CLOSE FILE FILEA BY TYPING AN E. '1'YPING A t C RETURNS TO THE MONITOR COMMAND LEVEL. . 8-61 Example 2 , . • EDIT FILEA RUN LINED AND OPEN EXISTING FILE rlLEA PRINT LINES 10 THROUGH 30 PR,INTOUT *Pl,fJ,3,fJ THE PROGRAM ,fJ,fJ,fJ2,fJ ISINS ERTE 0 ,fJ~3,fJ HERE *12,fJ ~~,fJ IS PLACED ,fJ,fJ,fJ3,fJ *D3,fJ *P 1,fJ, 3,fJ J~I,fJ THE PROGRAM ,fJ,fJ~,fJ IS PLACED *E ~tc ~,fJ,fJl,fJ INSERT LINE 20 CD 3. DelETE LINE 30 PRINT LINES 10 THROUGH 30 PRINTOUT TYPE E TO CLOSE FILE FILEA TYPING A t C RETURNS JOB TO MONITOR CONTROL LEVEL. AUXILIARY COMMANDS These Auxiliary Commands provide an alternate method of calling LINED and opening files. In most cases, auxiliary commands can be replaced by the monitor instructions CREATE and ED IT (Section 1). 3.1 R LINED LINED can be called in from the system device by typing .R LINED) * \ LINED responds with an asterisk to indicate its readiness to receive a command. 3.2 Initializing a File for Processing S filename •ext ) S filename .ext 4. Select an existing disk file,filename.ext, for ed iting • CD Select (create) a new disk file for editing, call ing it filename .ext. LINED CONVENTIONS AND RESTRICTIONS- -' The following conventions and restrictions should be noted. a. Files are written with the installation standard protection. See Book 1 for explanation of protected files. • 8-62 b. When in insert mode, typing ALTMODE following the printout of the next insertion line sequence number causes a returned to LINED command level. Typing ALTMODE to terminate a line of text to be inserted causes the text line to be ignored. ,a,af/11,.O f/1f/1f/12f/1 LINE OF TEXT CD Returns to LINED command level * ¢f/1¢I,a LINE OF TEXT CD Line is ignored * c. LINED assumes that all blocks in a disk file have an integral number of lines (i.e., each block begins with a sequence number and no line is split between blocks). This will always be the case with files which'have been created,and edited only with LINED; however, if sequence numbers have been removed, say by TECO, they may be restored by using PI P switch /A (see PDP-IO Reference Handbook.) d. LINED files can be resequenced using PIP switch jA (see PDP-IO Reference Handbook). e. Line number 0 is illegal and cannot be used. f. Lines can be edited in any order; however, editing lines by ascending line numbers reduces file access time. S. ERROR HANDLING When an error is detected, LIN ED types a message and returns the user to' LIN ED command leve I (indicated by the output of an * on the Teletype). Some errors are fatal and cause control to retum to the monitor. Error messages .for LIN ED are given in Table 1. Table I LIN ED' Error Messages Meaning Message ?FAU* Filename Already in Use. The filename specified for a newly created file already exists on the disk. Retype command correctl y • ?ILC* I L1egal Command. Illegal syntax or other error in command string. 8-63 Table 1 (C~nt.) Message Meaning ?NCF* Not Current File. The filename in,an "S filename" command could not be found on the disk. ?NFO* No File Open. No "S filename" command preceded this command st ring. ?NlN* Nonexistent Line Number. A Print or De lete command refers to a nonexistent Iine sequence number. NOTE The follow ing are internal system errors. ?CCl* CCl error. Error while referencing CCl comand file. ?COR* No core available for data segment. , ?DCPI Device directory full. ?DDE* Device Data Error. ?UNA* Unit Not Avai lab Ie. The disk is not avai lab Ie. Read or write failure On disk. 6. IMPLEMENTATION The following explanation is intended to help the user to understand how LINED works so that he may use it more effective Iy. Lines of text are stored in a 100O-Word working buffer. Each line has a I-word header containing two items. The left half contains the sequence nUl)1ber of the line, and the right half con-' tains the number of words (including the word contain ing the I ine header) needed to store the line of text. Thus, to find the beginning of the next line of text, it is necessary to simply take the address of the current line header and add the word count of the current line. Several pointer words are used to keep track of the lines in the working buffer. WRTLST contains the sequence number of the highest line in the buffer. SN contains the sequence number of the line currentl y being hand led in a command. When LI NED discovers that SN is greater than WRTLST, it knows that the Iine be ing sought has already passed through the working buffer. This line is not directly accessible, because there is no way to read a disk file backwards. Consequently, it is necessary for LINED to close the file and then reopen it. This process of going from the current position of the file to the end of the file, from there to the beginning of'the file, and finally to the line being sought is 8-64 accompl ished as fo I lows: a. To close the file, all remaining text must be passed through the working buffer to the temporary output file (called ###L1N. TMP). This is done by giving the subroutine FNDLIN (which finds a line whose sequence number is SN) the highest possible s~uence number - 99999. b. Next, the original file is renamed to ###TMP .TMP, the temporary output file is renamed to the original filename and the original file (###YMP. TMP) is renamed to name. BAK (same name as original with an extension of BAK). c. FNDLIN is then given the sequence number being sought, and LINED continues with the original command. 8-65 TEeo CHAPTER 1 INTRODUCTION TO TECO TECO, a very powerful text editor, enables the advanced PDP-l0 user to edit any ASCII text with a minimum of effort. All editing can be accomplished by using on Iy a few simple commands; or the user may select any of a large set of s~phisticated commands such as character string searching, command repetition, conditional commands, programmed editing, and text block movement. In this description of TECO only the basic commands are described. If the user requires information about the more advanced uses of TECO, he can refer to the TECO section of the PDP-IO Reference Handbook. TECO is a character'::'oriented editor. One or more characters in aline' can be modified without retyping the rest of the line. Any sort of document can be edited: programs written in FORTRAN, COBOL, MACRO-lO, or any other language; memoranda; specifications; and other types of arbitrarily formatted text. TE.cO does not require that line numbers or any other extraneous ; information be associated with the text. 1.1 GENERAL OPERATING PROCEDURE TECO operates on ASCII data files. A file is an ordered set of data on some peripheral device. In the case of TECO, a data file is some type of document. An input file may be a named file on disk or DECtape, a file on magnetic tape, a deck of punched cards, or a punched paper tape. An output file can be written onto any of these same devices. The input file for a given editing operation is the file to which the user wishes to make changes. If the user is using TECO to create a new file, there is no input file. The output file is either the newly created file or the edited version of the input file. An output file is not required if the user wishes merely to examine a file without making any changes. In general, the process of editing proceeds as follows. The user first specifies the file he wishes to edit and t hen reads in a "page II of text. A page is normally an amount of text that is intended for a single sheet of paper. Form feeds are used to separate a document into pages. Ol input, TECO interprets form feeds as end-of-page indicators. It is not required, however, 8-69 that a clocument be so divide~ into pages. If a form feed is not encountered, TEGO simply reads as much text as will reasonably fit into its editing buffer. For the purposes of this document, the word page is used to mean the segment of text in TECO's editing buffer. --- . When a page has been read into the buffer, the user can modify this text by using the various editing commands. When he has finished editing the page, he outputs it ~nd reads in the next page. This process continues until, after the last page has been output, the user closes the output file. If there are several pages where no editing is required, there are commands which may be used to skim over them. 1.2 INITIALIZATION . The two main uses of TECO are (I) to create a new disk file, and ( 2) to edit an existing disk file. These are the only uses of TECO described in this document. In particular, the use of TECO with devices other than disk is not described. The beginner can get around this limitation by using PIP to transfer files to and from disk. (Refer to Book 6 in the PDP-IO Reference Handbook for information about PI P.) The two main uses of TECO are so common that there are direct monitor commands to initialize TECO for executing them. The command • MAKE filename .ext ) is used to initialize TECO for creating a new disk file. Filename.ext is the name that the user gives to the new file. The filename can be from one to six alphanumeric c.hciract,ers. This is followed (optionally) by a period ( • ) and a filename extension of from one'to three alphanumeric cha·racters. The most commonly used filename extensions are: .F4 .CBL .MAC for FORTRAN source programs for COBOL source programs for MACRO-IO source programs The MAKE command opens a new disk file to receive output from TECO and gives it the name specified by the user. Once the file has been opened it is then actually created by' using the insert and output commands, which are explained in sections 2.5 and 2.6 of this document. The command • TECO filename .ext ) 8-70. is used to initialize TECO for editing an existing disk file, named filename ,ext, The filename and filename extension must be exact I y th~ same as those- of the file that is to be ed ited, The TECO command opens the specified file for input by TECO and opens a new file, with a temporary name, for output of the edited version. When output of the new version is completed, the original version of the file is automatically renamed filename.BAK, a~d the newly edited version is given the name of the original file. The filename extension .BAK is used for backup files. After TECO has been initialized for a particular job, it responds by typing an asterisk ( *) • The asterisk indicates that TECO is ready to accept commands; it is typed at the beginning of TECO·s operation and at the completion of exeEution of every command string. Examples: This command initializes TECO for creation of a new disk file called EARNNG.F4. The extension • F4 is used because the file is to be a FORTRAN source file. • MAKE EARNNG.F4) * • TECO This command initializes TECO for editing the existing disk file L1B40.MAC. At the completion of editing, TECO automatically changes the name of the original version of LlB40.MAC to L1B40.BAK and gives the name L1B40.MAC to the new version, L1B40.MAC) * NOTE The TECO command cannot be used to edit a file which has the filename extension .BAK.- To edit a backup file the user must first rename the backup file, For example, to edit the file L1B40.BAK the user should proceed as follows: • RENAME lIB40.0LD=LlB40.BAK) .TECO LI B40. OLD ) _ * 1.3 SPECIAL SYMBOLS USED IN THIS DOCUMENT Symbol ) The argument is "SOMETHING". " As shown in the above example, the altmode used to termi~ate an alphanumeric argument may also serve as one of the two altmodes necessary to terminate a command string. Any ASCII character except null, altmode, and rubout may be included in an alphanumeric argument. 8-74 • CHAPTER 2 TECO COMMAN OS 2.1 INPUT COMMANDS The Y (yank) command first clears the ed iting buffer and then reads the next page of the input file into the buffer. A single Y command is automatically performed by the command • TECO filename.ext) so that when editing with this command the first page of the input file is automatically read in before TECO prints the first asterisk • • The Y command may be used to delete entire pages of a file, since the editing buffer is completely cleared before the input is performed. The A (append) command reads in the next page of the input file without clearing the current contents of the ed iting buffer. This command is used to combine several pages of a document. When the A command is used, the form feed separating the page already in the buffer and the page to be read in is removed. Thus after the A command the two pages are combin!!d into one. If the editing buffer does not have enough room to accommodate an A command which has been given, TECO automatically expands its buffer and then executes the A command. The user is notified of this action by a message of the following form \ [3K CORE] If sufficient core is not available to allow buffer expansion, the user is notified by an error message. 8-75 NOTE On either an A,or a Y command the form feed terminating the _page to be read in is not actually read into the buffer. It is removed on input and a single form feed is appended to theend of the buffer when the buffer is output. Examples: • TECO REPORT.CBl) * * This command deletes the entire contents of the buffer and then reads in the next page of the input file. * Read the next two pages of the input file into the buffer, combining them with the page already in the buffer. ~A [4K CORE] * 2.2 This command, as part of the process of initializing TECO for editing the disk file REPORT .CBl, automatically clears the buffer and then reads in the first page of the file. The buffer is expanded as required by the A co mmand • In most case s th is message need be of no concern to the user. It is important only if the system is low on core and does not have swapping capabil ity • BUFFER POINTER POSITIONING Since TECO is a character-oriented editor, it is very important that the user understand the concept of the buffer pointer. The position of the buffer po inter determines the effect of many of the editing commands. For example, insertion and deletion always take place at the current position of the buffer pointer. The buffer pointer is simply a movable position indicator. It is always 'positioned between two characters in, the editing buffer, or before the first character in the buffer, or after the last character in the buffer. It is never positioned" on .. a particular character, but rather before or after the character. The pointer may be moved forward or backward over any number of characters. The J command moves the buffer pointer to the beginning of the buffer, i. e ., to the position immed iate Iy before the first character in the buffer. The ZJ command moves the pointer to the end of the buffer, i.e., to the position following . ' .. 8-76 the last character in the buffer. The C command advances the pointer over one character in the buffer. The C command may be preceded by a (decimal) numeric argument. The command nC moves the pointer forward over n characters. (The pointer cannot be advanced beyond the end of the buffer.) The R command moves the pointer backward over one character in the buffer. This command may also be preceded by a numeric argument. The command nR moves the pointer backward over n characters. (The pointer cannot be moved backward beyond the beginn ing of the buffer.) The L command is used to advance the buffer pointer or move it backward, on a line-by-Iine basis. The L command takes a numeric argument, wh ich may be positive, negative, or zero, and is understood to be one (1) if omitted. The action of the L command with various arguments is best explained in a more concrete way. Suppose the buffer pointer is positioned at the beginning of line b, or at some position within line b. The command L, or 1L, advances the pointer to the beginn ing of line b+ 1, i.e., to the position following the line feed which terminates line b. The command nL, where n > 0, advances the pointer to th~ beginning of line b+n. The command OL moves the pointer to the beginning of line b. If the pointer is already at the beginning of line b, nothing happens. The command -L moves the pointer back to the beginning of line b-1. The command -nL moves the pointer back to the beginning of line b-n. NOTE After execution of a Y command, the buffer pointer is always positioned before the first character in the buffer. (The Y command automatically executes an implicit J command.) The A command does not change the position of the buffer pointer. In examples, the position of the buffer pointer is often represented in this manual by the symbol t just below the I ine of text. &-77 Examples: .: J3L (J)(J) ,The J commend moves the pointer to the beginning of the first line in the buffer • The 3L command then moves it to the beg inn ing 0 fthe fourth line. * ':ZJ-2L Q)(J) . * This moves the pointer to the beginning of the next to last line in the buffer. - Advance the pointer to the position following the fourth character in the next line. * OL moves the pointer back to the beginning of the line it is currently on. Then 2R maves it back over the carriage return-line feed pair which terminates the preceding line. * In th is example of text stored in the buffer, the position of the buffer pointer is shown to be between B end C. 2.3 TEXT TYPE-OUT Various parts of the text in the buffer can be typed out for examination. This is done by use of . . ." the T command. Just what is typed out depends on the position of the buffer pointer and the argument given. The ~T command never' moves the buffer pointer. The command T types out everything from the buffer pointer through the next line feed. Thus, if the pointer is at the beginning of a line, the command T causes that line to be typed out. If the pointer is in the middle of a line, T causes the portion of the line fOllowing the pointer to be typed. The command nT ( n > 0) is used to type out n lines, i.e., everytliing from the buffer pointer through the nth line feed following it. The command OT types out everything from the beginning of the current line u'p to the buffer pointer. This is useful for determining the position of the pointer. The command HT types out the entire contents of the: buffer. The user, especially one new to TECO, should use the T command often, to make sure the buffer pointer is where he thinks it is. 8-78 During execution of any T command, the user may stop the Teletype output by typing the (control 0) character. to This command causes TECO to finish execution of the command string, omitting all further type-out. The to command does not carryover to the next command string. Examples: .: OlT ClXD ENTI RE LIN E TYPED * .: OTT (00) ENTIRE LINE TYPED * .: 2T 0, deletes the n characters immediately following the pointer. The commands -D and -nD delete the character or the n characters, respectively, which immediate Iy precede the buffer pointer. Lines are deleted using the K command. The K command may be preceded by a numeric argument I which is understood to be 1, if omitted. The command n K (n> 0) de letes everything from the current Position of the pointer through the nth line-feed character following the pointer. The command H K deletes the entire contents of the buffer. At the conclusion of a D or K command the buffer pointer is positioned between the characters which precede and follow the deletion. 8-79 Exa!"ples: The editing buffer contains the following three lines of text, and the pointer is positioned between the G and H. ABCDEF~t·iIJKLM:) ~ NOPQRSTUVWXYZ ) ~ 1234567890) ~ ~ 4D (00) Delete HIJ K • -~* -D (00) Delete G. * ~ -3D (00) Delete EFG. * Delete HIJ KLM) but do not delete the line feed at the end of the first line. * Delete HIJKLM) ~ • Since the carriage return and line feed at the end of the first line are deleted, the text in the buffer after this command would be: ABCDEFGNOPQRSTUVWXYZ) ~ , 1234567890) ~ * ~ 2KlOD axJ) -* :: OlK G)G) * :: l2K axJ) This would leave the buffer containing only ABCDEFG) ~ • . This is the command string that is required to kill (delete) the entire first line. This kills the last two lines. * Kill the entire buffer. * 2.5 INSERTION COMMAND The only insertion command is the I command.' The ASCII text that is to be inserted into the buffer is typed immediately after the letter I. ,The text to be i!,serted is terminated by an altmode. Any ASCII character except null, altmode, and rubout may be included 'in the text to be inserted. Specifically, spaces, tabs, carriage returns, form feeds, Iine feeds, and control ~80 characters are all allowed. If a carriage return is typed in an insertion, it is automatically followed by a I ine feed. The text to be inserted is placed in the buffer at the position of the buffer pointer, i.e., between the characters. At the conclusion of the insertion command the buffer pointer is positioned at the end of the insertion. Any number of lines may be inserted with a single I command. For the user's protection, however, no more than 10 to 20 I ines should be inserted with each I command. Examples: If the buffer contains ABCDlF) ~ with the pointer between D and E, the command .: IXYZ G)G) produces' ABCD XYZj- F ) ~ * produces ABCD) ~ !F)~ * *I~ produces G)(j) ABCD + EF) + t * produces AABCD~f) ~ * .: I( FORM) (00) * * JILINE ONE) LINE TWO) LINE THREE) This command is used to separate the page in the buffer into two pages. Both pages, however, remain in the buffer. They are not actually separated until output. This example shows insertion of several lines of text at the beg inn ing of the Duffer. (00) * 8-81 '1 * . This is the command string used to.delete the tail of a line without removing the carriage return-I ine feed at the end of the line. If the buffer contains This command will produce 2.6 OUTPUT COMMANDS The command P causes ( 1) the entire contents of the editing buffer to be output to the output file and ( 2 ) an impl icit Y command to be performed which reads in the ne~t page of the input file. This command is used after editing of a given page is complete and the user is ready to move on to the next page. The P command may be used with a posit~ve numeric argument to skim over several pages. Specifically, the nP command causes the n consecutive pages of the input file, starting with the page in the ed iting buffer;, to be output, and then the n+lst page to be yanked in. The PW command merely outputs the page currently in the editing buffer. It does not clear the buffer, it does not read in any more text, and it does not move the buffer pointer. This command is used when creating a new file. It is also used to output the last page of a file. I f the buffer is empty, the PW and P commands have no effect. The EF command must be used to close the output file after all output to it is complete. EF is normally used after the PW command which outputs the last page of the file. Examples: .: PWE F * 2.7 If, for example, page 6 of a document is in the ed iting buffer, this command causes pages 6 through 13 of the document to be output, one after the other, and then reads in page 14. SPECIAL EXIT COMMANDS The EX command is used to conclude an editing job with a minimum of effort. Its use is best shown by an example. Suppose the user is editing a 30-page file and suppose that the last actual change to the file is made on page 10. At this point the user gives the command .: EX (J)(J) .!. In this case the action performed by TECO is equivalent to the command string 20PPWEF, with an automatic return to the mon itor at the end. Thus, the action of TECO is ( 1) to rapid Iy move a" the rest of the input file on to the output file, (2) close thE! output file, and ( 3) to return control to the monitor. The EG command is even more efficient. This command performs exactly the same functions as the EX command, but after that it causes re-execution of the last COMPILE, LOAD, EXEOJTE, or DEBUG command attempted before TECO was called. For example, suppose the user gives the command .!. COMPILE PLOT. F4) to request compilation of a FORTRAN source program, but the compiler discovers error,S in the code. The user would then call TECO to correct these errors: • TECO PLOT. F4) * When" all the errors are edited, the user exits from TECO with the command .: EG GXi) 8-83 This causes'the COMPILE commarld to be executed again on the me PLOT. F4, after TECO has finished output of the file, Any TECO job may be aborted by using the standard return-to-monitor command: tC t C (contro'l C typed twice). However, ·if this command is typed before the output file is closed, the output file is lost. If no input or output operations are in progress a single tc is sufficient to exit from TECO to the mOnitor. In such a case, the user may reenter TECO without destroying the job he was previously executing. This is illustrated in the following example • .!. TECO SOURCE,MAC) A TECO job is started • .: ICOMMENTS (jX1) The user exits to perform a few simple monitor commands. . .: tc .• DEASSIGN LPT) • DAYTIME) 24-FEB-70 • REf) * 2.8 10:34 The user reenters TECO. The previous buffer is still intact, SEARCH COMMAND S In many cases the simplest wc,y to position the buffer pointer is by using a character string search. A search command causes TECO to sc"an through the text ~ntil a specified 'string of characters is fou~, and then to position the po inter at the end ~f th is string. There are two main search commands., The S command is used to search for a character string within the editing buffer. The string to b~ searched for is specified as an alphanumerical argument following the S command. This argument must be terminated by an altmode. The character string to be searched for may contain any ASCII character except null, altmode, or rubout. The S command may be preceded by a numerical argument n > 1. This argument is used to search for the nth occurrence of a character string. Thus a 2S comma~d searches for the second occurrence 'of the part,icular character string, skipping the first occurrence. If n)s omitted, n =1 is assumed. 8-84 Execution of the S command begins at the position of the buffer pointer and continues t,o the end of the buffer. If the specified character string is not found in this range, an error message is printed and the buffer po inter is set to the beginn ing of rhe buffer. Examples: This causes the pointer to be positioned after the B in the first occurrence of the string A - tab - B past the current position of the pointer. * ~ J 2SN AME ax1) * / * S20) TAG: TAG: OTT (j)G) FORMA T( 1X, WORD ') ~1~WORD2~ Here the user wishes to insert "~WO RD 2" after "WORD". He wisely types out the line to make sure he is at the right place, before inserting "WORD2" • * The other principle search command is the N command. The difference is that an S search ends at the end of the current buffer, whereas an N search does not. An N search begins like an S search, but if the character string is not found in the current buffer, an automatic P command is executed. The current page is outputted, the next page read in, and the search continued on the new page. This process continues until either the string is found or the input file is exhausted. 8-85 'If the .N.'search does find the specified character string, the pointer is positioned at its end • Inlle string is not found, an error message is generated. In this case the user caused himself a fair' amount of delay. If an N search fails, the user must close the file with an. EX command, then reopen it and try the N search ,again with a character string that can be found. The user is strongly urged to be careful when typing search character'strings. Remember also that a search string must be terminated with an altmode. Example: ~ NSTRIN G - 3D (J)(J) Her.e the user meant to search for the character string" STRING", and to delete the last th'ree characters of tile st ring. However, he forgot to terminate the search string with an altmode and this caused the unsotisfied search request errormessoge (?35 ). ?35 * EX (J)(D • TECO fi lena me .ext ) ~ NSTRING (1)- 3D axJ) * 8-86 CHAPTER 3 ERROR MESSAGES When TEce encounters an illegal command or a command that for any other reason cannot be executed, a numeric error message is printed on the user's Teletype. Such messages are of the form 1nn where nn is a two-d igit decimal integer that refers to the following table of error messages. When an error message is generated, the command to which it refers is not executed, the 'remainder of the command string is ignored, and TECe returns to the id Ie state by typing an asterisk and awaiting a new command string. The novice user is especially warned that there are a great many TECe commands that have not been described in this introductory material. Almost every letter of the alphabet and many of the special characters have meanings as TECe commands. Hence, the user should be careful when typing command strings. The beginner should probably stick to relatively short command strings. In the following table, all TECO error messages ore listed, even though som@! of them refer to the more advanced commands not described in this manual. Error messages referring to the advanced commands will probably be encountered by the user of this introductory material only if he has typed an unintended command letter. The complete set of TECO commands is fully described in the TECO section of the PDP-lO Reference Handbook. Since most editing can be done using only the basic commands covered in this introductory material, most users should be able to get along without the more advanced description for some time. The novice should gain complete mastery of the basic commands before attempting to use any of the advanced commands. 8-87 · Table 3)" 1 TECO Error Messages nn 1 2 Meaning where n=O is illegal. 8-89 Appendices Index A Bibliography of PDP·tO Programming Documents APRIL, 1970 To solve several customer problems, the POp-to Product Line has initiated a new documentation system. POP-tO software information is now being printed in two handbooks and a series of notebooks. The handbooks and the notetiooks will contain essentially the same material; the notebooks, however, will be updated more frequently with insertable pages. Two handbooks "PDP-IO Timesharing Handbook" and PDP-lO Reference Handbook" now duplicate software manuals. These handbooks are easy to handle and store, and to assure availability, they are printed in large quantities. Revision and reprinting of the handbooks is done every six months. Customers will receive twenty copies of each handbook with the signing of the pur9hase order for the POP-tO and twenty more copies with the delivery of the machine. Each customer will also receive, free of charge, two copies of the PDP-IO software note~ooks--a multiple volume set of manuals in the BY.! by II" format. The notebooks are printed on high quality paper allowing the customer to effectively reproduce the material. Tec;:hnical accuracy is maintained with quarterly update pages to the notebooks. Since most PDP-IO software information is presently included in the handbook, it is no longer necessary to print separate manuals. Therefore, except when information is not contained in the handbooks, individual manuals can no longer be ordered. This Bookshelf serves to indicate in which handbook manuals are now located. If the manuals are not located in either handbook, the order number and price are given. . Available manuals and additional copies of the handbooks may be obtained from Digital Sales Offices or by sending a written request (with check or money order) to Program Library, Digital Equipment Corporation, Maynard. AID (Algebraic Interpretive Dialogue) A 'hands-on' guide to the use of AID at the Teletype. AID, a PDP-IO version of JOS81, is an on-line system which provides each user with a personal computing service utilizing a conversational algebraic language. This manual describes the use of the Teletype, the syntax and general rules governing the AID language, and each of the AID commands, with appropriate examples. Contained in PDP-lO Time-sharing Handbook. PDP·tO Reference Handbook This handbook is a comprehensive volume of information for experienced programmers, systems analysts, and engineers who are interested in writing and operating assemblylanguage programs in the PDP-lO tillie-sharing environment. Included in the handbook are four manuals (System Reference Manual, MACRO-lO Assembler, Time-Sharing Monitors, and DDT-IO), editor programs (Editor, LINED and TECO), and utility programs (LOADER, PIP and TENDMP). A sample LOGIN procedure, a convenient summary of monitor commands, and a comprehensive index/ glossary make this handbook a valuable reference for the person interested in assembly-language programming. Order No. AIW $5.00 Single·User Monitor System Revision September, t969 A complete guide to the use of the Single-User Monitor, which performs fast job-to-job sequencing, provides II 0 service for all standard devices, and is upward compatible with the Time-Sharing systems. Order No. DEC-IO-MKZA-D $2.00 PDP·tO Timesharing Handbook This is a tutorial document intended primarily for students, scientists, engineers, and financial analysts who have no experience in programming. It contains an introduction to timesharing and an explanation of the elementary and advanced monitor commands. Included are the three reference manuals BASIC, AID, and FORTRAN, as well as procedural descriptions of Batch, CHAIN, LINED, and TECO. The four demonstration programs in Book 6 enhance the tutorial aspect of the handbook. Order No. AKW $5.00 Batch Processor (Batch) and Job Stacker (Stack) An indexed manual containing all information required to prepare and run user jobs under control of the Batch Processor in either a single-user or time-sharing environment. (Batch supervises the sequential execution of a series of jobs with a minimum of operator attention, yet allows the operator to interrupt, skip, repeat, or prematurely terminate one or more of the jobs in the series at any time.) Job Stacker is used in conjunction with Batch to (I) transfer job files to the Batch input device and stack them there for subsequent input to Batch, (2) transfer Batch output job files from the Batch output device to some other device, (3) list job file directories, (4) delete job files, and (5) list directories with selective file deletion or transfer. Contained in PDP-IO Time-Sharing Handbook. PDP· to System Reference Manual An indexed programmer's handbook that describes the PDP10 processor and the basic instruction repertoire. Following an introduction to the PDP-I0's central processor structure, general word format, memory characteristics, and assembler source-programming conventions, this manual presents the specific instruction format, mnemonic and octal op codes, functions, timing formulas, and examples of each of the basic instructions. Several helpful appendices, including mnemonic op code tables, al~orithms and timing charts, complete the manual. Contamed in PDP-IO Reference Handbook. System User's Guide Revision August, 1969 A fact-filled operations guide designed for handy reference at the user's Teletype. Contains the basics of Teletype usage and complete operating procedures for all Commonly Used Systems Programs (CUSPs). Includes complete write-ups on DECtape Editor, BASIC, LINED, and Linking Loader. A typical chapter includes a brief descriptioo of the program, its operating environment, initialization procedures, command string formats, special switches, diagnostic messages, and indepth examples. The' manual is tab-indexed for the user's convenience. Order No. DEC-lO-NGCC-D $10.00 Time-Sharing Monitors: A complete guide to the use of the PDP-lO's two powerful, real-time, mUltiprogramming, time-sharing Monitors. All Monitors schedule multiple-user time sharing of the system, allocate facilities to programs, accept input from and direct output to all system 1/ 0 devices, and relocate and protect user programs in storage. This manual details user ip.teraction with the Monitors, from botIi a programming and operating viewpoint, and contains several quick-reference tables of commonly used Monitor commands and parameters, as well as examples of user coding. Contained in PDP-lO Reference Handbook. 1JOSS is a trademark and service mark of the RAND Corporation for its computer program and services using that program. A-l PIP (Peripheral Interchange Program) Explains how PIP is used 'to transfer data files between standard peripheral devices. Shows .llow command strings are written, describes switches available for optional functions, techniques for handling file directories, error messages and other features. Contained in PDP-IO Reference Handbook. COBOL LANGUAGE August, 1969 A reference ~ manual designed to aid the user in writing COBOL programs for the PDP-IO. Each COBOL language element is accorded a detailed treatment that explains and demonstrates its use in a variety of programming contexts. The four major divisions of a COBOL program and their conventional formats are clearly described and. effectively illustrated. Other subjects given extended coverage in this manual are the COBOL library, COBOL reserved words, and the CALL procedure. Each chapter contains numerous examples of the efficient use of the components of a COBOL program. Indexed. Order No. DEC-lO-KCIA-D $6.00 FORTRAN IV This manual describes statements and features of FORTRAN IV on the PDP-IO. Includes descriptions of library· functions, calling library subroutines from the Science Library, and the FORTRAN IV operating System. An appendix contains language differences for those using the small (5.5K) PDP-lO FORTRAN Compiler. Contained in PDP-IO Time-Sharing Handbook. Science Library and Fortran Utility Subprograms Revision March, 1969 A general reference manual covering Science Library arithmetic function and utility subprograms and FORTRAN IV nonmathematical utility subprograms. A functional description followed by the calling sequence, list of external sub'programs called, entry points, and subprogram length, is given for each subprogram. In addition, the type of argument(s) and result, a description of the algorithm used, and a discussion of the accuracy of the algorithm are given for each function. Appendices contain information on error analyses, double-precision format and input conversion, a bibliography, and average run times. l Order No. DEC-IO-SFLE-D $4.00 MACRO-I0 Assembler The programmer's reference manual for the PDP-IO assembly system. Explains format of statements, use of pseUdo-operations, and coding of macro instructions which make MACRO-IO one of the most powerful assemblers available. Contained in PDP-IO Reference Handbook. PDp·tO Reference Card Revision November, 1969 . A handy pocket-sized guide to instruction mnemonics, hardware and software (Monitor system) word formats, and instruction codes. Order No. DEC-IO-JOOB-D $0.25 DDT·I0 (Dynamic Debugging Technique) This reference manual describes the dynamic debugging program used for on-line checkout and testing of MACRO-IO and FORTRAN programs. The commands .of DDT are grouped so that they can be used easily and effectively by both the uninitiated user and the experienced programmer. Included in the appendices is an informative summary of all DDT functions. Contained in PDP-lO Reference Handbook. The following supplementary documents are also available from the Program Library. TECO (Text Editor and Corrector) , I . Minor Revision, August, 1969 This programmer's reference manual describes the powerful context editor for the PDP-IO. Editing is done on a character, line or variable character string basis. Describes more than 30 commands for inserting, deleting, appending, searching for, and displaying text. Contained in PDP-IO Reference Handbook. BASIC A valuable guide to the BASIC® commands needed for a efficient expression of scientific, business, and educational problems. The manual contains complete tutorial explanations of these additional features: (1) matrix computations; (2) alphanumeric information handling; (3) program control and storage facilities; (4) program editing capabilities; (5) formatting of Teletype output; and (6) documentation and debugging aids. Contained in PDP-IO Time-Sharing Handbook. ® Registered: Trustees of Dartmouth College A-2 PDP-lO DECtape Copy Program (COPy) DEC-IO-RPTA-D 1.00 FORTRAN IV Software Maintenance Memos Linking Loader V.27 'DEC-IO-KFIA-D DEC-IO-LLZA-D 1.00 1.00 FORTRAN IV Utility Subprograms (RELEAS, MAGDEN, BUFFER, IFILE, and OFILE) DEC-lO-FIYB-D 1.00 S680I-DC68A Data Line Scanner for PDP-IO DEC-IO-FWVA-D 1.00 Program Logic Manual for the PDP-IO Time-Sharing Monitors DEC-IO-MRZA-D-(L) 4.00 APPENDIX B PDP-l0 SOFTWARE Table B-1 lists PDP-l0 system programs and the documentation pertaining to them. For a description of each of the documents, refer to the Bookshelf in Appendix A of this handbook. Table B-1 PO P-l 0 Software Software Documentation Document Order No. PDP-l0 Timesharing Handbook (Book 4) AKW PDP-l0 Software Notebook DEC-l0-SYZA-D System User's Guide DEC-l0-NGCC-D PDP-l0 Timesharing Handbook (Book 3) AKW PDP-l0 Software Notebook o EC-lO-SVZA-D PDP-l0 Timesharing Hardbook (Book 8) AKW PDP-l0 Software Notebook DEC-lo-SYZA-D PDP-l0 Referenc.e Handbook (Book 6) AIW PDP-l0 Software Notebook DEC-l0-SYZA-D System User's Guide DEC-l0-NGCC-D PDP-l0 Timesharing Handbook (Book 8) AKW PDP-l0 Software Notebook DEC-IO-SYZA-D CHKPNT Pf)~-10 Software No.tebook (System Manager's Guide) DEC-lO-SYZA-O COBOL COBOL language DEC-l0-KC lA-D PDP-l0 Software Notebook DEC-IO-SYZA-D AID BASIC Batch BINCOM CHAIN B-1 .. Table 8-1 (Cont.) , , -, SoftwQr~:' '. ,PDP-I0 Reference Handbook (Book 2) COMPIL AIW PO'P-lO Software Notebook DEC-I0-SYZA-D PDP-lO DECtape Copy Program '(COPY) DEC-I O-RPT A-D PDP-lO Software Notebook DEC-I0-SYZA-D PDP-I0 Reference Handbook (Book 5) AIW PDP-lO Software Notebook DEC-I0-SYZA-D PDP-I0 Reference Handbook. (Book 5) AIW PDP-I0 Software Notebook DEC-I O-SYZA-D System User·s Guide DEC-I0-NGCC-D PDP-I0 Timesharing Handbook (Book 8) AKW PDP-lO Software Notebook DEC-I0-SYZA-D DSKLST PDP-I0 Software Notebook (S'ystem Manager·s Guide) DEC-I0-SYZA-D EDITOR PDP-I0 Reference Handbook (Book 4) COpy CREF DDT DRIVER . .' AIW PDP-I0 Software Notebook DEC-I0-SYZA-D ~----------T-----------------------~------T-----------~----~ FAILSAFE PDP-lO Software Notebook (System Manager·s Guide) DEC-I0-SYZA-D FILDDT PDP-I0 Software Notebook (System Manager·s Guide) DEC-I0-SYZA-D FORTRAN PDP-lO Timesharing Handbook (Book 5) AKW PDP-I0 Software Notebook ,. . DEC-I0-SYZA-D System Userrs Guide' ",;,'}t DEC-I0-NGCC-f) " .•• i 1",- ,,', " FUDGE2 PDP-lO Reference Handbook (,Bbok :6) PDP-I0 Software Notebook B-2 ,'" '.' . AIW': DEC-I0-SYZA-D Table 8-1 (Cont.) Software GL08 LINED LOADER LOGIN LOGOUT Documentation Document Order No. PDP-l0 Reference Handbook (Book 6) AIW PDP-lO Software Notebook DEC-l0-SYZA-D PDP-l0 Reference Handbook (Book 4) AIW PDP-l0 Timesharing Handbook (Book 8) A~ PDP-l0 Software Notebook DEC-l0-SYZA-D PDP-lO Reference Handbook (Book 3 ) AIW PDP-l0 Software Notebook oEC-l0-SYZA-D PDP-lO Reference Handbook (Book 3) AIW PDP-l0 Software Notebook (System Manager's Guide) DEC-l0-SYZA-D PDP-lO Reference Handbook (Book 3) AIW PDP-l0 Software Notebook {System Manager's Guide) DEC-lO-SYZA-D . MACRO PDP- to Reference Handbook (Book 2) AIW PDP-lO Software Notebook DEC-lO-SYZA-D System User's Guide DEC- JO-NGCC-D . MONEY PO P-lO Software Notebook (System Manager's Guide) DEC-lO-SYZA-D MONGEN PDP- JO Software Notebook (System Manager!s Guide) DEC- JO-SYZA-D MONITOR PDP-lO Reference Handbook (Book 3) AIW PDP-lO Software Notebook DEC-lO-SYZA-D PO P-l 0 Reference Handbook (Book 3) AIW PDP-lO Software Notebook DEC-lO-SYZA-D PIP 8-3 Table 8-1 (Cont.) Software Document Order No. Documentation PIP1 PDP-10 Reference Handbook (Book 3) AIW PDP-10 Software Notebook DEC-10-SYZA-D I PRINT < PRINTR DEC-10-SYZA-D PDP-10 Software Notebook ($ystem Manager's Guide) . DEC-10-SYZA-D , REACT PDP-IO Software Notebook (System Manager's Guide) DEC-10-SYZA-D SRCCOM PDP- 10 Reference Handbook (Book 6) AIW PDP-10 Software Notebook DEC-lO-SYZA-D System User's Gu ide DEC-10-NGCC-D STACk PDP-10 Software Notebook SYSTAT PDP-10 Reference Handbook (Book 3) AIW PDP-10 Software Notebook DEC-1 O-SYZA-D PDP-10 Reference Handbook (Book 4) AIW PD,P-10 Timesharing Handbook (Book 8) A~ System User's Guide DEC-10-NGCC-D PDP-10 Software Notebook DEC-l0-SYZA-D PDP-10 Reference Handbook (Book 6) , AIW PDP-lO Software Notebook DEC-10-SYZA-D TECO - PD P-1 0 Software Notebook (System Manager's Guide) TENDMP . DEC-l0-SYZA-D i' '''' 8-4 , INDEX Page numbers refer to the book and the page number ~ithin the book; i.e., 3-42 is the 42nd page of Book 3. A command, TECO, 8-75 A format, 5-44 ABS function, 3-14, 3-73 Absolute value, 3-14, 3-73, 4-10, 4-23 ACCEPT stat~ment, 5-58, 5-77 Access time, 1-10 Access to BASI C, 3-29, 3-32 Accumulator conventions, 5-111 Accuracy of AID, 4-11 Addition, 4-10, 4-23 Adjustable dimensions, 5-63 Allocating system resources ASSIGN monitor command, 7-4 CORE monitor command, 7-8 DEASSIGN monitor command, 7-6 FINISH monitor command, 7-7 REASSIGN monitor command, 7-7 Alphanumeric fields, 5-44 AlPHI. routine, 5-84 AlPHO. routine, 5-84 AlTMODE key, 2-20 Argument, FORTRAN, definition, 5-24 Arithmetic error conditions, FORTRAN, 5-121 Arithmetic Formulas, AID, -4-19, 4-78 Arithmetic function definition statEm ent 5-71, 5-79 Arithmetic operations, BASIC, 3-13 Arithmetic operations on complex numbers, FORTRAN, 5-21 Arithmetic statement, ,FORTRAN, 5-29 Array dimensioning, 5-22, 5-62 Arrays, 4-21, 5-22 ASCII character set, 5-125 ASCII mode DECtape , 5- 128 disk, 5-128 magnetic tape, 5-131 $Assign Card, Batch control card, 8-20 PROTECT, 8-20, 8-21 ASSIGN monitor command, 7-4 ASSIGN statement, 5-32, 5-77 ASSIGN SYS monitor command, 7-15 Assigned GO TO statement, 5-32, 5-77 Asterisk convention, 2-11 Asynchronous design, 1-6 ATN function, 3-14, 3-73 ATIACH monitor command, 7-8, 7-16 Augmented matrix, 6-11 Background job, 7-8 BACKSPACE statement, 5-39, 5-59, 5-77 Batch diagnostic messages, 8-28 equipment requirements, 8-11 examples, 8-33, 8-39 introduction, 8-7 processing under PDP-I0 monitors, 8-7 processor, 8-7 Batch control cards 'Tape, 8-21 $*Cald, 8-27 $**Card, 8-28 $ ASSIGN Card, 8-20 $ BIN, e-24 $ CBl, 8-il $ CREF, 8-23 $DUMP, 8-27 $ EOF, 8-26 $ EOJ, 8-26 $EXCDR, 8-23 $ F4, 8-21 $ GET, 8-25 $JOB, 8-16 KEY, 8-18 $LDR, 8-23 $MAC, 8-21 Index-l (".: A-" ',' '; Clock, 1-5 Closed subroutines, 5-71. . COBOL compilation,' 8-21. Coding form, FORTRAN, 5-16, ':' Command " ", direct, definition,' 4-10 indirect, definition, 4-10 Command summary, AID, 4-80 Comment line, FORTRAN; 5-16 COMMON area, CHAIN, 8-47 Common block, FORTRAN, 5-64 COMMON statement, 5-64, 5-66, 5-78 Common storage, FORTRAN, 5-64 COMPILE monitor c~mmand, 2-13 Complex constants, FORTRAN, 5-20 Complex fields, 5-46 Complex subexpression, 5-25 COMPLEX, type declaration statement, 5-68, 5-78 Compound expressions, FORTRAN logical, 5-28 numeric, 5-24 Compute bound, 1-6 Computed GO TO statement, 5-31, 5-77 Conditional expressions, 4-32, 4-78 Conditional GO TO statement see IF-THEN Constants, FORTRAN complex, 5-20 double precision, 5-20 integer, 5-19 literal, 5-21 logical, 5-21 octal, 5-20 real, 5-19 Context switching, 1-5 CONTINUE monitor command, 3;'32, 4-10, 7-13 CONTINUE statement, 5-36, 5-77 Control commands, BASIC, 3 -65 Control statements, FORTRAN, 5-31, 5-77 CALL, 5-75 CONTfNUE, 5-36 DO, 5-34 END, 5-37 GO TO, 5-31 IF, 5-32 PAUSE, 5-36 RETU RN , 5-75 STOP, 5-37 CONTROL-C, 2-18, 3-31, 3-:66., .4-9 CONTROL-F, 2-20, 4-11, 4-12 . Core image ~ 2-3, 2-13' , CORE monitor command, 7-8 $ PAUSE, 8 - 2 i ' - ' $ RUN, 8-2S $ SAVE, 8-24 $ SSAVE, 8-24 $ START, 8-26 Batch processing, 1-3 $ BIN Card, Batch control card, 8-24 Binary ,mode DECtape, 5- 128 disk, 5-128 magnetic tape, 5-131 BINWR. routine, 5-85 Blank common, 5-64 Blank fields, 5-49 Blank records, 5-47 BLOCK DATA statement, 5-68, 5-76 BLOCK DATA subprogram, 5-76 Block identifier, 5-64 Block name, 5-64 Block of words, 1-10 Boolean expressions, 4-11,4-20,4-31 Brackets, AID, 4-10, 4-23 BTEMP, 8-11, 8-12, 8-19 Buffer pointer positioning, TECO, ,8-76 'Buffer sizes of peripheral devices, 5-127 BU FFE R subroutine, 5-90 h C TECO command" 8-77 CALL statement, 5-75, 5-77 CANCEL command, 4-37; 4-80 $*Card, Batch control card, 8-27 $**Card, Batch control card, 8-28 Card notation, Batch, # , 8-16 braces, 8-16 lower case letters, 8- 16 parameters, 8- 16 parentheses, 8- 16 Cards acceptable as Batch input card description, 8-16 card notation, 8-16 Carriage control, FORTRAN, 5-45, 5-48 $ CBL Card, Batch control card, 8-21. CCONT monitor command, 7-15 CHAIN calling sequence, 8-50 Chain files, 5-90, 8-47 CHAIN job implementation, 8-47 CHAIN program description, 8-54 CHAIN programming considerations, 8-53 CHAIN subroutine, 5-90, 8-47 CHAN G,E instruct jon , 3-61, 3-63 Character set, AID, 4-85 Character set, ASOI, 5-125 Character set, FORTRAN, 5-17 Index-2 ''1'; Correcting typing errors AID, 4-13 BASI C, 3-30,,3-31, 3-34 Monitor, 2-19 'TECO, 8-73 Cremer's method, 6-13 CREATE monitor command, 2-7, 8-59 Creating files CREATE monitor command, 2-7 MAKE monitor command, 2':'9 Creation of CHAIN files, 8-50 $CREF card, Batch control card, 8-23 cross reference assembly listing, 8-23 CREF monitor command, 7-10 Cross-reference listing, 7-10, 8-23 COS function, 3-14,3-73 C?sine, 3-14, 3-73 COT function, 3-14, 3-73 Cotangent, 3-14, 3-73 CSTART monitor command, 7-15 CTEST mon itor command, 7-16 o format, 5-40, 5-44 o LINED command, 8-61 o monitor command, 7-15 o TECO command, 8-79 Data block, 3-16, 3-61 Data file capability, BASIC, 3-67, 3-73 Data line multiplexor, 1-8 Data line scanner, 1-8 Data record, 5-53Data set, 1-8 DATA statement, BASIC, 3-11,3-12,3-13, 3-16, 3-71 DATA statement, FORTRAN, 5-66, 5-78 Data specification statements, 5-61 DATA, 5-66, 5-78 BLOCK DATA, 5-68, 5-76 Data specification subprogram, 5-68 Data transm iss ion statements, 5-39, 5-77 ACCEPT, 5-58 o ECOD E, 5-59 EN COD E, 5 -59 PRINT, 5-53 PUNCH, 5-54 READ, 5-56 REREAD, 5-57 TYPE, 5-54 WRITE, 5-54 DATA; UUO, 5-85 DATE subroutine, 5-90 DAYTIME monitor command, 2-16 DDT monitor command, 7-14 Index-3 DDT submode, 8..25 DEASSIGN monitor command, 7-6 DEBUG monitor command, 2-14 Debugging programs DEBUG monitor command, 2-14 in Basic, 3-34 DECODE statement, 5-59, 5-77 DECtape usage, 5-128 DEC. UUO, 5-86 Oedicated system, 1-4 DEF function, 3-40, 3-74 Defensive software, 1-12 DEFINE ALE statement, 5-55 Defined function, 3-41, 3-74 Defined locations, 5-111 DELETE, AID command, 4-39, 4-80 DELETE, BASIC command, 3-65 D ELET E, monitor command, 2-12 Deletion commands, TECO, 8-79 DEMAN 0 command, 4-18, 4-41, 4-80 Demonstration programs curve-fitting, 6-8 random-number generator, 6-36 remaindering, 6-26 sum of squares, 6-4 DET function, 3-55, 3-74 DETACH,monitor command, 7-8, 7-15 Device assignments, 5-128 Device control statements, 5-58, 5-77 BACK SPACE, 5-59 END FILE, 5-59 REWIND, 5-59 SKIP RECORD, 5-59 UNLOAD, 5-59 Device table, FORTRAN, 5-129 DEVTB., , 5-129 Diagnostic messages AID, 4-87 BASIC, 3-75 BATCH, 8-28 FORTRAN, 5-116 monitor, 7-16 LINED, 8-63 TECO, 8-87 Diagnostic software, 1-1 2 DIM statement, BASIC, 3-26, 3-28, 3-52, 3-74 DIMENSION statement, FORTRAN, 5-62, 5-78 adjustable dimension, 5-63 Dimensioning, BASIC, 3-26, 3-28, 3-52, 3-54 Direct command, definition, 4-10 Direct steps, 4-15 Directory format' , long format, 2-11 short format, 7-10 DIRECtORY, monitorcommond,2-11,7-1O DIRT. rOutine, 5-84 ., J DISCARD command, 4-45, 4-80, 4-84 Disk usage, 5-128 Division, 4-10, 4-23 DO command, 4-18, 4-34, 4-46, 4-80 DO statement, 5-34, 5-77 DON E command, 4-51, 4-80 DOUBLE PRECISION, type declaration statement, 5-68, 5-78 Double precision constants, FORTRAN, 5-20 Double word, FORTRAN, 5-25, 5-27 DOUBT. routine, 5-84 Driver equipment requirements, 8-30 general description, 8-29 implementation, 8-30 use of, 8-30 Dual memory protection and relocation, 1-8 Dummy arguments, AID, 4-20 Dummy arguments, FORTRAN, 5-72, 5-73 Dummy identifiers, 5-71, 5-72 DUMP, 8-27, 8-29, 8-31 DUMP subroutine, 5-91 $ DUMP card, Batch control card, 8-27 E format, 5-40, 5-44 E, LIN ED command, 8-61 E( monitor command, 7-15 Edit commands, BASIC, 3-65 EDIT, monitor comman<;l, 4-9, 8-59 Ed iting files EDIT monitor command, 2-9 TECO monitor command, 2-10 EF, TECO command, 8-82 EG, TECO command, 8-83 ENC. UUO~ 5-86 ENCODEstatement, 5-59 END OF FILE statement, 5-59 END statement, BASIC, 3-11, 3-19, 3-72 END I statement, FORTRAN, '5-37 Entering a BASIC program, 3-30, 3-32 $EOF card, Batch c.ontrol card, 8-26 EOF1 subroutine, 5-91 EOFC subroutine, 5-91 $ EOJ card, Batch control card, 8-26 Equipment requirement$ fpr BATCH, 8-11 EQUIVALENCE statement, 5-65, 5-66 Errors, BASIC . grammaticq,l, 3-34. logical, 3:"34 fRRSET subroutine, 5",:,91 EX, IECO commqnd, 8-83 Examples, BATCH, . 8-33, 8-'39 Examples, LIN ED., 8-61 EXECUTE, monitor command, 2-14 Executing a BASIC program, 3-31, 3-33, 3-35 Executing programs EXECUTE monitor commqnd, 2-14 Executive mode, 1-9 Executive program, 1-5 Exit commands, TECO, 8-83, EXIT subroutine, 5-91 ' $EXLDR card, Batch control card, 8-23 map', 8-23 EXP function, 3-14, 3-73 Exponentiotion, 4-10,4-23 Expression, definition, 4-10, 4-78 Expressions, FORTRAN logical, 5-26 numeric, 5-24 EXTERNAL statement, 5-76 External storage, defi,nition, 4-78 External subprograms, 5-71 c F format, 5-40-5-44 $F4 card, Batch control card, 8-21 Field delimiters, 5-43 Field specifications, 5-40 Field width~ 5-40,-5-44 FILE command, AID, 4-53, 4-81, 4-84 File, definition, 4-78 File protection, 1-11Filename extension, 2-6 Filenames, 2-6 Files, 2-6 FI LES command, Basic, 3-67, 3-73 Filing system, 1-10 FIN. UUO, 5-85 FINISH, monitor command, 7-7 FLIRT. routine, 5-84 flOUT. routine, 5-84 FN EN 0 statement, 3-40 FOR statement, Basic, 3-22, 3-23, 3-71 FORM command, 4-54, 4-81 Form, definition, 4-78 FORMAT statement, 5-39 alphanumeric fields, 5-44 blank fields,' 5-49 . complex fields, 5-46' logical fields, 5-43 Index-4 ~--. i mixed fields, 5-45 multiple records, 5-46 numeric fields, 5-40 variable field width, 5-43 Formats stored as data, 5-47 Formula, 4-19, 4-78 FORSE. , 5-83 FORMA T processing, 5-83 I/O device control, 5-84 UUO dispatching, 5-84 FORTRAN compilation, 8-21 FORTRAN compiler diagnostics command errors, 5-116 compilation errors, 5-117 FORTRAN compiler switches, 5-115 FORTRAN library functions, 5-86 FORTRAN library subprograms, 5-71, 5-86, 5-90 FORTRAN library subroutines, 5-90 FORTRAN operating system, 5-83 FORSE. , 5-83 I/O conversion routines, 5-84 FORTRAN UU01s, 5-85 FORTRAN program and MACRO subprogram linkage, example of, 5-97 FORTRAN UU01s, 5-85 Function, definition, 5-24 Function identifier, 5-24, 5-72 FUNCTION statement, 5-72 FUNCTION subprogr(lms, 5-72 FUNCTION statement, 5-72 Function subprogram linkage, example of, 5-96 Function type, 5-24, 5-73 Function value, 5-24 Functions, AID argument, 4-26 cosine, 4-26 digit part, 4-26 exponent part 4-28. exponential, 4-26 first, 4-26, 4-34 fraction part, 4-26 integer part, 4-26 logarithm, natural, 4-27 maximum, 4-27, 4-34 minimum, 4-27, 4-34 product, 4-27, 4-34 signum, 4-27 sine, 4-27 square root, 4-27 sum, 4-27, 4-34 truth value, 4-28, 4-32 Functions, Bcisic, 3-14, 3-27, 3-54, 3-55, 3-73 G format, 5-40-5-44 $ GET card, Batch control card, 8-25 GET monitor command, 7-12 Getting information from the mOnitor DAYTIME monitor command, 2-16 PJOB monitor command, 2-16 RESOURCES monitor command, 7-13 SYSTAT monitor command, 7-13 TIME monrtor command, 2-16 Getting on the system, 2-4 Glossary of AID terms, 4-78 GO command, 4-57, 4-81 GO TO statement, Basic, 3-11, 3-18, 3-71 GO TO statement, FORTRAN assigned, 5-32, 5-77 computed, 5-31, 5-77 uncond itional, 5-31, 5-77 GOSUB statement, 3-41, 3-72 H-conversion, 5-45 HALT monitor command, 1-10 Hierarchy of logical operators, 5-28 of numeric operators, 5-26, 5-28 of relational operators, 5-28 Hilbert matrix, 3-56 I format, 5-40-5-44 I LIN ED command, 8-60 I TECO command , 8-80 IBUFF call, 5-90 Identifiers, 4-10, 4-17, 4-78 indexed, 4-21 Identity matrix, 3-52, 3-72 IF clause, 4-59, 4-81 IF END statement, Basic', 3-70, 3-73 I F statement, FO RTRAN logical, 5-33, 5-77 numerical, 5-33, 5-77 IF - THEN statement, Basic, 3-10,' 3-18, 3-71 ' I FI LE subroutine, 5-91 III subrout ine, 5-02 Immediate storage, definition, 4-78 IMPLICIT statement, 5-68, 5-78 Impure code,rr=7 IN. UUO, 5-85 Indexed identifiers, 4-21 Indirect command, definition, 4,-10 Ind irect steps, 4-15 Index-5 '~~NF.~lJUOi,-5"'!85\!. m ';',. ~(.I '''l' LET command, AID, 4-19, 4.;,.6()i-'I~:;~Hr LET command; ,-Basic:,"'3.-10,- 3.. -16, '3-71 L1B40, 5...i.S3' ," i--":'~'-~ ')';":: LINE ~ommand,' ;4-~}·-'4-<'82 ~;.,',:: Line continuation fie Id, 5-15"'~ ·,i·' , Line format, 5- 15 ' '. ' Line numbers, Basic, 3-10, 3-12~ 3~31 Line spacing, 5-48 LINED a uxi Iiary commands, 8-62 command level, 8-60 commands, 8-59 conventions and restrictions, 8-62 error, 8-63 examples, 8-61, 6-62 implementation, 8-64 monitor commands, 8-59 text mode, 8-60 LINT. routine, 5-84 LI ST, Basic command, 3-65 LIST, monitor command, 7-9 Lists, Basic, 3-25 Literal constants, FORTRAN, 5-21 LOAD, monitor command, 2-14 Loading CHAIN, 8-49 Load ing programs DEBUG, monitor command, 2-14 EXECUTE, monitor command, 2-14 LOAD, monitor command, 2-14 Locations defined, 5-111 required, 5-111 LOG, Basic function, 3-14, 3-73 LOGICAL, type declaration statement, 5-68, 5-79 Logical constants, 5-21 . Logical device names, 7~3 Logical expressions; 5-26 Logical fields, 5-43 Logical I F statement, 5-33, 5-77 Logical operators, 5-27, 5-28 LOGIN, monitor command, 2-4 Login procedure, 2-4 Loops, 3-21 nested, 3-23 LOUT. routine, 5-84 ,1/, Input commands, TECO ,-_ 8-75 - Input file, TEeO ,_ ::·8-69", IN PUT stat~nt ,~.8I!rsi'C-r 3.,.48" 3...72 --~ data file, 3-69, 3""73 Input/output control, 1-9 Input/oufput processor, 1-6 Insertion command, TECO, 8-80 Instruction set, PDP-lO, 5-132 INT function, 3-37, 3-73 Integer constants, 5-19 Integer function, 3-37, 3-73 INTEGER, type declaration statement, 5-68, 5-79 Intelligent terminal, 1-14 Interaction, 1-3 Internal subprograms, 5-71 Interrupting execution of a Basic program, 3-31, 3-35 INTI. routine, 5-84 INTO. routine, 5-84 I/O bound, 1-6 I/O conversion routines, 5-84 I/O list, 5-52 I/O records, 5-53 Item-list, definition, 4-78 Iterative clauses, 4-34 J TECO command, 8-76 $ JOB card ,Batch control card, 8-16 DUMP, 8-18 NOGO, 8-18 K TE CO command, 8-79 KEY card, Batch contro I card, 8-18 KJ 0 B mon itor command, 4- 17, 4- 10 L format, 5-43 L TECO command, 8-77 Latency optimization, 1-10 $ LOR cQl'C\, Batch control card, 8-23 LIB, 8-23 Loader, 8-23 Least squares, 6-9 Leaving the monitor KJOB monito~ command, 2-17, 3-32, 3-33 LEGAL subrQutine" 5-92, LENGTH command, 3-65 $ MAC card, 8-21 MACRO main programs, 5-103 MACRO subprograms, 5-95 example, 6-26 . MAGDEN subroutine,- 5-92 Magneti c tape usage, 5- 130 Index-6 Natural logarithm functions, 3-14, 3-73 . n-dimensional arrays, simulation of, 3-57 NEW Basic command, 3-29, 3-65 . NEXT Basic command, 3-22, 3-23, 3-71 NLI. UUO, 5-85 NLO. UUO, 5-86 NMLST. routine, 5-85 Nonexecutable statements " FORMA T statement, 5-39 NAME LI ST statement, 5-49 Normal exit of a DO stat~ment, 5-34 NUM Basic function, 3-54, 3-74 Numbers, Basic, 3-15 Numeric expressions, 5-24 Numeric fields, 5-40 repetition of, 5-46 repetition of groups, 5-46 Numeric IF statement, 5-33, 5-77 Numeric operations, 5-26 Nu"meric operators, 5-24 Magnitude of double precision constants, 5-20 of integer constants, 5-19 of real constants, 5-19 Main memory, 1-5 MAKE,monitor command, 2-7, 8-70 Manipulating core images GET , monitor command, 7-12 R, monitor command, 7-12 RUN, monitor command, 7-11 SAVE, monitor command, 7-11' Manipulating files DELETE, monitor command, 2-12 DIRECTORY, monitor command, 2-11 RENAME, mon itor corrimand, 2-12 TYPE, monitor command,· 2-11 Manipulating Teletype assignment ATIACH, monitor command, 7-8 DETACH, monitor command, 7-8 TALK, monitor command, 7-8 Master File Directory, 1-10 Mathematical operators, absolute value, 4-10, 4-23 addition, 4-10, 4-23 brackets, 4-10, 4-23 division, 4-10, 4-23 exponentiation, 4-10, 4-23 multiplication, 4-10, 4-23 parentheses, 4-10, 4-23 subtraction, 4-10, 4-23 Matrices, 3-51 Memory blocks, 1-6 Memory protection and relocation, Batch, 8-9 Memory protection register, 1-5 MFD,I-10 Mixed fields, 5-45 Modem, 1-8 Modularity, 1-12 Monitor, 1-5 Monitor calls, 1-) 0 Monitor mode, 1-9 Monitor overhead, 1-7 MTOP. UUO, 5-85 Multiple record formats, 5-46 termination of, 5-47 Multiplication, 4-10, 4-23 Multiprocessor configurations, 1-14 "Multiprogramming, 1-5 o format, 5-40-5-44 OBUFF call, 5-90 Octal constants, 5-20 OCTI. routine, 5-85 OCTO. routine, 5-85 OFILE subroutine, 5-92 OLD Basic command, 3-29, 3-65 ON-GO TO, Basic, 3-19, 3-72 On-I ine, 1-9 Open subroutines, 5-71 Operating system, 1-5 Operating system diagnostics, FORTRAN, 5-120 Operators logical, 5-27 numeric, 5-24 priorities of, .5-28 re laHonal, 5-27 Order of precedence, 4-10, 4-23 our . UUO, 5-85· OUTF. UUO, 5-85 Output commands, TECO, 8-82 Output file, TECO, 8-69 Overlapped 1/0,1-10 Overlay, 1-8 P LINED command, 8-61 P n:::o command, 8-82 PAGE command, 4-63, 4-82 Page, TECO, 8-69 Parentheses, 4-10, 4-23 N, TECO command, 8-85 NAMELI ST statement, 5-39, 5-49, 5-79 input data, 5-50 output data, 5-51 Index-7 " ~ ,.:" . . APb'&7("J4.ii'l5;j,~7&~ ,'>t:P •. J, ~ j '~f' '(,,>1'1<, ,,2 $ PAUSE 'card~ Batch ,cantroJ card, ,,8-27 PAUSE statement, ,F0RT-AAN.; _5..36, :5..77 PDUMP subroutine, 5:-92,« ',' , < Peripheral deviees, ;,,7..3 ' Perman'ent device assignment ASSIGN monitor command, 7-4 Permanent resident area (CHAIN), 8-47 Physical device names, 7-3 PJOB mon itor command, 2-16 , Precision of double-precision constants, 5-20 of real constants, 5-19 PRIN T statement, Basic, 3- 11, 3-17, 3-45, 3-71 PRINT statement, FORTRAN, 5-53, 5-77 Printable characters, 3-62 Priorities of operators, 5-28 Priority interrupt system, 1-5 Private device, 1-10 Program names, 3-30 Programmed operators, 1-10 Programming phases, 2-3 Propositions, 4-20, 4-31 PseudQ-Teletype (PTY), 8-9 Public device, 1-10 PUNCH statement, 5-54, 5-78 Pure code, 1-7 PW, command, 8-~2 RECALL ;Gbmmaitd, 4-65; 4-82,,'4..~. Record, it -.\'0 ' REENTER;' ,monitor comman.d, 4,..10"',7-15 Re-entrarit software,! l":(,,,., "> ; <; , , Relational opefators,7-27 ", Relational symbols, 3-15' RHEAS subroutine, 5-92 Reliability, 1-3.1.. ' Relocatable b'inary program, 2-3, 2-13 REM statement, 3-49, 3-72 Remembered arguments, 2-10 Removable resident area (CHAIN), 8-48 Removable storage device, 1::-11 RENAME, Basic command; 3-65 RENAME, monitor command, 2-12 Repetition of field specifications, 5-46 of groups, 5-46 REPLACE command, 3-65 Replacement operator, 5-29 Requesting line printer output CREF, monitor command, 7-10 DIRECTORY, monitor command, 7-10 LIST, monitor command, 7-? Required locations, 5-111 REREAD statement, 5-57, 5-78 RERED. UUO, 5-85 RESEOUENCE command, 3-66 RESET TIMER command, 4-66, 4-82 RESET. UUO, 5-85 RESOURCES, monitor command, 7-13 RESTORE command, 3-49, 3-61, 3-72 data file, 3-69, 3-73 RETURN key, 2-19 RETURN statement, Basic, 3-41, 3-72 RETURN statement, FORTRAN, 5-75,5-77 REWIND statement, 5-59, 5-78 RND function, 3-38, 3-72 Round robin operation, H RTB. UUO, 5-85 RUBOUT key, 2-19, 3-30, 3-35 Rules of form, AID, 4-11 RUN, Basic command, 3-13, 3-31, 3-65 $ RUN card, Batch control card, 8-25 RUN, mon itor command; 7-11 RUNNH command, 3-31, 3-65 nco Queue, 1-6 QUIT command, 4-64, 4-82 R command, TECO, 8-77 R monitor command, 7-12 RAID, 4-9 R LIN ED, 8-62 Random access of records READ, 5-57, 5-78 WRITE, 5-55, 5-78 Random number generator, example, 6-36 Randon numbers, 3-38, 3-73 RANDOMIZE statement, 3':'39, 3-73 Range of a DO statement', 5-34 READ statement, Basic, 3-10, 3-11, 3-16, 3-71 READ statement, FORTRAN, 5-56, 5-78 Real constants, 5-19 REAL, type declaration statement, 5-68, 5-79 REASSIGN, monitor command, 7-7 S, LINED command, 8-62,,' S, TECO command, 8..$4 ',', $SAVE card, Batch control card, 8,..24, SAVE, monitor command, 3-3&'i3~,7-11 SAVRAN subroutine, 5.,.92 Scalar variables, 5-22 Index-8 Subprogram linkage, exampie ,'5....96, 5-104 SUBROU·TlNE statement, 5-74 Subroutine subprograms, 5-74 CALL statement,· 5-75 RETURN statement, 5-75 SUBROUTINE Statement, 5-(4 Subroutines, 3-41 nested, 3-42 SU BSCRI PT INTEGER, type declaration statement, 5-68, 5-79 Subscripts, 3-25, 3-28 Subtraction, 4-10, 4-23 Swapping, 1-5 Symbiont operation, 1-12 Symbolic logic, 5-26 SYS, 8-11, 8-12 SYSTAT, monitor command, 7-13 example, 7-14 SYSTEM command, 3-66 System device, 8-11, 8-12 Scale factor, 5-19, 5-20, 5-42 SCHEDULE, monitor command, 7-15' Scheduling algorithm, 1-6 SCRATCH command, 3-66 data fi Ie; 3 -68, 3:"73 Search commands, TECO, 8-84 Secondary memory, t-S Segment read-in area (CHAIN), 8-48 SET command, 4-17, 4-67, 4-82 SETRAN subroutine, 5-92 SON function, 3-40, 3-74 Shared system dev ice, 8-11 Sign function, 3-~, 3-74 SIN function, 3-14, 3-73 Sine, 3-14, 3-73 SIZE argument, 4-78 ~KIP RECORD statement, 5-59,5-78 SLIST. UUO, 5-85 SLITE subroutine, 5-93 Slow peripherals, 1-11 Source progr'am definition, 2-3 Spacing, 5-48 Specification statements, 5-61, 5-78 data specification, 5-66 storage specification, 5-62 type declaration, 5-68 Spooling, 1-12 SOR function, 3-14, 3-73 $ SSAVE card, Batch control card, 8-24 SSAV E, monitor command, 7-15 SSWTCH subroutine, 5-93 Standard processor, 2-13 $ START card, Batch contro I card, 8-26 START, monitor command) 7-12 Starting a core image program CONTINUE, monitor command, 7-13 HALT, monitor command, 7-13 START, monitor command, 7-12 Statement field, 5-16 Statement number field, 5-15 Statement numbers, S-15 Statements, 3-10 ST EP instruction, 3-22, 3-24 Steps, 4-15, 4-79 STOP command, AID, 4-68, 4-82 STOP command, Basic, 3-49, 3-72 STOP statement, FORTRAN, 5-37, 5-77 Storage specification statements, 5-62 COMMON, 5-64 DIMENSION, 5-62 EQUIVALENCE, 5-65 Stored formats,· 5-47 Strings, Basic, 3"'59 SubproQram calling seqlJenceS, 5-95 T format, 5-48 T, TEeO command, 8-Z8 Tab, horizontal, 3-47, 5-15 Tables, Basic, 3-25 TALK, monitor command, '7-8 #TAPE, Batch control card, 8-21 TAN function, 3-14, 3-73 ' TECO command arguments, 8-74 TECO command string syntax, 8-72 T ECO error me.ssage s, 8-87, 8-88 TECO general operating procedure, 8-69 TECO initialization, 8-70 TECO, mon itor command, 2- 10, 8-70 TECO special symbols, 8-71 TECO text type-out, 8-78 Te letype conso les, 4-12 Teletype control characters, 2-18 Teletype special keys ALTMODE key, 2-20 RETURN key, 2-19 RUBOUT key, 2-19 Temporary device assignment, 7-4 Termination of a program, 5-37 TIME, AID command, 4-79 TIME, monitor command, 2-16 Time quantum, 1-4 Time slice, 1-4 TIME subroutine, 5-93 TIMER argument, 4-79 Timesharing, 1-4 TO command, 4-69, 4-82 Index-9 Translating programs _ COMPILE, mon itor command, '2-13 Trappir)g" ,1... 9 ~ .:,.:. TYPE, AID command, 4-71, 4-83· Type de~laration statements, 5-68 TYPE,!TIonitor command, 2-11 TYPE statement, FORTRAN, 5-54, 5-78 stop, 4-68, 4-82 to, 4-69, 4-82 type', .1~,1}!jA-8fl" ,', use, 4-75, 4-83, 4-84 WEAVE, 3-66 Wor:d format, PD P-1 0., 5-126 WRITE statement, Basic, 3-:-68, 3-73 WRITE statement , FORTRAN, 5-54" 5-78 WTB. UUO, 5-85 . UFO, 1-10 Unconditional GO TO statement, 5-31, 5-77 Un it records, 5-40 UN LOAD statement, 5-59, 5-78 USE command, 4-75, 4-83, 4-84 User control levels, Batch console commands, 8-13 control cards, 8-13 User-defined functions, 4-~0, 4-29 User directories, 2-11 User mode, 1-9 User's Fi Ie Directory, 1-10 X format, 5 -49 Y, TECO command I 8-75 Variable field width, 5-43 Variables, AID, 4-10, 4-17, 4-79 Variables, Basic alphanumeric string, 3-59 numeric, 3-15 subscripted, 3-25 Variables, FORTRAN array, 5-22 scalar, 5-22 Vectors, 3-51 Verbs, AID cance I, 4-37, 4-80 de lete, 4-39, 4-80 demand, 4-18, 4-41, 4-80 discard, 4-45, 4-8Q, 4-84 do, 4-18, 4-34, 4-46, 4-80 done, 4-51, 4-80 file, 4-53, 4-81, 4-84 form, 4-54, 4-81 go, 4-57, 4-81 if clause, 4-59, 4-81 let, 4-19, 4:"60, 4-81 line; 4-62,4-82 page, 4063, 4-82 qu it, 4-64, 4-82 recall, 4-65, 4-82, 4-84 reset timer, 4-66, 4-82 set, 4-17,4-67, 4-82 Index-10 DIGITAL EQUIPMENT CORPORATION WORLD-WIDE SALES AND SERVICE MAIN OFFICE AND PLANT 146 MaIO Street, Maynard, Massachusetts, USA. 01754 • Telephone From Metropolitan Boston 646-8600' Elsewhere' (617)-897-51J1 • TWX. 710-347-{)212 Cable' DIGITAL MAYN Telex 94-8457 UNITED STATES NORTHEAST MID·ATLANTIC-SOUTHEAST (cont,) CENTRAL (cont,) REG/OhiAL OFFICE' 15 Lunda Street, W.lth.m, M.ss.chusetta 02154 Telephone' (617)-891-1006 TWX.710-324-0919 DURHAM/CHAPEL HILL 2704 Chapel Hill Boulev.rd Durham, North Carol me 27707 Telephone (919)-489-3347 TWX 510-927-0912 HUNTSVILLE ST. LOUIS Suite 110,115 Progress Pky .. Maryland Heights, WALTHAM 15 Lund. Street, Walth.m, M••••chu.etts 02154 Telephone (617)-891-6310/6315 TWX. 710-324-0919 CAMBRIDGE/BOSTON 899 Ma," Street, Cambridge, Massachu.ett.02139 TWX: 710-320-1167 Telephone: (617)-491-6130 ROCHESTER 130 Aliens Creek Road, Roche.ter, New York 14618 Telephone (716)-461-1700 TWX 710-599-3211 CONNECTICUT 1 Prestige Drive, Meriden, Connecticut 06450 Telephone: (203)-237-8441 TWX: 710-461-{)Q54 MID·ATLANTIC-SOUTHEAST REGIONAL OFFICE: U.S. Route I, Princeton, New Jer.ey 08540 Telephone (609)-452-9150 TWX. 510-685-2338 NEW YORK 95 Cedar Lane, Englewood, New Jersey 07631 Telephone. (201)-871-4984, (212)-584-5955, (212)-736-0447 TWX· 710-991-9721 NEW JERSEY 1259 Route 48, Parsippany, New Jersey 07054 Telephone: (201)-33S.3300 TWX: 71D-987-8319 PRINCETON Route One and Emmons Drive, Prmceton. Np,w Jersey 08540 Telephone: (609)-452-2940 TWX: 510-685-2337 LONG ISLAND 1919 Middle Country Road Centere.ch, L I., New York 11720 Telephone: (516)-585-5410 TWX: 510-228-6505 PHILADELPHIA 1100 We.t Valley Roed, W.yne, Pennsylvanl. 19087 Telephone (215)-687-1405 TWX: 510-668-4461 Suite 41 - Holiday Office Center 3322 Memorial Parkway S W , Huntsville, Ala, 35801 Telephone (205)-881-7730 TWX: 810-726-2122 ORLANDO SUite 232, 8990 Lake Ellenor Drive, Orlando, Flo 32809 Telephone (305)-651-4450 TWX 810-856-{)180 ATLANTA Suite 116, 1700 Commerce Drive, N.W .. Atlanta, Georgia 30318 Telephone: (404)-351-2822 TWX: 810-751-3251 KNOXVILLE 5731 Lyons View Pike, S W , Knoxville, Tenn. 37919 Telephone. (615)-588-6571 TWX· 810-583-{)\23 CENTRAL REGIONAL OFFICE. 1850 Frontage Road, Northbrook, illinOIS 60062 Telephone (312)-498-2580 TWX 9\0-666-0655 PITTSBURGH 400 Penn Center Boulevard, Pittsburgh, Pennsylvania 15235 Telephone' (412)-243-6500 TWX· 710-797-3657 CHICAGO 1850 Frontage Road, Northbrook, illinois 60062 Telephone (312)-498-2500 TWX 910-686-0655 ANN ARBOR 230 Huron View Boulevard. Ann Arbor. Michigan 48103 Telephone (313)-761-1150 TWX 8\0-223-8053 INDIANAPOLIS 21 Beachway Drive - SUite G IndianapoliS, Indiana 48224 Telephone (317)-243-8341 TWX 810-341-3436 MINNEAPOLIS 15016 Mlnnetonk. Industrial Ro.d Minnetonka, Minnesota 55343 MISSOUri 63043 Telephone: (314)-872-7520 TWX: 910-764-0831 DAYTON 3101 Ketter,"g Blvd., Dayton, Ohio 45439 Telephone: (513)-299-7377 TWX: 810-459-1676 DALLAS 8855 North Stemmons Freeway. SUite 204 Dallas. Texas 75247 Telephone (214)-636-4860 TWX· 910-661-4000 HOUSTON 3417 Milam Street, Suite A, Houston, Texas 77002 Telephone: (713)-524-2961 TWX: 910-881-1651 WEST REGIONAL OFFICE· 580 San Antonio Road, Palo Alto, California 84308 Telephone: (415)-328-0400 TWX: 910-373-1286 ANAHEIM 801 E. Ball Road, Anaheim, California 92805 Telephone: (714)-776-6932 or (213)-625-7669 TWX: 910-591-1188 WEST LOS ANGELES 2002 Cotner Avenue. Los Angeles. California 90025 Telephone. (213)-479-3791 TWX 910-342-6999 SAN FRANCISCO sao San AntoniO Road. Palo Alto. California 94306 Telephone: (415)-328-5840 TWX: .910-373-1266 ALBUQUERQUE 8303 Indian School Road, N.E, Albuquerque, N M. 87110 Telephone: (505)-296-5411 TWX· 910-989-0614 DENVER 2305 South Colorado Blvd., Suite #5 Denver, Colorado 60222 Telephone· 303-757-3332 TWX, 910-931-2650 SEATTLE 1521 l30th N.E , Bellevue, W.shlngton 96004 Telephone (208)-454-4058 TWX 910-443-2306 SALT LAKE CITY . 431 South 3rd East, Salt Lake City, Utah 84111 Telephone. (801)-328-9838 TWX 910-925-5834 WASHINGTON Executive Bulldlng7100 B.ltlmore Ave., College Park, Meryland 20740 Telephone: (301)-779-1100 TWX: 710-826-9662 Telephone: (612)-935-1744 TWX: 910-576-2818 CLEVELAND Park HIli Bldg, 35104 Euclid Ave. Willoughby, Ohio 44094 Telephone: (216)-946-6484 TWX: 810-427-2808 CANADA ENGLAND ITALY D,glt.1 Equipment of Cenada, Ltd. CANADIAN HEADQUARTERS 150 Ros.mond Street, C.rleton Place, Ont.rlo Telephone: (613)-257-2615 TWX: 610-581-1651 Digital Equipment Co_ Ltd, READING ArkWright Road, Reading, Berkshire, England Telex. 84327 Telephone: Reading 65131 MANCHESTER MILAN Corso Garibaldi, 49, 20121 Milano, Italy Telephone 872 746, 672694,872 394 Telex 33615 6 Upper Precinct. Worsley AUSTRALIA Manchester, England m285az Te,lephone.06I-790-4591/2 Telex: 666666 Digital Equipment Austr.lia Ply. Ltd_ SYDNEY 75 Alexander Slreet, Crows Nest, N.S.W. 2065. Austrelia INTERNATIONAL OTTAWA . 120 Holland Street, Ott.w.3, Ontario TWX 610-582-8907 Telephone: (613)-725-2193 TORONTO 230 Lakeshore Road East, Port Credit, OntariO Telephone: (416)-278-6111 TWX: 610-492-4306 MONTREAL 9675 Cote de Llesse Ro.d Dorv.I, Quebec, Canada 760 Telephone 514-636-9393 TWX· 610-422-4124 EDMONTON 5531-103 Street Bilton House. Uxbridge Road. Ealing. London W 5 Telephone. 01-579-2781 Telex 22371 FRANCE EqUipement Digital SA R.L. PARIS 233 Rue de Charenton, P.rls 12, Fr.nce Telex 21339 Telephone 344-76-07 BENELUX Edmonton. Alberta. Canada Telephone: (403)-434-9333 LONDON TWX. 610-831-2248 EUROPEAN HEADQUARTERS Digital EqUipment Corporation International-Europe 81 Route De L' Alre 1227 Carouge / Geneva. Switzerland Telephone: 42 79 50 Telex. 22 683 Digital EqUipment N.V_ (serv,"g Belgium, Luxembourg, and The Netherlands) THE HAGUE Konlng,"negracht 65, The Hague, Netherlands Telex: 32533 Telephone: 835960 SWEDEN Digital Equipment Aktlebolag STOCKHOLM GERMANY Vretenvagen 2. 8-171 54 Solna. Sweden Dlglt.' Equipment GmbH COLOGNE 5 Koeln, Blsmarckstrasse 7, West Germany Telephone 52 21 81.. Telex 668-2289 Telegram: Flip Chip Koeln Telephone 08 98 13 90 Telex 17050 Cable' Digital Stockholm MUNICH 8000 Muenchen 19. Leonrodstrasse 58 Telephone 516 30 54 Telex 524226 SWITZERLAND Digital EqUipment Corporation S A. GENEVA 81 Route De L'Aire 1227 Carouge / Geneva, Switzerland Telex: 22 663 Telephone. 42 79 50 - ,," Digital EqUipment SpA Telephone 439-2566 Telex 20740 Cable: Digital, Sydney MELBOURNE .J!! Park Street, South Melbourna, Victoria, 3205 -'1 elephone 69-6142 Telex 30700 WESTERN AUSTRALIA 643 Murray Street West Perth. Western Australia 6005 Telephone 21-4993 Telex 92140 BRISBANI! 139 Merlvale Street, South Brisbane Queensland. Australia 4101 Telephone 44047 Telex 40616 JAPAN TOKYO Rlkel Tredlng Co., Ltd (s.le8 only) Kozato-Kalkan Bldg, No, 18-14, Nlshlshlmbashl l-chome Mlnato-Ku,Tokyo, Japan Telephone: 5915248 Telex: 7814206 Digital Equipment Corporation International (engineering and services) Fukuyoshlcho Bulld,"g, No 2-6, Roppongl 2-Chome, Mmato-Ku, Tokyo Telex No. 0242-2850 Telephone 565-3624 • TO THE READER OF THE PDP-lO TIMESHARING HANDBOOK We at Digital want to improve the quality and usefulness of our publications. However, we cannot achieve this goal by ourselves. We need your collaboration: your corrections, your observations, your critical evaluations. Will you please provide us with such constructive information by filling out this questionnaire and mailing it hack to us? 1. (a) Is the handbook a useful document? ................................... DYES (b) If you answer is YES, tell us what features make it useful. FOLD D NO (c) If your answer is NO, tell us what features prevent it from being a useful document. 2. (a) Is the text clear and readily understandable? ............................. DYES D NO (b) If your answer is NO, cite the paragraphs, chapters, or sections that are unclear or difficult to understand. 3. (a) Are you pleased with the organization of the handbook? ................ DYES (b) Should the organization be changed? ................................... DYES ( c ) What changes do you suggest? D NO D NO 4. (a) Should the organization of individual chapters or books be changed? ...... DYES (b) If your answer is YES, give us your suggestions. D NO 5. (a) Should more demonstration programs be added when the handbook is revised? DYES D NO FOLD (b) What kind of programs would you like to see added? 6. (a) Should more utility programs be added when the handbook is revised? ..... (b) Give us your suggestions. 0 YES 0 NO 7. (a) Should anything be deleted from the handbook when it is revised? ......... (b) If your answer is YES, give us your suggestions. 0 YES 0 NO - FOLD 8. List any further suggestions you have for the improvement of this handbook. • FOLD FIRST CLASS PERMIT NO. 33 MAYNARD, MASS. BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Postage will be paid by: PDP·10 Software WrltiRg Groap ProgrammiRg Depaflmellt Digital EflUipment CorpentioR Maynard, Massachasetts 01754 STAPLE SAMPLE LOGIN PROCEDURE Make contact with your computer facility by whatever means the facility has estabilshed (e.g., acoustic coupler, telephone, or data phone). + Tum the little plastic knob on the right-hand side of the Teletype to ON. + Type C on the Teletype (i.e., hold down the CTRL key while striking C). This establishes communication with the Time-Sharing Monitor. The Monitor signifies its readiness to accept commands by responding with a period (.). + Type LOGIN, or LOG, followed by a carriage return. The system will respond with an informative message like the following: JOBn NAME OF SYSTEM # JOB n is the job number the system has just assigned to you. NAME OF SYSTEM is usually the Monitor name and version number. ~ Type your project-programmer numbers after the number sign, followed by a carriage return. + The time-sharing system will then type PASSWORD: + Type your secret password followed by a carriage return. The system will keep the password secret by not printing it on the paper. + If the project-programmer numbers and the pass- word match the project-programmer numbers and password stored in the system accounting file, the system responds with the time, date, TTY number, C, and a period. Example: 1301 8-May 70 TTY23 + Now the time-shraing system is ready to accept any commands you wish to type in. You may direct it to load and start a program from the System Library (.R prog), start a program already loaded in core (.START), or perform any of a variety of other operations. (See inside of back cover for a summary of Time-Sharing Monitor commands.) 1, 2, 3, 4, -5. 6. 7, 8, 9, 102X • 0·09·50 ~470 • AKW COllSole Teletype Central Processor ·16K, 1.0 ~sec Memory 16K, 1.0 ~sec Memory 16K, 1,0 ~sec Memory Data Channel Swapping Disk Control Swapping Disk Disk Pack Unit* 10, 11, 12, 13, 14. 15, 16. 17, 18. Disk Pack Unit·" Line Printer Card Reader Magnetic Tape Transport Magnetic Tape Transport Magnetic Tape Control Communications System Line Printer/ Card Reader Control DECtape Control and 3 DECtape Units PRINTED IN U,S.A.
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.6 Linearized : No XMP Toolkit : Adobe XMP Core 4.2.1-c041 52.342996, 2008/05/07-21:37:19 Create Date : 2018:05:14 10:14:16-08:00 Modify Date : 2018:05:14 10:35:08-07:00 Metadata Date : 2018:05:14 10:35:08-07:00 Producer : Adobe Acrobat 9.0 Paper Capture Plug-in Format : application/pdf Document ID : uuid:d8fadb7d-ea68-8a47-9bf9-0848ce9696f0 Instance ID : uuid:7e1c9815-19e6-d445-87ea-7819efd5adac Page Layout : SinglePage Page Mode : UseNone Page Count : 534EXIF Metadata provided by EXIF.tools