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
glen herrmannsfeldt

2004-06-25, 7:43 pm

Toon Moene wrote:

(snip)

> 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, if you modify WHATIF and relink (yes, linking is not
part of the standard), what kind of result do you get?

Say, for example I change to:

LOGICAL FUNCTION WHATIF()
WHATIF = .TRUE.
END

and link with the previously compiled version?

-- glen

Sponsored Links







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

Copyright 2008 codecomments.com