#! /bin/csh -f

# This file is used for running VCODE remotely when using NESL.
# It is copied to the remote machine by (execute-vcode-file ..) in
# vcode-test.lisp.
# It is only needed on remote machines that do not support AFS.
#
# The argumets are:
#  1: the user and machine from which to fetch the files
#        in the format username@machinename
#  2: the interpreter file on the remote machine
#  3: the vcode file on the remote machine
#  4: the memory size for the interpreter
#  5: the input file
#  6: the output file

# Use the tmp directory so not to waste space on the file system
cd /tmp

# Copy over the VCODE interpreter executable if not already there.
if (! (-f vinterp)) then
	echo "Copying the interpreter file to remote machine."
	rcp $1\:$2 vinterp
endif

echo "Copying VCODE and input file to remote machine."

# Copy over the VCODE code file.
rcp $1\:$3 vcode_source

# Copy over the VCODE code input file.
rcp $1\:$5 vcode_in

# Run the interpreter.
./vinterp -m $4 vcode_source < vcode_in > vcode_out

echo "Copying results back to local machine."

# Copy back the output file.
rcp vcode_out $1\:$6
