#!/bin/csh
#
# Make multiple runs under either LSF or LL
#   Must set exec below to pre-existing executable (this script does not build)
#   Input args are list of namelist read files
#
# Location of pre-existing model executable:
#
set exec = /ptmp/foster/tiegcm-multi/tiegcm-aix/tiegcm
if (! -e $exec) then
  echo ">>> Cannot find exec file $exec"
  exit
endif
if (! -x $exec) then
  echo ">>> Exec file $exec is not executable."
  exit
echo "exec = $exec"
#
# Must have at least one namelist input file:
#
if ($#argv == 0) then
  echo " " ; echo ">>> Please provide at least one namelist input file argument"
  exit
endif
#
# Determine if using LoadLeveler (e.g., bluesky), or LSF (e.g. bluevista
# or lightning):
#
set LSF = 0
set LL  = 0
if ($?LSF_ENVDIR) then
  set LSF = 1
  echo "Using Load Sharing Facility (LSF)"
else
  set LL = 1
  echo "Using LoadLeveler (LL)"
endif
#
@ job = 1
set prevjobname = dummy
#
# Loop through namelist input file(s) arguments:
#
while ($#argv)
  set input   = $argv[1]
  set jobname = multi_${job}
  set output  = $jobname.out
  set script  = $jobname.job
  echo "Job ${job}: script=$script  input=$input  output=$output"


#
# Update for next run:
#
  set prevjobname = $jobname
  @ job++
  shift


end # while there is another input file from args
