#!/bin/csh

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

# Write usage information
if ( ${#argv} == 0) then
  echo 
  echo "--------------------------------------------------------------"
  echo "Usage: reformat.sh trainp traout        "
  echo 
  echo "         trainp          : Input trajectory file"
  echo "         traout          : Output trajectory file"
  echo
  echo "     mode=1: ascii, sorted by trajectory"
  echo "     mode=2: ascii, sorted by time"
  echo "     mode=3: fortran (unformatted)"    
  echo "     mode=4: IVE netcdf"  
  echo "--------------------------------------------------------------"
  exit 0
endif

set inpfile=$1
set outfile=$2

set prog1=${LAGRANTO}/goodies/reformat
set prog2=${LAGRANTO}/goodies/trainfo.sh

set dim=`${prog2} ${inpfile} dim` 

\rm -f reformat.param
echo \"${inpfile}\"  >! reformat.param
echo \"${outfile}\"  >> reformat.param
echo ${dim}          >> reformat.param

${prog1}

\rm -f reformat.param

exit 0

