Collect astrometry observations for multiple objects
  This program takes care of assigning a unique code to moving target
    astrometric observations.  But, there may already be a cross-reference
    file for some observations.  These are applied at the same time.

  The current directory is scanned for all files ending in .ast.  These
    are the raw astrometry files.  Second, a file name lplast.xrft is
    sought.  This file will contain cross-references between the raw
    ids implied by the raw astrometry files and some other unique
    designation.  Anything that does not have an entry in the
    cross-reference file needs a final code which is optionally
    generated by this program.  If you request file codes, another
    file is consulted, newobj.dat in the SAVEDIR directory, and a unique
    id is generated and added to the lplast.xrft file.

  The newobj.dat file is searched for the first properly formatted line.
    This object code of this is used as a template for further codes.
    An object code consists of one or more alphabetic characters followed
    by up to five numeric digits.  Usually, there are two leading
    alphabetic characters but this program doesn't mind finding more.
    If there is one only alphabetic character then the limit is 99999
    object codes in the file.  If you have two or more alphabetic
    characters, the last digit of these will be used as an additional
    sequence character starting at 'A' (regardless of what may already
    be in the file).  This increases the limit to 2,600,000 (less 26,
    0 is not used).

  Once all the cross-referencing and code assignment is complete, a series
    of files is written to SAVEDIR.  YYMMDD is the date which is generated
    from the name of the current directory, usually meant to be the UT date
    of observation (but is not required, any name will do)
      SAVEDIR/YYMMDD.ast  - astrometry file (my format)
      SAVEDIR/YYMMDD.ted  - astrometry file (Ted Bowell format)
      SAVEDIR/YYMMDD.kted - astrometry file of slow moving objects (Bowell)
      SAVEDIR/ - summary listing of all objects in ast/ted file
      SAVEDIR/YYMMDD.kinfo - summary list of all objects in kted file.

  Note that the objects are placed into the ast and ted files in order of
    increasing rate of motion.  Also note that generating final codes can
    be hard to undo so only do it if you are absolutely sure you are ready.




  ALLTNO  - Flag, if set will alter the list of objects sent to the kinfo,
              and kted files.  With the flag, a query is done against the
              des.dclass table to find a list of currently known TNOs.  To
              this list is also added any slow moving object that is at a
              solar elongation of 150 degrees or greater.  These slow
              moving objects are NOT incorporated into the .ted file.
  DES     - Flag, if set will alter the list of objects sent to the kinfo,
              and kted files.  Without the flag, the files contain slow
              moving objects.  With the flag, a query is done against the
              des.vclass table to find a list of interesting objects.  To
              this list is also added any slow moving object that is at a
              solar elongation of 150 degrees or greater.  These slow
              moving objects are NOT incorporated into the .ted file.

    If neither of the flags above are specified, the .ted and .info files
    contain everything and no .kted and .kinfo files are created.  These
    secondary files are intended to carry the TNOs of interest and suppress
    them in the primary output files.  It is allowed to have just one or both
    of these keywords.

  NONEWCODE - Flag, if set suppresses the generation of new object id codes.
  NOXREF  - Flag, if set will not use available cross-reference information.
  OBSCODE - Observatory code for observations, default='688' (Lowell Obs.)
              THIS IS IMPORTANT!  So much so that it probably should not
              be a keyword input parameter.
  SAVEDIR - Directory where final astrometry is to be placed.  The default
              value is /net/frakir/raid/buie/astrometry
  NODB    - Flag, if set will suppress saving new codes to des.newobj database.
              This flag has no effect if not setting final codes.
  REPOST  - Flag, if set will check to make sure the localid code is present
              in the des.newobj database.  If it is not found, it will be
              (re)posted to the database.  NODB will override this keyword.
              You must also enable final codes to be able to repost the data.







  This program reads all the .ast files in the current directory and then
    writes files to SAVEDIR among which is one file with a .ast suffix.  This
    output file is NOT the same format as the input .ast files.  If you
    accidentally make this mistake, then the SECOND time you run astcol,
    it will pick up the output file and become very unhappy.


  1997/03/18 - Written by Marc W. Buie, Lowell Observatory
  1997/07/09 - Added the savedir keyword
  1997/07/25, MWB, slight change to the Bowell file format output.
  1998/06/22, MWB, added call to ASTLIST at end, also newcodes are taken from
                     first available number, not last code in file.
  1998/11/04, MWB, now filters out magnitudes fainter than 80.0
  2000/03/09, MWB, moved creation of .ted file to
  2000/09/20, MWB, changed to support vectors with repwrite.
  2002/09/09, MWB, added support for string obscode values
  2003/05/02, MWB, added NOXREF keyword
  2003/08/15, MWB, added NODB keyword and database storage to des.newobj
  2004/02/09, MWB, changed SAVEDIR default path
  2004/02/27, MWB, changed the codetag algorithm to extend the sequence
  2004/07/24, MWB, added the DES flag
  2004/9/21, MWB, removed obsolete call to Findfile
  2005/03/31, MWB, added REPOST keyword
  2005/10/12, MWB, fixed bug that prevented saving slow moving objects to a
                     separate file if the mysql-based list was empty
  2005/11/28, MWB, added code to make SAVEDIR if it doesn't exist but only
                     if the user requests that the program try to make it.
  2013/09/16, MWB, added ALLTNO keyword