#!/bin/bash

# -------------------------------------------------------
# RPC Project :
# Run vectime_vdh_to_xyz_GEOMAG: change coordinate of GEOS/S331 from VDH to XYZ
# P. Robert, ScientiDev, sep. 2020
# -------------------------------------------------------

appli=`basename $0`
appli36=`echo "$appli                                 " | cut -c1-36`
Narg=2
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 : change coordinate of GEOS/S331 from VDH to XYZ"
   echo "$appli   require $Narg argument(s), ex:"
   echo "$appli   GEOS1_MAG_VTL2_19771207.rff  GEOS1_MAG_VTL2_19771207_XYZ.rff"
   echo "         GEOS1_MAG_VTL2_19771207.rff     : name of an input   RFF file"
   echo "         GEOS1_MAG_VTL2_19771207_XYZ.rff : name of the output RFF file"
   echo ""
   if test $hh = 1 ; then exit 0 ; fi
   echo "$appli36 : *** ERROR ! Command aborted." >&2
   exit 1
fi

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

# remove RPC_ from RPC command

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

# creating appli.in from arguments list

if test -f $appli.in ; then \mv $appli.in $appli.in.old ; fi

for i in $*
    do
    echo $i >> $appli.in
done

# run appli.exe 

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