## LOGICAL FUNCTION LATABS(H)

### Arguments:

On entry H is 1x3 real array of h,k,l
On exit LATABS = .TRUE. if h,k,l absent, .FALSE. if present

### Prerequisite calls:

SYMOP should have set up the lattice information in /SYMDA, /NSYM

### Notes:

Deals with non-integral h,k,l also, giving the answer "absent"

SCALPR

### Called by:

CALCFR EQRLV FMPCAL GENMUL GETGEN LFCALC LMPCAL MAGABS ICDINC CALMSF CALQSF EXTCAL GETMSF ICDINC MAGPOW POWDER CALCTW

### Common blocks used:

/NSYM/ to use NLAT
/SYMDA/ to use ALAT

### Classification:

Basic Crystallography . . . . . . . Crystallographic

## SUBROUTINE LATGEN(KI,K,KLIM,DONE,ISW,ISWO)

### Arguments:

On entry: KI(3) is the previous point generated
KLIM(3,2) gives the limits over which points should be generated
ISW is a switch indicating for which axes the a point on the upper
limit is required. The point is required for the nth axis if t nth bit is set in ISW.

On exit: K contains the next point generated.
DONE is .TRUE. if there are no more points
ISWO indicates whether the point generated is at any of the limits.
The nth bit is set if the point is at the limit for the nth axis.

### Notes:

Use KLIM(1:3,1) for the first point, set KI(1:3)=KLIM(1:3,1) for the first call to LATGEN, for subsequent calls set KI=K and continue until
DONE is .TRUE.

JGMEQ

### Called by:

MAG3D MG3DGL MVENTR

### Classification:

Basic Crystallography . . . . . . . Crystallographic

## SUBROUTINE LATVCS(STEP,AVEC,NPRIM)

### Arguments:

On Input STEP contains 3 3-vectors which will be used to generate
points in a lattice

On exit NPRIM gives the number of lattice points in the cell defined by STEP
AVEC are the vectors joining these points to the origin

### Notes:

The first entry in AVEC is always a zero vector.

### Calls:

DETER3 ERRCHK FCTOR GMADD GMEQ GMREV GMSCA GMZER VECPRD

### Common blocks used:

/IOUNIT/ to use LPT ITO

## LOGICAL FUNCTION LATVEC(X)

### Arguments:

On entry X is a real 1x3 vector
On exit LATVEC is. TRUE. if X is a lattice vector, .FALSE. otherwise

### Prerequisite calls:

SYMOP must have set up the lattice information in /SYMDA, /NSYM

ATOPOS EQPPOS

### Classification:

Basic Crystallography . . . . . . . Crystallographic

## FUNCTION LCOLPG(NAME)

### Calls:

ERRMES LENGT NCFIND UPONE

INPUTM

### Common blocks used:

/PGNAMS/ to use PGCOLS
/PGNUMS/ to use NPGCOL LPGCOL

## LOGICAL FUNCTION LDUMMY(NN,MODE)

### Description:

It always returns false

### Called by:

DOMAG PARSDS SFLSQ

### Classification:

Specific Least Squares Refinement . . . . . . . Setting Up

## FUNCTION LENG(NTEXT,L)

### Arguments:

On entry NTEXT is an A1 character array of dimension L
On exit LEN is the number of visible characters in NTEXT

### Called by:

FILPRO INCREM NOPFIL PLOTO SORGAM

### Classification:

CCSL Input/Output Routines . . . . . . . Utility

## FUNCTION LENGT(CHAR)

### Arguments:

On entry CHAR is a character variable
On exit LENGT is the number of visible characters in CHAR

### Called by:

ADDSPC ARREAD ASK ATMPLT BIGCHA CDFIN CENTRE DOMAG DOMAG2 DOMPL2 ERRATM ERRCH2 ERRCHK ERRIN2 ERRMES ERRRE2 EXPAND F2NEW FILPRO INITIL INPUTN LCOLPG LERCHK LISPEC LSYMPG MESS NWINDS NWINFW NWINSF NWINT2 OTPUTI PLOTO PROPAG PSFILE RDDATA REAPOL SETFOR SETFOU UPLOW UPONE UPPER AVEXAR D3OP99 AISPRC NCHECK INFILE GRAFIC MADUBM ATLABS POSOUT

