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

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

Link Copied

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

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

Regards,

Abedin

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

Can you give a full example?

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

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

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

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

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