2.23                     ********************
                                 *  LSQROT WRITE-UP *
                                 ********************
        
           This program refines the orientation and position of a 
        noncrystallographic symmetry axis by least squares. It is applicable 
        only to pure rotational noncrystallographic symmetry axes, and the 
        rotation must be N-FOLD where N is an integer. An input map (which 
        MUST be orthogonal) is read in along with control information 
        specifying initial values for the operator, and what area in the map 
        to consider. The map area considered can be all points within a given 
        distance from an arbitrary input point, all points within an input 
        mask, or all points simultaneously satisfying both conditions. The 
        input map usually encompasses a dimer, trimer etc and was extracted 
        from a FSFOUR map via programs MAPVIEW or EXTRMAP. The input mask, if 
        one is used, must correspond precisely to the input map. If the input 
        map (and mask) does not correspond to an orthogonal system, program 
        MAPORTH should be used to convert them before they can be used here. 
        After each cycle of refinement the correlation coefficient is printed 
        along with the new parameters. One should always start with a low 
        resolution map (roughly 6 angstrom data, on a 2 angstrom grid) in case 
        the initial estimates are inaccurate. As the refinement converges 
        higher resolution data and finer map grids should be used. It is often 
        sufficient to refine within a sphere of radius 25-35 angstroms 
        centered on a point on the rotational axis near the center of gravity 
        of the dimer, trimer etc. This enables refinement of the operator 
        without the need for an input mask (although one will be needed later 
        for averaging). Usually correlation coefficients of about 0.4 or 
        higher (in a 4 angstrom map) indicate the noncrystallographic symmetry 
        axis is well positioned, and that averaging will be useful.
        
        
                                 INPUT DATA (UNIT 5)
        
        
        
         CARD I      PAMFIL      (free format)
        
                     PAMFIL = Input file specifying cell and symmetry 
                              parameters, used only to get "running log" file
        
        
        
         CARD II     INPMAP      (free format)
                           
                     INPMAP = Input map (orthogonal)
        
        
        
         CARD III    PHI, PSI, OX, OY, OZ, NFOLD     (free format)
        
        
                  PHI =  Spherical polar angles defining direction of the non-
                         crystallographic symmetry axis, oriented with respect 
                  PSI =  to orthogonal frame with X along a, Y along c* cross 
                         a, and Z along x cross y (i.e. c*). PSI = angle 
                         between NC symmetry axis and +Y axis.  PHI = angle 
                         between projection of NC symmetry axis on XZ plane 
                         and +X axis. +PHI= CCW rotation about +Y axis as 
                         measured from +X axis. 
        
                   OX =
                         Origin of NC symmetry rotation axis, in angstroms 
                   OY =  with respect to the orthogonal axes. The axis passes 
                         through this point.
                   OZ =
        
                NFOLD =  Order of the rotational axis, e.g 2,3,4 etc.
        
        
        
         CARD IV     NOBS, NCYCLE, ISPHER, IMASK     (free format)
        
                 NOBS =  2 times number of reflections used to compute map 
                         (used only to compute sigmas)
        
               NCYCLE =  Number of refinement cycles
        
               ISPHER =  0 use all points in map
         
                      =  1 use only grid points within a specified sphere.
                   
               IMASK  =  0 for no mask input
        
                      =  1 to only use grid points within envelope specified 
                           by input mask. (also subject to ISPHER criteria)
                    
        
        
         CARD V      INPMSK      (free format)
        
                  ******** include this card ONLY if IMASK=1 ********
        
             IMASK = Input mask file
        
        
        
         CARD VI     XCEN, YCEN, ZCEN RAD     (free format)
        
                 ******** include this card ONLY if ISPHER=1 ********
        
                XCEN  = 
                        Sphere center, in Angstroms, with respect to orthogonal
                YCEN  =
                        coordinate system.
                ZCEN  = 
        
                 RAD  = Sphere radius, in Angstroms
       

 
         CARD VII   ( IVAR(I), I=1,5 )    (free format)
        
                           Variable selection information

                  IVAR(1) = 1 to refine PHI, 0 to hold fixed
    
                  IVAR(2) = 1 to refine PSI, 0 to hold fixed
    
                  IVAR(3) = 1 to refine OX,  0 to hold fixed
    
                  IVAR(4) = 1 to refine OY,  0 to hold fixed
    
                  IVAR(5) = 1 to refine OZ,  0 to hold fixed      


 
        NOTES:  Input map must be orthogonal. If the crystal system does not  
        have orthogonal axes, program MAPORTH must be run to orthogonalize
        the map (and mask, if one is to be used).
        
        If a mask is input, it must coincide exactly with the input map.
        
        Normally all parameters are refined, but occasionally one must use
        the IVAR selection flags to hold a parameter fixed. An example would
        be the case where PSI is close to 0, in which case PHI is then
        indeterminate (and irrelevant!). One could then hold PHI fixed to
        avoid matrix singularities.

  
                                ******** FILES ********
        
        
                 INPUT MAP FILE (BINARY) 
        
        record 1)  A,B,C,AL,BE,GA,NX,NY,NZ,IXMN,IYMN,IZMN,IXMX,IYMX,IZMX
        
        with first 6 values REAL*4, next 9 INTEGER*4, lengths in Angstroms,
        angles in degrees.
        
        NX = 
              Number of grid points defining one "cell length" along
        NY =  respective axis. Implicitly defines grid spacing as 
              del x = A/NX, del y = B/NY and del z = C/NZ
        NZ =
        
        IXMN, IXMX =  
                     Minimum, maximum grid index defining map region such
        IYMN, IYMX = that  x (fractional) = IX * (del x) / A  etc. 
                     There are no restrictions on magnitudes or signs.
        IZMN, IZMX = 
        
        The map follows as (IYMX-IYMN+1)*(IZMX-IZMN+1) records, with each 
        containing one row (IXMX-IXMN+1 REAL*4 values) along X, starting at 
        IXMN. Y is slowest varying, i.e. the file could have been created with 
        the following FORTRAN code:
        
               DO 30 IY=IYMN,IYMX
                DO 20 IZ=IZMN,IZMX
        20     WRITE(LU)(RHO(IX,IY,IZ),IX=IXMN,IXMX)
        30     CONTINUE
        
        
        
                INPUT MASK FILE (BINARY), if needed
        
        Header record identical to map file.
        
        Mask records similar to normal map records except that the mask values 
        are written as FORTRAN type "BYTE" (INTEGER*1). Only grid points with 
        mask values of 0, 10, 20, 30, 40 etc will be used (i.e. inside 
        envelope masks 1,2,3,4,5 etc, respectively).