C****************************************************************
C* 								*
C*								*
C*	DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY *
C*	EITHER FOR THE CREATION OR FOR THE CLINICAL EFFICACY	*
C*	OF THIS PROGRAM. USERS MUST ASSUME FULL RESPONSIBILITY	*
C*	FOR ANY RESULTS OR DIAGNOSES OBTAINED FROM THE USE	*
C*	OF THIS PROGRAM. QUESTIONS ON THE EXECUTION OF THIS	*
C*	PROGRAM MUST BE REFERRED BACK TO THE ORIGINAL AUTHOR.	*
C*								*
C* AUTHOR:	SALLY FORSTER					*
C*		C/O DEPARTMENT OF NUCLEAR MEDICINE		*
C*		GUY'S HOSPITAL				*
C*		LONDON, ENGLAND					*
C*								*
C*		TEL: 01-407-7600 EXT 2583/4			*
C*								*
C****************************************************************
	FUNCTION SVIO(ISV,ICOM)
C*****ICOM=1..OPENS SAVE AREA ISV ON CHANNEL ICS AND READS 
C*****THE SAVE AREA DESC INTO SAVDES,AND THE CURVES
C*****INTO GAMMAS.SYS ON ICB.
C*****ICOM=2..OPENS SAVE AREA ISV ON ICS AND WRITES SAVDES TO
C*****THE SAVE AREA DESC BLOCK.AND THEN COPIES THE CURVES FROM ICB.
C*****ERRORS SVIO=-1..ILLEGAL SAVE AREA
C*****       SVIO=0..SAVE AREA NOT OPEN
C*****       SVIO=1..O.K.
	IMPLICIT INTEGER*2 (D-Z)
	COMMON//SAVDES(256),CURVE1(512),CURVE2(512),ICS,ICB
	COMMON/CH/MACFLG,NAME(3),CSR(20)
	INTEGER*2 IFILE(8)
	DATA IFILE/3RSY ,3RSVA,3RR00,3RSYS,
	<3RSY ,3RGAM,3RMAS,3RSYS/
	DATA ISAVE/3RR00/
C*****RS&WS
	IF(ISV.GT.9)GOTO 100
	SVIO=1
	IFILE(3)=ISAVE+ISV
	IF(LOOKUP(ICS,IFILE).LT.0)GOTO 100
	IF(ICOM.EQ.2)GOTO 40
C*****RS ONLY
	CALL CLOSEC(ICB)
	IF(LOOKUP(ICB,IFILE(5)).LT.0)GOTO 130
	IF(IREADW(256,SAVDES,0,ICS).LT.0)GOTO 100
	IF(SAVDES(7).NE."200)GOTO 140
	CSR(20)=FLOAT(SAVDES(108))
	IC1=ICS
	IC2=ICB
	GOTO 50
C*****WS ONLY
40	IC1=ICB
	IC2=ICS
C*****RS&WS
50	IF(IWRITW(256,SAVDES,0,IC2).LT.0)GOTO 120
	J=1
	DO 60 I=1,SAVDES(184)+1
	IF(IREADW(1024,CURVE2,J,IC1).LT.0)GOTO 110
	IF(IWRITW(1024,CURVE2,J,IC2).LT.0)GOTO 120
60	J=J+4
70	CALL CLOSEC(ICS)
	I=IFREEC(ICS)
	RETURN
100	SVI0=-1
	GOTO 70
110	SVIO=0
	GOTO 70
120	WRITE(7,121)
	STOP'SORRY'
121	FORMAT(1X,'SOMETHING FUNNY IS GOING ON..PLEASE CHECK YOUR
	<DISK')
130	WRITE(7,131)
131	FORMAT(1X,'FILE DK:GAMMAS.SYS NOT FOUND.53 BLOCKS')
	STOP
140	WRITE(7,141)
	GOTO 110
141	FORMAT(1X,'SAVEAREA DOES NOT CONTAIN DYNAMIC CURVES')
	END
