This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran Extensions
- To: "Toon Moene" <toon at moene dot indiv dot nluug dot nl>, "Emily" <eglass at cae dot ca>
- Subject: Re: Fortran Extensions
- From: "Tim Prince" <tprince at computer dot org>
- Date: Tue, 20 Jun 2000 17:34:03 -0700
- Cc: <gcc at gcc dot gnu dot org>
- References: <394F62CB.FD306486@cae.ca> <394FB189.5F1A7C95@moene.indiv.nluug.nl>
If certain of the BYTE variables are used only in LOGICAL context,
declare them accordingly. If they are used both in arithmetic and in
LOGICAL context, an even messier alternative (from the maintenance and
portability point of view) is to copy from one type to the other through
an EQUIVALENCE.
Tim Prince
----- Original Message -----
From: "Toon Moene" <toon@moene.indiv.nluug.nl>
To: "Emily" <eglass@cae.ca>
Cc: <gcc@gcc.gnu.org>
Sent: Tuesday, June 20, 2000 11:01 AM
Subject: Re: Fortran Extensions
> Emily wrote:
>
> > Since my last cry for help was so well answered, I figured I might
as
> > well try again. (But I don't want to become too dependent...)
>
> Thanks - of course, you yourself did half of the work by providing a
> simple example of your problem !
>
> > The old code that I am trying to port to linux (which compiled so
> > perfectly on AIX) declares many variables as type BYTE. My compiler
> > seems to acknowledge this data type
>
> Yes, in g77 BYTE and INTEGER*1 are synonymous (and result in one-byte
> integers being used).
>
> > but it doesn't like treating it as a
> > logical var. ie the following code is rejected...
> >
> > BYTE ELEPHANT
> > IF (ELEPHANT) THEN
> > .....
> >
> > because elephant is not a logical. I can't just declare all my BYTE
vars
> > as LOGICAL*1 vars because sometimes these vars hold numbers as
> > well...help?
>
> This is somewhat harder to solve. g77 is quite picky about using
types
> in the right way (it doesn't allow much in the way of deviations from
> the Standard here). So an INTEGER is not a LOGICAL and hence you
cannot
> use ELEPHANT (which is an INTEGER*1) in this way.
>
> The only way out that I know of is to try to determine what value of
> ELEPHANT represents "true" and what value represents "false" and then
> change all the tests to equality tests, i.e.
>
> IF (ELEPHANT .EQ. "the-truth-value") THEN
> ....
>
> Quite a lot of work, I'm afraid, but at least you'll be spared any
> further porting trouble to other compiler/operating system
combinations
> ...
>
> --
> Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346
214290
> Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
> GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
> GNU Fortran 95: http://g95.sourceforge.net/ (under construction)