This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran Extensions
- To: Emily <eglass at cae dot ca>
- Subject: Re: Fortran Extensions
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Tue, 20 Jun 2000 20:01:45 +0200
- CC: gcc at gcc dot gnu dot org
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <394F62CB.FD306486@cae.ca>
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)