#

if ($#argv != 1) then
  echo "";echo "Usage: runjob.csh <seed_int>"
  echo "  e.g. runjob.csh 654321";echo ""
  goto done
endif

rm -f mpikaia.output mpikaia.error

set seed=$argv[1]
set ARCH=`uname -s`
set MARCH=`uname -m`

if ($ARCH == 'Linux') then
# Linux default
  if ($MARCH == 'i686') then
# np is the number of processors
    mpirun -np 2 mpikaia $seed > mpikaia.output
  endif
# frost
  if ($MARCH == 'ppc64') then
# n is the number of nodes (2 CPU/node)
# c is the number of processors
# t is the estimated runtime
    cqsub -n 9 -c 17 -m vn -t 00:05:00 -O mpikaia mpikaia $seed
  endif
# lightning
  if ($MARCH == 'x86_64') then
    cat << 'EOF' > lightning.lsf
#!/bin/ksh
#
#BSUB -a mpich_gm                       # select the mpich-gm elim
#BSUB -n 9                              # number of total tasks
#BSUB -R "span[ptile=2]"                # run 2 tasks per node
#BSUB -o mpikaia.output                 # output filename (%J to add job id)
#BSUB -e mpikaia.error                  # error filename
#BSUB -J mpikaia                        # job name
#BSUB -q regular                        # queue
'EOF'
echo "mpirun.lsf ./mpikaia" $seed >> lightning.lsf
    bsub < lightning.lsf
    rm -f lightning.lsf
  endif
endif

# bluesky/bluevista
if ($ARCH == 'AIX') then
  cat << 'EOF' > bluesky.ll
#@job_name         = mpikaia
#@wall_clock_limit = 0:05:00
#@output           = mpikaia.output
#@error            = mpikaia.error
#@job_type         = parallel
#@network.MPI      = csss,shared,us
#@node             = 1
#@total_tasks      = 4
#@node_usage       = shared
#@class            = share
#@queue
setenv MP_RESD yes
setenv MP_RMPOOL 1
setenv MP_PGMMODEL spmd
setenv MP_NODES 1
setenv MP_PROCS 4
setenv MP_CPU_USE unique
'EOF'
echo "poe mpikaia" $seed >> bluesky.ll
  llsubmit bluesky.ll
  rm -f bluesky.ll
endif

done:

