	subroutine get_record(logical_unit,buffer,size,length_total,
     1				istat,fixed_records)

	parameter none  = 0,
     1		  first = 1,
     2		  last  = 2,
     3	          only  = 3

	include 'flags.inc'

 	logical overflow
	common /too_large/ overflow,large_length,iaddress
	integer*2 length,size,rfa(3),save_rfa(3)
	logical fixed_records
	
	integer std_seq_get,rms$_eof
	external rms$_eof,lib$_insvirmem
	byte fish(32768),buffer(32768)
	common /temp/ fish

	overflow=.false.
	ipart=0
	length_total=0
	large_length=0
	i_here=0
	if (fixed_records .or. variable) then
		length_of_header=0
	 else
		length_of_header=2
	 endif
 5	istat=std_seq_get(logical_unit,size,fish,length,rfa)
	if (istat.eq.%loc(rms$_eof)) goto 9000
	if (.not.istat) call lib$stop(%val(istat))
	ipart=ipart+1
	if (ipart.eq.1) then
		do i=1,3
			save_rfa(i)=rfa(i)
		 enddo
	 endif
	length_useful=length-length_of_header
	large_length=large_length+length_useful
	if (i_here+length_useful.gt.32768) then
		length_useful=32768-i_here
		overflow=.true.
	 endif
	do 7 l=1,length_useful
		buffer(l+i_here)=fish(l+length_of_header)
 7	 continue
	i_here=i_here+length_useful
	length_total=length_total+length_useful
	if (fish(1).eq.only .or. fish(1).eq.last .or. 
     1			fixed_records .or. variable) then
		if (overflow) then
			istat1=lib$get_vm(large_length,iaddress)
			if (istat1.eq.%Loc(lib$_insvirmem)) then
				type 10
 10				format(/' Insufficient virtual memory',
     1					' to dump record -- skipping'/)
				return
			 endif
			call get_bigrecord(save_rfa,%val(iaddress),
     1					large_length,fixed_records,istat,
     2					logical_unit)
		 endif
		if (length_total.eq.0 .and. variable) then
			buffer(1)=13
			length_total=1
	 	 endif
		return
	 else
		goto 5
	 endif
 9000	continue
	return
	end

	subroutine get_bigrecord(old_rfa,large_buffer,large_length,
     1				 fixed_records,istat,logical_unit)
	implicit integer (a-z)

	parameter none  = 0,
     1		  first = 1,
     2		  last  = 2,
     3	          only  = 3

	include	'flags.inc'

	logical fixed_records
	byte large_buffer(large_length)
	integer*2 old_rfa(3),size,length
	data size/32768/

	external rms$_eof
	byte fish(32768)
	common /temp/ fish

	i_here=0
	if (fixed_records .or. variable) then
		length_of_header=0
	 else
		length_of_header=2
	 endif

	istat=std_rfa_get(logical_unit,size,fish,length,old_rfa)
	if (.not. istat) call lib$stop (%val(istat))
	length_useful=length-length_of_header
	do 7 l=1,length_useful
		large_buffer(l+i_here)=fish(l+length_of_header)
 7	 continue
	i_here=i_here+length_useful
	length_total=length_total+length_useful

 5	istat=std_seq_get(logical_unit,size,fish,length)
	if (istat.eq.%loc(rms$_eof)) goto 9000
	if (.not.istat) call lib$stop(%val(istat))
	length_useful=length-length_of_header
	do 17 l=1,length_useful
		large_buffer(l+i_here)=fish(l+length_of_header)
 17	 continue
	i_here=i_here+length_useful
	length_total=length_total+length_useful
	if (fish(1).eq.only .or. fish(1).eq.last .or. 
     1			fixed_records .or. variable) then
		return
	 else
		goto 5
	 endif
 9000	return
	end
