Contents Manual

General Library Subroutines

. Profile Refinement

SUBROUTINE CALCFR(H,SFCALC,MGCALC)
Calculates GCALC = the flipping ratio and its derivatives for twinned
crystals
SUBROUTINE DOTWN1(MODE)
LOGICAL FUNCTION DOTWN2(NN,MODE)
Routine to process twin parameters
SUBROUTINE LATVCS(STEP,AVEC,NPRIM)
Determines whether STEP defines a primitive lattice and if not returns
the non-primitive vectors.
FUNCTION LCOLPG(NAME)
Returns the number of color NAME, or 0 if NAME not in PGNAME
FUNCTION LSYMPG(NAME,FILL)
Returns the symbol type as defined by KANGA3 for NAME and FILL
SUBROUTINE MUCALC
To calculate induced moments from anisotropic susceptibilities and
elipsoid orientation

1. Basic Crystallography

A. Setting Up

SUBROUTINE ADDELM(ITAB,IEL,IJTAB,NUM)
Adds the element IEL to the subgroup defined by ITAB
SUBROUTINE CELLMA(BGTOSM)
Makes the matrix to transform the variance/covariance matrix for the
quadratic products to that for a,b,c etc
SUBROUTINE COSET(JEL,ICOSET,N,IFTAB,NGP)
Returns the coset in the full group generated by a given element of
one of its sub-grouo
SUBROUTINE FACGRP(ISTAB,ISFTAB,NFAC)
Finds the factor elements which generate a space group from one of its
sub-groups.
SUBROUTINE FIXUNI(A,NDO)
Deals with one potential plane face of asymmetric unit, while the unit
is being formed.
SUBROUTINE GENGRP(ITAB,JTAB,IJTAB,MODE,PRODCT)
Generates the product of two subgroups of the space group in SYMTAB
SUBROUTINE INPUTC(ID,CELL)
Reads one "C" card .
SUBROUTINE INPUTS(ID,R,T)
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(HT)
Reads and interprets a
"U" card , giving a typical reflection to define the reciprocal asymmetric unit.
SUBROUTINE MAKGRP(IGSB,IOPS,MODE,PRODCT)
Generates the subgroup of a space group from the given generators.
SUBROUTINE ORTHG(IOP)
Calculates matrices for the transformation of vectors in real or
reciprocal space, between crystallographic and orthogonal axes.
SUBROUTINE PLN3AD(I,J,K)
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
Reads the lattice parameters and forms the reciprocal cell.
SUBROUTINE RECISD(MODE)
Interprets a "C
S D" card and calculates ESD's in both the cell parameters and their quadratic products
SUBROUTINE SETFC
Calls all the setting up routines needed for nuclear structure factor
calculations.
SUBROUTINE SPACE(NT,NSCR,NGENS)
Interprets symbols from an
S card which are the space group name.
SUBROUTINE SPGNAM(N,NAME)
Decodes space group symbol or integer from
S GRUP card
SUBROUTINE SYMCEN(NC)
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(NC)
Tidies all the arrays connected with the space group symmetry.
SUBROUTINE SYMUNI
Selects a reciprocal space asymmetric unit fitting the symmetry.
SUBROUTINE TRYUNI(NCHK)
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(A,B,IR)
Calculates the angle in radians between two vectors, in either space.
SUBROUTINE ASUNIT(H,HIN,N,M)
Produces reflection indices in the asymmetric unit, related to those
given.
SUBROUTINE CELMAT(TOSTAR)
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(R,T,N,L)
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(ANG,SYM,ROT)
Finds the Euler angles correponding to a symmetry rotation.
SUBROUTINE GENELM(NSUB,ISGEN)
Finds the generators of a subgroup of a space group.
LOGICAL FUNCTION ISPABS(H)
Checks space group absences.
LOGICAL FUNCTION LATABS(H)
Checks h,k,l for being a (nuclear) lattice absence.
SUBROUTINE LATGEN(KI,K,KLIM,DONE,ISW,ISWO)
Generates points on a lattice.
LOGICAL FUNCTION LATVEC(X)
Tests for the presence of a lattice vector.
SUBROUTINE OPMSYM
Prints out the magnetic symmetry operations.
SUBROUTINE OPSYM(ISYM)
Prints out the symmetry operators in either real or reciprocal space.
SUBROUTINE ORTHO(H,OH,IR)
Carries out conversions between crystallographic and orthogonal axes.
SUBROUTINE RECELL(N,M)
Makes real or reciprocal space cell parameters from the others.
SUBROUTINE ROTOSM(H,RH,IOP,ISS)
Calculates the effect of the rotation matrix of a symmetry operator, on
a vector given on orthogonal axes. ENTRY CROTO(CH,CRH,IOQ,IST)
SUBROUTINE ROTSYM(H,RH,IOP,ISS)
Rotates the vector H into RH by the given symmetry operator.
FUNCTION SCLPRD(H1,H2,IR)
Forms the scalar product of two vectors referred to crystal axes.
SUBROUTINE SUBSYM(ITAB)
Replaces all the symmetry parameters by those of a subgroup.
SUBROUTINE SYMBAK
Restores the original symmetry operators after a call to SUBSYM.
SUBROUTINE SYMREF(HIN,HOUT,NREFS,PHASE)
Generates a set of equivalent reflections and related phases.
FUNCTION VCTMOD(SCALE,H,IR)
Calculates the modulus of the vector H, in either space.

C. Utility

SUBROUTINE AXIS(R,A)
Finds the axis of a given rotation matrix.
SUBROUTINE FCTOR(H,N)
Finds the highest common factor of a set of indices and reduces them by
that factor.
SUBROUTINE FRAC3(VEC)
Makes all 3 elements of a vector fractional
SUBROUTINE INVENT(U,H,ANS)
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(J)
Returns the order of the Jth symmetry operator.

2. Data Collection and Reduction

A. Setting Up

SUBROUTINE ARPRIN(H,FBUF,MODE)
A multi-mode routine to produce the output in ARRNGE type main programs.
SUBROUTINE ARREAD(H,FBUF,IEND)
Multiple entry routine to deal with reading items for ARRNGE type
programs.
SUBROUTINE GAUSPT(NN,GPT,GWT)
Sets up Gauss points and weights for use in 3D integration.
SUBROUTINE ICDFMT(INC,ITEMS)
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 up and down polarisations of a polarised neutron beam.

B. Crystallographic

SUBROUTINE ABMULT(H,ABSC)
Forms transmission (=1/absorption) factors or related integrals.
SUBROUTINE ABSCOR(IS)
Applies absorption corrections to groups of equivalent reflections.
FUNCTION ABSOR(H)
Forms a transmission (=1/absorption) factor or related integrals.
SUBROUTINE AINOUT(K,FBUF,N,N1,MODE)
Multiple function routine called by ARRNGE type programs to process
sort items.
SUBROUTINE ALRPOL(H,ALR,POL,MODE)
Calculates the reciprocals of Lorentz and polarisation factors.
SUBROUTINE ANGDIR(H,ANG)
Calculates D3 or 4-circle angles from direction cosines.
SUBROUTINE BIGGAM(K,IQ,CSMAX,LBIG)
Deals with gammas whose value is greater than one, in SORGAM. There is
also the entry SETGAM to set up the calculation. ENTRY SETGAM(SOME,LBIG)
SUBROUTINE EXTINC(N,F)
Multi-entry routine to deal with all aspects of single crystal
extinction corrections. ENTRY EXTIN1
ENTRY EXTIN3(NP)
ENTRY EXTIN4
ENTRY EXTIN8(NP,NV)
ENTRY EXTIN9
SUBROUTINE EXTPAR(H,WLGTH,TM)
Calculates the theta dependent extinction parameters for reflection H
SUBROUTINE FGAMMA(R,M,QQ,QL,RMS)
Calculates gamma, the ratio of magnetic and nuclear scattering, and its
standard deviation.
SUBROUTINE GAMEX(R,G,FC,QQ,QL,RMS,IERR)
Calculates an extinction corrected gamma from a flipping ratio.
SUBROUTINE GETDC(H,DIREC)
Calculates direction cosines of the incident and diffracted beams used
by absorption correction type integrals
SUBROUTINE QARRIN(N,K,FBUF,LUNI,IEND)
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 QARRIN.
SUBROUTINE STATIS(MODE)
Calculates means and other statistics for a set of measurements of a
single quantity.

