#!/bin/csh 
# the default shell for N1GE6 is /bin/csh

#REQUIRED PARAMETERS:
# estimated hard runtime. your job will get stuck waiting in the
#   queue if you do not specify this parameter
#$ -l h_rt=0:31:00   

#OPTIONAL PARAMETERS:
# job name 
#$ -N Cas1
# send the standard output to your current working directory
# (where you submit the job from, not where the executable exists)
#$ -cwd
# define the name of your output file
#$ -o cas.log
# merge error and stdout into a single file
#$ -j y

# ---------------------------
# User defined variables:
#   The global $PATH <IS> automatically included in this non-login c-shell
#   so you do not have to include the entire path for a system call
#   like mpiexec
set RUN_NUM=1
set R_HOME="/home/jona/casimir/serial"
set DATA_DIR="/home/jona/casimir/serial/data"
set executable="$R_HOME/cas.out"

# ---------------------------
# start execution:
#   anything from stdout below is redirected to your job output file
#   note: aliases like af90 will not work in a script like this. You will
#         either have to compile before you submit the job to N1GE6 or
#         use gf90 which is not defined by an alias
cd $R_HOME
gf90 casimir.f90 -o $executable
$executable
fft -x 9 2-50 < ens.log > fft.dat
mv *.log *.dat $DATA_DIR
tar -zcf cas.tgz $DATA_DIR/*
mv cas.tgz /archive/jona/casimir/serial/archive/$RUN_NUM
rm -R $DATA_DIR