### Classification:

CCSL Input/Output Routines . . . . . . . Utility

## LOGICAL FUNCTION LERCHK(NTYP,NVALUE,NBOUND,NACT,MESS)

### Arguments:

On entry NTYP=type of check required:
NTYP=1 simply check NVALUE for being NOT GREATER THAN NBOUND
NTYP=2 increment NVALUE by 1, then as type 1

On entry NVALUE is the integer to be checked
NBOUND is its upper bound

On entry NACT says which action is required if the test fails:
NACT +ve means increase IERR in /CARDRC/ by 1, complain and exit
NACT -ve means complain and exit
NACT =0 means complain and stop

On entry MESS is the message specific to this error state

### Description:

returns TRUE if NVALUE <= NBOUND FALSE otherwise. If FALSE
NVALUE is set back to the value it had on entry.
The error message starts " ERROR ** ", and finishes with MESS.
If NTYP=1, NVALUE is printed.

### Output:

Outputs the required message on units LPT and ITO

LENGT MESS

### Called by:

INPUTM MPFORM PSICON GRAFIC INCMSF

### Common blocks used:

/CARDRC/ to use IERR
/IOUNIT/ to use LPT ITO

### Classification:

CCSL Input/Output Routines . . . . . . . Utility

## FUNCTION LETTER(I)

### Arguments:

On entry I is an A1 character
On exit LETTER=0 if I is not a letter, otherwise which letter in range 1-26

### Notes:

Small letters and capitals treated alike.

### Called by:

BIGCHA CDFIN CDSCAN DOMAG2 DOMPL2 DOTWN2 EXPAND FINDCD GENNAM INPUTA INPUTF INPUTT IPDONE MAJUST NWINDS NWINFW NWINSF NWINT2 ONCARD RDDATA RDINTG RDREAL RDWORD SAID SAYS UPLOW UPPER

### Common blocks used:

/CHARS/ to use LETUP LETLOW

### Classification:

CCSL Input/Output Routines . . . . . . . Utility

## SUBROUTINE LFCALC(H)

### Arguments:

On entry H is a 1x3 array containing h,k,l

### Prerequisite calls:

RECIP, SYMOP, SETANI, and SETFOR must have been obeyed to set up the structure factor calculations. (These are contained in SETFC).
The LSQ environment must have been set up by a suitable MAIN program (like
SFLSQ) which has called LSETUP and VARMAK.

### Description:

