|
|
1.1 root 1:
2:
3: 11/6/83
4:
5:
6:
7:
8:
9:
10:
11: MATLAB Installation Guide
12: November, 1983
13:
14:
15: Cleve Moler
16: Department of Computer Science
17: University of New Mexico
18:
19:
20:
21: The MATLAB tape is usually in one of two formats -- a UNIX
22: "tar" tape, or a "generic" tape with the following parameters:
23:
24: 9 track
25: 1600 bits per inch
26: no label
27: 80 characters per record
28: 1600 characters per block
29: 18 files in ASCII, followed by 18 files in EBCDIC
30:
31: There are 36 files on the generic tape. The names of the
32: first 18, and their approximate sizes, are:
33:
34: 1. INSTALL 1100 lines
35: 2. MAT 3900 lines
36: 3. LIB 3339 lines
37: 4. HELPER.66 75 lines
38: 5. HELPER.77 120 lines
39: 6. HELP 750 lines
40: 7. SYS.UNIX 900 lines
41: 8. SYS.VMS 260 lines
42: 9. SYS.TSO 200 lines
43: 10. SYS.CMS 350 lines
44: 11. SYS.DEC10 250 lines
45: 12. SYS.CDC 200 lines
46: 13. SYS.PRIME 350 lines
47: 14. DOC 3960 lines
48: 15. DEMO 21 lines
49: 16. DOC.NROFF 3250 lines
50: 17. MAT.SNGL 3850 lines
51: 18. LIB.SNGL 3339 lines
52:
53: where a line is one 80 character record.
54:
55: The first 18 files are in the ASCII character set. The
56: remaining 18 files are copies of the first 18 in EBCDIC.
57:
58: INSTALL is this document. You can skip over it if you have
59: this hard copy.
60:
61:
62:
63:
64:
65:
66:
67:
68:
69: MATLAB Installation, page 2
70:
71:
72:
73: MAT, LIB, one of the versions of HELPER and one of the
74: versions of SYS together constitute the complete source code for
75: the double precision version of MATLAB.
76:
77: The subroutines in MAT make up the parser and interpreter.
78: They include a COMMON statement which can be changed to change
79: the amount of memory allocated to variables.
80:
81: The subroutines in LIB include modified versions of the
82: necessary routines from LINPACK, EISPACK and the BLAS. These do
83: not contain any COMMON statements and do not have to be changed
84: if the size of the stack is changed.
85:
86: There are two versions of HELPER, the subroutine which
87: manages the help facility. The version in HELPER.66 is written
88: in Fortran 66 and uses sequential i/o. The version in HELPER.77
89: is written in Fortran 77 and uses character variables and direct
90: access i/o. If your system supports both versions, you will
91: probably want to choose the direct access one -- it should be
92: much faster. If you choose the direct access version, you will
93: have to run a preprocessor named HELPSET, which is also in file
94: HELPER.77.
95:
96: HELP is the source text for the help facility. It is read
97: by the sequential version of HELPER, or preprocessed by HELPSET
98: into two files which are then read by the direct access version
99: of HELPER. HELP is also included as an appendix in the User's
100: Guide.
101:
102: The subroutines in one of the versions of SYS may have to be
103: modified for your particular operating system. They involve file
104: access and floating point word format. I have included versions
105: that should work on several different operating systems. Pick
106: the version that is closest to your own system and make any
107: changes you need. There are no machine dependent constants.
108:
109: DOC is a report entitled "MATLAB Users' Guide". It should
110: be printed on a nice printer with upper and lower case; there are
111: 66 lines per page. Make as many copies as you need, or order
112: copies from us at New Mexico.
113:
114: DEMO contains a demonstration exec file which can be
115: accessed by the exec command in MATLAB. On most systems, all that
116: is required is EXEC('DEMO') or EXEC('DEMO',7). On some systems,
117: like TSO and NOS, it will be necessary to attach file DEMO to
118: unit 2 and then EXEC(2) or EXEC(2,7).
119:
120: DOC.NROFF is the input to the UNIX text processing system
121: that was used to produce DOC. This may be useful if you want to
122: print the users' guide in a different format.
123:
124: MAT.SNGL and LIB.SNGL are the single precision versions of
125: MAT and LIB. It is suggested that these be used only on systems
126:
127:
128:
129:
130:
131:
132:
133:
134:
135: MATLAB Installation, page 3
136:
137:
138:
139: with long words (48 bit floating point fraction) or small
140: memories.
141:
142: The first thing to worry about is the character set. The use
143: of an upper-lower case character set is highly desirable, but not
144: essential. Read the tape and look at the first 50 or so lines of
145: MAT. This is the subroutine MATLAB, a listing of which is
146: included in this document. Check the comments near the beginning
147: to see if the special characters are ok. The ones we have had
148: trouble with include:
149: SEMI ; BSLASH \ COLON : LESS < GREAT >
150: Any characters which are not ok should be changed in the comment
151: and in the data statement which follows. The alternate character
152: set includes the lower case letters as well as substitutes for
153: some of the special characters, such as \ and :, which are not on
154: some terminals. Do not worry too much about the alternate
155: character set now. These data statements in subroutine MATLAB
156: are the only place in the source code where the special
157: characters occur. (If you want to get fancy, there is a data
158: statement involving BEL in subroutine ERROR near the end of file
159: MAT. Change 1H-blank to 1H-control G to get your terminal to
160: ring its bell for any error.)
161:
162: The files DOC and HELP are full of special characters,
163: including
164: < > [ ] : ; \ |
165: If they are not ok, I hope it is not too difficult to fix them
166: up.
167:
168: I have used several FORTRAN constructions which are only
169: semi-standard, and which may have to be changed for some systems:
170: Single quote (') in FORMATS instead of a tribute to Hollerith.
171: Entire arrays initialized in DATA statements.
172: Use of END= in READ statements.
173: I have not asked PFORT to tell me what else is non-standard.
174:
175: Some interactive FORTRAN systems use column 1 for carriage
176: control and others don't. If your system does not, edit file MAT
177: and delete all "1X," . There are 131 occurrences.
178:
179: The main program in file SYS simply calls MATLAB. It may
180: have to be modified to control the printing of underflow and
181: overflow messages. The ground rules are: Underflows are
182: possible, but are harmless if they are quietly set to zero.
183: Overflows are error conditions. It would be nice to print a
184: message and continue.
185:
186: A listing of a typical version of SYS, using some Fortran 77
187: for clarity, is included in this document. I hope it is fairly
188: easy to see what the various subroutines do and how they have to
189: be revised for your system. Please send me copies of versions
190: appropriate for your system.
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201: MATLAB Installation, page 4
202:
203:
204:
205: The amount of memory required can be altered by a global
206: text edit on MAT which changes the matrix element stack length
207: from 5005 to something else. Be sure to get the statement
208: VSIZE = 5005
209: in the subroutine MATLAB. With this setting of the stack length,
210: MATLAB requires about a 300K byte region on an IBM system. The
211: length has to be reduced somewhat to get MATLAB to fit into a 64K
212: word region on a CDC system. Since each matrix element occupies
213: two double or single precision words, an increase of 1000 in the
214: stack length requires an additional 16K bytes or 2000 words.
215:
216: It is possible to get by with less memory if you use
217: overlays. The simplest way to do this is the following.
218:
219: ROOT
220: |
221: -------------------------------
222: | | | | | |
223: S0 S1 S2 S3 S4 S5
224:
225: Only ROOT plus one of the segments S0 through S5 need be in
226: memory at any one time. The segments do not call each other, but
227: return to the root. All the relevant calls are near the end of
228: subroutine MATLAB in the root. There are five labeled COMMON
229: blocks which are shared by the root and all the segments. The
230: various segments consist of:
231:
232: ROOT:
233: MAIN MATLAB STACK1
234: PRINT PRNTID FUNS
235: STACKP ERROR FILES
236: HELPER PYTHAG FORMZ
237: FLOP PROMPT
238: Plus everything in file LIB not mentioned below.
239:
240: S0:
241: PARSE COMAND CLAUSE
242: EXPR TERM FACTOR
243: STACKG STACK2 GETSYM
244: GETLIN GETCH GETVAL
245: EDIT XCHAR
246:
247: S1:
248: MATFN1 WGECO WGEFA
249: WGESL WGEDI WPOFA
250: RREF HILBER
251:
252: S2:
253: MATFN2 CORTH COMQR3
254: HTRIDI HTRIBK IMTQL2
255:
256: S3:
257: MATFN3 WSVDC
258:
259:
260:
261:
262:
263:
264:
265:
266:
267: MATLAB Installation, page 5
268:
269:
270:
271: S4:
272: MATFN4 WQRDC WQRSL
273:
274: S5:
275: MATFN5 MATFN6 MAGIC
276: SAVLOD RAT USER
277: PLOT
278:
279: If you have enough room, combine ROOT and S0. With more room,
280: combine ROOT, S0 and S5. If you use some overlay structure,
281: please send me a description of how it is done on your system.
282:
283: In case anybody needs to know, here are the changes
284: necessary to convert from double to single precision. They can
285: all be safely accomplished by simple global text changes in MAT,
286: LIB and an appropriate version of SYS.
287:
288: DOUBLE PRECISION REAL
289: DOUBLE- REAL-
290: DSQRT SQRT
291: DLOG ALOG
292: DEXP EXP
293: DSIN SIN
294: DCOS COS
295: DATAN ATAN
296: DABS ABS
297: DMAX1 AMAX1
298: DMIN1 AMIN1
299: IDINT IFIX
300: DSIGN SIGN
301: DMOD AMOD
302: D0 E0
303: D1 E1
304: D2 E2
305: D9 E9
306:
307:
308: Here are some additional comments that apply to individual
309: systems.
310:
311:
312: VAX UNIX.
313:
314: If you have read the "tar" format tape, see file README and
315: the makefile. Ignore the rest of this section.
316:
317: It is essential to change the single backslash \ in the data
318: statement near the beginning of file MAT to a double backslash
319: \\. If this is not done, the F77 compiler produces an obscure
320: error message about "dataalpha" being too long.
321:
322: Increase the size of the stack to take advantage of the
323: virtual memory. Eliminate all the "1X," in formats. Change the
324:
325:
326:
327:
328:
329:
330:
331:
332:
333: MATLAB Installation, page 6
334:
335:
336:
337: statement CASE = 0 in MATLAB to CASE = 1 to get lower case file
338: names. All these changes can be accomplished by applying the
339: following ed or vi commands to file MAT.
340:
341: 1,$s/\/\\/g
342: 1,$s/5005/50005/g
343: 1,$s/1X,/0X,/g
344: 1,$s/CASE = 0/CASE = 1/
345: 1,$s/BEL/1H /BEL/1H^G/
346: 1,$s/LCT(2) = 25/LCT(2) = 25000/
347:
348: The compilation should suppress warnings about initializing
349: non-character variables with Hollerith and should use the
350: Berkeley version of the i/o support routines. This can be
351: accomplished with:
352:
353: % f77 -w66 mat.f lib.f helper.f sys.f -lI77uc
354:
355: Gary Klimowicz and Lee Ward of UNM have developed a overflow
356: fault handler for use with VAX UNIX. A copy of their C program
357: in included in SYS.UNIX and on the "tar" tape.
358:
359:
360:
361: VAX VMS
362:
363: SYS.VMS contains an extra subroutine for proper handling of
364: floating point overflow. The main program includes a call to the
365: system which initializes this handling.
366:
367: Integer overflow is expected in the the print routine and in
368: random number generator. The integer overflow messages can be
369: turned off by
370:
371: FORTRAN/NOCHECK MAT.FOR,LIB.FOR
372:
373:
374:
375: IBM (TSO)
376: (Thanks to Jack Dongarra at Argonne.)
377:
378: The main program in SYS.TSO includes the appropriate calls
379: to the IBM system utility ERRSET that turns off verbose underflow
380: and overflow messages.
381:
382: Unfortunately, TSO does not have a mechanism for opening
383: files during execution. It is necessary to use file numbers with
384: SAVE, LOAD and EXEC.
385:
386: We have to specify LRECL=80 for terminal input on unit 5 to
387: get blanks added to input lines. It is a good idea to set up a
388: clist something like the following.
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399: MATLAB Installation, page 7
400:
401:
402:
403: FREE FILE(FT05F001 FT06F001 FT09F001 FT01F001 FT02F001)
404: FREE ATTRLIST(AT80)
405: ATTR AT80 LRECL(80) BLKSIZE(80) RECFM(F)
406: ALLOC FILE(FT05F001) DA(*) USING(AT80)
407: ALLOC FILE(FT06F001) DA(*)
408: ALLOC FILE(FT09F001) DA('MATLAB.HELP.DATA')
409: ALLOC FILE(FT01F001) DA(SAVLOD.DATA)
410: ALLOC FILE(FT02F001) DA('MATLAB.DEMO.DATA')
411: CALL 'MATLAB.LOAD(MATMOD)'
412:
413: With this arrangement, the DEMO file can be executed by exec(2).
414:
415:
416:
417: IBM (CMS)
418: (Thanks to Jack Dongarra at Argonne and David Gay at MIT.)
419:
420: Entering a blank line in response to the MATLAB prompt
421: generates an end-of-file from terminal input (Fortran unit
422: FT05F001). This results in a call from GETLIN to FILES with LUNIT
423: = -5. The terminal is "rewound" and control eventually returned
424: to PARSE which prints another prompt. I hope this works.
425:
426: An assembly language routine used to attach files with names
427: generated by MATLAB to Fortran unit numbers is included in
428: SYS.CMS.
429:
430:
431:
432: DEC-10
433: (Thanks to Stan Eisenstat and Craig Douglas at Yale.)
434:
435: The hyperbolic trig functions SINH and COSH are not
436: available on the DEC system. Fortran subroutines are included in
437: the SYS.DEC10 file.
438:
439:
440:
441: PRIME 400
442: (Thanks to Richard Franke and Drexel University.)
443:
444: The terminal is Fortran I/O unit number 1. Subroutine
445: MATLAB has to be changed so that
446: RTE = 5 becomes RTE = 1
447: WTE = 6 becomes WTE = 1
448: Subroutine MATFN5 has to be changed so that
449: WIO = 1 becomes WIO = 8
450: LUNIT = 1 becomes LUNIT = 8 (in two places).
451:
452:
453:
454: CDC
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465: MATLAB Installation, page 8
466:
467:
468:
469: CDC systems offer exciting challenges as far as portability
470: is concerned. The first question is: which character set should
471: be used? An easy approach is to convert everything to the
472: venerable 6-bit character set. Even so, you may have trouble
473: with the colon, which is a pretty important MATLAB character. It
474: is far more fun to try to use upper and lower case and all the
475: special symbols. I have succeeded in doing this with the 6/12-
476: bit setup used on the NOS system at Sandia, but have given up
477: with the 6/18-bit coding on LTSS at Los Alamos.
478:
479: In "ASCII" mode on NOS, lower case characters are
480: represented by 12 bits -- the first 6 bits are octal 76 and the
481: last 6 are the corresponding upper case character. They count as
482: two characters. So, the following changes are required in file
483: MAT. Several of the mixed case strings in FORMAT statements
484: extend beyond column 72. You might as well convert these to all
485: upper case. All the 80A1's in FORMATS should be changed to
486: 132A1's and all the DATA statements initializing LRECL should be
487: changed from 80 to 132. The DATA statement for ALPHB in
488: subroutine MATLAB can be changed to have all upper case
489: alphabetic characters because subroutine XCHAR will catch the
490: prefix octal 76.
491:
492: An important change involves our friend the colon, which
493: becomes a 12-bit octal 7404. In the DATA statement for ALPHA,
494: make the element just before 1H+ into a 1H(percent sign). And,
495: in the DATA statement for ALPHB, make the corresponding element
496: into a 2H(colon). Then read the comments in subroutine XCHAR in
497: file SYS.CDC and make sure that the DATA statements there are
498: correct.
499:
500: The FTN5 compiler should take MATLAB pretty much is it is.
501: The older FTN compiler requires two familiar changes to the
502: entire source code. First, the END= in the READ statements have
503: to be replaced by IF (EOF) GO TO ... . Second, the single quotes
504: in FORMATS have to be replaced with asterisks.
505:
506:
507:
508: Good luck. Please let me know what difficulties you have, and
509: what I have left out of this guide. You can call me at:
510: 505-268-8631 (home)
511: 505-277-3112 (office)
512:
513: ------------
514:
515: The support of the National Science Foundation and the use
516: of facilities at Argonne National Laboratory, Los Alamos National
517: Laboratory and Stanford Linear Accelerator Center is gratefully
518: acknowledged. So is the assistance of the many people who have
519: installed early versions of MATLAB.
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531: MATLAB Installation, page 9
532:
533:
534:
535: Contents of file MAT:
536:
537: SUBROUTINE MATLAB(INIT)
538: SUBROUTINE PARSE
539: SUBROUTINE COMAND(ID)
540: SUBROUTINE CLAUSE
541: SUBROUTINE EXPR
542: SUBROUTINE TERM
543: SUBROUTINE FACTOR
544: SUBROUTINE FUNS(ID)
545: SUBROUTINE STACKP(ID)
546: SUBROUTINE STACKG(ID)
547: SUBROUTINE STACK1(OP)
548: SUBROUTINE STACK2(OP)
549: SUBROUTINE PRINT(ID,K)
550: SUBROUTINE PRNTID(ID,ARGCNT)
551: SUBROUTINE GETSYM
552: SUBROUTINE GETLIN
553: SUBROUTINE GETCH
554: SUBROUTINE GETVAL(S)
555: SUBROUTINE MATFN1
556: SUBROUTINE MATFN2
557: SUBROUTINE MATFN3
558: SUBROUTINE MATFN4
559: SUBROUTINE MATFN5
560: SUBROUTINE MATFN6
561: SUBROUTINE ERROR(N)
562: DOUBLE PRECISION FUNCTION PYTHAG(A,B)
563: SUBROUTINE RAT(X,LEN,MAXD,D)
564:
565: Contents of file HELPER.66:
566:
567: SUBROUTINE HELPER(H) -- Sequential version
568:
569: Contents of file HELPER.77:
570:
571: PROGRAM HLPSET -- Direct access setup
572: SUBROUTINE HELPER(H) -- Direct access version
573:
574: Contents of file SYS:
575:
576: PROGRAM MAIN
577: SUBROUTINE FILES(LUNIT,NAME)
578: SUBROUTINE SAVLOD(LUNIT,ID,M,N,IMG,JOB,XREAL,XIMAG)
579: SUBROUTINE FORMZ(LUNIT,X,Y)
580: DOUBLE PRECISION FUNCTION FLOP(X)
581: SUBROUTINE XCHAR(BUF,K)
582: SUBROUTINE USER(A,M,N,S,T)
583: SUBROUTINE PROMPT(PAUSE)
584: SUBROUTINE PLOT(LUNIT,X,Y,N,P,K,BUF)
585: SUBROUTINE EDIT(BUF,N)
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597: MATLAB Installation, page 10
598:
599:
600:
601: Contents of file LIB:
602:
603: SUBROUTINE WGECO(AR,AI,LDA,N,IPVT,RCOND,ZR,ZI)
604: SUBROUTINE WGEFA(AR,AI,LDA,N,IPVT,INFO)
605: SUBROUTINE WGESL(AR,AI,LDA,N,IPVT,BR,BI,JOB)
606: SUBROUTINE WGEDI(AR,AI,LDA,N,IPVT,DETR,DETI,WORKR,WORKI,JOB)
607: SUBROUTINE WPOFA(AR,AI,LDA,N,INFO)
608: SUBROUTINE RREF(AR,AI,LDA,M,N,EPS)
609: SUBROUTINE HILBER(A,LDA,N)
610: SUBROUTINE HTRIDI(NM,N,AR,AI,D,E,E2,TAU)
611: SUBROUTINE HTRIBK(NM,N,AR,AI,TAU,M,ZR,ZI)
612: SUBROUTINE IMTQL2(NM,N,D,E,Z,IERR,JOB)
613: SUBROUTINE CORTH(NM,N,LOW,IGH,AR,AI,ORTR,ORTI)
614: SUBROUTINE COMQR3(NM,N,LOW,IGH,ORTR,ORTI,HR,HI,WR,WI,ZR,ZI,IERR
615: SUBROUTINE WSVDC(XR,XI,LDX,N,P,SR,SI,ER,EI,UR,UI,LDU,VR,VI,LDV,
616: SUBROUTINE WQRDC(XR,XI,LDX,N,P,QRAUXR,QRAUXI,JPVT,WORKR,WORKI,
617: SUBROUTINE WQRSL(XR,XI,LDX,N,K,QRAUXR,QRAUXI,YR,YI,QYR,QYI,QTYR,
618: SUBROUTINE MAGIC(A,LDA,N)
619: SUBROUTINE BASE(X,B,EPS,S,N)
620: DOUBLE PRECISION FUNCTION URAND(IY)
621: SUBROUTINE WMUL(AR,AI,BR,BI,CR,CI)
622: SUBROUTINE WDIV(AR,AI,BR,BI,CR,CI)
623: SUBROUTINE WSIGN(XR,XI,YR,YI,ZR,ZI)
624: SUBROUTINE WSQRT(XR,XI,YR,YI)
625: SUBROUTINE WLOG(XR,XI,YR,YI)
626: SUBROUTINE WATAN(XR,XI,YR,YI)
627: DOUBLE PRECISION FUNCTION WNRM2(N,XR,XI,INCX)
628: DOUBLE PRECISION FUNCTION WASUM(N,XR,XI,INCX)
629: INTEGER FUNCTION IWAMAX(N,XR,XI,INCX)
630: SUBROUTINE WRSCAL(N,S,XR,XI,INCX)
631: SUBROUTINE WSCAL(N,SR,SI,XR,XI,INCX)
632: SUBROUTINE WAXPY(N,SR,SI,XR,XI,INCX,YR,YI,INCY)
633: DOUBLE PRECISION FUNCTION WDOTUR(N,XR,XI,INCX,YR,YI,INCY)
634: DOUBLE PRECISION FUNCTION WDOTUI(N,XR,XI,INCX,YR,YI,INCY)
635: DOUBLE PRECISION FUNCTION WDOTCR(N,XR,XI,INCX,YR,YI,INCY)
636: DOUBLE PRECISION FUNCTION WDOTCI(N,XR,XI,INCX,YR,YI,INCY)
637: SUBROUTINE WCOPY(N,XR,XI,INCX,YR,YI,INCY)
638: SUBROUTINE WSET(N,XR,XI,YR,YI,INCY)
639: SUBROUTINE WSWAP(N,XR,XI,INCX,YR,YI,INCY)
640: SUBROUTINE RSET(N,DX,DY,INCY)
641: SUBROUTINE RSWAP(N,X,INCX,Y,INCY)
642: SUBROUTINE RROT(N,DX,INCX,DY,INCY,C,S)
643: SUBROUTINE RROTG(DA,DB,C,S)
644: LOGICAL FUNCTION EQID(X,Y)
645: SUBROUTINE PUTID(X,Y)
646: DOUBLE PRECISION FUNCTION ROUND(X)
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663: MATLAB Installation, page 11
664:
665:
666:
667: First subroutine in file MAT:
668:
669: SUBROUTINE MATLAB(INIT)
670: C INIT = 0 FOR ORDINARY FIRST ENTRY
671: C = POSITIVE FOR SUBSEQUENT ENTRIES
672: C = NEGATIVE FOR SILENT INITIALIZATION (SEE MATZ)
673: C
674: DOUBLE PRECISION STKR(5005),STKI(5005)
675: INTEGER IDSTK(4,48),LSTK(48),MSTK(48),NSTK(48),VSIZE,LSIZE,BOT,TOP
676: INTEGER ALFA(52),ALFB(52),ALFL,CASE
677: INTEGER IDS(4,32),PSTK(32),RSTK(32),PSIZE,PT,PTZ
678: INTEGER DDT,ERR,FMT,LCT(4),LIN(1024),LPT(6),RIO,WIO,RTE,WTE,HIO
679: INTEGER SYM,SYN(4),BUF(256),CHAR,FLP(2),FIN,FUN,LHS,RHS,RAN(2)
680: COMMON /VSTK/ STKR,STKI,IDSTK,LSTK,MSTK,NSTK,VSIZE,LSIZE,BOT,TOP
681: COMMON /ALFS/ ALFA,ALFB,ALFL,CASE
682: COMMON /RECU/ IDS,PSTK,RSTK,PSIZE,PT,PTZ
683: COMMON /IOP/ DDT,ERR,FMT,LCT,LIN,LPT,RIO,WIO,RTE,WTE,HIO
684: COMMON /COM/ SYM,SYN,BUF,CHAR,FLP,FIN,FUN,LHS,RHS,RAN
685: C
686: DOUBLE PRECISION S,T
687: INTEGER EPS(4),FLOPS(4),EYE(4),RAND(4)
688: C
689: C CHARACTER SET
690: C 0 10 20 30 40 50
691: C
692: C 0 0 A K U COLON : LESS <
693: C 1 1 B L V PLUS + GREAT >
694: C 2 2 C M W MINUS -
695: C 3 3 D N X STAR *
696: C 4 4 E O Y SLASH /
697: C 5 5 F P Z BSLASH \
698: C 6 6 G Q BLANK EQUAL =
699: C 7 7 H R LPAREN ( DOT .
700: C 8 8 I S RPAREN ) COMMA ,
701: C 9 9 J T SEMI ; QUOTE '
702: C
703: INTEGER ALPHA(52),ALPHB(52)
704: DATA ALPHA /1H0,1H1,1H2,1H3,1H4,1H5,1H6,1H7,1H8,1H9,
705: $ 1HA,1HB,1HC,1HD,1HE,1HF,1HG,1HH,1HI,1HJ,
706: $ 1HK,1HL,1HM,1HN,1HO,1HP,1HQ,1HR,1HS,1HT,
707: $ 1HU,1HV,1HW,1HX,1HY,1HZ,1H ,1H(,1H),1H;,
708: $ 1H:,1H+,1H-,1H*,1H/,1H\,1H=,1H.,1H,,1H',
709: $ 1H<,1H>/
710: C
711: C ALTERNATE CHARACTER SET
712: C
713: DATA ALPHB /1H0,1H1,1H2,1H3,1H4,1H5,1H6,1H7,1H8,1H9,
714: $ 1Ha,1Hb,1Hc,1Hd,1He,1Hf,1Hg,1Hh,1Hi,1Hj,
715: $ 1Hk,1Hl,1Hm,1Hn,1Ho,1Hp,1Hq,1Hr,1Hs,1Ht,
716: $ 1Hu,1Hv,1Hw,1Hx,1Hy,1Hz,1H ,1H(,1H),1H;,
717: $ 1H|,1H+,1H-,1H*,1H/,1H$,1H=,1H.,1H,,1H",
718: $ 1H[,1H]/
719: C
720:
721:
722:
723:
724:
725:
726:
727:
728:
729: MATLAB Installation, page 12
730:
731:
732:
733: DATA EPS/14,25,28,36/,FLOPS/15,21,24,25/
734: DATA EYE/14,34,14,36/,RAND/27,10,23,13/
735: C
736: IF (INIT .GT. 0) GO TO 90
737: C
738: C RTE = UNIT NUMBER FOR TERMINAL INPUT
739: C WTE = UNIT NUMBER FOR TERMINAL OUTPUT
740: C HIO = UNIT NUMBER FOR HELP FILE
741: RTE = 5
742: WTE = 6
743: HIO = 9
744: C
745: IF (INIT .GE. 0) WRITE(WTE,100)
746: 100 FORMAT(//1X,' < M A T L A B >'
747: $ /1X,' Version of --/--/--')
748: C
749: C ASK HELPER TO OPEN HELP FILE
750: BUF(1) = 0
751: CALL HELPER(BUF)
752: C
753: C RANDOM NUMBER SEED
754: RAN(1) = 0
755: C
756: C INITIAL LINE LIMIT
757: LCT(2) = 25
758: C
759: ALFL = 52
760: CASE = 1
761: C CASE = 1 for file names in lower case
762: DO 20 I = 1, ALFL
763: ALFA(I) = ALPHA(I)
764: ALFB(I) = ALPHB(I)
765: 20 CONTINUE
766: C
767: VSIZE = 50005
768: LSIZE = 48
769: PSIZE = 32
770: BOT = LSIZE-3
771: CALL WSET(5,0.0D0,0.0D0,STKR(VSIZE-4),STKI(VSIZE-4),1)
772: CALL PUTID(IDSTK(1,LSIZE-3),EPS)
773: LSTK(LSIZE-3) = VSIZE-4
774: MSTK(LSIZE-3) = 1
775: NSTK(LSIZE-3) = 1
776: S = 1.0D0
777: 30 S = S/2.0D0
778: T = 1.0D0 + S
779: IF (T .GT. 1.0D0) GO TO 30
780: STKR(VSIZE-4) = 2.0D0*S
781: CALL PUTID(IDSTK(1,LSIZE-2),FLOPS)
782: LSTK(LSIZE-2) = VSIZE-3
783: MSTK(LSIZE-2) = 1
784: NSTK(LSIZE-2) = 2
785: CALL PUTID(IDSTK(1,LSIZE-1), EYE)
786:
787:
788:
789:
790:
791:
792:
793:
794:
795: MATLAB Installation, page 13
796:
797:
798:
799: LSTK(LSIZE-1) = VSIZE-1
800: MSTK(LSIZE-1) = -1
801: NSTK(LSIZE-1) = -1
802: STKR(VSIZE-1) = 1.0D0
803: CALL PUTID(IDSTK(1,LSIZE), RAND)
804: LSTK(LSIZE) = VSIZE
805: MSTK(LSIZE) = 1
806: NSTK(LSIZE) = 1
807: FMT = 1
808: FLP(1) = 0
809: FLP(2) = 0
810: DDT = 0
811: RAN(2) = 0
812: PTZ = 0
813: PT = PTZ
814: ERR = 0
815: RIO = RTE
816: WIO = 0
817: IF (INIT .LT. 0) RETURN
818: C
819: 90 CALL PARSE
820: IF (FUN .EQ. 1) CALL MATFN1
821: IF (FUN .EQ. 2) CALL MATFN2
822: IF (FUN .EQ. 3) CALL MATFN3
823: IF (FUN .EQ. 4) CALL MATFN4
824: IF (FUN .EQ. 5) CALL MATFN5
825: IF (FUN .EQ. 6) CALL MATFN6
826: IF (FUN .EQ. 21) CALL MATFN1
827: IF (FUN .NE. 99) GO TO 90
828: RETURN
829: END
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861: MATLAB Installation, page 14
862:
863:
864:
865: Typical file SYS (Nonstandard stuff in lower case):
866:
867: C PROGRAM MAIN
868: call overflow-control
869: CALL MATLAB(0)
870: STOP
871: END
872:
873:
874: SUBROUTINE FILES(LUNIT,NAME)
875: INTEGER LUNIT,NAME(32)
876: C
877: C SYSTEM DEPENDENT ROUTINE TO ALLOCATE FILES
878: C LUNIT = LOGICAL UNIT NUMBER
879: C NAME = FILE NAME, 1 CHARACTER PER WORD
880: C
881: character*32 nam
882: c
883: c close exec, save, load and print files
884: if (lunit .lt. 0) then
885: close(unit=-lunit)
886: return
887: end if
888: c
889: c Fortran 77 internal file conversion from 32a1 to character*32
890: write(nam,'(32a1)') name
891: c
892: c formatted i/o for exec and print
893: if (lunit .gt. 2) open(unit=lunit,file=nam)
894: c
895: c unformatted i/o for save and load
896: if (lunit .le. 2) open(unit=lunit,file=nam,form='unformatted')
897: c
898: c rewind all except diary
899: if (lunit .ne. 8) rewind lunit
900: c
901: RETURN
902: END
903:
904:
905: SUBROUTINE SAVLOD(LUNIT,ID,M,N,IMG,JOB,XREAL,XIMAG)
906: INTEGER LUNIT,ID(4),M,N,IMG,JOB
907: DOUBLE PRECISION XREAL(1),XIMAG(1)
908: C
909: C IMPLEMENT SAVE AND LOAD
910: C LUNIT = LOGICAL UNIT NUMBER
911: C ID = NAME, FORMAT 4A1
912: C M, N = DIMENSIONS
913: C IMG = NONZERO IF XIMAG IS NONZERO
914: C JOB = 0 FOR SAVE
915: C = SPACE AVAILABLE FOR LOAD
916: C XREAL, XIMAG = REAL AND OPTIONAL IMAGINARY PARTS
917: C
918:
919:
920:
921:
922:
923:
924:
925:
926:
927: MATLAB Installation, page 15
928:
929:
930:
931: C THIS VERSION USES UNFORMATTED READ AND WRITE
932: C
933: IF (JOB .GT. 0) GO TO 20
934: C
935: C SAVE
936: 10 WRITE(LUNIT) ID,M,N,IMG
937: DO 15 J = 1, N
938: K = (J-1)*M+1
939: L = J*M
940: WRITE(LUNIT) (XREAL(I),I=K,L)
941: IF (IMG .NE. 0) WRITE(LUNIT) (XIMAG(I),I=K,L)
942: 15 CONTINUE
943: RETURN
944: C
945: C LOAD
946: 20 READ(LUNIT,END=30) ID,M,N,IMG
947: IF (M*N .GT. JOB) GO TO 30
948: DO 25 J = 1, N
949: K = (J-1)*M+1
950: L = J*M
951: READ(LUNIT,END=30) (XREAL(I),I=K,L)
952: IF (IMG .NE. 0) READ(LUNIT,END=30) (XIMAG(I),I=K,L)
953: 25 CONTINUE
954: RETURN
955: C
956: C END OF FILE
957: 30 M = 0
958: N = 0
959: RETURN
960: END
961:
962:
963: SUBROUTINE FORMZ(LUNIT,X,Y)
964: DOUBLE PRECISION X,Y
965: C
966: C SYSTEM DEPENDENT ROUTINE TO PRINT WITH Z FORMAT
967: C
968: IF (Y .NE. 0.0D0) WRITE(LUNIT,10) X,Y
969: IF (Y .EQ. 0.0D0) WRITE(LUNIT,10) X
970: 10 format(2z18)
971: RETURN
972: END
973:
974:
975: DOUBLE PRECISION FUNCTION FLOP(X)
976: DOUBLE PRECISION X
977: C SYSTEM DEPENDENT FUNCTION
978: C COUNT AND POSSIBLY CHOP EACH FLOATING POINT OPERATION
979: C FLP(1) IS FLOP COUNTER
980: C FLP(2) IS NUMBER OF PLACES TO BE CHOPPED
981: C
982: INTEGER SYM,SYN(4),BUF(256),CHAR,FLP(2),FIN,FUN,LHS,RHS,RAN(2)
983: COMMON /COM/ SYM,SYN,BUF,CHAR,FLP,FIN,FUN,LHS,RHS,RAN
984:
985:
986:
987:
988:
989:
990:
991:
992:
993: MATLAB Installation, page 16
994:
995:
996:
997: C
998: double precision mask(14),xx,mm
999: real mas(2,14)
1000: logical lx(2),lm(2)
1001: equivalence (lx(1),xx),(lm(1),mm)
1002: equivalence (mask(1),mas(1))
1003: data mas/
1004: $ z'ffffffff',z'fff0ffff',
1005: $ z'ffffffff',z'ff00ffff',
1006: $ z'ffffffff',z'f000ffff',
1007: $ z'ffffffff',z'0000ffff',
1008: $ z'ffffffff',z'0000fff0',
1009: $ z'ffffffff',z'0000ff00',
1010: $ z'ffffffff',z'0000f000',
1011: $ z'ffffffff',z'00000000',
1012: $ z'fff0ffff',z'00000000',
1013: $ z'ff00ffff',z'00000000',
1014: $ z'f000ffff',z'00000000',
1015: $ z'0000ffff',z'00000000',
1016: $ z'0000fff0',z'00000000',
1017: $ z'0000ff80',z'00000000'/
1018: C
1019: FLP(1) = FLP(1) + 1
1020: K = FLP(2)
1021: FLOP = X
1022: IF (K .LE. 0) RETURN
1023: FLOP = 0.0D0
1024: IF (K .GE. 15) RETURN
1025: XX = X
1026: MM = MASK(K)
1027: LX(1) = and(LX(1),LM(1))
1028: LX(2) = and(LX(2),LM(2))
1029: FLOP = XX
1030: RETURN
1031: END
1032:
1033:
1034: SUBROUTINE XCHAR(BUF,K)
1035: INTEGER BUF(1),K
1036: C
1037: C SYSTEM DEPENDENT ROUTINE TO HANDLE SPECIAL CHARACTERS
1038: C
1039: INTEGER DDT,ERR,FMT,LCT(4),LIN(1024),LPT(6),RIO,WIO,RTE,WTE
1040: COMMON /IOP/ DDT,ERR,FMT,LCT,LIN,LPT,RIO,WIO,RTE,WTE
1041: write(WTE,10) buf(1)
1042: 10 format(A1,' is not a MATLAB character.')
1043: RETURN
1044: END
1045:
1046:
1047: SUBROUTINE USER(A,M,N,S,T)
1048: DOUBLE PRECISION A(M,N),S,T
1049: C
1050:
1051:
1052:
1053:
1054:
1055:
1056:
1057:
1058:
1059: MATLAB Installation, page 17
1060:
1061:
1062:
1063: INTEGER A3(9)
1064: DATA A3 /-149,537,-27,-50,180,-9,-154,546,-25/
1065: IF (A(1,1) .NE. 3.0D0) RETURN
1066: DO 10 I = 1, 9
1067: A(I,1) = A3(I)
1068: 10 CONTINUE
1069: M = 3
1070: N = 3
1071: RETURN
1072: END
1073:
1074:
1075: SUBROUTINE PROMPT(PAUSE)
1076: INTEGER PAUSE
1077: C
1078: C ISSUE MATLAB PROMPT WITH OPTIONAL PAUSE
1079: C
1080: INTEGER DDT,ERR,FMT,LCT(4),LIN(1024),LPT(6),RIO,WIO,RTE,WTE
1081: COMMON /IOP/ DDT,ERR,FMT,LCT,LIN,LPT,RIO,WIO,RTE,WTE
1082: WRITE(WTE,10)
1083: IF (WIO .NE. 0) WRITE(WIO,10)
1084: 10 FORMAT(1X,/'<>')
1085: IF (PAUSE .EQ. 1) READ(RTE,20) DUMMY
1086: 20 FORMAT(A1)
1087: RETURN
1088: END
1089:
1090:
1091: SUBROUTINE PLOT(LUNIT,X,Y,N,P,K,BUF)
1092: DOUBLE PRECISION X(N),Y(N),P(1)
1093: INTEGER BUF(79)
1094: C
1095: C PLOT X VS. Y ON LUNIT
1096: C IF K IS NONZERO, THEN P(1),...,P(K) ARE EXTRA PARAMETERS
1097: C BUF IS WORK SPACE
1098: C
1099: DOUBLE PRECISION XMIN,YMIN,XMAX,YMAX,DY,DX,Y1,Y0
1100: INTEGER AST,BLANK,H,W
1101: DATA AST/1H*/,BLANK/1H /,H/20/,W/79/
1102: C
1103: C H = HEIGHT, W = WIDTH
1104: C
1105: XMIN = X(1)
1106: XMAX = X(1)
1107: YMIN = Y(1)
1108: YMAX = Y(1)
1109: DO 10 I = 1, N
1110: XMIN = DMIN1(XMIN,X(I))
1111: XMAX = DMAX1(XMAX,X(I))
1112: YMIN = DMIN1(YMIN,Y(I))
1113: YMAX = DMAX1(YMAX,Y(I))
1114: 10 CONTINUE
1115: DX = XMAX - XMIN
1116:
1117:
1118:
1119:
1120:
1121:
1122:
1123:
1124:
1125: MATLAB Installation, page 18
1126:
1127:
1128:
1129: IF (DX .EQ. 0.0D0) DX = 1.0D0
1130: DY = YMAX - YMIN
1131: WRITE(LUNIT,35)
1132: DO 40 L = 1, H
1133: DO 20 J = 1, W
1134: BUF(J) = BLANK
1135: 20 CONTINUE
1136: Y1 = YMIN + (H-L+1)*DY/H
1137: Y0 = YMIN + (H-L)*DY/H
1138: JMAX = 1
1139: DO 30 I = 1, N
1140: IF (Y(I) .GT. Y1) GO TO 30
1141: IF (L.NE.H .AND. Y(I).LE.Y0) GO TO 30
1142: J = 1 + (W-1)*(X(I) - XMIN)/DX
1143: BUF(J) = AST
1144: JMAX = MAX0(JMAX,J)
1145: 30 CONTINUE
1146: WRITE(LUNIT,35) (BUF(J),J=1,JMAX)
1147: 35 FORMAT(1X,79A1)
1148: 40 CONTINUE
1149: RETURN
1150: END
1151:
1152:
1153: SUBROUTINE EDIT(BUF,N)
1154: INTEGER BUF(N)
1155: C
1156: C CALLED AFTER INPUT OF A SINGLE BACKSLASH
1157: C BUF CONTAINS PREVIOUS INPUT LINE, ONE CHAR PER WORD
1158: C ENTER LOCAL EDITOR IF POSSIBLE
1159: C
1160: character*256 s
1161: open(7,file='----')
1162: write(7,10) (buf(i),i=1,n)
1163: 10 format(256a1)
1164: close(7)
1165: call system('edit ----')
1166: open(7,file='----')
1167: rewind 7
1168: read(7,'(a)') s
1169: close(7)
1170: call system('remove ----')
1171: n = 0
1172: do 20 i = 1, 256
1173: if (s(i:i) .ne. ' ') n = i
1174: 20 continue
1175: read(s,10) (buf(i),i=1,n)
1176: RETURN
1177: END
1178:
1179:
1180:
1181:
1182:
1183:
1184:
1185:
1186:
1187:
1188:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.