Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

what does this do? UPSHIFT(I:I) = CHAR (ICHAR (STRING(I:I) ) - 40B)

1 view
Skip to first unread message

diverbeard

unread,
May 18, 2006, 5:06:56 PM5/18/06
to
Fairly new to fortran. Took a F77 class in college but never used it.
Now, I've been given some legacy fortran code and told to compile it as
a dll using Intel Fortran 8.1. It had been compiled on unix before.

Anyway, I'm working my way through the compiler errors. This one has
me stumped. Nobody here seems to have any idea what this line does.
What's the 40B?

My compiler chokes on the line with this error.

Error: Syntax error, found IDENTIFIER 'B' when expecting one of: * :: ,
<END-OF-STATEMENT> ; : ) + . - (/ [ ] /) ' ** / > // .LT. ...

Anyway, any help would be appreciated.

Thanks,

Jason

Richard E Maine

unread,
May 18, 2006, 5:25:33 PM5/18/06
to
diverbeard <jason...@ge.com> wrote:

> Anyway, I'm working my way through the compiler errors. This one has
> me stumped. Nobody here seems to have any idea what this line does.
> What's the 40B?

(You had me stumped for a minute until I looked up at the subject line.
As I was taught in technical writing, things like section and document
titles summarize, but should not replace material in the body. Newsgroup
postings aren't so formal, but it can still help to say something like
"see the subject line" in the text. Otherwise, people like me, who are a
little slow, might be confused for a while.) Anyway...

The 40B is certainly a nonstandard form for an octal constant. Yes, it
is a little strange that "B" stands for "Octal"; there are reasons, but
that doesn't matter for now. The usage is nonstandard and thus
nonportable.

In this case, by far the simplest thing to do is to relpace the 40B with
just 32, which is the decimal value. I also recognize that as the
appropriate value for doing the case conversion that this line is
clearly doing.

I'll also note that the line is specific to the ASCII character set or
derivatives of it. There are ways to do this without assuming a
particular character set. But the odds are low that you would end up
running on a machine with a character set where this doesn't work, so
I'll not digress further on that for the moment - just change the 40B to
32 for the quick and simple fix.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain

Steve Lionel

unread,
May 18, 2006, 5:39:04 PM5/18/06
to
I'd replace the 40B with ICHAR(' ') - makes it clearer what is going
on.

Steve

Brooks Moses

unread,
May 18, 2006, 5:58:22 PM5/18/06
to
Steve Lionel wrote:
> I'd replace the 40B with ICHAR(' ') - makes it clearer what is going
> on.

I'm just going to be amused at this as an example of how people think
differently. For me, it's completely counterintuitive to think of the
offset between upper and lower case letters in ASCII as being the index
of the space character -- it makes much more sense to me just to think
of it as being 32.

Does this mean a space is an uppercase null? :)

- Brooks


--
The "bmoses-nospam" address is valid; no unmunging needed.

glen herrmannsfeldt

unread,
May 18, 2006, 6:17:23 PM5/18/06
to
Someone wrote:

>> what does this do? UPSHIFT(I:I) = CHAR (ICHAR (STRING(I:I) ) - 40B)

Steve Lionel wrote:

> I'd replace the 40B with ICHAR(' ') - makes it clearer what is going
> on.

If you IXOR with ICHAR(' '), I think it works for both ASCII and EBCDIC.

More clear to me would be (ICHAR('a')-ICHAR('A')).

I would hope most compilers could do that as a constant expression
at compile time.

-- glen

James Giles

unread,
May 18, 2006, 6:44:24 PM5/18/06
to
Steve Lionel wrote:
> I'd replace the 40B with ICHAR(' ') - makes it clearer what is going
> on.

Actually it doesn't. The difference between the uppercase
and corresponding lowercase letters just happens to be the
same as the value of the blank character in the ASCII collating
sequence, but that's hardly mnemonic. Replace 40B with
ichar('a')-ichar('A') if you like.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


Dr Ivan D. Reid

unread,
May 19, 2006, 2:52:37 AM5/19/06
to
On Thu, 18 May 2006 14:58:22 -0700,
Brooks Moses <bmoses...@cits1.stanford.edu>
wrote in <446CEDFE...@cits1.stanford.edu>:

> Steve Lionel wrote:
>> I'd replace the 40B with ICHAR(' ') - makes it clearer what is going
>> on.

> I'm just going to be amused at this as an example of how people think
> differently. For me, it's completely counterintuitive to think of the
> offset between upper and lower case letters in ASCII as being the index
> of the space character -- it makes much more sense to me just to think
> of it as being 32.

> Does this mean a space is an uppercase null? :)

No, null is control-@.

--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".

Steve Lionel

unread,
May 19, 2006, 8:19:49 AM5/19/06
to
glen herrmannsfeldt wrote:

> More clear to me would be (ICHAR('a')-ICHAR('A')).

Yes, and in fact that's how I code it in similar routines I've written.
Not sure what I was thinking at the time...

Steve

diverbeard

unread,
May 19, 2006, 11:41:33 AM5/19/06
to
Thanks for the fast reply. You solved my problem and I learned
something too.

Later,

Jason

diverbeard

unread,
May 19, 2006, 11:41:37 AM5/19/06
to
0 new messages