C. Utility

FUNCTION INPUAR(M,LUN)
Reads the data from files made by ARRNGE and other similar programs.
FUNCTION LISPEC(PATHIN,ICYC,NUMOR,TEXT,ITEXT,IPARS,NINTS,
FPARS,NREALS,SCAN,NSPTS)
Reads files from the ILL data base
SUBROUTINE LSTCTS(C,D,TMORTS)
Calculates a dead time correction
SUBROUTINE MULIND(MUL)
Used by ARRNGE for data whose indices may be submultiples of integers ENTRY INDMUL(HI,HO)
ENTRY INDDIV(HI,HO)
LOGICAL FUNCTION REAPOL(H,POL,DPOL,MTYP,TEMP,TITLE,LUNI)
Reads polarisations from the .pol file written by CRYPAD

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(S)
Sets up the generation of a complete set of reflection indices.

B. Crystallographic

SUBROUTINE GENMUL(H,NOMORE,M)
Gives next useful set of h,k,l and multiplicity, scanning the asymmetric
unit of reciprocal space.
SUBROUTINE GETGEN(H,NOMORE)
Gives the next useful set of h,k,l scanning the asymmetric unit of
reciprocal space.
SUBROUTINE INBOX(H,IN)
Determines whether the given reflection is inside, on, or outside the
reciprocal space asymmetric unit.

C. Utility

SUBROUTINE INDFIX(H,K)
Converts 3 real items in H to be integers in K.
SUBROUTINE INDFLO(H,K)
Converts 3 integers in K into floating point reals in H.
LOGICAL FUNCTION INTIND(H,K)
True if the indices H(3) are integer
FUNCTION MATCH(K)
Checks to see whether two sets of reflection indices match.
FUNCTION MATCHF(F)
Checks to see whether two sets of floating point reflection indices
match.
FUNCTION MULBOX(H)
Tests indices for being in the asymmetric unit, and gives multiplicity.

4. Structure Factor Calculations

A. Setting Up

SUBROUTINE ATOPOS
Reads and interprets all given
A cards .
SUBROUTINE INPUTA(ID,LABA,LBALEN,LABS,LBSLEN,X,T,S,IER)
Reads an
A card and prepares it for further processing.
SUBROUTINE INPUTF(ID,LABF,LBFLEN,NTYP,IPT,IER)
Reads and partially interprets an "F" card .
SUBROUTINE INPUTT(ID,LABA,LBALEN,NTYP,A,IER)
Reads and interprets one "T" card .
SUBROUTINE INPUTW(IAT,XWORD,ID,IPT)
To read the
"W" card indicated by ID, as far as atom label and word.
SUBROUTINE RADFUN(JAT,IEND)
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(H,N)
Forms the contribution to the anisotropic temperature factor on an atom
N from indices H.
SUBROUTINE ATOMS(IR,N,ALIST,MAX)
Makes a real space unit cell full of related atomic positions.
FUNCTION CONATF(N,IA)
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(H)
Calculates the COMPLEX nuclear structure factor for the reflection H.
COMPLEX FUNCTION FORMFA(AK,II)
Calculates form or scattering factors.
FUNCTION FORMFC(AK,L,MODE,JAT)
Calculates form factor integrals from radial wave functions.

5. Fourier Calculations

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(C,ICON,MORE)
Sets up the "next" contour value to plot for Fouriers.
SUBROUTINE SETFOU(MNEED)
Sets up data for Fourier map calculations.
SUBROUTINE UNUSYM
Undoes the transformsation of symmetry operators by pre- and
post-multiplying them by the inverse of the orientation matrix for a Fourier map.
SUBROUTINE USYM(N)
Transforms all the symmetry operators by pre- and post-multiplying them
by U, the orientation matrix for a Fourier map.

B. Crystallographic

SUBROUTINE ATMPLO(IFND,NFND,JP)
Plots atom positions on a map.
SUBROUTINE ATMPLT(ZED)
Plots atom positions on a map.
SUBROUTINE ATOGEN(MOLD)
Generates a set of equivalent positions.
SUBROUTINE ERRMAP
Calculates the standard deviation of the density in a Fourier map.
SUBROUTINE FORIER(IIN,IOP,START)
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(CFOUND,IC,IBMAX,IFMAX)
After a Fourier map has been plotted, sends to the plotter the list of
contours which were plotted, with a frame.
SUBROUTINE MAPDRW(CFOUND,IC,IBMAX,IFMAX)
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(IFND,NFND,JP)
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(L21)
Prints out a Fourier projection or one layer of a 3D Fourier.
SUBROUTINE QFOUIN(K,F,ALPHA,ENDD)
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(H,D)
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(HI,H,K,N,MI,UU,BETA)
Generates new indices and a phase, in Fourier calculations.
SUBROUTINE TBOUND(IFOUND)
A specialist routine used duing the plotting of atomic positions in main
program ATMPLO.

C. Utility

SUBROUTINE CHOOSF(F,SF,ALPHA1,ALPHA,MODEF)
Chooses modulus and phase for a particular Fourier.
SUBROUTINE DOSIDE(A,B,ISIDE,NR,NC,X,Y)
A specialist routine for contour plotting, to help to decide where a
contour crosses the side of a square.
SUBROUTINE FOUINP(K,F,ALPHA,MODED,MODEF,ENDIP)
Reads one data item for a given type of Fourier, in a given format.

6. General Least Squares Refinement

A. Setting Up

