Cambridge Crystallographic Subroutine Library

CCSL Mark 4 Update 57 17

Appendix A

List of subroutines divided according to topic

  1. Basic crystallography

  2. Data collection & reduction

  3. Manipulation of reflection indices

  4. Structure factors

  5. Fourier maps

  6. Least Squares Refinement, general

  7. Least Squares Refinement, specific

  8. Crystal geometry

  9. Mathematical functions

  10. Trigonometry

  11. Tests

  12. Matrices & vectors

  13. Special input/output

  14. Graphical output

  15. Logical operations

  16. Miscellaneous

  17. Magnetic routines

  18. Multipole routines

  19. Profile refinement

  20. As yet unclassified

General Library

1. Basic crystallography

A. Setting up

SUBROUTINE FACGRP
Extracts factor groups from a space group.

SUBROUTINE FACTGP
Finds the factor elements which generate a space group from one of its sub-groups.

SUBROUTINE FIXUNI
Deals with one potential plane face of asymmetric unit, while the unit is being formed.

SUBROUTINE INPUTC
Reads one "C" card.

SUBROUTINE INPUTS
Reads and interprets one "S" card containing a space group operator. Can also interpret an S GRUP card containing a space group specification.

SUBROUTINE INPUTU
Reads and interprets a "U" card, giving a typical reflection to define the reciprocal asymmetric unit.

SUBROUTINE MAKGRP
Generates the subgroup of a space group from the given generators.

SUBROUTINE ORTHG
Calculates matrices for the transformation of vectors in real or reciprocal space, between crystallographic and orthogonal axes.

SUBROUTINE PLN3AD
A specialist routine used during the formation of the reciprocal unit cell, to offer up 3 planes as boundaries, in cubic space groups.

SUBROUTINE POLUNI
A specialist routine to "polish" the edges of a found asymmetric unit by specifying exactly how its faces and edges should be treated.

SUBROUTINE RECIP
SUBROUTINE REINDX
Reads the lattice parameters and forms the reciprocal cell. To reindex a set of reflections after a least squares cycle in which the propagation vector changes

SUBROUTINE SETFC
Calls all the setting up routines needed for nuclear structure factor calculations.

SUBROUTINE SHUFLE
Reorders the symmetry operators for various specialist applications.

SUBROUTINE SPACE
Interprets symbols from an S card which are the space group name.

SUBROUTINE SPGNAM
Decodes space group symbol or integer from S GRUP card

SUBROUTINE SYMCEN
A specialist routine used during the input of space group symmetry to discover whether there is a centre of symmetry.

SUBROUTINE SYMFRI
Reads and interprets an item "FRIE" on an I card.

SUBROUTINE SYMGEN
Produces the generators of a space group which has been read by SYMOP.

SUBROUTINE SYMOP
Reads all the symmetry operators or a space group specification from "S" cards, and generates the space group.

SUBROUTINE SYMTID
Tidies all the arrays connected with the space group symmetry.

SUBROUTINE SYMUNI
Selects a reciprocal space asymmetric unit fitting the symmetry.

SUBROUTINE TRYUNI
A specialist routine used in the setting up of the asymmetric unit, to try out a given set of planes as faces of the unit.

SUBROUTINE UNITID
A specialist routine called when an asymmetric unit has been found, to tidy the unit, its faces and edges.

B. Crystallographic

FUNCTION ANGRAD
Calculates the angle in radians between two vectors, in either space.

SUBROUTINE ASUNIT
Produces reflection indices in the asymmetric unit, related to those given.

SUBROUTINE CELMAT
Sets up the matrix to convert derivatives wrt A,B,C . . (cell quadratic products in real space) to derivatives wrt A*, B*, C*, . . in reciprocal space.

SUBROUTINE EQOP
Checks whether a rotation matrix and a translation vector of a symmetry operator are already in a list, and adds them if not. Also finds lattice translations.

SUBROUTINE EULSYM
Finds the Euler angles correponding to a symmetry rotation.

SUBROUTINE GENELM
Finds the generators of a subgroup of a space group.

LOGICAL FUNCTION ISPABS
Checks space group absences.

LOGICAL FUNCTION LATABS
Checks h,k,l for being a (nuclear) lattice absence.

SUBROUTINE LATGEN
Generates points on a lattice.

LOGICAL FUNCTION LATVEC
Tests for the presence of a lattice vector.

SUBROUTINE OPSYM
Prints out the symmetry operators in either real or reciprocal space.

SUBROUTINE ORTHO
Carries out conversions between crystallographic and orthogonal axes.

SUBROUTINE RECELL
Makes real or reciprocal space cell parameters from the others.

SUBROUTINE ROTOSM
Calculates the effect of the rotation matrix of a symmetry operator, on a vector given on orthogonal axes.

SUBROUTINE ROTSYM
Rotates the vector H into RH by the given symmetry operator.

FUNCTION SCLPRD
Forms the scalar product of two vectors referred to crystal axes.

SUBROUTINE SUBSYM
Replaces all the symmetry parameters by those of a subgroup.

SUBROUTINE SYMBAK
Restores the original symmetry operators after a call to SUBSYM.

SUBROUTINE SYMREF
Generates a set of equivalent reflections and related phases.

FUNCTION VCTMOD
Calculates the modulus of the vector H, in either space.

C. Utility

SUBROUTINE AXIS
Finds the axis of a given rotation matrix.

SUBROUTINE FCTOR
Finds the highest common factor of a set of indices and reduces them by that factor.

SUBROUTINE FRAC3
Makes all 3 elements of a vector fractional

SUBROUTINE INVENT
Given a plane U and an axis H, produces a direction ANS which is in the plane but not parallel to the axis.

FUNCTION NORDER
Returns the order of the Jth symmetry operator.

2. Data collection & reduction

A. Setting up

SUBROUTINE ARPRIN
A multi-mode routine to produce the output in ARRNGE type main programs.

SUBROUTINE ARREAD
Multiple entry routine to deal with reading items for ARRNGE type programs.

SUBROUTINE GAUSPT
Sets up Gauss points and weights for use in 3D integration.

SUBROUTINE ICDFMT
Interprets I and Q PROP cards for programs reading ARRNGE type data".

