[flang-commits] [PATCH] D112245: [flang] Support NAMELIST input of short arrays

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Oct 21 10:55:01 PDT 2021


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.

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.


https://reviews.llvm.org/D112245

Files:
  flang/runtime/connection.h
  flang/runtime/descriptor-io.h
  flang/runtime/edit-input.cpp
  flang/runtime/format.h
  flang/runtime/io-stmt.h
  flang/runtime/namelist.cpp
  flang/runtime/namelist.h
  flang/unittests/Runtime/Namelist.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112245.381328.patch
Type: text/x-patch
Size: 12266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211021/9d10cb4c/attachment-0001.bin>


More information about the flang-commits mailing list