	character*34 out
	logical over

	open(unit=10,file='LRC.dat')

	call ieopen(2,'gpib2')
	call egstatus(ibsta,iberr,iegerr,ibcntrl)
	print*,ibsta,iberr,iegerr,ibcntrl

	call IEk196init(2,22,4,0)
c for controlling keithley model 196 DMM
c
c  iunit: unit number for connection established with IEopen
c   iadd: primary address of device [22,23]
c ifunct: 0:DCV, 1:ACV, 2:OHM, 3:DCA, 4:ACA, 5:ACV_dB, 6:ACA_dB, 7:comp_OHM 
c irange: 0:auto, 1:.3, 2:3, 3:30, etc. 7 max
c
c
	call IEk196status(2,22,out)
c	subroutine IEk196status(iunit,iadd,out)
c for controlling keithley model 196 DMM
c
c  iunit: unit number for connection established with IEopen
c   iadd: primary address of device [22,23]
c    out: string in which output is placed
c
c status report default 1961010000010000000023600000000\c\n
c        33 bytes       mdlABFGJKMMNPPQQQQQQRSTWWWWWYZcal
c	print*,out

	call IEw23reset(2,8)
c	subroutine IEw23reset(iunit,iadd)
c for controlling wavetek model 23 function generators
c
c  iunit: unit number for connection established with IEopen
c   iadd: primary address of device [8,9]

	call IEw23status(2,8,out,f,a1,o)
c	subroutine IEw23status(iunit,iadd,out,freq,amp,offset)
c for controlling wavetek model 23 function generators
c
c  iunit: unit number for connection established with IEopen
c   iadd: primary address of device [8,9]
c    out: string in which output is placed [34 bytes max]
c   freq: frequency in Hz
c    amp: amplitude in V
c offset: DC offset in V (-5.1 to 5.1)
	print*,out,f,a1,o

	print*,'enter fstart, fstop, n'
	read*,fstart,fstop,n
	write(10,*)fstart,fstop,n

c	subroutine IEk196read(iunit,iadd,xx,xerror,over)
c for controlling keithley 196 DMM
c takes multiple readings and reports stable result or enlarges error accordingly
c ifunct & irange set in IEk196init
c
c  iunit: unit number for connection established with IEopen
c   iadd: primary address of device [22,23]
c     xx: reading
c xerror: calibration error from manual
c   over: flags errors, including overflow

c	subroutine IEw23(iunit,iadd,ifunct,imode,freq,amp,offset)
c for controlling wavetek model 23 function generators
c
c  iunit: unit number for connection established with IEopen
c   iadd: primary address of device [8,9]
c ifunct: 0:sin, 1:square, 2:triangle, 3:rampUp, 4:rampDown, 5:DC
c  imode: 0:continuous, 1:triggered, 2:gated, 3:trigHaver, 4:gateHaver, 5:clock, 6:synthesized
c   freq: frequency in Hz
c    amp: peak-to-peak amplitude in V (into 50 ohms, so typically will be larger) max: 10.2
c offset: offset in V (-5.1 to 5.1)
c
c if imode=6, freq is changed to reflect the exact valued produced


	do i=0,n-1
		f=fstart*(fstop/fstart)**(float(i)/(n-1))
		call IEw23(2,8,0,0,f,3.34,0.)
		call IEk196read(2,22,a,ae,over)
		if(over)stop
		print*,f,a,ae
		write(10,*)f,a,ae
	enddo
	call ieclose(2)
	close(10)

	end

