This is an archive of the discontinued LLVM Phabricator instance.

[flang] Support NAMELIST input of short arrays
ClosedPublic

Authored by klausler on Oct 21 2021, 10:54 AM.

Details

Summary

NAMELIST array input does not need to fully define an array.
If another input item begins after at least one element,
it ends input into the array and the remaining items are
not modified.

The tricky part of supporting this feature is that it's not
always easy to determine whether the next non-blank thing in
the input is a value or the next item's name, esp. in the case
of logical data where T and F can be names. E.g.,

&group logicalArray = t f f t
    = 1 /

should read three elements into "logicalArray" and then read
an integer or real variable named "t".

So the I/O runtime has to do some look-ahead to determine whether
the next thing in the input is a name followed by '=', '(', or '%'.
Since the '=' may be on a later record, possibly with intervening
NAMELIST comments, the runtime has to support a general form of
saving and restoring its current position. The infrastructure
in the I/O runtime already has to support repositioning for
list-directed repetition, even on non-positionable input sources
like terminals and sockets; this patch adds an internal RAII API
to make it easier to save a position and then do arbitrary
look-ahead.

Diff Detail

Event Timeline

klausler created this revision.Oct 21 2021, 10:54 AM
klausler requested review of this revision.Oct 21 2021, 10:54 AM
vdonaldson accepted this revision.Oct 21 2021, 12:28 PM

If we ever consider the extension of allowing '.' as an alternative to '%' for component access, that might have consequences here.

This revision is now accepted and ready to land.Oct 21 2021, 12:28 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2021, 1:38 PM