Run glred and glorg for a list of h-files from GAMIT day directories 
 
  This script can be used to 
             1) aggregate days or networks into a smaller number of h-files
    and/or   2) generate repeatability plots 
 
  It is usually run in conjunction with GAMIT phase processing and takes
  advantage of the directory structure and files of sh_gamit, but it can
  also be used without this structure to combine externally generated h-files.
  Used with sh_gamit, it reads station and directory information from the 
  process.defaults and site.defaults files, searches automatically the day 
  directories for h-files, and gathers (by ftp or local link) additional global 
  or regional h-files for those days. The script then runs glred to combine
  all of the h-files and generates time series of station coordinates.
  It is not designed to run globk and glorg to estimate velocities.
 
 
 USAGE:  sh_glred -d <yr day> -s <yr1 d1 yr2 d2> -r <day> -ncomb <num> -net <networks> -expt <expt> -sinfo <sinfo>
                  -local -ftp_prog <ftp/ncftp> -opt <A F H L U G E K C R> 
  
 REQUIRED: 
   
   Use one of the following to specify the range of days to process:
    -s <yr1 d1 yr2 d2>   start and stop dates, e.g. -s 1997 153 1998 178 
    -d <yr day>          do a single day (e.g., to replace one .org file); e.g. -d 1997 153 
    -r <day>             number of days before current date to start, e.g.. -r 21 
 
 
 OPTIONAL: 
   Use the following to aggregate the data:
    -ncomb <num>   number of consecutive days of data to include in each solution (+ in gdl file) [Default 1] 
    -expt  <expt>  4-char names of experiments/solutions (corresponds to h-file name) [Default expt] 
   Other options
    -net   <networks> list of h-file networks to be retrieved from the SOPAC ftp archive [Default ALL] 
    -netext <char> suffix for directories to search for h-files; i.e. r to search DDDr [Default seach only DDD]
    -yrext  <char> year prefix for directories to search for h-files; i.e. 1997_053 [Default seach only doy]
    -local Only combine days where a local directory (h-file) exists [default do combinations of all requested].
    -noftp Do not try to ftp EOP values (use what's already available or abort)
    -ftp_prog is the name of the ftp program e.g. ftp or ncftp [default is ftp]
 
   Use the following to customize plotting style 
    -xtype set the x-axis of the plots to day or year scale [Default: day if (data span < 365 days)]
    -detrend (Y/N) remove a slope form the plots [Default: no slope if (data span <= 32 days)]
 
  Processing options (at least one required):
   <R>  remove old h*.gl? files from the glfpth directory prior to starting
   <F>  Ftp global h-files from the SOPAC archive, search names given by <networks> 
   <H>  Run htoglb on all ascii files present or linked within glfpth (usually procdir/glbf)
   <LA> Link locally archived ascii h-files (all h[net|expt]?.yyddd) for inclusion in the combination.
         Searches are from hfnd down, where hfnd is by default procdir/glbf but may be specified as multiple paths in process.defaults.
   <LB> Link locally archived binary h-files (all hyymmdd????_[net|expt].gl?) for inclusion in the combination.
         Searches are from hfnd down, where hfnd is by default procdir/glbf but may be specified as multiple paths in process.defaults.
   <LC> Link locally archived binary combined h-files (all Hyymmdd_[net|expt].GLX) for inclusion in the combination.
         Searches are from hfnd down, where hfnd is by default procdir/glbf but may be specified as multiple paths in process.defaults.
   <U>  Run hfupd on binary h-files <-- not yet tested 
   <G>  Run glred for combination or repeatabilities
   <E>  Run ensum and sh_baseline for plots
   <C>  At the end compress the ascii h-files, remove any links, and copy the ascii and binary
        h-files to glbpth/ascih_yyyy and glbpth/binh_yyyy, respetively,  where glbpth is specified
        by process.defaults [default glbf]
   <A>  Do all options
  
 Not required but always to be checked are entries in /tables/sites.defaults for station
 selection by globk, glorg, and multibase (glrepu, glreps, and glts) [default is to use all
 stations in globk and plots, and to use an internally defined list of IGS stations for glorgl]
 Entries may also be made in /tables/process.defaults for solution directory [default procdir/gsoln]
 binary h-file directory (default procdir/glbf), and ascii h-file search path [default procdir/glbf].
 
 OPTIONAL:
 
  -sinfo <sinfo> path to the station.info to be used by hfupd if requested [default tpth/station.info 
                 where tpth from process.defaults usually points to the /tables directory of sh_gamit
 
  -cmd <options>  Run the script just to generate command files for glred and glorg
 
 
 
 EXAMPLES
 
  Combine regional files from sh_gamit with global files from SOPAC, one day at a time
   and generate repeatability plots:  
 
      sh_glred -s 1999 235 1999 250 -net igs1 igs2 igs3 -netext r -expt emed -opt F H G E C 
 
  Regenerate repeatability plots from existing binary h-files (e.g with different stabilzation):
 
      sh_glred -s 1999 235 1999 250 -net igs1 igs2 igs3 -netext r -expt emed -opt G E
 
  Combine existing regional and global binary h-files into monthly averages:
 
      sh_glred -s 1999 235 2000 120 -ncomb 30 -net igs1 igs2 igs3 -expt emed -opt G LB 
 
 
 NOTES 
 
  1. For daily h-files, the .glx (bias-fixed) extension will be chosen if it is
     available; if not, the .glr (biases-free) extension will be used.  To force
     use of .glr, you must remove any .glx files available in /glbf.
 
  2. To avoid overwriting useful h-files or using obsolete ones, it is important to keep 
     in mind the logical precedence established by sh_glred.
 
     For local data (sh_gamit day directories), specifying the H option will force htoglb
     to be rerun for all directories within the time span indicated, whether or not a
     binary file exists in the searched directories (nominally glbf and glbf/bin_yyyy).
     Omitting H will cause no new binary files to be created, so it is not possible
     to have only selected ascii files retranslated (but htoglb runs quickly).
 
     For remote data (locally linked or ftp'd from SOPAC), setting H will also force htoglb
     to be rerun on any ascii h-files present or linked (by LA) in the h-file (glbf)
     directory, but you can safely set F since the script will not re-ftp any remote 
     (ascii) h-files that are present.  
 
  3. Output h-files from the combination are named HYYMMDD_[expt][netext].GLX and 
     written in to the solution directory.  The script creates a separate .gdl file
     for each day with a similar name, each pointing to the combined GLX h-file in
     the solution directory.
 
  4. The script uses command files named globk_comb.cmd and glorg_comb.cmd, which it
     looks for in the solution directory.  If these files do not do not exist, they 
     will be created with the appropriate commands to do a loose combination with 
     glred and a glorg stabilization using the stations specified with glreps in 
     sites.defaults.  If you wish to alter any of the globk or glorg
     commands, e.g. to constrain orbits in a regional solution, you can run sh_glred
     initially with only the -cmd option to create the command files for editing, i.e.
        sh_glred -cmd  [options]
 
  5.  When ensum is run, it will create SUM. and VAL. files by concatenating all .org 
      files present, so that sh_glred can be run separately for different time spans.
  
====================================================================================