SUBROUTINE IICD3
Interprets I cards for ARRNGE-type MAIN programs, and sets them up.

SUBROUTINE INPUTD
Reads and interprets all D cards, for general diffraction information.

SUBROUTINE INPUTE
Reads and interprets an E card, and sets up extinction calculations.

SUBROUTINE INPUTG
Reads and interprets all "G" cards, for Gaussian integration of various integrals over a crystal defined by its plane faces.

SUBROUTINE SETABS
Sets up data for the calculation of absorption (or related) integrals.

SUBROUTINE SETDC
Reads D cards to set up crystal orientation and diffraction geometry.

SUBROUTINE SETGAU
Sets up the COMMON /GAUSS/ for Gaussian integration (for use in absorption correction type integrals).

SUBROUTINE SETLP
Prepares to calculate (X-ray) Lorentz and polarisation corrections.

SUBROUTINE SETPOL
Reads the polarisation and flipping efficiencies (for polarised neutrons).

B. Crystallographic

SUBROUTINE ABMULT
Forms transmission (=1/absorption) factors or related integrals.

SUBROUTINE ABSCOR
Applies absorption corrections to groups of equivalent reflections.

FUNCTION ABSOR
Forms a transmission (=1/absorption) factor or related integrals.

SUBROUTINE AINOUT
Multiple function routine called by ARRNGE type programs to process sort items.

SUBROUTINE ALRPOL
Calculates the reciprocals of Lorentz and polarisation factors.

SUBROUTINE ANGDIR
Calculates D3 or 4-circle angles from direction cosines.

SUBROUTINE BIGGAM
Deals with gammas whose value is greater than one, in SORGAM. There is also the entry SETGAM to set up the calculation.

SUBROUTINE EXTINC
Multi-entry routine to deal with all aspects of single crystal extinction corrections.

SUBROUTINE FGAMMA
Calculates gamma, the ratio of magnetic and nuclear scattering, and its standard deviation. FGAMMS does this in the presence of spin-independent multiple scattering.

SUBROUTINE GAMEX
Calculates an extinction corrected gamma from a flipping ratio.

SUBROUTINE GETDC
Calculates direction cosines of the incident and diffracted beams used by absorption correction type integrals

SUBROUTINE QARRIN
In the library, simply a dummy routine. If the user wishes some special new input format for "ARRNGE" type main programs, he provides a new version of QUARRIN.

SUBROUTINE STATIS
Calculates means and other statistics for a set of measurements of a single quantity.

C. Utility

FUNCTION INPUAR
Reads the data from files made by ARRNGE and other similar programs.

3. Manipulation of reflection indices

A. Setting up

SUBROUTINE PRMTIV
A specialist routine for use in generating h,k,l indices where the natural stepping vectors do not define a primitive cell.

SUBROUTINE SETGEN
Sets up the generation of a complete set of reflection indices.

B. Crystallographic

SUBROUTINE GENMUL
Gives next useful set of h,k,l and multiplicity, scanning the asymmetric unit of reciprocal space.

SUBROUTINE GETGEN
Gives the next useful set of h,k,l scanning the asymmetric unit of reciprocal space.

SUBROUTINE INBOX
Determines whether the given reflection is inside, on, or outside the reciprocal space asymmetric unit.

C. Utility

SUBROUTINE INDFIX
Converts 3 real items in H to be integers in K.

SUBROUTINE INDFLO
Converts 3 integers in K into floating point reals in H.

FUNCTION MATCH
Checks to see whether two sets of reflection indices match.

FUNCTION MATCHF
Checks to see whether two sets of floating point reflection indices match.

FUNCTION MULBOX
Tests indices for being in the asymmetric unit, and gives multiplicity.

4. Structure factors

A. Setting up

SUBROUTINE ATOPOS
Reads and interprets all given A cards.

SUBROUTINE INPUTA
Reads an A card and prepares it for further processing.

SUBROUTINE INPUTF
Reads and partially interprets an "F" card.

SUBROUTINE INPUTT
Reads and interprets one "T" card.

SUBROUTINE INPUTW
To read the "W" card indicated by ID, as far as atom label and word.

SUBROUTINE RADFUN
Reads coefficients for the expansion of an atomic wave function.

SUBROUTINE SETANI
Reads "T" cards to set up for calculation of anisotropic temperature factors.

SUBROUTINE SETFOR
Sets up data for scattering or form factor calculations.

B. Crystallographic

FUNCTION ANITF
Forms the contribution to the anisotropic temperature factor on an atom N from indices H.

SUBROUTINE ATOMS
Makes a real space unit cell full of related atomic positions.

FUNCTION CONATF
Produces for a single coefficient of an anisotropic temperature factor, its conversion factor from the internally used betas, in order to communicate with the user.

COMPLEX FUNCTION FCALC
Calculates the COMPLEX nuclear structure factor for the reflection H.

COMPLEX FUNCTION FORMFA
Calculates form or scattering factors.

FUNCTION FORMFC
Calculates form factor integrals from radial wave functions.

5. Fourier maps

A. Setting up

SUBROUTINE INPUTM
Reads and interprets all "M" cards.

SUBROUTINE MAJUST
A specialist routine used in the input of the Crystal Data File needing previously stored Fourier maps.

SUBROUTINE NEXCON
Sets up the "next" contour value to plot for Fouriers.

SUBROUTINE SETFOU
Sets up data for Fourier map calculations.

SUBROUTINE USYM
Transforms all the symmetry operators by pre- and post-multiplying them by U, the orientation matrix for a Fourier map.

B. Crystallographic

SUBROUTINE ATMPLO
Plots atom positions on a map.

SUBROUTINE ATOGEN
Generates a set of equivalent positions.

SUBROUTINE ERRMAP
Calculates the standard deviation of the density in a Fourier map.

SUBROUTINE FORIER
Controls Fourier calculations.

SUBROUTINE FOUR1D
Calculates a Fourier along a general line.

SUBROUTINE FOUR1Z
Calculates 1 layer of Fourier sum : a section if 3D, a projection if 2D, or a bounded section if "4D".

SUBROUTINE FOURGP
Calculates a Fourier on a general plane.

SUBROUTINE GETMAP
Retrieves 1 Fourier map previously filed using SAVMAP.

