process (version 1.5)

You can also look at:
#! /usr/bin/ksh

###########################################################################
# 
# SYNTAX: process
#
# BRIEFLY: Setup for processing and call major subroutines.
#
# DESCRIPTION: This is the top level routine for the processing script.
# DESCRIPTION: It sources the setup script, opens and closes the log files,
# DESCRIPTION: and calls a number of subroutines to do the actual processing.
#
# VERSION: 1.5
#
# HISTORY: 0.0 -> 1.0 9/11/96
# HISTORY: Added images subroutine
# HISTORY: 
# HISTORY: 1.0 -> 1.1 9/27/96
# HISTORY: Added sources subroutine
# HISTORY: 
# HISTORY: 1.1 -> 1.2 10/8/96
# HISTORY: added spectra subroutine
# HISTORY: 
# HISTORY: 1.2 -> 1.3 11/25/96
# HISTORY: added lightcurves subroutine, 
# HISTORY: 12/4/96 but commented it out pending further debugging
# HISTORY: 12/9/96 moved rev1trend to before filelists
# HISTORY: 
# HISTORY: 1.3 -> 1.4 12/30/96
# HISTORY: uncommented lightcurves subroutine and added the information 
# HISTORY: subroutine
# HISTORY: 1/2/97 added sourceevents subroutine
# HISTORY: 1/3/97 moved eventinfo to before header subroutine
# HISTORY: 
# HISTORY: 1.4 -> 1.5 2/7/97
# HISTORY: added sourceinfo routine
# HISTORY: 1.5 -> 1.6 2/25/97
# HISTORY: added calsource routine
# HISTORY: 
# HISTORY: 1.6 -> 1.7 4/17/97
# HISTORY: added earthevents routine
#
##############################################################################

WHERE_THE_PARFILE_LIVES=${0%/*}
if [ "$WHERE_THE_PARFILE_LIVES" = "$0" ]; then
     WHERE_THE_PARFILE_LIVES=$(which $0 )
     WHERE_THE_PARFILE_LIVES=${0%/*}
fi

SETUP_SCRIPT=$WHERE_THE_PARFILE_LIVES/processing_setup


##############################
#############################
##
## Setup
##
##############################
##############################


###########################################
# set things from the command line
###########################################

WORKING_DIRECTORY=$1

###########################################################################
# check the working directory and set it to the current directory if
# one isn't currently defined
##########################################################################
if [ -z "$WORKING_DIRECTORY" ]; then
     WORKING_DIRECTORY="."
fi

if [ ! -d "$WORKING_DIRECTORY" ]; then
     echo "working directory $WORKING_DIRECTORY is not a directory at all."
     exit 3
fi


##############################
# go to the working directory
##############################
cd $WORKING_DIRECTORY
if [ $? -ne 0 ]; then
     #################
     # didn't work
     #################
     echo "Processing can\'t go to working directory: $WORKING_DIRECTORY"
     exit 3
fi


#######################################
# source the setup and clear the logs
#######################################

. $SETUP_SCRIPT

$UTIL/clear_logs
$UTIL/milestone "Processing started"

#########################################
#########################################
##
##  Start Processing
##
#########################################
#########################################

$SUBS/telemetry
$SUBS/aspecting

$SUBS/readfrfs
$SUBS/combine
$SUBS/faint2bright

$SUBS/linearize
$SUBS/fixthings
$SUBS/makefilters

$SUBS/screen
$SUBS/images
$SUBS/sources
$SUBS/spectra
$SUBS/lightcurves
$SUBS/sourceevents
$SUBS/calsource
$SUBS/earthevents
$SUBS/rev1products

$SUBS/information
$SUBS/eventinfo
$SUBS/header
$SUBS/sourceinfo
$SUBS/rev1trend
$SUBS/filelists



$SUBS/wrapup
$UTIL/close_logs