#! /bin/csh -f
# ***************************************************************************
#    FILE:  maketree
#    USAGE: maketree < [ pathname/ ]cruise-name > < CODAS path >
#    csh script for setting up a subdirectory system for an ADCP
#    database and automatically copying the required control and .M files
#    to the appropriate subdirectories.  It is derived from the original 
#    adcptree and is limited to creating and copying only selected
#    directories and files useful for data extraction and plotting.
#
#    The command line argument must
#    specify the pathname (optional), and cruise name (e.g., MW8901) as
#    a single string; the cruise name should have no more than 8 characters.
#    The CODAS path may also be specified on the command line or
#    else it defaults to the CODASPATH definition below.
# **************************************************************************
echo " "
if ($#argv < 2) then
#   set CODASPATH = /home/`hostname`/programs
   set CODASPATH = /home/noio/programs
else
   set CODASPATH = $argv[2]
endif
if ($#argv < 1) then
   echo " USAGE: maketree <[pathname/]cruise-name> [CODAS-path]"
   echo " EXAMPLE: maketree mw9103 /home/noio/programs"   
   echo " "
   exit
endif
mkdir -p $argv[1]/adcpdb $argv[1]/contour $argv[1]/grid $argv[1]/quality \
         $argv[1]/stick $argv[1]/vector $argv[1]/util
set DEST = `pwd`/$argv[1]
pushd $CODASPATH/codxtrct/cntfiles > /dev/null
cp as_con.cnt contour.cpa                	$DEST/contour
cp llgrid.cnt timegrid.cnt arrdep*.cnt		$DEST/grid
cp profstos.cnt profstuw.cnt			$DEST/quality
cp as_con.cnt  					$DEST/stick
cp as_vec.cnt vector.cnt			$DEST/vector
cp mkblkdir.cnt lst*.cnt as_sub.cnt asc_dump.cnt $DEST/util
cd ../mfiles > /dev/null
cp stn_udw.m   					$DEST/quality
cp runstick.m    				$DEST/stick
echo "Done."
popd > /dev/null
echo " "
