Skip to content

Conversation

mcinally
Copy link
Contributor

@mcinally mcinally commented Oct 6, 2025

Light cleanup of the IntrinsicTypes.md documentation:

  • Don't rely on GFortran for description of LOGICAL implementation.
  • Highlight some keywords.
  • Add a table for the supported TYPES and KINDS.
  • Spell out -fdefault-[real|integer]-<kind>.

@llvmbot llvmbot added the flang Flang issues not falling into any other category label Oct 6, 2025
@mcinally
Copy link
Contributor Author

mcinally commented Oct 6, 2025

Screenshots for readability...

Screenshot 2025-10-06 at 6 36 20 PM Screenshot 2025-10-06 at 6 36 46 PM Screenshot 2025-10-06 at 6 37 08 PM

@klausler klausler removed their request for review October 6, 2025 22:39
Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes, Cameron! I have one comment inlined.

DOUBLE PRECISION 8
LOGICAL 4
Modules compiled with different `-fdefault-real-<kind>` and
`-f-default-integer-<kind>` may be freely mixed. Module files encode the kind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that this is good message to send, in general. Mixing files compiled with different default kinds may cause problems for calls to subprograms without explicit interfaces.

Copy link
Contributor

@tarunprabhu tarunprabhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mcinally. I particularly appreciated the screenshots - they made things much easier.

which determines the representation method for the specified type.
The intrinsic type character also has a length type parameter called LEN,
The intrinsic type character also has a length type parameter called `LEN`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"length parameter" seems clearer to me than "length type parameter", but the same comment applies here as for "kind type parameter".

Suggested change
The intrinsic type character also has a length type parameter called `LEN`,
The intrinsic type `CHARACTER` also has a length parameter called `LEN`,

Intrinsic types are integer, real, complex, character, and logical.
All intrinsic types have a kind type parameter called KIND,
Intrinsic types are `INTEGER`, `REAL`, `COMPLEX`, `CHARACTER`, and `LOGICAL`.
All intrinsic types have a kind type parameter called `KIND`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if the term "kind type parameter" is in common use/the language used in the standard? Just "kind parameter" seems clearer to me. But if the former is the convention (or in the official standard), we should prefer that.

Suggested change
All intrinsic types have a kind type parameter called `KIND`,
All intrinsic types have a kind parameter called `KIND`

which determines the length of the character string.

The implementation of `CHARACTER` type in f18 is described
The implementation of the `CHARACTER` type in f18 is described
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to switch to using flang instead of f18. The latter is the historic name of this compiler/project, but since the the official binary is also called "flang", so we probably should be consistent.

If you don't mind this being held up a little, I can bring it up at the flang call tomorrow (Wednesday, 8 Oct), to see if the community has any objections. Does that sound reasonable?

Suggested change
The implementation of the `CHARACTER` type in f18 is described
The implementation of the `CHARACTER` type in `flang` is described

LOGICAL(KIND=2) 16-bit integer
LOGICAL(KIND=4) 32-bit integer
LOGICAL(KIND=8) 64-bit integer
### Defaults kinds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Defaults kinds
### Default kinds

* `INTEGER` 4
* `REAL` 4
* `COMPLEX` 4
* `DOUBLE PRECISION` 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOUBLE PRECISION is not in the table above. Is this intentional?

quad precision type is supported.
* No 128-bit logical support.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* No 128-bit logical support.
* 128-bit `LOGICAL` is not supported

#### Modifying the default kind with default-integer-8:
INTEGER 8
LOGICAL 8
* `REAL` 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a sentence before these bullet points clarifying that the use of -fdefault-real-8 will only affect the default kinds for the following types.


## Representation of LOGICAL variables
* `INTEGER` 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a sentence before these bullet points clarifying that the use of -fdefault-integer-8 will only affect the default kinds for the following types.

share the following characteristics:
.TRUE. is represented as 1_kind
.FALSE. is represented as 0_kind
The Fortran standard specifies that a logical has two values, `.TRUE.` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Fortran standard specifies that a logical has two values, `.TRUE.` and
The Fortran standard specifies that a `LOGICAL` has two values, `.TRUE.` and


Tests for true is *integer value is not zero*.
Flang specifies that logical literal constants with `KIND=[1|2|4|8]` share the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Flang specifies that logical literal constants with `KIND=[1|2|4|8]` share the
Flang specifies that `LOGICAL` literal constants with `KIND=[1|2|4|8]` share the

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants