      PROGRAM REFINE
************************************************************************
*         P R O F I L E   R E F I N E M E N T   P R O G R A M          *
*======================================================================*
*                       Version  3-JAN-1989                            *
*                                                                      *
************************************************************************
*************************  H I S T O R Y  ******************************
************************************************************************
*                  H. M. Rietveld - December 1970.                     *
************************************************************************
*    Modified December 1972 for anisotropic temperature factors by     *
*    A. W. Hewat, UKAERE Harwell, Didcot, Berkshire, England.          *
************************************************************************
*    Modified for Voigtian shape function on 1983 by M. Nurmela,       *
*    University of Helsinki.                                           *
************************************************************************
*    Modified June 1986 for x-ray data by M. Nurmela,                  *
*    Imatran Voima Oy, Helsinki                                        *
************************************************************************
*    Modified July 1986 by M. Nurmela, Imatran Voima Oy, Helsinki      *
*    The concept 'number of overlapping reflections' is obsolete.      *
************************************************************************
*    Modified July 1987 by M. Nurmela, Imatran Voima Oy, Helsinki      *
*    Texture correction is changed according to M.Jarvinen.
*    Preparation program attached as a subroutine.                     *
************************************************************************
*    Modified january 1989 by M. Nurmela, Imatran Voima Oy, Helsinki   *
*    A reference to the theory of texture correction is given. No      *
*    changes in code between versions 8-OCT-1987 and 3-JAN-1989.       *
************************************************************************
*                         VARIABLE DIMENSIONS                          *
*                         -------------------                          *
*           B=MAXIMUM NUMBER OF BACKGROUND POSITIONS                   *
*           R=MAXIMUM NUMBER OF EQUIVALENT POSITIONS + 1               *
*           K=MAXIMUM NUMBER OF SCATTERING LENGTHS                     *
*           F=MAXIMUM NUMBER OF FORMFACTORS                            *
*           N=MAXIMUM NUMBER OF ATOMS                                  *
*           M=MAXIMUM NUMBER OF MAGNETIC ROTATION MATRICES             *
*           P=MAXIMUM NUMBER OF LEAST SQUARES PARAMETERS               *
*           C=MAXIMUM NUMBER OF CONSTRAINT FUNCTIONS                   *
*           T=MAXIMUM NUMBER OF TERMS IN CONSTRAINT FUNCTION           *
*           I=MAXIMUM NUMBER OF REFLECTIONS                            *
*           L=MAXIMUM NUMBER OF EXCLUDED REGIONS                       *
*           X=MAXIMUM NUMBER OF PROFILE INTENSITIES                    *
*          PC=P+C                                                      *
*                                   *****                              *
*                      Arrays with variable dimensions                 *
*                      -------------------------------                 *
*          ICODE(I)            IH(3,I)             IHIGH(L)            *
*          IL(C,T)             INDEX(I)            IORD(X)             *
*          IQ(C,T)             JCODE(I)            JL(C,T)             *
*          JQ(C,T)             LL(I)               LN(C)               *
*          LOW(L)              M(I)                MEQ(N)              *
*          MTYP(N)             NTYP(N)             ATEXT(N)            *
*          BAK(B)              BRAGG(I)            C(C,PC)             *
*          CF(C)               COEF(C,T)           COSAR(R,N)          *
*          COSTHE(I)           COSPHI(I)           DERIV(PC)           *
*          DERSTO(I,PC)        DF(C)               DISPIM(K)           *
*          DISPRE(K)           DUMP(I)             EQUIV(4,3,R)        *
*          F(21,F)             FAC(I)              FESD(I)             *
*          FF(I,F)             FMAG(I)             FNUC(I)             *
*          FOBS(I)             H(R,3)              HKL(3,I)            *
*          HW(I)               PLOR(I)             POS(B)              *
*          RM(9,M,R)           RSA(N,3,3)          RSB(N,3,3)          *
*          S(21,F)             SA(N)               SB(N)               *
*          SCAT(K)             SINAR(R,N)          SJJ(I)              *
*          SMM(PC,PC)          SNEX(N)             SOMEGA(I)           *
*          SZ(6,N)             T(I)                TEMP(N)             *
*          TEXCOR(I)           TL(I)               TR(R)               *
*          V(PC)               WEIGHT(X)                               *
************************************************************************
*                            ******************                        *
*                            * PRESENT VALUES *                        *
*                            *      R =   24  *                        *
*                            *      K =   10  *                        *
*                            *      F =   10  *                        *
*                            *      N =   30  *                        *
*                            *      M =    2  *                        *
*                            *      P =   47  *                        *
*                            *      C =    4  *                        *
*                            *      PC=   51  *                        *
*                            *      I =  999  *                        *
*                            *      T =    9  *                        *
*                            *      B =  100  *                        *
*                            *      L =   10  *                        *
*                            *      X =15000  *                        *
*                            ******************                        *
*               *****************************************              *
*               *   UNIT  3 = Raw measurement data      *              *
*               *   UNIT  5 = Standard input            *              *
*               *   UNIT  6 = Standard output           *              *
*               *   UNIT  7 = Disk file for reflection  *              *
*               *             output                    *              *
*               *   UNIT  8 = Disk file for profile     *              *
*               *             output                    *              *
*               *   UNIT 13 = Output file for observed  *              *
*               *             and calculated profile    *              *
*               *   UNIT 18 = Output file for observed  *              *
*               *             and calculated structure  *              *
*               *             factors.                  *              *
*               *****************************************              *
*                                                                      *
************************************************************************
*             PARAMETER NAME CONVENTIONS IN THIS PROGRAM               *
*                                                                      *
*      1.          Instrument dependent parameters                     *
*      --          -------------------------------                     *
*                                                                      *
*               PINSTR(1)  = Asymmetry parameter                       *
*               PINSTR(2)  = Overall scale factor                      *
*               PINSTR(3)  = Gaussian halfwidth parameter T            *
*               PINSTR(4)  = Gaussian halfwidth parameter U            *
*               PINSTR(5)  = Gaussian halfwidth parameter V            *
*               PINSTR(6)  = Gaussian halfwidth parameter W            *
*               PINSTR(7)  = Lorentzian halfwidth parameter X          *
*               PINSTR(8)  = Lorentzian halfwidth parameter Y          *
*               PINSTR(9)  = Zeropoint parameter Z                     *
*               PINSTR(10) = Zeropoint parameter S                     *
*----------------------------------------------------------------------*
*                                                                      *
*      2.          Structure dependent parameters                      *
*      --          ------------------------------                      *
*                                                                      *
*               PCRYST(1)  = Cell constant A in the equation below     *
*                  .                    .                              *
*                  .                    .                              *
*                  .                    .                              *
*               PCRYST(6)  = Cell constant F in the equation below     *
*               PCRYST(7)  = Overall temperature factor                *
*               PCRYST(8)  = Texture parameter #1                      *
*               PCRYST(9)  = Texture parameter #2                      *
*                  .                    .                              *
*                  .                    .                              *
*                  .                    .                              *
*               PCRYST(22) = Texture parameter #15                     *
*                                                                      *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
*        1/d**2 = A*h**2 + B*k**2 + C*l**2 + D*k*l + E*h*l + F*h*k     *
*                                                                      *
*----------------------------------------------------------------------*
*                                                                      *
*      3.                Atom parameters                               *
*      --                ---------------                               *
*                                                                      *
*               PATOM(1)   = Fractional atomic coordinate x            *
*               PATOM(2)   = Fractional atomic coordinate y            *
*               PATOM(3)   = Fractional atomic coordinate z            *
*               PATOM(4)   = Isotropic atomic temperature factor B     *
*               PATOM(5)   = Occupation number                         *
*               PATOM(6)   = Magnetic vector component K(x)            *
*               PATOM(7)   = Magnetic vector component K(y)            *
*               PATOM(8)   = Magnetic vector component K(z)            *
*               PATOM(9)   = Anisotropic temperature factor B(11)      *
*               PATOM(10)  = Anisotropic temperature factor B(22)      *
*               PATOM(11)  = Anisotropic temperature factor B(33)      *
*               PATOM(12)  = Anisotropic temperature factor B(12)      *
*               PATOM(13)  = Anisotropic temperature factor B(13)      *
*               PATOM(14)  = Anisotropic temperature factor B(23)      *
*                                                                      *
************************************************************************
