#!/bin/bash

# -------------------------------------------------------
# RPC Project :
# Run RPC_current_tube : create 4 POS files and 4 MAG files for tests
# P. Robert, LPP, 2011-03-21
# -------------------------------------------------------

appli=`basename $0`
appli36=`echo "$appli                                 " | cut -c1-36`
Narg=7
echo " -------------------------------------------------------------------"
echo $appli $*


if( (test $# = 1 ) && (test $1 = -h ) ) ; then hh=1 ; else hh=0 ; fi

if test $# != $Narg || test $hh = 1
   then
   echo "$appli : create 8 simulated data files containing position and mag. field values" 
   echo "                   require $Narg argument(s)"
   echo "                   R tube ? (ex: 2000. km)"
   echo "                   Density in A/km2 ? (ex: 0. 0. 0.25)"
   echo "                   characteristic lengh fo the tetrahedron . (ex: 1. or 10., or 100.)"
   echo "                   impact parameter ? (ex: -0.7, in fraction or R tube)"
   echo "                   Velocity in X ? (ex: 10 km/s)"
   echo ""
   if test $hh = 1 ; then exit 0 ; fi
   echo "$ appli36 : *** ERROR ! Command aborted." >&2
   exit 1
fi

echo $appli $*

datim1=`date +%F'  '%H':'%M':'%S `
julsec1=`date +%s`

# remove RPC_ from RPC command

appli=`echo $appli | cut -c5-`

echo $1        > $appli.in
echo $2 $3 $4 >> $appli.in
echo $5       >> $appli.in
echo $6       >> $appli.in
echo $7       >> $appli.in

# run appli.exe 

. run_appli.bash $appli
err=$?
exit $err
