1 Subroutines
2 Primitives
3 Count
  Subroutine Count(time) - Initiates a count for 'time' seconds.
3 Do_drive
  Subroutine Do_drive(i,xp,degpm) - Issues drive command to PDP for
  motor 'i' to target angle 'xp', at 'degpm' degrees per minute.
3 Getexp
  Subroutine Getexp(time) - This routine returns the current exposure time
  in seconds.
3 Istats
	Integer Function Istats() - Routine to return status of interface
 
 	VALUE	INTERPRETATION
 
 	0	nothing busy
 	1	1 or more motors driving
 	2	scaler running
 	3	motors and scaler busy
       -1	limit

3 Kcinit
  Subroutine Kcinit - Routine to initialise communications with PDP.
3 Ldmtr
  Subroutine Ldmtr(i,x) - Routine to initialize the position of motor
  'i' to a value of 'x'
3 Mtrhlt
  Subroutine Mtrhlt(i) - This routine halts motor 'i'.
3 Ofattn
  Subroutine Ofattn - Routine to turn attenuator off.
3 Ofbeam
  Subroutine Ofbeam - Routine to close shutter.
3 Ofchart
  Subroutine Ofchart - Routine to turn chart drive off.
3 Oftest
  Subroutine Oftest - Routine to turn test mode off.
3 Onattn
  Subroutine Onattn - Routine to turn attenuator on.
3 Onbeam
  Subroutine Onbeam - Routine to open shutter.
3 Onchart
  Subroutine Onchart - Routine to turn chart drive on.
3 Ontest
  Subroutine Ontest - Routine to turn test mode on.
3 RdAllMtr
  Subroutine RdAllMtr(angl) - This routine returns the current positions
  of all 4 motors in the real array 'angl', which must have at least 4 elements.
3 Rdmtr
  Real Function Rdmtr(i) - This routine returns the current position of
  motor 'i'.
3 Rdsclr
  Real Function Rdsclr() - This function returns the current value of the
  scaler, in counts.
3 Rdtime
  Real Function Rdtime() - This function returns the current value of the
  timer, in seconds.
3 Sclhlt
  Subroutine Sclhlt - This routine halts the scaler immediately.
3 Setexp
  Subroutine Setexp(time) - This routine initializes the crystal exposure
  time to 'time' seconds.
3 Stpall
 Subroutine Stpall - This routine halts the scaler and all motors.
3 Wait
  Subroutine Wait - This routine waits for the scaler and all motors to
  finish.
3 Wtmtr
  Subroutine Wtmtr(i) - This routine waits for motor 'i' to finish.
2 Application_Routines

3 Allowed
  Subroutine Allowed(iabsent) - Checks for reflection in 'fh' (in
  common/single/) allowed by space group symmetry. Returns
  'iabsent' zero if allowed, 1 otherwise.
3 Angcal
  Subroutine Angcal - Calculates setting angles for a reflection from
  keyboard input indices.
3 Angletable 
  Subroutine Angletable - Produces a table of inter-reflection angles
  from entries in the reflection list with IUSE set to 1.
3 AutoIn
  Subroutine AutoIn - This routine autoindexes the angle data in the
  reflection list to determine a reduced unit cell consistent with the
  data. 
  See also BRAV for interpreting the reduced cell.
3 CalcA                                                                 
  Subroutine CalcA(hphi,angl,ierr) - This routine calculates the
  diffractometer angles 'angl' corresponding to a vector 'hphi' in
  diffractometer coordinates.  Softlimits are called and the error 
  flag, 'ierr', will be set non-zero if the reflection is inaccessible.
3 CalcB
  Subroutine CalcB(cell,b) - This routine uses the unit-cell parameters
  in 'cell' to calculate the matrix, 'b', the transforms from
  crystallographic to cartesian coordinates.
3 CalcH
  Subroutine CalcH(angl,hphi) - This subroutine uses the diffractometer
  angles 'angl' to calculate a vector 'hphi' in diffractometer
  coordinates. Note: Angle #2 must be the deviation from bisecting
  position.
3 CalCom
  Subroutine CalCom - Keyboard supervised calculation of orientation
  matrix. Data can either be taken from list items or input.
3 CalPhi
  Subroutine CalPhi(h,hphi) - This routine calculates a vector, 'hphi',
  in diffractometer coordinates from a real vector of Miller indices,
  'h', and the orientation matrix.
3 Center
  Subroutine Center(ifnd,ityp,width,tthzero) - Carries out centering
  of a single reflection, at +/-2theta if 'ityp'=1, current position
  only if 'ityp'=0. If no peak is found, 'ifnd' is set non-zero. On
  succesful centering  'ifnd' is set zero, and 'width' is set to the
  omega width of the reflection. If 'ityp'=1 then tthzero has an 
  estimate of the 2theta zero error.
3 Cntr
  Subroutine Cntr(iflag) - Initiates centering from the keyboard of 
  a single reflection at the current diffractometer position. 
  If 'iflag' is zero only the current position is centered, 
  if 1 the reflection is centered at +/- 2theta.