SUBROUTINE CELREL(IFAM,IGEN,ISPC)
Transfers any relations which exist between cell parameters from their
own COMMON to the general "contraint/fixing" COMMON.
SUBROUTINE F2VAR8(NG,NS,NV)
Records varying information for a particular family 2 (structure)
parameter. ENTRY F2VAR9
SUBROUTINE FIXPAR(NP,NFIX)
Records an instruction to fix a LSQ parameter.
SUBROUTINE FIXREL(N,NFIX,FIX,KKLIST,NSTAT)
Takes a temporary set of fix/relate information and adds it to the
permanent information.
SUBROUTINE FUDGIN
Interprets all L FUDG cards .
SUBROUTINE GEOMIN(N)
Reads
L cards for bond slack constraints.
SUBROUTINE IICD1
Interprets basic
I cards to drive any LSQ.
SUBROUTINE LLSCAL(N)
Multiple entry routine which deals with scale factors in Least Squares. ENTRY LSCAL8(NP,NV)
ENTRY LSCAL9
SUBROUTINE LLTFAC(N)
Multiple entry routine which deals with overall isotropic temperature
factors in Least Squares. ENTRY LTFAC8(NV)
ENTRY LTFAC9
SUBROUTINE LSETSF(NW,LSPEC,LWORDS)
Sets up vocabulary for a specific LSQ problem involving structure
factors.
SUBROUTINE LSETUP(NW,LSPEC,LWORDS)
Sets up specific LSQ problem - copies the vocabulary to standard COMMON.
SUBROUTINE RDFV(DOTHER)
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(N1,A1,N2,A2,NFIX,FIX)
In the setting up of LSQ applications, relates two parameters by a
simple linear relationship.
SUBROUTINE RELSM3(R,NFIX,FIX)
Forms a complete set of relations imposed by symmetry on the given 3
parameters of a LSQ application.
SUBROUTINE RELSM6(R,NFIX,FIX)
Forms a complete set of relations imposed by symmetry on the given 6
parameters of a LSQ application.
SUBROUTINE SCLCHN(NP,A,NFIX,FIX)
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(DEFALT,GETPAR,VARSXX,DOTHER)
Makes variables for a LSQ cycle from given FIX/VARY and CONSTRAINT
lists.
SUBROUTINE VOCAB(WORD,MEAN,NW)
Adds a given set of vocabulary and meanings to the Least Squares total
vocabulary.

B. Crystallographic

SUBROUTINE CELDER(H,DERS)
From h,k,l calculates d* squared and its derivatives, and sets SSQRD.
SUBROUTINE F2NEW(L)
Outputs a new LSQ family 2 (structure parameters) card (for A, T or
F cards ).
SUBROUTINE F2RELA(IFAM,ISPVEC)
Collects all structure factor type constraints implied by the symmetry.
SUBROUTINE F2SHFT
Applies a shift to a particular family 2 (structure) parameter.
SUBROUTINE GEOMLS(ALSQ,MATSZ)
Calculates bond lengths and derivatives for geometrical slack
constraints.
SUBROUTINE LFCALC(H)
Calculates a nuclear structure factor and its derivatives.
SUBROUTINE MATCEL(ALSQ,MATSZ)
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(K,IEND)
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 REINDX(DPROP)
To reindex a set of reflections after a least squares cycle in which
the propagation vector changes
SUBROUTINE RFACS(IN)
A multiple entry routine to deal with all aspects of R Factor
calculations and statistics for single crystal observations, and
SUBROUTINE RREFSF(LUNR,H,K,IEND)
A common interface for reading reflection data in structure factor LSQ
SUBROUTINE XYZREL
Collects all position parameter constraints implied by the symmetry.

C. Utility

SUBROUTINE ADDCON(NPAR,KK1,AM,NSTAT)
Adds a constraint to the list held in LSQ programs. ENTRY RELCON(NPAR,KK1,AM,NSTAT)
ENTRY SUBCON(NPAR,KK1,AM,NSTAT)
SUBROUTINE ADJUST(PAR)
Applies a (possibly fudged) shift to a given LSQ parameter.
SUBROUTINE CELNEW
Writes out a new
C card after cell parameter refinement.
SUBROUTINE CELSDP(ALSQ,MATSZ)
Prints the esds of real cell parameters after a cycle of refinement.
SUBROUTINE CELSHF(N)
Applies a shift to a cell quadratic product. ENTRY CELVAR(N,NV)
SUBROUTINE DEPRIN(IPRNT)
Decodes an integer which describes the frequency of LSQ printing
required, and outputs this frequency.
FUNCTION ELEMAT(ALSQ,MATSZ,I,J)
Gets a matrix element from the triangular LSQ matrix.
SUBROUTINE FETSHF(N,SH,ES)
Fettles a shift and esd for printing and counts, in the application of
shifts in LSQ.
SUBROUTINE FIXVAR(FX,IFAM,IGEN,ISPC,KP,KS,NSTAT)
Adds a request to fix (or vary) a parameter to the lists held in setting
up LSQ environments. ENTRY ADDFX5(IFAM,IGEN,ISPC,KP,KS,NSTAT)
ENTRY ADDVR5(IFAM,IGEN,ISPC,KP,KS,NSTAT)
ENTRY ADDFIX(KKK,NSTAT)
ENTRY ADDVAR(KKK,NSTAT)
ENTRY FVKPAK(KKK,NSTAT,FX)
SUBROUTINE FUDGET(IPT,ITYP,F1,F2)
Reads a fudge factor from a card having already read a parameter
specification.
SUBROUTINE GEOMCO(N)
Multiple entry routine for geometric slack constraints.
FUNCTION KPAK(IFAM,IGEN,ISPC,KP,KS)
Pack a LSQ parameter specification on to integer.
LOGICAL FUNCTION KSAME(KK1,KK2)
Tells if two LSQ parameter specifications are the same, allowing wild
card elements.
SUBROUTINE KUNPAK(KK,IFAM,IGEN,ISPC,KP,KS)
Unpacks a LSQ parameter specification from single integer.
LOGICAL FUNCTION KWHOLE(KK,K)
Says if KK is a whole packed parameter specification, or whether there
are wild card elements.
SUBROUTINE MATCOR(ALSQ,MATSZ)
After a Least Squares cycle, prints correlations from the inverse
matrix.
SUBROUTINE MATINV(ALSQ,MATSZ)
Inverts the matrix in ALSQ, of which the upper triangle only is held.
SUBROUTINE MATSET(ALSQ,MATSZ)
Sets up pointers into a Least Squares matrix, and clears the matrix and
the corresponding right hand side vector.
SUBROUTINE MATSHF(ALSQ,MATSZ)
From an inverted Least Squares matrix, calculates shifts in basic
variables.
SUBROUTINE MATTOT(ALSQ,MATSZ)
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.
SUBROUTINE PARNAM(IPNAM1,IPNAM2,N,M)
Obtains the printing name of a LSQ parameter.
SUBROUTINE PARRD(IPT1,IPT2,K,IFAM,IGEN,ISPC)
Reads a LSQ parameter specification from a given card at given point.
SUBROUTINE PARRUN(IFAM,IGEN,ISPC)
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(IFAM,IGEN,ISPC,NAME,MODE)
Finds the name of the packed (possibly part) LSQ parameter from the
built-in table of parameter names.
LOGICAL FUNCTION PRNCYC(N)
Decides whether printing (of various different quantities in LSQ) is
needed during the current LSQ cycle.
SUBROUTINE PUNPAK(KK,IFAM,IGEN,ISPC)
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(M,N,F,X,W,S,H,SD)
Called after VA05A to give the standard deviations of the parameters.
SUBROUTINE SHFESD(J)
During the application of LSQ shifts, calculates the shift and ESD for a
"redundant" variable.
LOGICAL FUNCTION SYMFIX(KK)
Says whether a LSQ parameter is fixed by symmetry or not.
SUBROUTINE TBLFND(NAME,IANS,IFAM,IGEN,ISPC,KP,KS)
Looks for an A4 NAME in every table it can find, trying to identify it
as part of a LSQ parameter name.
SUBROUTINE VA05A (M,N,F,X,DSTEP,DMAX,ACC,MAXFUN,IPRINT,W)
Minimises the sum of squares of given functions without requiring the
explicit calculation of derivatives.
SUBROUTINE WGHTLS(N,ARG)
Performs various operations to do with weights for LSQ, either for PR
or simpler applications. applications.
SUBROUTINE WGHTSF
Deals with weights of LSQ observations for single crystal.

7. Specific Least Squares Refinement

A. Setting Up

LOGICAL FUNCTION DFLTMG(IFAM,IGEN,ISPC)
Called as a substitute for DEFALT via VARMAK, giving default fix/vary
for otherwise unspecified parameters for magnetic structures.
LOGICAL FUNCTION DFLTMP(IFAM,IGEN,ISPC)
Called as a substitute for DEFALT out of VARMAK, giving defaults
fix/vary for otherwise unspecified parameters of multipole refinements.
LOGICAL FUNCTION DFLTSF(IFAM,IGEN,ISPC)
Called as a substitute for DEFALT out of SUBROUTINE VARMAK, giving
default fix/vary information for structure parameters.
LOGICAL FUNCTION DFTRUE(IFAM,IGEN,ISPC)
Called as a substitute for DEFALT out of VARMAK in main programs, to
vary an otherwise unspecified parameter.
SUBROUTINE F2PARP
Dummy routine to force inclusion of BLOCK DATA F2PARS
SUBROUTINE INOBGR(ISCR)
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.
LOGICAL FUNCTION LDUMMY(NN,MODE)
A dummy function to be called by APSHSF,VARSSF etc in simple structure
factor LSQ
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 VARSSF(DOTHER)
Records variable pointers for all variables in structure-factor LSQ.

B. Crystallographic

SUBROUTINE ADDPLN(NIN,N)
A dummy routine at the moment, called when setting slack constraints
SUBROUTINE APSHDS
Applies shifts for during d-spacing refinement.
SUBROUTINE APSHFW
Applies shifts for Forsyth & Wells scattering factor coefficient
refinement.
SUBROUTINE APSHSF(MAGSHF)
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(H)
Calculates d star squared, and its derivatives wrt reciprocal cell
quadratic products.
SUBROUTINE CALCFW(S)
Calculates the Forsyth & Wells exponential function which approximates
to observed scattering factor curves.
SUBROUTINE CALCGR(H,FAC)
Gives the calculated function for grouped single crystal Least Squares.
SUBROUTINE CALCMG(H,SFCALC,MGCALC)
Calculates GCALC and its derivatives for structures which may have mixed
magnetic and nuclear reflections.
SUBROUTINE CALCMP(H)
Makes the calculated function and derivatives for single crystal LSQ
with multipoles.
SUBROUTINE CALCSF(H,SFCALC)
Makes the calculated function and derivatives for single crystal LSQ.
SUBROUTINE CALPOL(H,NEW,ICOMP,SFCALC,MGCALC)
Calculates scattered polarisations and their derivatives for structures
which may have mixed magnetic and nuclear reflections.
SUBROUTINE CONVMP(MODE)
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(H)
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 NWINSF(MAGNEW)
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(MAGPAR)
Collects all parameter fix and vary information for single crystal LSQ.
SUBROUTINE VARST2
Makes variables for zero and cell for T2 type LSQ

8. Crystal Geometry

A. Setting Up

SUBROUTINE ADDANG(NAME,N1,N2,N3,NA,IE)
Finds an angle in the tables for geometric constraints, or adds it if
absent.
SUBROUTINE ADDATM(NAME,IA,XA,ISA,ILA,CELA,N)
Finds an atom in the tables for geometric constraints, or adds it if
absent.
SUBROUTINE ADDBON(NAME,NA1,NA2,NA)
Finds a bond in the tables for geometric constraints, or adds it if
absent.
SUBROUTINE ADDTOR(NAME,N1,N2,N3,N4,N5,N6,NT,IE)
Finds a torsion angle in the tables for geometric constraints, or adds
it if absent.
SUBROUTINE RDANGL(IPT,N1,N2,N3,NCOM,IE)
Reads a specification of a bond angle, by reading the names of 2
intersecting bonds; makes the third bond involved.
SUBROUTINE RDATOM(IPT,IA,XACT,ISYMM,ILATT,CS)
Reads the specification of an atom for slack constraint purposes
SUBROUTINE RDBOND(IPT,NEND,IE)
Reads a specification of a bond, by reading the names of the atoms at
each end.
SUBROUTINE RELCL6
Determines the constraint matrix for the cell quadratic products needed
for determining esd's of bond lengths and angles

B. Crystallographic

SUBROUTINE ANGERS(I1,NB1,NB2,COSANG,ANGER)
To calculate esd's in bond angles
SUBROUTINE ANGLST(I1)
Lists all angles at one source atom made by a given list of bonds.
SUBROUTINE BNDLST(NAME1,NAME2)
Writes out and saves a list of bonds from one atomic position.
SUBROUTINE BONCOS(B1,B2,B3,ANGLE,COSTH,SINTH,DADB)
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(I1,I2,I3)
Calculates the angle between two bonds.
SUBROUTINE BONDER(N)
Calculate a bond and its derivatives for slack constraints.
SUBROUTINE BONERR(I1,I2,IS,XBON,BL,BERR)
To calculate the esd's in bondlengths
SUBROUTINE BONTRI(N1,N2,N3,K,IE)
Given two bonds with a common atom, completes the triangle and
identifies the atom.
SUBROUTINE INCELL(X,P)
Sets P to be the position in the central cell equivalent to X.
SUBROUTINE RELMT3(IPFIX,APFIX,IOP,RLMAT)
Determines symmetry constraints in the calculation of the esd's of bond
lengths and angles
SUBROUTINE RELMTX(RELMT1,RELMT2,IATS,NA)
Makes the matrix relating the coordinates of NA atoms, which may or may
not be equivalent to one-another, to a set of basic variables
SUBROUTINE RELPOS(IAT,NFIX3,FIX3)
Gets the constraints imposed by the symmetry on a set of atomic
positions.
SUBROUTINE XROOT(IA,XX,IS,IL,C)
Finds the symmetry operations which take the given source atom into the
given coordinates.
SUBROUTINE XTRANS(IAT,XX,IS,IL,C)
Transforms a given atomic position by given symmetry operator and
lattice and cell translations.

C. Utility

SUBROUTINE ATSPEC(N,K,CH)
Makes the 16-character specification of a symmetry related atom from its
packed specification.

9. Mathematical Functions

A. Setting Up

SUBROUTINE SPLINE(N,X,F,D)
Sets up a cubic spline to fit a curve.

C. Utility

FUNCTION ALNINT(A,B,X,N)
Performs linear interpolation, suitable for profile backgrounds etc.
FUNCTION BJ(N,X)
Calculates Bessel functions of order 1 or 2.
FUNCTION BRILL(T,TN,S)
Returns the value of the Brillouin function.
SUBROUTINE CGAMMA(R,PUP,PDN,DEL,G,QQ,QLAM,RMS)
Solves the quadratic equation for gamma in terms of the flipping ratio.
SUBROUTINE DIJROT(D,ALPHA,BETA,GAMMA,KMAX)
Calculates the matrix D(i,j) for the Euler rotations alpha,beta,gamma of
the eigenfunctions of angular momentum l.
SUBROUTINE EA06C(A,VALUE,VECTOR,M,IA,IV,W)
Harwell routine to Find the eigenvalues and eigenvectors of a real
symmetric matrix A
SUBROUTINE EA06D(V,IV,M)
Harwell routine called by EA06C
SUBROUTINE EA08C(A,B,VALUE,VEC,M,IV,W)
Harwell routine to find the eigenvalues and eigenvector of a symmetric
tridiagonal matrix.
SUBROUTINE EA09C(A,B,VALUE,M,OFF)
Harwell routine used in solution od eigenvalue problem
FUNCTION ERFNC(X)
Calculates the error function accurate to 3E-7, for + and - X.
FUNCTION EXPINT(A,P,N,L)
Calculates an exponential radial integral.
FUNCTION FACT(K)
Calculates factorial K.
SUBROUTINE FF01A(VJS,VYS,XS,N)
Modified Harwell routine for zero order Bessel functions.
SUBROUTINE FF02A(VJS,VYS,S,N)
Modified Harwell routine for first order Bessel functions.
SUBROUTINE FRACT(X,Y,N)
Forms the fractional part of a real number.
SUBROUTINE FT01A(IT,INV,TR,TI)
Modification of Harwell Fast Fourier Transform.
SUBROUTINE JTERMS(G,R,H,S)
Calculates the terms in the 2D averaged spherically symmetric form
factor summation which depend on S,K, and R only.
SUBROUTINE MC04B(A,ALPHA,BETA,M,IA,Q)
Harwell routine to perform Householder reduction of a symmetric matrix
to tri-diagonal form.
SUBROUTINE NB01A(K,AZ,BZ,E2,X,Y,MAXIT)
Harwell routine NB01A to find the zero of a function.
SUBROUTINE RATFRC(F,I,J)
To make a rational fraction of the form F**2=I/J out of F
FUNCTION RGAUSS(SIGMA)
Returns a value random number with a gaussian distribution.
SUBROUTINE SPHARM(Y,T,P,LMAX,NUM)
Calculates spherical harmonics.
FUNCTION SPLINT(IX,N,U,S,D,X)
Evaluates a cubic spline given spline values and first derivative values
at the given knots.
SUBROUTINE STERMS(G,R,H,S)
Calculates a term in the spherically symmetric form factor summation,
for a 3D averaged form-factor involving Sk and r only.
SUBROUTINE TB02A(A,F,X,Y,N)
Interpolates in non-equal interval table.
FUNCTION THREEJ(AJ)
RETURNS A 3J COEFFICIENT
SUBROUTINE TQLI(D,E,N,NP,Z,BOTH)
Performs the QL algorithm for eigenvalues and vectors of a real
symmetric matrix previously reduced to tridiagonal form.
SUBROUTINE TRED2(A,N,NP,D,E,BOTH)
Performs the Householder reduction of a real symmetric matrix to
tridiagonal form.
FUNCTION VECOUP(J1,M1,J2,M2,J,M)
Calculates Clebsch-Gordon vector coupling coefficient
SUBROUTINE VOIGT(X,SIGMA,GAMMA,YVAL,DERX,DERS,DERG)
Calculates normalised Voigt function
SUBROUTINE WERF(RS1,RS2,XX,YY)
Weighted error function ???
FUNCTION WIYPOS(Y)
Returns \$\exp(y^2){\textrm errf}(y)\$ for positive \$y\$ only
SUBROUTINE WTMEAN(X,DX,IFUN,SUMS)
Multiple entry routine for the calculation of weighted averages.

10. Trigonometry

C. Utility

FUNCTION ARCCOS(X)
Calculates an arc cosine.
FUNCTION DEGREE(X)
Converts from radians to degrees.
FUNCTION RADIAN(X)
Converts from degrees to radians.
SUBROUTINE SINCOS(SN,CS,L1)
Calculates sin from cos or vice-versa.
SUBROUTINE TRIAN1(A,B,C,D,I)
Applies the cosine formula for the solution of spherical triangles.
SUBROUTINE TRIG(A,B,K)
Sets up cos(nx) and sin(nx) for a range of n by recursion.

11. Tests

C. Utility

LOGICAL FUNCTION BINDIG(N,NBIN)
Tests for the presence of a given binary digit within an integer.
LOGICAL FUNCTION CHGPAR(A,B,N)
Indicates whether two real arrays are the same
SUBROUTINE EQPOS(VEC1,VEC2,N1,N2,M)
Checks whether the given atom position already occurs in a given list,
and adds the new one if not.
SUBROUTINE EQPPOS(VEC1,VEC2,N1,N2,M)
Checks whether the given position vector is related by lattice
translation to one already in the given list.
SUBROUTINE EQRLV(VEC1,VEC2,N1,N2,M)
Checks whether vectors differ by a reciprocal lattice vector.
SUBROUTINE EQVEC(VEC1,VEC2,N1,N2,M)
Finds a given vector in given table of vectors, or adds it as a new one.
LOGICAL FUNCTION EXCLD(A,B,M)
Determines whether a number occurs within any of a set of given ranges.
LOGICAL FUNCTION GMSAME(A,B,N,TOLER)
Tells whether one vector is the same as another, to a given tolerance.
FUNCTION IATOM(ANAME)
Identifies an atom name in a given list.
FUNCTION ISCAT(FNAME)
Searches for a potential scattering factor name in the table.
FUNCTION LMATCH(LABEL,NAMTAB,NUM,NBOUND)
Matches an A4 item in given table, adding it if it is not there already.
FUNCTION MINIM(LIST,N,M)
Finds the position and value of the minimum in a list of integers.
FUNCTION NCFIND(CH,CTABLE,NBOUND)
Searches for a particular word in a table of words.
FUNCTION NFIND(N,NTABLE,NBOUND)
Searches for integer N in a table.
SUBROUTINE PARITY(N,M,EVEN)
Finds out whether N is odd or even.
FUNCTION RANGE(X,A,B)
Puts a number into a given range.
SUBROUTINE REJECT(N,NEXT,LREJ,USE)
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(INCHAR,WANT)
Decides whether the character variables INCHAR and WANT are the same,
ignoring any distinction between upper and lower case.
LOGICAL FUNCTION SAYS(WANT)
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(A,B)
Tests a floating division for potential overflow.

12. Matrices and Vectors

C. Utility

