Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development Tools (Compilers, Debuggers, Profilers & Analyzers)
- Intel® Fortran Compiler
- Fortran compound logical expression

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

Abedin__Abedin

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-18-2019
08:29 PM

50 Views

Fortran compound logical expression

Hi guys,

This is my first time in this community, so please forgive me if my question is sort of stupid.

I've been programming in Fortran but never claimed to be a programmer, so without further adieu here is my question:

I noticed that:

c**************************************************

real*8 :: x, y, b, c if ((x .lt. b) .and. (y .gt. c))

is not equal to:

c******************************************

real*8 :: x, y, b, c logical :: l1, l2 l1=(x.lt.b) l2=(y.gt.c) if (l1 .and. l2)

Any idea why?

I am using gfortran.

Regards,

Abedin

4 Replies

Highlighted
##

Abedin__Abedin

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-18-2019
09:41 PM

50 Views

I am so sorry!!! Please disregard this post. There was a bug in my code.

Regards,

Abedin

Highlighted
##

Juergen_R_R

Valued Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-19-2019
02:49 PM

50 Views

Can you give a full example?

Highlighted
##

FortranFan

Honored Contributor I

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-20-2019
06:38 AM

50 Views

Abedin, Abedin wrote:.. I am using gfortran. ..

For any other questions with Fortran, you may want to consider posting on forums such as comp.lang.fortran and StackOverflow.com.

For any gfortran issues, you may want to try this site: https://gcc.gnu.org/wiki/GFortran#Reporting_bugs

Highlighted
##

jimdempseyatthecove

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-20-2019
12:01 PM

50 Views

Abedin.

Seeing that you may be new to Fortran, it is important to you to realize that the evaluation rules/behavior in Fortran is * not *the same as that in C/C++/C#/...

Fortran evaluates all portions of the IF expressions, whereas C shortcuts the evaluations in left to right order

IF( (A > 0.0) .AND. ((B / A) > C) THEN...

Will (is permitted to) evaluate both sides of .AND., or right side then left side, or left side then right side, or both sides at the same time (different lanes in vector).

Whereas C in if((A>0.0) && ((B / A) > C)) will evaluate the left side of && and stop evaluating if the left side is false.

Jim Dempsey

For more complete information about compiler optimizations, see our Optimization Notice.