3 Cone
  Subroutine Cone - Performs a cone search at a specified angle
  around the current position. 
3 Conv
  Subroutine Conv(n,pi,d,c,t,ierr) - Performs edge convergence on
  reflection with motor 'n'. 'pi' is the initial position, returned
  as centered position, 'd' is the initial axis offset, 'c' is the
  count rate to be found, 't' is the count time per step. 'Ierr'
  is returned non-zero if set by subroutine drive.
3 Device_Update
  Subroutine Device_Update - Allows the user to set the device-type,
  and thus the diffraction mode and soft-limits for the diffractometer.
3 Drive
  Subroutine Drive(i,x,degpm,ichk,ierr) - Initiates a motor drive for unit
  'i' (0<i<5) to final position 'x' at a speed of 'degpm' degrees
  per minute.  If 'degpm' is zero, slew speed will be used.  If 'Ichk' is
  set to 1 the target angle is checked against the softlimits. 'Ierr' is
  returned as 1 if the target angle cannot be reached. 

  This routine handles the conversions necessary for a decoupled
  diffractometer; therefore, the position of motor #2 should correspond
  to the deviation from bisecting position, even for this type of
  instrument.
3 DriveP
  Subroutine DriveP(iflg,ierr) - Drives diffractometer to angles
  in 'cangl' in common/single/. On entry 'iflg' equal zero
  suppresses printing of message. 'Ierr' is returned from 
  subroutine drive.
3 Edit
  Subroutine Edit(ityp) - Manipulates reflection list:
     ITYP=1     Deletes entries.
     ITYP=2     Insertion of entries by indices.
     ITYP=3     Insertion of entries by angles.
     ITYP=4     List entries.
     ITYP=5     Insertion of entries by indices and angles.
     ITYP=6     Modify Use flags.
     ITYP=7     Indexing of entries.
     ITYP=8     Sort entries by 2theta values.
3 Entom
  Subroutine Entom - Entry of UB matrix from keyboard.
3 Getcl
  Subroutine Getcl - Entry of unit cell from keyboard.
3 Getidx
  Subroutine Getidx - Calculates indices of angles input from keyboard.
3 HCalc
  Subroutine HCalc(angl,h) - This routine returns a real vector, 'h',
  of "apparent" Miller indices for the angles input in 'angl'.
3 Inshell
  Subroutine Inshell(hkl,ierr) - Checks for reflection in 'hkl'
  (real array) occuring in current 2theta shell during data
  collection. Returns 'ierr' 1 if outside shell, zero otherwise.
3 Intall
  Subroutine Intall - Performs data collection with indices 
  generated under control of parameters input from setup.
3 Integr
  Subroutine Integr - Initiates single reflection data collection.
3 Intlist
  Subroutine Intlist - Performs data collection of list of 
  reflections provided in an Ascii file.
3 Listscan
  Subroutine Listscan(iflag) - Prints scan and data collection
  parameters. 'Iflag' controls what data is printed.
3 Lsq
  Subroutine Lsq(iprnt) - Performs unconstrained least-squares
  refinement of lattice parameters based upon indexed entries
  in reflection list with IUSE=1. If 'iprnt' is non-zero
  terminal output is suppressed.
3 Lsvec
  Subroutine Lsvec - Performs constrained least-squares
  refinement of lattice parameters based upon indexed entries
  in reflection list with IUSE=1. 
3 MatMul
  Subroutine MatMul(a,b,c) - This routine performs the matrix
  multiplication C = A * B.  All three matrices must be of rank 3.
3 MatTsp
  Subroutine MatTsp(a,b) - This routine transposes matrix 'a' of rank 3
  and stores the result in 'b', which may be the same matrix as 'a'.
3 Minicenter
  Subroutine Minicenter(ifnd,width) - Performs omega and chi centering
  of a reflection, returning 'ifnd'=1 if reflection not found,
  'ifnd'=0 if reflection centered, with 'width' holding the omega 
  half-height width.
3 Minv
  Subroutine Minv(a,b,det) - This routine calculates the inverse of
  matrix 'a' of rank 3 and stores the result in 'b'.  The determinant is
  returned in 'det', which is zero if the matrix is singular.
3 Motoru
  Subroutine Motoru - Driving of motors from keyboard.
3 Mtinit
  Subroutine Mtinit - Handles keyboard initialisation of motor positions.
3 MtStep
  Subroutine MtStep(no,ddelo,rtmax,rtmin,time,nstep,ierr) - performs
  'nstep' point step scan of motor 'no', with steps of size 'ddelo'
  and time 'time' seconds. Returns min and max count rates in 'rtmin'
  and 'rtmax', and 'ierr' as set by subroutine drive.
3 OmStep
  Subroutine Omstep(ifnd,pos,t,width) - performs step-scan and fitting
  of omega profile of a reflection. Returns 'ifnd'=1 if reflection 
  not found, 'ifnd'=0 if reflection centered, with 'width' holding 
  the omega half-height width. 't' is the count time per step.
