; VLBAFIX
;---------------------------------------------------------------
;! looks for subarrays in VLBA data
;# PROCEDURE VLBI
;-----------------------------------------------------------------------
;;  Copyright (C) 2002
;;  Associated Universities, Inc. Washington DC, USA.
;;
;;  This program is free software; you can redistribute it and/or
;;  modify it under the terms of the GNU General Public License as
;;  published by the Free Software Foundation; either version 2 of
;;  the License, or (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU General Public License for more details.
;;
;;  You should have received a copy of the GNU General Public
;;  License along with this program; if not, write to the Free
;;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
;;  MA 02139, USA.
;;
;;  Correspondence concerning AIPS should be addressed as follows:
;;         Internet email: aipsmail@nrao.edu.
;;         Postal address: AIPS Project Office
;;                         National Radio Astronomy Observatory
;;                         520 Edgemont Road
;;                         Charlottesville, VA 22903-2475 USA
;-----------------------------------------------------------------------
;---------------------------------------------------------------
VLBAFIX   LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
VLBAFIX : Procedure to fix (sort etc.) VLBA data
INNAME                             Input file name
INCLASS                            Input file class
INSEQ                              Input file sequence number
INDISK                             Disk number for input file
CLINT                              CL entry interval (min)
                                   0 => 1 minute.
OUTDISK                            Disk number for output file
SUBARRAY                           Set to 1 ONLY if you know you
                                   have subarrays, otherwise
                                   leave default
                                   0 -> NO SUBARRAYS

          VLBAFIX is defined in the VLBAUTIL run file.
----------------------------------------------------------------
VLBAFIX
Type: Procedure
Use:  VLBAFIX is a procedure that will sort, correct subarrays,
      split into different frequencies and index VLBA data, if
      necessary.  This is designed to replace VLBASUBS, VLBAFQS
      and VLBAFPOL.

      Type RUN VLBAUTIL to make the VLBAFIX procedure available.
      NOTE: NEVER ABORT THIS PROCEDURE WHILE IT IS RUNNING, IT
            COULD CAUSE YOUR ORIGINAL DATA FILE TO BE DESTROYED.

  INNAME.....The name of the file to be corrected. Wildcard characters are
             allowed.
  INCLASS....The class of the file to be corrected. Wildcard characters are
             allowed.
  INSEQ......The sequence number of the file to be corrected. Zero defaults
             to the highest sequence number matching INNAME, INCLASS, and
             INDISK.
  INDISK.....The disk drive number of the file to be corrected. Zero defaults
             to any disk.
  CLINT......Calibration table interval in minutes. This should normally be in
             the range 0.25 to 1.0 and is used when the calibration table is
             regenerated. A calibration interval of 1 minute will be assumed
             if this is less than or equal to zero.
  OUTDISK....The disk drive number for the output files, if any are produced.
  SUBARRAY...Set to 0 if there are no subarrays, 1 if there are subarrays.
             This tells VLBAFIX whether to run USUBA or not.
----------------------------------------------------------------
VLBAFIX:            Procedure to look for subarrays
Documentor:         Amy Mioduszewski
Related Programs:   MSORT, USUBA, UVCOP, INDXR, VLBAFPOL VLBAUTIL

VLBAFIX can be run on any VLBA data set loaded into AIPS, it
will only perform fixes to the data that are necessary.  It
runs in these steps:
1) Test the data see if it is in time-baseline (TB) order, if the
   first index (NX) or calibration (CL) tables are present, if it is
   multifrequency and if it has only one stokes.
2) If it is out of TB order, then it sorts it with MSORT
3) If the input SUBARRAY > 1 it fixes the subarray nomenclature with
   USUBA
4) If it is multifrequency, it splits the data into single frequency
   files (with UVCOP) and the file is indexed with INDXR.
5) If it has only one stokes, then VLBAFPOL is run to fix the
   polarization structure.
6) If step 4 has not been performed and the first NX or CL table
   are missing, it creates the NX and/or CL tables with INDXR.
VLBAFIX is designed to replace VLBASUBS, VLBAFQS and VLBAFPOL.

NEVER ABORT THIS PROCEDURE WHILE IT IS RUNNING, IT COULD
CAUSE YOUR ORIGINAL DATA FILE TO BE DESTROYED.

You should run VLBAFIX after you have finished loading the data
from tape but before load any calibration data for non-VLBA
telescopes, or apply the calibration data.

VLBAFIX is intended for all levels of VLBA users.

NOTE: This program will split the frequencies in experiments where
S band (13 cm) and X band (4 cm) or 90 cm and 50 cm are observed
simultaneously (as well as multiple FREQIDs).  However, it WILL
NOT split data where 90 cm, 50 cm and 18 cm are observed
simultaneously correctly.
