There are no other files named subs.lbr in the archive.

E/ sub.LBR.1;xF_

sBINOML(%[urCLEOL,V%[urCLEOS,WZ%[usCOPY-1`%[usCPLOT0\%[usCPLOT25nk%[utCRBARS:Y%[utCRBELL>w%[utCRC151-2?w]%[uuCRC153-156DT9%[uuCRC154-155K -%[uzICHOUTr7l3]AQCRJOUTu##3]ANCREMOTxF m%[u{CRERBR4k%[u{CRFLIN%[u{CRFNIN=w%[u|CRFREQ4:%[u}CRFUNCok%[u~CRGAMZ*%[u~DATA-ENTRY-INDEXDEXF:u\QCRGRIT"o%[vCRGRLB$s;%[vCRHACH).}%[vCRHALT-,*%[vCRHIAX.Vb%[vCRHIST187%[vCRMTOC8o3]AOCRLBOP:&%[vCRLDAV@%%[vCRLHSTB;n%[vCRLNFCH*l%[vCRLOGGAML2%[vCRMAILOH%[v CRMATH2VbV%[v CRMNIMY8 |%[v CRMNX-2c5%[v CRMOVEgL%[v CRUSERiek3]APCRMVCHkP3%[vCRNINo%[vCRNTOIr

%[v

CRON-CROFF-CRTESTu,\%[v1%[vCRPOLYA@%[vICHINxk%[vCRSINTd)%[vCRSIZE

}%[vCRTWMY/f%[vCRVCR4~I%[vCRWAIT:G%[vCRWTST<]x%[vCRXPNGBUJ%[vCURHOMH [%[vCURUPH{s%[vDATA-ENTRYIn%[vDATEf-%[vDATEINg/J%[vDOJSYSuy

G%[vEASTERA]%[vCRUPER34-GETADRI%[vGETDDTQ;%[vHOSPNO

C%[vICOMPO4%[vICRCH2i%[vICRCH3#lO%[vICRCH4&<o%[vICRCH7)+m%[vICRNTM,^%[vICRSCH.wd%[vICRTLU4[%[vDATA-ENTRY-INDEX7nzMONTHINDEX:i^3;=OINPUT-TERMINAL-INDEX<GF%kX9CRCLRCRZEROTING>q0%[v!MWsg%[v"NELDER~w%[v"NINT

A%[v#NPH11NX%[v#NPH2 &A%[v$NPH3o%[v$NPLOT1u%[v$NSCOR2y%[v%NUMINV%[v%PK,b%[v&PNPLOT/aPOLY4z%[v&PUTCRS7t%[v'RADII9

B%[v'RANDOMEJ}%[v'RANDUPHGq%[v'RANSETJ9'%[v(REALINK`%[v(RIGHTYa2%[v(SBS[

%[v)SNDEVvPS%[v)SPLITNxs.:%[v,STAT7Ahn%[v,STAT7MW

%[v,STAT8!ch%[v,TABCLR$LJ%[v-TABLE%g%[v-TABSET0}g%[v-TBLOOK1d%[v.TBRLOC8h%[v.TEXTIN@O%[v.VT-SUBROUTINE-CONVENTIONSOO%[v/VT132SfR%[v/VT80T8Q%[v/VTATRU .%[v0VTBIGW72%[v0VTCBLXjW%[v0VTCBSYAV%[v0VTCLINZW%[v0VTCLSZnL%[v0VTDWN[:m%[v1VTEND\'%[v1VTGOF]9d%[v1VTGON^&%[v1VTINIT_D%[v2VTIUP`O#%[v2VTJMPasJ%[v2VTLEDb=t%[v2VTLFTc2m%[v3VTORGd%[v3VTRESf.[%[v3VTRITg m%[v3VTSAVgwX%[v4VTSCRNhOh%[v4VTSMTHi7L%[v4VTTYj3%[v4VTWIDm7=%[v5WCOEFnt%[v5WEXTqw}%[v5YESNOvt

O%[v5LP-PLOTTING-INDEXD'%kX:NRMPLTkt%cd?CRSIL_+NECRGRAFy

+c_CRAX5-F-G C+29CRGRAX%I+LECRGRWOERS-INDEX-h'6PCRAISE3+.|[kDATES-INDEX5>Z3;= CHKLETBINOML ROUTINE CAT8{3=/MISCELLANEOUS-INDEX(N,M,PT,PROB) LANG:3=.tCRDTOISCRIPTION THIS SUBROUTINE CAL?#3]ANCRLBRDY OF 'M' SUCCESSES IN 'N' D93]AOCRRSCNTHE PROBABILITY OF A SINGLE b{HW|3]APSIMINPTURNS THETCALCULATED PROBABILITY MTl3]AQGENCHKQ@ CATTMG4-pGRAPH-PLOTTING-INDEXN,M,PT,PROB) LANGZ 6QOWSCRIPTION THIS SUBROUTINE CAL^m:{>}KYDALWY OF 'M' SUCCESSES IN 'N' fB:{?TIMEINTHE PROBABILITY OF A SINGLE lN3:{S`PNPLOTTURNS THE CALCULATED PROBABILITY |E;xFINVALID VALUES OF THE INPUT PARAMETERS(E.G. M>N ETC.) CAUSE THE VALUE OF PROB TO BE RETURNED AS ZERO. METHOD: PROB = N!/(M!*(N-M)!)*(PT**M)*(1-PT)**N-M BUT THE CALCULATION IS CARRIED OUT IN TERMS OF THE LOG OF THE FACTORIALS SO AS TO MINIMISE THE POSSIBILITY OF OVERFLOW OR UNDERFLOW FOR LARGE N OR M AND TO OPTIMISE THE COMPUTATION SPEED. PROB=EXP[ LOGFAC(N)-LOGFAC(M)-LOGFAC(N-M)+M*LOG(PT) +(N-M)*LOG(1-PT) ] PARAMETERS N INTEGER VARIABLE M INTEGER VARIABLE PT FLOATING POINT VARIABLE 0.0.LE.PT.LE.1.0 PROB OUTPUT VALUE - FLOATING POINT VARIABLE LEVEL: LEVEL 1 AUTHOR G.GIBBS/I.D.HILL DATE: FEBRUARY 1981 CLEOL ROUTINE CATEGORY: L6 NAME: CLEOL PURPOSE: Clears from the cursor to the end of the line. PARAMETERS: None AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 CLEOS ROUTINE CATEGORY: L3 NAME: CLEOS PURPOSE: Clears the screen from the cursor to the end of screen PARAMETERS: None AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 COPY ROUTINE CATEGORY: A2 TITLE: SUBROUTINE COPY(N,A,I,B,J) LANGUAGE: FORTRAN DESCRIPTION: COPY CHARACTERS N CHARACTERS ARE COPIED FROM B TO A. IF ANY OF N,I AND J ARE NON-POSITIVE, THERE IS NO EFFECT. PARAMETERS: N INTEGER INPUT NO OF CHARACTERS TO BE COPIED A ANY INPUT ELEMENT TO WHICH TO COPY I INTEGER INPUT CHAR POSITION IN A TO WHICH COPYING IS TO START (COUNTING FROM 1) B ANY INPUT ELEMENT FROM WHICH TO COPY J INTEGER INPUT CHAR POSITION IN B FROM WHICH COPYING IS TO START ROUTINES CALLED: CRMVCH LEVEL: LEVEL 1 AUTHOR: G.GIBBS DATE: MARCH 1981 CPLOT ROUTINE CATEGORY: D9 TITLE: CPLOT (SSP,NVAR,NUM,NCHAN) LANGUAGE FORTRAN DESCRIPTION GIVEN A SYMMETRIC MATRIX OF CORRELATION COEFFICIENTS IN SSP BASED ON NVAR VARIABLES OBSERVED ON NUM CASES THIS SUBROUTINE USES A GRAPHICAL TECHNIQUE TO DETERMINE WHICH OF THE CORRELATION COEFFICIENTS ARE TOO LARGE TO COME FROM ZERO POPULATION VALUES. INTERPRETATION OF THE PRINTOUT RESTS ON COMPARING THE HALF-NORMAL PLOT WHICH IS OBTAINED FROM A GIVEN MATRIX WITH A STRAIGHT LINE THROUGH THE ORIGIN OF THE MATRIX AND A POINT MARKED AT A VALUE ON THE X AXIS EQUAL TO 2.0. THIS LINE CORRESPONDS TO THE HALF-NORMAL PLOT WHICH IS APPROPRIATE FOR NUM CASES AND NVAR UNCORRELATED VARIABLES. NOTE THAT ARRAY SSP IS SORTED BY CRC154 FIRST. FURTHER EVIDENCE IS OBTAINED BY ANY SHARP CHANGES IN SLOPE OF THE OBSERVED PLOT. REFERENCES: THE HALF-NORMAL PLOT IS USED AS DESCRIBED BY HILLS , BIOMETRIKA(1969),56,249. PARAMETERS SSP REAL ARRAY SYMMETRIC MATRIX NVAR INTEGER NO. OF VARIABLES NUM INTEGER NO. OF CASES NCHAN INTEGER OUTPUT CHANNEL OWN VARIABLES: Y REAL ARRAY DIMENSIONED TO 500 I.E. 1/2*NVAR*(NAR-1)+1.LE.500 OR NVAR.LE.32 ROUTINES CALLED: CRC154, SNDEV, CRC561 LEVEL: LEVEL 2 AUTHOR KLIM MCPHERSON DATE 19TH JULY 1972 CPLOT2 ROUTINE CATEGORY: D10 TITLE: SUBROUTINE CPLOT2(X,IX,Y,IY,N,ICHAN,RESLT) DESCRIPTION: SCATTER DIAGRAM WITH STATISTICS X,Y ARE 1-DIM'L ARRAYS OF COORDINATES OF N POINTS. A SCATTER DIAGRAM OF Y AGAINST X IS OUTPUT AS A NEW PAGE ON CHANNEL ICHAN.IF N IS NOT >1000, THEN THIS IS FOLLOWED BY A TITLE LINE AND THEN BY THE MEANS, SD'S AND CORRELATION OF X AND Y. IX AND IY ARE TEXT ARRAYS OF UP TO 20 CHARS EACH DESCRIBING THE X'S AND Y'S RESPECTIVELY, SO THAT THE TITLE READS - X-VARIABLE IS (IX) Y-VARIABLE IS (IY) IF TEXT CONSTANTS ARE USED, THEY SHOULD HAVE AT LEAST 16 CHARS. THE STATISTICS ARE ALSO PLACED IN THE ARRAY RESLT IN THE SEQUENCE XBAR, SDX, YBAR, SDY, R IF N NOT >1000 . PARAMETERS: X,Y REAL ARRAY INPUT COORDINATES IX,IY INTEGER ARRAY INPUT COORD. DESCRIPTIONS N INTEGER INPUT NO OF POINTS =< 1000 ICHAN INTEGER INPUT OUTPUT CHANNEL RESLT REAL ARRAY OUTPUT STATISTICS COMMON BLOCKS: NONE OWN VARIABLES: NONE ROUTINES CALLED: CRC561,G01ABF LEVEL: LEVEL 3 AUTHOR: M.J.R.HEALY DATE: 30 JULY 1973 CRBARS ROUTINE CATEGORY: C29 TITLE: SUBROUTINE CRBARS(X,N,XLOW,XHIGH,IBP,IEP,YMIN,MARK) LANGUAGE: FORTRAN DESCRIPTION: DRAWS HISTOGRAM BARS (N.B. OPEN AT BOTTOM) PARAMETERS: X REAL ARRAY I/P ARRAY CONTAINING HEIGHTS OF NAME BARS (IN REQUIRED ORDER) N INTEGER I/P NUMBER OF BARS XLOW REAL I/P LOWER LIMIT OR VALUE OF FIRST BAR XHIGH REAL I/P UPPER LIMIT OR VALUE OF LAST BAR IBP, INTEGER I/P PERCENTAGE POINTS IN EACH IEP INTERVAL OF THE START AND FINISH POINTS OF EACH BAR YMIN REAL I/P MINIMUM POINT ON Y AXIS MARK INTEGER I/P A TWO DIGIT INDICATOR -2ND DIGIT INDICATES HATCHING REQUIRED IN BAR (SEE CRHATCH C30). 1ST DIGIT IF ZERO INTERVAL IS A RANGE, IF ONE INTERVAL IS A CATEGORY (SEE CRAXIS5 C32) REFERENCE: DOCAS REPORT ON PLOTTING PACKAGE ROUTINES CALLED: CRHACH+GINO-F ROUTINES LEVEL: LEVEL 1 AUTHOR: L.J.DOBSON/G.GIBBS DATE: DECEMBER 1981 CRBELL ROUTINE Category: L31 Title: CRBELL(N) Language: MACRO Description: Rings your terminal bell N times. If N is less than 1 the bell is not rung. Parameter: N Integer Input Number of times bell rung Author: G.Gibbs Date: 2 June 81 CRC151-2 ROUTINE CATEGORIES: E5 AND E6 TITLE: CRC151 (LIST,N) CRC152 (LIST,N,NCHAN) LANGUAGE: FORTRAN DESCRIPTION: SETS UP LIST OF INTEGERS. CRC151 SIMPLY WRITES 1,2,....N INTO THE ARRAY LIST. CRC152 EXPECTS IN LIST A LIST OF INTEGERS IN ABBREVIATED FORM. M,-K STANDS FOR M,M+1,...,K WHEN K>M M,-K STANDS FOR M,M-1,...,K WHEN K<M IF K=M, THEN -K IS CHANGED TO K. THE ROUTINE EXPANDS THE LIST. N IS THE LENGTH OF THE EXPANDED LIST. IF N IS TOO SMALL AN ERROR MESSAGE IS OUTPUT ON CHANNEL NCHAN, AND EXPANSION IS HALTED. PARAMETERS: CRC151 LIST INTEGER 1-ARRAY OUTPUT LOT OF CONSECUTIVE INTEGERS. N INTEGER INPUT LENGTH OF LIST CRC152 LIST INTEGER 1-ARRAY INPUT ABBREVIATED LIST OUTPUT EXPANDED LIST N INTEGER INPUT LENGTH OF EXPANDED LIST NCHAN INTEGER INPUT OUTPUT CHANNEL NO. FOR ERROR MESSAGE. COMPRESSED INTEGERS? YES FORTRAN TRACEABLE LEVEL 1 ONLY ROUTINES USED NONE LEVEL: LEVEL 0 AUTHOR M.J.R. HEALY DATE 3 JUNE 1971 CRC153-156 ROUTINE CATEGORIES: E7 AND E8 TITLE: CRC153 (X,LIST,C,N,NCHAN) CRC156 (X,CN,N,NCHAN,Y) *********************** ** Running but ** ** NOT definitively ** ** tested ** *********************** LANGUAGE: FORTRAN DESCRIPTION: LOG TRANSFORMATION OF VARIABLES. X IS A VECTOR OF VARIATE VALUES. CRC153 TRANSFORMS THE N ITEMS IDENTIFIED BY THE ELEMENTS OF LIST SO THAT X(LIST(I))=100.0*ALOG10(X(LIST(I))-C(I)) CRC156 SETS Y(I) =100.0*ALOG10(X(I)-CN) FOR I=1,N. IF A NON-POSITIVE ARGUMENT OF THE LOGARITHM IS ENCOUNTERED, THE ARGUMENT IS PRINTED OUT ON CHANNEL NCHAN, AND THE MODULUS OF THE ARGUMENT IS USED UNLESS THE ARGUMENT IS ZERO, WHEN X(LIST(I)) OR Y(I) IS SET TO ZERO. PARAMETERS: X REAL 1-ARRAY INPUT VECTOR OF VARIATE VALUES. OUTPUT VECTOR WITH SELECTED (CRC153) VALUES TRANSFORMED. LIST INTEGER 1-ARRAY INPUT VECTOR OF VARIATE (CRC153) NUMBERS. C REAL 1-ARRAY INPUT VECTOR OF CONSTANTS (CRC153) N INTEGER INPUT NO. OF VARIATE VALUES TO BE TRANSFORMED. NCHAN INTEGER INPUT OUTPUT CHANNEL NO. FOR ERROR MESSAGE. CN REAL INPUT CONSTANT (CRC156) Y REAL 1-ARRAY OUTPUT VECTOR OF TRANSFORMED (CRC156) VALUES. Y MAY COINCIDE WITH X COMPRESSED INTEGERS? YES FORTRAN TRACEABLE? LEVEL 1 ONLY ROUTINES USED NONE LEVEL: LEVEL 0 LIBRARY: SUBGROUPCRCA (0) AUTHOR M.J.R. HEALY DATE 3 JUNE 1971. CRC154-155 ROUTINE CATEGORY: B1 TITLE: CRC154 (A,N) CRC155 (A,N,IY) LANGUAGE FORTRAN DESCRIPTION SORT SUBROUTINES. A IS THE REAL ARRAY OF LENGTH N TO BE SORTED IN ORDER OF ASCENDING MAGNITUDE. CRC155 SORTS INTEGER ARRAY IY IN THE ORDER CORRESPONDING TO THAT OF A. METHOD BOOTHROYD'S PART SORT. ALGORITHM 27, COMP.J.10,308 1967. PARAMETERS: A REAL 1-ARRAY INPUT/OUTPUT ARRAY TO BE SORTED. N INTEGER INPUT SIZE OF A IY INTEGER 1-ARRAY INPUT/OUTPUT AUXILIARY ARRAY. ROUTINES USED NONE LEVEL: LEVEL 0 AUTHOR M.J.R. HEALY DATE 3 JUNE 1971. CRC161 ROUTINE CATEGORY: D1 TITLE: CRC161 (SMALL,BIG,AXLEN,DIV,START,FINISH,MARK1) LANGUAGE FORTRAN DESCRIPTION CALCULATES AXIS PARAMETERS FOR PLOTTING ROUTINE CRC561 TO ACCOMODATE VALUES BETWEEN SMALL AND BIG PARAMETERS: SMALL,BIG REAL INPUT EXTREME VALUES TO BE PLOTTED. AXLEN REAL INPUT NO. OF DIVISIONS AVAILABLE ON PLOTTING AXIS. DIV REAL OUTPUT LENGTH OF ONE DIVISION START,FINISH REAL OUTPUT COORDINATES OF EXTREMES OF AXIS. MARK1 INTEGER OUTPUT POSITION ON AXIS OF FIRST POINT TO BE LABELLED. ROUTINES USED NONE LEVEL: LEVEL 0 AUTHOR M.J.R. HEALY DATE 3 JUNE 1971 CRC162 ROUTINE CATEGORY: D2 TITLE: CRC162 (NCHAN) LANGUAGE: FORTRAN DESCRIPTION: PLOTS AXIS FOR PLOTTING ROUTINES (CRC362,CRC561) ON CHANNEL NCHAN. PARAMETERS: NCHAN INTEGER INPUT CHANNEL NO. FOR OUTPUT. COMMON BLOCK /PSCOM/ NM,MARKX,NUM. ROUTINES CALLED NONE LEVEL: LEVEL 0 AUTHOR M.J.R. HEALY DATE 3 JUNE 1971 CRC163 ROUTINE CATEGORY: D3 TITLE: CRC163 (AXLEN,START,FINISH,DIV,MARK1) LANGUAGE: FORTRAN DESCRIPTION: CALCULATES AXIS PARAMETERS FOR PLOTTING ROUTINE CRC362. PARAMETERS AXLEN REAL INPUT NO. OF DIVISIONS REQUIRED ON AXIS. START REAL INPUT (COORDINATES OF EXTREMES FINISH REAL INPUT (OF AXIS DIV REAL OUTPUT LENGTH OF ONE DIVISION MARK 1 INTEGER OUTPUT POSITION ON AXIS OF FIRST POINT TO BE LABELLED. ROUTINES CALLED NONE LEVEL: LEVEL 0 AUTHOR S. CHINN DATE 13 SEPT. 1971 CRC361 ROUTINE CATEGORY: D4 TITLE: CRC361 (X,N,AXLEN,DIV,START,FINISH,MARK1) LANGUAGE: FORTRAN DESCRIPTION: X IS AN ARRAY OF LENGTH N. THE ROUTINE CALCULATES PARAMETERS FOR PLOTTING ROUTINE CRC561 TO FIT ALL VALUES OF X ONTO A PAGE. PARAMETERS: X REAL 1-ARRAY INPUT VECTOR OF VALUES TO BE PLOTTED. N INTEGER INPUT LENGTH OF X AXLEN REAL INPUT NO. OF DIVISIONS AVAILABLE ON PLOTTING AXIS DIV REAL OUTPUT LENGTH OF ONE DIVISION START REAL OUTPUT (COORDINATES OF ENDS FINISH REAL OUTPUT (OF AXIS MARK 1 INTEGER OUTPUT POSITION ON AXIS OF FIRST POINT TO BE LABELLED. ROUTINES CALLED: CRC161 LEVEL: LEVEL 1 AUTHOR M.J.R. HEALY DATE 3 JUNE 1971 CRC363 ROUTINE CATEGORY: D5 TITLE: CRC363 (X,NX,NINT,XMIN,XINT,NAME,NCHAN) LANGUAGE FORTRAN DESCRIPTION: PLOTS HISTOGRAM. X IS AN ARRAY OF LENGTH NX CONTAINING VALUES FOR HISTOGRAM. NINT IS THE NUMBER OF INTERVALS USED, EACH OF LENGTH XINT, XMIN IS THE MINIMUM VALUE ON THE AXIS. THE CHARACTERS HELD IN THE FIRST 18 ELEMENTS (ONE IN EACH) OF NAME ARE USED TO LABEL THE HISTOGRAM. THE FIRST INTERVAL CONTAINS ALL POINTS LESS THAN XMIN+NINT*XINT. IF THERE ARE MORE THAN 106 POINTS IN ANY INTERVAL THE HISTOGRAM WILL NOT FIT ON THE LINE PRINTER PAGE. AN ERROR MESSAGE IS PRINTED ON CHANNEL NCHAN, AND THE CALLING ROUTINE RE-ENTERED. N.B. THE ROUTINE SORTS X IN ASCENDING ORDER. PARAMETERS X REAL 1-ARRAY INPUT/ VECTOR OF DIS- OUTPUT TRIBUTION VALUES NX INTEGER INPUT LENGTH OF X NINT INTEGER INPUT NO. OF INTERVALS XMIN REAL INPUT MINIMUM VALUE ON AXIS XINT REAL INPUT LENGTH OF INTERVAL NAME INTEGER 1-ARRAY INPUT HOLDS LABEL FOR HISTOGRAM NCHAN INTEGER INPUT OUTPUT CHANNEL NUMBER ROUTINES CALLED: CRC154 LEVEL: LEVEL 1 AUTHOR M.J.R. HEALY DATE 3 JUNE 1971 CRC561-362 ROUTINE CATEGORY: D7 TITLE: CRC561 (X,Y,N,NCHAN) CRC362 (X,Y,N,XPMIN,XPMAX,YPMIN, YPMAX,XDIV,YDIV,NCHAN) LANGUAGE FORTRAN DESCRIPTION: LINE PRINTER PLOT (2-WAY DISTRIBUTION). GIVEN ARRAYS X,Y OF LENGTH N, A TWO-WAY LINE PRINTER PLOT OF Y AGAINST X IS PRODUCED ON CHANNEL NCHAN. AN INTEGER BETWEEN 1 AND 9 REPRESENTS THAT NO. OF VALUES AT ONE POINT; IF THERE ARE MORE THAN 9 VALUES AT A POINT,* IS PRINTED. X AND Y ARE NOT ALTERED CRC561 CALCULATES EXTREME VALUES ON X AXIS OF LENGTH 100 AND Y AXIS OF LENGTH 45 SO THAT ALL POINTS ARE PLOTTED. CRC 362 USES AXES AS SPECIFIED (LENGTH OF X AXIS .LE. 100) THE NUMBER OF POINTS ( IF ANY ) THAT FALL OUTSIDE THE RANGE OF THE AXES IS PRINTED. PARAMETERS: X,Y REAL 1-ARRAY INPUT VECTORS OF COORDINATES NCHAN INTEGER INPUT CHANNEL NUMBER N INTEGER INPUT LENGTH OF X,Y IF NEGATIVE THE GRID MARKINGS ARE SUPPRESSED XPMIN REAL INPUT (EXTREMES OF X AXIS XPMAX REAL INPUT ( YPMIN REAL INPUT (EXTREMES OF Y AXIS YPMAX REAL INPUT ( XDIV REAL INPUT (NUMBER OF DIVISIONS YDIV REAL INPUT (ON EACH AXIS COMMON BLOCKS: PSCOM, NM, MARK, X, NUM ROUTINES CALLED CRC 561 CALLS CRC 361, CRC 162 CRC 362 CALLS CRC 162, CRC 163 LEVEL: CRC561 - LEVEL 2 CRC362 - LEVEL 1 AUTHOR M.J.R. HEALY, S.CHINN DATE 13 SEPT. 1971. CRCMD ROUTINE CATEGORY: K13 NAME: CRCMD(COMND,FLAGS,JSERR) PURPOSE: Allows a user program to execute EXEC commands while running. The sequence is somewhat similar to typing 2 ctrl/c's, followed by PUSH, the command, POP and CONTINUE. There are numerous differences, however. The command string may either be in an array, terminated by a zero word, or a quoted string. The flag word is a sum of a number of separate numbers as below ; if you want to use a certain combination of features, you just add up the numbers corresponding to them, and the result is the flag word. Value Effect ----- ------ 0 None 1 MEXEC is used instead of EXEC. 2 Command is echoed on the screen. 8 Performs a PUSH - see below 16 Execute COMAND.CMD on first call. The value of 1 must be specified on the first call, if used. Its value has no effect in subsequent calls. Similarly, 16 (to use COMAND.CMD) should be used on the first call, if desired. Normally, COMAND.CMD is temporarily renamed while the subroutine executes : specifying this flag causes it to be run when the EXEC is first started. The 8 value is used if you want to do a PUSH command from your program. It merely suspends your program, and allows any EXEC commands to be entered from your terminal. To return to your program, type POP. This then effects a return from the CRCMD subroutine. When 8 is used, the contents of the COMND array are ignored. On return, JSERR will contain the JSYS error code , if any, or zero for success. PARAMETERS: COMND Array input Contains the command to be executed May be a quoted string or array. FLAGS Integer input Bit encoded flag to indicate whether COMAND.CMD should be used, MEXEC, or whether command should be echoed. JSERR Integer output Contains the JSYS error code on exit or zero. Error codes may be looked up in the file <SOURCES>MONSYM.MAC. RESTRICTIONS: The LOGOUT or BYE commands may not be executed either by CRCMD, or by the user when using the PUSH feature. This is to prevent accidental loss of files. Attempting to execute these commands produces the error ?LOG capability required. Fielding of CTRL/C interrupts while CRCMD is running is not handled by the superior EXEC, but by CRCMD's inferior. Thus, a CTRL/C struck while in CRCMD merely causes CRCMD to return success instantly. AUTHOR: K. Ashley 27-Oct-81 REVISED: 1-Nov-81,1-Dec-81 Language: Macro-20 CRDIXN ROUTINE category: E43 title: Subroutine crdixn(x, n, p, ifail) language: fortran description: Dixon's test for a single outlier in a normal distribution. p is the probability that x(n) is not a member of the sample x(1) to x(n-1). P-values are interpolated from the table given by Dixon (Biometrics, 74-89, 9, 1953) using natural cubic spline functions (note that if this routine is to be called a very large number of times it will be more efficient to group the calls by n). If the data are supplied in ascending order, the extreme upper value is tested as a putative outlier; if the data are supplied in descending order, the extreme lower value is tested. parameters: x real array input observations n integer input number of observations p real output probability that x(n) is an outlier ifail integer output failure flag: -1: success, but p outside the range given by Dixon (0.005<p<0.3). p therefore set to 0.005 or 0.3, as appropriate. 0 : success 1 : n<3 or n>25 2 : observations not ordered 3 : all/too many observations the same 4 : internal (fit) failure 5 : internal (interpolation) failure routines called: x02acf, e01baf (calling e02baf & p01aaf), e02bbf (Nag library) author: R.Wootton date: 28-Jan-83 ICHOUT ROUTINE category: M6 title: subroutine ichout(letter) language: macro description: send a character to the screen, see also ichin. example: CALL VTINIT !initialise screen control CALL CRSIL(1) !stop echoing of characters DO 100 I=1,80 LETTER=ICHIN(IERROR) !get next character IF (IERROR.NE.0) GO TO 999 IF (LETTER.EQ.ITAB) CALL TABS !check for a tab CALL ICHOUT(LETTER) !echo character 100 CONTINUE CALL CRSIL(0) CALL VTEND ... parameters: letter integer input Ascii value of the character to output. or character i/p The character to output. routines called: none level: level 0 author: G.Gibbs date: July 1982, character variables July 1984 CRJOUT ROUTINE Category: J22 Title: CRJOUT (ICDATE,JDAY,IFMT) Language: MACRO Descrption: Outputs date in character form, to one of an array, a character variable or your terminal. In the latter case the name of the array should be replaced by the number 1, e.g. CALL CRDOUT(1,JDAY,IFMT) The degree of verbosity used is defined by IFMT, increasing from 27-Nov-81 for IFMT=1 to Friday, 27 November 1981 for IFMT=4 Sufficient space must be allowed in the array, if used, to allow for the maximum number of characters you are likely to get +1. Parameters: ICDATE array or OUTPUT Date in character form character JDAY integer OUTPUT The Julian day number IFMT integer INPUT The verbosity of output from 1 to 4 Author: G.Gibbs Date: November 1981, character variable July 1984 CREMOT ROUTINE CATEGORY: K10 TITLE: CREMOT(FILNAM,UNIT,ERROR) LANGUAGE: MACRO-20/MACRO-11 DESCRIPTION: The purpose of this routine is to allow a programmer on the 20 to spool a file to the OKI dot matrix plotter or the Calcomp plotter connected to our 11/34 system. This subroutine is both FORTRAN and MACRO callable. The routine communicates with our own network spooler, FLXSYS, which maintains the queue of files to be printed, in the same manner as the RPLOT program. The plot spooler (FLXSYS) will delete the file once it has been plotted. To remove files from the plot queue, use the PLDEL program (see HELP RPLOT for details about this.) To find out how long your file may take before it is plotted, type the IPQ command. This will give information similar to INFORMATION (ABOUT) OUTPUT-REQUESTS, and show you where you are in the queue. METHOD: The FORTRAN routine merely reformats the arguments, and then calls the routine at the MACRO entry point. This routine uses the IPCF system to communicate with [SYSTEM]FLXSYS, using a message format described in FLXSYS.DOC . The error (if any) returned to the user is that received FLXSYS. These are very few, and apart from an illegal unit number, the only one likely to be recieved is F$$QFU (queue full). This will occur if there are more than 64 files waiting to be plotted. Most errors will be handled by the spooler, which will recover, and need not concern the user. PARAMETERS: FORTRAN: FILNAM - An array containing the filename in ASCIZ or a quoted string, e.g. 'OKI.DAT' . The file must not be open at the time of the call. UNIT - An integer constant or variable to specify the unit number to plot on - 0 for the OKI, 1 for the Calcomp ERROR - An integer variable to receive the error/completion code (These are described below.) This variable MUST be zero on entry to the routine. It is reserved for future use as an input parameter. MACRO: Enter with T1/ JFN of file to be plotted (must be closed) T2/ Unit number (as above) T3/ 0 (As above) Returns: +1 always with T3/ Error/completion code, as follows: ERRORS: Defined error numbers: 0/ Call completed succesfully 5/ Unknown system error - this indicates a bug in the spooler, and should be reported to Kevin. 6/ Couldn't find filename (Fortran only) 7/ Illegal unit number 8/ Couldn't open file for read AUTHOR: K. Ashley DATE: 21-AUG-81 REVISED: 15-SEP-81,2-Dec-81 CRERBR ROUTINE category: C41 title: subroutine crerbr(x,y,vminus,vplus,width,log) language: fortran description: Draws error bars around the indicated position. If one of the uncertainties is zero then that "half" of the bar will not be drawn. parameters: x }real input { co-ordinates to draw error bars y } { around, in the user's units. vminus }real input { uncertainties in the -ve and +ve vplus } { directions in the user's units. width real input width of the error bars in mm. log logical input .true. gives a vertical bar .false. gives a horizontal one routines called: gino-f and ginograf routines level: level 0 author: G.Gibbs date: May 1982 CRFLIN ROUTINE Category: M3 Title: CRFLIN(A,MESAGE,IFT) Language: MACRO Description: Outputs MESAGE to your terminal as a prompt and accepts a real number from the keyboard,terminated with a new line or 80 characters, full ^R,^W,^U facilities are available. IFT is 0 if successful and 1 if erroneous. Parameters: A Real Output The number entered(if successful) MESAGE Array Input The prompt to be sent to terminal This should be as a quoted string eg:- 'PLEASE ENTER NUMBER >>' If it is neccessary to have a variable prompt it must terminate with a <null>.This may be inserted using PK , thus if the message has 24 characters you would require CALL PK(MESAGE,0,25) IFT integer Output 0 =success 1 = fail Author: G.Gibbs Date: 5th June 81 CRFNIN ROUTINE Category: M4 Title: CRFNIN(MESAGE,MODE,DEFNAM,DEFEXT,DFILEN,IPPN,IFT) Language: MACRO Description: Outputs MESAGE to your terminal as a prompt and accepts a file name from the keyboard,terminated with a new line. Recognition is available using the escape key, and defaults may be provided for the name and/or the extension. The file name is returned together with the 'project programmer number' which is required for opening files in a different directory. ^R,^W,^U facilities are available, although ^U will erase the prompt, however, ^R will restore it. The file may be required to exist or not-exist or don't care and a flag is returned to indicate success or not. Parameters: MESAGE Array Input The prompt to be sent to terminal This should be as a quoted string eg:- 'PLEASE ENTER FILE NAME >>' If it is neccessary to have a variable prompt it must terminate with a <null>.This may be inserted using PK , thus if the message has 24 characters you would require CALL PK(MESAGE,0,25) MODE integer input 0 = the file may or may not exist 1 = the file must not exist 2 = the file must exist DEFNAM integer input The default file name in quotes e.g. 'FRED', or 0 if there is to be no default DEFEXT integer input The default file extension in quotes e.g. 'DAT', or 0 if there is no default DFILEN double output The complete file name with extension precision in up to 10 characters IPPN integer output The project programmer number for array(2) the directory. This may be passed staight to the OPEN statment IFT integer Output 0 =success 1 = fail Example: DIMENSION IPPN(2) DOUBLE PRECISION DFILEN 100 CONTINUE CALL CRFNIN ('FILE NAME>',2,'FRED','DAT',DFILEN,IPPN,IFL) IF (IFL .NE. 0) GO TO 100 OPEN(UNIT=8,DEVICE='DSK',FILE=DFILEN,ACCESS='SEQIN' + ,DIRECTORY=IPPN) ========= OR =========== DIMENSION IPPN(2) DOUBLE PRECISION DFILEN 100 CONTINUE CALL CRFNIN ('FILE NAME>',0,0,0,DFILEN,IPPN,IFL) IF (IFL .NE. 0) GO TO 100 OPEN(UNIT=9,DEVICE='DSK',FILE=DFILEN,ACCESS='SEQOUT') Author: G.Gibbs Date: 5th June 81 CRFREQ ROUTINE CATEGORY: G14 TITLE: SUBROUTINE CRFREQ(X,N,Y,NO,XLOW,XHIGH) LANGUAGE: FORTRAN DESCRIPTION: GIVEN AN ARRAY (X) OF VALUES ASSIGNS THEM TO THE REQUIRED INTERVAL, WHERE THERE ARE N INTERVALS BETWEEN XLOW AND XHIGH SO THAT THE FIRST INTERVAL IS FROM XLOW UPTO XLOW + (XHIGH-XLOW)/N. FREQUENCY COUNTS FOR EACH INTERVAL ARE OUTPUT IN THE ARRAY Y. Y(N+1) AND Y(N+2) CONTAIN THE NUMBER LT XLOW, AND GE XHIGH RESPECTIVELY PARAMETERS: X REAL ARRAY I/P DATA TO BE ASSIGNED NAME N INTEGER I/P NO. OF VALUES Y REAL ARRAY O/P ARRAY CONTAINING FREQUENCY COUNTS NAME NO INTEGER I/P NO.OF INTERVALS + 2 XLOW REAL I/P LOWER LIMIT XHIGH REAL I/P UPPER LIMIT ROUTINES CALLED: CRCLR LEVEL: LEVEL 1 AUTHOR: L.J.DOBSON DATE: DECEMBER 1977 CRFUNC ROUTINE CATEGORY: G12 TITLE: FUNCTION CRFUNC(NF,C,NC,X) FUNCTION CRUSFN(NF,C,NC,X) FUNCTION CRMLFN(NF,X,NARG,C,NC) LANGUAGE: FORTRAN DESCRIPTION: RETURNS VALUE OF REQUIRED FUNCTION OF X, IF NF IS .GT. 0-9 THEN THE FUNCTION CRUSFN IS CALLED, THIS IS A USER DEFINED FUNCTION OF X. THE USER CAN VARY THE CONSTANTS SUPPLIED TO A STANDARD FUNCTION OR HIS OWN FUNCTION. N.B. THERE IS NO CHECK THAT THE USER HAS SUPPLIED THE CORRECT NO. OF CONSTANTS. THE FUNCTION CRUSFN BELOW IS THE ONE USED IF THE USER HAS NOT SUPPLIED HIS OWN:- FUNCTION CRUSFN(NF,C,NC,X) HER DIMENSION C(NC) CRUSFN=X RETURN END IF NF IS -VE THEN CRMLFN IS CALLED, IF THE USER HAS NOT SUPPLIED HIS/HER OWN VERSION THEN THE FOLLOWING IS USED :- FUNCTION CRMLFN(NF,X,NARG,C,NC) DIMENSION X(NARG),C(NC) CRMLFN=0.0 RETURN END PARAMETERS: NF INTEGER I/P FUNCTION NO. REQUIRED. FOR FUNCTIONS 1-9 SEE BELOW C REAL ARRAY I/P CONSTANTS IN FUNCTION NAME NC INTEGER I/P NUMBER OF CONSTANTS X REAL I/P X VALUE TO CALCULATE FUNCTION FOR NF=0 CRFUNC= X 1 = C(1)+C(2)*X 2 = C(1)+C(2)*X+C(3)*X**2 3 = C(1)+C(2)*X+C(3)*X**2+C(4)*X**3 4 = C(1)+C(2)*LOG10(X+C(3)) 5 = C(1)+C(2)*LOG(X+C(3)) 6 = C(1)+C(2)*EXP10(X+C(3)) 7 = C(1)+C(2)*EXP(X+C(3)) 8 = C(1)+C(2)*(X+C(3))**C(4) 9 = C(1)/(X+C(2)) ROUTINES CALLED: ALOG10,ALOG,EXP10,EXP,CRUSFN,CRMLFN (CRFUNC) LEVEL: CRFUNC -LEVEL 1, CRUSFN -LEVEL 0, CRMLFN -LEVEL 0 AUTHOR: L.J.DOBSON DATE: DECEMBER 1977 CRGAM ROUTINE category: E42 title: Function crgam(x,alpha,beta,upper,ifault) language: fortran description: incomplete gamma integral, i.e. tail area of the gamma distribution wtih parameters alpha and beta. Upper should be set .TRUE. to get upper tail area, use .FALSE. for lower tail area. method: slightly modified version of Applied Statistics algorithm references: AS 32 by G.P.Bhattacharjee (Appl. Statist.,19,285,1970) parameters: x real input gamma variate alpha real input parameter 1 (shape) beta real input parameter 2 (scale) upper logical input tail area selector ifault integer output fault indicator :- 0 if ok 1 if alpha =< 0 2 if x < 0 common blocks: none own variables: no routines called: s14abf (nag) level: level 0 author: J.P.Royston date: October 1982 DATA-ENTRY CATEGORY N Question/answer data entry --------------------------- N1 TEXTIN Reads free text from terminal after prompt N2 HOSPNO Reads a hospital number after a prompt N3 DATEIN Reads a free-format date after prompt, converts to Julian N4 KYWORD Reads one of a list of keywords or phrases, with recognition N5 SEXIN Reads a sex N6 YESNO Reads yes or no N7 NUMIN Reads an integer after a prompt N8 REALIN Reads a real after a prompt N9 TABLE Builds a keyword table for KYWORD N10 CROPEN Reads a filename, with recognition, and opens the file N11 TBLOOK Looks up a character string in a table created by TABLE N12 TBRLOC Relocates lookup table pointers after reading from disk. N13 KYALOW Allows special characters to be entered as part of keywords N14 KYDALW Prevents certain characters being considered part of keywords o 5 normal plots on the plotter 41 CRERBR draws error bars CRGRIT ROUTINE CATEGORY: C34 TITLE: SUBROUTINE CRGRIT LANGUAGE: FORTRAN DESCRIPTION: GRAPH DRAWING ROUTINE NO. 1 THIS INITIALISES AND SETS THE GRAPH DRAWING PARAMETERS TO THEIR DEFAULT VALUES AND SO MUST BE THE FIRST ROUTINE CALLED. SUBSEQUENT CALLS JUST RESET THE PARAMETERS TO THEIR DEFAULT VALUES. PARAMETERS: NONE REFERENCE: DOCAS REPORT ON PLOTTING PACKAGE ROUTINES CALLED: CRMOVE LEVEL: LEVEL 1 AUTHOR: L.J.DOBSON DATE: DECEMBER 1977 CRGRLB ROUTINE CATEGORY: C35 TITLE: SUBROUTINE CRGRLB(I,LAB) LANGUAGE: FORTRAN DESCRIPTION: GRAPH DRAWING ROUTINE NO. 2 THIS SETS UP LABELS OF THE REQUIRED TYPE FOR USE BY CRGRAPH OR CRHIST; THE DEFAULT IS NO LABELS. EACH LABEL WILL ONLY BE USED ONCE. THE LABEL ITSELF MUST BE A CHARACTER STRING OF UPTO 80 CHARACTERS, INCLUDING THE STRING TERMINATOR '*.' IT CAN ALSO INCLUDE SWITCHES SO THAT UPPER AND LOWER CASE LETTERS CAN BE PLOTTED, IF YOU CHOSE NOT TO USE LOWER CASE CHARACTERS IN 'LAB'. THE DEFAULT TO START IS UPPER CASE, THEN '*L' WILL SWITCH TO LOWER CASE AND '*U' WILL SWITCH TO UPPER CASE. TO OUTPUT AN '*' JUST PUT 2 TOGETHER, '**'. PARAMETERS: I INTEGER I/P TYPE OF LABEL. 1= X AXIS 2= Y AXIS, 3= GRAPH TITLE, 4= LINE,POINT OR HISTOGRAM BAR LABEL LAB INTEGER ARRAY I/P LABEL CHARACTER STRING OR TEXT CONSTANT REFERENCE: DOCAS REPORT ON PLOTTING PACKAGE ROUTINES CALLED: CRGRER,IPK,PK,CRMOVE LEVEL: LEVEL 1 AUTHOR: L.J.DOBSON DATE: DECEMBER 1977 CRHACH ROUTINE CATEGORY: C30 TITLE: SUBROUTINE CRHACH(XMIN,XMAX,YMIN,YMAX,MARK) LANGUAGE: FORTRAN DESCRIPTION: HATCHES OR SHADES A RECTANGULAR AREA IN THE CURRENT LINE MODE. THE PERPENDICULAR DISTANCE BETWEEN LINES IS THE CYCLE LENGTH OF THE LINE TYPE BEING USED, IN THE CASE OF SOLID LINES IT IS THE DOTTED LINE CYCLE. N.B. HATCHING IS EXPENSIVE ON PLOTTING TIME AND THEREFORE SHOULD ONLY BE USED WHEN IT IS ESSENTIAL. PARAMETERS: XMIN,XMAX, REAL I/P LIMITS OF RECTANGLE TO BE YMIN,YMAX HATCHED MARK INTEGER I/P HATCHING TYPE REQUIRED:- 0- NONE 1- 45 DEG. DIAGONAL LINES 2- 1 AND 3 COMBINED 3- 135 DEG. DIAGONAL LINES 4- HORIZONTAL LINES 5- 4 AND 6 COMBINED 6- VERTICAL LINES REFERENCE: DOCAS REPORT ON PLOTTING PACKAGE ROUTINES CALLED: GINO-F ROUTINES LEVEL: LEVEL 0 AUTHOR: L.J.DOBSON/G.GIBBS DATE: DECEMBER 1981 CRHALT ROUTINE Category: K9 Title: CRHALT Language: FORTRAN calling MACRO routine Description: Halts program. Any open files are closed and then the program is halted without producing the usual STOP &c. on the terminal screen. Routines called: CRHLTF Level: 1,CRHLTF Level 0 Author: G.Gibbs Date: 17-June-1981 CRHIAX ROUTINE CATEGORY: C38 TITLE: SUBROUTINE CRHIAX(XLOW,XHIGH,IBP,IEP) LANGUAGE: FORTRAN DESCRIPTION: GRAPH DRAWING ROUTINE NO. 5 THIS SETS UP THE EXTRA PARAMETERS REQUIRED FOR A HISTOGRAM AND SO MUST BE CALLED BEFORE CALLING CRHIST. PARAMETERS: XLOW REAL I/P LOWER LIMIT OR VALUE OF FIRST BAR XHIGH REAL I/P UPPER LIMIT OR VALUE OF LAST BAR IBP, INTEGER I/P PERCENTAGE POINTS IN EACH INTERVAL IEP OF THE START AND FINISH POINTS OF EACH BAR. REFERENCE: DOCAS REPORT ON PLOTTING PACKAGE ROUTINES CALLED: CRGRER LIBRARY: SUBGROUP-PLT LEVEL: LEVEL 1 AUTHOR: L.J.DOBSON DATE: DECEMBER 1977 CRHIST ROUTINE CATEGORY: C39 TITLE: SUBROUTINE CRHIST(I,X,N,ISEL) LANGUAGE: FORTRAN DESCRIPTION: GRAPH DRAWING ROUTINE NO. 6 THIS DRAWS GRAPH AXES AND HISTOGRAMS OF VARIOUS TYPES. THE GRAPH AXES ARE DRAWN WHEN NO AXES HAVE PREVIOUSLY BEEN DRAWN OR THE PREVIOUS GRAPH HAS BEEN FINISHED, I.E. ANY CALL TO CRHIST CAN DRAW THE AXES. THE Y AXIS WILL BE 'BEAUTIFIED' UNLESS STATED OTHERWISE (SEE CRGRAF). A GRAPH IS FINISHED BY SETTING THE HISTOGRAM TYPE OR GRAPH TYPE (IN CRGRAF) NEGATIVE. N.B. A CALL TO CRHIAX MUST BE MADE BEFORE CRHIST. PARAMETERS: I INTEGER I/P HISTOGRAM TYPE. THE TYPES ARE:- 1=DRAW AXES ONLY (Y AXIS NOT BEAUTIFIED 2=DRAWS A HISTOGRAM GIVEN ACTUAL DATA WHICH NEEDS ASSIGNING TO INTERVALS, CALCULATING THE FREQUENCY COUNTS AND PLOTTING THEM 3=DRAWS A HISTOGRAM GIVEN THE ACTUAL FREQUENCY COUNTS FOR EACH INTERVAL OR CATEGORY IN THE REQUIRED ORDER. 11=DRAWS AXES ONLY (Y AXIS IS BEAUTIFIED) X REAL ARRAY I/P INPUT DATA ARRAY N INTEGER I/P NO. OF POINTS IN INPUT ARRAY ISEL INTEGER I/P THIS IS A TWO DIGIT SELECTOR. FOR HISTOGRAMS WHERE ONLY AXES ARE DRAWN (I=1,11) THE 1ST DIGIT IS REDUNDANT AND THE 2ND DIGIT INDICATES THE TYPE OF AXIS OFFSET REQUIRED (SEE CRGRAF). FOR OTHER HISTOGRAMS THE 1ST DIGIT INDICATES THE LINE TYPE USED FOR THE HATCHING (SEE CRGRAF) AND THE 2ND DIGIT INDICATES THE TYPE OF HATCHING REQUIRED (SEE CRHACH C30) REFERENCE: DOCAS REPORT ON PLOTTING PACKAGE ROUTINES CALLED: CRFREQ,CRMNX,CRSCAL,CRGRAF,CRBARS, +GINO-F AND GINOGRAF ROUTINES LEVEL: LEVEL 4 AUTHOR: L.J.DOBSON/G.GIBBS DATE: DECEMBER 1981 CRMTOC ROUTINE Category: J18 Title: CRMTOC ( IMONTH,MONTH) Language: FORTRAN Description: Convert integer month to characters. A month in integer form is converted to a 3 character abbreviation of the month's name, thus 1 becomes 'Jan'.A month of 0 is assumed unknown and is returned as '000'. An erroneous month, i.e. 0>MONTH>12 returns 'XXX'. Parameters: IMONTH INTEGER INPUT month as integer MONTH INTEGER OUTPUT month as characters See also: the character function MONTH Author: G.Gibbs Date: April 1981 CRLBOP ROUTINE Category: K16 Title: CALL CRLBOP(LIBRARY,MODULE,JFN,START,ERR) Purpose: Opens a LBR-format library file for reading Language: MACRO-20 Description: This routine can be called from FORTRAN to read files that are stored in LBR-format libraries directly. CRLBOP is used to "open" a specific module in the library, and CRLBRD to read records from the file. LIBRARY is the library file name, either a quoted string or an A5 array terminated by a null ; MODULE is the name of the specific module desired, in a similar format. JFN and START are values returned by this routine which must be passed to the CRLBRD routine to enable it to read the file. The user should not modify these words. ERR is returned zero on success, else is positive to indicate an error condition. Parameters: LIBRARY Input Array or quoted string Name of library (type .LBR assumed) MODULE Input Array or quoted string Name of module to retrieve JFN Output Integer Job file number for CRLBRD START Output Integer File address for CRLBRD ERR Output Integer Return status (see below) Errors: 0 Success 1 - Cannot find library 2 - Cannot open library 3 - File is not a library, or format incorrect 4 - Cannot locate module 5 - general JSYS error Level: 0 Author: Kevin Ashley Date: August 1982 CRLDAV ROUTINE CATEGORY: K13 NAME: CRLDAV(LOAD1,LOAD5,LOAD15) PURPOSE: Returns the 1-minute, 5-minute and 15-minute load averages (as displayed by the SYSTAT command) as three single-precision floating point numbers. This can be useful for a program that requires fast terminal response to be useful, ie with an interactive display. PARAMETERS: LOAD1 Real output 1-minute load average LOAD5 Real output 5-minute load average LOAD15 Real output 15-minute load average. Author: K. Ashley 19-Jan-82 Language: Macro-20 Level: 0 CRLHST ROUTINE Category: D12 Title: CRLHST (IFREQ,MM,DATA,N,LENG,NCHAN,IND) Language: FORTRAN Description: plots histogram on the line printer across the page This routine will accept the data in DATA(N) if IND = 1, if the frequencies are available they should be supplied in IFREQ(MM) with IND = 0,otherwise they will be calculated and returned.The length of the plot is controlled by LENG (in lines maximum)if .LE.10 a value of 50 is used. Failure is indicated by IND set to 2 Reference: Algorithm AS 45 Applied Statistics (J.R.Statist.Soc. C) (1971) vol.20,No.3 Parameters: IFREQ integer input vector of frequencies from which array output lists printed MM integer input number of classes into which the data are to be grouped, when given in DATA ,and size of array IFREQ. DATA real input the original data from which the array frequencies are to be obtained. If these are supplied in IFREQ then DATA is not used. N integer input size of array DATA LENG integer input maximum number of lines of print which output will occupy.A minimum of 11 is required & if less will be set to 50. NCHAN integer input channel number to receive output IND integer input type of data input and output failure indicator =0 frequencies supplied =1 data only supplied =2 returned if all values equal Routines called: CRSCL2 Level: 1,CRSCL2 Level 0 Author: D.N.Sparks Date: 1971 CRLNFC ROUTINE CATEGORY: G10 TITLE: FUNCTION CRLNFC(J,IFAULT) LANGUAGE: FORTRAN DESCRIPTION: NATURAL LOGARITHM OF FACTORIAL FOR NON-NEGATIVE ARGUMENT. THE LOG-FACTORIAL IS MUCH EASIER TO HANDLE THAN THE FACTORIAL ITSELF, SINCE 58! IS TOO BIG FOR THE MACHINE TO HOLD, WHEREAS LOG(8388607!) IS WELL WITHIN ITS RANGE. AN EXPRESSION SUCH AS (M+N)!/M!N! MAYBE CALCULATED AS: EXP(CRLNFC(M+N,IFA)-CRLNFC(M,JFA) -CRLNFC(N,KFA)) IF(IFA+JFA+KFA.NE.0) GO TO .... WITHOUT RISK OF OVERFLOW. METHOD: TABLE LOOK-UP FOR SMALL ARGUMENT. STIRLING'S FORMULA FOR LARGE ARGUMENT. PARAMETERS: J INTEGER INPUT ARGUMENT IFAULT INTEGER OUTPUT 0 FOR VALID ARGUMENT 1 FOR NEG.ARGUMENT. COMMON BLOCKS: NONE OWN VARIABLES: NONE COMPRESSED INTEGERS: YES FORTRAN TRACEABLE: YES ROUTINES CALLED: NONE LIBRARY: SUBGROUP-CRC AUTHOR: I.D.HILL DATE: JULY 77 CRLOGGAM ROUTINE CATEGORY: G11 TITLE: FUNCTION CRLOGGAM(X,IFAULT) LANGUAGE: FORTRAN DESCRIPTION: NATURAL LOGARITHM OF GAMMA FUNCTION FOR POSITIVE ARGUMENT. THE ADVANTAGE OF USING THE LOGARITHM, RATHER THAN THE GAMMA FUNCTION ITSELF, IS AS GIVEN FOR G10. METHOD: STIRLING'S FORMULA FOR LARGE ARGUMENT. RECURRENCE RELATION (GAMMA(X+1)=XGAMMA(X)), FOLLOWED BY STIRLING'S FORMULA FOR SMALL ARGUMENT. PARAMETERS: X REAL INPUT ARGUMENT IFAULT INTEGER OUTPUT 0 FOR VALID ARGUMENT 1 FOR NEGATIVE OR ZERO ARGUMENT. 2 FOR ARGUMENT GREATER THAN 3.2E74 COMMON BLOCKS: NONE OWN VARIABLES: NONE COMPRESSED INTEGERS: YES FORTRAN TRACEABLE: YES ROUTINES CALLED: NONE LIBRARY: SUBGROUP-CRC AUTHOR: I.D.HILL DATE: JULY 77 CRMAIL ROUTINE CATEGORY: K14 TITLE: CRMAIL(FILNAM,USRLST,ERROR,ERQUAL) LANGUAGE: MACRO-20 DESCRIPTION: This routine allows a FORTRAN or MACRO programmer to transmit a text file to another user or list of users as mail. Any errors which occur are reported. Arguments defined as array or string must be in ASCIZ, ie a string of characters terminated by a null byte. If you use a quoted string, this occurs. If you build up a string in an array, you must be sure to place a zero word or byte at the end of the string. PARAMETERS: FILNAM Integer array or string : The name of the file containing the mail. This will be transmitted as is, The system mail program will add the header lines which say "From:"... and "To:"... and also the date and time. USRLST: Integer array or string : An ASCIZ string specifying a list of user names to receive the mail, separated by commas. ERROR: Integer output : Must be 0 on entry. Contains 0 on exit for success, or an error number (see below). ERQUAL: Integer output : Must be 0 on entry. If ERROR is 0 on exit, the contents of this variable are undefined. Else, ERQUAL contains a JSYS error code, or some other number which identifies the error more exactly. ERRORS: Defined error numbers: 0/ Call completed succesfully -1/ Could not find named file. -2/ Could not open named file -3/ Name in username list invalid (ERQUAL contains position of first invalid name. NO mail has been sent.) -4/ MAILER returned errors (ERQUAL contains further info.) -5/ Some IPCF error occurred. (MAILER has crashed, or you have exceeded your PID or message quota - unlikely.) -6/ Failed opening temporary file -7/ Failed writing temporary file AUTHOR: K. Ashley DATE: 26-Apr-82 CRMATH2 ROUTINE category: G3 title: crmth2(i,j,iq,ir,iover) language: macro description: quotient and remainder. iq, ir are the quotient and remainder on dividing i by j. ir = i - iq*j, and ir has the same sign as i. iover is normally set to 0, but if overflow occurs (e.g. if j = 0), iover is set to 1 and iq, ir are undefined. parameters i integer input dividend j integer input divisor iq integer output quotient ir integer output remainder iover integer output overflow indicator routines called: none level: level 0 author: G.Gibbs date: May 1981 CRMNIM ROUTINE CATEGORY: G15 *NEW* TITLE: SUBROUTINE CRMNIM(F,STEP,NOP,FUNC,MAX,IPRINT,NCHAN, STOPCR,NLOOP,IQUAD,SIMP,VAR,FUNCTN,IFAULT) LANGUAGE: FORTRAN DESCRIPTION: FUNCTION MINIMISATION. WORKS ON THE SAME METHOD AS G5 (NELDER), BUT WITH THE ADDITIONAL OPTION OF ESTIMATING THE VARIANCE-COVARIANCE MATRIX OF THE ESTIMATES BY FITTING A QUADRATIC SURFACE TO THE MINIMUM. PARAMETERS: F REAL ARRAY (NOP) INPUT: INITIAL VALUES OF THE VARIABLES OUTPUT: VALUES AT THE MINIMUM STEP REAL ARRAY (NOP) INPUT: INITIAL STEP SIZES NOP INTEGER INPUT: NUMBER OF VARIABLES, INCLUDING THOSE TO BE HELD FIXED. 1 < NOP < 21 FUNC REAL OUTPUT: FUNCTION VALUE AT MINIMUM MAX INTEGER INPUT: MAXIMUM ALLOWABLE NUMBER OF FUNCTION EVALUATIONS IPRINT INTEGER INPUT: <0 FOR NO PRINTED OUTPUT WANTED =0 FOR PRINTED OUTPUT (ON UNIT NCHAN) OF FINAL VALUES >0 AS FOR IPRINT=0, BUT WITH ADDITIONAL PROGRESS REPORTS DURING MINIMISATION EVERY IPRINT FUNCTION EVALUATIONS **NEW** NCHAN INTEGER INPUT: OUTPUT CHANNEL NUMBER STOPCR REAL INPUT: A SMALL NUMBER USED AS CONVERGENCE CRITERION NLOOP INTEGER INPUT: CONVERGENCE IS TESTED FOR AFTER EVERY NLOOP ITERATIONS IQUAD INTEGER INPUT: =0 FINDS MINIMUM AND RETURNS #0 ALSO FITS QUADRATIC SURFACE TO FIND VAR-COV MATRIX SIMP REAL INPUT: A SMALL NUMBER USED IN FITTING QUADRATIC SURFACE VAR REAL ARRAY (NOP) OUTPUT: DIAGONAL ELEMENTS OF INVERSE OF INFORMATION MATRIX FUNCTN REAL FUNCTION NAME OF THE FUNCTION TO BE MINIMISED. THE NAME MUST ALSO BE DECLARED AS EXTERNAL IN THE CALLING PROGRAM. THE FUNCTION MUST HAVE ONE ARGUMENT (A REAL ARRAY OF DIMENSION NOP) IFAULT INTEGER OUTPUT: 0 - NO FAULT 1 - NUMBER OF FUNCTION EVALUATIONS EXCEEDS MAX 2 - INFORMATION MATRIX NOT POSITIVE SEMI-DEFINITE 3 - NOP<2 OR NOP>20 4 - NLOOP<1 ROUTINES CALLED: CRC301 (WHICH CALLS CRC120) AUTHOR: MODIFIED BY I.D.HILL FROM A SUBROUTINE BY D.E.SHAW AND R.W.M.WEDDERBURN IN PROGRAM LIBRARY OF ROTHAMSTED EXPERIMENTAL STATION DATE: 3 MAY 1979 CRMNX-2 ROUTINE CATEGORY: G13 TITLE: CRMNX(X,N,XMIN,XMAX) CRMNX2(X,N,XMIN,XMAX,IMIN,IMAX,A) LANGUAGE: FORTRAN DESCRIPTION: FIND THE MINIMUM AND MAXIMUM OF N ELEMENTS IN ARRAY X. IN CRMNX2 THE LOCATIONS OF THESE ARE STORED IN IMIN AND IMAX RESPECTIVELY, AND EXTREME VALUES (EG MISSING VALUE CODES) CAN BE EXCLUDED FROM CONSIDERATION BY MEANS OF VALUE OF A. PARAMETERS: X REAL ARRAY INPUT DATA ARRAY N INTEGER INPUT LENGTH OF ARRAY XMIN REAL OUTPUT MINIMUM VALUE XMAX REAL OUTPUT MAXIMUM VALUE IMIN INTEGER OUTPUT POSITION OF MINIMUM VALUE WITHIN X IMAX INTEGER OUTPUT POSITION OF MAXIMUM VALUE WITHIN X A REAL INPUT A=1.0 ALL VALUES EXAMINED A<1.0 VALUES .LE. A NOT CONSIDERED A>1.0 VALUES .GE. A NOT CONSIDERED ROUTINES CALLED: AMIN1,AMAX1 LEVEL: LEVEL 0 AUTHORS: L.J.DOBSON,D.G.ALTMAN DATE: DECEMBER 1977,APRIL 1978 CRMOVE ROUTINE CATEGORY A4 TITLE: CRMOVE (IA,IB,N) LANGUAGE: MACRO DESCRIPTION: HIGH-SPEED MOVE. IA,IB ARE ARRAYS N WORDS STARTING AT IA ARE MOVED TO THE AREA STARTING AT IB. THE BLock Transfer INSTRUCTION IS USED. PARAMETERS: IA ANY INPUT START OF SOURCE AREA. IB ANY INPUT START OF DESTINATION AREA N INTEGER INPUT NO. OF WORDS TO BE MOVED. ROUTINES CALLED NONE LEVEL: LEVEL 0 AUTHOR G.GIBBS DATE MARCH 1981. CRUSER ROUTINE Category: K8 Title: CRUSER(USER) Language: MACRO Description: Places in the array or character variable USER the current user's name. If it is an array USER MUST be long enough to receive this, n.b. 8 elements will hold the longest allowable name of 39 characters. Parameters: USER Array or output User's name character Routines called: None Level: 0 Author: G.Gibbs Date: 16 June 1981, character variables July 1984 CRMVCH ROUTINE CATEGORY: A1 TITLE: SUBROUTINE CRMVCH(IA,I,JA,J,N) LANGUAGE: MACRO DESCRIPTION: MOVE CHARACTERS N CHARACTERS ARE MOVED FROM THE I'TH POSITION OF IA (COUNTING FROM 1) AND ONWARDS TO THE J'TH POSITION OF JA AND ONWARDS. IF N , I OR J ARE NOT +VE, THERE IS NO EFFECT. THIS IS EQUIVALENT TO THE ICL ROUTINE COPY (A2) WHICH NOW CALLS THIS ROUTINE. NOTE THE DIFFERENT SEQUENCE OF THE PARAMETERS. PARAMETERS: IA ANY INPUT AREA TO COPY FROM I INTEGER INPUT CHARACTER NO. IN 'IA' JA ANY INPUT AREA TO COPY TO J INTEGER INPUT CHARACTER NO. IN 'JA' N INTEGER INPUT NO OF CHARACTERS TO BE MOVED COMMON BLOCKS: NONE OWN VARIABLES: NO ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: MARCH 1981 CRNIN ROUTINE Category: M2 Title: CRNIN(I,MESAGE,IFT) Language: MACRO Description: Outputs MESAGE to your terminal as a prompt and accepts an integer from the keyboard,terminated with a new line or 80 characters, full ^R,^W,^U facilities are available. IFT is 0 if successful and 1 if erroneous. Parameters: I Integer Output The number entered(if successful) MESAGE Array Input The prompt to be sent to terminal This should be as a quoted string eg:- 'PLEASE ENTER NUMBER >>' If it is neccessary to have a variable prompt it must terminate with a <null>.This may be inserted using PK , thus if the message has 24 characters you would reqiure CALL PK(MESAGE,0,25) IFT integer Output 0 =success 1 = fail Author: G.Gibbs Date: 5th June 81 CRNTOI ROUTINE Category: J19 Title: CRNTOI (IDATE,IDAY,MONTH,IYEAR) Language: FORTRAN Description: Convert character date to 3 integers. A date in character form, with the month expressed as a number (e.g. '22.11.80') is converted to 3 integer numbers (i.e. 22 11 1980 ) Any non-digit may separate day and month, but a * separateing month and year indicates a date between 1800 and 1899; any other non-digit separator is taken to mean a 20th centuary date. This routine checks the validity of the date, and returns values of 3 zeroes for a non valid date. Parameters: IDATE INTEGER ARRAY INPUT Date in character form IDAY INTEGER } {The 3 parts MONTH INTEGER } OUTPUT {of the date IYEAR INTEGER } { Author: G.Gibbs Date: April 1981 CRON-CROFF-CRTEST ROUTINE CATEGORY: A24 TITLE: SUBROUTINE CRON(I,J) SUBROUTINE CROFF(I,J) LOGICAL FUNCTION CRTEST(I,J) LANGUAGE: MACRO DESCRIPTION: BIT SWITCHING ROUTINES CRON SETS BIT J OF WORD I CROFF UNSETS BIT J OF WORD I CRTEST RETURNS THE STATE OF BIT J IN WORD I. THE RESULT IS TRUE IF SET AND FALSE IF UNSET BIT POSITIONS ARE NUMBERED FROM 0 TO 35, STARTING WITH THE MOST SIGNIFICANT PARAMETERS: I INTEGER VARIABLE INPUT/OUTPUT WORD CONTAINING BIT OR ARRAY ELEMENT J INTEGER INPUT POSITION OF BIT ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: APRIL 1981 CROOM ROUTINE category: K16 title: subroutine CROOM(DIRLFT,SYSLFT) language: MACRO-20 description: Returns the space left in your connected directory and connected structure. The space left in your directory is calculated by subtracting the number of pages used from your working quota, and is returned in DIRLFT. SYSLFT receives the total number of pages free on the disk. Note that if SYSLFT is below 200 pages, then the system prevents everyone from writing to the disk, so that even if DIRLFT is large, you will not be able to create any files. This routine is useful for a program that is about to create a large file (for plotting, say) and wishes to ensure that space is available before doing so. method: The GTDAL and GDSKC JSYSs are used. parameters: DIRLFT Integer output Pages free in connected directory SYSLFT Integer output Pages free on whole structure. common blocks: none own variables: no routines called: none level: level 0 author: Kevin Ashley date: August 1982 CROPEN ROUTINE category: N10 title: subroutine cropen(prompt,unit,status,fail, help,defnam,defext,defdir,defdev,option) language: macro description: the routine prompts at the terminal for a file name and then opens the file. The routine allows the user to make full use of the tops-20 facilities for recognition of file names using the escape key, and providing default names, &c. Only the first 4 arguments have to be supplied. Other arguments may be omited by either giving a value of zero or by simply omitting adjacent, unwanted, trailing arguments,viz:- CALL CROPEN ('File name >>',30,'old',fail) CALL CROPEN ('File 2 =',31,'unknown',fail, + 0,'fred','dat',0,0,'/dispose:delete') The arguments consisting of text should be given in quotes as shown above, or may be passed in an array but must terminate with a null. The routine will prompt repeatedly until an acceptable name, as defined by the status argument, is input. If it is wished to change this then the second word of the common block/cmdprm/ is set to the number of retries to be allowed (-1 is infinite). If you wish to access the file name then it is stored in the common block /cmdstg/ starting at word 171, together with any options given in the final argument. This array may be given to a later open statement using dialog=. See defbfr(56) under common blocks below. parameters: prompt any input the prompt to be output by the routine unit integer input the fortran logical unit number for the file to be opened on status any input a keyword as supplied to the status field in an open statement,'old''new'&c fail integer output a failure indicator, 0= success a failure in opening the file returns the iostat error code, or enters dialog help any input *optional* help message displayed in reply to a ? . defnam any input *optional* default file name (not including the extension) defext any input *optional* default filename extension (not including the .). defdir any input *optional* default directory (including the < >) defdev any input *optional* default device option any input *optional* any further options you wish to give to an open statement in the format required for 'dialog=' common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),CMDBLK(10) (all variables integer) routines called: none level: level 0 author: G.Gibbs date: August 1982 CRPOLY ROUTINE CATEGORY: E28 TITLE: CRPOLY(X,Y,M,N,C,S,IER) LANGUAGE: FORTRAN DESCRIPTION: FITS THE POLYNOMIAL REGRESSION, (OF ORDER 1, 2 OR 3) OF Y(I) ON X(I) METHOD: THE REQUIRED REGRESSION COEFFICIENTS ARE FOUND BY DIRECT SOLUTION OF THE RELEVANT SIMULTANEOUS EQUATIONS. IN INDETERMINATE CASES (E.G. A. CUBIC REQUESTED WHERE THE DATA LIE ON A STRAIGHT LINE) THE HIGH ORDER COEFFICIENTS ARE SET TO ZERO. PARAMETERS: X REAL ARRAY(M) INPUT THE 'INDEPENDENT' VARIABLE Y REAL ARRAY(M) INPUT THE 'DEPENDENT' VARIABLE M INTEGER INPUT NUMBER OF DATA POINTS N INTEGER INPUT DEGREE OF POLYNOMIAL (MUST BE 1,2 OR 3 AND LESS THAN M) C REAL ARRAY(4) OUTPUT (1) CONSTANT TERM (2) COEFFICIENT OF X (3) COEFFICIENT OF X**2 (OR 0 IF N=1) (4) COEFFICIENT OF X**3 (OR 0 IF N=1 OR 2) S REAL ARRAY(4) OUTPUT (1) SUM OF SQUARES DUE TO LINEAR FIT (2) ADDITIONAL SUM OF SQUARES DUE TO QUADRATIC FIT (OR 0 IF N=1) (3) ADDITIONAL SUM OF SQUARES DUE TO CUBIC FIT (OR 0 IF N=1 OR 2) (4) RESIDUAL SUM OF SQUARES IER INTEGER OUTPUT 0 FOR SUCCESS 1 FOR ILLEGAL VALUE OF N 2 FOR ZERO VARIANCE IN X ARRAY 3 FOR INDETERMINATE CASE - LINEAR FIT WHERE QUADRATIC OR CUBIC WAS REQUESTED. 4 FOR INDETERMINATE CASE - QUADRATIC FIT WHERE CUBIC WAS REQUESTED. AUTHOR: I.D.HILL DATE: 21 OCTOBER 1977 ICHIN ROUTINE Category: M5 Title: INTEGER FUNCTION ICHIN(IERR) CHARACTER FUNCTION ICHIN(IERR) Language: MACRO Description: Obtains the next character from your terminal without waiting for a <return> to be typed. It should however be noted that a <return> will give a <line feed> as well, and that some control characters will still have their usual effect viz:- ^C,^O,^S,^Q, and ^T. The character is returned as the ascii value by the function, if declared as integer, or as a character if so declared It is necessary to call VTINIT before using ICHIN and you may wish to call CRSIL to turn off echoeing of the characters as they are entered e.g. CHARACTER*1 ICHIN CALL VTINIT CALL CRSIL(1) IF (ICHIN(IERR).EQ.'A') CALL ALPHA CALL VTEND Parameters: ICHIN integer OUTPUT The ascii value of the next character. character O/P The next character. IERR INTEGER OUTPUT An error indicator, 0=success Level: level 0 Author: G.Gibbs Date: 5 April 1982, character variables July 1984 CRRUN ROUTINE category: K22 title: subroutine CRRUN(PRGNAM,COMAND,ERROR) language: macro-20 description: Runs the program (expected to be in an EXE file) specified by the first argument. Passes the command line specified by the second argument via the 'rescan buffer'. This simulates running a program called FRED, say, by typing @FRED input,output FRED could use CRRSCN to read this command if you typed it in. Calling CRRUN('FRED.EXE','FRED input,output',ERROR) has the same effect. Error is 0 on success, 1 if the program cannot be found, or 2 if it cannot be run. Alternatively, if you wanted to invoke an editor from your program, you could use CALL CRRUN('SYS:TV.EXE','EDIT myfile.txt',ERROR) or CALL CRRUN('SYS:SED.EXE','EDIT myfile.txt',ERROR) if you prefer to use SED as your editor. The routine returns when the program exits. method: RSCAN% and GET% are used. parameters: PRGNAM Array or text literal input Name of program file COMAND Array or text literal input Command line ERROR Integer output Completion code common blocks: none own variables: no routines called: none level: level 0 author: Kevin Ashley date: April 1982 CRSHPE ROUTINE CATEGORY: E30 TITLE: CRSHPE(X,N,SKEW,AKURT,GEARY) LANGUAGE: FORTRAN DESCRIPTION: CALCULATES USUAL COEFFICIENTS OF SKEWNESS & KURTOSIS; ALSO MEAN DEVIATION/STD. DEVIATION, ANOTHER MEASURE OF KURTOSIS KNOWN AS GEARY'S A STATISTIC. UPPER AND LOWER PERCENTAGE POINTS OF GEARY'S A HAVE BEEN TAB- ULATED FOR NORMAL SAMPLES OF SIZE 11-2000. METHOD: USES STAT7B. A DIVISOR OF N (NOT N-1) IS USED IN THE CALCULATION OF STANDARD DEVIATION. REFERENCE: FOR SIGNIFICANCE LEVELS AS TESTS OF DEPARTURE FROM NORMALITY, SEE BIOMETRIKA TABLES, VOL.1,P.207-8. PARAMETERS: X REAL ARRAY(N) INPUT SAMPLE VALUES N INTEGER INPUT SAMPLE SIZE SKEW REAL OUTPUT COEFF. OF SKEWNESS AKURT REAL OUTPUT COEFF OF KURTOSIS GEARY REAL OUTPUT GEARY'S A STATISTIC LEVEL: LEVEL 1 ROUTINES CALLED: STAT7B AUTHOR: J.P.ROYSTON DATE: 3 MAY 1978 CRSINT ROUTINE category: A31 title: subroutine crsint(array,chars) language: Fortran 77 description: Move characters from an array to a character variable. The number of characters moved is defined by the length of the character variable, as declared in the calling routine. If, however, a null is encountered in the array, then the rest of the character variable is padded out with blanks. parameters: array any input area to copy from chars character o/p area to copy to common blocks: none routines called: crmvch author: G.Gibbs date: August 1983 CRSIZE ROUTINE category: K19 title: subroutine crsize('file.name',pages,bytes,bytsiz,err) language: macro-20 description: Returns a file's size in pages and bytes, and returns the size of the bytes. These are the three numbers seen in a VDIRECTORY command. The byte size is the number in brackets, as in FILE.NAME 4 11023(7) means the file has 4 pages, 11023 bytes (characters) and the bytes are each 7 bits (ie they are ASCII text). Can only be used for disk files. method: SIZEF% and GTFDB% parameters: FILNAM Array or text literal input Name of file PAGES Integer Output Pages in file BYTES Integer Output Bytes in file BYTSIZ Integer Output Bits per byte ERR Integer Output Error code 0=Success 1=File not found 2=File exists, but cannot find size (eg file was TTY:) common blocks: none own variables: no routines called: none level: level 0 author: Kevin Ashley date: August 1982 CRSOUT ROUTINE category A30 title: crsout (array) language: macro description: Send a string of characters, terminated by a null, to the terminal. The string may be in qoutes, e.g.:- CALL CRSOUT('?ERROR ABANDON RUN') or you may set up an array containing the characters, which may include escape sequences and control characters, provided that it is terminated with a null. You will have to call VTINIT if you want the control characters to be passed to the screen intact. parameters: array any input the string of characters routines called none level: level 0 author G.Gibbs date February 1983. CRTIMR ROUTINE category: K26 title: SUBROUTINE CRTIMR(INTVAL,ROUTIN,FAIL) language: macro-20 description: Calls a specified routine when a time limit expires This subroutine is used to generate "interrupts" from Fortran. The caller specifies a number of milliseconds, and either a subroutine name, or a statement label in the second argument. CRTIMR returns immediately, letting your program continue, but when the specified number of milliseconds has elapsed, your program is suspended, and the subroutine you named in the call is called. When it returns, your program is allowed to continue. This can be useful for timeing out a request to read from the terminal, for instance. Maybe you have a program that prompts at the terminal to read something. It is possible that sometimes, you may have left the program running, and not noticed when it prompts again. Using CRTIMR, you can ring the terminal bell if you do not answer the question within, say, 10 seconds. See the example below. To eliminate a request for an interrupt due to a previous call to CRTIMR, call CRTIMR with an elapsed time of 0. You can only have one outstanding timer request. Unless it is disarmed by calling CRTIMR with a time of 0, the timer continues to trigger at every time interval specified. Thus, in the example below, the bell continues to ring every 10 seconds until the user answers the question. NOTE: if you supply a subroutine name as the second parameter, you must declare the subroutine EXTERNAL in the calling program. You specify a statement label by prefixing it with a *, as in *100 Restrictions: The called subroutine must NOT perform any Fortran I/O. If you need to perform I/O, call one of the CRC subroutines written in Macro-20, or use DOJSYS to do it. If you supply a statement label to be called when the timer triggers, the statement cannot be in the main program. The time interval cannot be more than one day in the future (ie 1000*60*60*24 milliseconds.) Example: To ring the bell every 5 seconds until the user answers a question. EXTERNAL WAKEUP !Subroutine to call to wake up user . . . CALL CRTIMR(10000,WAKEUP,FAIL) !Arm the timer to go off in 10 seconds CALL CHECK(FAIL) !Make sure it worked CALL NUMIN('Enter your new x value:',NX,FAIL) CALL CHECK(FAIL) !Make sure that worked CALL CRTIMR(0,0,FAIL) !Disarm the timer - they answered us . . . SUBROUTINE WAKEUP CALL CRBELL(3) !Ring the bell 3 times every 10 seconds RETURN !Leave interrupt, hope they answer soon END method: The TIMER% Jsys is used. All accumulators are saved over the interrupt call, and restored before leaving interrupt context. Parameters: INTVAL Integer Input Number of milliseconds to wait before calling interrupt routine. ROUTIN Routine/ Input Name of EXTERNAL routine to call Label when time interval expires. FAIL Integer Output Error code, 0=success -1: You already have an outstanding call to CRTIMR. Only one is permitted. -2: FOROTS could not allocate an interrupt channel. -3: System error: No timer blocks. This should not occur. common blocks: none level: level 0 author: Kevin Ashley date: January 1983 CRTWMY ROUTINE category: G19 title: subroutine crtwmy(n,a,g,gamma,w,lw,f,rms,ifail) language: Fortran description: Twomey's method for the regularized solution of a Fredholm integral equation of the first kind (J.Ass.Comp.Mach. 97-101, 10, 1963). The integral equation is expressed as a quadrature and the smoothest new solution f(n), is obtained in comparison with any existing solution f(n), in the sense of minimizing its second differences. parameters: n integer input no of quadrature coefficients a(n) real array input system vector g(n) real array input response vector gamma real input regularization parameter w real array --- workspace lw integer input length of w, at least n(3n+2) f real array in/out solution vector rms real output residual mean square ifail integer output failure flag:- 0=success 1=not enough workspace 2=bad parameters (n<5, gamma<0) 3=internal error (f01clf) 4=internal error (f01caf) 5,6=ill-conditioning (f01abf) 7-10=internal error (f01ckf) 11-14=internal error (f01ckf) 15-18=internal error (f01ckf) level: 2 routines called: rwtwm1 (calling crmove) rwtwm2 (calling f01abf [calling f01acf], f01caf, f01ckf, f01clf and f01def) author: R.Wootton date: 25-apr-83 CRVCR ROUTINE CATEGORY: G17 TITLE: SUBROUTINE CRVCR(FSUMSQ,M,N,S,V,LW,W,IFAIL) LANGUAGE: FORTRAN DESCRIPTION: COMPUTES THE VARIAANCE-COVARIANCE AND CORRELATION MATRICES FOR THE PARAMETERS ESTIMATED BY THE 'COMPREHENSIVE' LEAST- SQUARES NAG ROUTINES E04FCF, E04HEF, E04GDF OR E04GBF. PARAMETERS: FSUMSQ REAL INPUT VALUE OF OBJECTIVE FUNCTION AT FINAL POINT. M INTEGER INPUT NUMBER OF RESIDUALS. N INTEGER INPUT NUMBER OF PARAMETERS. S REAL ARRAY(N) INPUT DIAGONAL MATRIX CONTAINING THE SINGULAR VALUES OF THE ESTIMATED JACOBIAN MATRIX FOLLOWING ITS SINGULAR VALUE DECOMPOSITION. V REAL ARRAY(N,N) INPUT ORTHOGONAL MATRIX CONTAINING THE RIGHT-HAND SINGULAR VECTORS OF THE ESTIMATED JACOBIAN AFTER ITS S.V.D. (NOTE THAT PARAMETERS 1-5 ARE OUTPUT BY THE ABOVE NAG ROUTINES) LW INTEGER INPUT LENGTH OF ARRAY W AS DECLARED IN THE CALLING SEGMENT. MUST BE AT LEAST N(2N+1). W REAL ARRAY(LW) OUTPUT WORKSPACE/RESULTS. ON SUCCESSFUL EXIT, THE FIRST N*N ELEMENTS OF W CONTAIN THE V-C MATRIX AND THE NEXT N*N THE CORRELATION MATRIX. IFAIL INTEGER OUTPUT FAILURE FLAG: 0=SUCCESSFUL EXIT; 1=FAIL ON FIRST MATRIX MULTIPLICATION; 2=FAIL ON SECOND; 3=NOT ENOUGH WORKSPACE SUPPLIED. LEVEL: 1 ROUTINES CALLED:RWVCR (AT LEVEL 0) (CALLING F01CKF AND P01AAF) AUTHOR: R.WOOTTON DATE: 25-JAN-82 CRWAIT ROUTINE CATEGORY: K15 TITLE: CRWAIT(MILLIS) LANGUAGE: MACRO-20 DESCRIPTION: This routine suspends program execution for the specified number of milliseconds. The accuracy of the routine is limited to the nearest 20 milliseconds - the maximum period that may be specified is 2^27 milliseconds (18 hours, 38 minutes, 28 seconds and 864 milliseconds ). No errors are possible. PARAMETERS: MILLIS Input integer variable or constant: Time to wait in milliseconds. ERRORS: None. AUTHOR: K. Ashley DATE: 15-Jul-82 CRWTST ROUTINE CATEGORY: E34 TITLE: CRWTST(X,N,AVE,SD,W,PW,IOUT) LANGUAGE: FORTRAN DESCRIPTION: CALCULATES SHAPIRO AND WILK'S W STATISTIC, A TEST OF NORMALITY OF THE N SAMPLE VALUES X. THIS STATISTIC INDICATES HOW CLOSELY A NORMAL PLOT OF X APPROXIMATES TO A STRAIGHT LINE. IT IS MEANT TO BE USED AS AN ADJUNCT TO A NORMAL PLOT, AND HAS ONLY BEEN WORKED OUT FOR SAMPLES OF SIZE BETWEEN 3 AND 50. THE APPROIMATE SIG- NIFICANCE LEVEL PW OF W IS CALCULATED BY INTERPOLATION IN THE RANGE .01.LE.PW.LE.0.99,VALUES BEING EXACT AT .01,.02,.05,.10,.50,.90,.95,.98 AND .99. SMALL VALUES OF W AND PW INDICATE DEVIATION FROM NORMAL DISTRIBUTION. IF N IS LESS THAN 3 OR GREATER THAN 50, W AND PW ARE SET TO ZERO, BUT AVE AND SD ARE STILL CALCULATED. REFERENCE: 'AN ANALYSIS OF VARIANCE TEST FOR NORMALITY (COMPLETE SAMPLES)' BY S.S.SHAPIRO AND M.B.WILK, BIOMETRIKA,1965, 52,PAGE 591. PARAMETERS: X REAL ARRAY(N) INPUT SAMPLE DATA N INTEGER INPUT SAMPLE SIZE AVE REAL OUTPUT MEAN OF DATA SD REAL OUTPUT STANDARD DEVIATION W REAL OUTPUT W STATISTIC PW REAL OUTPUT SIG. LEVEL OF W IOUT INTEGER OUTPUT 1 = PW<.01 2 = .01<PW<.99 3 = PW>.99 4 = N<3 OR N>50 LEVEL: LEVEL 1 ROUTINES CALLED: STAT7,CRC154,SQRT,MOD,ALOG10 AUTHOR: J.P.ROYSTON DATE: 22 AUGUST 1978 CRXPNG ROUTINE category: K21 title: subroutine crxpng('directory-name',error) language: macro-20 description: Expunges (ie removes all deleted files from) the directory specified in the first argument. All space used by deleted files is released. This can be useful in a program that produces many temporary output files (ie plot files). The directory name may either be in the form PS:<A-USER>, or may be a logical name (such as HERE:). If in the first form, the structure ID (PS: or US: or MELON:) must always be present, as must the angle or square brackets. Wildcards (* or %) may not be used. If in the second form, you may supply the logical name either with or without its terminating colon. Examples: CALL CRXPNG('PS:<C-CHAPLIN>',IER) CALL CRXPNG('HERE:',IER) CALL CRXPNG('DP',IER) !DP is assumed to be a logical name To use this routine effectively, you must either be connected to the directory, or have expunge access (which means that you can connect without giving a password.) method: DELDF%, LNMST% and RCDIR% are used parameters: DIRNAM Array or text literal input Name of directory ERR Integer Output Completion code: 0: Success 1: Cannot find directory 2: Directory cannot be expunged. common blocks: none own variables: no routines called: none level: level 0 author: Kevin Ashley date: October 1982/August 1983 CURHOM ROUTINE CATEGORY: L2 NAME: CURHOM PURPOSE: Moves the cursor to the top left of the screen ("home") PARAMETERS: None AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 CURUP ROUTINE CATEGORY: L1 NAME: CURUP(N) PURPOSE: Moves the cursor up the number of times specified. PARAMETERS: N Integer Input Number of places to move cursor (+ve) AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 DATA-ENTRY ROUTINES Category: N0 A number of data entry routines are available to make it easier for a user to write a questionaire-type input program. The suite of routines provide a consistent interface both the programmer and user, allowing for such facilities as retyping of prompts after errors, range checking, defaults, and recognition of the special terms EXIT and UNKNOWN for any question, and ^ to indicate the desire to go back and re-enter a previous question. The method by which these are handled takes much of the tedium of such matters away from the programmer. To see the range of routines available, type INFO INDEX DATA-ENTRY to the SUBS program, which will give a list of routines ; writeups on each one may be obtained by typing INFO followed by the name of the routine. Each of the routines usually has a set of compulsory parameters which must be supplied, and a set of optional parameters. Optional parameters which come after any arguments you supply may simply be omitted from the call. Optional parameters which come between parameters you wish to supply should be replaced by 0. One of these optional parameters to every routine is BACK, which is a statement label to go to if the user types "^", indicating that they wish to re-enter their answer to the previous question. You supply this parameter as noted in the FORTRAN reference manual, by placing a * in front of the statement label in the parameter list, as in CALL YESNO(' More ?',YEA,FAIL,*10) to jump to label 10, or by using ASSIGN to a variable, and then using the variable in the call. Constructs such as this make it much easier for you to write a data-entry program which is fairly flexible from the users' point of view, but avoids too much repetetive coding on your part. The jump to the statement label (usually a label for the call to the routine that asked the last question) is done automatically. It avoids lots of IF-type statements occurring after each question/ answer sequence in the program, and avoids the usual problem of trapping out-of-range errors, or checking that a word typed in belongs to one of a short list of commands. Each of these routines has a specific sort of answer it will accept, and some also have ranges in which they must fall. An answer that does not satisfy the criteria is in error, and one of two things may be done - either an error message can be typed, and the user reprompted for the answer, or an error code can be returned to the calling program to do with as it wishes. Under normal circumstances, an error message is output until valid input is received. Thus, your program can be sure that what is input satisfies certain conditions. Alternatively, you can tell the routines only to reprompt a certain number of times, and then accept the answer anyway. The number of times can be 0 (thus, no error is ever typed by the routines, but your program receives an error code if an error occurs.) This communication is established via a common block CMDPRM, described below. COMMON /CMDPRM/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),cmdblk(10) INITF - **internal** Non-zero if data entry routines have been initialized. Do not alter this word. RETRYS - Number of times to reprompt the user if an error occurs. If this number is negative, reprompt for ever until a correct answer is input. Set to -1 initially. May be altered at any time, inspected at each call. TRIED - **internal** Number of attempts made. ENDNSE - If non-zero, indicates that the caller is willing to allow garbage input to occur after the end of a field, i.e. if we are reading a number, we are willing to accept "3 eggs" as input as well as just "3". Initially set to 0, in which case the error code 2 is returned, or the user is reprompted if extraneous input should occur. N O T E One problem with this feature is that, if a default has been supplied for a field, and the user enters something totally incorrect (eg you wish to read a number and they type WOT), the default for the field is returned, without much indication to the calling program. This is because the numeric field is terminated by the first non-numeric character, so is defaulted, and the text becomes part of the trailing text which you have indicated our willingness to ignore. This text is, however, returned in the CMDBFR. RAISE - If non-zero, indicates that all input text should be raised to upper case. This does NOT affect what is on the screen, only what is stored in the command buffer, and any text strings returned to your program. This is useful in areas where letter case is important, i.e. in key fields to be inserted into RAPPORT data files, which consider text of differing cases to be different. It does not affect the user typing at the terminal, who is unaware of it. SAVRET - **internal** Return address for reparse SAVP - **internal** Saved stack pointer EXILAB - If non-zero, indicates the statement to jump to if the user types EXIT. To cause control to transfer to statement 9000 when EXIT is typed, use code such as the following: ASSIGN 9000 TO EXILAB This can be changed as the program continues, to transfer control to different statements at different points. Note that if this is 0, an error code of -2 will be returned instead if EXIT is typed. USEEXT - Indicates whether the routines should allow EXIT or UNKNOWN to be be typed in answer to a question. Normally, EXIT or UNKNOWN can always be typed as an answer, returning special fail codes to the calling program, or jumping to a special label. If this variable is set non-zero, the keywords EXIT and UNKNOWN will not be permitted as answers. Can be changed at any point in the program. SPARE - Unused CMDBLK - **internal** Command state block (see monitor calls reference manual if you're interested.) This common block need only be declared if you wish to alter values of variables in the block. Another common block, CMDSTG, is used mainly by the routines internally. However, one field in it may be of use if you wish to access the actual text entered by the user as it was typed (which may be especially useful if you want to examine their input in case of an error). COMMON /CMDSTG/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) CMDBFR - Stores exact text of last line typed in. ATMBFR - Stores exact text of last field typed in. Usually the same as CMDBFR, unless rubbish was entered after the real input (in which case this contains the extraneous input.) FDB - COMND function descriptor block HLPBFR - Used to construct help messages if user does not supply them. DEFBFR - Used to contruct text for defaults. GJFBLK - GTJFN argument block, zeroed on each call. ARGBLK - FOROTS argument block for CROPEN. Note: A copy of the writeup for all routines is in HLP:DATA-ENTRY.DOC Example ======= DATE ROUTINE category: J4 title: subroutine date(text) language: macro description: returns today's date in character form, e.g.14-Aug-83 , in either a 2 element array, or a character variable*10 references: Tops 10/20 Fortran language manual parameters: text array/ output the date in character form character author: Dec DATEIN ROUTINE category: N3 title: subroutine DATEIN (PROMPT,JULIAN,FAIL,BACK,LOWER,UPPER,HELP,DEFALT) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads a date, typed in any reasonable format. Dates may be numeric (in which case day/month/year is assumed) or text, such as Feb 8 82 or Wednesday, September 1st 1982. In general, anything unambiguous is accepted. The corresponding julian day number is returned. The program can supply both upper and lower limits for the date (which are inclusive) independently of each other, or supply neither. A default can be supplied by the program( as a julian day no.). This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string Julian Integer output Returned julian day number fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. Lower Integer input *Optional* Lower limit for date (inclusive) or 0 if not desired. Upper Integer input *Optional* Upper limit for date (inclusive) or 0 if not desired. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. If no help is supplied, a message will be constructed of the form "Enter a date, before 1-jul-82, after 1-jul-81", with limits only mentioned if they are supplied in the call. defalt Integer input *Optional* Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL DATEIN('Date:',JULIAN,FAIL) is valid, as is CALL DATEIN('Date:',JULIAN,FAIL,*10,0,JTODAY(K),'Enter date & of birth') which supplies a label to return to if the user types ^ (the label is 10),stores the date of birth in JULIAN, specifies no lower limit, but specifies an upper limit of today's date, and outputs a help message if a question mark is typed. No default has been supplied, however. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Invalid input 2 Not confirmed (this is only possible if RETRYS is set to a non-negative value and the user types EXIT, UNKNOWN or ^ and then types rubbish after the command.) 5 Date is not in valid format 6 Date is out of range. -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),cmdblk(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 DOJSYS ROUTINE category: K24 title: SUBROUTINE DOJSYS(JSNUM,ARG1,ARG2,ARG3,ARG4,LABEL) language: macro description: Executes any TOPS-20 monitor call. This allows the high-level programmer (in ALGOL,PASCAL or FORTRAN) to do ANYTHING that the system is capable of, providing that he or she can work out what arguments to supply. This is not always easy. A description of the monitor calls available may be found in the TOPS-20 Monitor Calls Reference Manual. There are about 300-400 of them, providing access to all system facilities. An introduction can be found in the TOPS-20 Monitor calls User's Guide. Monitor calls usually accept arguments in the machine's accumulators when called from a MACRO program. When using this subroutine, ARG1 contains the argument usually supplied in AC1, ARG2 usually contains that supplied in accumulator two, etc. JSNUM is the number of the JSYS required. Note that the numbers in the reference manual are OCTAL. Label is an fortran statement label which will be jumped to if the monitor call fails. Most calls return an error code in ARG1. The error can always be obtained with the GETER jsys ( number 10 (decimal)). ERSTR (JSYS 9) can be used to print an informative message on failure. All arguments except JSNUM are optional. If an error occurs, and the LABEL argument is not supplied, the program is halted, and an informative message is printed giving the reason for the error. N O T E ======= Arguments ARG1 to ARG4 are all input/output. This is because monitor calls often use them to return values as well as accept them. The implication of this is that these arguments may NOT be literals, constants or expressions. All of them must be assigned to variables or array elements before using these in the call. The LABEL and JSNUM arguments do not suffer from this restriction. Hints: Functions LEFT and RIGHT can be very useful in retrieving arguments that are returned in right or left halves of acs. Function GETADR can be useful when one of the ac arguments requires the address of a storage location. These routines are all described in this library. method: Horrific parameters: JSNUM Integer Input Monitor call to execute ARG1 Any Input/output Contents of first accumulator ARG2 Any Input/output Contents of second accumulator ARG3 Any Input/output Contents of third accumulator ARG4 Any Input/output Contents of fourth accumulator LABEL Label Input Statement to return to on error Example: We wish to find out which terminal number our program is running at. Perhaps we want to know if it is feasible to use graphics on it. The GJINF% JSYS is most useful in this regard. Its number is 13 (octal). CALL DOJSYS("13,USRNUM,DIRNUM,JOBNUM,TERNUM) This call never fails. We also receive our user number, number and job number, which may or may not be useful. N O T E A pint of beer (or other suitable replacement) is offered to the first person to get COMND (Jsys 544(octal)) to work using this method. common blocks: none level: level 0 author: Dan Murphy/Kevin Ashley date: November 1982 EASTER ROUTINE category: J23 title: Integer function easter(year) language: fortran description: returns the julian day number of Easter Sunday for the given year. It is valid between 1583 and 4200, although if a year of less than 100 is given, then it is assumed to be in the 20th century. An invalid year returns a value of 0. method: The method is due to Gauss. references: Programming in Standard Fortran 77 by Balfour and Marwick parameters: year integer input the year for which the date of Easter Sunday is sought. common blocks: none own variables: no routines called: none level: level 0 author: Balfour/Marwick/G.Gibbs date: December 1982 CRUPER ROUTINE category: A33 title: subroutine cruper(text) language: macro description: put text into upper case method: Uses the MOVe String Translated instruction. references: parameters: text character i/o text to be raised to capitals common blocks: none routines called: gtbypt,gtbufa,ptbufa author: G.Gibbs date: July 1984 E. IN A1 FORMAT. LOOK-UP TABLE. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A B D E F H J K L M N P R S T V X PARAMETERS: IUN INTEGER INPUT NPH UNIT NUMBER ICHL INTEGER OUTPUT CHECK LETTER. ROUTINES CALLED: LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: 2nd JUNE 1981 GETADR ROUTINE Category: A28 Title: INTEGER FUNCTION GETADR(Thing) Language: Macro-20 Description: Returns the address of its argument. The argument can be a variable of any type, an array, a literal string, or a routine or label. This is most useful in conjunction with DOJSYS. Parameters: THING Any Input The address of this will be returned. Example: We wish to discover the account we are running under. We can store the account string in an array, but the GACCT jsys requires a byte pointer to the array, which consists of a word containing -1 in the left half, and the array address in the right. We may do this as follows: MINUS=-1 ACCPTR="777777000000.OR.GETADR(ACOUNT) CALL DOJSYS("546,MINUS,ACCPTR) Array ACOUNT will receive a string of characters representing the account of the current job. Level: 0 Author: Kevin Ashley Date: Nov 82 GETDDT ROUTINE category: K25 title: SUBROUTINE GETDDT language: macro-20 description: Loads DDT into a process, and causes a breakpoint This subroutine provides a method for a program to invoke the dynamic debugger (DDT) at will, without it being permanently resident in a program. Thus, a program could have a special DEBUG command, which loads DDT, or it could load DDT whenever a serious error occurs which requires attention. Alternatively, DDT could be loaded asynchronously by an interrupt routine, invoked, say by CTRL/D. The possibilities are endless. On each call to GETDDT, a breakpoint is simulated by jumping to $0BPT in DDT. One can proceed as from a normal breakpoint. Note that DDT is liable to be useful only to those with a knowledge of assembler programming. method: SYS:UDDT is merged into the process, and the symbol table address (from .JBSYM) is placed in the DDT user symbol pointer. The user ACs are restored, and a jump is made to the unsolicited breakpoint in DDT. common blocks: none level: level 0 author: Terry Pettit/Kevin Ashley date: January 1983 HOSPNO ROUTINE category: N2 title: subroutine HOSPNO (PROMPT,HOSNUM,LETTER,FAIL,BACK,HELP,DEFALT) language: MACRO-20 purpose: This routine reads a hospital number with its attached check letter from the terminal. An error is returned if the check letter does not match the digits, and the user is usually reprompted to try again. The letter and the number are returned separately. This routine is part of the general data entry suite, and so automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string hosnum Integer output The returned hospital number Letter Any output The ascii code for the check letter (ie R1 format) fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. length Integer output *Optional* Length of text string. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of "hospital number" will be used if you do not supply one. defalt Array or input *Optional* string Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL HOSPNO('Number:',PATNUM,PATLET,FAIL) is valid, as is CALL HOSPNO('Number:',PATNUM,PATLET,FAIL,*10,'Enter patient''s & Number') which supplies a label to return to if the user types ^ (the label is 10) and outputs a help message if a question mark is typed. No default has been supplied, however. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Invalid input (should not occur) 2 Not confirmed (this is only possible if RETRYS is set to a non-negative value and indicates that extraneous information was entered after the check letter.) 3 Hospital number is not a number, or is out of range (ie is negative, contains too many digits, etc.) 4 Check letter does not match patient number. -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),cmdblk(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 ICOMP ROUTINE CATEGORY: A3 TITLE: FUNCTION ICOMP (N,A,I,B,J) LANGUAGE: MACRO DESCRIPTION: COMPARE CHARACTER STRINGS. CHARACTER STRINGS OF LENGTH N STARTING AT THE I'TH CHARACTER OF A AND THE J'TH CHARACTER OF B (COUNTING FROM 1). RESULT IS +1,0 OR -1 ACC AS THE A-STRING IS >,= OR< THE B-STRING. N IS ALSO SET TO THE NO OF EQUAL CHARACTERS AT THE BEGINNING OF THE STRINGS. IF N, I OR J ARE NON-POSITIVE,N IS SET TO 0 AND ICOMP RETURNS A VALUE OF 2. A,B MAY BE TEXT CONSTANTS. PARAMETERS N INTEGER INPUT/OUTPUT NO OF CHARACTERS TO BE COMPARED A,B ANY INPUT STRINGS TO BE COMPARED I,J INTEGER INPUT STARTING POSITIONS IN STRINGS EXAMPLE: N=4 IF (ICOMP(N,BUFFER,1,'FRED',1).EQ.0) GO TO 200 ROUTINES CALLED: NONE AUTHOR: G.GIBBS DATE: MARCH 1981 ICRCH2 ROUTINE CATEGORY A6 TITLE: FUNCTION ICRCH2 (I,J) LANGUAGE: FORTRAN DESCRIPTION: CHARACTER EXTRACTION(ICL CODE). I IS A SCALAR OR (USUALLY) AN ARRAY ELEMENT (NOT AN ARRAY NAME). RESULT IS THE INTEGER VALUE OF THE JTH CHARACTER IN ICL CODE, COUNTING THE FIRST CHARACTER IN I AS NO. 1. IF, FOR EXAMPLE, THE 3-WORD ARRAY I CONTAINS THE CHARACTERS M.J.R.HEALY, THEN THE VALUE OF ICRCH2 (I(2),4) IS 33 (EQUIVALENT TO A). IF YOU DO NOT SPECIFICALLY REQUIRE ICL CODE, IPK (WHICH THIS CALLS) IS PREFERED AS IT IS QUICKER AND GIVES ASCII CODE A LOWER CASE LETTER RETURNS THE VALUE FOR THE UPPER CASE LETTER AND A CONTROL CHARACTER RETURNS THE VALUE -1. PARAMETERS I INTEGER INPUT START OF CHARACTER STRING. J INTEGER INPUT POSITION OF REQUIRED CHARACTER. ROUTINES CALLED NONE LEVEL: LEVEL 1 AUTHOR G.GIBBS DATE 31st MARCH 1981 ICRCH3 ROUTINE CATEGORY: A7 TITLE: ICRCH3 (K,I,J) LANGUAGE FORTRAN DESCRIPTION CHARACTER INSERTION(IN ICL CODE). THE LEAST SIGNIFICANT 6 BITS OF K (TAKEN AS ICL CODE) ARE INSERTED IN CHARACTER POSITION J (COUNTING FROM 1) OF I. IF YOU DO NOT SPECIFICALLY REQUIRE ICL CODE,PK (WHICH THIS CALLS) IS PREFERED AS IT IS QUICKER,AND USES ASCII CODE. PARAMETERS K INTEGER INPUT CHARACTER TO BE INSERTED I INTEGER OUTPUT CHARACTER STRING J INTEGER INPUT POSITION IN CHARACTER STRING ROUTINES CALLED PK LEVEL: LEVEL 1 AUTHOR G.GIBBS DATE 31st MARCH 1981 ICRCH4 ROUTINE CATEGORY: A8 TITLE: FUNCTION ICRCH4 (I,J,K) LANGUAGE: MACRO DESCRIPTION: DECIMAL TO BINARY CONVERSION. VALUE RETURNED IS THAT OF THE POSITIVE INTEGER IN THE K NUMERIC CHARACTERS FROM THE J TH CHARACTER POSITION OF I (COUNTING FROM 1). ANY NON-DIGIT,A VALUE OF >34359738368 OR K< 1 CAUSES -1 TO BE RETURNED. LEADING SPACES ARE IGNORED BUT IF ALL K CHARACTERS ARE SPACES, -2 IS RETURNED. PARAMETERS: I ANY INPUT CHARACTER STRING J INTEGER INPUT POSITION OF FIRST CHARACTER K INTEGER INPUT NO. OF CHARACTERS ROUTINES CALLED NONE LEVEL: LEVEL 0 AUTHOR G.GIBBS DATE APRIL 1981 ICRCH7 ROUTINE CATEGORY: A21 TITLE: ICRCH7(I,J,K,L) LANGUAGE: MACRO DESCRIPTION: BINARY INTEGER TO DECIMAL CONVERSION THE VALUE OF I IS CONVERTED TO A STRING OF DECIMAL DIGITS, AND THIS IS PLACED IN THE L CHARACTER POSITIONS STARTING FROM THE K'TH CHARACTER OF ARRAY J IF L IS NEGATIVE LEADING ZEROES ARE OUTPUT AS SPACES. L ASTERISKS WILL BE OUTPUT IF L IS TOO SMALL PARAMETERS: I INTEGER INPUT BINARY VALUE J ARRAY OUTPUT START OF CHARACTER STRING K INTEGER OUTPUT POSITION OF START IN J L INTEGER INPUT NO. OF DECIMAL DIGITS ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: APRIL 1981 ICRNTM ROUTINE category: K23 title: function icrntm(dummy) language: macro description: returns the current run time of the current fork This may be used for timing sections of code and seeing if changes improve the speed. It should be noted that your program will take different lengths of time, depending on the load etc. so that you should time sections of code several times to get a figure for comparison. Simply reference the function before and after the section of interest, and obtain the difference. method: uses the monitor call RUNTM% parameters: dummy for syntax only common blocks: none level: level 0 author: G.Gibbs date: November 1982 ICRSCH ROUTINE category: A25 title: function icrsch(record,i,lenrec,word,j,numcha) language: macro description: Search the array "record" (starting at the ith character) for the characters in "word" (starting at the jth character), the number of characters in the search string being numcha. The function returns the character position in "record" where the match starts, regardless of the starting position (i) A value of 0 is returned if there is no match and -1 if erroneous arguments are given. method: Comparing the search string against each allowable position until a match is found, using the hardware compare strings instruction. parameters: record any input array to be searched for match i integer input the starting position in characters, counting from 1. lenrec integer input the length of the array "record", starting from the begining to the last character to be considered in the search, measured in characters. word any input the string of text to be searched for j integer input the starting position in characters, counting from 1, in "word" for the comparison. numcha integer input The length of the string being sought. Note that this is not necessarily the length of the array "word", especially if you do not start from character 1. Measured in characters. routines called: none level: level 0 author: G.Gibbs date: November 1982 ICRTLU ROUTINE CATEGORY: A16 TITLE: FUNCTION ICRTLU (I,JA,L) LANGUAGE: MACRO DESCRIPTION: TABLE LOOK-UP BY BINARY SEARCH. JA IS A TABLE CONSISTING OF L ONE-WORD ENTRIES ARRANGED IN ASCENDING ORDER (IN THE CHARACTER SENSE, SO THAT NEGATIVE INTEGERS EXCEED POSITIVE INTEGERS). THE RESULT IS THE POSITION OF I IN THE TABLE (COUNTING FROM 1); IF I DOES NOT OCCUR IN THE TABLE, THE RESULT IS ZERO. (CF. NPH2). PARAMETERS: I INTEGER INPUT VALUE TO BE LOOKED UP. JA INTEGER INPUT FIRST LOCATION OF TABLE. L INTEGER INPUT LENGTH OF TABLE COMMON BLOCKS: NONE OWN VARIABLES: NO ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: APRIL 1981 DATA-ENTRY CATEGORY N Question/answer data entry --------------------------- N1 TEXTIN Reads free text from terminal after prompt N2 HOSPNO Reads a hospital number after a prompt N3 DATEIN Reads a free-format date after prompt, converts to Julian N4 KYWORD Reads one of a list of keywords or phrases, with recognition N5 SEXIN Reads a sex N6 YESNO Reads yes or no N7 NUMIN Reads an integer after a prompt N8 REALIN Reads a real after a prompt N9 TABLE Builds a keyword table for KYWORD N10 CROPEN Reads a filename, with recognition, and opens the file N11 TBLOOK Looks up a character string in a table created by TABLE N12 TBRLOC Relocates lookup table pointers after reading from disk. MONTH ROUTINE category: J24 title: character function month(number) language: Fortran 77 description: returns the month in characters, 0 returns 'Unknown' and 'Error' is return for other out of range numbers. parameters: number integer input the n'th month of the year routines called: none example: character*9 month do i=0,13 type (fmt='1x,a') month(i) end do author: G.Gibbs date: June 1984 INPUT-TERMINAL CATEGORY M INPUT FROM THE TERMINAL ----------------------- J20 CRDTOI CONVERT CHARACTER DATE TO 3 INTEGERS M2 CRNIN INPUT INTEGER FROM TERMINAL M3 CRFLIN INPUT REAL NUMBER FROM TERMINAL M4 CRFNIN INPUT A FILE NAME FROM TERMINAL M5 ICHIN INPUT NEXT CHARACTER FROM THE TERMINAL M6 ICHOUT OUTPUT A CHARACTER TO THE TERMINAL CRCLR ROUTINE category a19 title: crclr(i,j,k) language: macro description: crclr sets 'j' words starting at 'i' to the value of 'k' k must be of the same type as i but not double precision nor complex. parameters: i any input start of area j integer input length of area k any input value to fill area example: dimension buffer (30) call crclr (buffer,30,' ') own variables: no routines called: none level: level 0 author: G.Gibbs date: April 81 MATHEMATICS CATEGORY: *G G MATHEMATICS ----------- 3 CRMATH2 QUOTIENT AND REMAINDER. 5 NELDER FUNCTION MINIMISATION. 10 FUNCTION CRLNFC NATURAL LOGARITHM OF FACTORIAL FOR NON-NEGATIVE ARGUMENT 12 CRFUNC,CRUSFN,CRMLFN RETURNS VALUE OF REQUIRED FUNCTION GIVEN X 13 CRMNX,CRMNX2 FIND THE MINIMUM AND MAXIMUM OF N ELEMENTS IN ARRAY X. 14 CRFREQ CALCULATES HISTOGRAM FREQUENCY COUNTS 15 CRMNIM FUNCTION MINIMISATION 17 CRVCR COMPUTES MATRICES FOR INPUT TO NAG LEAST-SQUARES ROUTINES 18 NINT ROUNDS REALS TO INTEGERS 19 CRTWMY Twomey's method for Fredholm integral equation of 1st kind CRDOUT ROUTINE Category: J21 Title: CRDOUT (ICDATE,IDAY,MONTH,IYEAR,IFMT) Language: MACRO Descrption: Outputs date in character form, to one of an array, a character variable or your terminal. in the latter case the name of the array should be replaced by the number 1, e.g. CALL CRDOUT(1,IDAY,MONTH,IYEAR,IFMT) The degree of verbosity used is defined by IFMT, increasing from 27-Nov-81 for IFMT=1 to Friday, 27 November 1981 for IFMT=4 Sufficient space must be allowed in the array, if used, to allow for the maximum number of characters you are likely to get +1. Parameters: ICDATE array or OUTPUT Date in character form character IDAY } {The 3 parts MONTH} integer INPUT {of the date IYEAR} { IFMT integer INPUT The verbosity of output from 1 to 4 Author: G.Gibbs Date: November 1981, character variables July 1984 SORTING CATEGORY: *B B SORTING ------- 1 CRC154,CRC155 IN-CORE SORT(REAL VARIABLES) STATISTICS CATEGORY: *E E STATISTICS ---------- 1 BINOML BINOMIAL PROBABILITY. 4 SNDEV CALCULATES A NORMAL EQUIVALENT DEVIATE. 5&6 CRC151,CRC152 SET UP LIST OF INTEGERS. 7&8 CRC153,CRC156 LOG TRANSFORMATION. 12 STAT7,STAT7B MEAN AND POWER SUMS ABOUT MEAN 13 STAT8 NORMAL TAIL AREAS. 20 STAT13 MARGINAL MEANS OF MULTI-WAY TABLE 21 STAT14 ANALYSIS OF MULTI-WAY TABLE 22 STAT7A AS CRSTAT7 BUT IGNORING NEGATIVE AND ZERO VALUES. 27 STAT19 MEAN,STANDARD DEVIATION FROM CENSORED SAMPLE 28 CRPOLY FITS THE POLYNOMIAL REGRESSION 30 CRSHPE CALCULATES USUAL COEFFICIENTS OF SKEWNESS AND KURTOSIS. 34 CRWTST CALCULATES SHAPIRO AND WILK'S STATISTIC. 37 STAT7M MEAN AND SD ALLOWING FOR MISSING VALUES. 39 RANDOM RETURNS A RANDOM NUMBER 40 RANDUP STARTS THE RANDOM NUMBER GENERATOR PSEUDO-RANDOMLY 41 RANSET STARTS THE RANDOM NUMBER GENERATOR REPEATABLY 42 CRGAM INCOMPLETE GAMMA INTEGRAL 43 CRDIXN Dixon's test for a single outlier 44 WEXT W test for normality 45 WCOEF Set up WEXT for a given sample size 46 NSCOR2 Calculates rankits 47 POLY Calculates a polynomial 48 SPLITN Fits a mixture of Normal distributions. 49 MW Test of multivariate normality. 50 RADII Test of multivariate normality. 51 SBS Testing multivariate normality. TERMINAL-CONTROL CATEGORY L TERMINAL CONTROL ---------------- L0 VTINIT Initializes the terminal for use L1 CURUP Moves the cursor up the number of times specified. L2 CURHOM Moves the cursor to the top left of the screen ("home") L3 CLEOS Clears the screen from the cursor to the end of screen L4 SCRRG Alters the scrolling region so that only certain areas of L5 PUTCRS Positions the cursor to an absolute position on the screen. L6 CLEOL Clears from the cursor to the end of the line. L7 VTLED Lights the specified LED above the keyboard, or clears all leds L8 TABCLR Clears all tab settings L9 TABSET Places a tab stop at the specified column L10 VTCBL Clears from the beginning of line to the cursor L11 VTCLIN Clears the entire line containing the cursor L12 VTCBS Clears from the start of screen to the cursor L13 VTCLS Clears the entire screen L14 VTLFT Moves the cursor left the specified number of places L15 VTRIT Moves the cursor right the specified number of places L16 VTDWN Moves the cursor down the specified number of places L17 VTSAV Saves the current cursor position and attributes L18 VTRES Restores cursor position and attributes saved by VTSAV L19 VTIUP Performs a "reverse index" L20 VT80 Sets the terminal to 80-column width L21 VT132 Sets the terminal to 132-column width L22 VTSCRN Sets the screen background to light or dark L23 VTORG Alters the setting of "origin mode". L24 VTJMP Sets jump scroll mode L25 VTSMTH Sets smooth scroll mode L26 VTATR Sets or clears the character attributes. L27 VTWID Types a text string in double width characters. L28 VTBIG Types a text string in double height, double width chars. L29 CRSIL Turns terminal echoing of typein on or off L30 VTEND Called at the end of a program to reset terminal parameters L31 CRBELL RING TERMINAL BELL L32 VTGON Turns VT100 graphics mode on. L33 VTGOF Turns VT100 graphics mode off L34 VTTY Changes terminal for screen routines IPK ROUTINE CATEGORY: A11 TITLE: FUNCTION IPK (IARRAY, J) LANGUAGE: MACRO DESCRIPTION: ASCII CHARACTER EXTRACTION. IARRAY IS THE AREA CONTAINING TEXT OR A TEXT CONSTANT. THE RESULT IS THE ASCII INTEGER VALUE OF THE J'TH CHARACTER, COUNTING THE FIRST CHARACTER IN IARRAY AS 1. IF, FOR EXAMPLE IARRAY CONTAINED THE CHARACTERS 'PENTONVILLE ROAD', THE VALUE RETURNED BY IPK (IARRAY, 7)WOULD BE 86 - EQUIVALENT TO V. THIS ROUTINE IS PREFERED TO ICRCH2. PARAMETERS: IARRAY ANY INPUT AREA HOLDING CHARACTER STRING J INTEGER INPUT POSITION OF REQUIRED CHARACTER ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: 30th MARCH 1981 JDATE ROUTINE CATEGORY: J15 TITLE: JDATE (J,IDAY,MONTH,IYEAR) LANGUAGE: FORTRAN DESCRIPTION: CONVERTS JULIAN DAY NUMBER TO CALENDAR DATE. THE DAY NUMBER IS CONVERTED TO CALENDAR DATE, GREGORIAN CALENDAR,HELD AS 3 INTEGER NUMBERS. IF THE DAY NUMBER CORRESPONDS TO A DATE PRIOR TO THE ADOPTION OF THE GREGORIAN CALENDAR IN BRITAIN, 14 SEPT 1752, THE DATE WILL BE RETURNED AS 0 , 0 , 0 . Reference: Collected algorithms from CACM 199 (R.G.Tantzen 1963) Parameters: J INTEGER INPUT Julian day number IDAY INTEGER OUTPUT} The 3 parts MONTH INTEGER OUTPUT} of the date IYEAR INTEGER OUTPUT} Authors: R.G.Tantzen/G.Gibbs Date: April 1981 JDAY ROUTINE Category: J16 Title: FUNCTION JDAY (IDAY,MONTH,IYEAR) Language: FORTRAN Description: Convert calendar date to Julian day number. A calendar date Gregorian calendar, held as 3 integer numbers, is used to compute the Julian day number. Non valid dates, e.g. 29, 2, 1973 or 32, 13, 1981 return a Julian day number of 0, as will a date prior to the adoption of the Gregorian calendar in England, 14 September 1752. A year of less than 100 will be assumed to be in the 20th Centuary. Calls JDATE to check validity of date. Reference: Collected algorithms from CACM 199 (R.G.TANTZEN 1963) Parameters: IDAY INTEGER INPUT} The 3 parts MONTH INTEGER INPUT} of the date IYEAR INTEGER INPUT} Routines called:JDATE Author: G.Gibbs Date: April 1981 JTODAY ROUTINE Category: J17 Title: FUNCTION JTODAY (K) Language: MACRO Description: Today's Julian day number. the function returns today's Julian day number. K is a dummy argument. Method: Today's Smithsonian day number is retrieved from the internal date and time , and is converted to the Julian day number. Parameters: K DUMMY Required by FORTRAN syntax Author: G.Gibbs Date: April 1981 KYWORD ROUTINE category: N4 title: subroutine KYWORD (prompt,ktable,keynum,fail,back,help,defalt,string) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then accepts one of a supplied set of keywords or phrases from a previously constructed table. Any valid abbreviation of a keyword or phrase is accepted (ie one which is unique among all words or phrases), and the escape key can be used to complete a phrase. The question mark key can be used to obtain a list of valid inputs at any point during the entering of the phrase. A default string can be supplied by the program, which will be used if the user just types escape or return. The tables are set up using the TABLE routine (see separate entry), and contain both the text of the phrases, and a value to associate with each. It is this value that is returned, although the actual text of the phrase may be returned as well if desired. The case (upper or lower) of input is not significant when matches are being considered. This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. This routine is unable to read a keyword which is an abbreviation of the words EXIT or UNKNOWN. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string ktable Integer array input Table of pointers and values for keyword strings (set up by TABLE subroutine.) keynum Integer output Returned number associated by the user with the keyword or phrase. fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of "one of the following:" followed by a list of all possible words or phrases in alphabetical order will be supplied if the user does not supply one. It is recommended that the default help is used. defalt Array or input *Optional* string Default to be used if user types escape, or 0 if not desired. answer Array output *Optional* Returned text string of phrase or keyword. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL KYWORD('Disease:',DISTAB,DISEASE,FAIL) is valid, as is CALL KYWORD('Disease:',DISTAB,DISEASE,FAIL,*10, & 'Enter patient''s complaint') which supplies a label to return to if the user types ^ (the label is 10) and outputs a help message if a question mark is typed. No default has been supplied, however. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Phrase or word did not match any keyword in the list 2 Not confirmed (only if endnse is non-zero, which is the usual condition. It indicates superfluous input after keyword or phrase.) 17 Input was ambiguous (ie matched more than one word) -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),cmdblk(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 LCRBAT ROUTINE category: k20 title: logical function lcrbat(dummy) language: macro-20 description: returns true if job is running in batch and false if interactive method: uses monitor call getji% (get job info) parameters: DUMMY for syntax only common blocks: none own variables: no routines called: none level: level 0 author: G.Gibbs date: October 1982 LEFT ROUTINE Category: A27 Title: INTEGER FUNCTION LEFT(WORD) Language: Macro-20 Description: Returns the Left half (ie highest 18 bits) of its argument sign extended. This is most useful with the DOJSYS routine. Parameters: WORD Any Input Word to return Left half of Level: 0 Author: Dan Murphy/Kevin Ashley Date: November 1982 MW ROUTINE category: E49 title: subroutine MW (X,MAN,MA,MMA,N,N2,XBAR,A,EPS,SSP, MB,MMB,WORK,XWORK1,XWORK2,ZW,H,E,PH,IFAULT) language: FORTRAN 66 description: MW provides a test of multivariate normality based on the combination of univariate Shapiro-Wilk W statistics. Allowance is made for the observed correlations in the data. The resulting test statistic is a chi-square with possibly non-integral degrees of freedom, depending on the said correlations; however its P value is given also, so no problem. For data with correlations less than about 0.7, the test is the equivalent of combining the significance levels of the individual univariate (one-tailed) W tests. NOTE that the input array X is required to be ONE dimensional in row order, and that the SSP matrix (SSP) is also ONE-d arranged as lower triangle. The routine CRC135 is designed to produce just such an SSP matrix row-by-row from the input data. method: Requires Royston's method for evaluating the P value from W. references: Royston JP (1983). Some techniques for assessing multivariate normality based on the Shapiro-Wilk W. Appl. Statist. 31, 121-133. parameters: X REAL INPUT multivariate data set, ARRAY (MAN) arranged in row order MAN INTEGER INPUT total number of data values (MA*N) MA INTEGER INPUT number of variates MMA INTEGER INPUT length of sums of squares and products matrix N INTEGER INPUT number of observations per variate (i.e. sample size) N2 INTEGER INPUT N/2 if N even, (N-1)/2 otherwise XBAR REAL INPUT vector of variate means ARRAY (MA) A REAL INPUT coefficients for calculation of W ARRAY (N2) (use S/R WCOEF) EPS REAL INPUT minimum possible value of W (use S/R WCOEF) SSP REAL INPUT sums of squares and products (SSP) ARRAY (MMA) for X, arranged as lower triangle in row order LIST INTEGER INPUT variates to be included in analysis ARRAY (MB) MB INTEGER INPUT number of variates in LIST (<=MA) MMB INTEGER INPUT (MB*(MB+1))/2 WORK REAL OUTPUT ) ARRAY (MMB) ) XWORK1 REAL OUTPUT ) work space ARRAY (MB) ) XWORK2 REAL OUTPUT ) ARRAY (N) ZW REAL OUTPUT array of normal equivalent deviates from MB univariate W statistics ARRAY (MB) H REAL OUTPUT chi-square test statistic from ZW E REAL OUTPUT equivalent degrees of freedom for H PH REAL OUTPUT error indicator, equal to 7 if any P value for a univariate W test is zero or one 6 if a zero SD is found for any variate in LIST 5 if N<3 or N>2000 4 if items in LIST are not in ascending order 3 if any of the items in LIST are <1 or >MA 2 if MMB<>(MB*(MB+1))/2 or MB<1 or MB>MA 1 if MMA<>(MA*(MA+1))/2 or MA<1 0 otherwise (success!) common blocks: none own variables: no routines called: SUBTRI,SSPCOR,CRC154,WEXT,SNDEV,MULTW level: level 3 author: P.Royston date: September 19, 1983 NELDER ROUTINE CATEGORY: G5 TITLE: NELDER (F,N,START,STEP,ACC,MAXIT,RESULT,ARG,IT) LANGUAGE: FORTRAN DESCRIPTION: FUNCTION MINIMISATION. THE ROUTINE FINDS THE MINIMUM OF A FUNCTION F OF N VARIABLES(N MUST BE .LE.25) BY A SEARCH PROCEDURE THAT DOES NOT USE DERIVATIVES. SEE NELDER,J.A. & MEAD,R.,COMPUTER J,7,308-313,1965, F SHOULD BE WRITTEN AS A FORTRAN FUNCTION WITH A SINGLE (VECTOR) ARGUMENT HOLDING THE N VARIABLE VALUES. IT MUST BE DECLARED AS EXTERNAL IN THE CALLING SEGMENT. PARAMETERS: F REAL FUNCTION FUNCTION TO BE MINIMISED N INTEGER INPUT NO.OF VARIABLES OF F (MUST BE .LE.25) START REAL ARRAY INPUT INITIAL VALUES OF VARIABLES STEP REAL ARRAY INPUT INITIAL STEP LENGTHS ACC REAL INPUT ACCURACY CRITERION. THE FINAL VALUE WILL USUALLY BE WITHIN THIS AMOUNT OF TRUE MINIMUM. MAXIT INTEGER INPUT MAX. ALLOWED NUMBER OF FUNCTION EVALUATIONS. THE ROUTINE WILL BE LEFT WHEN THIS NO. OF EVALUA- TIONS HAS BEEN COMPLETED, EVEN IF THE ACCURACY CRI- TERION HAS NOT BEEN REACHED. RESULT REAL OUTPUT VALUE OF F AT THE MINIMUM. ARG REAL ARRAY OUTPUT VALUES OF VARIABLES AT THE MINIMUM. IT INTEGER OUTPUT NO. OF FUNCTION EVALUA- TIONS ACTUALLY PERFORMED. ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHORS: E. CHAMBERS/M.J.R. HEALY. DATE: 9TH SEPTEMBER, 1971. NINT ROUTINE category: G18 title: function nint(real) language: macro description: round a real number to give an integer. It will round halves in the positive direction. method: it uses the FIXR instruction parameters: real real input the number to be rounded common blocks: none routines called: none level: level 0 author: G.Gibbs date: November 1982 NPH11 ROUTINE CATEGORY: A14 TITLE: FUNCTION NPH11 (I, J, K) LANGUAGE: MACRO DESCRIPTION LOGICAL AND SHIFT OPERATIONS. J AND K ARE THE OPERANDS AND THE VALUE FOR I = 1-5 IS I = 1 J.AND.K 2 J.OR.K 3 J.NEQ.K 4 J SHIFTED LEFT K PLACES LOGICALLY 5 J SHIFTED LEFT K PLACES CIRCULARLY FOR I = 1-3, THE RESULTS ARE GIVEN BY THE TABLE BELOW J K .AND. .OR. .NEQ. 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 FOR I = 4-5,NEGATIVE VALUES OF K GIVE RIGHT SHIFTS FOR I OUT OF RANGE THE FUNCTION IS SET TO ZERO. PARAMETERS: I INTEGER INPUT TYPE OF OPERATION J, K INTEGER INPUT ARGUMENTS OTHER ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: APRIL 1981 NPH2 ROUTINE CATEGORY: A12 TITLE FUNCTION NPH2 (I,JA,K) LANGUAGE MACRO DESCRIPTION TABLE LOOK-UP. JA IS AN ARRAY OF K ITEMS. THE RESULT IS THE POSITION OF THE FIRST ITEM IN THE ARRAY EQUAL TO I, IF THERE IS ONE; IF THERE IS NOT, THE RESULT IS ZERO. NOTE THAT FASTER METHODS OF LOOK-UP SHOULD BE USED FOR LARGE TABLES, ESPECIALLY IF THESE CAN BE SORTED INTO ASCENDING ORDER. IF K IS NOT +VE THE RESULT IS ZERO. THE ITEM TO BE LOOKED UP MUST BE OF THE SAME TYPE AS THE ARRAY E.G. INTEGER , AND MUST NOT BE DOUBLE PRECISION OR COMPLEX. PARAMETERS I ANY INPUT ITEM TO BE LOOKED UP JA ARRAY INPUT LOOK-UP TABLE K INTEGER INPUT NO. OF ITEMS IN TABLE. ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR G.GIBBS DATE APRIL 1981 NPH3 ROUTINE CATEGORY: A13 TITLE: FUNCTION NPH3 (I,J,K) LANGUAGE: MACRO DESCRIPTION: BIT EXTRACTION. I IS A SCALAR. RESULT IS BITS J THROUGH K OF I, RIGHT JUSTIFIED. BIT-POSITIONS ARE NUMBERED FROM 0 TO 35, STARTING WITH THE MOST SIGNIFICANT. THUS IF I = '47610', THE VALUE OF NPH3 (I,18,20) IS 6 AND NPH3(I,14,20) IS 54,THE ASCII VALUE OF 6. -1 IS RETURNED UNLESS 0<J<K<35 NOTE THAT IPK IS QUICKER IF A CHARACTER IS TO BE EXTRACTED. PARAMETERS: I INTEGER INPUT DATA WORD. J,K INTEGER INPUT FIRST AND LAST BIT POSITIONS OF PORTION TO BE EXTRACTED. ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: APRIL 81 NPLOT ROUTINE CATEGORY: D8 TITLE: NPLOT (X,N,NCHAN) LANGUAGE: FORTRAN DESCRIPTION THIS SUB-ROUTINE PLOTS (ON CHANNEL NCHAN) NORMAL PLOTS FOR THE N VALUES OF THE FLOATING POINT ARRAY X. THE VALUES Y= (X-XBAR)/S (WHERE XBAR AND S ARE THE SAMPLE ESTIMATES OF THE MEAN AND STANDARD DEVIATION) ARE PLOTTED ON THE Y-AXIS. ON THE X-AXIS IS PLOTTED THE NORMAL EQUIVALENT DEVIATE CORRESPONDING TO THE PROPORTION PI = (I-0.5)/N FOR THE I'TH RANKED ELEMENT OF X. PLOTTING IS DONE BY SUB-ROUTINE CRC 561 AND THE NORMAL EQUIVALENT DEVIATES CALCULATED BY FUNCTION SNDEV. VALUES OF XBAR AND S ARE PRINTED AFTER THE PLOT ON CHANNEL NCHAN. PARAMETERS: X REAL ARRAY VECTOR OF OBSERVATIONS N INTEGER NUMBER OF OBSERVATIONS UNTIL GREATER THAN 1000. NCHAN INTEGER OUTPUT CHANNEL NUMBER. ROUTINES CALLED: CRC154,CRC561,FUNCTION SNDEV LEVEL: LEVEL 2 AUTHOR KLIM MCPHERSON NPLOT1 ROUTINE CATEGORY: D11 TITLE: NPLOT1(X,N,NCHAN) LANGUAGE: FORTRAN DESCRIPTION: NORMAL PLOT ***REVISED VERSION OF NPLOT (AUG.78)*** NORMAL EQUIVALENT DEVIATES ARE CALCULATED FOR THE ADJUSTED SAMPLE CUMULATIVE PROPORTIONS P(I) VIA P(I)=(I-1/3)/(N+1/3). THESE ARE PLOTTED AGAINST THE RANKED SAMPLE VALUES X (WHICH MAY BE INPUT UNSORTED) WITH THE NED'S ON THE HORIZONTAL AXIS. OUTPUT IS DIRECTED TO CHANNEL NCHAN. THE PROGRAM ALSO OUTPUTS THE FOLLOWING STATISTICS WHICH AUGMENT THE NORMAL PLOT AS TESTS OF NORMALITY:- 1) MEAN AND STANDARD DEVIATION OF X; 2) COEFFICIENTS OF SKEWNESS AND KURTOSIS OF X(FROM CRSHAPE [E29]); 3) SHAPIRO AND WILK'S W-STATISTIC,AND ITS APPROXIMATE SIGNIFICANCE LEVEL.(USES CRWTEST[E35]). REFERENCE: FOR W-STATISTIC, DESCRIPTION OF SUBROUTINE CRWTEST[E35] AND BIOMETRIKA 52 (1965),P.591. PARAMETERS: X REAL ARRAY(N) INPUT SAMPLE DATA (IN ANY ORDER) N INTEGER INPUT SAMPLE SIZE (LESS THAN 1000 NCHAN INTEGER INPUT OUTPUT CHANNEL NUMBER LEVEL: LEVEL 2 ROUTINES CALLED: CRWTST,CRC154,FLOAT,SNDEV,CRC561,CRSHPE AUTHOR: J.P.ROYSTON DATE: 22 AUGUST 1978. NSCOR2 ROUTINE category: E46 title: subroutine nscor2(s,n,n2,ifault) language: fortran description: Calculates expected normal order statistics for sample size N (also known as 'rankits'). S(1) contains the largest positive rankit; the array stops at S(N2), i.e. the negative symmetric rankits are not supplied in S, but can be found via S(N-J+1) = S(J) for J=1,...,N2. The array S is needed in the calculation of the W test (E44). method: uses a polynomial approximation based on Blom's (1958) method. Accurate to 0.0001 and usually much better. references: Applied Statistics Vol.31 no.2 1982, algorithm AS 177 parameters: s real output contains n2 largest rankits array n integer input sample size n2 integer input largest integer .le. 1/2 n ifault integer output fault indicator, 3 if n2.ne.[n/2] 2 if n.gt.2000 1 if n.le.2 0 otherwise common blocks: none own variables: no routines called: correc,sndev level: level 1 author: P.Royston date: February 1983 NUMIN ROUTINE category: N7 title: subroutine NUMIN (prompt,answer,fail,back,lolim,hilim,help,defalt) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads an integer number from the terminal, optionally checking if it falls within specified limits. A default may be used which is supplied by the calling program, which will be used if the user types return or escape. The limits can be both specified, or only one specified, or neither. They are inclusive. If it is wished to include arguments following the limits, but not the limits themselves, one may supply the largest or smallest integer (as appropriate) as limit values. These may be obtained using NAG functions, or just input as constants (which are octal 377777777777 and 400000000000 for upper and lower limits respectively.) This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string answer Integer output Returned value fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. lolim Integer input *Optional* Lower limit for input, inclusive (ie this number is valid), or "400000000000 to ignore. hilim Integer input *optional* Upper limit for input, inclusive or "377777777777 to ignore. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of the form "Enter a number, at least 0 and not more than 120" will be used if you do not supply one (with limits set only if supplied.) defalt Integer input *Optional* Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL NUMIN('Age:',AGE,FAIL) is valid, as is CALL NUMIN('Age:',AGE,FAIL,*10,0,120,'Enter patient''s age at & at examination') which supplies a label to return to if the user types ^ (the label is 10),stores the integer age answer in AGE, and outputs a help message if a question mark is typed. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) (But note exceptions for LOLIM and HILIM) Error codes: 0 Success 1 Invalid input 2 Not confirmed (this indicates superfluous input after the word.) 7 Not a number 8 Number too small 9 Number too large -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),CMDBLK(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 PK ROUTINE CATEGORY: A15 TITLE: PK (IARRAY,K,J) LANGUAGE: FORTRAN DESCRIPTION: CHARACTER INSERTION (IN ASCII CODE). IARRAY IS THE NAME OF AN ARRAY INTO THE JTH CHARACTER OF WHICH (COUNTING FROM 1) IS WRITTEN A CHARACTER WHOSE VALUE IS OBTAINED FROM THE LEAST SIGNIFICANT 7 BITS OF K, IE. K MODULO 128. THIS ROUTINE IS PREFERED TO ICRCH3 PARAMETERS: IARRAY ARRAY OUTPUT ARRAY INTO WHICH CHARACTER IS TO BE INSERTED. K INTEGER INPUT CHARACTER TO BE INSERTED. J INTEGER INPUT POSITION IN CHARACTER STRING. ROUTINES CALLED: NONE LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: APRIL 1981 PNPLOT ROUTINE CATEGORY: C40 TITLE: PNPLOT(X,N,NDS,IDS,NCHAN) LANGUAGE: FORTRAN DESCRIPTION: PRODUCES UP TO 5 NORMAL PLOTS ON EITHER THE OKI DOT MATRIX PRINTER OR THE CALCOMP PEN PLOTTER (WHEN READY). STANDARD- IZED DATA VALUES(X-XBAR)/SD ARE PLACED ON THE Y-AXIS; OTHERWISE METHOD AND OUTPUT ARE THE SAME AS THE LINE- PRINTER NORMAL PLOT [D8]. MEAN,STANDARD DEVIATION, SKEWNESS, KURTOSIS AND (WHEN 2<N<51) THE W-STATISTIC (SEE CRWTST [E34]) FOR EACH DATA SET ARE OUTPUT TO CHANNEL NCHAN. THE PLOT IS SENT TO THE OKI UNLESS NCHAN IS SET NEGATIVE, WHEN IT IS SENT TO THE CALCOMP. PARAMETERS: X REAL ARRAY(N) INPUT CONTAINS UP TO 5 DATA SETS N INTEGER INPUT TOTAL NUMBER OF X-VALUES NDS INTEGER INPUT NUMBER OF DATA SETS TO BE ANALYSED (UP TO 5) IDS INTEGER ARRAY(5)INPUT SAMPLE SIZES OF DATA SETS IN X (IN SAME ORDER) NCHAN INTEGER INPUT OUTPUT CHANNEL NUMBER. IF SET NEGATIVE THE PLOT WILL BE SENT TO THE CALCOMP RATHER THAN TO THE OKI LEVEL: LEVEL 4 ROUTINES CALLED: CRWTST,CRC154,CRSHPE,SNDEV CRGRIT,CRGRAX,CRGRLB,CRGRAF AUTHOR: J.P.ROYSTON/G.GIBBS DATE: 12 JANUARY 1982. POLY ROUTINE category: E47 title: function poly(c,nord,x) language: fortran description: Calculates the algebraic polynomial of order NORD-1 for input value X. C(NORD) are the polynomial coefficients. E.g. for NORD = 3 POLY will return C(1) + X*C(2) + X*X*C(3). references: Applied Statistics Vol.31 no.2 1982, algorithm AS 181 parameters: c real input coefficients nord integer input order x real input common blocks: none own variables: no routines called: none level: level 0 author: P.Royston date: February 1983 PUTCRS ROUTINE CATEGORY: L5 NAME: PUTCRS(ROW,COLUMN) PURPOSE: Positions the cursor to an absolute position on the screen. The next write will occur at that position. PARAMETERS: ROW Integer input Row number COLUMN Integer input Column number Row and column numbers start at (1,1) although (0,0) is read as (1,1). The maximum value of row is 24, and that of column is 80 or 132, depending on screen setting. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 RADII ROUTINE category: E50 title: subroutine RADII (X,MAN,MA,MMA,N,N2,XBAR,A,EPS,SSP, MB,MMB,WORK,XWORK1,D,OMEGA,P,IFAULT) language: FORTRAN 66 description: The square of the scaled Euclidean distance of a datum (sampled at random from a multivariate normal dist- ribution) from the sample centroid of the whole data has a beta distribution. These 'squared radii' may be used as the basis of a test of multivariate normality by transforming them to a standard normal variate and then subjecting the resulting vector to the usual W test. The present routine performs this procedure, called the 'omega test'(to distinguish it from the W test). It also outputs the squared radii (array D) for plotting if the user desires. (I recommend this.) NOTE: it has been found that it is very useful to examine subsets of VARIATES for departure from normality using the squared radii method, because subsets can reveal anomalies not apparent in the full data. Routine SBS has been included in the Library for this purpose. See also Routine MW. method: Requires Royston's method for evaluating the P value from W. references: Royston JP (1983). Some techniques for assessing multivariate normality based on the Shapiro-Wilk W. Appl. Statist. 31, 121-133. Healy, MJR (1968). Multivariate normal plotting. Appl. Statist. 17, 157-161. parameters: X REAL INPUT multivariate data set, ARRAY (MAN) arranged in row order MAN INTEGER INPUT total number of data values (MA*N) MA INTEGER INPUT number of variates MMA INTEGER INPUT length of sums of squares and products matrix N INTEGER INPUT number of observations per variate (i.e. sample size) N2 INTEGER INPUT N/2 if N even, (N-1)/2 otherwise XBAR REAL INPUT vector of variate means ARRAY (MA) A REAL INPUT coefficients for calculation of W ARRAY (N2) (use S/R WCOEF) EPS REAL INPUT minimum possible value of W (use S/R WCOEF) SSP REAL INPUT sums of squares and products (SSP) ARRAY (MMA) for X, arranged as lower triangle in row order LIST INTEGER INPUT variates to be included in analysis ARRAY (MB) MB INTEGER INPUT number of variates in LIST (<=MA) MMB INTEGER INPUT (MB*(MB+1))/2 WORK REAL OUTPUT ) ARRAY (MMB) ) XWORK1 REAL OUTPUT ) work space ARRAY (MB) ) D REAL OUTPUT transformed squared radii ARRAY (N) OMEGA REAL OUTPUT normal score from W test applied to D P REAL OUTPUT P value for OMEGA IFAULT INTEGER OUTPUT error indicator, equal to 7 if any P value for a univariate W test is zero or one 6 if the submatrix of SSP corresponding to LIST is not positive semi- definite or has pos. nullity 5 if N<3 or N>2000 4 if items in LIST are not in ascending order 3 if any of the items in LIST are <1 or >MA 2 if MMB<>(MB*(MB+1))/2 or MB<1 or MB>MA 1 if MMA<>(MA*(MA+1))/2 or MA<1 0 otherwise (success!) common blocks: none own variables: no routines called: SUBTRI,CRC301,TSDIST,STAT7,CRC154,SNDEV,WEXT level: level 3 author: P.Royston date: September 19, 1983 RANDOM ROUTINE category: E39 title: function random (dummy) language: fortran description: returns a random number method: The routine maintains 3 separate generators and produces the random number from the fractional part of the sum of them. The state of the generator may be saved for restarting later by saving the 3 integers and 1 logical in the common block. The generator is started in a pseudo random way unless a prior call has been made to ranset for a repeatable start. references: B.A.Wichmann and I.D.Hill Applied Statistics 1982 parameters: dummy any input dummy required for syntax common blocks: /crrand/ix,iy,iz,notset routines called: randup level: level 2 author: I.D.Hill/G.Gibbs date: July 1982 RANDUP ROUTINE category: E40 title: subroutine randup language: fortran description: starts the random number generator in a pseudo random way method: The separate generators are started with three numbers, today's Julian day number, the elapsed time since start-up, and the current time and date in internal machine form. parameters: none common blocks: crrand routines called: jtoday,mtime,meltime level: level 1 author: G.Gibbs date: July 1982 RANSET ROUTINE category: E41 title: subroutine ranset (seed) language: fortran description: starts the random number generator in a repeatable way parameters: seed real input number to set up generator with common blocks: crrand routines called: none level: level 0 author: I.D.Hill/G.Gibbs date: July 1982 REALIN ROUTINE category: N8 title: subroutine REALIN (prompt,answer,fail,back,lolim,hilim,help,defalt) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads an real number from the terminal, optionally checking if it falls within specified limits. A default may be used which is supplied by the calling program, which will be used if the user types return or escape. The limits can be both specified, or only one specified, or neither. They are inclusive. If it is wished to include arguments following the lintis, but not the limits themselves, one may supply the largest or smallest real (as appropriate) as limit values. These may be obtained using NAG functions, or just input as constants. This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string answer Real output Returned value fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. lolim Real input *Optional* Lower limit for input, inclusive (i.e. this number is valid) hilim Real input *optional* Upper limit for input, inclusive help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of the form "Enter a number, at least 0. and not more than 120." will be used if you do not supply one (with limits set only if supplied.) defalt Real input *Optional* Default to be used if user types escape, or 0.0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL REALIN('Age:',AGE,FAIL) is valid, as is CALL REALIN('Age:',AGE,FAIL,*10,0.,120.,'Enter patient''s age at & at examination') which supplies a label to return to if the user types ^ (the label is 10),stores the Real age answer in AGE, and outputs a help message if a question mark is typed. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) (But note exceptions for LOLIM and HILIM) Error codes: 0 Success 1 Invalid input 2 Not confirmed (this indicates superfluous input after the word.) 7 Not a number 8 Number too small 9 Number too large -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),CMDBLK(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 RIGHT ROUTINE Category: A26 Title: INTEGER FUNCTION RIGHT(WORD) Language: Macro-20 Description: Returns the right half (ie lowest 18 bits) of its argument sign extended. This is most useful with the DOJSYS routine. Parameters: WORD Any Input Word to return right half of Level: 0 Author: Dan Murphy/Kevin Ashley Date: November 1982 SBS ROUTINE category: E51 title: subroutine SBS (X,MAN,MA,MMA,N,N2,XBAR,A,EPS,SSP, MB,MMB,WORK,XWORK1,XWORK2,ICLIST,IC,MC,P,MBCMC,CHAN,IFAULT) language: FORTRAN 66 description: Please read the description of routine RADII for the motivation of this routine. SBS allows you examine the test of squared radii for all subsets of variates of given size (you input this quantity as MC). The input parameter MBCMC contains the number of combinations represented by your choice. For example, if MA=12 (twelve variates in entire data set), MB=6 (LIST of six variates being analysed), MC=3 (examine all variate-subsets of size 3), then MBCMC=6!/(3!3!)=20, and you will get 20 P values in array P, corresponding to W tests on squared radii for each combination. See paper by Royston (1983) for further discussion. method: Requires Royston's method for evaluating the P value from W. references: Royston JP (1983). Some techniques for assessing multivariate normality based on the Shapiro-Wilk W. Appl. Statist. 31, 121-133. Healy, MJR (1968). Multivariate normal plotting. Appl. Statist. 17, 157-161. parameters: X REAL INPUT multivariate data set, ARRAY (MAN) arranged in row order MAN INTEGER INPUT total number of data values (MA*N) MA INTEGER INPUT number of variates MMA INTEGER INPUT length of sums of squares and products matrix N INTEGER INPUT number of observations per variate (i.e. sample size) N2 INTEGER INPUT N/2 if N even, (N-1)/2 otherwise XBAR REAL INPUT vector of variate means ARRAY (MA) A REAL INPUT coefficients for calculation of W ARRAY (N2) (use S/R WCOEF) EPS REAL INPUT minimum possible value of W (use S/R WCOEF) SSP REAL INPUT sums of squares and products (SSP) ARRAY (MMA) for X, arranged as lower triangle in row order LIST INTEGER INPUT variates to be included in analysis ARRAY (MB) MB INTEGER INPUT number of variates in LIST (<=MA) MMB INTEGER INPUT (MB*(MB+1))/2 WORK REAL OUTPUT ) ARRAY (MMB) ) XWORK1 REAL OUTPUT ) work space ARRAY (MB) ) XWORK2 REAL OUTPUT ) ARRAY (N) ) ICLIST INTEGER OUTPUT working array containing changing set ARRAY (MC) of variates entering S/R RADII IC INTEGER OUTPUT working array representing the same list as ICLIST but with binary entries (0=exlude, 1=include) MC INTEGER INPUT size of subsets of MB variates to test P REAL OUTPUT P values for omega tests for all ARRAY (MBCMC) combinations of MC variates from LIST MBCMC INTEGER OUTPUT number of combinations of MC variates out of MB [= MB!/(MC!(MB-MC)!)] CHAN INTEGER INPUT channel number to print current list of variates and P values for omega test. Set CHAN to zero to suppress printing. IFAULT INTEGER OUTPUT error indicator, equal to 8 if MBCMC is incorrect 7 if any P value for a univariate W test is zero or one 6 if MC<1 or MC>MB 5 if N<3 or N>2000 4 if items in LIST are not in ascending order 3 if any of the items in LIST are <1 or >MA 2 if MMB<>(MB*(MB+1))/2 or MB<1 or MB>MA 1 if MMA<>(MA*(MA+1))/2 or MA<1 0 otherwise (success!) common blocks: none own variables: no routines called: RADII,NXCBN,MCN level: level 4 author: P.Royston date: September 19, 1983 SCRRG ROUTINE CATEGORY: L4 NAME: SCRRG(TOP,BOTTOM) PURPOSE: Alters the scrolling region so that only certain areas of the screen can be scrolled off. PARAMETERS: TOP Integer input Top line of region (0<TOP<25) BOTTOM Integer input Bottom line of region An error will occur if the parameters are out of range, or if BOTTOM <= TOP. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 SEXIN ROUTINE category: N5 title: subroutine SEXIN (prompt,answer,fail,back,help,defalt) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads MALE or FEMALE from the terminal. A default may be supplied by the calling program, which will be used if the user types return or escape.The returned value is 1 for male, -1 for female, 0 for unknown (which also sets an error.) Any abbreviation can be used for MALE and FEMALE. A default can be supplied by the program, which is used if the user types escape or return. This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string answer Integer output Returned value fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of "one of the following: FEMALE MALE" will be used if you do not supply one. defalt Array or input *Optional* string Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL SEXIN('Sex:',TYPE,FAIL) is valid, as is CALL SEXIN('Sex:',TYPE,FAIL,*10,'Enter sex','MALE') which supplies a label to return to if the user types ^ (the label is 10),stores the answer in TYPE, and outputs a help message if a question mark is typed. MALE is assumed if nothing is entered. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Invalid input (ie not MALE FEMALE or UNKNOWN) 2 Not confirmed (this indicates superfluous input after the word.) 11 Does not match, or ambiguous -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),CMDBLK(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 SNDEV ROUTINE CATEGORY: E4 TITLE: FUNCTION SNDEV(PROB) LANGUAGE: FORTRAN DESCRIPTION: CALCULATES THE NORMAL EQUIVALANT DEVIATE ASSOCIATED WITH PROB. THAT IS THE AREA OF A NORMAL CURVE WITH MEAN ZERO AND VARIANCE UNITY, FROM MINUS INFINITY TO SNDEV, IS PROB. METHOD: APPLIED STATISTICS ALGORITHM AS 111 (J.D.BEASLEY AND S.G.SPRINGER, 1977) THE INTERNAL CALCULATIONS ARE PERFORMED IN DOUBLE PRECISION ALTHOUGH THE ARGUMENTS ARE PASSED IN SINGLE PRECISION PARAMETER: PROB REAL INPUT (0.0 .LT. PROB .LT. 1.0 ROUTINES CALLED: NONE AUTHOR: I.D.HILL DATE: 6 AUGUST 1979 SPLITN ROUTINE category: E48 title: subroutine SPLITN (ND,MODEL,ISTART,X,N,NCH,XBAR,SD,ALPHA,CHI,PCHI,IFAIL) language: FORTRAN 66 description: Fits a mixture of Normal (Gaussian) distributions by the method of maximum likelihood. Up to 10 distributions may be fitted. Maximum sample size is 2000. Outputs the estimated means, SDs and proportions for the putative populations, together with a Chi-square statistic which represents the likelihood ratio test for whether the current model (multiple Normal) is a better fit than one Normal. A significant chi-square therefore rejects the hypothesis of one Normal. You can also restrict the model to have equal population variances, using the parameter MODEL. Starting values will be provided automatically if ISTART is set to zero, otherwise the routine will expect to find ND positive values in the array SD and ND-1 values between 0 and 1 exclusive in the first ND-1 values of array ALPHA, where ND is the number of Normals you are fitting. Note that the solution may not be unique, due to the tricky nature of the 'likelihood surface' for this problem, but experience so far suggests that the routine is pretty robust and 'almost always' converges. If you wish, you can get more information about the progress of the fit by specifying output to a channel (NCH) between 1 and 63, e.g. 5 sends output to the terminal. method: Uses the simplex method of function minimisation to find the maximum likelihood solution. references: Royston, Flecknell & Wootton (Biol. Neonate 100-104, 42, 1982) parameters: ND INTEGER INPUT Number of Normal distributions to be fitted MODEL INTEGER INPUT Model: 0 = distinct variances 1 = equal variances ISTART INTEGER INPUT Starting values: 0 = automatic 1 = user-supplied X ARRAY IN/OUT Sample data to be analysed n.b. the data are sorted by the routine. N INTEGER INPUT Number of data values in X NCH INTEGER INPUT Channel number for output. No output if NCH<1 or NCH>64, else goes to NCH. XBAR ARRAY IN/OUT IN: may contain starting values for estimated means OUT:ML estimates of population means SD ARRAY IN/OUT IN: may contain starting values for estimated SDs OUT:ML estimates of population SDs ALPHA ARRAY IN/OUT IN: may contain starting values for estimated proportions OUT:ML estimates of proportions CHI REAL OUTPUT Likelihood ratio test statistic PCHI REAL OUTPUT P value for CHI IFAIL INTEGER OUTPUT Failure indicator: 0=SUCCESS 1=INVALID NO OF OBSERVATIONS (5<N<=2000) 2=INVALID NO OF DISTRIBUTIONS REQUESTED (1<ND<11) 3=TOO FEW DEGREES OF FREEDOM 4=MINIMIZATION FAIL: PARAMETER OUT OF RANGE 5=MINIMIZATION FAIL: TOO MANY ITERATIONS 6=INTERNAL: SHOULD NOT OCCUR (ESTIMATION OF START VALUES) 7=INTERNAL: SHOULD NOT OCCUR (SORT) 8-10=INTERNAL: SHOULD NOT OCCUR (CHI-SQUARE TAIL) 11=ZERO STARTING VALUES FOR ALPHA OR SD (ISTART=1 ONLY) common blocks: CCRE40 /XCOM(2000),NCOM,NDCOM,NCHCOM,NPCOM,MODCOM/ own variables: no routines called: E04CCF (calling P01AAF & X02AAF), FUNCT (calling X02AEF & X02AGF), G01BCF (calling P01AAF, S15ABF & X01AAF), M01ANF, MONIT, MSQ, RWSTRT (calling MSQ & X02ACF), X02AAF, X02ACF level: level ?? author: P.Royston & R.Wootton date: July 27, 1983 STAT13 ROUTINE CATEGORY: E20 TITLE: SUBROUTINE STAT13(T1,NF1,L1,INC,T2,NF2,L2,SS,ICH) LANGUAGE: FORTRAN DESCRIPTION: MARGINAL MEANS OF MULTI-WAY TABLE T1 IS A MULTI-WAY TABLE, STORED AS A 1-DIMENSIONAL ARRAY WITH THE 1ST FACTOR MOVING FASTEST. IT HAS NF1 FACTORS (NF1<15) WHOSE NUMBERS OF LEVELS ARE STORED IN THE ARRAY L1. THE ROUTINE CALCULATES A MARGINAL TABLE OF MEANS, T2, WITH NF2 FACTORS WHOSE NUMBERS OF LEVELS ARE STORED IN THE ARRAY L2. T2 IS DEFINED BY THE LOGICAL ARRAY INC, WHOSE ELEMENTS ARE .TRUE. IFF THE CORRESPONDING FACTOR OF T1 IS TO BE INCLUDED IN T2. SS IS CALCULATED AS THE SUM OF SQUARES OF THE ELEMENTS OF T2 MULTIPLIED BY THE NUMBER OF VALUES IN EACH MEAN, AS APPROPRIATE FOR AN ANALYSIS OF VARIANCE OF T1. ICH IS A PRINT CHANNEL. IF IT IS SET NON-NEGATIVE, T2 WILL BE OUTPUT IN L2(1) COLUMNS, HEADED BY THE CONTENTS OF INC. IF THE NUMBER OF LEVELS OF A PARTICULAR FACTOR IS SET NEGATIVE, PRINTING OF TABLES INVOLVING THAT FACTOR IS SUPPRESSED. PARAMETERS: T1 REAL ARRAY INPUT MULTI-WAY TABLE NF1 INTEGER INPUT NO OF FACTORS IN T1 L1 INTEGER ARRAY INPUT FACTOR LEVELS OF T1 INC LOGICAL ARRAY INPUT FACTORS TO BE INCLUDED IN T2 T2 REAL ARRAY OUTPUT MARGINAL MEANS TABLE NF2 INTEGER OUTPUT NO OF FACTORS IN T2 L2 INTEGER ARRAY OUTPUT FACTOR LEVELS OF T2 SS REAL OUTPUT SUM OF SQUARES FOR T2 ICH INTEGER INPUT PRINT CHANNEL ROUTINES CALLED: STAT7 LEVEL: LEVEL 1 AUTHOR: M.J.R.HEALY DATE: 27 JULY 1973 STAT14 ROUTINE CATEGORY: E21 TITLE: SUBROUTINE STAT14(T,NF,L,SS,TW,ICH) LANGUAGE: FORTRAN DESCRIPTION: ANALYSIS OF MULTI-WAY TABLE T IS A MULTI-WAY TABLE, STORED AS A 1-DIMENSIONAL ARRAY WITH THE 1ST FACTOR MOVING FASTEST. IT HAS NF FACTORS (NF<15) WHOSE NUMBERS OF LEVELS ARE STORED IN THE ARRAY L. THE SUMS OF SQUARES FOR THE MAIN EFFECTS AND INTERACTIONS ARE PLACED IN SS IN THE SEQUENCE (1),A,B,AB,C,AC,BC,ABC,D,... (SS(1)=0.0). TW IS A WORKING ARRAY AT LEAST AS LARGE AS T. ICH IS A PRINT CHANNEL. IF IT IS NON-NEGATIVE, THE MARGINAL MEANS TABLES OF T WILL BE OUTPUT FOLLOWED BY THE VALUES IN SS, THE LATTER IN 8 COLUMNS. PARAMETERS: T REAL ARRAY INPUT MULTI-WAY TABLE NF INTEGER INPUT NO OF FACTORS IN T L INTEGER ARRAY INPUT FACTOR LEVELS OF T SS REAL ARRAY OUTPUT SUMS OF SQUARES FOR T TW REAL ARRAY WORKSPACE ICH INTEGER INPUT PRINT CHANNEL ROUTINES CALLED: STAT13 CRMOVE LEVEL: LEVEL 2 AUTHOR: M.J.R.HEALY DATE: 27 JULY 1973 STAT19 ROUTINE CATEGORY: E27 TITLE: STAT19(X,D1,D2,N,N1,N2,A,S,ARMS,SRMS),STT19A LANGUAGE: FORTRAN DESCRIPTION: CALCULATES ESTIMATES OF MEAN AND STANDARD DEVIATION,AND THEIR ROOT MEAN SQUARED ERRORS,OF A NORMAL DISTRIBUTION GIVEN A TYPE I CENSORED SAMPLE. METHOD: ESTIMATES ARE LINEAR IN SUM OF OBSERVATIONS AND CENSORING POINTS. D1 IGNORED IF N1=0,D2 IGNORED IF N2=0 REFERENCE: J.G.SAW: BIOMETRIKA(1961) 48,367-377 PARAMETERS: X REAL ARRAY I/P DATA VALUES NOT CENSORED D1 REAL I/P LOWER CENSORING POINT D2 REAL I/P UPPER CENSORING POINT N INTEGER I/P NO. OF VALUES KNOWN I.E. IN X N1 INTEGER I/P NO. OF VALUES LT D1 N2 INTEGER I/P NO. OF VALUES GT D2 A REAL O/P ESTIMATE OF MEAN S REAL O/P ESTIMATE OF STANDARD DEVIATION ARMS REAL O/P ROOT MEAN SQUARED ERROR OF A SRMS REAL O/P ROOT MEAN SQUARED ERROR OF S 'OWN' VARIABLES: NO ROUTINES CALLED: STAT7,STAT8,STT19A,SNDEV LEVEL: LEVEL 2 AUTHOR: S.CHINN DATE: 29 JULY 1976 STAT7-7B ROUTINE CATEGORY: E12 TITLE: STAT7(X,N,AVE,SSQ) STAT7B(X,N,AVE,SSQ,S1,S3,S4) LANGUAGE: FORTRAN DESCRIPTION: MEAN AND POWER SUMS ABOUT MEAN. IF X IS AN ARRAY OF LENGTH N (.GE.1), CRSTAT7 & CRSTAT7B BOTH PRODUCE THE MEAN OF THE X-VALUES (AVE) & SUM OF SQUARES ABOUT THE MEAN (SSQ). IN ADDITION, CRSTAT7B PRODUCES THE SUM OF ABSOLUTE DEVIATIONS ABOUT MEAN (S1), AND SUM OF THIRD AND SUM OF FOURTH POWERS ABOUT MEAN(S3,S4). THE STANDARD DEVIATION CAN BE ESTIMATED AS: SQRT(SSQ/(N-1)) METHOD: FIRST THE MEAN (AVE) IS COMPUTED, THEN THE SUMS OF POWERS ABOUT THE MEAN. THIS METHOD IS ABOUT TWICE AS FAST FOR SSQ AND ABOUT 3 TIMES AS FAST FOR THE HIGHER SUMS OF POWERS AS THE 'RUNNING SUM' METHOD, WHICH UPDATES THE POWER SUMS FOR EACH NEW INPUT VALUE. PARAMETERS: X REAL ARRAY(N) INPUT SAMPLE VALUES N INTEGER INPUT SIZE OF SAMPLE AVE REAL OUTPUT MEAN OF VALUES IN X SSQ REAL OUTPUT SUM OF SQUARES ABOUT MEAN S1 REAL OUTPUT SUM OF ABSOLUTE DEVIATIONS ABOUT MEAN S3 REAL OUTPUT SUM OF CUBES ABOUT MEAN S4 REAL OUTPUT SUM OF FOURTH POWERS ABOUT MEAN LEVEL: LEVEL 0 ROUTINES CALLED: ABS AUTHOR: J.P.ROYSTON DATE: 5 APRIL 1978 STAT7A ROUTINE CATEGORY: E22 TITLE: STAT7A (X,N,AVE,SSQ) LANGUAGE: FORTRAN DESCRIPTION: EXACTLY AS STAT7 EXCEPT THAT ZERO AND NEGATIVE RESULTS ARE IGNORED. THE VARIABLE N IS RETURNED AS THE NUMBER OF RESULTS GREATER THAN ZERO FOUND IN X METHOD: AS STAT7 PARAMETERS: X REAL ARRAY INPUT SAMPLE VALUES N INTEGER INPUT/ SIZE OF SAMPLE OUTPUT NO. OF VALUES GREATER THAN ZERO IN X AVE REAL OUTPUT MEAN OF VALUES GREATER THAN ZERO IN X SSQ REAL OUTPUT SUM OF SQUARES ABOUT MEAN OF VALUES GREATER THAN ZERO IN X LEVEL: LEVEL 0 AUTHOR: G.GIBBS DATE: 15th DECEMBER 1981 STAT7M ROUTINE CATEGORY: E37 TITLE: STAT7M(X,N,VM,AVE,SSQ,N1) LANGUAGE: FORTRAN DESCRIPTION: MEAN & S.D.,ALLOWING FOR MISSING VALUES. IF ANY DATA VALUE IN ARRAY X EQUALS VM,IT IS OMITTED FROM THE MEAN(AVE) SUM OF SQUARES(SSQ) AND NO.OF OBSERVATIONS(N1). METHOD: BY DEVIATIONS AROUND FIRST NON-MISSING VALUE. PARAMETERS: X REAL ARRAY(N) INPUT ARRAY OF DATA N INTEGER INPUT NO.OF VALUES IN X VM REAL INPUT MISSING VALUE CODE AVE REAL OUTPUT MEAN (ZERO IF N.EQ.0) SSQ REAL INPUT SUM OF SQUARES ABOUT MEAN N1 INTEGER OUTPUT NO. OF VALUES IN X UNEQUAL TO VM. LEVEL: LEVEL 0 ROUTINES CALLED: NONE AUTHOR: J.P.ROYSTON DATE: 21.APRIL 1980 STAT8 ROUTINE CATEGORY: E13 TITLE: SUBROUTINE STAT8 (X,Q,P) LANGUAGE: FORTRAN DESCRIPTION: Q,P ARE THE LOWER AND UPPER TAIL AREAS OF A UNIT NORMAL DISTRIBUTION AT DEVIATION X. THE INTERNAL CALCULATIONS ARE PERFORMED IN DOUBLE PRECISION ALTHOUGH THE ARGUMENTS ARE PAST IN SINGLE PRECISION. THE RESULTS ARE GOOD TO 9 SIGNIFICANT FIGURES FOR ANY X. REFERENCE: ADAMS,A.G. (1969), COMP.J.,12, 197-198 PARAMETERS: X REAL INPUT DEVIATE Q,P REAL OUTPUT TAIL AREAS COMMON BLOCKS: NONE OWN VARIABLES: NONE ROUTINES CALLED EXP LEVEL: LEVEL 0 AUTHOR: M.J.R.HEALY DATE: 25TH JANUARY, 1972 TABCLR ROUTINE CATEGORY: L8 NAME: TABCLR PURPOSE: Clears all tab settings PARAMETERS: None AUTHOR: G Gibbs 27-Oct-81 Language: Macro-20 TABLE ROUTINE category: N9 title: subroutine TABLE (KEYWRD,KEYNUM,POINTS,STRINGS,FAIL) language: MACRO-20 purpose: This routine is used to build up a table of keywords or phrases for use by the KYWORD routine. Each call to TABLE adds one new keyword or phrase to a table stored in two arrays. One array is used to store all the text strings for each keyword, and the other array is used to store a list of pointers and associated values. The usual practice with these routines is to call them in a loop once only during the program's initialization phase, and then use the arrays without further modification. The array POINTS is supplied to the KYWORD routine, and it locates the strings array itself. Multiple tables may be built, but they must use different POINTS and STRINGS arrays. The tables may be used for interactive data input with KYWORD, or for primitive data bases using TBLOOK and TBRLOC (see below), which allow one to find strings in tables, or any combination of these three. The text phrase is supplied in KEYWRD, and may be a quoted string, or text in an array terminated by a zero word or byte. A value to associate with the phrase is supplied in KEYNUM, and will be returned by KYWORD to the caller when that phrase is typed. The value is limited to an 18-bit value. Thus, only numbers in the range -131072 to 131071 can be associated with keywords. Real numbers cannot be stored at all. This should not, in general, be a restriction. The points array is used to store the values and pointers. One word of this array is used for each keyword, plus three extra words for overhead. The STRINGS array is used to store the text strings themselves, and should be constructed to be long enough to hold each string end to end, plus one word for each string, plus 2 words of overhead. It is probably easiest just to make this array much too big. On the first call to TABLE, strings must be all zero, and POINTS should contain the size of the POINTS array in its first element (which will be altered.) Example ======= CALL TABLE('Aspirin',1,drugs,worksp,fail) CALL TABLE('Paracetamol',2,drugs,worksp,fail) CALL TABLE('Opium',3,drugs,worksp,fail) or:- CALL TABLE('Start',1,comand,worka,fail) CALL TABLE('Continue',2,comand,worka,fail) CALL TABLE('Stop',3,comand,worka,fail) then:- CALL KYWORD('Drug given >',drugs,drugno,fail) CALL KYWORD('Next action>'comand,cmdnum,fail) method: The TBADD% Jsys is used. parameters: keywrd Array or input The keyword or phrase for the string table keynum Any input Value to associate with keyword points Integer input/output Array of pointers and values strings Integer array output String storage fail Integer output Error code (see below) Error codes: 0 Success 13 Entry is already in table 12 Table is full own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 TABSET ROUTINE CATEGORY: L9 NAME: TABSET(COLUMN) PURPOSE: Places a tab stop at the specified column PARAMETERS: COLUMN Integer input Column number AUTHOR: G. Gibbs 27-Oct-81 Language: Macro-20 TBLOOK ROUTINE category: N11 title: subroutine TBLOOK(KEYWRD,TAB,KEYNUM,FAIL) language: MACRO-20 purpose: This routine can be used to lookup a character string in a keyword table created by the TABLE routine. It matches the string in much the same wasy as the KYWORD routine does - a string matches an entry if it is an unambiguous abbreviation of a keyword in the table. Letter case is not considered when searching for matches. The search is binary, and part of the operating system, and is thus extremely fast, even for tables containing many thousands of entries. This can be used to implement primitive (or not so primitive) data bases. The text phrase to look for is supplied in KEYWRD, and may be a quoted string, or an array or variable, with text terminated by a zero word or byte. The maximum length of this string is 349 characters. KEYNUM returns the keyword value associated with the keyword when TABLE was used to build the table of pointers. If fail is non-zero, KEYNUM will contain zero. Example ======= CALL TABLE('Aspirin',1,drugs,worksp,fail) CALL TABLE('Paracetamol',2,drugs,worksp,fail) CALL TABLE('Opium',3,drugs,worksp,fail) CALL TBLOOK('OP',drugs,drugno,fail) Returns 3 in drugno, as 'op' is an unambiguous abbreviation for 'opium'. method: The TBLUK% Jsys is used. parameters: keywrd Array or input The keyword or phrase to search string for tab Array Input Points array from TABLE routine. keynum Integer Output Value associated with keyword fail Integer output Error code (see below) Error codes: 0 Success 16 No such keyword in table 17 Keyword is ambiguous own variables: no routines called: none level: level 1 author: Kevin Ashley date: November 1982 TBRLOC ROUTINE category: N12 title: subroutine TBRLOC(POINTS,STRINGS) language: MACRO-20 purpose: This routine is used to relocate pointers in a keyword table after that table has been written to disk and read back in again, or after it has been copied from one array to another. The tables constructed by TABLE and used by KYWORD and TBLOOK contain absolute memory addresses as part of their pointers. Thus, if you copy them from one array to another, or if one run of a program writes the array out, and another reads it in again, these pointers may be askew. The TBRLOC routine merely relocates these pointers, using information stored there by the TABLE routine. This allows a program to use a keyword table as an index to a file or database. Say you have a number of records about patients, which you wish to look up via hospital number or patient name. You can keep a random access file sorted by hospital number, and use a binary search or index to retrieve the record by number. You may also use a keyword table, which stores patient names, and with them, the first record number for that patient. The keyword arrays are written out by the program whenever it exits, and read back in again when it starts. Example: CALL TABLE(PATNAM,PATPNT,PATSTR,FAIL) .... Many times WRITE(20) PATPNT !unformatted write of pointers WRITE(20) PATSTR !and strings Later.. in another program perhaps READ(20) PATPNT !Read pointers READ(20) PATSTR !Read strings from disk also CALL TBRLOC(PATPNT,PATSTR) !Relocate pointers. parameters: points Array Input/output Points from TABLE routine strings Array Input/output Strings from TABLE routine own variables: no routines called: none level: level 1 author: Kevin Ashley date: November 1982 TEXTIN ROUTINE category: N1 title: subroutine TEXTIN (prompt,answer,fail,back,length,help,defalt) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads an arbitrary text string. A default can be supplied by the program, and the routine also returns the number of characters read. It is possible to specify a maximum number of characters to read. Text strings are terminated with a null character, and this null must be allowed for in calculations of the array size of the answer. If the first element of the ANSWER array is set to a non-zero integer value less than 350 on entry to the routine, it is used as a limit on the number of characters to accept. Otherwise, the limit is 350 char- acters, which could overflow many arrays. The restriction on the limit being non-zero and < 350 means that if the array contains left-over text, this will not be interpreted as a meaningless limit. This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. This routine is unable to read a string which is an abbreviation of the words EXIT or UNKNOWN. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user stringanswer Array outputTextmtypedrbygusergth fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. length Integer output *Optional* Length of text string. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of "text string" will be used if you do not supply one. defalt Array or input *Optional* string Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL TEXTIN('Name:',PATNAM,FAIL) is valid, as is CALL TEXTIN('Name:',PATNAM,FAIL,*10,NAMLEN,'Enter patient''s & name') which supplies a label to return to if the user types ^ (the label is 10), stores the length of the name in NAMLEN, and outputs a help message if a question mark is typed. No default has been supplied, however. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Invalid input (should not occur) 2 Not confirmed (this is only possible if RETRYS is set to a non-negative value and the user types EXIT, UNKNOWN or ^ and then types rubbish after the command. Normally it cannot occur.) 15 Maximum length of input exceeded. This error can only occur if a maximum length was specified by setting word 1 of array answer to a value >0 and < 350 before calling TEXTIN. -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),cmdblk(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 VT-SUBROUTINE-CONVENTIONS ROUTINE All terminal control routines may be called from MACRO as well as high-level languages. The MACRO entry points are the same as the FORTRAN entry points, but the names are preceded by a dollar sign, thus $VTINIT, $VTEND, etc. The impure storage may be kept in the user's own reserved area. To do this, place the following statements in your program - SEARCH VTMAC $TITL==0 VTSTOR This should preceed all relocatable code. Alternatively, call the FORTRAN VTINIT, which reserves its own impure area. Parameters are passed in the scratch acs 1,2 etc. as needed. VTATR may only have one parameter when called from MACRO. Acs 1-4 may be destroyed as usual by all routines. You are advised not to fiddle with the JFN mode word or CCOC word during program execution, unless you leave the altered bits alone. Where references are made to quoted string arguments from other languages, the macro programmer is expected to provide a byte pointer (which may be in implicit form) to an ASCIZ string. VT132 ROUTINE CATEGORY: L21 NAME: VT132 PURPOSE: Sets the terminal to 132-column width PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VT80 ROUTINE CATEGORY: L20 NAME: VT80 PURPOSE: Sets the terminal to 80-column width PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTATR ROUTINE CATEGORY: L26 NAME: VTATR(N1,N2,....) PURPOSE: Sets or clears the character attributes. These affect whether characters should be typed in reverse video, blinking, bold or underlined, or any combination of these. Each attribute is given a type code - 1 for bold, 4 for underline, 5 for blink and 7 for reverse. You may specify as many or few parameters as you wish. Successive calls are cumulative. Specify 0 to clear all attributes and return typeout to normal. PARAMETERS: N1,N2,... Integer input Type codes AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTBIG ROUTINE CATEGORY: L28 NAME: VTBIG(' string of characters') or VTBIG(ARRAY) PURPOSE: Types a text string in double height, double width chars. PARAMETERS: ARRAY Input - either a quoted string ('string') or an array name, which contains the characters terminated by a zero byte or word. AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTCBL ROUTINE CATEGORY: L10 NAME: VTCBL PURPOSE: Clears from the beginning of line to the cursor PARAMETERS: None AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTCBS ROUTINE CATEGORY: L12 NAME: VTCBS PURPOSE: Clears from the start of screen to the cursor PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTCLIN ROUTINE CATEGORY: L11 NAME: VTCLIN PURPOSE: Clears the entire line containing the cursor PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTCLS ROUTINE CATEGORY: L13 NAME: VTCLS PURPOSE: Clears the entire screen PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTDWN ROUTINE CATEGORY: L16 NAME: VTDWN(N) PURPOSE: Moves the cursor down the specified number of places PARAMETERS: N Integer input Number of places to move AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTEND ROUTINE CATEGORY: L30 NAME: VTEND PURPOSE: Called at the end of a program to restore the JFN mode word, so allowing TOPS-20 to continue to remember the terminal width. Not essential, but recommended. PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTGOF ROUTINE CATEGORY: L33 NAME: VTGOF PURPOSE: Turns off VT100 graphics characters after VTGON has turned them on. PARAMETERS: None. AUTHOR: K. Ashley 17-Dec-81 Language: Macro-20 VTGON ROUTINE CATEGORY: L32 NAME: VTGON PURPOSE: Used to turn on the VT100's graphics character set. These are useful for drawing graphs or line figures, or displaying certain mathematical symbols. See the VT100 guide for fuller documentation. PARAMETERS: None. AUTHOR: K. Ashley 17-Dec-81 Language: Macro-20 VTINIT ROUTINE CATEGORY: L0 NAME: VTINIT PURPOSE: Sets up the environment for the other routines. This routine MUST be called first, otherwise you will receive errors at link time and at runtime. PARAMETERS: None AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTIUP ROUTINE CATEGORY: L19 NAME: VTIUP PURPOSE: Performs a "reverse index" - the cursor is moved up one place, but, unlike CURUP, if the top of the scrolling region is reached, the screen is scrolled down. A reverse linefeed, in effect. PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTJMP ROUTINE CATEGORY: L24 NAME: VTJMP PURPOSE: Sets jump scroll mode PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTLED ROUTINE CATEGORY: L7 NAME: VTLED(N) PURPOSE: Lights the specified LED above the keyboard, or clears all leds PARAMETERS: N Integer input LED number, or 0 to clear all AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTLFT ROUTINE CATEGORY: L14 NAME: VTLFT(N) PURPOSE: Moves the cursor left the specified number of places PARAMETERS: N Integer input Number of places to move AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTORG ROUTINE CATEGORY: L23 NAME: VTORG(FLAG) PURPOSE: Alters the setting of "origin mode". This defines whether cursor addresses are relative to the scrolling region. If origin mode is off, cursor addresses are relative to the whole screen. If origin mode is on, cursor addresses are relative to the scrolling region, (1,1) is the top left of the scrolling region, and the cursor cannot move outside the scrolling region. PARAMETERS: FLAG Integer input 0=off, 1=on AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTRES ROUTINE CATEGORY: L18 NAME: VTRES PURPOSE: Restores cursor position and attributes saved by VTSAV PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTRIT ROUTINE CATEGORY: L15 NAME: VTRIT(N) PURPOSE: Moves the cursor right the specified number of places PARAMETERS: N Integer input Number of places to move AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTSAV ROUTINE CATEGORY: L17 NAME: VTSAV PURPOSE: Saves the current cursor position and attributes PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-81 Language: Macro-20 VTSCRN ROUTINE CATEGORY: L22 NAME: VTSCRN(FLAG) PURPOSE: Sets the screen background to light or dark PARAMETERS: FLAG Integer input 0=light, 1=dark AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTSMTH ROUTINE CATEGORY: L25 NAME: VTSMTH PURPOSE: Sets smooth scroll mode PARAMETERS: None. AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 VTTY ROUTINE CATEGORY: L34 NAME: VTTY(TERMIN) PURPOSE: This routine can be used to tell the terminal routines (PUTCRS, CLEOS, etc. ) to use a terminal other than the one you are logged in on. This is useful to debug a program which uses the screen in a complex manner, as you can still use the job's own terminal for debugging, while the screen input/output is happening on another terminal. One supplies the terminal name as a parameter to switch I/O, as in CALL VTTY('TTY24:'). If no parameter is supplied, or the parameter consists of blanks, then output is switched back to your controlling terminal. This routine should be called before VTINIT. PARAMETERS: TERMIN String constant or Input Name of terminal to character variable. which output is to be redirected AUTHOR: K. Ashley 2-Aug-83 Language: Macro-20 VTWID ROUTINE CATEGORY: L27 NAME: VTWID('TEXT string') or VTWID(array) PURPOSE: Types a text string in double width characters. PARAMETERS: text array or quoted string input. This can be a string as 'hello there' or an array containing the characters. If an array, it must be terminated by a zero byte or word. AUTHOR: K. Ashley 27-Oct-80 Language: Macro-20 WCOEF ROUTINE category: E45 title: subroutine wcoef(a,n,n2,eps,ifault) language: fortran description: Set up WEXT, must be called once for a given sample size, before WEXT is called. method: references: Applied Statistics Vol.31 no.2 1982, algorithm AS 181 parameters: a real output coefficients for calculation of w, set array by WCOEF n integer input sample size n2 integer input [n/2] 1/2 n if n even 1/2(n-1) if n odd eps real output minimum possible value of w set by WCOEF ifault integer output fault indicator, 3 if n2.ne.[n/2] 2 if n.gt.2000 1 if n.le.2 0 otherwise common blocks: none own variables: no routines called: nscor2 level: level 2 author: P.Royston date: February 1983 WEXT ROUTINE category: E44 title: subroutine wext(x,n,ssq,a,n2,eps,w,pw,ifault) language: Fortran description: Calculates the Shapiro and Wilk W test for detecting departures from normality. The data vector (X) must be ordered before calling WEXT. For a given sample size N, call the auxiliary subroutine WCOEF once before using WEXT. Calculations are still performed if N>2000, but the significance level PW for the test cannot be as accurate as for lower N. references: Applied Statistics Vol.31 no.2 1982, algorithm AS 181 parameters: x real input ordered sample values n integer input sample size ssq real input sum of squares of data about mean a real input coefficients for calculation of w, set array by WCOEF n2 integer input [n/2] 1/2 n if n even 1/2(n-1) if n odd eps real input minimum possible value of w set by WCOEF w real output W statistic pw real output significance level of W ifault integer output fault indicator, 4 if data not sorted or are all equal 3 if n2.ne.[n/2] 2 if n.gt.2000 1 if n.le.2 0 otherwise common blocks: none own variables: no routines called: stat8,poly level: level 1 author: P.Royston date: February 1983 YESNO ROUTINE category: N6 title: subroutine YESNO (prompt,answer,fail,back,help,defalt) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads a YES, NO or UNKNOWN from the terminal. A default may be supplied by the calling program, which will be used if the user types return or escape. The returned value may be interpreted as logical, in which case YES is true, and NO or UNKNOWN are false, or integer in which case YES is -1, NO is 1 and UNKNOWN is 0. A default can be supplied by the program, which is used if the user types escape or return. This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, help file, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string answer Integer or output Returned value logical fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. A help message of "one of the following: NO UNKNOWN YES" will be used if you do not supply one. defalt Array or input *Optional* string Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL YESNO('New call:',YEA,FAIL) is valid, as is CALL YESNO('New call:',YEA,FAIL,*10,NAMLEN,'Enter whether this & is a new call','YES') which supplies a label to return to if the user types ^ (the label is 10),stores the true or false answer in YEA, and outputs a help message if a question mark is typed. YES is assumed if nothing is entered. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Invalid input (ie not YES NO or UNKNOWN) 2 Not confirmed (this indicates superfluous input after the word.) 10 Does not match keyword -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),CMDBLK(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 LP-PLOTTING CATEGORY: *D D PLOTTING (LINE PRINTER) ----------------------- 1 CRC161 CALCULATES AXIS PARAMETERS FOR PLOTTING ROUTINE CRC561. 2 CRC162 PLOTS AXIS FOR PLOTTING ROUTINES CRC362 AND CRC561. 3 CRC163 CALCULATES AXIS PARAMETERS FOR PLOTTING ROUTINE CRC362. 4 CRC361 CALCULATES AXIS PARAMETERS FOR ROUTINE CRC561 TO FIT ON A PAGE. 5 CRC363 PLOTS HISTOGRAM. 7 CRC561,CRC362. LINE PRINTER PLOT (TWO WAY DISTRIBUTION) 8 NPLOT NORMAL PLOT. 9 CPLOT HALF-NORMAL PLOT OF CORRELATION COEFFICIENTS. 10 CPLOT2 SCATTER DIAGRAM WITH STATISTICS 11 NPLOT1 NORMAL PLOT (REVISED VERSION OF NPLOT) 12 CRLHST PLOTS HISTOGRAM ACROSS PRINTER PAGE 13 NRMPLT Normal plot (latest vesion [1983]) NRMPLT ROUTINE category: D8 title: NRMPLT (x,n,nplus,nchan,ifault) language: Fortran description ** note: updated version of nplot; parameter list changed ** This subroutine plots (on channel nchan) normal plots for the n values of the floating point array x. The ordered values of x are plotted on the y-axis. On the x-axis is plotted the normal equivalent deviate corresponding to the proportion pi = (i-1/3)/(n+1/3) for the i'th ranked element of x. Plotting is done by sub-routine crc 561 and the normal equivalent deviates calculated by function sndev. Values of mean and sd are printed after the plot on channel nchan, together with skewness, kurtosis, shapiro and wilk's w statistic and their p values as tests of departure from normality. Note that the array x must be dimensioned to at least 2.5 times n (it contains work space). The first n elements of x contain the data to be used. They will be sorted by the routine into ascending order. parameters: x array(nplus) vector of observations n integer number of observations nplus integer at least 2.5*n, dimension of x nchan integer output channel number. ifault integer fault code: 0 - ok 1 - n<3 2 - n>2000 (not fatal, no w-statistic) 3 - nplus too small 11-16 - error from pskew 21-26 - error from pkurt routines called: crc154,crc561,stat7,wcoef,wext,pskew,pkurt,crshpe, function sndev level: level 2 authors Klim McPherson/Patrick Royston date 18 Nov 1983 CRSIL ROUTINE CATEGORY: L29 NAME: CRSIL(FLAG) PURPOSE: Turns terminal echoing of typein on or off, depending on the value of the FLAG parameter PARAMETERS: FLAG Integer input 1=off,0=on **NOTE** This used to be incorrect. It is now RIGHT. AUTHOR: K. Ashley 1-Feb-81 Language: Macro-20 crgraf routine category: c37 title: subroutine crgraf(i,x,y,n,isel) language: fortran description: graph drawing routine no. 4 This draws graph axes and graphs of various types. Multiple plots may be drawn on one set of axes with mutiple calls to this routine, with i set negative for the final plot on a given set of axes. The graph axes are drawn when no axes have previously been drawn or the previous graph has been finished, i.e. any call to crgraf can draw the axes. These axes will be 'beautified' unless stated otherwise, that is to say the number of intervals and the axes limits will be altered to provide acceptable values along the axis from the values supplied in x and y. These may be numbers calculated by you (in an array of 2) with a call which only draws the axes, if you wish. A graph is finished by setting the graph type or histogram type (in crhist) negative. You have further control over the plotting with other routines to modify the default settings :- crgrit initialises the plotting crgrax controls the type of axes crgrlb inserts labels crhist draws histograms parameters: i integer i/p graph type. Set negative to terminate the current graph. The types are:- 1=draws axes only (x and y axes not beautified) 2=scatter plot 3=scatter plot with points joints in order presented 4=scatter plot and linear regression line of y on x fitted 5=scatter plot and quadratic polynomial fitted 6=scatter plot and cubic polynomial fitted 7=scatter plot and linear regression line of x on y fitted 10=draws axes only (x axis only beautified) 11=draws axes only (y axis only beautified) 12=draws axes only (both axes are beautified) 13-17 are the same as 3-7 but without the scatter plot. x,y real i/p input data arrays arrays n integer i/p no. of points in input arrays isel integer i/p this is a two digit selector. for graphs where only axes are drawn (i=1,10,11,12) the 1st digit is redundant and the 2nd digit indicates the type of axis offset required; 0-no offset, 1-y axis pulled away, 2-x axis pulled away, 3-both axes pulled away for all other graphs the 1st digit indicates the line type for any lines that are to be drawn (not axes) 0-solid,1-dotted,2-dashed,3-chained. the 2nd digit indicates the marker to be used in the scatter plot. reference: docas report on plotting package routines called: crmnx,crgrer,crpoly,crmove,crfunc,crscal, crax5,crax5f,crax5g,crax5l + gino-f and ginograf routines level: level 3 author: L.J.Dobson/G.Gibbs date: December 1981 crax5-f-g routine category: c32 title: crax5(x,y,alen,angle,nint,ia,itype,ltick,i1,i2, vmin,vmax) crax5f(x,y,alen,angle,nint,ia,itype,ltick,i1,i2, vmin,vmax,func) crax5g(x,y,alen,angle,nint,ia,itype,ltick,i1,i2, vmin,vmax,func) crax5l(x,y,alen,angle,nint,ia,itype,ltick,i1,i2, vmin,vmax) language: fortran description: alternative axis plotting routines, with different ways of numerical labelling. crax5 produces a normal linear axis crax5f produces log spacing of ticks, with power labels crax5g produces equal spacing of the ticks. crax5l produces log spacing of ticks, with nicer labels parameters: x,y real i/p coordinates, (in plotter space), of start of axis alen real i/p length of axis (mm in plotter sp.) angle real i/p angle of axis (in degrees(0. or 90.)) nint integer i/p no. of intervals along axis (if negative (crax5 only) gives a category axis with nint categories) ia int.array i/p text to be used as label along axis or quoted (terminated with '*.' as for a string. string in crgrlb -c35) e.g. 'Serum t3*.' itype integer i/p orientation of values against ticks and position of label. 0- normal x-axis with end label 1- normal x-axis with centred label 2- normal y-axis with end label 3- normal y-axis with centred label ltick integer i/p controls the orientation and labelling of ticks along axis: if +ve, ticks on natural side if -ve, ticks on opposite. i1 integer i/p field width (including any decimal point) of numerical labels i2 integer i/p no. of digits after decimal point of numerical labels vmin, real i/p minimum and maximum coorinate vmax values to be plotted against axis func real i/p user defined mapping function, function taking as an argument a single real value (must be declared as external in the calling segment). this function must be the inverse of the transform used on the data being plotted.(note exp10(x) is available in the crc library) reference: docas report on plotting package compressed integers: yes fortran traceable: level 1 routines called: crax5- crax5g,ipk,xnull crax5f- ipk crax5g- ipk crax5l- ipk + gino-f and ginograf routines level: crax5- level 2 crax5f,g & l - level 1 author: G.Gibbs date: January 82 CRGRAX ROUTINE category: C36 title: subroutine crgrax(i,alen,nint,ntick,nf,nd,itype) language: fortran description: graph drawing routine no. 3 this alters the axis parameters from their default or previous values. the default values for the parameters are shown in brackets, < >. parameters: i integer i/p axis type. 1= x axis, 2= y axis alen real i/p axis length in mm. <half available size> If zero is supplied the default will be used. nint integer i/p specifies the no. of intervals, if it is negative a category axis is given <5> ntick integer i/p controls the orientation and labelling of ticks along the axis, it will label every ntick'th tick. 0 will suppress the tick marks if +ve ticks are on natural side if -ve they are on the opposite <1> nf integer i/p specifies the maximum numeric label field width, including any decimal point and sign.<6> nd integer i/p specifies the no. of digits required after the decimal point for numeric labels. <1> itype integer i/p specifies the type of axis required <0> 0= normal or linear transformed } { 1= log10 (log spaced ticks)} always by the } { 2= log (log spaced ticks) } beautified user before } { 3= log10 (equal spaced ticks) calling } { 4= log (equal spaced ticks) } { 5= equally spaced tickes, values printed defined by user's function, myaxfn. a version is available in the library suitable for hours of the day REAL FUNCTION MYAXFN (X) MYAXFN=AMOD(X,24.0) RETURN END supply untransformed } { 6= log10 (log spaced ticks, nice labels) data } { 7= log10 ( -- ditto -- power labels) reference: DoCaS report on plotting package routines called: crgrer level: level 1 author: L.J.Dobson date: December 1977 CRGRWO ROUTINE category: C42 title: subroutine crgrwo language: Fortran description: Terminate a graph being drawn by crgraf or crhist. This provides an alternative to setting the first argument negative in a call to either crgraf or crhist, in the final call to that routine. Calling this routine may be easier in circumstances where many lines are being plotted on one set of axes, and some may consider it to be better style anyway. parameters: none common blocks: plghp routines called: crgrer level: level 2 author: G.Gibbs date: August 1984 1 LOGICAL AND SHIFT OPERATIONS. 15 PK CHARACTER INSERTION(ASCII code). 16 ICRTLU TABLE LOOK-UP BY BINARY SEARCH. 19 CRCLR CLEARING AN ARRAY 21 ICRCH7 INTEGER TO CHARACTER DIGITS CONVERSION 24 CRON,CROFF,CRTEST BIT SWITCHING ROUTINES 25 ICRSCH SEARCH FOR A CHARACTER STRING 26 RIGHT Returns the right half of a machine word, sign extended 27 LEFT Returns the left half of a machine word, sign extended 28 GETADR Returns the absolute address of its argument. 29 TBLOOK Lookup a table of character strings by binary search. 30 CRSOUT Send a character string to the terminal. 31 CRSINT Move characters from an array to a character variable. 32 CRAISE Raise a character string to upper case. CRAISE ROUTINE category: A32 title: character function craise(lower) language: macro description: Returns a character variable raised to upper case. Fortran 77 only. method: uses the hardware instruction MOVST (MOVe String Translated). parameters: name type i/o description lower character input character variable to be raised to upper case example: character*80 line,upper,craise read (unit=5,fmt='a') line write (unit=5,fmt=*) craise(line) or... upper=craise(line) routines called: none level: level 0 author: G.Gibbs date: March 1981 DATES CATEGORY: *J J DATE HANDLING --------------- 4 DATE Today's date in characters 15 JDATE Convert Julian day no. to calendar date 16 JDAY Convert calendar date to Julian day no. 17 JTODAY Today's Julian day no. 18 CRMTOC Convert integer month to characters 19 CRNTOI Convert character date(numeric) to 3 integers 20 CRDTOI Convert character date to 3 integers 21 CRDOUT Output date from 3 integers 22 CRJOUT Output date from Julian day number 23 EASTER Julian day number of Easter Sunday in specified year 24 MONTH Returns month in characters CHKLET ROUTINE category: K28 title: character function chklet(number) language: Fortran 77 description: returns the check letter corresponding to the hospital number supplied. parameters: number integer input the hospital number routines called: none example: character*1 chklet,hoslet integer hosnum accept (fmt='i,a') hosnum,hoslet if (hoslet.ne.chklet(hosnum))then type *,'Check letter does not match' end if author: G.Gibbs date: June 1984 MISCELLANEOUS CATEGORY *K MISCELLANEOUS ------------- 1 GENCHK Generates check letters 8 CRUSER User's name obtained 9 CRHALT Halts program with no messages 10 CREMOT Plots files on Oki printer or Calcomp plotter 11 CRRSCN Obtains EXEC command line for program 12 CRCMD Allows a program to execute EXEC commands 13 CRLDAV Returns the 1-minute, 5-minute and 15-minute load averages. 14 CRMAIL Allows a program to send MAIL to other users. 15 CRWAIT Suspends program execution for a number of milliseconds. 16 CROOM Returns space available in directory and on whole disk. 17 CRLBOP Opens a LBR-format library file for reading 18 CRLBRD Reads a record from a file opened by CRLBOP 19 CRSIZE Returns the size of a file in pages and bytes. 20 LCRBAT Returns whether running in batch or not. 21 CRXPNG Expunges a disk directory 22 CRRUN Runs a program and passes a command line. 23 ICRNTM Returns a programs run time. 24 DOJSYS Executes a TOPS-20 monitor call (!) 25 GETDDT Loads DDT and causes an unsolicted breakpoint. 26 CRTIMR Calls a specified routine when a time limit expires. 27 SIMINP Simulate terminal input 28 CHKLET Returns the check letter for a hospital number CRDTOI ROUTINE Category: J20 Title: CRDTOI (ICDATE,IDAY,MONTH,IYEAR) Language: MACRO Descripton: Converts TOPS 20 character date to 3 integers. A date in character form (e.g. '22-Nov-80' ,as returned by the DEC routine DATE ),is converted into 3 integer numbers (i.e. 22 11 1980 ). The routine will accept any reasonable format for the date, including any unambiguous truncation of the month in characters or the month as a number, in the latter case the month MUST be after the day. Non valid dates will return 3 zero values as will a date prior to 17 November 1858. It will accept input directly from your terminal if the first argument is set to 1. In this case it is recomended that a prompt be given before calling the routine and a responce is given afterwards, perhaps a call to CRDOUT q.v. e.g.:- TYPE 50 50 FORMAT ('ENTER THE DATE >>') CALL CRDTOI (1,IDAY,MONTH,IYEAR) CALL CRDOUT (1,IDAY,MONTH,IYEAR,2) Method: The routine uses the monitor call IDTNC% (Monitor Call Reference Manual 3-177) Parameters: ICDATE array or INPUT Date in character form character IDAY integer } The 3 parts MONTH integer } OUTPUT of the date IYEAR integer } See also: DATEIN Author: G.Gibbs Date: April 1981, character variables July 1984 CRLBRD routine Category: K17 Title: CALL CRLBRD(ARRAY,RECLEN,JFN,START,ERR) Language: MACRO-20 Description: Reads a record from a library file opened by CRLBOP. The record returned is padded with trailing blanks if a character variable is used, but not otherwise, and includes the carriage return/linefeed combination. If ARRAY is integer it receives the record in A5 format, RECLEN the record length in characters (not including the CR/LF). JFN and START should be preserved between calls - they are initially supplied by CRLBOP, and are updated on each call to CRLBRD. ERR is 0 for success, else is positive. Parameters: ARRAY Output Array or Receives record from file character RECLEN Output Integer Length of record in characters JFN Input Integer Job file number from CRLBOP START Input/output Integer Address of next record from CRLBOP ERR Output Integer Return status Errors: 0 - OK 1 - end of file 2 - some error reading file Author: Kevin Ashley Level: 0 Date: 11 Aug 1982, character variables July 1984 CRRSCN ROUTINE CATEGORY: K11 NAME: CRRSCN(COMAND,LENGTH) LANGUAGE: MACRO-20 AUTHOR: K. Ashley 8-Oct-81 PURPOSE: The CRRSCN routine enables a program to "rescan" the TOPS-20 command that caused the program to be run. This means that a program can be written to behave more like a TOPS-20 command and can be invoked from indirect command files. It eases the burden on users of your program who do not have to distinguish so much between programs and commands. For instance, say you have a program called REDUCE which takes a number of input data files and produces one output file. The user could invoke your program with the command @REDUCE LPT:=INPUT1.DAT,INPUT2.DAT indicating that they wished the input to come from the two files on the right of the equals sign, and the output to the lineprinter. On calling CRRSCN, the array or character variable COMAND would receive that command in full, and you can parse it as you wish. The second parameter, LENGTH, is an integer variable that receives the length of the command in characters. PARAMETERS: COMAND array or output the line of text typed in to character invoke the program calling this routine LENGTH integer output number of characters in COMAND LEVEL: level 0 SIMINP ROUTINE category: K27 title: subroutine SIMINP(TEXT) language: Macro 20 description: Simulate input from the terminal. The text of the argument will apear to the program as if it were typed in at the terminal. This may be of use if your program is running another program, and wishes to send data to it, or if some segment of code which you are unable to alter always requires the same input. Any input which the user may have typed ahead will be thrown away. Multiple lines should be separated by the backslash character "\". e.g. call siminp('LINE ONE\LINE TWO\LINE THREE') N.B. Do not use from batch. method: The routine uses the monitor calls CFBIF%, STI% and GETJI% references: Monitor Calls Reference Manual parameters: text array input text to be input from terminal or character common blocks: none own variables: no routines called: none level: level 1 author: Paul O'Riordan/Geoff Gibbs date: Jan-83 GENCHK ROUTINE category: K1 title: GENCHCK (IUN,ICHL) language: Fortran description: The check letter is derived by taking n-th of a set of selected letters of the alphabet, where n is the remainder on dividing the unit number by 17. The check letter is stored in the first character position of ichl i.e. in a1 format. Look-up table. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 A B D E F H J K L M N P R S T V X parameters: iun integer input nph unit number ichl integer output check letter. routines called: none level: level 0 see also: the character function CHKLET in the CRC library author: G.Gibbs date: 2nd June 1981 CHARACTERS CATEGORY: *A A. BIT,CHARACTER AND WORD MANIPULATION. ------------------------------------- 1 CRMVCH MOVE CHARACTERS 2 COPY COPY CHARACTERS 3 ICOMP COMPARE CHARACTER STRINGS 4 CRMOVE COPY WORDS 6 ICRCH2 CHARACTER EXTRACTION(ICL code, limited life). 7 ICRCH3 CHARACTER INSERTION(ICL code, limited life). 8 ICRCH4 CHARACTER DIGITS TO INTEGER CONVERSION 11 IPK CHARACTER EXTRACTION(ASCII code). 12 NPH2 TABLE LOOK-UP BY SERIAL SEARCH 13 NPH3 BIT PATTERN EXTRACTION. 14 NPH11 LOGICAL AND SHIFT OPERATIONS. 15 PK CHARACTER INSERTION(ASCII code). 16 ICRTLU TABLE LOOK-UP BY BINARY SEARCH. 19 CRCLR CLEARING AN ARRAY 21 ICRCH7 INTEGER TO CHARACTER DIGITS CONVERSION 24 CRON,CROFF,CRTEST BIT SWITCHING ROUTINES 25 ICRSCH SEARCH FOR A CHARACTER STRING 26 RIGHT Returns the right half of a machine word, sign extended 27 LEFT Returns the left half of a machine word, sign extended 28 GETADR Returns the absolute address of its argument. 29 TBLOOK Lookup a table of character strings by binary search. 30 CRSOUT Send a character string to the terminal. 31 CRSINT Move characters from an array to a character variable. 32 CRAISE Raise a character string to upper case. 33 CRUPER Raise a character string to upper case. graph-plotting category: *C C Graph Plotter Routines. ------------------------ 29 CRBARS draws histogram bars 30 CRHATCH hatches or shades a rectangular area 32 CRAX5, 5F, 5G and 5L alternative axis plotting routines 34 CRGRIT (Graph drawing routine no. 1) initialises graph drawing and resets to default values 35 CRGRLB (Graph drawing routine no. 2) sets up a label of the required type 36 CRGRAX (Graph drawing routine no. 3) alters axis parameters from default or previous values 37 CRGRAF (Graph drawing routine no. 4) draws axes and various types of graphs 38 CRHIAX (Graph drawing routine no. 5) sets up extra parameters for plotting histograms 39 CRHIST (Graph drawing routine no. 6) draws axes and various types of histogram 40 PNPLOT produces up to 5 normal plots on the plotter 41 CRERBR draws error bars 42 CRGRWO Terminates a plot drawn by crgraf or crhist KYALOW ROUTINE category: N12 title: subroutine KYALOW (allows) language: MACRO-20 purpose: This routine is used only in conjunction with the KYWORD routine. It allows special characters to be considered valid parts of keywords that would otherwise be rejected. For instance, KYWORD does not usually allow the character "^" in keywords (although they can be placed in a table with the TABLE routine without problems.) However, attempting to read one of these keywords using KYWORD could easily produce an error, either because two keywords were only distinguishable by an up-arrow, or because KYWORD complained of excess input on the line (all the characters following the uparrow.) However, a call to KYALOW, with the parameter being a text string, character expression or integer array containing an uparrow will make all following calls to KYWORD accept the "^" character. See KYDALW for methods of preventing certain characters being allowed as part of keywords (for instance, if you want to use the dot or full stop character to separate keywords.) Calling KYALOW with a null string , or a value of zero, causes the keywords breakset (the characters allowed) to be reset to their default settings. These are: All alphanumerics are permitted, and also the following special characters: "-" (hyphen) "_" (underline "." (full stop) "#" (hash or pound) "*" (asterisk) "(" (open round bracket) " " (space) "/" (solidus) "%" (percent sign) ":" (colon) "'" (single quote) ")" (close round bracket) parameters: allows Character expression Input The characters to or array be added to those permitted by KYWORD or null to reset defaults. Examples: CALL KYALOW('+=') !Permits plus and equals as !part of strings CALL KYALOW(0) !Resets defaults routines called: none level: level 1 author: Kevin Ashley date: October 1984 KYDALW ROUTINE category: N13 title: subroutine KYDALW (allows) language: MACRO-20 purpose: This routine is used only in conjunction with the KYWORD routine. It stops characters being considered valid parts of keywords that would otherwise be allowed. For instance, KYWORD usually allows the character "." in keywords. If you wish dots or full stops in your input to delimit different keywords, you can call KYDALW with a string containing dot as the parameter, and KYWORD will now terminate keyword input on dot, as well as the usual characters. See KYALOW for methods of allowing certain characters being part of keywords (for instance, if you want to use the equals or plus sign character as part of keywords.) Calling KYDALW with a null string , or a value of zero, causes the keywords breakset (the characters allowed) to be reset to their default settings. These are: All alphanumerics are permitted, and also the following special characters: "-" (hyphen) "_" (underline "." (full stop) "#" (hash or pound) "*" (asterisk) "(" (open round bracket) " " (space) "/" (solidus) "%" (percent sign) ":" (colon) "'" (single quote) ")" (close round bracket) parameters: allows Character expression Input The characters to or array be removed from those permitted by KYWORD or null to reset defaults. Examples: CALL KYDALW('. ') !Stops dot and space being part !of valid keywords CALL KYDALW(0) !Resets defaults routines called: none level: level 1 author: Kevin Ashley date: October 1984 TIMEIN ROUTINE category: N14 title: subroutine TIMEIN (PROMPT,SECNDS,FAIL,BACK,LOWER,UPPER,HELP,DEFALT) language: MACRO-20 purpose: The routine prompts the terminal user with a supplied string, and then reads a time, typed in any reasonable format. Times may be 24 hour format, separated by colons or spaces, or may be 12-hour with trailing AM or PM, and possibly also 3-letter time zone (such as GMT or GDT for greenwich daylight time, often known as BST.) The routine returns the number of seconds since midnight, local time. If a time zone is supplied, the seconds are relative to that time zone (ie 00:01 always returns 60 seconds, even if it is 00:01 BST). Upper and lower limits for the time, also in seconds since midnight, may be supplied. They are inclusive and independant of each other. A default can be supplied by the program (as seconds since midnight.) This routine is part of the terminal data entry routine suite - full facilities for recognition of defaults, retyping of prompts, automatic recognition of UNKNOWN, EXIT and ^ are available. This is more fully explained in the DATA-ENTRY section of this program, which should be read in conjunction with this. method: The COMND% Jsys is used. parameters: prompt Array or input The prompt for the user string Secnds Integer output Returned seconds since midnight fail Integer output Error code (see below) back Label input *Optional* Statement to jump to if user uses ^ to go back one question, or 0 to ignore this. Lower Integer input *Optional* Lower limit for time (inclusive) or 0 if not desired. Upper Integer input *Optional* Upper limit for time (inclusive) or 0 if not desired. help Array or input *Optional* string Help message to be output if user types question mark, or 0 to ignore argument. If no help is supplied, a message will be constructed of the form "Enter a time, before 11:00 PM, after 1:00 PM", with limits only mentioned if they are supplied in the call. defalt Integer input *Optional* Default to be used if user types escape, or 0 if not desired. NOTE: Optional input arguments can be omitted if they are all trailing, so the call CALL TIMEIN('Time:',SECNDS,FAIL) is valid, as is CALL TIMEIN('Time:',SECNDS,FAIL,*10,0,3600,'Enter time & of birth') which supplies a label to return to if the user types ^ (the label is 10),stores the time of birth in SECNDS, specifies no lower limit, but specifies an upper limit of 1 AM, and outputs a help message if a question mark is typed. No default has been supplied, however. You may use 0 for an optional argument if you wish to supply some arguments that follow it, but you wish that argument to be ignored (ie if you want to supply a default, but not a help message.) Error codes: 0 Success 1 Invalid input 2 Not confirmed (this is only possible if RETRYS is set to a non-negative value and the user types EXIT, UNKNOWN or ^ and then types rubbish after the command.) 18 Time is not in valid format 19 Time is out of range. -1 User typed UNKNOWN. -2 User typed EXIT (this code is only returned if you did not initialize location EXILAB in common block CMDPRM with the label to jump to). -3 User typed "^" to go back a question (this code is only returned if you did not supply a label to jump to on this condition.) common blocks: /cmdstg/cmdbfr(70),atmbfr(70),fdb(5),hlpbfr(25), defbfr(56),gjfblk(15),argblk(5) /cmdprm/initf,retrys,tried,endnse,raise,savret, savp,exilab,useext,spare(3),cmdblk(10) (All integer, see DATA-ENTRY for more info) own variables: no routines called: none level: level 1 author: G.Gibbs / Kevin Ashley date: August 1982 PNPLOT Routine category: c40 title: PNPLOT(X,N,NDS,IDS,NCHAN) language: Fortran description: Produces up to 5 normal plots on either the Oki dot matrix printer or the Calcomp pen plotter. Standardized data values(x-xbar)/sd are placed on the y-axis; otherwise method and output are the same as the line- printer normal plot [d8]. Mean,standard deviation, skewness, kurtosis and (when 2<n<51) the w-statistic (see crwtst [e34]) for each data set are output to channel nchan. The plot is sent to the Oki unless nchan is set negative, when it is sent to the Calcomp. The routine is currently restricted to 1000 values, due to the size of an internal array. parameters: X real array(n) input contains up to 5 data sets N integer input total number of x-values NDS integer input number of data sets to be analysed (up to 5) IDS integer array(5)input sample sizes of data sets in x (in same order) NCHAN integer input output channel number. if set negative the plot will be sent to the calcomp rather than to the oki level: level 4 routines called: crwtst,crc154,crshpe,sndev crgrit,crgrax,crgrlb,crgraf author: J.P.Royston/G.Gibbs date: 12 January 1982.