3 OmtoB
  Subroutine OmtoB - This routine calculates the B matrix from the
  orientation matrix.  It also calculates the cell constants.
3 Orthog
  Subroutine Orthog(v1,v2,x) - This routine creates a 3 x 3 matrix, 'x',
  which has its first column parallel to 'v1', and its third column
  perpendicular to 'v1' and 'v2'.
3 PkLsq
  Subroutine PkLsq(xd,y,ndata,x,inv) - Fits constrained gaussian 
  profiles to alpha1-alpha2 doublet in omega. On entry, 'xd' and
  'y' hold the 'ndata' data pairs. On exit 'x' holds the four
  profile parameters, 'inv' set 1 indicates refinement failure.
3 PkProf
  Subroutine PkProf(nstep,ssize,time,iprof,ierr) - Performs and prints
  peak profile step-scan of 'nstep' steps of 'ssize' degrees, counting
  'time' seconds at each step. For 2theta scans 'iprof'=1, for omega
  'iprof'=2. 'Ierr' is returned non-zero if set by subroutine drive.
3 PopOM
  Subroutine PopOM - This routine restores an orientation matrix saved
  by PushOM.
3 PrintDevice
  Subroutine Printdevice - Prints device characteristics and softlimits
  currently set.
3 PrintHeader
  Subroutine PrintHeader - Prints page header lines for data collection.
3 Prnt_on
  Sends an escape sequence to the terminal to turn on the attached 
  printer.
3 Prnt_off
  Sends an escape sequence to the terminal to turn off the attached 
  printer.
3 ProfSt
  Subroutine ProfSt - Initiates individual profiling of a reflection
  from the keyboard.
3 PsiAng
  Subroutine PsiAng(pmat,psi,angl,ierr) - Returns setting angles in 'angl'
  for reflection at rotated 'psi' degrees in psi from normal position. 
  Requires previous call to PsiMat to set up Ro matrix in 'pmat'.
  Returns 'ierr' equal to 1 if setting inaccessible.
3 PsiMat
  Subroutine PsiMat(angl,pmat) - Sets up Ro matrix in 'pmat' for psi-scans
  about reflection at angles given in 'angl'. 
  See also PsiAng.
3 PsiScan 
  Subroutine PsiScan - Performs psi scans of a list of reflections
  input from keyboard.
3 PushOM
  Subroutine PushOM - This routine saves the current orientation matrix
  in a separate matrix.  The routine PopOM can be used to recover this
  matrix.
3 Reduce
  Subroutine Reduce(h,z1,noref) - 
3 Refine
  Subroutine Refine - Initiates 2-position centering of reflections in
  reflection list. 
3 Scanref
  Subroutine Scanref(ierr) - Performs data collection scan about current
  position. Returns 'ierr' equal to 1 if a drive error occured. 
  Prints integrated intensity information to terminal, writes step-scan
  information to reflection datafile.  
3 Search
  Subroutine Search - Performs search for reflections, centering and
  profiling. Centered angles are deposited in the reflection list.
3 SetIndex
  Subroutine SetIndex - Sets limits to slowest-moving index during
  data collection, based on 2theta limits of shell, cell parameters,
  and data collection parameters.
  See also SetIndexFast.  
3 SetIndexFast
  Subroutine SetIndexFast(ihslow) - Sets limits to faster-moving 
  indices during data collection, based on 2theta limits of shell, 
  cell parameters, data collection parameters, and value of 
  slowest-moving index in 'ihslow'.
  See also SetIndex.  
3 SetIseq
  Subroutine SetIseq - Requests from keyboard initial sequence 
  number for data collections.
3 Setup
  Subroutine Setup - Keyboard input of experiment parameters.
3 Sngint
  Subroutine Sngint - Initialises communications by calling KCINIT.
3 Standard
  Subroutine Standard(iorient) - Supervises centering and collection
  of standard reflections during data collection. 'Iorient' is
  returned non-zero if standards move enough to halt data collection.
3 Softlimits
  Subroutine Softlimits(angl,ichk,ierr) - Routine to determine whether
  the set of angles in 'angl' is accessible on the diffractometer. If
  all four diffractometer angles are available in 'angl', set 'ichk'
  equal to 0, and all will be checked. If only one angle is available
  then 'ichk' should be set to the corresponding motor number. 

  On exit, 'Ierr' is set to 1 if angle(s) inaccessible, 0 if accessible.
3 Trans
  Subroutine Trans - This routine reads a transformation matrix from the
  keyboard and recalculates both the list indices and the cell parameters.
3 UnitL
  Subroutine UnitL(v) - This routine replaces vector 'v' with a parallel
  unit vector.
3 Update
  Subroutine Update - This routine updates the orientation matrix and 
  other parameters describing the experiment in the MAT file.
3 Vcross
  Subroutine Vcross(u,v,w) - This routine calculates the vector product of
  'u' and 'v' and stores it in 'w'.  All matrices are of rank 3.
3 Zref
  Subroutine Zref - Supervises 8-position centering of reflections from
  reflection list. Will also deal with case of only 4 accessable due to
  softlimits.
