
#.... JR 2011-03-31;  target for moose and friends

if ( "$TARGETHOST" == "none" ) then
   set TARGETHOST="moose.sr.unh.edu"
endif

if ( "$TARGETPREP" == "none" ) then
   set TARGETPREP="export GFORTRAN_UNBUFFERED_PRECONNECTED=y "
endif

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

if ( "$MPIF77_FLAGS" == "none" ) then
   set MPIF77_FLAGS=" -O3 -v -w -mcmodel=medium  "
endif

if ( "$MPIF90_FLAGS" == "none" ) then
   set MPIF90_FLAGS="-g -O -w -mcmodel=medium "
endif

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


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

mv openggcm $RUN.exe
#...... we want to run everything in the pp directory, which is supposed to be on a large file system
mkdir -p \$HOME/pp/$RUN
/bin/cp -au ./* \$HOME/pp/$RUN
ln -s \$HOME/pp/${RUN} \${PWD}/target &>/dev/null 
cd \$HOME/pp/$RUN

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

cat > $RUN.qsub <<XEOF
#!/bin/csh

cd \$HOME/pp/\$RUN
/bin/ls -al
date
setenv GFORTRAN_UNBUFFERED_PRECONNECTED y
mpirun -np \$NODES   -mca btl '^sm' $RUN.exe >&! $RUN.log

XEOF

echo === Submitting job $RUN.qsub  Target: remote-unh-quads
cat $RUN.qsub 
csh $RUN.qsub  &
EOF