SUBROUTINE MAPCON
After a Fourier map has been plotted, sends to the plotter the list of contours which were plotted, with a frame.

SUBROUTINE MAPDRW
Draws an unframed contour map, in predetermined place.

SUBROUTINE MAPFRA
Draws a black frame round a potential contoured map, adding the labels X Y and a 1A scale.

SUBROUTINE MAPKEY
Plots a key to the atoms found by ATMPLO.

SUBROUTINE MAPTIT
Writes a title over a plotted map, with a frame.

SUBROUTINE PLTTXT
Plots a block of explanatory text under a plotted Fourier map.

SUBROUTINE PRNTMP
SUBROUTINE PROPAG
Multiple entry subroutine for propagation vector refinement Prints out a Fourier projection or one layer of a 3D Fourier.

SUBROUTINE QFOUIN
In the library, simply a dummy routine. If the user wishes some special new input format for Fourier routines, he provides a new version of QFOUIN.

SUBROUTINE READMP
Reads into the array DENS a map previously written to file, unformatted.

FUNCTION RESOL
Calculates a resolution function for use with Fourier inversion.

SUBROUTINE SAVMAP
Writes 1 layer of map to given file, plus information for later retrieval.

SUBROUTINE SYMEQU
Generates new indices and a phase, in Fourier calculations.

SUBROUTINE TBOUND
A specialist routine used duing the plotting of atomic positions in main program ATMPLO.

C. Utility

SUBROUTINE CHOOSF
Chooses modulus and phase for a particular Fourier.

SUBROUTINE DOSIDE
A specialist routine for contour plotting, to help to decide where a contour crosses the side of a square.

SUBROUTINE FOUINP
Reads one data item for a given type of Fourier, in a given format.

6. Least Squares Refinement, general

A. Setting up

SUBROUTINE CELREL
Transfers any relations which exist between cell parameters from their own COMMON to the general "contraint/fixing" COMMON.

SUBROUTINE F2VAR8
Records varying information for a particular family 2 (structure) parameter.

SUBROUTINE FIXPAR
Records an instruction to fix a LSQ parameter.

SUBROUTINE FIXREL
Takes a temporary set of fix/relate information and adds it to the permanent information.

SUBROUTINE FUDGIN
Interprets all L FUDG cards.

SUBROUTINE GEOMIN
Reads L cards for bond slack constraints.

SUBROUTINE IICD1
Interprets basic I cards to drive any LSQ.

SUBROUTINE LLSCAL
Multiple entry routine which deals with scale factors in Least Squares.

SUBROUTINE LLTFAC
Multiple entry routine which deals with overall isotropic temperature factors in Least Squares.

SUBROUTINE LSETSF
Sets up vocabulary for a specific LSQ problem involving structure factors.

SUBROUTINE LSETUP
Sets up specific LSQ problem - copies the vocabulary to standard COMMON.

SUBROUTINE RDFV
Reads all the user's L FIX and L VARY cards in sequence.

SUBROUTINE RDRELA
Reads and interprets all user-supplied L RELA cards for constraints.

SUBROUTINE RELPAR
In the setting up of LSQ applications, relates two parameters by a simple linear relationship.

SUBROUTINE RELSM3
Forms a complete set of relations imposed by symmetry on the given 3 parameters of a LSQ application.

SUBROUTINE RELSM6
Forms a complete set of relations imposed by symmetry on the given 6 parameters of a LSQ application.

SUBROUTINE SCLCHN
A specialist routine used during the setting up of constraints on LSQ variables. Scales a chain of connected variables by the given constant.

SUBROUTINE VARMAK
Makes variables for a LSQ cycle from given FIX/VARY and CONSTRAINT lists.

SUBROUTINE VOCAB
Adds a given set of vocabulary and meanings to the Least Squares total vocabulary.

B. Crystallographic

SUBROUTINE CELDER
From h,k,l calculates d* squared and its derivatives, and sets SSQRD.

SUBROUTINE F2NEW
Outputs a new LSQ family 2 (structure parameters) card (for A, T or F cards).

SUBROUTINE F2RELA
Collects all structure factor type constraints implied by the symmetry.

SUBROUTINE F2SHFT
Applies a shift to a particular family 2 (structure) parameter.

SUBROUTINE GEOMLS
Calculates bond lengths and derivatives for geometrical slack constraints.

SUBROUTINE LFCALC
Calculates a nuclear structure factor and its derivatives.

SUBROUTINE MATCEL
After a cycle of LSQ gives variance-covariance matrix for cell A* B* etc in both real and reciprocal space, and the same for abc, alpha,beta,gamma.

SUBROUTINE OTPUTI
Outputs a new I card after a LSQ refinement, updating the cycle number.

SUBROUTINE QLSQIN
In the library, simply a dummy routine. If the user wishes some special new input format for Least Squares routines, he provides a new version QLSQIN.

SUBROUTINE RFACS
A multiple entry routine to deal with all aspects of R Factor calculations and statistics for single crystal observations, and

SUBROUTINE XYZREL
Collects all position parameter constraints implied by the symmetry.

C. Utility

SUBROUTINE ADDCON
Adds a constraint to the list held in LSQ programs.

SUBROUTINE ADJUST
Applies a (possibly fudged) shift to a given LSQ parameter.

SUBROUTINE CELNEW
Writes out a new C card after cell parameter refinement.

SUBROUTINE CELSDP
Prints the esds of real cell parameters after a cycle of refinement.

SUBROUTINE CELSHF
Applies a shift to a cell quadratic product.

SUBROUTINE DEPRIN
Decodes an integer which describes the frequency of LSQ printing required, and outputs this frequency.

FUNCTION ELEMAT
Gets a matrix element from the triangular LSQ matrix.

SUBROUTINE FETSHF
Fettles a shift and esd for printing and counts, in the application of shifts in LSQ.

SUBROUTINE FIXVAR
Adds a request to fix (or vary) a parameter to the lists held in setting up LSQ environments.

SUBROUTINE FUDGET
Reads a fudge factor from a card having already read a parameter specification.

SUBROUTINE GEOMCO
Multiple entry routine for geometric slack constraints.

FUNCTION KPAK
Pack a LSQ parameter specification on to integer.

LOGICAL FUNCTION KSAME
Tells if two LSQ parameter specifications are the same, allowing wild card elements.

