home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / fortranf1_1 / Library_Docs_Utils < prev    next >
Encoding:
Text File  |  1997-01-28  |  5.3 KB  |  138 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. 24 Aug 1996: SWIF77 corrected to run also on StrongARM
  36. 13 Nov 1996: SWIF77 corrected to run better on StrongARM
  37.  
  38.        CHARACTER FUNCTION CDATE()
  39.  Returns the current date and time as a CHARACTER variable (of length at
  40.  least 25, otherwise the function does nothing). The string is of the form:
  41.        ddd,nn mmm yyyy.hh:mm:ss<Return>
  42.  E.g.  Sun,30 Aug 1992.10:22:47
  43.  
  44.        FUNCTION IGET()
  45.  Emulates the BASIC command GET:
  46.  waits for a key press & returns an ASCII character 
  47.  
  48.        FUNCTION INKEY(NUM)
  49.  Emulates the BASIC command INKEY:
  50.  If NUM>= 0 returns an ASCII character of a key pressed within NUM
  51.  centiseconds. If NUM <0 checks whether this key (or mouse button is
  52.  currently pressed. (see BASIC manual Appendix C page 411 for INKEY values)
  53.  
  54.        FUNCTION LNBLNK(STRING)
  55.  Returns the index to the last non-blank character in CHARACTER STRING
  56.  
  57.        FUNCTION LOC(VAR)
  58.  Returns the memory address of variable VAR in BYTES
  59.  
  60.        FUNCTION LOCC(CHARAC)
  61.  Returns the memory address of character string CHARAC in BYTES
  62.  
  63.        MOUSE(MX,MY,MBUTN)
  64.  Emulates the BASIC command MOUSE X%,Y%,B%:
  65.  where MX,MY are the mouse pointer co-ordinates and MBUTN shows which mouse
  66.  button is pressed, 1=adjust, 2=menu, 4=select
  67.  
  68.        QSORTD(D,INDEX,N)
  69.        QSORTI(I,INDEX,N)
  70.        QSORTR(R,INDEX,N)
  71.     Quicksort of the index to an array of DoublePrecision, Integer or Real
  72. variables.
  73.  N is the dimension of the array to sort;
  74.  D, I, or R is the array of variables;
  75.  INDEX is an array of pointers which must span the whole of the array of
  76. variables. Normally this will be the integers 1 to N in any order. However,
  77. if the array to sort is multilply dimensioned (E.g. DIMENSION XYZ(3,10) for
  78. the x, y & z of 10 points), then INDEX could have other values
  79.  (= 3,6,9 .. 30 for the previous example if you want to sort on z).
  80.     After the sort, the pointers in INDEX are ordered so that they address
  81. the array to give algebraically increasing values.
  82.     Note, this sort does not use the FPEmulator, and hence is extremely
  83. fast. E.g. 100,000 real numbers are sorted in 2.4 seconds with ARM3.
  84.  
  85.          SWIERR(IERR,REPORT,LEN)
  86.  Returns the error number in IERR, and the report in character variable
  87. REPORT after an errror detected by SWIF77. The length of the report is in
  88. LEN, but it may get truncated if REPORT is too small.
  89.  
  90.        LOGICAL FUNCTION SWIF77(NUMB,IREGS,IFLAG)
  91.  Performs the SWI number NUMB. IREGS(0:7) must contain the register values
  92. for input, and will contain the values output. It must be at least 8 words
  93. long even if the particular SWI uses less, because copies of registers 0 to
  94. 7 are always returned.
  95.  IFLAG returns the flags N Z C V in bits 3 2 1 0
  96.  The function returns .FALSE. if SWI is OK, otherwise .TRUE., when the error
  97. can be found from SUBROUTINE SWIERR.
  98.  
  99.  Example:
  100.  
  101. C         readĀ file names in directory $.LIBRARY using SWI OS_GBPB
  102. C
  103.       DIMENSION IREGS(0:7)
  104.       CHARACTER*11 FILE
  105. C
  106. C           N countsĀ files
  107.       N=0
  108. C          OS_GBPB type 9 reads only file names from directory
  109.       IREGS(0)=9
  110. C          location of directory name as null terminated string
  111.       IREGS(1)=LOCC('$.LIBRARY'//?H00)
  112. C          location in memory for answer (Character variable FILE)
  113.       IREGS(2)=LOCC(FILE)
  114. C          one name to read at a time
  115.       IREGS(3)=1
  116. C          initialize index of name to read
  117.       IREGS(4)=0
  118. C          maximum size for output name
  119. C          (FILE is CHARACTER*11 to include the null terminator)
  120.       IREGS(5)=11
  121. C          no wild-carded name to match
  122.       IREGS(6)=0
  123.       WRITE(*,*)' files in $.LIBRARY are:'
  124. C          do SWI to OS_GBPB (SWI &0C)
  125.     2 IF(SWIF77(?I0C,IREGS,IFLAG)) CALL ERROR
  126. C          check if finished
  127.       IF(IREGS(4).LT.0.OR.IREGS(3).LE.0) GO TO 4
  128. C          count names
  129.       N=N+1
  130. C          find length of name from null termination
  131.       I=INDEX(FILE,?H00)
  132. C          print name
  133.       WRITE(*,*)' ',FILE(1:I-1)
  134. C          look for next name
  135.       GO TO 2
  136. C          come here when finished
  137.     4 WRITE(*,*)' number of files = ',N
  138.