[Info-vax] Text processing examples with Fortran requested

glen herrmannsfeldt gah at ugcs.caltech.edu
Mon Nov 16 12:23:46 EST 2009


Bob Koehler <koehler at eisner.nospam.encompasserve.org> wrote:
> In article <iOudnQ2-U6rSIp3WnZ2dnUVZ_uOdnZ2d at giganews.com>, "Richard B. Gilbert" <rgilbert88 at comcast.net> writes:
 
>> If you use two or more, you are faced with the problem of "packing" and 
>> "unpacking" the data.  I don't believe that either Fortran II or Fortran 
>>   66 supported a character data type.
 
>   Fortran-IV (aka -66) has standard character constants in single quotes.
>   How they pack into other data types is machine dependent.  I know of
>   a large package developed on IBM mainframes Fortran-IV in which strings 
>   are routinely stuffed into arrays of REAL*8.  We ported it to a VAX
>   under VMS 2.x and these were not a problem.

Fortran IV had constants in single quotes, Fortran 66 only has the
Hollerith (1Hx) form of constants.  In both cases they are valid in
the same places, but one is easier to use.

If you want to move around and compare individual characters,
then it is much easier with one character per array element,
and the only way within the Fortran 66 standard.  Fortran IV has
datatypes of other widths.  IBM has LOGICAL*1, I believe DEC had
INTEGER*1 or some other one byte type.  In that case, one can copy
a larger variable to an EQUIVALENCEd variable, move around characters,
and copy back.  Much more work and non-standard.
 
>   We've got a ton of code developed on PDP-11 with two characters
>   per integer, that's been running for a couple of decades on VAX
>   with the simple expedient of making sure they are all explicity
>   declared INTEGER*2.

Within the Fortran 66 standard, strictly you can't even copy
(such as with an assignment statement) a variable with a Hollerith
value and be sure that the character is copied.  INTEGER variables
can be wider than the value stored in them.  (36 bits to hold a
16 bit signed integer on the 704 through 7090.)  Also, with REAL
variables some processors will normalize on assignment.  (S/360,
S/370 don't, though.)   Fortran 66 doesn't guarantee the ability
to compare two variables, even containg only one character each,
but text processing programs rely on that small extension
to the standard.

-- glen



More information about the Info-vax mailing list