SUBROUTINE KUNPAK
Unpacks a LSQ parameter specification from single integer.

LOGICAL FUNCTION KWHOLE
Says if KK is a whole packed parameter specification, or whether there are wild card elements.

SUBROUTINE MATCOR
After a Least Squares cycle, prints correlations from the inverse matrix.

SUBROUTINE MATINV
Inverts the matrix in ALSQ, of which the upper triangle only is held.

SUBROUTINE MATSET
Sets up pointers into a Least Squares matrix, and clears the matrix and the corresponding right hand side vector.

SUBROUTINE MATSHF
From an inverted Least Squares matrix, calculates shifts in basic variables.

SUBROUTINE MATTOT
Add in contributions to LSQ matrix and RHS for one observation.

SUBROUTINE NEWCD
Opens a file on to which to write a new Crystal Data File after a Least Squares refinement. .CCN at RAL, .CRY at ILL, for unit NEWIN in /NEWOLD/

SUBROUTINE PARNAM
Obtains the printing name of a LSQ parameter.

SUBROUTINE PARRD
Reads a LSQ parameter specification from a given card at given point.

SUBROUTINE PARRUN
Controls the cycling over all parameters in LSQ (not for Profile Refinement).

SUBROUTINE PRBLOK
Prints a block of shifts in parameters all relating to the same atom in LSQ applications involving structure parameters.

SUBROUTINE PRIVAR
Prints a list of basic variables, and constraint relations, for LSQ.

SUBROUTINE PRIWRD
Finds the name of the packed (possibly part) LSQ parameter from the built-in table of parameter names.

LOGICAL FUNCTION PRNCYC
Decides whether printing (of various different quantities in LSQ) is needed during the current LSQ cycle.

SUBROUTINE PUNPAK
Unpacks a parameter specification from single integer.

SUBROUTINE RELATE
In LSQ programs, converts a vector of derivatives wrt variables into the vector of derivatives wrt basic variables.

SUBROUTINE SERROR
Called after VA05A to give the standard deviations of the parameters.

SUBROUTINE SHFESD
During the application of LSQ shifts, calculates the shift and ESD for a "redundant" variable.

LOGICAL FUNCTION SYMFIX
Says whether a LSQ parameter is fixed by symmetry or not.

SUBROUTINE TBLFND
Looks for an A4 NAME in every table it can find, trying to identify it as part of a LSQ parameter name.

SUBROUTINE VA05A
Minimises the sum of squares of given functions without requiring the explicit calculation of derivatives.

SUBROUTINE WGHTLS
Performs various operations to do with weights for LSQ, either for PR or simpler applications. applications.

FUNCTION WIYPOS
SUBROUTINE WGHTSF
GIVES EXP(Y*Y)ERFNC(Y) FOR +VE Y ONLY Deals with weights of LSQ observations for single crystal.

7. Least Squares Refinement, specific

A. Setting up

LOGICAL FUNCTION DFLTMG
Called as a substitute for DEFALT via VARMAK, giving default fix/vary for otherwise unspecified parameters for magnetic structures.

LOGICAL FUNCTION DFLTMP
Called as a substitute for DEFALT out of VARMAK, giving defaults fix/vary for otherwise unspecified parameters of multipole refinements.

LOGICAL FUNCTION DFLTSF
Called as a substitute for DEFALT out of SUBROUTINE VARMAK, giving default fix/vary information for structure parameters.

LOGICAL FUNCTION DFTRUE
Called as a substitute for DEFALT out of VARMAK in main programs, to vary an otherwise unspecified parameter.

SUBROUTINE INOBGR
Performs a preliminary pass of observations for GRLSQ, (group refinement, integrated intensity LSQ).

SUBROUTINE INPLSF
Reads in (nearly) all L cards for the particular LSQ type 'SF', for single crystal work.

SUBROUTINE MPOVAR
Records whether each multipole parameter is fixed or varied.

SUBROUTINE PARSDS
Collects together all parameter fixing and varying information for LSQ refinement of cell parameters using d spacings.

SUBROUTINE PARSFW
An older routine to set up variables from parameters for FWLSQ.

SUBROUTINE STLSFW
Sets up the main program FWLSQ to perform LSQ on Forsyth & Wells scattering factor coefficients.

SUBROUTINE STLSSF
Sets up any main program which does single crystal structure factor LSQ.

SUBROUTINE VARSDS
Makes variables for cell parameters and propagation vector for d-spacing LSQ.

SUBROUTINE VARSMG
Records variable pointers for all variables in magnetic structure-factor LSQ.

SUBROUTINE VARSMP
Records pointers for all variables in multipole LSQ.

SUBROUTINE VARSSF
Records variable pointers for all variables in structure-factor LSQ.

B. Crystallographic

SUBROUTINE APSHDS
Applies shifts for during d-spacing refinement.

SUBROUTINE APSHFW
Applies shifts for Forsyth & Wells scattering factor coefficient refinement.

SUBROUTINE APSHMP
Applies shifts to all variables in multipole LSQ, and prints the results.

SUBROUTINE APSHSF
Applies shifts to all variables in single crystal structure factor based LSQ, and prints the results.

SUBROUTINE APSHT2
Applies shifts for reciprocal cell quadratic products and zero during 2theta refinement.

SUBROUTINE CALCDS
Calculates d star squared, and its derivatives wrt reciprocal cell quadratic products.

SUBROUTINE CALCFW
Calculates the Forsyth & Wells exponential function which approximates to observed scattering factor curves.

SUBROUTINE CALCGR
Gives the calculated function for grouped single crystal Least Squares.

SUBROUTINE CALCMG
Calculates GCALC and its derivatives for structures which may have mixed magnetic and nuclear reflections.

SUBROUTINE CALCMP
Makes the calculated function and derivatives for single crystal LSQ with multipoles.

SUBROUTINE CALCSF
Makes the calculated function and derivatives for single crystal LSQ.

SUBROUTINE CALCT2
Calculates a function to match an observation for 2theta-type refinement of reciprocal cell parameters and a zero point.

SUBROUTINE CALPOL
Calculates scattered polarisations and their derivatives for structures which may have mixed magnetic and nuclear reflections.

