Because the Fortran standard does not specify a unified memory representation of logical values.
The following is a description of GNU fortran.
5.2 Internal representation of logical variables
Fortran standard does not specify how to represent variables of logical type.
In addition to requiring logical variables of the default type to have the same storage size
Default integer and real variables. (This paragraph says that Fortran standard does not specify a unified memory representation for logical values, and the default logical values account for the same memory size as integers and real numbers. )
GNU Fortran is expressed internally as follows.
Logical (KIND=N) variables are expressed as integer (KIND=N) variables, but there are only two allowed values: 1 for. That's right. 0 stands for. Wrong ... Any other integer value will lead to undefined behavior. (This paragraph says that when GNU Fortran logic values are expressed as integers, 1 is. That's right. And 0 is. Fake. Other undefined, resulting in "undefined behavior")
Note that for mixed-language programming using the ISO_C_BINDING feature, there is a C_BOOL type that can be used to create logical (KIND=C_BOOL) variables that interoperate with the C99 _Bool type.
The C99 _Bool type has an internal representation described in the C99 standard, which is the same as the above description, that is, 1 means true, and 0 means false is the only allowed value. Therefore, in GNU Fortran, the internal representation of logical variables is the same as C99 _Bool, except that the storage size may be different according to different types.
This paper discusses the processing method in the mixed programming of Fortran and C language.