cray to sun

Roger Glover glover at eastrg1.cray.com
Thu Jul 20 22:26:40 AEST 1989


>>Who knows a program to convert data, which were written in unformatted
>>structure from a fortran-program on a cray, to unformatted data for a f77
>>compiler on a sun 3/50 (sunos4.0)?

The Sun 3 uses IEEE formats for floating-point numbers (I assume your data
is floating point), so, if at all possible, you should convert the data on
the Cray (if not possible see below), using these Cray library routines:

	IESCTI:	Cray single-precision(64 bit) to IEEE single-precision(32 bit)
	IEDCTI:	Cray single-precision to IEEE double-precision(64 bit)

The calling sequence is the same for both routines:

In FORTRAN:
		CALL IEDCTI (srce, dest, iput, num, ier [, inc])
	C	REAL srce(?)		! source array of Cray data
	C	(any type) dest(?)	! destination array of IEEE data
	C	INTEGER iput		! byte within dest to start numbers,
	C				!	starting with 1
	C	INTEGER num		! number of numbers to convert
	C	INTEGER ier		! number of converted numbers whose
	C				!	exponents overflowed
	C	INTEGER inc		! (optional) increment through srce

In C (must use "-lu" on "cc" command):
	fortran void IEDCTI();
	 .
	 .
	IEDCTI (srce, dest, p_iput, p_num, p_ier[, p_inc]);
	/*	float srce[?];		! source array of Cray data
	 *	(any type) dest[?];	! destination array of IEEE data
	 *	int *p_iput;		! pointer to iput (described above)
	 *	int *p_num;		! pointer to num (described above)
	 *	int *p_ier;		! pointer to ier (described above)
	 *	int *p_inc;		! pointer to inc (described above)
	 */

IF A CRAY IS UNAVAILABLE OR UNDESIRED for this work, you can try cracking
the numbers yourself.  If the Cray file is "unblocked," the file is pure
data.  It should not be hard to write a C program which will manipulate
the bit strings as required, based on the following representations.

CRAY SINGLE-PRECISION REPRESENTATION (bit numbers from right to left):
	0-47:		mantissa
	48-62:		exponent	(biased by +40000 octal(16324 decimal))
	63:		sign bit	(0 = + ; 1 = -)

IEEE SINGLE-PRECISION REPRESENTATION (bit numbers from right to left):
	0-22:		mantissa
	23-30:		exponent	(biased by +177 octal (127 decimal))
	31:		sign bit	(0 = + ; 1 = -)

IEEE SINGLE-PRECISION REPRESENTATION (bit numbers from right to left):
	0-51:		mantissa
	52-62:		exponent	(biased by +1777 octal (1023 decimal))
	63:		sign bit	(0 = + ; 1 = -)

If the Cray file is "blocked" you will have to filter out "control words"
among the data.  Every control word is 64 bits, and the first 64 bits of
any blocked file is a control word.  The nine least significant bits of
each control word is an integer representing the number of 64-bit "data
words" between the current control word and the next control word.

Symbolic Example:
	starting	"data"		comments
	byte #
	--------	-------------	-----------------------------------
	 1		[v:w:x:y:z:2]	<- Control Word (64 bits)
	 9			22.55	<- 2 Cray Data Words (64 bits each)
	17			181.8
	25		[a:b:c:d:e:0]	<- Control Word
	33		[i:j:k:l:m:5]	<- Control Word
	 .		.
	 .		.
	 .		.

I don't know of any Sun-based program that does all this for you, but even
in the "blocked" case a C program to do these manipulations should not be
too taxing.

Roger Glover            |  "Any opinions expressed herein are mine,
Software Instructor     |   not Seymour's"
Eastern Region Office   |
Cray Research, Inc.     |  "The good news is that the new CRAY-6 prototype is
                        |   the size of a doughnut and has a one picosecond
(301)-595-2671          |   clock.  The bad new is that Mr. Patterson just
glover at eastrg1.cray.com |   dunked it in his coffee."



More information about the Comp.sys.sun mailing list