SUBROUTINE C1MSCA(A,B,SCALE,NI,NJ)
Multiplies every element of the REAL matrix A by the COMPLEX scalar
SCALE.
SUBROUTINE CGMADD(A,B,C,NI,NJ)
Sets COMPLEX matrix C = COMPLEX matrix A + COMPLEX matrix B.
SUBROUTINE CGMEQ(A,B,N,M)
Sets COMPLEX matrix B equal to COMPLEX matrix A.
SUBROUTINE CGMPRD(A,B,C,I,J,K)
Multiplies together two COMPLEX matrices.
SUBROUTINE CGMREV(A,B,NI,NJ)
Reverses the signs of the elements of an NI X NJ complex matrix.
SUBROUTINE CGMSCA(A,B,SCALE,NI,NJ)
Multiplies every element of a COMPLEX matrix by a COMPLEX scale.
SUBROUTINE CGMSUB(A,B,C,NI,NJ)
Sets COMPLEX matrix C = COMPLEX matrix A - COMPLEX matrix B.
SUBROUTINE CGMUNI(A,NI)
Clears a COMPLEX square matrix to contain the unit matrix.
SUBROUTINE CGMZER(A,NI,NJ)
Clears to zero a complex matrix.
SUBROUTINE CMCONJ(A,B,I,J)
Gives the conjugate of a COMPLEX matrix.
SUBROUTINE CMIMAG(A,B,I,J)
Gives the imaginary parts of a COMPLEX matrix.
SUBROUTINE CMREAL(A,B,I,J)
Gives the real parts of a COMPLEX matrix.
SUBROUTINE CMRSCA(A,B,SCALE,NI,NJ)
Multiplies every element of a COMPLEX matrix by a REAL scale.
SUBROUTINE CRMPRD(A,B,C,I,J,K)
Performs COMPLEX by REAL matrix multiplication.
COMPLEX FUNCTION CRSCLP(A,B)
Finds the COMPLEX scalar product of a COMPLEX with a REAL vector.
FUNCTION DETER3(A)
Forms the determinant of a 3 x 3 matrix.
SUBROUTINE GMADD(A,B,C,NI,NJ)
Sets matrix C = matrix A plus matrix B.
LOGICAL FUNCTION GMATCH(A,B,NA,NB)
To determine whether the two real matrices A and B are the same
SUBROUTINE GMEQ(A,B,NI,NJ)
Sets matrix B = matrix A.
SUBROUTINE GMINV(A,B,N)
Inverts matrix A into matrix B.
SUBROUTINE GMNORM(A,B,II,JJ)
Normalises the rows of a matrix.
SUBROUTINE GMPRD(A,B,C,NI,NJ,NK)
Sets matrix C = matrix A times matrix B.
SUBROUTINE GMREV(A,B,NI,NJ)
Reverses the signs of the elements of an NI X NJ matrix.
SUBROUTINE GMSCA(A,B,SCALE,NI,NJ)
Multiplies every element of the matrix A by the scalar SCALE.
SUBROUTINE GMSUB(A,B,C,NI,NJ)
Sets matrix C = matrix A minus matrix B.
SUBROUTINE GMTRAN(A,B,JJ,II)
Transposes a JJxII matrix A into B.
SUBROUTINE GMUNI(A,NI)
Writes a unit matrix into the square matrix A.
SUBROUTINE GMZER(A,NI,NJ)
Clears to zero the matrix A.
SUBROUTINE JGMADD(JA,JB,JC,NI,NJ)
In integers, sets matrix C = matrix A plus matrix B.
SUBROUTINE JGMEQ(JA,JB,NI,NJ)
Equates an integer matrix to a given integer matrix.
SUBROUTINE JGMPRD(JA,JB,JC,NI,NJ,NK)
In integers, sets matrix C = matrix A times matrix B.
SUBROUTINE JGMREV(JA,JB,NI,NJ)
Reverses the signs of the elements of an integer matrix.
SUBROUTINE JGMSUB(JA,JB,JC,NI,NJ)
In integers, sets matrix C = matrix A minus matrix B.
SUBROUTINE JGMZER(JA,NI,NJ)
Clears an integer matrix to zero.
SUBROUTINE MB11A(M,N,A,IA,W)
Inverts a rectangular matrix whose order is the smaller dimension; used
by the Harwell refinement routine VA05A.
FUNCTION NUMJGM(K,I,J)
Returns the number of non-zero elements in the IxJ integer matrix K
SUBROUTINE RCMPRD(A,B,C,I,J,K)
Performs the multiplication of a COMPLEX by a REAL matrix.
FUNCTION RSCALP(A,B)
Forms the scalar product of two COMPLEX vectors.
FUNCTION SCALPR(A,B)
Forms the scalar product of two orthogonal vectors (or of one from real
space with one from reciprocal space).
SUBROUTINE SID(A,N,ND1,ND2,D)
Solves a set of simultaneous linear equations.
SUBROUTINE SUMVEC(A,I,J,K,SUM)
Calculates the sum of elements of a real array
SUBROUTINE TRANSC(A,ND)
Replaces a COMPLEX square matrix by its transposed conjugate.
SUBROUTINE TRANSQ(A,ND)
Replaces a real square matrix by its transpose.
SUBROUTINE TRINV3(A,D)
Replaces a 3x3 matrix by the transpose of its inverse.
SUBROUTINE UNIVEC(X,U)
Replaces a vector by a parallel unit vector, and gives its length.
SUBROUTINE VECPRD(VEC1,VEC2,PRD)
Calculates the vector product of two 1x3 vectors.

13. CCSL Input/Output Routines

A. Setting Up

SUBROUTINE ESDFMT(X,DX,BUFF,IW)
Writes X and its esd DX in the form X(DX)
SUBROUTINE PREFIN(PROGRM)
Makes the Crystal Data File readable in a random order by writing it to
a scratch file.

C. Utility