SUBROUTINE CONVMP
Converts between user values and LSQ parameters for multipoles.

SUBROUTINE JMPOL
Writes to unit NEWIN all J MPOL cards after a multipole refinement.

SUBROUTINE LMPCAL
Calculates a structure factor and its derivatives using a multipole description of the form factors.

SUBROUTINE NWINDS
Outputs to unit NEWIN a new input dataset at the end of a refinement of cell parameters and propagation vector from d spacing values.

SUBROUTINE NWINFW
Writes out a new Crystal Data File for main program FWLSQ.

SUBROUTINE NWINMP
Writes to unit NEWIN a replacement Crystal Data File after multipole LSQ.

SUBROUTINE NWINSF
Outputs a replacement Crystal Data File after single crystal refinement.

SUBROUTINE NWINT2
Writes out a new Crystal Data File for main program T2LSQ.

SUBROUTINE PARSSF
Collects all parameter fix and vary information for single crystal LSQ.

SUBROUTINE PRMBLK
Applies shifts to multipole parameters, in both program and user units.

SUBROUTINE VARST2
Makes variables for zero and cell for T2 type LSQ

8. Crystal geometry

A. Setting up

SUBROUTINE ADDANG
Finds an angle in the tables for geometric constraints, or adds it if absent.

SUBROUTINE ADDATM
Finds an atom in the tables for geometric constraints, or adds it if absent.

SUBROUTINE ADDBON
Finds a bond in the tables for geometric constraints, or adds it if absent.

SUBROUTINE ADDTOR
Finds a torsion angle in the tables for geometric constraints, or adds it if absent.

SUBROUTINE RDANGL
Reads a specification of a bond angle, by reading the names of 2 intersecting bonds; makes the third bond involved.

SUBROUTINE RDATOM
Reads the specification of an atom for slack constraint purposes

SUBROUTINE RDBOND
Reads a specification of a bond, by reading the names of the atoms at each end.

B. Crystallographic

SUBROUTINE ANGLST
Lists all angles at one source atom made by a given list of bonds.

SUBROUTINE BNDLST
Writes out and saves a list of bonds from one atomic position.

SUBROUTINE BONCOS
Given 3 bonds forming a triangle, calculates the angle opposite the first, its sine and cosine, and its derivatives wrt all 3 bonds.

FUNCTION BONDA
Calculates the angle between two bonds.

SUBROUTINE BONDER
Calculate a bond and its derivatives for slack constraints.

SUBROUTINE BONTRI
Given two bonds with a common atom, completes the triangle and identifies the atom.

SUBROUTINE INCELL
Sets P to be the position in the central cell equivalent to X.

SUBROUTINE XROOT
Finds the symmetry operations which take the given source atom into the given coordinates.

SUBROUTINE XTRANS
Transforms a given atomic position by given symmetry operator and lattice and cell translations.

C. Utility

SUBROUTINE ATSPEC
Makes the 16-character specification of a symmetry related atom from its packed specification.

9. Mathematical functions

A. Setting up

SUBROUTINE SPLINE
Sets up a cubic spline to fit a curve.

C. Utility

FUNCTION ALNINT
Performs linear interpolation, suitable for profile backgrounds etc.

FUNCTION BJ
Calculates Bessel functions of order 1 or 2.

FUNCTION BRILL
Returns the value of the Brillouin function.

SUBROUTINE CGAMMA
Solves the quadratic equation for gamma in terms of the flipping ratio. The ENTRY CGAMMS is for when there is spin-independent multiple scattering.

SUBROUTINE DIJROT
Calculates the matrix D(i,j) for the Euler rotations alpha,beta,gamma of the eigenfunctions of angular momentum l.

FUNCTION ERFNC
Calculates the error function accurate to 3E-7, for + and - X.

FUNCTION EXPINT
Calculates an exponential radial integral.

FUNCTION FACT
Calculates factorial K.

SUBROUTINE FF01A
Modified Harwell routine for zero order Bessel functions.

SUBROUTINE FF02A
Modified Harwell routine for first order Bessel functions.

SUBROUTINE FRACT
Forms the fractional part of a real number.

SUBROUTINE FT01A
Modification of Harwell Fast Fourier Transform.

SUBROUTINE JTERMS
Calculates the terms in the 2D averaged spherically symmetric form factor summation which depend on S,K, and R only.

SUBROUTINE NB01A
Harwell routine NB01A to find the zero of a function.

FUNCTION RGAUSS
Returns a value random number with a gaussian distribution.

SUBROUTINE SPHARM
Calculates spherical harmonics.

FUNCTION SPLINT
Evaluates a cubic spline given spline values and first derivative values at the given knots.

SUBROUTINE STERMS
Calculates a term in the spherically symmetric form factor summation, for a 3D averaged form-factor involving Sk and r only.

SUBROUTINE TB02A
Interpolates in non-equal interval table.

SUBROUTINE TQLI
Performs the QL algorithm for eigenvalues and vectors of a real symmetric matrix previously reduced to tridiagonal form.

SUBROUTINE TRED2
Performs the Householder reduction of a real symmetric matrix to tridiagonal form.

FUNCTION VECOUP
Calculates Clebsch-Gordon vector coupling coefficients.

SUBROUTINE VOIGT
Calculates normalised Voigt function

SUBROUTINE WERF
Weighted error function ???

SUBROUTINE WTMEAN
Multiple entry routine for the calculation of weighted averages.

10. Trigonometry

FUNCTION ARCCOS
Calculates an arc cosine.

FUNCTION DEGREE
Converts from radians to degrees.

FUNCTION RADIAN
Converts from degrees to radians.

SUBROUTINE SINCOS
Calculates sin from cos or vice-versa.

SUBROUTINE TRIAN1
Applies the cosine formula for the solution of spherical triangles.

SUBROUTINE TRIG
Sets up cos(nx) and sin(nx) for a range of n by recursion.

11. Tests

LOGICAL FUNCTION BINDIG
Tests for the presence of a given binary digit within an integer.

SUBROUTINE EQPOS
Checks whether the given atom position already occurs in a given list, and adds the new one if not.

SUBROUTINE EQPPOS
Checks whether the given position vector is related by lattice translation to one already in the given list.

SUBROUTINE EQRLV
Checks whether vectors differ by a reciprocal lattice vector.

