Subversion Repositories lagranto.um

Rev

Rev 3 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/bin/csh

# Set Lagranto 
set LAGRANTO = ${LAGRANTOBASE}.${MODEL}/

# Write usage information
if ( ${#argv} == 0) then
  echo 
  echo "--------------------------------------------------------------"
  echo "Usage: extract.sh trainp traout [options]        "
  echo 
  echo "         trainp           : Input trajectory file"
  echo "         traout           : Output trajectory file"
  echo
  echo "       Options: "
  echo 
  echo "         -var    list of variables    : trajectory columns"
  echo "         -time   list of times        : trajectory times"
  echo "         -tra    list of trajectories : single trajectories"
  echo "         -startf                      : Starting points"
  echo "         -index  filename             : Index file list"
  echo "         -boolean  filename           : Boolean file"
  echo
  echo "       Lists are of the following format: 2, 4 to 7, 9"
  echo "---------------------------------------------------------------"
  exit 1
endif

# Set the input and output filenames
set inpfile = $1
set outfile = $2
shift; shift;

# Handle optional arguments (get a list, remove , and / separators)
set mode=$1
shift;
set str=
while ( $#argv > 0 )
   set str = "${str} $1"
   shift
end
set str=`echo $str | sed -e "s/,//g"`  
set str=`echo $str | sed -e "s/\///g"`  

# Check the mode is valid
if ( "${mode}" == "-var"      )  goto next
if ( "${mode}" == "-time"     )  goto next
if ( "${mode}" == "-tra"      )  goto next
if ( "${mode}" == "-startf"   )  goto next
if ( "${mode}" == "-index"    )  goto next
if ( "${mode}" == "-boolean"  )  goto next

echo " Invalid mode ${mode}..."
exit 1

next:

# Set program names
set prog1=${LAGRANTO}/goodies/extract
set prog2=${LAGRANTO}/goodies/trainfo.sh

# Get trajectory dimensions
set dim=`${prog2} ${inpfile} dim` 

# Run program
\rm -f extract.param
echo \"${inpfile}\"  >! extract.param
echo \"${outfile}\"  >> extract.param
echo \"${mode}\"     >> extract.param
echo ${dim}          >> extract.param
echo \"${str}\"      >> extract.param

${prog1}

#\rm -f extract.param

exit 0