#!/usr/local/bin/tcsh
#
# Script to run QG model on GFDL t90 machines 
#
#QSUB -Gp ga1         # project 
#QSUB -Gf 10          # FTMP usage
#QSUB -Gc 1           # Number of processors (for t3e use someday)
#QSUB -Gh t932        # host machine
#QSUB -lT 4:00:00     # CPU time limit for request
#QSUB -lt 3:50:00     # per process CPU time limit - leave time to finish up
#QSUB -lM 4.0Mw       # Memory limit for request 
#QSUB -eo             # combine st error and st output files
#QSUB -J m            # append job log to above file
#QSUB -o /t90/$USER/SQG/DATA/EX1/job.log   
#QSUB -r EX1          # queue name - change in accord w/ DATADIR below

# Dir from which to get input and to which to write output
set DATADIR      = SQG/DATA/EX1

# Set some variables that won't need to be changed often:
set EXEC         = /t90/$USER/SQG/sqg2.84    # full path to executable
set MYFTMP       = /ftmp/$USER               # semi-permanent FTMP space
set BASE         = $ARCHIVE

# Check for input errors
if ( ! -d $BASE/$DATADIR ) then
   echo 'No such data directory: '$DATADIR
   exit
endif
echo "DATADIR     = " $DATADIR
echo "EXECUTABLE  = " $EXEC

# To run, cd to semi-permanent user FTMP space, make a mirror directory
# there (if it doesn't already exist), copy any dmgotten files from archive
# dir to this run directory and run the model in new directory.  
# At finish, copy files back to archive, overwriting old ones if necessary.

dmget $BASE/$DATADIR/*.bin
cd $MYFTMP
if (! -d $DATADIR) mkdir -p $DATADIR
cd $DATADIR
rm -fr *
cp $BASE/$DATADIR/* .
$EXEC . 
cp -f * $BASE/$DATADIR