SUBROUTINE EQVEC
Finds a given vector in given table of vectors, or adds it as a new one.

LOGICAL FUNCTION EXCLD
Determines whether a number occurs within any of a set of given ranges.

LOGICAL FUNCTION GMSAME
Tells whether one vector is the same as another, to a given tolerance.

FUNCTION IATOM
Identifies an atom name in a given list.

FUNCTION ISCAT
Searches for a potential scattering factor name in the table.

FUNCTION LMATCH
Matches an A4 item in given table, adding it if it is not there already.

FUNCTION MINIM
Finds the position and value of the minimum in a list of integers.

FUNCTION NCFIND
Searches for a particular word in a table of words.

FUNCTION NFIND
Searches for integer N in a table.

SUBROUTINE PARITY
Finds out whether N is odd or even.

FUNCTION RANGE
Puts a number into a given range.

SUBROUTINE REJECT
Decides for ARRNGE-type main programs whether the record number of a reflection occurs in a list of those to be rejected.

LOGICAL FUNCTION SAID
Decides whether the character variables INCHAR and WANT are the same, ignoring any distinction between upper and lower case.

LOGICAL FUNCTION SAYS
Decides whether the string WANT matches a string of the same length,just read into /SCRACH/ ignoring any distinction between upper and lower case.

LOGICAL FUNCTION TESTOV
Tests a floating division for potential overflow.

12. Matrices & vectors

SUBROUTINE C1MSCA
Multiplies every element of the REAL matrix A by the COMPLEX scalar SCALE.

SUBROUTINE CGMADD
Sets COMPLEX matrix C = COMPLEX matrix A + COMPLEX matrix B.

SUBROUTINE CGMEQ
Sets COMPLEX matrix B equal to COMPLEX matrix A.

SUBROUTINE CGMPRD
Multiplies together two COMPLEX matrices.

SUBROUTINE CGMSCA
Multiplies every element of a COMPLEX matrix by a COMPLEX scale.

SUBROUTINE CGMSUB
Sets COMPLEX matrix C = COMPLEX matrix A - COMPLEX matrix B.

SUBROUTINE CGMUNI
Clears a COMPLEX square matrix to contain the unit matrix.

SUBROUTINE CGMZER
Clears to zero a complex matrix.

SUBROUTINE CMCONJ
Gives the conjugate of a COMPLEX matrix.

SUBROUTINE CMIMAG
Gives the imaginary parts of a COMPLEX matrix.

SUBROUTINE CMREAL
Gives the real parts of a COMPLEX matrix.

SUBROUTINE CMRSCA
Multiplies every element of a COMPLEX matrix by a REAL scale.

SUBROUTINE CRMPRD
Performs COMPLEX by REAL matrix multiplication.

COMPLEX FUNCTION CRSCLP
Finds the COMPLEX scalar product of a COMPLEX with a REAL vector.

FUNCTION DETER3
Forms the determinant of a 3 x 3 matrix.

SUBROUTINE GMADD
Sets matrix C = matrix A plus matrix B.

SUBROUTINE GMEQ
Sets matrix B = matrix A.

SUBROUTINE GMINV
Inverts matrix A into matrix B.

SUBROUTINE GMNORM
Normalises the rows of a matrix.

SUBROUTINE GMPRD
Sets matrix C = matrix A times matrix B.

SUBROUTINE GMREV
Reverses the signs of the elements of an NI X NJ matrix.

SUBROUTINE GMSCA
Multiplies every element of the matrix A by the scalar SCALE.

SUBROUTINE GMSUB
Sets matrix C = matrix A minus matrix B.

SUBROUTINE GMTRAN
Transposes a JJxII matrix A into B.

SUBROUTINE GMUNI
Writes a unit matrix into the square matrix A.

SUBROUTINE GMZER
Clears to zero the matrix A.

SUBROUTINE JGMADD
In integers, sets matrix C = matrix A plus matrix B.

SUBROUTINE JGMEQ
Equates an integer matrix to a given integer matrix.

SUBROUTINE JGMPRD
In integers, sets matrix C = matrix A times matrix B.

SUBROUTINE JGMREV
Reverses the signs of the elements of an integer matrix.

SUBROUTINE JGMSUB
In integers, sets matrix C = matrix A minus matrix B.

SUBROUTINE JGMZER
Clears an integer matrix to zero.

SUBROUTINE MB11A
Inverts a rectangular matrix whose order is the smaller dimension; used by the Harwell refinement routine VA05A.

SUBROUTINE RCMPRD
Performs the multiplication of a COMPLEX by a REAL matrix.

FUNCTION RSCALP
Forms the scalar product of two COMPLEX vectors.

FUNCTION SCALPR
Forms the scalar product of two orthogonal vectors (or of one from real space with one from reciprocal space).

SUBROUTINE SID
Solves a set of simultaneous linear equations.

SUBROUTINE SUMVEC
Calculates the sum of elements of a real array

SUBROUTINE TRANSC
Replaces a COMPLEX square matrix by its transposed conjugate.

SUBROUTINE TRANSQ
Replaces a real square matrix by its transpose.

SUBROUTINE TRINV3
Replaces a 3x3 matrix by the transpose of its inverse.

SUBROUTINE UNIVEC
Replaces a vector by a parallel unit vector, and gives its length.

SUBROUTINE VECPRD
Calculates the vector product of two 1x3 vectors.

13. Special input/output

A. Setting up

SUBROUTINE PREFIN
Makes the Crystal Data File readable in a random order by writing it to a scratch file.

C. Utility

SUBROUTINE ASK
Writes a message on unit ITO and reads an interactive answer to /SCRACH/.

SUBROUTINE BIGCHA
Writes on unit LPT up to 9 characters in large letters.

SUBROUTINE CARDIN
Finds the record number IDEN in the DIRECT ACCESS file on unit IO10, which is a copy of the Crystal Data File.

SUBROUTINE CDFIN
Reads in one Crystal Data File and copies it to direct access unit number IO10, starting at record number ID.

SUBROUTINE CDSCAN
Finds the next card which starts with the letter given in CH, and has then a word which is one of the collection given in WORDS.

SUBROUTINE CENTRE
Writes on unit LUNIT the given message, centred & preceded by N empty lines.