SUBROUTINE ADDSPC(WORD,LWORD)
To pad a word with spaces to length lword
SUBROUTINE ASK(MESS)
Writes a message on unit ITO and reads an interactive answer to
/SCRACH/.
SUBROUTINE BIGCHA(BWORD)
Writes on unit LPT up to 9 characters in large letters.
SUBROUTINE CARDIN(IDEN)
Finds the record number IDEN in the DIRECT ACCESS file on unit IO10,
which is a copy of the Crystal Data File.
SUBROUTINE CDFIN(NUMCDF,ID,ENDIP)
Reads in one Crystal Data File and copies it to direct access unit
number IO10, starting at record number ID.
SUBROUTINE CDSCAN(CH,WORDS,LEN,K,LCD,NW)
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(LUNIT,N,TXT,NWIDE)
Writes on unit LUNIT the given message, centred & preceded by N empty
lines.
SUBROUTINE CLOFIL(LUN)
Closes the FORTRAN unit LUN and returns the CCSL unit to the pool.
SUBROUTINE ERRATM(NAME,NACT,MESS)
Writes an error message to say that the given name is not an atom name;
there is a choice of subsequent action.
SUBROUTINE ERRCH2(WORD,NACT,MESS1,MESS2)
Write an error message which involves a given WORD between 2 messages;
there is a choice of subsequent action.
SUBROUTINE ERRCHK(NTYP,NVALUE,NBOUND,NACT,MESS)
(Possibly increases and) checks a value, giving if appropriate an error
message; there is a choice of subsequent action.
SUBROUTINE ERRIN2(INT,NACT,MESS1,MESS2)
Writes an error message which involves a given integer INT between 2
messages; there is a choice of subsequent action.
SUBROUTINE ERRMES(NTYP,NACT,MESS)
Writes an error message, with choice of action on exit.
SUBROUTINE ERRRE2(X,NACT,MESS1,MESS2)
Writes an error message which involves a given real X between 2
messages; there is a choice of subsequent action.
SUBROUTINE EXPAND(IBUF,OBUF)
Expands UNIX pathnames by substituting for environment variables
SUBROUTINE FETTLE(X,IFIELD,IFDIG)
Decides field width and fractional part of real number in order to print
it.
CHARACTER*10 FUNCTION FILNOM(LUN)
Returns the name of the file on FORTRAN unit LUN.
SUBROUTINE FILPRO(DEFT,IU,LFIL)
Makes sense of general file names, under VMS AND UNIX.
SUBROUTINE FINDCD(CH,WORD,LEN,K,LCD)
Searches for a card starting with letter CH and with WORD in columns
3-6.
CHARACTER *4 FUNCTION GENNAM(NAME)
Finds all the starting letters of an atom name.
SUBROUTINE INCREM(IFNS,IFNL)
Increments a file name.
SUBROUTINE INITIL(PROGRM)
Initialises the CCSL system.
SUBROUTINE INPUTI
Gathers information from a user's interactive instruction card.
SUBROUTINE INPUTN(NOUT)
Deals with the
"N" card giving the Crystal Data File title.
SUBROUTINE INTCHR(IDIG,NDIG,ICHR,NCHR,MODE)
Converts digits to characters, either left- or right-justified.
SUBROUTINE INTDIG(N,IDIG,NDIG)
Unpacks an integer into its individual digits.
LOGICAL FUNCTION IPDONE(CHAR)
Checks whether a the cards labelled CHAR have been read
FUNCTION IPOPE(N)
Machine specific routine to interpret error codes during file opening.
FUNCTION LENG(NTEXT,L)
Determines the length of a text string, omitting trailing spaces.
FUNCTION LENGT(CHAR)
Determines the length of a character variable, omitting the final
spaces.
LOGICAL FUNCTION LERCHK(NTYP,NVALUE,NBOUND,NACT,MESS)
FALSE or TRUE according to whether NVALUE (possibly incremented) is
greater than NBOUND
FUNCTION LETTER(I)
Determines whether a character is a letter.
CHARACTER *4 FUNCTION MAKNAM(CHAR,N)
Makes an A4 name from the given character and the digits of the given
number.
SUBROUTINE MESS(LUNIT,N,TXT)
Writes on unit LUNIT the given message, preceded by N empty lines.
FUNCTION NCHINT(CH)
Converts an ASCII character into an integer
FUNCTION NDIGIT(I)
Identifies a character as a digit or not.
SUBROUTINE NEWCRY(IFUN,LET,LUNO)
Writes a new crystal data file in which the
"LE T" cards are modified
SUBROUTINE NEWLIN(LUNIT)
Writes a newline to the output unit LUNIT
SUBROUTINE NEWPAG(LUNIT)
Writes a newpage carriage control ('1') to the output unit LUNIT
FUNCTION NOPFIL(MODE)
Opens a file on a FORTRAN unit for the first time in this job.
FUNCTION NSIGFG(DX)
Returns the number of figures to print after the decimal point based on
the ESD dx
FUNCTION NSYMBL(I)
Finds whether the character I is one of the symbols recognised by the
system.
SUBROUTINE NUMA1(X,IFIELD,IFDIG,ITOT,IA)
Prepares a number for writing, probably on a plotter.
SUBROUTINE NUMDEN(X,N1,N2,KI,KO)
Converts a real number to the numerator and denominator of a fraction.
LOGICAL FUNCTION ONCARD(C,WORD,A)
Finds a card which starts with the given letter and word, and reads one
number from it.
SUBROUTINE OPNFIL(L,M)
Opens file L according to requirements given in M; L may be preset.
SUBROUTINE PRILIS(AVAL,IPT1,IPT2)
Prints a list of real numbers held in an array, 5 per line.
SUBROUTINE PRIPLN(A,IR)
Given the normal to a plane face in A, prints the equation of the plane.
SUBROUTINE PUTPAR(A,I,NUM,PAR,BAD)
Distributes parameters read by RDNUMS amongst individually named
variables.
SUBROUTINE RDDATA(NUNIT,K,H,F,IN,IOU)
Reads in free format h,k,l (possibly floating) and a list of values,
allowing for a possible title.
SUBROUTINE RDINTG(N,IPT1,IPT2,IPTEND,IER)
Reads an integer in free format from a character string.
SUBROUTINE RDNUMS(A,IPT1,NBOUND,NUM,IER)
Reads all the numbers on a line in free format.
SUBROUTINE RDREAL(X,IPT1,IPT2,IPTEND,IER)
Reads a real number in free format from a character string.
SUBROUTINE RDWORD(WORD,IWDLEN,IPT1,IPT2,IPTEND,IANY,IER)
Reads the next word from a character string.
SUBROUTINE RDWRDS(WD,IPT1,NBOUND,NUM,IER)
Reads all the words on a line from column 3 onwards.
SUBROUTINE TESTP(LUN,LINO,I,HEADNG,NL)
Puts a given heading at top of every printer page, counting lines.
SUBROUTINE UPLOW(C)
Makes first letter of C upper case, and any subsequent letters lower
case.
SUBROUTINE UPONE(CH,IS)
Puts character strings into all uppercase or all lower case depending on
ISYS
SUBROUTINE UPPER(C)
Replaces any lower case letters in C by upper case

14. Graphical Output

A. Setting Up

SUBROUTINE GETSCL(VMIN,VMAX,L)
Chooses a sensible scale for a graph.
SUBROUTINE PINITL
Initialises the system in order to make graphical output.
SUBROUTINE PSFILE(NAME)
Generates a name for a postscript file
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(X1,Y1,NN1,X2,Y2,NN2)
Performs the transformation of coordinates between different plotter
spaces.
SUBROUTINE PLOTCT(C,A,FOUND,M,N)
Plots a single contour throughout a given array.
SUBROUTINE PLOTIT(X,NP,SIZE)
Plots the graph of given vector y against x, with esds.
SUBROUTINE PLOTO(XX,YY,ER,MODE)
A multi-purpose graph-drawing routine.
SUBROUTINE PLTRIN(PMAT,N,M)
Defines a new coordinate transformation for plotting.
SUBROUTINE PMTINV(A,B)
Specialist routine to invert a 2x3 matrix, such as those which transform
plotting coordinates from one space to another.
SUBROUTINE PMTMUL(A,B,C)
Specialist routine to multiply together two 2x3 matrices, such as those
which transform plotting coordinates from one space to another.
SUBROUTINE SPCSET(N)
Defines the "space" in which coordinates will be given for plotting.

C. Utility

SUBROUTINE ARROW(P,S,N)
Writes postscript output to plot an arrow in MAG3D
SUBROUTINE CIRCLE(XX,YY,R,M)
Draws a circle of given radius and centre, with various options.
SUBROUTINE DPLOT(XXIN,YYIN,LINE)
Does plotting in current coordinate system.
SUBROUTINE FRAME(X1,Y1,X2,Y2)
Draws a rectangle in the plotting context.
SUBROUTINE KANGA1(X,Y,MODE)
Moves plotter pen (or equivalent) to X,Y in current coordinates.
SUBROUTINE KANGA2(X0,Y0,XF,ICHARS,NCHAR)
Writes on a plot a string of characters, or simulates this in order to
measure the length of the string.
SUBROUTINE KANGA3(X,Y,SIZE,MSYM)
Plots a special symbol.
SUBROUTINE PIGLET(X,Y,N)
A complete set of device-specific plotting commands.

15. Logical Operations

C. Utility

SUBROUTINE BITSET(I,NC,TEST,SET)
Sets or tests a single bit in a word.
SUBROUTINE GETSQ(A,T,X,I,J,MM,NN)
Works out where a contour crosses the sides of a square of function
values.
FUNCTION ITPOS(IPOS)
Sets ITPOS=a single bit (a one), in position IPOS, counting from the
right.
SUBROUTINE LOCBIT(I,J,NR,NC,ISIDE,M,N)
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(I,J)
Performs logical "and" on 2 whole integers.
FUNCTION LOGOR(I,J)
Performs logical "or" on 2 whole integers.
SUBROUTINE MAKEBM(I,A,C,M,N)
A specialist contour plotting routine which makes a bit map to show
where the contours are.

16. Miscellaneous

C. Utility

