REAL*4 VMS v. ULTRIX (SUMMARY)

John Kemp kemp at uiatma.atmos.uiuc.edu
Wed Jun 19 23:57:36 AEST 1991


Here is a summary of responses.  I obviously should have said
"VAX/VMS-to-RISC/Ultrix floats" in my question, as a number of
people pointed out.

The network cookies are to be split between David Warren and
Jim Pflugrath:  one sent an actual subroutine for doing the 
conversion, the other sent the man page for a RISC/Ultrix library
subroutine that deals with the conversion.

Thanks for all the contributions people!
--------  john kemp            (  (  )_  internet - kemp at uiatma.atmos.uiuc.edu
  -----                       (  (   __)   decnet - uiatmb::kemp
   ---    univ of illinois   (_ (   __)    bitnet - {uunet,convex}
   --     dept of atmos sci  .(____).               !uiucuxc!uiatma!kemp
   -      105 s gregory ave    ...          phone - (217) 333-6881
    -     urbana, il 61801    ...             fax - (217) 244-4393

-------------------- Original Posting -----------------------------

We have a bunch of REAL*4 binary files on a VMS machine.
We want to move them to an ULTRIX machine.  Here are the 
two $64,000,000 questions:

1) If we want to ftp the binaries, how should they be converted
   first before ftping them to the Ultrix machine?

2) What are the differences between the REAL*4 format on
   VMS and Ultrix?

Correct answers will be rewarded with a network cookie!

----------------------- Responses ----------------------------

From: Richard Seymour <seymour at milton.u.washington.edu>
Subject: Re: REAL*4 VMS v. ULTRIX

is your target machine a VAX running ULTRIX (in which case, the numbers
should just work...)
or a RISC DECstation (in which case, i don't know what will happen
-- but they may work)?

(gee -- i should look/test this one -- i'm bound to run into it...)
--dick

From: pflugrat at cshl.org (Jim Pflugrath)

I recommend ftping first, then converting.  Mostly because the Ultrix machine
is probably a faster machine.

2) What are the differences between the REAL*4 format on
   VMS and Ultrix?

Below is code to convert from VMS to IEEE floating format.  Note that
the Ultrix supplied ftoi procedure does not work properly for some
numbers (as we found out to our dismay!).

Jim Pflugrath

P.S.  Since VMS and Ultrix have same byte-order, SWAP should be undefined
below.

========cut here for vureal.c==================
/*
** vureal_
**
** Convert a VMS 4 byte floating point representation to a IEEE 754 floating
** point representation.
**
** 19-Dec-1990        Ching-Lin Lun         Cold Spring Harbor Laboratory
**    Created.
*/
void vureal_(n)
unsigned long *n;
{

#ifdef SWAP
/*
** swap bytes  (may not be necessary on your machine)
*/
  *n =   ((*n & 0xff) << 24) + ((*n & 0xff00) << 8) + ((*n & 0xff0000) >> 8)
       + ((*n & 0xff000000) >> 24);
#endif

/*
** On VMS, if exponent is 0, then number is 0 no matter how other bits are set
*/
  if ( (*n & 0x0001fe00) == 0) {
     *n = 0;
     }
  else {
/*
** shift the bits from VMS format to Sun format 
** ffffffffffffffffseeeeeeeefffffff => seeeeeeeefffffffffffffffffffffff 
*/
     *n = ((*n & 0x8000) << 16)     + ((*n & 0x7f80) << 16) +
          ((*n & 0xffff0000) >> 16) + ((*n & 0x7f) << 16);
/*
**  ... and subtract 2 from exponent
*/
     *n = *n - 0x1000000;
   }
}

From: Ed Otto <edotto at ux1.cso.uiuc.edu>

Read them in, and write them unformatted to a file.
FTP the ASCII file.
Read them in unformatted and write them formatted to a new file.

That will GUARANTEE the port.  I'll do it for a fee in my free time.

>2) What are the differences between the REAL*4 format on
>   VMS and Ultrix?

I don't think there any; just in the format of the file itself. (I.E.:
the record terminators are different...)

>Correct answers will be rewarded with a network cookie!
Make mine chocolate chip.


*************************************************************************
**	Edward C. Otto III	* Email:  UIPSA::OTTO                  **
**	University of Illinois  *         UIPSB::OTTO                  **
**	Printing Division	* 	  edotto at uipsuxb.ps.uiuc.edu   **
**	54A E. Gregory		* 	  edotto at ux1.cso.uiuc.edu      **
**	Champaign, IL		*         otto at uipsa.dnet.nasa.gov     **
**	217/333-9422		*				       **
*************************************************************************

	"As knowledge is to ignorance, so is light unto the darkness."

			--  GO 'PODS!  --


