c
c The alpha/ipf conversions for reals
c  real_s_intasc
c  real_t_intasc
c  real_h_intasc
c  real_x_intasc
c
c  real_s_ascint
c  real_t_ascint
c  real_h_ascint
c  real_x_ascint
c
	options /float=ieee
	function dix_con_real_s_intasc(nk,data,value,nkar,control)
	implicit none
c
c real conversion (s_format)
c
	include 'dix_def.inc'
	integer*4 nk		!:i: data length
	byte data(*)		!:i: the data
	character*(*) value	!:o: the converted text
	integer*4 nkar		!:o: length of text
	record /control /control!:i: control block
	logical*4 dix_con_real_s_intasc	!:F: true if not compressed
c#
	real*4 real4
	integer*4 exponent,sign,mantisse(4)
	logical*4 mantisse_zero,is_zero
c
	logical*4 overflow
        common /dix_con_common/ overflow
	external dix_con_overflow
	integer*4 dix_util_get_len_fu
c
	real4 = 0
	call dix_util_copy(nk,data,real4)
c
	overflow = .false.
	call lib$establish(dix_con_overflow)
c
	dix_con_real_s_intasc = real4 .ne. 0.0
	if(overflow) goto 50
	write(value,control.format_real4,err=10) real4
10	nkar = dix_util_get_len_fu(value)
	goto 70
c
c We had some kine of overflow, check for the specific parts
c
50	call dix_con_cvt_float_split(control,real4,enttyp_real_s,
     1                               sign,exponent,mantisse,
     1                               mantisse_zero,is_zero)
c
	value = 'Overflow'		!take default
	if(exponent .eq. 'FF'x) then
c
c Exponent has max value, either a NAN or +/- infinity
c
	  if(mantisse_zero) then
	    if(sign .eq. 0) then
	      value = 'plus_infinity'
	    else
	      value = 'Minus_Infinity'
	    endif
	  else
	    value = 'Nan'
	  endif
	elseif(exponent .eq. 0) then
	  value = 'Denorm'
	endif
	nkar = index(value,' ')-1
70	call dix_util_left_just(value,nkar)
	return
	end

	options /float=ieee
	function dix_con_real_t_intasc(nk,data,value,nkar,control)
	implicit none
c
c real conversion (t_format)
c
	include 'dix_def.inc'
	integer*4 nk		!:i: data length
	byte data(*)		!:i: the data
	character*(*) value	!:o: the converted text
	integer*4 nkar		!:o: length of text
	record /control /control!:i: control block
	logical*4 dix_con_real_t_intasc	!:F: true if not compressed
c#
	real*8 real8
	integer*4 sign,exponent,mantisse(4)
c
	logical*4 overflow
        common /dix_con_common/ overflow
	external dix_con_overflow
	logical*4 mantisse_zero,is_zero
	integer*4 dix_util_get_len_fu
c
	real8 = 0
	call dix_util_copy(nk,data,real8)
c
	overflow = .false.
	call lib$establish(dix_con_overflow)
c
	dix_con_real_t_intasc = real8 .ne. 0.0
	if(overflow) goto 50
	write(value,control.format_real8,err=10) real8
10	nkar = dix_util_get_len_fu(value)
	goto 70
c
c We had some kine of overflow, check for the specific parts
c
50	call dix_con_cvt_float_split(control,real8,enttyp_real_s,
     1                               sign,exponent,mantisse,
     1                               mantisse_zero,is_zero)
	
	value = 'Overflow'		!take default
	if(exponent .eq. '7FF'x) then
c
c Exponent has max value, either a NAN or +/- infinity
c
	  if(mantisse_zero) then
	    if(sign .eq. 0) then
	      value = 'plus_infinity'
	    else
	      value = 'Minus_Infinity'
	    endif
	  else
	    value = 'Nan'
	  endif
	elseif(exponent .eq. 0) then
	  value = 'Denorm'
	endif
	nkar = index(value,' ')-1
70	call dix_util_left_just(value,nkar)
	return
	end
	options /float=ieee
	function dix_con_real_x_intasc(nk,data,value,nkar,control)
	implicit none
c
c real conversion (x_format)
c
	include 'dix_def.inc'
	integer*4 nk		!:i: data length
	byte data(*)		!:i: the data
	character*(*) value	!:o: the converted text
	integer*4 nkar		!:o: length of text
	record /control /control!:i: control block
	logical*4 dix_con_real_x_intasc	!:F: true if not compressed
c#
	real*16 real16
	integer*4 exponent,sign,mantisse(4)
	logical*4 mantisse_zero ,is_zero
c
	logical*4 overflow
        common /dix_con_common/ overflow
	external dix_con_overflow
	integer*4 dix_util_get_len_fu
c
	real16 = 0.0
	call dix_util_copy(nk,data,real16)
c
	overflow = .false.
	call lib$establish(dix_con_overflow)
c
	dix_con_real_x_intasc = real16 .ne. 0.0
	if(overflow) goto 50
	write(value,control.format_real16,err=10) real16
10	nkar = dix_util_get_len_fu(value)
	goto 70
c
c We had some kine of overflow, check for the specific parts
c
50	call dix_con_cvt_float_split(control,real16,enttyp_real_x,
     1                               sign,exponent,mantisse,
     1                               mantisse_zero,is_zero)
c
	value = 'Overflow'		!take default
	if(exponent .eq. '7FFF'x) then
c
c Exponent has max value, either a NAN or +/- infinity
c
	  if(mantisse_zero) then
	    if(sign .eq. 0) then
	      value = 'plus_infinity'
	    else
	      value = 'Minus_Infinity'
	    endif
	  else
	    value = 'Nan'
	  endif
	elseif(exponent .eq. 0) then
	  value = 'Denorm'
	endif
	nkar = index(value,' ')-1
