Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

.TRUE. versus TRUE

m_cash_stramel
ビギナー
483件の閲覧回数
I have a IVF10 DLL that is the calculation engine for a frontend application written in VB.NET 2005.

I've noticed that when I pass a Boolean/Logical from VB.NET to IVF10 as part of an argument list, when I try to evaluate it it only evaluates correctly if I type it without the "dots" before and after the TRUE.

IF ( BVAR.EQ.TRUE ) THEN

BVAR is declared this way:

LOGICAL*2, INTENT(IN) :: BVAR

And on the VB.NET side BVAR is declared this way:

Dim bVar as Boolean

However, if I declare a variable that exists solely withing the IVF10 DLL and assign it's value from with the DLL, rather that having its value passed from VB.NET, then the "dots" are necessary or it won't evaluate correctly.

IF ( CVAR.EQ..TRUE. ) THEN

CVAR is declared this way:

LOGICAL*2 CVAR

Can anyone please shed some light on this behavior? Thanks in advance.
0 件の賞賛
1 返信
Steven_L_Intel1
従業員
483件の閲覧回数
Very simply, VB (and C/C++) boolean is NOT the same as Fortran LOGICAL. Rather, it is an integer type and should be treated as such. Do not use logical operators on boolean values. You can, as you found, compare them to the integer values TRUE (1) and FALSE (0) defined in module IFWINTY, though for correctness the test should be 0=false, non-zero=true.

IFWINTY defines a BOOL kind value so you can declare these as INTEGER(BOOL).
For more information, see this article I wrote about the LOGICAL type.
返信