From: Stephan Jansen <SJANSEN at vms.macc.wisc.edu>
Hi,
 
1) If the Ultrix machine is a RISC machine, then you need to do one of
   two things: 1) convert the data to either I*2 or I*4 files, scale
   the data if it is needed, either way you need to write a program to
   do this,  or 2) send the real*4 data to the Ultrix machine and write
   a program to convert the VAX real*4 data into IEEE single precision
   (there are C runtime routines for doing the conversion).  There may
   actually be a program somewhere that does either one of these things
   to a file but I dont know where they would be.
 
   If the Ultrix machine is a VAX, then you should be able to just ftp
   the file.
 
   In both cases you want the VMS file to either be fixed-length or
   Stream-LF format files and use IMAGE when FTPing.
 
2) The VAX real*4 format is the same between VMS and Ultrix (this is
   machine dependent and not operating system dependent).  The real*4
   format on the RISC Ultrix machines is actually IEEE sigle precision
   the VMS real*4 format is the VAX  D_FLOAT format.  I dont know off-
   hand what the difference is as far as bit fields.
 
Hope this helps.
 
Stephan


From: cdl at mpl.UCSD.EDU (Carl Lowenstein)

REAL*4 format is not necessarily a function of VMS vs. Ultrix, but rather
VAX vs. IEEE.  DECstations (RISC) use IEEE format, VAXstations (vax)
don't.  Suns, NeXTs, etc. etc. use IEEE format.

So the question really depends on what kind of hardware you are porting
to, not software.  There should be a library of VAX to IEEE conversion
routines somewhere in your RISC Ultrix software.

-- 
        carl lowenstein         marine physical lab     u.c. san diego
        {decvax|ucbvax} !ucsd!mpl!cdl                 cdl at mpl.ucsd.edu
                                                  clowenstein at ucsd.edu
From: przemek at rrdstrad.nist.gov (Przemek Klosowski)

VAXes (I assume that you run VMS on a VAX :^) has different floating
point format than IEEE used on R3000-based machines like our DEC 5810.
If however you are running ultrix on VAX, you are OK here. The FTP
format you should use depends on
	- the RMS format your files are in (the easiest are fixed
	binary 512 bytes/record)
	- the FTP you use.
If they are fix/512, you should be able just to issue `bin' ftp command
and transfer. If not, I don't know.
	przemek



From: David Warren <warren at atmos.washington.edu>

The difference isn't between VMS and ULTRIX it is between the VAX and 
DECstation architecture. The MIPS chip uses ieee. If you are going to a 
DECstation, there are some undocumented system calls that translate between
VAX and ieee floating point. They can be found with man ftoi. Incase your
man pages are not loaded:
     Name
          ftoi, itof, dtoi, itod, gtoi, itog - convert floating values
          between VAX and IEEE format

     Syntax
          int ftoi(value)
              float *value;

          int itof(value)
              float *value;

          int dtoi(value)
              double *value;

          int itod(value)
              double *value;

          int gtoi(value)
              double *value;

          int itog(value)
              double *value;

     Description
          The following C library functions convert floating values between
          VAX and IEEE formats.

          The ftoi function converts the specified VAX ffloat number to
          IEEE single-precision format.  It returns zero if successful and
          nonzero without performing the conversion if not successful (for
          example, underflow).

          The itof function converts the specified IEEE single-precision
          number to VAX ffloat format.  It returns zero if successful and
          nonzero without performing the conversion if not successful (for
          example, overflow).

          The dtoi function converts the specified VAX dfloat number to
          IEEE double-precision format.  It returns zero if successful and
          nonzero without performing the conversion if not successful (for
          example, underflow).

          The itod function converts the specified IEEE double-precision
          number to VAX dfloat format.  It returns zero if successful and
          nonzero without performing the conversion if not successful (for
          example, underflow or overflow).

          The gtoi function converts the specified VAX gfloat number to
          IEEE double-precision format.  It returns zero if successful and
          nonzero without performing the conversion if not successful (for
          example, underflow).

         The itog function converts the specified IEEE double-precision
          number to VAX gfloat format.  It returns zero if successful and
          nonzero without performing the conversion if not successful (for
          example, underflow).


-- 
David Warren 		INTERNET: warren at atmos.washington.edu
(206) 543-0945		UUCP:	  uw-beaver!atmos.washington.edu!warren
Dept of Atmospheric Sciences, AK-40
University of Washington



More information about the Comp.unix.ultrix mailing list