#!/usr/local/bin/sbcl --script
;
; This program will use the grid to multiply 2 numbers which
; are input by the user. It will display the result and the IP
; address of the CPU Resource Server that was used. It will
; also tell the user if the program was self executed or grid
; executed. Portable tasks are self executed if the local
; machine has the highest ACR.
;

(load "/home/grid/porta.lisp")

;
; Main Program
;

(defvar resultp NIL)
(defvar a NIL)
(defvar b NIL)
(defvar ip NIL)
(defvar self NIL)

(format t "~%Grid Demo. Performs multiplication & shows which CPU Resource Server was used.~%~%")
(format t "Input 1st integer: ")
(force-output)
(setq a (read))
(format t "Input 2nd integer: ")
(force-output)
(setq b (read))

(multiple-value-setq (resultp ip self)
	(porta
		(list 'progn			; This progn is used to transfer vars to the portable task.
			(list 'defvar 'x a)
			(list 'defvar 'y b)
			'(progn			; This progn contains the portable task. Not really needed
				(* x y)		; for this example but good if the portable task contains
			)			; multiple forms or objects.
		)
	)
)

(format t "Result of multiplication = ~a~%" resultp)
(format t "CPU Resource Server used = ~a~%" ip)
(if self
	(format t "Task was self executed.~%")
	(format t "Task was grid executed.~%")
)

;
; End Main
;
