
if ( "$TARGETHOST" == "none" ) then
   set TARGETHOST="localhost"
endif

if ( "$TARGETPREP" == "none" ) then
   set TARGETPREP="module purge; module load mpich-pgi7/p4; module load pgi/7.1; module list"
endif

if ( "$RUNTIME" == "none" ) then
   set RUNTIME="168:00:00"
endif

if ( "$MPIF77_FLAGS" == "none" ) then
   set MPIF77_FLAGS="-g -fast"
endif

if ( "$MPIF90_FLAGS" == "none" ) then
   set MPIF90_FLAGS="-g -fast"
endif

if ( "$MPICC_FLAGS" == "none" ) then
   set MPICC_FLAGS="-g -O2"
endif


cat >> tmp.submit << EOF
echo === Preparing batch file for run $RUN on $TOTNODES nodes.
echo === Location: \$USER@`hostname -f`:\$PWD

mv openggcm $RUN.exe

PPN=2
NODES=\$(( ($TOTNODES + \$PPN - 1) / \$PPN))

cat > $RUN.qsub <<XEOF
#! /bin/bash
#PBS -l nodes=\$NODES:ppn=\$PPN:eth
#PBS -l walltime=$RUNTIME

cd \$PWD

mpiexec --comm=mpich-p4 -mpich-p4-no-shmem ./$RUN.exe >$RUN.log 2>&1

XEOF

echo === Submitting job $RUN.qsub
cd \$PWD && qsub $RUN.qsub
EOF
