For Programmers: Free Programming Magazines  


Home > Archive > Fortran > June 2004 > Re: Function PRESENT and logical combinations









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Function PRESENT and logical combinations
Toon Moene

2004-06-25, 7:43 pm

James Giles wrote:

> I think that's a profound misinterpretation of the concept of
> "as-if". Execution is the ultimate authority on the semantic
> meaning of the program.


Depends on your definition of "execution" (and what the meaning of "is"
is - sorry, couldn't resist :-)

Given the following Fortran program:

LOGICAL FUNCTION WHATIF()
WHATIF = .FALSE.
END
PROGRAM PROG
LOGICAL WHATIF
IF (WHATIF()) THEN
PRINT*, 'WHOAH'
ELSE
PRINT*, 'YEAH, RIGHT'
ENDIF
END

and compiling with g77 -O2 -finline-functions -S, the resulting
assembler file shows that the compiler completely elided the

IF (WHATIF()) THEN
PRINT*, 'WHOAH'
ELSE
ENDIF

part and only retained the

PRINT*, 'YEAH, RIGHT'

part.

Now, depending on your definition of "execute", this might mean that the
"processor" didn't "execute" the function.

Hope this helps,

--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com