SUBROUTINE CLOFIL
Closes the FORTRAN unit LUN and returns the CCSL unit to the pool.

SUBROUTINE ERRATM
Writes an error message to say that the given name is not an atom name; there is a choice of subsequent action.

SUBROUTINE ERRCH2
Write an error message which involves a given WORD between 2 messages; there is a choice of subsequent action.

SUBROUTINE ERRCHK
(Possibly increases and) checks a value, giving if appropriate an error message; there is a choice of subsequent action.

SUBROUTINE ERRIN2
Writes an error message which involves a given integer INT between 2 messages; there is a choice of subsequent action.

SUBROUTINE ERRMES
Writes an error message, with choice of action on exit.

SUBROUTINE ERRRE2
SUBROUTINE ESDFMT
Writes X and its esd DX in the form X(DX) Writes an error message which involves a given real X between 2 messages; there is a choice of subsequent action.

SUBROUTINE EXPAND
Expands UNIX pathnames by substituting for environment variables

SUBROUTINE FETTLE
Decides field width and fractional part of real number in order to print it.

CHARACTER*10 FUNCTION FILNOM
Returns the name of the file on FORTRAN unit LUN.

SUBROUTINE FILPRO
Makes sense of general file names, under VMS AND UNIX.

SUBROUTINE FINDCD
Searches for a card starting with letter CH and with WORD in columns 3-6.

CHARACTER *4 FUNCTION GENNAM
Finds all the starting letters of an atom name.

SUBROUTINE INCREM
Increments a file name.

SUBROUTINE INITIL
Initialises the CCSL system.

SUBROUTINE INPUTI
Gathers information from a user's interactive instruction card.

SUBROUTINE INPUTN
Deals with the "N" card giving the Crystal Data File title.

SUBROUTINE INTCHR
Converts digits to characters, either left- or right-justified.

SUBROUTINE INTDIG
Unpacks an integer into its individual digits.

FUNCTION IPOPE
Machine specific routine to interpret error codes during file opening.

FUNCTION LENG
Determines the length of a text string, omitting trailing spaces.

FUNCTION LENGT
Determines the length of a character variable, omitting the final spaces.

LOGICAL FUNCTION LERCHK
FALSETRUE or TRUE according to whether NVALUE (possibly incremented) is greater than NBOUND

FUNCTION LETTER
Determines whether a character is a letter.

CHARACTER *4 FUNCTION MAKNAM
Makes an A4 name from the given character and the digits of the given number.

SUBROUTINE MESS
Writes on unit LUNIT the given message, preceded by N empty lines.

FUNCTION NCHINT
Converts an ASCII character into an integer

FUNCTION NDIGIT
Identifies a character as a digit or not.

SUBROUTINE NEWLIN
Writes a newline to the output unit LUNIT

SUBROUTINE NEWPAG
Writes a newpage carriage control ('1') to the output unit LUNIT

FUNCTION NOPFIL
Opens a file on a FORTRAN unit for the first time in this job.

FUNCTION NSYMBL
Finds whether the character I is one of the symbols recognised by the system.

SUBROUTINE NUMA1
Prepares a number for writing, probably on a plotter.

SUBROUTINE NUMDEN
Converts a real number to the numerator and denominator of a fraction.

LOGICAL FUNCTION ONCARD
Finds a card which starts with the given letter and word, and reads one number from it.

SUBROUTINE OPNFIL
Opens file L according to requirements given in M; L may be preset.

SUBROUTINE PRILIS
Prints a list of real numbers held in an array, 5 per line.

SUBROUTINE PRIPLN
Given the normal to a plane face in A, prints the equation of the plane.

SUBROUTINE PUTPAR
Distributes parameters read by RDNUMS amongst individually named variables.

SUBROUTINE RDDATA
Reads in free format h,k,l (possibly floating) and a list of values, allowing for a possible title.

SUBROUTINE RDINTG
Reads an integer in free format from a character string.

SUBROUTINE RDNUMS
Reads all the numbers on a line in free format.

SUBROUTINE RDREAL
Reads a real number in free format from a character string.

SUBROUTINE RDWORD
Reads the next word from a character string.

SUBROUTINE RDWRDS
Reads all the words on a line from column 3 onwards.

SUBROUTINE TESTP
Puts a given heading at top of every printer page, counting lines.

SUBROUTINE UPLOW
Makes first letter of C upper case, and any subsequent letters lower case.

SUBROUTINE UPONE
Puts character strings into all uppercase or all lower case depending on ISYS

SUBROUTINE UPPER
Replaces any lower case letters in C by upper case

14. Graphical output

A. Setting up

SUBROUTINE GETSCL
Chooses a sensible scale for a graph.

SUBROUTINE PINITL
Initialises the system in order to make graphical output.

SUBROUTINE STPLOT
Sets up the plotting of maps; fits elements of a picture together.

B. Crystallographic

SUBROUTINE PICMOV
If plotting to Tektronix, do nothing; if to plotter, move to next picture.

SUBROUTINE PLCONV
Performs the transformation of coordinates between different plotter spaces.

SUBROUTINE PLOTCT
Plots a single contour throughout a given array.

SUBROUTINE PLOTIT
Plots the graph of given vector y against x, with esds.

SUBROUTINE PLOTO
A multi-purpose graph-drawing routine.

SUBROUTINE PLTRIN
Defines a new coordinate transformation for plotting.

SUBROUTINE PMTINV
Specialist routine to invert a 2x3 matrix, such as those which transform plotting coordinates from one space to another.

SUBROUTINE PMTMUL
Specialist routine to multiply together two 2x3 matrices, such as those which transform plotting coordinates from one space to another.

SUBROUTINE SPCSET
Defines the "space" in which coordinates will be given for plotting.

C. Utility

SUBROUTINE ARROW
Draws an arrow centred at X,Y in the current space.

SUBROUTINE CIRCLE
Draws a circle of given radius and centre, with various options.

SUBROUTINE DPLOT
Does plotting in current coordinate system.

SUBROUTINE FRAME
Draws a rectangle in the plotting context.

SUBROUTINE KANGA1
Moves plotter pen (or equivalent) to X,Y in current coordinates.

