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

Elementary question

rahzan
New Contributor I
788 Views
I have never figured out why is the logical type allows anything other than 1 byte (or really even 1 bit).

So even logical(1) has 7 bits too many, let alone logical(4).

Tim

0 Kudos
5 Replies
Steven_L_Intel1
Employee
788 Views
In the beginning (or close to it), all Fortran types were either one "arithmetic storage unit" or two. INTEGER, REAL and LOGICAL were one storage unit, COMPLEX and DOUBLE PRECISION were two. Fortran had no concept of bytes, and in fact, prior to Fortran 77, didn't even have CHARACTER. Therefore, LOGICAL was the same size as INTEGER (and in fact there is a lot of wording in the standard stating this.)

Not until Fortran 90 did the concept of "kind" come around, so that you could have LOGICALs of different sizes. But even then, Fortran had no bit datatype (as it still doesn't today.) Even so, the default LOGICAL type is the same size as default INTEGER and REAL.

For further reading, see my article It's Only Logical.

Steve
0 Kudos
rahzan
New Contributor I
788 Views
Thanks,
I will look at your article.
However, if this is a fortran quirk, why so many other lang's also have things like boolean(2).

Similarly, the fact that there is logical(4) in the com server wizid means that this oversized type is not a fortran only quirk.

just curious.

Tim
0 Kudos
Steven_L_Intel1
Employee
788 Views
Fortran now has the ability to specify different kinds (typically sizes) for LOGICAL. Note that Fortran LOGICAL is not the same as Windows return statuses (or C's bool).

I don't understand what problem you see here.

Steve
0 Kudos
rahzan
New Contributor I
788 Views
I mostly wonder why Logical(1) is not allowed as a data type in the com server interface.
0 Kudos
Steven_L_Intel1
Employee
788 Views
At the time the COM Server Wizard was written, Automation did not support an equivalent of LOGICAL(1). It may still not.

Steve
0 Kudos
Reply