NAME:
  msrcor
 PURPOSE:   (one line only)
  Spatial correlation of source positions found in multiple lists
 DESCRIPTION:
  This routine is a conceptual extension of the Astronomy Users Library
    routine, srcor.pro.  This extension of this routine is that you
    can correlate more than two lists of positions.
  Each call of this routine will serve to add one list to the description
    of the union of all the prior lists.  The lists are copied into the
    information collected about the set of lists so you don't need to
    maintain a copy of the original lists.
 CATEGORY:
  Photometry
 CALLING SEQUENCE:
  msrcor,set,x,y,dcr
 INPUTS:
  set - This is the description of the set of all lists seen thus far.
          There are three ways to signal the first call to this routine.
          1) set is undefined
          2) set is not a structure
          3) set is a valid structure but set.nlists is equal to zero.
        Note that there is absolutely no performance advantage to maintaining
          a previous structure and then setting set.nlists=0.  If you want
          to restart it is just as effective to simply say set=0 prior to
          an initilizing call.
        If the structure exists already and set.nlists!=0 then the information
          will be added to and the anonymous structure will be modified
          before returning.
  x,y - Array of x and y coordinates for a new list to add to the set.
          The order in which these array are successively presented to msrcor
          will determine the ordinal number of the list within the set.
  dcr - Critical radious outside which correlations are rejected.
          x,y,dcr can be in any units that make sense to your problem but
          they must all be the same units.
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
 OUTPUTS:
  set - Information structure, the following tags are defined:
         x - X position of source (all lists are concatenated here)
         y - Y position of source (all lists are concatenated here)
         objid - vector that matches the length of x and y.  These values
                   are unique object id numbers, starting at 0.
         objcnt - vector that indicates how many times each object
                     appears in the lists (<= nlists)
         lidx   - vector (same length as x,y) that indicates which list
                     the position appears in.
         nobj   - scalar, number of unique objects found.
         nlists - scalar, total number of lists included.

  There may be other related information you might like to keep along with
    this information, such as magnitude or FWHM.  If you concatentate
    everything in list order you will have a vector whose structure matches
    set.x and set.y and the indexing for all will be the same.
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  2008/06/18, Written by Marc W. Buie with algorithmic input from Leslie Young,
     Southwest Research Institute.
  2011/08/02, MWB, promoted all counters and pointers to long, this caused
                      some odd problems when linking a lot of lists.