SUBROUTINE KANGA2
Writes on a plot a string of characters, or simulates this in order to measure the length of the string.

SUBROUTINE KANGA3
Plots a special symbol.

SUBROUTINE PIGLET
A complete set of device-specific plotting commands.

15. Logical operations

SUBROUTINE BITSET
Sets or tests a single bit in a word.

SUBROUTINE GETSQ
Works out where a contour crosses the sides of a square of function values.

FUNCTION ITPOS
Sets ITPOS=a single bit (a one), in position IPOS, counting from the right.

SUBROUTINE LOCBIT
A specialist routine for contour plotting, which finds the "next" bit in the bit-map, removes it, and indicates where on the picture it was.

FUNCTION LOGAND
Performs logical "and" on 2 whole integers.

FUNCTION LOGOR
Performs logical "or" on 2 whole integers.

SUBROUTINE MAKEBM
A specialist contour plotting routine which makes a bit map to show where the contours are.

16. Miscellaneous

SUBROUTINE BATCH
Signals batch running, not interactive.

SUBROUTINE DUMMY
Does absolutely nothing; used as a default in routine calls.

SUBROUTINE FLIP
Exchanges the integers I and J.

FUNCTION JFIX
Rounds a real to be an integer.

FUNCTION NSIGFG
SUBROUTINE NPACK
Deals with the packing and unpacking of up to 10 integers in/out of one Returns the number of figures to print after the decimal point based on the ESD dx integer.

FUNCTION NTICK
Advances its argument by 1 and sets the function to that value also.

SUBROUTINE RESHUF
Reorders a real array, given a parallel pointer array out of SORTX.

SUBROUTINE SORTN
Sorts pointers to an integer array using Heapsort.

SUBROUTINE SORTX
Sorts pointers to a real array using Heapsort.

17. Magnetic routines

A. Setting up

SUBROUTINE INPUTQ
Reads individual "Q" cards

SUBROUTINE LOGMAG
Sets mnemonic logicals from the type of magnetic structure.

SUBROUTINE MAGCNC
To find magnetic constraints in a non-least squares calculation.

SUBROUTINE MAGCNL
Does the fixing associated with constraints found by MAGCON and PSICON.

SUBROUTINE MAGCON
Finds and reports the symmetry constraints on magnetic parameters.

SUBROUTINE PROPER
Determines whether the satellites generated by the propagation vector PROP have integer indices, and generates its "star".

SUBROUTINE PSICON
Determines the constraints on the phase factors in helimagnets.

SUBROUTINE READRT
Reads whatever follows on a "W atom-name ROTN" card.

SUBROUTINE SETFCM
Calls the routines needed to set up magnetic structure factor calculations (or non-magnetic also).

SUBROUTINE SPHPOL
Sets up spherical polar spin directions for magnetic structures.

B. Crystallographic

SUBROUTINE CALDSM
Calculates d star squared, and its derivatives wrt reciprocal cell quadratic products and components of propagation vector.

SUBROUTINE CENTRO
Executes the action of the centre of symmetry on a term in the magnetic structure factor for helimagnetic structures.

SUBROUTINE DOMAG
Multiple entry subroutine to deal with parameters for magnetic structures on Q cards (but not their fixing/varying).

SUBROUTINE FMCALC
Calculates magnetic interaction vectors and magnetic structure factors.

FUNCTION LMAGPR
Gives the fix/vary information for one of the family 2 parameters for magnetic atoms.

SUBROUTINE LMCALC
Calculates a magnetic structure factor and its derivatives.

LOGICAL FUNCTION MAGABS
Tests for systematic absence of magnetic reflections.

SUBROUTINE MAGDIR
Calculates various geometric corrections for various magnetic states. The ENTRY ENTMAG sets up the COMMON.

SUBROUTINE MAGDOM
In Least Squares refinement with magnetic scattering, forms the matrix needed for derivatives of Q with respect to a spin direction.

SUBROUTINE MAGSYM
Routine with 4 named entry points, MAGSYM, MELIN, NELIN and ROTMAG, to deal generally with magnetic symmetry. MAGSYM sets magnetic symmetry, MELIN puts in an operator for a generator, NELIN puts in non-symmetric rotation and ROTMAG rotates with a magnetic operator.

SUBROUTINE MAGVAR
Records the initial fixing, or subsequent varying of magnetic parameters.

SUBROUTINE MOLORB
To read molecular orbital wave-functions from "W atom-name FUNC" card.

SUBROUTINE PROPDR
Makes derivatives of d*sqrd with respect to the magnetic propagation vector

SUBROUTINE SATFND
Finds the indices HS of the satellite equivalent to H, offset by the propagation vector PROP from a reciprocal lattice point.

SUBROUTINE SATGEN
Generates a set of magnetic satellite reflections.

SUBROUTINE SPHELI
Imposes perpendicularity on the two components of a helix.

C. Utility

FUNCTION ASPHFF
Calculates an aspherical form factor for a cubic space group.

SUBROUTINE GENMAG
Generates the next set of magnetic h,k,l, scanning the asymmetric unit.

SUBROUTINE MTPROD
Puts entries into the table of time inversion operators.

18. Multipole routines

A. Setting up

SUBROUTINE INPUTJ
Reads individual J cards.

SUBROUTINE MPCON
Finds the symmetry constraints on multipoles.

SUBROUTINE MPFORM
Finds out which radial form factors to apply to which atom and L value.

SUBROUTINE ORTFUN
Finds the best set of orthonormal functions compatible with symmetry based on the users input, and hence defines the multipoles to refine.

SUBROUTINE PFSET
Directs the reading of J and W cards for multipole calculations.

SUBROUTINE REAORB
To change the orbital basis from Ylm and Yl-m to (Ylm +- Yl-m).

B. Crystallographic

SUBROUTINE MF5ADD
A specialist routine to deal with the refinement of multipoles. Converts each type of LSQ family 5 (multipoles) addressing to the other.

COMPLEX FUNCTION PFCALC
Calculates the COMPLEX nuclear structure factor for the reflection H, using a multipole expansion of the form factor.

SUBROUTINE PFORMF
Calculates radial form factors for multipole refinement.

C. Utility

SUBROUTINE NAMPOL
Creates the label for a given multipole.

P. Jane Brown (brown@ill.fr)