70	call dix_util_left_just(value,nkar)
	return
	end
	options /float=ieee
	function dix_con_real_h_intasc(nk,data,value,nkar,control)
	implicit none
c
c real conversion (H_format)
c
	include 'dix_def.inc'
	integer*4 nk		!:i: data length
	byte data(*)		!:i: the data
	character*(*) value	!:o: the converted text
	integer*4 nkar		!:o: length of text
	record /control /control!:i: control block
	logical*4 dix_con_real_h_intasc	!:F: true if not compressed
c#
	real*16 real16
c
	logical*4 overflow
        common /dix_con_common/ overflow
	external dix_con_overflow
	logical*4 dix_con_real_x_intasc
c
c Convert h_float to x_float
c
	real16 = 0.0
	call dix_util_copy(nk,data,real16)
c
	call dix_con_cvt_float(control,
     1                         real16,enttyp_real_h,
     1                         real16,enttyp_real_x,
     1                         overflow)
	if(overflow) goto 50
c
c Now we have a x_float
c	
	dix_con_real_h_intasc = dix_con_real_x_intasc(nk,real16,
     1                                value,nkar,control)
	goto 70
c
c We had some kind of overflow, check for the specific parts
c
50	value = 'Overflow'		!take default
	nkar = index(value,' ')-1
c
70	call dix_util_left_just(value,nkar)
	return
	end
c
c And now the ascint routines
c
	options /float=ieee
	function dix_con_real_s_ascint(line,data,size,control)
	implicit none
c
c Convert real (s_floating)
c
	character*(*) line		!:i: the text
	byte data(*)			!:o: the binary data
	integer*4 size			!:i: the size
	integer*4 control
	logical*4 dix_con_real_s_ascint	!:f: conversion result
c#
c	integer*4 istat
	integer*4 ios
	real*4 hulp	
c
	external dix_msg_invreali
c
c The ots$cvt_t_s is not supported in old vms versions
c	integer*4 ots$cvt_t_s
c
c	istat = ots$cvt_t_s(line,hulp,,,1)
	read(line,2000,err=10,iostat=ios) hulp
2000	format(g20.10e6)
c	if(istat) then
10	if(ios .eq. 0) then
	  call dix_util_copy(size,hulp,data)
	  dix_con_real_s_ascint = .true.
	else
	  call dix_message(control,dix_msg_invreali,line)
	  dix_con_real_s_ascint = .false.
	endif
	return
	end
	options /float=ieee
	function dix_con_real_t_ascint(line,data,size,control)
	implicit none
c
c Convert real (g_floating)
c
	character*(*) line		!:i: the text
	byte data(*)			!:o: the binary data
	integer*4 size			!:i: the size
	integer*4 control
	logical*4 dix_con_real_t_ascint	!:f: conversion result
c#
c	integer*4 istat
	integer*4 ios
	real*8 hulp		!big enough for 4/8
c
	external dix_msg_invreali
c
c The ots$cvt_t_t is not supported in old vms versions
c	integer*4 ots$cvt_t_t
c
c	istat = ots$cvt_t_t(line,hulp,,,1)
	read(line,2000,err=10,iostat=ios) hulp
2000	format(g20.10e8)
c	if(istat) then
10	if(ios .eq. 0) then
	  call dix_util_copy(size,hulp,data)
	  dix_con_real_t_ascint = .true.
	else
	  call dix_message(control,dix_msg_invreali,line)
	  dix_con_real_t_ascint = .false.
	endif
	return
	end
	function dix_con_real_h_ascint(line,data,size,control)
	implicit none
c
c Convert real
c
	character*(*) line		!:i: the text
	byte data(*)			!:o: the binary data
	integer*4 size			!:i: the size	
	integer*4 control
	logical*4 dix_con_real_h_ascint	!:f: the result
c
	integer*4 istat
	real*16 hulp   
c#
	integer*4 ots$cvt_t_h
	external dix_msg_invreal
c
	istat = ots$cvt_t_h(line,hulp,,,1)
	if(istat) then
	  call dix_util_copy(size,hulp,data)
	  dix_con_real_h_ascint = .true.
	else
	  call dix_message(control,dix_msg_invreal,line)
	  dix_con_real_h_ascint = .false.
	end if
c
	return
	end
	options /float=ieee
	function dix_con_real_x_ascint(line,data,size,control)
	implicit none
c
c Convert real*16 alpha/ipf format
c
	include 'dix_def.inc'
	character*(*) line		!:i: the text
	byte data(*)			!:o: the binary data
	integer*4 size			!:i: the size	
	record /control/ control	!:i: control block
	logical*4 dix_con_real_x_ascint	!:f: the result
c
	real*16 real16
c#
	external dix_msg_invreal
c
	read(line,control.format_real16,err=50) real16
	call dix_util_copy(size,real16,data)
	dix_con_real_x_ascint = .true.
	goto 90
c
50	call dix_message(control,dix_msg_invreal,line)
	dix_con_real_x_ascint = .false.
c
90	return
	end
	function dix_con_i8_intasc(control,i8val,line)
	implicit  none
c
c FOrmat a i*8 integer according to the i8 format
c
	include 'dix_def.inc'
	record /control/ control
	integer*8 i8val
	character*(*) line
	logical*4 dix_con_i8_intasc
c
	dix_con_i8_intasc = .false.
	write(line,control.format_integer8,err=10) i8val
	dix_con_i8_intasc = .true.
10	return
	end


