- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I accidentally made an error in an IF statement by writing IF (I > 0 .AND. J > K > L > 0) THEN. I presume this statement is syntactically wrong besides not being what I intended. It should have been IF (I > 0 .AND. J > K .AND. L > 0) THEN. However, the compiler and linker does not flag it as an error. Luckily I caught it before the library was updated since it represents a flaw in the intended logic of the code. Is the first statement erroneous?
program main integer :: i, j, k, l i = 1 j = 5 k = 4 l = 2 ! statement below was intended to be: if (i > 0 .and. j > k .and. l > 0) then if (i > 0 .and. j > k > l > 0) then print *, 'condition satisfied' end if read * end program main
1>------ Build started: Project: TestFINAL_IVFForum, Configuration: Debug Win32 ------ 1>Compiling with Intel(R) Visual Fortran Compiler 19.0.1.144 [IA-32]... 1>test_logical.f90 1>Linking... 1>Embedding manifest... 1> 1>Build log written to
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From: IVF document Data Type of Numeric Expressions
Integer operations: Integer operations are performed only on integer operands. (Logical entities used in a numeric context are treated as integers.)
edit And from Logical Expressions:
Logical operations on integers produce single values of integer type.
This would explain no error message, but is of little help in defining what order or what to expect.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler may be free to evaluate
(i > 0 .and. j > k > l > 0) as (i > 0 .and. (j > (k >( l > 0)))) or (i > 0 .and. (((j > k) > l) > 0)) or (i > 0 .and. ((j > k) > (l > 0))) o (i > 0 .and. (j > (k > l)) > 0) or (i > 0 .and. j > ((k > l) > 0))
I think I have all permutations
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
D:\Projects>ifort /stand t.f90 Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.1.144 Build 20181018 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. t.f90(8): warning #6192: Fortran 2008 does not allow this data type conversion. if (i > 0 .and. j > k > l > 0) then --------------------^ t.f90(8): warning #6192: Fortran 2008 does not allow this data type conversion. if (i > 0 .and. j > k > l > 0) then ------------------------^
You'd have to look at the documentation for precedence order to see how it is interpreted.

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