SUBROUTINE BATCH
Signals batch running, not interactive.
SUBROUTINE DUMMY
Does absolutely nothing; used as a default in routine calls.
SUBROUTINE FLIP(I,J)
Exchanges the integers I and J.
FUNCTION JFIX(X)
Rounds a real to be an integer.
SUBROUTINE NPACK(NPK,L,N,MODE,LPACK)
Deals with the packing and unpacking of up to 10 integers in/out of one
integer.
FUNCTION NTICK(NTIME)
Advances its argument by 1 and sets the function to that value also.
SUBROUTINE RESHUF(A,IPT,N)
Reorders a real array, given a parallel pointer array out of SORTX.
SUBROUTINE SORTN(IVAL,IP,N)
Sorts pointers to an integer array using Heapsort.
SUBROUTINE SORTX(VAL,IP,N)
Sorts pointers to a real array using Heapsort.

17. Magnetic Structure Factors

A. Setting Up

SUBROUTINE INPUTQ(ID,NTYP,IAT,IPT,IER)
Reads individual "Q" cards
SUBROUTINE KSTARS(AKSTAR)
Returns the vectors AKSTAR in the star of the propagation vector.
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(IATO,LMFIX,FIRST)
Finds and reports the symmetry constraints on magnetic parameters.
SUBROUTINE PROPER(AKVEC)
Determines whether the satellites generated by the propagation vector
PROP have integer indices, and generates its "star". ENTRY KSTAR(AKVEC,BKSTAR)
SUBROUTINE PSICON(MGAT,IFTAB)
Determines which atoms need phase factors in modulated structures.
SUBROUTINE READRT(IAT,IEND,NAME)
Reads whatever follows on a "W atom-name
ROT N" card .
SUBROUTINE SETFCM(MAGSET)
Calls the routines needed to set up magnetic structure factor
calculations (or non-magnetic also).
SUBROUTINE SPHPOL(ANG1,ANG2,SD,MODE)
Sets up spherical polar spin directions for magnetic structures.

B. Crystallographic

SUBROUTINE CALDSM(H,ISAT)
Calculates d star squared, and its derivatives wrt reciprocal cell
quadratic products and components of propagation vector.
SUBROUTINE CENTRO(CVEC,SVEC,RMAT,PSIFAC,PSIFCC)
Executes the action of the centre of symmetry on a term in the magnetic
structure factor for helimagnetic structures. ENTRY CENDIF(CVEC,SVEC,VEC1,VEC2,RMAT,PSIFAC,PSIFCC)
SUBROUTINE DOCHI1(MODI)
Multiple entry subroutine to read and check parameters for paramagnetic
structure calculations given on Q cards
SUBROUTINE DOMAG(MODE)
Multiple entry subroutine to deal with parameters for magnetic
structures on Q cards (but not their fixing/varying).
SUBROUTINE DOMAG1(MODE)
Multiple entry subroutine to deal with parameters for magnetic
structures on Q cards .
LOGICAL FUNCTION DOMAG2(NN,MODE)
Multiple entry subroutine to deal with magnetic variables in magnetic
structure refinements
SUBROUTINE FCHALC(H,FMCMOD,FMCSQR)
Calculates induced magnetic interaction vectors and magnetic structure
factors. with anisotropic susceptibilities
SUBROUTINE FMCALC(H,FMCMOD,FMCSQR)
Calculates magnetic interaction vectors and magnetic structure factors.
FUNCTION LMAGPR(IP,IM,IR)
Gives the fix/vary information for one of the family 2 parameters for
magnetic atoms.
SUBROUTINE LMCALC(H)
Calculates a magnetic structure factor and its derivatives.
LOGICAL FUNCTION MAGABS(H,IK)
Tests for systematic absence of magnetic reflections.
SUBROUTINE MAGDIR(H,QLAM,QQ)
Calculates various geometric corrections for various magnetic states.
The ENTRY ENTMAG sets up the COMMON. ENTRY ENTMAG
SUBROUTINE MAGDOM(H,HK,IOP,SKIP)
In Least Squares refinement with magnetic scattering, forms the matrix
needed for derivatives of Q with respect to a spin direction.
SUBROUTINE MAGSYM(MODE)
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. ENTRY MELIN(IOP,VAL)
ENTRY NELIN(IOP,SROT)
ENTRY ROTMAG(S,RS,IOP)
SUBROUTINE MAGVAR(IG,IS,NV)
Records the initial fixing, or subsequent varying of magnetic
parameters.
SUBROUTINE MOLORB(IAT,IPTI)
To read molecular orbital wave-functions from "W atom-name
FUN C" card .
SUBROUTINE PROPAG(MODE,INOUT)
Multiple entry subroutine for propagation vector refinement
SUBROUTINE PROPDR(H,IS,DER)
Makes derivatives of d*sqrd with respect to the magnetic propagation
vector
SUBROUTINE SATFND(H,HS,NR)
Finds the indices HS of the satellite equivalent to H, offset by the
propagation vector PROP from a reciprocal lattice point.
SUBROUTINE SATGEN(HF,HS,MUL,NUM)
Generates a set of magnetic satellite reflections.
SUBROUTINE SPHELI(IM,MODE)
Imposes perpendicularity on the two components of a helix.

C. Utility

FUNCTION ASPHFF(H,IAT)
Calculates an aspherical form factor for a cubic space group.
SUBROUTINE GENMAG(H,NOMORE,MUL,SMAX,NFLAG)
Generates the next set of magnetic h,k,l, scanning the asymmetric unit.
SUBROUTINE MTPROD(I,J,N)
Puts entries into the table of time inversion operators.

18. Multipole Form Factors

A. Setting Up

SUBROUTINE INPUTJ(ID,NTYP,IAT,IPT,IER)
Reads individual J cards .
SUBROUTINE MPCON(MAT,KMAX)
Finds the symmetry constraints on multipoles.
SUBROUTINE MPFORM(IDT,NJ)
Finds out which radial form factors to apply to which atom and L value.
SUBROUTINE MPOVAR(I,J)
Records whether each multipole parameter is fixed or varied.
SUBROUTINE ORTFUN(I,KMAX,VAL,MODE)
Finds the best set of orthonormal functions compatible with symmetry
based on the users input, and hence defines the multipoles to refine.
SUBROUTINE PFOUT
Reports the allocation of multipole form factors
SUBROUTINE PFSET
Directs the reading of J and
W cards for multipole calculations.
SUBROUTINE REAORB(CORB,ORB,KMAX)
To change the orbital basis from Ylm and Yl-m to (Ylm +- Yl-m).

B. Crystallographic

LOGICAL FUNCTION DOMPL2(NN,MODE)
Logical multi-purpose function to deal with multipole variables in least
squares structure refinements
SUBROUTINE FMMPCA(H,FMCMOD,FMCSQR)
Calculates magnetic interaction vectors and magnetic structure factors
with multipole form factors.
COMPLEX FUNCTION FMPCAL(H)
Calculates the COMPLEX nuclear structure factor for the reflection H,
using a multipole expansion of the form factor.
SUBROUTINE LMMPCA(H)
Calculates magnetic structure factor and its derivatives using multipole
description of the form factors.
SUBROUTINE MF5ADD(ISPC,IG,IS,N)
A specialist routine to deal with the refinement of multipoles. Converts
each type of LSQ family 5 (multipoles) addressing to the other.
SUBROUTINE PFORMF(H,MAT,PSUM,PFACS,KODE)
Calculates radial form factors for multipole refinement.
SUBROUTINE PRMBLK
Applies shifts to multipole parameters, in both program and user units.

C. Utility

SUBROUTINE NAMPOL(NAME,K,L)
Creates the label for a given multipole.


Contents Manual

P. Jane Brown e-mail: brown@ill.fr
Institut Laue Langevin,
Grenoble, FRANCE