🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.cray
Article #277

Re: Storage of Fortran character strings on Cray

#277
From: James Davies
Date: Thu, 17 Dec 1992 16:48
38 lines
2530 bytes
In article <MRL.92Dec16094950@sun4.uai.com> mrl@uai.com (Mark R. Ludwig) writes:
>I'd appreciate information or pointers to information about how
>Fortran character strings are stored on Cray machines.  I have the
>impression that sometimes they are word-aligned, but I don't know how
>they then honor the X3.9-1978 standard which requires adjacency of
>elements of a character array.  Perhaps only the first element of the
>array is mandatorily aligned, and rest are also aligned only if the
>length of each element is an integer multiple of 8?

They're packed 8 to a word, and aligned when possible.  The need to
make common blocks, equivalenced variables, and arrays conform to the
standard make it necessary to start things on non-word boundaries at times.
For example, Fortran 77 allows passing an array declared
	character*3 a(4)
to a subroutine and declaring it in the subroutine as
	character*4 a(3)
and both arrays have to reference the same 12 characters.  Similar
tricks can be played by equivalencing variables together or varying the
declarations in common blocks between routines.

>Hopefully related enough to not need a separate post, can someone tell
>me what the addressability is of data on Cray machines?  What does the
>machine have to do to extract an arbitrary character from a string?

Character variables are passed by descriptor.  The descriptor contains
the address of the first word, the starting offset in that word,
and the length of the variable in bytes, all packed into a 64-bit word.
The format of the descriptors varies by model, but the Cray-2 and 3 have 
the starting bit offset in the upper 6 bits of the word, the length in the
next 26 bits, and the word address in the lower 32 bits.  C character pointers
have the same format, except that the length field isn't used.

To reference an arbitrary character, you basically have to work real hard :-).
Shift and mask to extract the fields from the descriptor, load the word with
the character you want, and shift and mask some more to extract the character.

						Jim Davies
						jrbd@craycos.com
Technical Details
Message-ID: <1992Dec17.164818.2198@craycos.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!copper!aspen.craycos.com!jrbd
References: <MRL.92Dec16094950@sun4.uai.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!copper!aspen.craycos.com!jrbd
From: jrbd@craycos.com (James Davies)
Newsgroups: comp.unix.cray
Subject: Re: Storage of Fortran character strings on Cray
Message-ID: <1992Dec17.164818.2198@craycos.com>
Date: 17 Dec 92 16:48:18 GMT
References: <MRL.92Dec16094950@sun4.uai.com>
Organization: Cray Computer Corporation
Lines: 38