home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / fortran77_210 / library / docs / utils < prev    next >
Encoding:
Text File  |  1994-01-30  |  5.2 KB  |  136 lines

  1.  
  2.       UTILS a FORTRAN general utilities subroutine library.   18 Nov 1991
  3.  
  4.   ************************************************************************
  5.                     C O P Y R I G H T    N O T I C E
  6.  
  7.                      Copyright D.J & K.M. Crennell,
  8.               P.O. Box 64, Didcot, Oxon, OX11 0TH.
  9.  
  10.  This software is in the Public Domain and may not be sold or included in any
  11.  program that will be sold, without written permission from the authors.
  12.  
  13.  The authors must be given credit in any publications using this software.
  14.  
  15.  The software may be copied and distributed as long as no changes are made
  16.  and this copyright notice is included. Please send any suggested
  17.  improvements to the authors. 
  18.  
  19.  In no circumstances shall the authors be liable for any damage, loss of
  20.  profits, or any indirect or consequential loss arising out of the use of
  21.  this software or inability to use this software, even if they have been
  22.  advised of the possibility of such loss.
  23.  
  24.  The authors do their best to ensure that this library is distributed virus
  25.  free.
  26.   ************************************************************************
  27.  
  28.      The source of this library is assembler, and is not included.
  29.      The library is %.lib.utils
  30.  
  31. Updates
  32. 18 Jun 1992: SWIF77 no longer writes over its own code.
  33. 30 Aug 1992: CDATE added
  34. 02 Nov 1992: SWIF77 corrected to run under RISC-OS 3.10
  35.  
  36.        CHARACTER FUNCTION CDATE()
  37.  Returns the current date and time as a CHARACTER variable (of length at
  38.  least 25, otherwise the function does nothing). The string is of the form:
  39.        ddd,nn mmm yyyy.hh:mm:ss<Return>
  40.  E.g.  Sun,30 Aug 1992.10:22:47
  41.  
  42.        FUNCTION IGET()
  43.  Emulates the BASIC command GET:
  44.  waits for a key press & returns an ASCII character 
  45.  
  46.        FUNCTION INKEY(NUM)
  47.  Emulates the BASIC command INKEY:
  48.  If NUM>= 0 returns an ASCII character of a key pressed within NUM
  49.  centiseconds. If NUM <0 checks whether this key (or mouse button is
  50.  currently pressed. (see BASIC manual Appendix C page 411 for INKEY values)
  51.  
  52.        FUNCTION LNBLNK(STRING)
  53.  Returns the index to the last non-blank character in CHARACTER STRING
  54.  
  55.        FUNCTION LOC(VAR)
  56.  Returns the memory address of variable VAR in BYTES
  57.  
  58.        FUNCTION LOCC(CHARAC)
  59.  Returns the memory address of character string CHARAC in BYTES
  60.  
  61.        MOUSE(MX,MY,MBUTN)
  62.  Emulates the BASIC command MOUSE X%,Y%,B%:
  63.  where MX,MY are the mouse pointer co-ordinates and MBUTN shows which mouse
  64.  button is pressed, 1=adjust, 2=menu, 4=select
  65.  
  66.        QSORTD(D,INDEX,N)
  67.        QSORTI(I,INDEX,N)
  68.        QSORTR(R,INDEX,N)
  69.     Quicksort of the index to an array of DoublePrecision, Integer or Real
  70. variables.
  71.  N is the dimension of the array to sort;
  72.  D, I, or R is the array of variables;
  73.  INDEX is an array of pointers which must span the whole of the array of
  74. variables. Normally this will be the integers 1 to N in any order. However,
  75. if the array to sort is multilply dimensioned (E.g. DIMENSION XYZ(3,10) for
  76. the x, y & z of 10 points), then INDEX could have other values
  77.  (= 3,6,9 .. 30 for the previous example if you want to sort on z).
  78.     After the sort, the pointers in INDEX are ordered so that they address
  79. the array to give algebraically increasing values.
  80.     Note, this sort does not use the FPEmulator, and hence is extremely
  81. fast. E.g. 100,000 real numbers are sorted in 2.4 seconds with ARM3.
  82.  
  83.          SWIERR(IERR,REPORT,LEN)
  84.  Returns the error number in IERR, and the report in character variable
  85. REPORT after an errror detected by SWIF77. The length of the report is in
  86. LEN, but it may get truncated if REPORT is too small.
  87.  
  88.        LOGICAL FUNCTION SWIF77(NUMB,IREGS,IFLAG)
  89.  Performs the SWI number NUMB. IREGS(0:7) must contain the register values
  90. for input, and will contain the values output. It must be at least 8 words
  91. long even if the particular SWI uses less, because copies of registers 0 to
  92. 7 are always returned.
  93.  IFLAG returns the flags N Z C V in bits 3 2 1 0
  94.  The function returns .FALSE. if SWI is OK, otherwise .TRUE., when the error
  95. can be found from SUBROUTINE SWIERR.
  96.  
  97.  Example:
  98.  
  99. C         readĀ file names in directory $.LIBRARY using SWI OS_GBPB
  100. C
  101.       DIMENSION IREGS(0:7)
  102.       CHARACTER*11 FILE
  103. C
  104. C           N countsĀ files
  105.       N=0
  106. C          OS_GBPB type 9 reads only file names from directory
  107.       IREGS(0)=9
  108. C          location of directory name as null terminated string
  109.       IREGS(1)=LOCC('$.LIBRARY'//?H00)
  110. C          location in memory for answer (Character variable FILE)
  111.       IREGS(2)=LOCC(FILE)
  112. C          one name to read at a time
  113.       IREGS(3)=1
  114. C          initialize index of name to read
  115.       IREGS(4)=0
  116. C          maximum size for output name
  117. C          (FILE is CHARACTER*11 to include the null terminator)
  118.       IREGS(5)=11
  119. C          no wild-carded name to match
  120.       IREGS(6)=0
  121.       WRITE(*,*)' files in $.LIBRARY are:'
  122. C          do SWI to OS_GBPB (SWI &0C)
  123.     2 IF(SWIF77(?I0C,IREGS,IFLAG)) CALL ERROR
  124. C          check if finished
  125.       IF(IREGS(4).LT.0.OR.IREGS(3).LE.0) GO TO 4
  126. C          count names
  127.       N=N+1
  128. C          find length of name from null termination
  129.       I=INDEX(FILE,?H00)
  130. C          print name
  131.       WRITE(*,*)' ',FILE(1:I-1)
  132. C          look for next name
  133.       GO TO 2
  134. C          come here when finished
  135.     4 WRITE(*,*)' number of files = ',N
  136.