On exit in /FCAL/
FC is the complex structure factor
FCMOD is its modulus
COSAL is the cosine of its phase
SINAL is the sine of its phase
FCDERS is an array of derivatives of FCMOD wrt all family 2 (structure
parameters. These are NOT multiplied or divided by anything else; compare LMCALC

The above will all be zero if h,k,l gives a lattice absence; note that such would not be true of FCALC, the similar routine which does not cater for LSQ

### Calls:

ANITF CGMZER FORMFA GMZER LATABS ROTSYM SCALPR TESTOV

### Called by:

CALCGR CHILSQ MAGLSQ MMPLSQ PALSQ SFLSQ SFTLSQ

### Common blocks used:

/ANISO/ to use KATF IAPT
/BRAGG/ to use STHL SSQRD
/CONSTA/ to use TWOPI
/FCAL/ to use all members
/FORMDA/ to use NFORMF KCMULT
/NSYM/ to use NOPC CENTRC
/PHASE/ to use JPHASE
/POSNS/ to use NATOM KX AMULT TF KTF SITE KSITE
/PRBLEM/ to use LVFST1 NVARF
/SYMDA/ to use TRANS

### Classification:

General Least Squares Refinement . . . . . . . Crystallographic

## FUNCTION LISPEC(PATHIN,ICYC,NUMOR,TEXT,ITEXT,IPARS,NINTS,FPARS,NREALS,SCAN,NSPTS)

### Calls:

CLOFIL EXPAND LENGT NOPFIL

### Common blocks used:

/SCRACH/ to use MESSAG

### Classification:

Data Collection and Reduction . . . . . . . Utility

## SUBROUTINE LLSCAL(N)

### Arguments:

On entry, N indicates the required action:
N=0 deals with the introduction of a single scale factor with the value 1,
to be refined, when no L SCAL cards are given.

N=1 reads in an L SCAL card and records the scale factors from it.
N=2 is not assigned.
N=3 applies a shift to a specific SCALE(ISPC), with ISPC in /NEWOLD/.
N=4 writes out a new L SCAL card to unit NEWIN.

### Called by:

APSHSF INPLSF NWINSF STLSSF

### Common blocks used:

/CARDRC/ to use IERR
/IOUNIT/ to use LPT ITO
/NEWOLD/ to use ISPC NEWIN
/SCLDAT/ to use NSCALE SCALE KSCALE NSCL LSCD

### Classification:

General Least Squares Refinement . . . . . . . Setting Up

## SUBROUTINE LLTFAC(N)

### Arguments:

On entry N indicates the action required:
N=1 reads in L TFAC card and stores value of overall isotropic
temperature factor in TFAC.

N=2 is not assigned.
N=3 applies a shift to TFAC.
N=4 writes out a new L TFAC card .
N=5 deals with the default if no L TFAC card is given.
N=6 fixes a zero TFAC which is implied by the absence of an L TFAC card .
ENTRY LTFAC8(NV) sets KTFAC to indicate TFAC is variable number NV
ENTRY LTFAC9 sets KTFAC to indicate TFAC fixed

### Common blocks used:

/IOUNIT/ to use LPT
/NEWOLD/ to use IGEN ISPC NEWIN
/OVER/ to use NTFAC
/PHASE/ to use JPHASE

### Classification:

General Least Squares Refinement . . . . . . . Setting Up

## FUNCTION LMAGPR(IP,IM,IR)

### Arguments:

On entry IP = which species required, in the range 1-22
IM = which magnetic atom (if IP > 12)
IR = which atom

On exit LMAGPR = 0 if the parameter is fixed
= which variable it is if it is varied.

### Description:

This function is necessary now we hold the fix/vary information with the parameter (e.g. KX with X, KATF with ATF) instead of in a single array regardless of the physical meaning of the parameter.

### Notes:

One could use this for non-magnetic applications, if IP =< 12

LMCALC LMMPCA

### Common blocks used:

/ANISO/ to use KATF IAPT
/POSNS/ to use KX KTF KSITE
/MAGDAT/ to use KANGM KSMOD KPHIH

### Classification:

Magnetic Structure Factors . . . . . . . Crystallographic

## FUNCTION LMATCH(LABEL,NAMTAB,NUM,NBOUND)

### Arguments:

On entry LABEL is the A4 item to be matched
NAMTAB is the A4 array in which to search (and add)
NUM is the number of entries so far (0 is allowed)
NBOUND is the dimension of NAMTAB

On exit LMATCH is set to the address of LABEL in NAMTAB
NUM is increased by 1 if an entry is added.

### Output:

Writes an error message if the table becomes overfull.

NCFIND

### Called by:

ATOPOS INPUTQ SETFOR

### Common blocks used:

/IOUNIT/ to use LPT ITO

### Classification:

Tests . . . . . . . Utility

## SUBROUTINE LMCALC(H)

### Arguments:

On entry H is the 1x3 vector containing h,k,l

### Prerequisite calls:

RECIP, SYMOP, SETANI, SETFOR and DOMAG must have been obeyed to set up the structure factor calculation. (They are all called by SETFCM)
The LSQ environment must have been set up by a suitable MAIN program (like
SFLSQ) which has called LSETUP and VARMAK.

### Description:

On exit, in /MCAL/:
FMCMOD = modulus of FMC
FMCSQR = squared modulus of FMC
FMCDER is an array containing the derivatives of FMCMOD wrt the family
2 (structure) parameters, ALL MULTIPLIED BY FMCMOD.
(Note the difference from the specification of LFCALC's derivatives)

On exit, in /QCAL/:
Q is an array containing the magnetic interaction vectors for each domain
in general there will be NDOM*KCENT domains

On exit, in /QCALD/:
FQCDER is an array containing the derivatives of the Q's with respect to
all the family 2 parameters.

All the above will be zero if h,k,l is a magnetic absence

### Notes:

Note the existence also of LFCALC (nuclear structure factors for LSQ)
FMCALC (magnetic structure factors)
FCALC (nuclear structure factors)

### Calls:

ANITF C1MSCA CGMADD CGMEQ CGMSCA CGMSUB CGMZER CMRSCA FORMFA GMREV GMZER LMAGPR MAGABS MAGDOM RADIAN RCMPRD ROTOSM ROTSYM RSCALP SCALPR VCTMOD ROTMAG CROTO

MAGLSQ PALSQ

### Common blocks used:

/ANISO/ to use KATF IAPT
/BRAGG/ to use STHL SSQRD
/CONSTA/ to use TWOPI VALMUB
/IOUNIT/ to use LPT IOUT
/MAGDAT/ to use NMAG JMAGAT NMFORM KANGM SMOD KSMOD PHIH KPHIH LPHI FCENT IPTAB SPIND
/MCAL/ to use all members
/NSYM/ to use NOPC CENTRC
/PHASE/ to use JPHASE
/POSNS/ to use KX AMULT TF KTF SITE KSITE
/PRBLEM/ to use LVFST1 NVARF
/QCALD/ to use all members
/SATELL/ to use KSTAB IPROP FKSTAR
/SYMDA/ to use TRANS
/SYMMAG/ to use MSTAB OTRSYM FERO FERA HELI MODUL
/SYMTAB/ to use MULTAB

### Classification:

Magnetic Structure Factors . . . . . . . Crystallographic

## SUBROUTINE LMMPCA(H)

### Arguments:

On entry H is the 1x3 vector containing h,k,l

### Prerequisite calls:

RECIP, SYMOP, SETANI, SETFOR and DOMAG must have been obeyed to set up the structure factor calculation. (They are all called by SETFCM)
The LSQ environment must have been set up by a suitable MAIN program (like
MPLSQ) which has called LSETUP and VARMAK.

### Description:

On exit, in /MCAL/:
FMCMOD = modulus of FMC
FMCSQR = squared modulus of FMC
FMCDER is an array containing the derivatives of FMCMOD wrt the family
2 (structure) and family 5 (multipole) parameters, ALL
MULTIPLIED BY FMCMOD.
(Note the difference from the specification of LFCALC's derivatives)
FVCDER is an array containing the derivatives of FMC with respect to
all the family 2 parameters.

On exit, in /QCAL/:
Q is an array containing the magnetic interaction vectors for each domain
in general there will be NDOM*KCENT domains

On exit, in /QCALD/:
FQCDER is an array containing the derivatives of the Q's with respect to
all the family 2 parameters.

All the above will be zero if h,k,l is a magnetic absence

### Notes:

Note the existence also of LFCALC (nuclear structure factors for LSQ)
FMCALC (magnetic structure factors)
FCALC (nuclear structure factors)
LMCALC (magnetic structure factors for LSQ)

### Calls:

ANITF C1MSCA CGMADD CGMEQ CGMSCA CGMSUB CGMZER CMCONJ CMRSCA FORMFA FORMFC GMREV GMZER LMAGPR MAGABS MAGDOM PFORMF RADIAN RCMPRD ROTOSM ROTSYM RSCALP SCALPR VCTMOD ROTMAG CROTO

MMPLSQ

### Common blocks used:

/ANISO/ to use KATF IAPT
/BRAGG/ to use STHL SSQRD
/CONSTA/ to use TWOPI FOURPI VALMUB
/FORMDA/ to use KCMULT
/IOUNIT/ to use LPT IOUT
/MAGDAT/ to use NMAG JMAGAT NMFORM KANGM SMOD KSMOD PHIH KPHIH LPHI FCENT IPTAB SPIND
/MCAL/ to use all members
/MPODA/ to use MPNMTB MPTAB MP KPOLMP
/NSYM/ to use NOPC CENTRC
/POLFOR/ to use MPFOR MPLFOR
/POSNS/ to use KX AMULT TF KTF SITE KSITE
/PRBLEM/ to use LVFST1 NVARF
/QCALD/ to use all members
/SATELL/ to use KSTAB IPROP FKSTAR
/SYMDA/ to use TRANS
/SYMMAG/ to use MSTAB OTRSYM FERO FERA HELI MODUL
/SYMTAB/ to use MULTAB

### Classification:

Multipole Form Factors . . . . . . . Crystallographic

## SUBROUTINE LMPCAL(H)

### Arguments:

On entry H is a 1x3 array containing h,k,l

### Description:

On exit in /FCAL/
FC is the complex structure factor
FCMOD is its modulus
COSAL is the cosine of its phase
SINAL is the sine of its phase
FCDERS is an array of derivatives of FCMOD wrt all family 2 (structure
parameters and family 5 (multipole). These are NOT multiplied or divided by anything else; compare LMCALC

The above will all be zero if h,k,l gives a lattice absence; note that such would not be true of FCALC

### Calls:

ANITF CGMZER FORMFA FORMFC GMZER LATABS PFORMF ROTSYM SCALPR TESTOV VCTMOD

CALCMP MPLSQ

### Common blocks used:

/ANISO/ to use KATF IAPT
/BRAGG/ to use STHL SSQRD
/CONSTA/ to use TWOPI FOURPI
/FCAL/ to use all members
/FORMDA/ to use NFORMF KCMULT
/MPODA/ to use MPNMTB MPTAB MP KPOLMP
/NSYM/ to use NOPC CENTRC
/POLFOR/ to use MPFOR MPLFOR
/POSNS/ to use NATOM KX AMULT TF KTF SITE KSITE
/PRBLEM/ to use LVFST1 NVARF
/SYMDA/ to use TRANS

### Classification:

Specific Least Squares Refinement . . . . . . . Crystallographic

## SUBROUTINE LOCBIT(I,J,NR,NC,ISIDE,M,N)

### Arguments:

On entry I=which bit within a word in the bit-map,
J=which word in the bit-map
M,N give the size of the bit-map

On exit ISIDE=1,2,3 or 4 to indicate side of picture,
NR,NC are set to indicate the top left of the relevant square.

### Prerequisite calls:

The bit-map must be set up in IBIT in /BITMAP/
NBITS must be set up as at most the number of bits in an integer.

### Description:

Finds whether the indicated bit is 0 or 1, and in any case removes it.

LOGAND

PLOTCT

### Common blocks used:

/BITMAP/ to use all members
/IOUNIT/ to use LPT ITO
/LENINT/ to use all members

### Classification:

Logical Operations . . . . . . . Utility

## FUNCTION LOGAND(I,J)

### Arguments:

On entry I and J are the integers whose "and" is wanted.
On exit LOGAND is I and J, taken bit by bit.

### Description:

Takes the logical "and" of all of the bits in I and J, except the sign digit, relying on the value of NBITS in /LENINT/ being set to one fewer than the number of bits in an integer (at most). NBITS is set in INITIL as a machine specific quantity.

### Notes:

This is now part of standard FORTRAN

BITSET LOCBIT

### Common blocks used:

/IOUNIT/ to use LPT ITO
/LENINT/ to use all members

### Classification:

Logical Operations . . . . . . . Utility

## SUBROUTINE LOGMAG

### Arguments:

On entry MTYP gives the type of structure, usually read from a Q STYP
card.

### Description:

Complains and stops if MTYP is not between 1 and 5.
Sets only one of FERO, FERA, HELI, AMOD and ANTI to be TRUE and the rest to be FALSE. Sets MODUL to be TRUE if either HELI or AMOD.

ERRMES

### Called by:

DOMAG DOMAG1 MAGLSQ MMPLSQ PALSQ

### Common blocks used:

/SYMMAG/ to use MTYP FERO FERA HELI AMOD ANTI MODUL

### Classification:

Magnetic Structure Factors . . . . . . . Setting Up

## FUNCTION LOGOR(I,J)

### Arguments:

On entry I and J are the integers whose "or" is wanted.
On exit LOGAND is I or J, taken bit by bit.

### Description:

Takes the logical "or" of all of the bits in I and J, except the sign digit, relying on the value of NBITS in /LENINT/ being set to one fewer than the number of bits in an integer (at most). NBITS is set in INITIL as a machine specific quantity.

### Notes:

This is now part of standard FORTRAN

BITSET

### Common blocks used:

/IOUNIT/ to use LPT ITO
/LENINT/ to use all members

### Classification:

Logical Operations . . . . . . . Utility

## SUBROUTINE LSETSF(NW,LSPEC,LWORDS)

### Arguments:

NW on entry is the number of words in this problem's specific vocabulary
LSPEC on entry is an array specifying the meaning of the words
with 3 integers per word - family, genus, species

LWORDS on entry is an A4 array of words in this problem's vocabulary

### Prerequisite calls:

The problem must have already been specified to the extent of:
NFAM=number of families
NGENS(I)=number of genera in family I
NSPC(I)=number of species in each genus of family I

### Description:

Sets up the packing of IFAM, IGEN, ISPC into one integer
Packs the LSPEC integers to 1 word
First sets up the standard Structure Factor LSQ vocabulary for family 2 parameters (and cell from family 1).
Copies both arrays LSPEC and LWORDS into standard arrays IWDSPC and
LSQWD in /WDSPEC/ and /WORDS/.

### Notes:

Because of its use of the standard family 2 names and numbers, it determines these to be the same in every application (e.g. B11 is always species 4).
If this is not what is wanted, use LSETUP and give it the entire vocabulary.

### Calls:

ERRCHK ERRMES F2PARP NPACK VOCAB

### Called by:

CHILSQ MAGLSQ MMPLSQ SFLSQ SFTLSQ

### Common blocks used:

/F2NAMS/ to use all members
/F2NUMS/ to use all members
/LINKAG/ to use NUMFV NUMPAK NUMCON KPTCON
/LSQPAK/ to use all members
/PRBLEM/ to use NFAM
/REFINE/ to use MAG
/WDSPC/ to use IWDNUM

### Classification:

General Least Squares Refinement . . . . . . . Setting Up

## SUBROUTINE LSETUP(NW,LSPEC,LWORDS)

### Arguments:

NW on entry is the number of words in this problem's vocabulary
LSPEC on entry is an array specifying the meaning of the words
with 3 integers per word - family, genus, species

LWORDS on entry is an A4 array of words in this problem's vocabulary

### Prerequisite calls:

The problem must have already been specified to the extent of:
NFAM=number of families
NGENS(I)=number of genera in family I
NSPC(I)=number of species in each genus of family I

### Description:

Packs the LSPEC integers to 1 word
Copies both arrays LSPEC and LWORDS into standard arrays IWDSPC and
LSQWD in /WDSPEC/ and /WORDS/.
Sets up the packing of IFAM, IGEN, ISPC into one integer

### Calls:

ERRCHK ERRMES NPACK

MPLSQ PALSQ

### Common blocks used:

/LINKAG/ to use NUMFV NUMPAK NUMCON KPTCON
/LSQPAK/ to use all members
/PRBLEM/ to use NFAM
/WDSPC/ to use all members
/WORDS/ to use all members

### Classification:

General Least Squares Refinement . . . . . . . Setting Up

## SUBROUTINE LSTCTS(C,D,TMORTS)

### Arguments:

On entry:
C is the uncorrected count-rate
TMORTS(1) and TMORTS(2) the constants \\$t_1\\$ and \\$2_2\\$ and
TMORTS(3) and TMORTS(4) their esd's

On exit:
C is the correction factor by which the observed count should be multiplied
D is its esd

### Description:

Calculates the correction to be applied to a counting rate R due to detector non-linearity. The corrected rate \\$R_c\\$ is given by \\$\\$R_c=R/(1-rt_1-r^2t_2)\\$\\$

BPBPRC AISPRC

### Classification:

Data Collection and Reduction . . . . . . . Utility

## FUNCTION LSYMPG(NAME,FILL)

### Calls:

ERRMES LENGT NCFIND UPONE

INPUTM

### Common blocks used:

/PGNAMS/ to use PGSYMS PGTYPS
/PGNUMS/ to use NPGSYM LPGSYM NPGTYP LPGTYP

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